Clang-hacking-notes-for-wip-clang-branch: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
No edit summary
Line 1: Line 1:
==Code Completion==
[[Category:Tools::Qt Creator:Branches]]


<span class="caps">GCC</span> C++ frontend is a parser that also generates code. Clang is quite similar: it is parser that also calls various actions along with creating <span class="caps">AST</span>. Completion implemented via inserting virtual token, on which parser calls one of Sema class methods, implemented in SemaCodeComplete.cpp.
== Code Completion ==


Main pros of this approach is context-sensitive completion: parser will not produce any completion results if it doesn’t expect completion token at given point, otherwise it will call one of ~40 methods from SemaCodeComplete.cpp, choice depends on context. There are declarations of some code complete methods, parser calls one of them:<br />
GCC C++ frontend is a parser that also generates code. Clang is quite similar: it is parser that also calls various actions along with creating AST. Completion implemented via inserting virtual token, on which parser calls one of Sema class methods, implemented in SemaCodeComplete.cpp.


Additional notes:
Main pros of this approach is context-sensitive completion: parser will not produce any completion results if it doesn't expect completion token at given point, otherwise it will call one of ~40 methods from SemaCodeComplete.cpp, choice depends on context. There are declarations of some code complete methods, parser calls one of them:<br /><code><br /> void CodeCompleteTag(Scope *S, unsigned TagSpec);<br /> void CodeCompleteTypeQualifiers(DeclSpec &amp;DS);<br /> void CodeCompleteCase(Scope *S);<br /> void CodeCompleteCall(Scope *S, Expr '''Fn, ArrayRef&amp;lt;Expr'''&gt; Args);<br /> void CodeCompleteInitializer(Scope *S, Decl *D);<br /> void CodeCompleteReturn(Scope *S);<br /> void CodeCompleteAfterIf(Scope *S);<br /> void CodeCompleteAssignmentRHS(Scope *S, Expr '''LHS);<br /></code>
 
<br />Additional notes:<br />''' &quot;Builder pattern&amp;quot;:http://en.wikipedia.org/wiki/Builder_pattern used to create completion results, see ResultBuilder class.
* [http://en.wikipedia.org/wiki/Builder_pattern Builder pattern] ''[en.wikipedia.org]'' used to create completion results, see ResultBuilder class.
* Declarations will be collected by CodeCompletionDeclConsumer class, passed to Sema::LookupVisibleDecls() method.
 
===Categories:===
 
* [[:Category:Tools|Tools]]
** [[:Category:Tools::Qt-Creator:Branches|Qt Creator:Branches]]

Revision as of 10:41, 24 February 2015


Code Completion

GCC C++ frontend is a parser that also generates code. Clang is quite similar: it is parser that also calls various actions along with creating AST. Completion implemented via inserting virtual token, on which parser calls one of Sema class methods, implemented in SemaCodeComplete.cpp.

Main pros of this approach is context-sensitive completion: parser will not produce any completion results if it doesn't expect completion token at given point, otherwise it will call one of ~40 methods from SemaCodeComplete.cpp, choice depends on context. There are declarations of some code complete methods, parser calls one of them:

<br /> void CodeCompleteTag(Scope *S, unsigned TagSpec);<br /> void CodeCompleteTypeQualifiers(DeclSpec &amp;DS);<br /> void CodeCompleteCase(Scope *S);<br /> void CodeCompleteCall(Scope *S, Expr '''Fn, ArrayRef&amp;lt;Expr'''&gt; Args);<br /> void CodeCompleteInitializer(Scope *S, Decl *D);<br /> void CodeCompleteReturn(Scope *S);<br /> void CodeCompleteAfterIf(Scope *S);<br /> void CodeCompleteAssignmentRHS(Scope *S, Expr '''LHS);<br />


Additional notes:
"Builder pattern&quot;:http://en.wikipedia.org/wiki/Builder_pattern used to create completion results, see ResultBuilder class.