rlogiacco / Natural

Natural is a collection of Eclipse plugins to enable rich smart editing of acceptance tests using natural language definition files. It currently supports Cucumber and JBehave syntax.
Eclipse Public License 1.0
75 stars 37 forks source link

CTRL-Click not working when using composed Regex #50

Closed gjobin closed 3 years ago

gjobin commented 7 years ago

We've been investigating an issue with CTRL+Click not working when one of our project is loaded.

We noticed that if a project that contains steps defs as below is loaded, it will not work, and generate entry logs in eclipse when trying to CTRL+Click on a step. This should be taken as a regression since is was reported to be working on previous versions of the plugin or eclipse. Tests are valid and runs without problem.

Thanks for your help.

protected static final String REF_PATTERN = "(\\s*\\w+\\s*(?:,\\s*\\w+\\s*)*)";
@When("^I request events " + REF_PATTERN + " by ID$")
public void whenGetEventsById(List<String> refs) {
   ...
}

The error that is generated in eclipse using Natural 0.7.6

eclipse.buildId=4.6.2.M20161124-1400
java.version=1.8.0_121
java.vendor=Oracle Corporation
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_CA
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os linux -ws gtk -arch x86_64 -product org.eclipse.epp.package.jee.product

org.eclipse.ui
Error
Tue Mar 07 11:12:20 EST 2017
Unhandled event loop exception

java.lang.NullPointerException

!ENTRY org.eclipse.ui 4 0 2017-03-07 11:11:29.218
!MESSAGE Unhandled event loop exception
!STACK 0
java.lang.NullPointerException
    at java.util.regex.Pattern.<init>(Pattern.java:1350)
    at java.util.regex.Pattern.compile(Pattern.java:1028)
    at java.util.regex.Pattern.matches(Pattern.java:1133)
    at java.lang.String.matches(String.java:2121)
    at org.agileware.natural.common.JavaAnnotationMatcher.findMatches(JavaAnnotationMatcher.java:71)
    at org.agileware.natural.cucumber.ui.CucumberHyperlinkHelper.findLinkTargets(CucumberHyperlinkHelper.java:54)
    at org.agileware.natural.cucumber.ui.CucumberHyperlinkHelper.createHyperlinksByOffset(CucumberHyperlinkHelper.java:47)
    at org.eclipse.xtext.ui.editor.hyperlinking.DefaultHyperlinkDetector$1.exec(DefaultHyperlinkDetector.java:48)
    at org.eclipse.xtext.ui.editor.hyperlinking.DefaultHyperlinkDetector$1.exec(DefaultHyperlinkDetector.java:1)
    at org.eclipse.xtext.resource.OutdatedStateManager.exec(OutdatedStateManager.java:98)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.internalReadOnly(XtextDocument.java:520)
    at org.eclipse.xtext.ui.editor.model.XtextDocument$XtextDocumentLocker.readOnly(XtextDocument.java:492)
    at org.eclipse.xtext.ui.editor.model.XtextDocument.readOnly(XtextDocument.java:133)
    at org.eclipse.xtext.ui.editor.hyperlinking.DefaultHyperlinkDetector.detectHyperlinks(DefaultHyperlinkDetector.java:39)
    at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:287)
    at org.eclipse.jface.text.hyperlink.HyperlinkManager.findHyperlinks(HyperlinkManager.java:259)
    at org.eclipse.jface.text.hyperlink.HyperlinkManager.mouseMove(HyperlinkManager.java:455)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:213)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:5227)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1340)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4561)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:4151)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$4.run(PartRenderingEngine.java:1121)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.run(PartRenderingEngine.java:1022)
    at org.eclipse.e4.ui.internal.workbench.E4Workbench.createAndRunUI(E4Workbench.java:150)
    at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:693)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:610)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:148)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:138)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:134)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:104)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:388)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:243)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:673)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:610)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1519)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1492)
gjobin commented 7 years ago

Also please note that the following works :

@When("^I request events " + "(\\s*\\w+\\s*(?:,\\s*\\w+\\s*)*)" + " by ID$")
public void whenGetEventsById(List<String> refs) {
   ...
}
rlogiacco commented 7 years ago

First of all thanks for the report. I hardly believe constants replacement has ever worked because the matching algorithm between steps and stepdefs has always relied on string matching.

I understand this capability can be quite useful, but it might also be quite difficult to implement and I've also been unable to find any help in bringing this project forward: apparently everyone wants additional features implemented but nobody has time to learn or do it :-)

If you wish to change this trend I will be very happy to have you onboard.

github-actions[bot] commented 3 years ago

This issue has not been updated for a while: marking it as stale.