| Parser and Indexer collaboration in CDT [message #163170] |
Sun, 05 February 2006 04:33  |
Eclipse User |
|
|
|
Originally posted by: orly.goren.google.com
I am trying to understand the collaboration between the parser and the
index in the context of code assist, what information is gathered on the
fly and what is done incrementally...
I have a few questions on the subject:
1) Is the parsing for building the AST used for other than understanding
the current ASTNode to complete, and perhaps scope?
Is the parsing for understanding the ASTNode a complete parsing or are
there optimizations such as not parsing include files etc.?
2) As I understand the Indexer is built in an incremental way (or I am
wrong?).
Do you know when is it updated? (triggered upon each change in a file?)
3) I understood that in the context of code assist:
Semantic resolution is only done for the completion node instead of for
the whole tree.
I don't understand what does the semantic resolution refers to? Binding
references to declarations? Anything else?
But binding to references can be done in case where completion is
requested for a struct/class member. But in other cases what is the
semantic resolution needs to be done?
Thanks,
Orly
|
|
|
| Re: Parser and Indexer collaboration in CDT [message #163331 is a reply to message #163170] |
Mon, 06 February 2006 12:16   |
Eclipse User |
|
|
|
Orly Goren wrote:
> I am trying to understand the collaboration between the parser and the
> index in the context of code assist, what information is gathered on the
> fly and what is done incrementally...
>
> I have a few questions on the subject:
>
> 1) Is the parsing for building the AST used for other than understanding
> the current ASTNode to complete, and perhaps scope?
> Is the parsing for understanding the ASTNode a complete parsing or are
> there optimizations such as not parsing include files etc.?
During content assist, the parse builds the AST for the entire
compilation unit up to the cursor. The resulting ASTCompletionNode
provides a context for the ICompletionContributors to start from.
>
> 2) As I understand the Indexer is built in an incremental way (or I am
> wrong?).
> Do you know when is it updated? (triggered upon each change in a file?)
>
I believe the index is updated when you save a file. All compilation
units that include that file would be reindexed.
Content assist does not cause an index. The SearchCompletionContributor
searches the existing index for things it would want to propose.
> 3) I understood that in the context of code assist:
> Semantic resolution is only done for the completion node instead of for
> the whole tree.
> I don't understand what does the semantic resolution refers to? Binding
> references to declarations? Anything else?
> But binding to references can be done in case where completion is
> requested for a struct/class member. But in other cases what is the
> semantic resolution needs to be done?
A binding is an object that is a logical representation of something in
the code (a class, function, variable, etc). Every declaration and
reference of some logical entity will resolve to the same binding object.
During content assist, the DOMCompletionContributor basically treats the
completion request as a reference with a wild card in its name and tries
to collect all the bindings that would resolve if their name was used
there. In addition to resolving things with a matching name, we have to
resolve all scopes that would normally be traversed during the lookup of
those names. The number of bindings that ultimately get resolved can be
significant for complex code, though this is still less than resolving
all the bindings in the compilation unit.
>
> Thanks,
> Orly
>
>
-Andrew
|
|
|
| Re: Parser and Indexer collaboration in CDT [message #163339 is a reply to message #163331] |
Mon, 06 February 2006 16:21   |
Eclipse User |
|
|
|
Originally posted by: orly.goren.google.com
Andrew Niefer wrote:
> Orly Goren wrote:
>> I am trying to understand the collaboration between the parser and the
>> index in the context of code assist, what information is gathered on the
>> fly and what is done incrementally...
>>
>> I have a few questions on the subject:
>>
>> 1) Is the parsing for building the AST used for other than understanding
>> the current ASTNode to complete, and perhaps scope?
>> Is the parsing for understanding the ASTNode a complete parsing or are
>> there optimizations such as not parsing include files etc.?
> During content assist, the parse builds the AST for the entire
> compilation unit up to the cursor. The resulting ASTCompletionNode
> provides a context for the ICompletionContributors to start from.
For understanding the ASTCompletionNode there can be optimizations such as
skipping function bodies in include files or so (so I assume), do you know
if such are done, or as you said before building the AST for the entire
compilation unit up to the cursor (with no optimizations).
>>
>> 2) As I understand the Indexer is built in an incremental way (or I am
>> wrong?).
>> Do you know when is it updated? (triggered upon each change in a file?)
>>
> I believe the index is updated when you save a file. All compilation
> units that include that file would be reindexed.
So, the proposed suggestions will be only from saved files?
If I have writen the following:
int some_variable;
so (and then press the Ctrl Space for content assist)
Before saving anything won't I get the some_variable as a suggestion? If
it is not saved in the Indexer where will such suggestion be provided?
> Content assist does not cause an index. The SearchCompletionContributor
> searches the existing index for things it would want to propose.
>> 3) I understood that in the context of code assist:
>> Semantic resolution is only done for the completion node instead of for
>> the whole tree.
>> I don't understand what does the semantic resolution refers to? Binding
>> references to declarations? Anything else?
>> But binding to references can be done in case where completion is
>> requested for a struct/class member. But in other cases what is the
>> semantic resolution needs to be done?
> A binding is an object that is a logical representation of something in
> the code (a class, function, variable, etc). Every declaration and
> reference of some logical entity will resolve to the same binding object.
> During content assist, the DOMCompletionContributor basically treats the
> completion request as a reference with a wild card in its name and tries
> to collect all the bindings that would resolve if their name was used
> there. In addition to resolving things with a matching name, we have to
> resolve all scopes that would normally be traversed during the lookup of
> those names. The number of bindings that ultimately get resolved can be
> significant for complex code, though this is still less than resolving
> all the bindings in the compilation unit.
So what is the difference between the results that the
DOMCompletionContributor returns to the results the Indexer returns? I
think I am missing something here.
The DOMCompletionContributor returns results based on the AST built until
the Completion node, right? Which means there is no incremental processing
here (all is done on the fly for the entire translation unit until cursor)?
Thanks...
>>
>> Thanks,
>> Orly
>>
>>
> -Andrew
|
|
|
| Re: Parser and Indexer collaboration in CDT [message #163390 is a reply to message #163339] |
Tue, 07 February 2006 18:01  |
Eclipse User |
|
|
|
Orly Goren wrote:
> For understanding the ASTCompletionNode there can be optimizations such
> as skipping function bodies in include files or so (so I assume), do you
> know if such are done, or as you said before building the AST for the
> entire compilation unit up to the cursor (with no optimizations).
>
Looking at the code reveals that the parser does currently skip function
bodies in includes when doing content assist.
AbstractGNUSourceCodeParser.handleFunctionBody();
> So, the proposed suggestions will be only from saved files?
> If I have writen the following:
> int some_variable;
> so (and then press the Ctrl Space for content assist)
> Before saving anything won't I get the some_variable as a suggestion? If
> it is not saved in the Indexer where will such suggestion be provided?
The SearchCompletionContributor would not suggest it, but the
DOMCompletionContributor would.
> So what is the difference between the results that the
> DOMCompletionContributor returns to the results the Indexer returns? I
> think I am missing something here.
The SearchCompletionContributor searches for everything except methods
and fields and local variables. (Local variables are not stored in the
index). These results are generally less accurate and may not
necessarily be visible from where you did the content assist.
The DOMCompletionContributor builds the AST on the unsaved buffers. It
returns only valid completions that are visible in your current
location. Unlike search, methods, fields and local variables will be
proposed.
The DOMCompletionContributor is more vulnerable to invalid code above
the completion point than the search contributor is. The DOM
contributor can fail entirely in projects that aren't set up properly
wrt header files and predefined symbols, the search contributor can have
better results here (especially using the CTags indexer).
|
|
|
Powered by
FUDForum. Page generated in 0.03678 seconds