Qt wiki will be updated on October 12th 2023 starting at 11:30 AM (EEST) and the maintenance will last around 2-3 hours. During the maintenance the site will be unavailable.

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

From Qt Wiki
Jump to navigation Jump to search
No edit summary
 
(Decode HTML entity names)
 
(4 intermediate revisions by 2 users not shown)
Line 1: Line 1:
==Code Completion==
{{Cleanup | reason=Auto-imported from ExpressionEngine.}}


<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.
[[Category:Tools::Qt Creator:Branches]]


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 Completion ==


Additional notes:
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.


* [http://en.wikipedia.org/wiki/Builder_pattern Builder pattern] ''[en.wikipedia.org]'' used to create completion results, see ResultBuilder class.
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:
* Declarations will be collected by CodeCompletionDeclConsumer class, passed to Sema::LookupVisibleDecls() method.
<code>
void CodeCompleteTag(Scope *S, unsigned TagSpec);
void CodeCompleteTypeQualifiers(DeclSpec &DS);
void CodeCompleteCase(Scope *S);
void CodeCompleteCall(Scope *S, Expr '''Fn, ArrayRef<Expr'''> Args);
void CodeCompleteInitializer(Scope *S, Decl *D);
void CodeCompleteReturn(Scope *S);
void CodeCompleteAfterIf(Scope *S);
void CodeCompleteAssignmentRHS(Scope *S, Expr '''LHS);
</code>


===Categories:===
Additional notes:
 
''' [http://en.wikipedia.org/wiki/Builder_pattern Builder pattern] used to create completion results, see ResultBuilder class.
* [[:Category:Tools|Tools]]
** [[:Category:Tools::Qt-Creator:Branches|Qt Creator:Branches]]

Latest revision as of 16:59, 12 March 2015

This article may require cleanup to meet the Qt Wiki's quality standards. Reason: Auto-imported from ExpressionEngine.
Please improve this article if you can. Remove the {{cleanup}} tag and add this page to Updated pages list after it's clean.

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:

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

Additional notes: Builder pattern used to create completion results, see ResultBuilder class.