Clang: Reparse always before you complete the code

There are two ways to hot fix the dependency problem. First version is to
disable the caching(not the preamble) but it is triggering bugs. Second 
version is to enable caching and reparse before every complete. I opted
for the second version because it is the commonly used path for most
implementations. Later we have to minimize the reparse calls but for that 
we need the cooperation of editor.

Change-Id: I878afb896cbf2338cbeb13d9e596a7776dd49854
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-07-21 19:44:08 +02:00
parent 568d7e7c7d
commit b3113bbbc6
3 changed files with 10 additions and 0 deletions

View File

@@ -49,6 +49,8 @@ CodeCompleter::CodeCompleter(TranslationUnit translationUnit)
QVector<CodeCompletion> CodeCompleter::complete(uint line, uint column) QVector<CodeCompletion> CodeCompleter::complete(uint line, uint column)
{ {
translationUnit.reparse();
ClangCodeCompleteResults completeResults(clang_codeCompleteAt(translationUnit.cxTranslationUnit(), ClangCodeCompleteResults completeResults(clang_codeCompleteAt(translationUnit.cxTranslationUnit(),
translationUnit.filePath().constData(), translationUnit.filePath().constData(),
line, line,

View File

@@ -96,6 +96,13 @@ void TranslationUnit::reset()
d.reset(); d.reset();
} }
void TranslationUnit::reparse()
{
cxTranslationUnit();
reparseTranslationUnit();
}
CXIndex TranslationUnit::index() const CXIndex TranslationUnit::index() const
{ {
checkIfNull(); checkIfNull();

View File

@@ -73,6 +73,7 @@ public:
bool isNull() const; bool isNull() const;
void reset(); void reset();
void reparse();
CXIndex index() const; CXIndex index() const;
CXTranslationUnit cxTranslationUnit() const; CXTranslationUnit cxTranslationUnit() const;