jhorstmann / zuchini

A reimplementation of gherkin and cucumber for java based on antlr4 and junit
11 stars 3 forks source link

Support intellij navigation with zuchini annotations #19

Open jhorstmann opened 7 years ago

jhorstmann commented 7 years ago

Initial Idea:

jhorstmann commented 7 years ago

Unfortunately does not work since the intellij plugin does not look for the meta annotation, but for the package name of the annotations, see https://github.com/JetBrains/intellij-plugins/blob/35ea1b3433b523b7a4bf60f5a8dd9a989d254722/cucumber-java/src/org/jetbrains/plugins/cucumber/java/steps/AnnotationPackageProvider.java and https://github.com/JetBrains/intellij-plugins/blob/35ea1b3433b523b7a4bf60f5a8dd9a989d254722/cucumber-java/src/org/jetbrains/plugins/cucumber/java/CucumberJavaUtil.java

whiskeysierra commented 7 years ago

So there are two options now, right?

  1. Change the IntelliJ plugin to check for meta annotations (and follow the initial idea) or
  2. Stick with compatible annotations.
jhorstmann commented 7 years ago

I'd prefer (1), but I have no idea about the effort to get this change into the intellij plugin. Maybe there is also a simpler fix in the plugin, this https://github.com/JetBrains/intellij-plugins/blob/35ea1b3433b523b7a4bf60f5a8dd9a989d254722/cucumber-java/src/org/jetbrains/plugins/cucumber/java/CucumberJavaUtil.java#L64 seems to be comparing qualified names with simple names, if it just compared simple names it would also work for zuchini annotations.

jhorstmann commented 7 years ago

Maybe I looked in the wrong place, https://github.com/JetBrains/intellij-plugins/blob/35ea1b3433b523b7a4bf60f5a8dd9a989d254722/cucumber-java/src/org/jetbrains/plugins/cucumber/java/CucumberJavaExtension.java#L43 seems to do exactly what we want. Maybe the code from previous comments is for generating code snippets. Still does not work though.

jhorstmann commented 6 years ago

Finally got around to debug this. Intellij is building a correct index of step definitions based on the StepDefAnnotation meta annotation, but is using explicit package names when trying to extract the regex for matching.

The call stack (some levels omitted):

The easiest solution would probably be to just use the same package name as cucumber for the zuchini annotations.

jhorstmann commented 6 years ago

See JetBrains/intellij-plugins#552