Details
-
Bug
-
Status: Open
-
Major
-
Resolution: Unresolved
-
None
-
None
-
None
Description
Consider the following:
int a = 0 // insert ( here instead of this comment and try to select anything below a = 0 a = 0 a = 0 ... (like 50 times)
With the unmatched parenthesis inserted at line 2, there is a loop in the parser looking for command arguments.
Here is a test case that demonstrates:
import groovy.transform.CompileStatic import org.codehaus.groovy.control.CompilerConfiguration import org.junit.Test import static org.codehaus.groovy.control.ParserPluginFactory.antlr2 import static org.codehaus.groovy.control.ParserPluginFactory.antlr4 @CompileStatic final class Groovy9213 { @Test(timeout=15000L) void testUnmatchedParenInLongScript2() { def config = new CompilerConfiguration() config.pluginFactory = antlr2() new GroovyShell(config).evaluate(''' int a = 0 ( ''' + ('a = 0\n' * 50)) } @Test(timeout=15000L) void testUnmatchedParenInLongScript4() { def config = new CompilerConfiguration() config.pluginFactory = antlr4(config) new GroovyShell(config).evaluate(''' int a = 0 ( ''' + ('a = 0\n' * 50)) } }
This is a problem for users editing Groovy scripts in the IDE: https://github.com/groovy/groovy-eclipse/issues/932