Details
-
Type:
Bug
-
Status:
Resolved
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.1.1Release
-
Fix Version/s: 2.1.2Release
-
Component/s: None
-
Labels:None
-
Number of attachments :
Description
I have a simple file FFF.groovy in a grails project:
package a.b.c class FFF { int i; private void foo() {} }
if I select it in the package explorer and press Command+G (I was trying to do Alt+G, ALt+J but having mac keyboard issues, so pressed Command by accident!), I get (in the console):
BUG! exception in phase 'semantic analysis' in source unit 'FFF.groovy' commencingResolution failed: declaration found, but unexpectedly found no scope for a.b.c.FFF at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:952) at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:574) at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:550) at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:527) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.processToPhase(GroovyCompilationUnitDeclaration.java:165) at org.codehaus.jdt.groovy.internal.compiler.ast.GroovyCompilationUnitDeclaration.resolve(GroovyCompilationUnitDeclaration.java:1832) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.process(MatchLocator.java:1733) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1123) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1223) at org.eclipse.jdt.internal.core.search.matching.MatchLocator.locateMatches(MatchLocator.java:1355) at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.locateMatches(JavaSearchParticipant.java:94) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.findMatches(BasicSearchEngine.java:231) at org.eclipse.jdt.internal.core.search.BasicSearchEngine.search(BasicSearchEngine.java:515) at org.eclipse.jdt.core.search.SearchEngine.search(SearchEngine.java:582) at org.eclipse.jdt.internal.ui.search.JavaSearchQuery.run(JavaSearchQuery.java:144) at org.eclipse.search2.internal.ui.InternalSearchUI$InternalSearchJob.run(InternalSearchUI.java:91) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54) Caused by: org.codehaus.jdt.groovy.internal.compiler.ast.GroovyEclipseBug: commencingResolution failed: declaration found, but unexpectedly found no scope for a.b.c.FFF at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.commencingResolution(JDTResolver.java:578) at org.codehaus.groovy.control.ResolveVisitor.visitClass(ResolveVisitor.java:1328) at org.codehaus.groovy.control.ResolveVisitor.startResolving(ResolveVisitor.java:164) at org.codehaus.jdt.groovy.internal.compiler.ast.JDTResolver.startResolving(JDTResolver.java:626) at org.codehaus.groovy.control.CompilationUnit$1.call(CompilationUnit.java:680) at org.codehaus.groovy.control.CompilationUnit.applyToSourceUnits(CompilationUnit.java:943) ... 16 more
The scope is missing because bindings haven't been built. Bindings haven't been built because in MatchLocator.parseAndBuildBindings() the mustResolve flag is false. This situation would be OK, but unfortunately sometime later some more code runs in MatchLocator.process()
// GROOVY Start
// Do not process non-Java files. They use a separate delegated search
if (LanguageSupportFactory.isInterestingSourceFile(new String(possibleMatch.getFileName()))) {
possibleMatch.parsedUnit.resolve();
return;
}
// GROOVY End
That call to resolve is what leads to the exception above because the scope is missing. If a buildTypeBindings is added ahead of the resolve:
this.lookupEnvironment.buildTypeBindings(possibleMatch.parsedUnit, null /*no access restriction*/);
then the exception goes away as the scope is correct by the time it is referenced. Not my code though so I don't know if this is the right thing to do and I don't know which tests to run to verify the change.
committed the change with a big try catch round it. Let's see if it gets through the tests.