Community
Participate
Working Groups
For reference to an objects member function/method, such as: stringBuffer.toString(); "Quick fix" can help to create a new field/local variable. So, what about reference to an objects member variable/field? such as: gridBagConstrains.insets; I suggest "Quick fix" can also help to do the similar for this, since in this case it's an obvious syntax error. -- Roger Ye
The problem is that an expression like gridBagConstrains.insets; is a syntax error and syntax error prevent the AST to be build. So there's not much quick fix can do here.
I'm not clear about the 'AST' you said, Anyway, Code like these: String value = arrayList.get(0); and a code snippet has an uncaught checked exception I think they are all syntax error (if i'm right), and they can be fix by Quick-Fix So, why in this case it can not? any explanation is appreciated, thanks in advance ;-)
There are syntax errors and semantic errors. Syntax error are problems were the source code could not be parsed at all and therefor the Java compiler could not form a compile tree (AST). Semantic errors are when the sytax is correct (tree can be build), but some elements just could be resolved or are not visible, initialized ect. Quick fix needs a compile tree (AST) to do anything at all. We can forward this bug report to jdt.core and ask that the parser should be changed to also return a tree for 'gridBagConstrains.insets;' but I think it is unlikely that they will do that. Moving to jdt.core
Hi, Is there any news about this ticket?
gridBagConstrains.insets; is not a valid statement. Therefore the grammar rejects such cases. We could however add the following rule in the grammar: Statement ::= Name ';' /.$putCase consumeInvalidStatement(); $break ./ Right now we report: ---------- 1. ERROR in d:\tests_sources\X.java (at line 6) a.i; ^ Syntax error, insert "AssignmentOperator ArrayInitializer" to complete Expression ---------- 1 problem (1 error) javac reports: X.java:6: not a statement a.i; ^ 1 error which is a bit more helpful. The only way to return a better error message is to accept this as syntactically correct and reject the code later. Philippe, with this new rule, the grammar is still LALR(1). The problem is that right now no node could be used to represent this construct.
We could also not create any node and report the error in the semantic action attached to this rule. We would report the error against the current reference context.
Moving to JDT/UI. With the statement recovery, a recovered node is created for gridBagConstrains.insets;. Therefore it might now be possible to add a quickfix for this kind of error.
waiting for bug 129330 to be fixed
reopen as bug 129330 has been fixed
verified that gridBagConstrains.insets; and arr[i]; now work added tests > 20060410
mark as fixed