This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 124912 - Gstring in source breaks token recognition
Summary: Gstring in source breaks token recognition
Status: RESOLVED FIXED
Alias: None
Product: groovy
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: schmidtm
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-01-08 19:39 UTC by schmidtm
Modified: 2008-10-30 14:24 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
AccountController.groovy (5.79 KB, text/plain)
2008-01-08 19:40 UTC, schmidtm
Details
EntriesController.groovy (3.22 KB, text/plain)
2008-01-17 08:09 UTC, schmidtm
Details
LoginController.groovy (2.16 KB, text/plain)
2008-01-17 08:11 UTC, schmidtm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description schmidtm 2008-01-08 19:39:26 UTC
If one loads the testcase given in the attachment, you'll see the token recognition mixed-up and out of sync when ${var} type of strings are in string 
constants. See lines # 40/41, 91/92, etc.
Comment 1 schmidtm 2008-01-08 19:40:42 UTC
Created attachment 54831 [details]
AccountController.groovy
Comment 2 schmidtm 2008-01-09 13:20:37 UTC
One additional information: It seems that only full syntax gstrings ( ${id} ) break the editor. Have a look, how this
looks in the editor:

// Groovy source file

def name='World'

println "Hello $name"
println "Hello ${name}"
assert true

println """
Test 1
and yet another line
"""
println """
Test 2
and yet another line
Now with Gstring simple = $name
"""

println """
Test 3
and yet another line
And with Gstring full = ${name}
"""

println """
Test 4
and yet another line
Now with Gstring simple = $name
And with Gstring full = ${name}
"""

println "end of run."
Comment 3 schmidtm 2008-01-09 16:25:33 UTC
I've added a little testcase to demonstrate this bug a bit more:

http://www.netbeans.org/source/browse/scripting/groovy/editor/test/unit/src/org/netbeans/modules/groovy/editor/GroovyLexerBatchTest.java?r1=1.7&r2=1.8

it gives:

Testcase: testFullSyntaxGstring(org.netbeans.modules.groovy.editor.GroovyLexerBatchTest):	FAILED
Invalid token.id() for text="}" expected:<org.netbeans.modules.groovy.editor.lexer.GroovyTokenId:GSF_RBRACE:26> but
was:<org.netbeans.modules.groovy.editor.lexer.GroovyTokenId:GSF_STRING_LITERAL:17>
junit.framework.AssertionFailedError: Invalid token.id() for text="}"
expected:<org.netbeans.modules.groovy.editor.lexer.GroovyTokenId:GSF_RBRACE:26> but
was:<org.netbeans.modules.groovy.editor.lexer.GroovyTokenId:GSF_STRING_LITERAL:17>
        at org.netbeans.lib.lexer.test.LexerTestUtilities.assertTokenEquals(LexerTestUtilities.java:112)
        at org.netbeans.lib.lexer.test.LexerTestUtilities.assertTokenEquals(LexerTestUtilities.java:98)
        at org.netbeans.modules.groovy.editor.GroovyLexerBatchTest.testFullSyntaxGstring(GroovyLexerBatchTest.java:138)

So the input line:

String text = "def name = 'World'; println \"Hello, ${name}\"";

causes the lexer to tread the closing brace to be a GSF_STRING_LITERAL rather than a GSF_RBRACE
Comment 5 schmidtm 2008-01-17 08:09:57 UTC
Created attachment 55180 [details]
EntriesController.groovy
Comment 6 schmidtm 2008-01-17 08:11:17 UTC
Created attachment 55181 [details]
LoginController.groovy
Comment 7 schmidtm 2008-01-17 08:14:36 UTC
Hi, thank you Martin for the fix! It solved the most important problem, but we still have issues with string-constants.
Therefore i reopen but lower the priority. Please take a look at these Attachments:

EntriesController.groovy: Line 22
LoginController.groovy: Line 49-60

cheers, M.
Comment 9 schmidtm 2008-01-22 12:24:15 UTC
Thanks Martin for the last fix, which was a great relieve. But we still have issues in these attachments:

EntriesController.groovy: Line 22
LoginController.groovy: Line 49-60

to narrow it down a bit i added an additional testcase for Gstrings in strings:

http://www.netbeans.org/source/browse/scripting/groovy/editor/test/unit/src/org/netbeans/modules/groovy/editor/GroovyLexerStringConstants.java?rev=1.1&view=markup
Comment 11 Quality Engineering 2008-05-20 05:23:49 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #206 build
Changeset: http://hg.netbeans.org/main/rev/260a269563c6
User: Martin Adamek <martin_adamek@netbeans.org>
Log: #124912: Gstring in source breaks token recognition