[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.tools.jdt] Re: Incremental parsing in JDT

Hi,

There is no documentation on the design of these features but i will try to explain the general design of code assist.

Code assist use a subclass of the java compiler parser: CompletionParser
This parser (as the compiler parser) parse the edited file in two step.
During the first step, the 'diet parse', only the top level structure of the class (type declaration, method declaration, field declaration) is parsed and the parser jump over the methods bodies. If there is a syntax error, the top level structure is re-parse in recovery mode to build AST nodes for incorrect code.
If the completion is inside a method body then the second step start, the 'method parse'. Only the body which contain the completion is parsed, the other method bodies aren't parsed. If there is a syntax error in this body, the method body is re-parse in recovery mode.


The CompletionParser build a special AST node at completion location.
Once the edited unit is parsed, types in the AST are resolved.
With these data and the current state of the environment, the completion engine compute completion proposals.


So the classes to look are CompletionEngine and CompletionParser. The code assist API are ICodeAssist#codeComplete(...) methods.

It's the simplified design of the JDT/Core completion process. I hope that my explanations are clear enough and that will help you.

David

Orly Goren wrote:
Hi,

I wonder how the code assist and Error highlighting is implemented in JDT.
Is there some incremental parsing done, or in the background there is a some light parsing done on files being edited?
How is the Index used, is the information retrieved from the index alone, and the parser updates the index of each translation unit when finished parsing?


Is there some documentation on the design of those features (code assist, error highlighting) you can point me out?

Thanks,
Orly