Skip to content

Commit e2b2e9a

Browse files
committed
- Upgrade to IDEA 2019.3.2
- Add development instructions for the gradle plugin
1 parent cf297f4 commit e2b2e9a

File tree

7 files changed

+38
-110
lines changed

7 files changed

+38
-110
lines changed

README.md

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -15,79 +15,17 @@ Enables Reference tracking of glue code when using cucumber-scala DSL.
1515
# Development
1616

1717
1. `git clone [email protected]:danielwegener/intellij-cucumber-scala.git`
18-
2. `sbt updateIdea` will download the idea sdk to the SDK folder and all required plugins
19-
3. Import the project as sbt project into IDEA.
18+
2. `./gradlew` will download the idea sdk to the SDK folder and all required plugins
19+
3. Import the project as gradle project into IDEA.
2020

21-
Now you can build this plugin with `sbt package`
22-
23-
> IntelliJ Plugin Development is too hard :/ Please provide a public (maybe non-oss, non-free) repo for Idea artifacts. Or maybe a sbt plugin.
24-
25-
To start an IDE with the plugin installed in the example project just run `sbt "runIdea example"` (_todo: does not work yet_)
26-
27-
28-
# Using a run configuration
29-
(set it to 'single instance only' so it kills the current version when restarting)
30-
31-
This is all reverse engineered (in reality playing a game of spot the difference)
32-
with the scala plugin run configurations.
33-
34-
https://github.com/JetBrains/intellij-scala/blob/8030aef21f8f726796f7230d5f29669e35ebeec9/.idea/runConfigurations/IDEA.xml#L7
35-
36-
It is quite important that scala library does not get added to the classpath etc. If there are
37-
problems run the scala plugin by
38-
39-
1. Checkout https://github.com/JetBrains/intellij-scala
40-
2. Open in Intellij
41-
3. git checkout idea as that will demangle the run configuration so it can be ran easily
42-
43-
When running a configuration to analyse the output of the run window replace : with new lines
44-
so it is diffable.
45-
46-
## Main class
47-
```
48-
com.intellij.idea.Main
49-
```
50-
51-
## VM Options (Note this is using build id 181.4445.78)
52-
```
53-
-Xmx800m
54-
-XX:ReservedCodeCacheSize=240m
55-
-XX:+HeapDumpOnOutOfMemoryError
56-
-ea
57-
-Didea.is.internal=true
58-
-Didea.debug.mode=true
59-
-Dapple.laf.useScreenMenuBar=true
60-
-Dplugin.path=target/scala-2.12/intellij-cucumber-scala_2.12-2018.1.0.jar
61-
-Didea.platform.prefix=Idea
62-
-Didea.system.path=idea/system
63-
-Didea.config.path=idea/config
64-
-Didea.plugins.path=idea/181.4445.78/externalPlugins
65-
```
66-
67-
If system and config outside of extraction directory then it is easier to
68-
purge when a new version is out. You don't have to go through the whole
69-
running for the first time wizard.
70-
71-
72-
## Use classpath of module
73-
```
74-
runner-cucumber-scala-idea
75-
```
76-
77-
## Optional but useful
78-
Under run configuration create additional before launch external tool
79-
1. Name: sbt_package
80-
2. Program: sbt
81-
3. Arguments: package
82-
83-
This will mean that a fresh plugin jar is created each time the test community
84-
edition launches from the run configuration.
21+
Now you can build this plugin with `./gradlew buildPlugin`.
8522

23+
To start an IDE with the plugin installed in the example project just run `./gradlew runIde`. Import the whole project as gradle project in the sandbox-ide. Wait for indexing to finish. Open `example/src/test/resources/cucumber/examples/scalacalculator/basic_arithmetic.feature`.
24+
8625
# Publishing
8726

88-
89-
1. Add your credentials to `ideaPublishSettings` in `build.sbt` (make sure to not check them in!)
90-
2 run `sbt publishPlugin`
27+
1. Add your publish token to `publishPlugin.token` in `cucumber-scala/build.gradle` (make sure to not check them in!)
28+
2 run `./gradlew publishPlugin`
9129

9230
# License
9331

build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
ext.versions = [
22
scala: '2.12',
3-
scalaFull: '2.12.8',
4-
cucumber: '191.7479.7',
5-
gherkin: '191.6707.7',
6-
idea: '2019.1.3',
7-
scalaPlugin: '2019.1.9'
3+
scalaFull: '2.12.7',
4+
cucumber: '193.5662.7',
5+
gherkin: '193.6015.53',
6+
idea: '2019.3.2',
7+
scalaPlugin: '2019.3.23',
88
]
99

1010
ext.libs = [
1111
jUnit : 'junit:junit:4.12',
1212
scala : "org.scala-lang:scala-library:${versions.scalaFull}",
13-
scalaTest : "org.scalatest:scalatest_${versions.scala}:3.0.5",
14-
cucumber : "info.cukes:cucumber-scala_${versions.scala}:1.2.4"
13+
cucumberScala : "info.cukes:cucumber-scala_${versions.scala}:1.2.4",
14+
cucumberJUnit : 'io.cucumber:cucumber-junit:5.1.1'
1515
]
1616

1717
subprojects {

cucumber-scala/build.gradle

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
plugins {
2-
id "org.jetbrains.intellij" version "0.4.9"
2+
id "org.jetbrains.intellij" version "0.4.16"
33
id "scala"
44
}
55

@@ -8,23 +8,24 @@ version "${versions.idea}"
88
sourceCompatibility = 1.8
99

1010
dependencies {
11-
implementation libs.scala
11+
compileOnly libs.scala
1212
}
1313

1414
intellij {
1515
pluginName 'intellij-cucumber-scala'
16-
version "IC-${versions.idea}"
16+
version "${versions.idea}"
17+
type "IC"
1718

1819
plugins = [
1920
"cucumber-java:${versions.cucumber}",
2021
"gherkin:${versions.gherkin}",
22+
"java",
2123
"org.intellij.scala:${versions.scalaPlugin}"
2224
]
2325
updateSinceUntilBuild false
2426
}
2527

2628
publishPlugin {
27-
username ''
28-
password ''
29-
channels ''
29+
token ''
30+
//channels 'default'
3031
}

cucumber-scala/src/main/resources/META-INF/plugin.xml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,9 @@
3535
]]>
3636
</change-notes>
3737

38-
<!-- please see http://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
39-
<idea-version since-build="191.0" until-build="192.0" />
38+
<idea-version since-build="193.0" until-build="194.0" />
4039

41-
<!-- please see http://confluence.jetbrains.com/display/IDEADEV/Plugin+Compatibility+with+IntelliJ+Platform+Products
42-
on how to target different products -->
43-
44-
<!--<depends>com.intellij.modules.lang</depends>-->
40+
<depends>com.intellij.modules.java</depends>
4541
<depends>gherkin</depends>
4642
<depends>org.intellij.scala</depends>
4743

cucumber-scala/src/main/scala/com/github/danielwegener/intellij/cucumber/scala/CucumberScalaExtension.scala

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,34 @@
11
package com.github.danielwegener.intellij.cucumber.scala
22

3-
import java.util.{ Collections, Collection => JavaCollection, Set => JavaSet }
3+
import java.util.{Collection => JavaCollection}
44

55
import com.github.danielwegener.intellij.cucumber.scala.steps.ScalaStepDefinition
66
import com.intellij.openapi.diagnostic.Logger
7-
import com.intellij.openapi.module.{ Module, ModuleUtilCore }
7+
import com.intellij.openapi.module.{Module, ModuleUtilCore}
88
import com.intellij.openapi.project.Project
9-
import com.intellij.psi._
109
import com.intellij.psi.search.GlobalSearchScope
10+
import com.intellij.psi.{JavaPsiFacade, PsiElement, PsiFile}
1111
import org.jetbrains.annotations.NotNull
12-
import org.jetbrains.plugins.cucumber.{ BDDFrameworkType, StepDefinitionCreator }
1312
import org.jetbrains.plugins.cucumber.psi.GherkinFile
14-
import org.jetbrains.plugins.cucumber.steps.{ AbstractCucumberExtension, AbstractStepDefinition }
13+
import org.jetbrains.plugins.cucumber.steps.{AbstractCucumberExtension, AbstractStepDefinition}
14+
import org.jetbrains.plugins.cucumber.{BDDFrameworkType, StepDefinitionCreator}
1515
import org.jetbrains.plugins.scala.ScalaFileType
1616
import org.jetbrains.plugins.scala.lang.psi
1717
import org.jetbrains.plugins.scala.lang.psi.api.ScalaFile
1818
import org.jetbrains.plugins.scala.lang.psi.api.expr.ScMethodCall
19-
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ ScTrait, ScTypeDefinition, ScClass }
19+
import org.jetbrains.plugins.scala.lang.psi.api.toplevel.typedef.{ScClass, ScTrait, ScTypeDefinition}
20+
import org.jetbrains.plugins.scala.lang.psi.stubs.util.ScalaInheritors
2021

2122
import scala.annotation.tailrec
2223
import scala.collection.JavaConverters
2324
import scala.util.Try
2425

2526
object CucumberScalaExtension {
26-
val LOG = Logger.getInstance(classOf[CucumberScalaExtension])
27+
val LOG: Logger = Logger.getInstance(classOf[CucumberScalaExtension])
2728
}
2829

2930
class CucumberScalaExtension extends AbstractCucumberExtension {
3031

31-
import com.github.danielwegener.intellij.cucumber.scala.CucumberScalaExtension._
32-
3332
val CUCUMBER_RUNTIME_SCALA_STEP_DEF_TRAIT = "cucumber.api.scala.ScalaDsl"
3433

3534
override def isStepLikeFile(@NotNull child: PsiElement, @NotNull parent: PsiElement): Boolean = {
@@ -50,20 +49,14 @@ class CucumberScalaExtension extends AbstractCucumberExtension {
5049
@NotNull
5150
override def getStepDefinitionCreator: StepDefinitionCreator = throw new UnsupportedOperationException("You cannot automatically create Steps yet.")
5251

53-
@NotNull override def getGlues(@NotNull file: GherkinFile, jGluesFromOtherFiles: JavaSet[String]): JavaCollection[String] = {
54-
// never called? wtf
55-
LOG.debug("GET GLUES CALLED")
56-
Collections.emptyList()
57-
}
58-
5952
override def loadStepsFor(featureFile: PsiFile, module: Module): java.util.List[AbstractStepDefinition] = {
6053

6154
val dependenciesScope: GlobalSearchScope = module.getModuleWithDependenciesAndLibrariesScope(true)
6255
val project: Project = featureFile.getProject
6356

6457
val stepDefs = for {
6558
cucumberDslClass <- JavaPsiFacade.getInstance(project).findClasses(CUCUMBER_RUNTIME_SCALA_STEP_DEF_TRAIT, dependenciesScope)
66-
scalaDslInheritingClass <- psi.stubs.util.ScalaStubsUtil.getClassInheritors(cucumberDslClass, dependenciesScope).collect { case sc: ScClass => sc; case sct: ScTrait => sct }
59+
scalaDslInheritingClass <- psi.stubs.util.ScalaInheritors.withStableScalaInheritors(cucumberDslClass).collect { case sc: ScClass => sc; case sct: ScTrait => sct }
6760
glueCodeClass <- classAndItsInheritors(scalaDslInheritingClass, dependenciesScope)
6861
scConstructorBody <- glueCodeClass.extendsBlock.templateBody.toSeq
6962
outerMethodCall <- scConstructorBody.getChildren.collect { case mc: ScMethodCall => mc }
@@ -80,14 +73,15 @@ class CucumberScalaExtension extends AbstractCucumberExtension {
8073
queue match {
8174
case Nil => akku
8275
case a =>
83-
val newChildren = psi.stubs.util.ScalaStubsUtil.getClassInheritors(a.head, scope)
76+
val newChildren = ScalaInheritors.findInheritorObjects(a.head)
8477
.collect { case sc: ScClass => sc; case sct: ScTrait => sct }
85-
.filterNot(akku.contains)
78+
.filterNot(akku.contains _)
8679
rec(a.tail ::: newChildren.toList, akku + a.head)
8780

8881
}
8982

9083
}
84+
9185
rec(List(parentOfHierarchy), Set.empty)
9286
}
9387

@@ -100,7 +94,7 @@ class CucumberScalaExtension extends AbstractCucumberExtension {
10094
searchScope = module.getModuleContentScope
10195
globalSearchScope = module.getModuleWithDependenciesAndLibrariesScope(true)
10296
cucumberDslClass <- JavaPsiFacade.getInstance(project).findClasses(CUCUMBER_RUNTIME_SCALA_STEP_DEF_TRAIT, globalSearchScope).toSeq
103-
scalaDslInheritingClass @ (some: ScClass) <- psi.stubs.util.ScalaStubsUtil.getClassInheritors(cucumberDslClass, searchScope)
97+
scalaDslInheritingClass@(some: ScClass) <- psi.stubs.util.ScalaInheritors.withStableScalaInheritors(cucumberDslClass)
10498
glueCodeClass <- classAndItsInheritors(scalaDslInheritingClass, searchScope)
10599
containingFile <- Try(glueCodeClass.getContainingFile).toOption
106100
} yield containingFile

cucumber-scala/src/main/scala/com/github/danielwegener/intellij/cucumber/scala/steps/ScalaStepDefinition.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import com.intellij.openapi.diagnostic.Logger
1010
import java.util.Collections
1111

1212
object ScalaStepDefinition {
13-
val LOG = Logger.getInstance(classOf[ScalaStepDefinition])
13+
val LOG: Logger = Logger.getInstance(classOf[ScalaStepDefinition])
1414
}
1515

1616
class ScalaStepDefinition(scMethod: ScMethodCall) extends AbstractStepDefinition(scMethod) {

example/build.gradle

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ description "Example project Cucumber for Scala"
77

88
dependencies {
99
implementation libs.scala
10-
10+
testCompile libs.cucumberScala
1111
testCompile libs.jUnit
12-
testCompile libs.cucumber
1312
}

0 commit comments

Comments
 (0)