Bug 186789 - Structural parse mode picks up less information than quick parse mode
Summary: Structural parse mode picks up less information than quick parse mode
Status: VERIFIED FIXED
Alias: None
Product: CDT
Classification: Tools
Component: cdt-core (show other bugs)
Version: 3.1.2   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.1.3   Edit
Assignee: Chris Recoskie CLA
QA Contact:
URL:
Whiteboard:
Keywords: contributed
Depends on:
Blocks:
 
Reported: 2007-05-14 10:06 EDT by Jason Montojo CLA
Modified: 2008-06-19 23:49 EDT (History)
2 users (show)

See Also:


Attachments
Proposed patch (22.98 KB, patch)
2007-05-14 13:00 EDT, Jason Montojo CLA
bjorn.freeman-benson: iplog+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jason Montojo CLA 2007-05-14 10:06:53 EDT
The structural parse mode in CDT uses the complete parser which expects code to be syntactically and semantically correct.  This is not desirable behaviour when you want the parser to make a best attempt at building a model because certain non-fatal errors can cause the parser to bail out (especially in code involving templates).

Structural parse mode should be using the quick parser.  The only difference would be that it should also follow inclusions.  I posted a patch for this as part of bug 185536, but I'll separate it out and post here because it's a significant enough change.
Comment 1 Doug Schaefer CLA 2007-05-14 11:17:49 EDT
What do you mean by quick parse? Do you mean skipping function bodies?

The error handling code in the parser was meant to recover from as many errors as possible. Would spending time enhancing this help?

What are the ill affects of this change?
Comment 2 Chris Recoskie CLA 2007-05-14 11:22:41 EDT
Just to clarify in case anyone wasn't sure, this is on the outline parser in 3.x, not in the DOM parser.
Comment 3 Doug Schaefer CLA 2007-05-14 11:26:02 EDT
(In reply to comment #2)
> Just to clarify in case anyone wasn't sure, this is on the outline parser in
> 3.x, not in the DOM parser.

Yes, that does make more sense now :)
Comment 4 Jason Montojo CLA 2007-05-14 12:58:41 EDT
> What do you mean by quick parse? Do you mean skipping function bodies?

ParserMode.QUICK_PARSE, which entails skipping inclusions and function bodies.

> What are the ill affects of this change?

None from what I can see.  Changing Parser to use QuickParseASTFactory instead of the CompleteParseASTFactory while in ParserMode.STRUCTURAL_PARSE mode actually speeds up the structural parse test cases without loss in accuracy.  The only affected client is the model builder.  No other clients use STRUCTURAL_PARSE.
Comment 5 Jason Montojo CLA 2007-05-14 13:00:10 EDT
Created attachment 67100 [details]
Proposed patch
Comment 6 Chris Recoskie CLA 2007-05-14 14:43:46 EDT
Applied to the cdt_3_1 branch.  Thanks Jay.
Comment 7 Chris Recoskie CLA 2007-05-14 14:44:57 EDT
Janees please verify.
Comment 8 Janees Elamkulam CLA 2007-05-15 09:19:16 EDT
Verified this fixed and works fine.

But, there is a problem with the current approach, after making the changes in preference page (C/C++ -> Follow #includes while parsing working copies), i see that, the changes are not effected immediately, unless you modify the file or restart the workbench. This is an issue if the file is in source control.

I suggest issue a refresh on all C/C++ project when this particular preference change, or Popup a dialog (OK /Cancel dialog)  asking user, whether to restart the workbech for changes to take effect. 

Workbench can be restart by calling org.eclipse.ui.IWorkbench.restart()
Comment 9 Jason Montojo CLA 2007-05-15 09:24:42 EDT
> But, there is a problem with the current approach, after making the changes in
> preference page (C/C++ -> Follow #includes while parsing working copies), i see
> that, the changes are not effected immediately, unless you modify the file or
> restart the workbench. This is an issue if the file is in source control.

Since model information is cached, all open C/C++ editors would need to be closed and re-opened for this change to take effect.  Similarly, any expanded files in the C/C++ Projects view would need to be collapsed and expanded.
Comment 10 Chris Recoskie CLA 2007-05-15 10:00:00 EDT
Marking as VERIFIED.

(In reply to comment #8)
> I suggest issue a refresh on all C/C++ project when this particular preference
> change, or Popup a dialog (OK /Cancel dialog)  asking user, whether to restart
> the workbech for changes to take effect. 
> Workbench can be restart by calling org.eclipse.ui.IWorkbench.restart()

Please file a separate Bugzilla for the refresh issue.  There are lots of places where changing parser, indexer, and language settings does not refresh the CModel, syntax highlighting, etc. due to the AST caching mechanism.  An organized approach will have to be taken to addressing that and I personally do not want to try to address that in a point release.