Skip to content

Commit

Permalink
Merge pull request #1 from intuit/master
Browse files Browse the repository at this point in the history
Merge into my fork
  • Loading branch information
salilbc authored Oct 5, 2020
2 parents 3aa8915 + 70f1f01 commit 6e91381
Show file tree
Hide file tree
Showing 13 changed files with 39 additions and 43 deletions.
10 changes: 5 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ buildscript {

repositories {
mavenCentral()
maven { url 'http://dl.bintray.com/jetbrains/intellij-plugin-service' }
maven { url 'https://dl.bintray.com/jetbrains/intellij-plugin-service' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Expand Down Expand Up @@ -60,17 +60,17 @@ jar {
}

from {
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) }
configurations.runtimeClasspath.collect { it.isDirectory() ? it : zipTree(it) }
}
}


dependencies {
compileProcessBuilder
compile "com.fasterxml.jackson.core:jackson-core:2.9.9"
compile "com.fasterxml.jackson.core:jackson-databind:2.9.9"
implementation "com.fasterxml.jackson.core:jackson-core:2.9.9"
implementation "com.fasterxml.jackson.core:jackson-databind:2.9.9"
compileOnly "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
testCompile "org.hamcrest:hamcrest-all:1.3"
testImplementation "org.hamcrest:hamcrest-all:1.3"
}


Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.intuit.ddb

import com.intellij.execution.ExecutorRegistry
import com.intellij.execution.Executor
import com.intellij.execution.Location
import com.intellij.execution.PsiLocation
import com.intellij.execution.RunManagerEx
Expand Down Expand Up @@ -28,6 +28,6 @@ class DockDockBuildRunTargetAction(private val target: MakefileTarget) : AnActio
val configuration = producer.findOrCreateConfigurationFromContext(context)?.configurationSettings ?: return

(context.runManager as RunManagerEx).setTemporaryConfiguration(configuration)
ExecutionUtil.runConfiguration(configuration, ExecutorRegistry.getInstance().registeredExecutors.first())
ExecutionUtil.runConfiguration(configuration, Executor.EXECUTOR_EXTENSION_NAME.extensionList.first())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,10 @@ class MakefileAnnotator : Annotator {
}

if (!targetReferences && !fileReferenceResolved) {
holder.createWeakWarningAnnotation(element, "Unresolved prerequisite").registerFix(CreateRuleFix(element))
holder.newAnnotation(HighlightSeverity.WEAK_WARNING, "Unresolved prerequisite").range(element)
.withFix(CreateRuleFix(element)).create()
} else if (unresolvedFile != null) {
holder.createWeakWarningAnnotation(unresolvedFile!!, "File not found")
holder.newAnnotation(HighlightSeverity.WEAK_WARNING, "File not found").range(unresolvedFile!!).create()
}
}
} else if (element is MakefileVariable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.intellij.openapi.fileTypes.*
import com.intellij.openapi.util.IconLoader
import javax.swing.Icon

val MakefileIcon = IconLoader.getIcon("/ddb/icon/DockDockBuild15pxl.png")
val MakefileIcon = IconLoader.getIcon("/ddb/icon/DockDockBuild15pxl.png", MakefileFileType::class.java)
val MakefileTargetIcon = AllIcons.RunConfigurations.TestState.Run!!

class MakefileFileType : LanguageFileType(MakefileLanguage) {
Expand Down
8 changes: 8 additions & 0 deletions src/test/kotlin/DockDockTestCase.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import com.intellij.testFramework.fixtures.BasePlatformTestCase

/**
* Base test case for the DockDockBuild tests using fixtures.
*/
abstract class DockDockTestCase : BasePlatformTestCase() {
final override fun getTestDataPath() = "testData"
}
6 changes: 2 additions & 4 deletions src/test/kotlin/MakefileCompletionTest.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase

class MakefileCompletionTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileCompletionTest : DockDockTestCase() {
fun testSimple() = doTest("b", "c", "d", "${getTestName(true)}.mk")
fun testTargets() = doTest("a", "${getTestName(true)}.mk")

fun doTest(vararg variants: String) = myFixture.testCompletionVariants("$testDataPath/$basePath/${getTestName(true)}.mk", *variants)
fun doTest(vararg variants: String) = myFixture.testCompletionVariants("$basePath/${getTestName(true)}.mk", *variants)

override fun getTestDataPath() = "testData"
override fun getBasePath() = "completion"
}
6 changes: 2 additions & 4 deletions src/test/kotlin/MakefileCreateRuleQuickfixTest.kt
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase

class MakefileCreateRuleQuickfixTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileCreateRuleQuickfixTest : DockDockTestCase() {
fun testSimple() = doTest()
fun testMiddle() = doTest()


fun doTest() {
myFixture.configureByFile("$testDataPath/$basePath/${getTestName(true)}.mk")
myFixture.configureByFile("$basePath/${getTestName(true)}.mk")
val intention = myFixture.findSingleIntention("Create Rule")
myFixture.launchAction(intention)
myFixture.checkResultByFile("$basePath/${getTestName(true)}.gold.mk")
}

override fun getTestDataPath() = "testData"
override fun getBasePath() = "quickfix/createRule"
}
8 changes: 3 additions & 5 deletions src/test/kotlin/MakefileFindUsagesTest.kt
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import com.intellij.codeInsight.TargetElementUtil
import com.intellij.find.FindManager
import com.intellij.find.impl.FindManagerImpl
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase
import org.hamcrest.collection.IsCollectionWithSize.hasSize
import org.hamcrest.core.IsNull.nullValue
import org.junit.Assert.assertThat

class MakefileFindUsagesTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileFindUsagesTest : DockDockTestCase() {
fun testSimple() {
val usages = myFixture.testFindUsages("$testDataPath/$basePath/${getTestName(true)}.mk")
val usages = myFixture.testFindUsages("$basePath/${getTestName(true)}.mk")

assertThat(usages, hasSize(2))
}
Expand All @@ -17,13 +16,12 @@ class MakefileFindUsagesTest : LightPlatformCodeInsightFixtureTestCase() {
fun testForce() = notSearchableForUsages()

fun notSearchableForUsages() {
myFixture.configureByFiles("$testDataPath/$basePath/${getTestName(true)}.mk")
myFixture.configureByFiles("$basePath/${getTestName(true)}.mk")
val targetElement = TargetElementUtil.findTargetElement(myFixture.editor, TargetElementUtil.ELEMENT_NAME_ACCEPTED or TargetElementUtil.REFERENCED_ELEMENT_ACCEPTED)
val handler = (FindManager.getInstance(project) as FindManagerImpl).findUsagesManager.getFindUsagesHandler(targetElement!!, false)

assertThat(handler, nullValue())
}

override fun getTestDataPath() = "testData"
override fun getBasePath() = "findUsages"
}
4 changes: 1 addition & 3 deletions src/test/kotlin/MakefileFoldingTest.kt
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase

class MakefileFoldingTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileFoldingTest : DockDockTestCase() {
fun testRule() = doTest()
fun testVariable() = doTest()
fun testDefine() = doTest()


fun doTest() = myFixture.testFolding("$testDataPath/$basePath/${getTestName(true)}.mk")

override fun getTestDataPath() = "testData"
override fun getBasePath() = "folding"
}
9 changes: 5 additions & 4 deletions src/test/kotlin/MakefileHighlightingTest.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase

class MakefileHighlightingTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileHighlightingTest : DockDockTestCase() {
fun testUnresolved() = doTest()
fun testRedundant() = doTest(true)
fun testTargetspecificvars() = doTest()

fun doTest(checkInfos: Boolean = false) { myFixture.testHighlighting(true, checkInfos, true, "$testDataPath/$basePath/${getTestName(true)}.mk") }
fun doTest(checkInfos: Boolean = false) {
myFixture.testHighlighting(true, checkInfos, true,
"$basePath/${getTestName(true)}.mk")
}

override fun getTestDataPath() = "testData"
override fun getBasePath() = "highlighting"
}
6 changes: 2 additions & 4 deletions src/test/kotlin/MakefileRemoveRuleQuickfixTest.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase

class MakefileRemoveRuleQuickfixTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileRemoveRuleQuickfixTest : DockDockTestCase() {
fun testSingle() = doTest()
fun testTwo() = doTest()

fun doTest() {
myFixture.configureByFile("$testDataPath/$basePath/${getTestName(true)}.mk")
myFixture.configureByFile("$basePath/${getTestName(true)}.mk")
val intention = myFixture.findSingleIntention("Remove Empty Rule")
myFixture.launchAction(intention)
myFixture.checkResultByFile("$basePath/${getTestName(true)}.gold.mk")
}

override fun getTestDataPath() = "testData"
override fun getBasePath() = "quickfix/removeRule"
}
8 changes: 3 additions & 5 deletions src/test/kotlin/MakefileStructureViewTest.kt
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import com.intellij.testFramework.*
import com.intellij.testFramework.fixtures.*
import com.intellij.testFramework.PlatformTestUtil

class MakefileStructureViewTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileStructureViewTest : DockDockTestCase() {
fun testSimple() {
val filename = "${getTestName(true)}.mk"
myFixture.configureByFile("$testDataPath/$basePath/$filename")
myFixture.configureByFile("$basePath/$filename")
myFixture.testStructureView {
PlatformTestUtil.expandAll(it.tree)
PlatformTestUtil.assertTreeEqual(it.tree, "-simple.mk\n all\n hello\n world\n")
}
}

override fun getTestDataPath() = "testData"
override fun getBasePath() = "structure"
}
6 changes: 2 additions & 4 deletions src/test/kotlin/MakefileTargetRenameTest.kt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import com.intellij.testFramework.fixtures.LightPlatformCodeInsightFixtureTestCase

class MakefileTargetRenameTest : LightPlatformCodeInsightFixtureTestCase() {
class MakefileTargetRenameTest : DockDockTestCase() {
fun testSimple() = doTest("qwerty")


fun doTest(newName: String) {
myFixture.configureByFile("$testDataPath/$basePath/${getTestName(true)}.mk")
myFixture.configureByFile("$basePath/${getTestName(true)}.mk")
myFixture.renameElementAtCaret(newName)
myFixture.checkResultByFile("$basePath/${getTestName(true)}.gold.mk")
}

override fun getTestDataPath() = "testData"
override fun getBasePath() = "rename"
}

0 comments on commit 6e91381

Please sign in to comment.