groovy / groovy-eclipse

Eclipse Groovy Development Tools
655 stars 193 forks source link

Eclipse 4.6.1 hangs sometimes during code proposal #223

Closed wagnerma closed 7 years ago

wagnerma commented 7 years ago

First, thanks for your work! Sure, I also installed the newest version and I observe sometimes a complete hang of eclipse (4.6.1) during code proposals. Hope the following stack trace helps:

java.lang.StringIndexOutOfBoundsException: String index out of range: -1 at java.lang.String.substring(Unknown Source) at org.codehaus.groovy.eclipse.quickfix.proposals.AddClassCastResolver$AddClassCastProposal.calculateTypeName(AddClassCastResolver.java:90) at org.codehaus.groovy.eclipse.quickfix.proposals.AddClassCastResolver$AddClassCastProposal.<init>(AddClassCastResolver.java:60) at org.codehaus.groovy.eclipse.quickfix.proposals.AddClassCastResolver.getQuickFixProposals(AddClassCastResolver.java:43) at org.codehaus.groovy.eclipse.quickfix.processors.GroovyQuickFixProcessor.getCorrections(GroovyQuickFixProcessor.java:73) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionCollector.safeRun(JavaCorrectionProcessor.java:384) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.run(JavaCorrectionProcessor.java:344) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor$SafeCorrectionProcessorAccess.process(JavaCorrectionProcessor.java:339) at org.eclipse.jdt.internal.ui.text.correction.JavaCorrectionProcessor.collectCorrections(JavaCorrectionProcessor.java:474) at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getJavaAnnotationFixes(ProblemHover.java:102) at org.eclipse.jdt.internal.ui.text.java.hover.ProblemHover$ProblemInfo.getCompletionProposals(ProblemHover.java:76) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.deferredCreateContent(AbstractAnnotationHover.java:287) at org.eclipse.jdt.internal.ui.text.java.hover.AbstractAnnotationHover$AnnotationInformationControl.setInput(AbstractAnnotationHover.java:187) at org.eclipse.jface.text.AbstractInformationControlManager.internalShowInformationControl(AbstractInformationControlManager.java:1194) at org.eclipse.jface.text.AbstractInformationControlManager.presentInformation(AbstractInformationControlManager.java:1163) at org.eclipse.jface.text.AbstractHoverInformationControlManager.presentInformation(AbstractHoverInformationControlManager.java:894) at org.eclipse.jface.text.TextViewerHoverManager.doPresentInformation(TextViewerHoverManager.java:244) at org.eclipse.jface.text.TextViewerHoverManager$5.run(TextViewerHoverManager.java:234) at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35) at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:182) at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4203) at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3819) 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:687) at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:336) at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:604) 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(Unknown Source) at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.lang.reflect.Method.invoke(Unknown Source) 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)

eric-milles commented 7 years ago

This is where the exception comes from:

        private String calculateTypeName() {
            String message = getQuickFixProblemContext().getProblemDescriptor().getMarkerMessages()[0];
            String name = message.substring(message.lastIndexOf(" ") + 1);

Would you happen to have the text of the problem marker you are trying to run the quick-fix on?

wagnerma commented 7 years ago

I try to reproduce it, at the moment without success. I will report all exceptions I get. Another one:

java.util.ConcurrentModificationException at java.util.ArrayList$Itr.checkForComodification(Unknown Source) at java.util.ArrayList$Itr.next(Unknown Source) at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.FilteringPointcut.filterResult(FilteringPointcut.java:71) at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.FilteringPointcut.matches(FilteringPointcut.java:59) at org.codehaus.groovy.eclipse.dsl.pointcuts.AbstractPointcut.matchOnPointcutArgument(AbstractPointcut.java:119) at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.FilteringPointcut.matches(FilteringPointcut.java:57) at org.codehaus.groovy.eclipse.dsl.pointcuts.AbstractPointcut.matchOnPointcutArgument(AbstractPointcut.java:119) at org.codehaus.groovy.eclipse.dsl.pointcuts.impl.CurrentTypePointcut.matches(CurrentTypePointcut.java:61) at org.codehaus.groovy.eclipse.dsl.DSLDStore.findContributions(DSLDStore.java:132) at org.codehaus.groovy.eclipse.dsl.lookup.DSLDTypeLookup.lookupTypeAndDeclaration(DSLDTypeLookup.java:84) at org.eclipse.jdt.groovy.search.AbstractSimplifiedTypeLookup.lookupType(AbstractSimplifiedTypeLookup.java:133) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.lookupExpressionType(TypeInferencingVisitorWithRequestor.java:2033) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.handleSimpleExpression(TypeInferencingVisitorWithRequestor.java:2002) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstantExpression(TypeInferencingVisitorWithRequestor.java:1433) at org.codehaus.groovy.ast.expr.ConstantExpression.visit(ConstantExpression.java:83) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1606) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) at org.codehaus.groovy.ast.CodeVisitorSupport.visitListOfExpressions(CodeVisitorSupport.java:278) at org.codehaus.groovy.ast.CodeVisitorSupport.visitTupleExpression(CodeVisitorSupport.java:183) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitTupleExpression(TypeInferencingVisitorWithRequestor.java:1887) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitArgumentlistExpression(TypeInferencingVisitorWithRequestor.java:939) at org.codehaus.groovy.ast.expr.ArgumentListExpression.visit(ArgumentListExpression.java:76) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitMethodCallExpression(TypeInferencingVisitorWithRequestor.java:1625) at org.codehaus.groovy.ast.expr.MethodCallExpression.visit(MethodCallExpression.java:66) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBooleanExpression(CodeVisitorSupport.java:171) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBooleanExpression(TypeInferencingVisitorWithRequestor.java:1169) at org.codehaus.groovy.ast.expr.BooleanExpression.visit(BooleanExpression.java:42) at org.codehaus.groovy.ast.CodeVisitorSupport.visitAssertStatement(CodeVisitorSupport.java:82) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitAssertStatement(ClassCodeVisitorSupport.java:246) at org.codehaus.groovy.ast.stmt.AssertStatement.visit(AssertStatement.java:50) at org.codehaus.groovy.ast.CodeVisitorSupport.visitBlockStatement(CodeVisitorSupport.java:40) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitBlockStatement(ClassCodeVisitorSupport.java:251) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitBlockStatement(TypeInferencingVisitorWithRequestor.java:1367) at org.codehaus.groovy.ast.stmt.BlockStatement.visit(BlockStatement.java:71) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitClassCodeContainer(ClassCodeVisitorSupport.java:148) at org.codehaus.groovy.ast.ClassCodeVisitorSupport.visitConstructorOrMethod(ClassCodeVisitorSupport.java:159) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitConstructorOrMethod(TypeInferencingVisitorWithRequestor.java:814) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:565) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitJDT(TypeInferencingVisitorWithRequestor.java:395) at org.eclipse.jdt.groovy.search.TypeInferencingVisitorWithRequestor.visitCompilationUnit(TypeInferencingVisitorWithRequestor.java:350) at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.internalFindOccurences(GroovyOccurrencesFinder.java:180) at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.getOccurrences(GroovyOccurrencesFinder.java:102) at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1249) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3364) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:182) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55)

eric-milles commented 7 years ago

That's the problem with DSLDStore that comes up from time to time. I tried to protect the maps, but they contain lists that are not synchronized. I may get old-school and use Hashtable<String, Vector>. Otherwise, the interface needs to be refactored so that these lookups and additions are properly synchronized.

wagnerma commented 7 years ago

Another problem exists, when working with multiple opened groovy files containing errors, then you get unlimited exceptions clicking in the editor window:

`eclipse.buildId=4.6.1.M20160907-1200 java.version=1.8.0_112 java.vendor=Oracle Corporation BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=de_DE Framework arguments: -product org.eclipse.epp.package.jee.product Command-line arguments: -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product -clean

org.eclipse.core.jobs Error Mon Nov 14 11:02:18 CET 2016 An internal error occurred during: "Requesting Java AST from selection".

java.lang.StringIndexOutOfBoundsException: String index out of range: -19 at java.lang.String.substring(Unknown Source) at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.visitClass(ASTNodeFinder.java:124) at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.visitClass(ASTNodeFinder.java:205) at org.codehaus.groovy.eclipse.codebrowsing.requestor.ASTNodeFinder.doVisit(ASTNodeFinder.java:77) at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.findNodeForRegion(CodeSelectHelper.java:172) at org.codehaus.groovy.eclipse.codebrowsing.requestor.CodeSelectHelper.selectASTNode(CodeSelectHelper.java:100) at org.codehaus.groovy.eclipse.search.GroovyOccurrencesFinder.initialize(GroovyOccurrencesFinder.java:221) at org.codehaus.groovy.eclipse.editor.GroovyEditor.updateOccurrenceAnnotations(GroovyEditor.java:1248) at org.eclipse.jdt.internal.ui.javaeditor.JavaEditor$6.selectionChanged(JavaEditor.java:3364) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup.calculateASTandInform(SelectionListenerWithASTManager.java:182) at org.eclipse.jdt.internal.ui.viewsupport.SelectionListenerWithASTManager$PartListenerGroup$3.run(SelectionListenerWithASTManager.java:158) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:55) `

eric-milles commented 7 years ago

Would you mind sending just the class declaration line of the open file or files when this happens? ASTNodeFinder is trying to look after the class name or its last generic type and before the opening {. In this example, the code hover may be on SomethingElse or SomeInterface, but they don't always have source location information.

public class Something extends SomethingElse implements SomeInterface {
wagnerma commented 7 years ago

Sure the Groovy class:

@CompileStatic public class SvBoDocNewImpl extends SvBoDocNewImplBase {

And the Base Java Class:

public abstract class SvBoDocNewImplBase extends ServiceBase<de.effectivecompany.app.doc.service.SvBoDocNew> implements de.effectivecompany.app.doc.service.SvBoDocNew

And the interface:

@net.bull.javamelody.MonitoredWithSpring @Transactional(readOnly = true, propagation = Propagation.SUPPORTS, rollbackFor = Exception.class) public interface SvBoDocNew

wagnerma commented 7 years ago

...and the ServiceBase is:

public abstract class ServiceBase<S>

eric-milles commented 7 years ago

Thanks. Could you try changing SvBoDocNew to an import to see if it makes a difference? I think the generics part is where the code is braking down.

wagnerma commented 7 years ago

..well, strange I can't reproduce it any more, with or without the import... but a colleague has the problem, with and without the import...strange, I will verify with the newest build and a clean Eclipse setup..

One cosmetic thing, if you start Eclipse with opened groovy files, the g Icon in the editor tap is displayed, activating the editor tap, the g changes to j, like Java files.

eric-milles commented 7 years ago

You mentioned this last error happened when you had syntax or compile errors. Can you recall where in the class the error was and what editing action you were taking when the error came?

wagnerma commented 7 years ago

At the moment, I can't reproduce it any more, but colleagues will try...

Another compile error I have from time to time:

` @CompileStatic public class FrBoDoc extends EFCFrTd {

private static final long serialVersionUID = -1L;   

` Then the -1L is a compile error: The literal -1L of type long is out of range

wagnerma commented 7 years ago

Has something to do with the CompileStatic annotation, removing it, the error disappears. But other classes with the same structure have no problems with this combination, only this one. Hmmm, making a compile error in the FrBoDoc class with the long error, all classes referencing the error FrBoDoc will also get the type long is out of range error and correctly the references of the FrBoDoc class are marked error.

eric-milles commented 7 years ago

Are you using the latest 2.9.2 snapshot? Number literals with a leading + or - required a fix for source position and this is likely why the literal is improperly formed.

wagnerma commented 7 years ago

No, indeed the latest build fixes it. Thanks!

Please close this bug report, I will open a new one, when I find a new reproduceable one.