Community
Participate
Working Groups
I typed the following code in a scrapbook page, highlighted it, and selected "display": java.awt.Frame f = new java.awt.Frame(""); java.lang.String b = f.getClass().getName(); int index = b.lastIndexOf('.'); b.substring(index+1, b.length); The resulting message is "b cannot be resolved". What I would have expected was a message indicating that the snippet didn't compile, or that length is not a field of "b". The current message led me down a wrong path, thinking that I hadn't properly declared "b" somewhere, when in fact I had just failed to send the "length()" message to "b".
This message is coming from the CodeSnippetCompiler. Moving to JCORE.
CodeSnippetQualifiedNameReference.getOtherFieldBindings() was wrongly reporting an error on the scope, instead of reporting an invalid field access. Fixed and added regression test NegativeCodeSnippetTest.testInvalidField().
Verified.