Commit d7b648ab authored by Nikolai Kosjar's avatar Nikolai Kosjar
Browse files

Clang: Make translation unit and code completion options consistent



...otherwise we might run into the following assertion:

Assertion failed: (IncludeBriefComments ==
        this->IncludeBriefCommentsInCodeCompletion), function CodeComplete, file
        ASTUnit.cpp, line 2411.

Change-Id: I4723b600c7ac5aa2b4c1cb1827f51156afb492b8
Reviewed-by: default avatarErik Verbruggen <erik.verbruggen@theqtcompany.com>
parent 768c9009
......@@ -139,6 +139,8 @@ public:
SkippedSourceRanges skippedSourceRanges() const;
static uint defaultOptions();
private:
void setDirty();
void checkIfNull() const;
......@@ -152,7 +154,6 @@ private:
void reparseTranslationUnit() const;
void reparseTranslationUnitIfFilesAreChanged() const;
void updateIncludeFilePaths() const;
static uint defaultOptions();
static void includeCallback(CXFile included_file,
CXSourceLocation * /*inclusion_stack*/,
unsigned /*include_len*/,
......
......@@ -84,15 +84,13 @@ ClangCodeCompleteResults CodeCompleter::complete(uint line,
CXUnsavedFile *unsavedFiles,
unsigned unsavedFileCount)
{
const auto options = CXCodeComplete_IncludeMacros | CXCodeComplete_IncludeCodePatterns;
return clang_codeCompleteAt(translationUnit.cxTranslationUnitWithoutReparsing(),
translationUnit.filePath().constData(),
line,
column,
unsavedFiles,
unsavedFileCount,
options);
defaultOptions());
}
bool CodeCompleter::hasDotAt(uint line, uint column) const
......@@ -103,6 +101,17 @@ bool CodeCompleter::hasDotAt(uint line, uint column) const
return unsavedFile.hasCharacterAt(location.offset(), '.');
}
uint CodeCompleter::defaultOptions() const
{
uint options = CXCodeComplete_IncludeMacros
| CXCodeComplete_IncludeCodePatterns;
if (translationUnit.defaultOptions() & CXTranslationUnit_IncludeBriefCommentsInCodeCompletion)
options |= CXCodeComplete_IncludeBriefComments;
return options;
}
ClangCodeCompleteResults CodeCompleter::completeWithArrowInsteadOfDot(uint line, uint column)
{
ClangCodeCompleteResults results;
......
......@@ -50,6 +50,8 @@ public: // for tests
bool hasDotAt(uint line, uint column) const;
private:
uint defaultOptions() const;
ClangCodeCompleteResults complete(uint line,
uint column,
CXUnsavedFile *unsavedFiles,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment