Open jhorstmann opened 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
So there are two options now, right?
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.
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.
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):
findStepDefinitions
: https://github.com/JetBrains/intellij-plugins/blob/d9505d4fa3624aa62be26e1d866de65dae23bdf7/cucumber/src/org/jetbrains/plugins/cucumber/steps/CucumberStepsIndex.java#L119getCucumberRegexFromElement
: https://github.com/JetBrains/intellij-plugins/blob/35ea1b3433b523b7a4bf60f5a8dd9a989d254722/cucumber-java/src/org/jetbrains/plugins/cucumber/java/steps/JavaStepDefinition.java#L38isCucumberStepAnnotation
: https://github.com/JetBrains/intellij-plugins/blob/d9505d4fa3624aa62be26e1d866de65dae23bdf7/cucumber-java/src/org/jetbrains/plugins/cucumber/java/CucumberJavaUtil.java#L56The easiest solution would probably be to just use the same package name as cucumber for the zuchini annotations.
See JetBrains/intellij-plugins#552
Initial Idea:
StepDefAnnotation
fromzuchini-compat-annotations
into its own artifactzuchini-compat-step-definition
zuchini-annotations
depend on this with scopeprovided
or asoptional
StepDefAnnotation
zuchini-intellij-support
depend onzuchini-compat-step-definition