Community
Participate
Working Groups
Created attachment 170127 [details] java hover Hover over function haves gives nice overview of parameters for function, when user typing the code it is good to have it. However cdt parser shows parse error (because of no semicolon for example) and range of the error starts at the begging of the function I am typing and ends god knows where. Because of that I loose my useful hover. For example printf() return; would mark all this code as big error I am attaching 2 screenshots: one from java and one for c. Same error - different user experience. Java parser only highlights ")" which what user needs. Another solution to show both hovers. (Or I can turn off squiggly line but I like it)
Created attachment 170128 [details] c hover
For declarations we have a way to report the syntax error for a missing semicolon. A similar approach could be taken for statements. While this would for instance not help for missing closing parenthesis, it would address the specific example. (In reply to comment #0) > Hover over function haves gives nice overview of parameters for function, > when user typing the code it is good to have it. However cdt parser > shows parse error (because of no semicolon for example) and range of the error > starts at the begging of the function I am typing and ends god knows where. > Because of that I loose my useful hover. The error ends at the next semicolon or closing brace. > I am attaching 2 screenshots: one from java and one for c. Same error - > different user experience. Java parser only highlights ")" which what user > needs. Nevertheless, the java-parser is bad at parsing c/c++. > Another solution to show both hovers. (Or I can turn off squiggly line but I > like it) I don't think the hover framework allows for two hovers.
> > I am attaching 2 screenshots: one from java and one for c. Same error - > > different user experience. Java parser only highlights ")" which what user > > needs. > Nevertheless, the java-parser is bad at parsing c/c++. This is a joke right? I know how hard hard to parse c/c++ (I wrote a few parsers). But it is not impossible. Gcc for example knows that user is missing semicolon and where. i.e error: expected ';' before 'return'
(In reply to comment #3) > > > I am attaching 2 screenshots: one from java and one for c. Same error - > > > different user experience. Java parser only highlights ")" which what user > > > needs. > > Nevertheless, the java-parser is bad at parsing c/c++. > > This is a joke right? You can also take it seriously: The java parser is really bad at parsing c/c++. > I know how hard hard to parse c/c++ (I wrote a few parsers). > But it is not impossible. Gcc for example knows that user is missing > semicolon > and where. i.e > error: expected ';' before 'return' Sure it is possible (as I wrote in comment 2 we could do something similar as when parsing lists of declarations), nevertheless we have to consider the effects of such an implementation. The fact that this works with gcc does not really help us. The problem with doing something smart is that you can find some input that explores the worst side of your solution. Gcc for instance deals with crazy situations by stopping with a message similar to 'Too many errors, bailing out...'. We don't really have that option. A specific concern is that when we create an error, where we think there is a missing semicolon and keep on parsing as if it has been there, in the worst case we'd do that after every token until we hit the next semicolon. With that we'd potentially create lots of syntax errors, where there should be just one.
Created attachment 172489 [details] testcase + fix The patch fixes the range of the syntax error. With that you do get an AST node for the statement without the semicolon. Note, that the name resolution for the name of the function call will fail when the parameters are not specified, you'll get a IProblemBinding.
Fixed in 8.0 > 20100623.
*** cdt cvs genie on behalf of mschorn *** Bug 314593: Handling of missing semicolon after statement. [*] GNUCSourceParser.java 1.152 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/GNUCSourceParser.java?root=Tools_Project&r1=1.151&r2=1.152 [*] AbstractGNUSourceCodeParser.java 1.153 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/AbstractGNUSourceCodeParser.java?root=Tools_Project&r1=1.152&r2=1.153 [*] GNUCPPSourceParser.java 1.234 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/GNUCPPSourceParser.java?root=Tools_Project&r1=1.233&r2=1.234 [*] CPPPopulateASTViewAction.java 1.30 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.ui.tests/src/org/eclipse/cdt/ui/tests/DOMAST/CPPPopulateASTViewAction.java?root=Tools_Project&r1=1.29&r2=1.30 [*] FaultToleranceTests.java 1.6 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/FaultToleranceTests.java?root=Tools_Project&r1=1.5&r2=1.6 [*] AST2SelectionParseTest.java 1.17 http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.cdt-core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/core/parser/tests/ast2/AST2SelectionParseTest.java?root=Tools_Project&r1=1.16&r2=1.17
Parameters are not specified you mean printf() or print? In C we should not get problem binding for function, only in C++. It is legal in C to call function which less arguments than defined.
(In reply to comment #8) > Parameters are not specified you mean printf() or print? > In C we should not get problem binding for function, only in C++. > It is legal in C to call function which less arguments than defined. You are right, there will be no problem binding for printf() in c.