forked from qt-creator/qt-creator
CppTools: Move languageFeatures around in CompletionAssist...
... from InternalCppCompletionAssistProcessor to CppCompletionAssistInterface Change-Id: I769fd86a387f1087f37b56fe114bdf132f1b0be7 Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
committed by
Orgad Shaneh
parent
2ffe50c208
commit
1a37605f91
@@ -200,15 +200,14 @@ IAssistProcessor *ClangCompletionAssistProvider::createProcessor() const
|
||||
}
|
||||
|
||||
AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
|
||||
const QString &filePath,
|
||||
QTextDocument *document, bool isObjCEnabled, int position, AssistReason reason) const
|
||||
const QString &filePath, QTextDocument *document,
|
||||
const LanguageFeatures &languageFeatures, int position, AssistReason reason) const
|
||||
{
|
||||
Q_UNUSED(isObjCEnabled);
|
||||
|
||||
CppModelManager *modelManager = CppModelManager::instance();
|
||||
QList<ProjectPart::Ptr> parts = modelManager->projectPart(filePath);
|
||||
if (parts.isEmpty())
|
||||
parts += modelManager->fallbackProjectPart();
|
||||
LanguageFeatures features = languageFeatures;
|
||||
ProjectPart::HeaderPaths headerPaths;
|
||||
QStringList options;
|
||||
PchInfo::Ptr pchInfo;
|
||||
@@ -220,13 +219,14 @@ AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
|
||||
if (!pchInfo.isNull())
|
||||
options.append(Utils::createPCHInclusionOptions(pchInfo->fileName()));
|
||||
headerPaths = part->headerPaths;
|
||||
features = part->languageFeatures;
|
||||
break;
|
||||
}
|
||||
|
||||
return new ClangCompletionAssistInterface(
|
||||
m_clangCompletionWrapper,
|
||||
document, position, filePath, reason,
|
||||
options, headerPaths, pchInfo);
|
||||
options, headerPaths, pchInfo, features);
|
||||
}
|
||||
|
||||
// ------------------------
|
||||
@@ -545,12 +545,14 @@ ClangCompletionAssistInterface::ClangCompletionAssistInterface(ClangCompleter::P
|
||||
AssistReason reason,
|
||||
const QStringList &options,
|
||||
const QList<ProjectPart::HeaderPath> &headerPaths,
|
||||
const PchInfo::Ptr &pchInfo)
|
||||
const PchInfo::Ptr &pchInfo,
|
||||
const LanguageFeatures &features)
|
||||
: AssistInterface(document, position, fileName, reason)
|
||||
, m_clangWrapper(clangWrapper)
|
||||
, m_options(options)
|
||||
, m_headerPaths(headerPaths)
|
||||
, m_savedPchPointer(pchInfo)
|
||||
, m_languageFeatures(features)
|
||||
{
|
||||
Q_ASSERT(!clangWrapper.isNull());
|
||||
|
||||
@@ -711,10 +713,7 @@ int ClangCompletionAssistProcessor::startOfOperator(int pos,
|
||||
}
|
||||
|
||||
SimpleLexer tokenize;
|
||||
LanguageFeatures lf = tokenize.languageFeatures();
|
||||
lf.qtMocRunEnabled = true;
|
||||
lf.objCEnabled = true;
|
||||
tokenize.setLanguageFeatures(lf);
|
||||
tokenize.setLanguageFeatures(m_interface->languageFeatures());
|
||||
tokenize.setSkipComments(false);
|
||||
const Tokens &tokens = tokenize(tc.block().text(), BackwardsScanner::previousBlockState(tc.block()));
|
||||
const int tokenIdx = SimpleLexer::tokenBefore(tokens, qMax(0, tc.positionInBlock() - 1)); // get the token at the left of the cursor
|
||||
|
||||
@@ -58,9 +58,9 @@ public:
|
||||
|
||||
virtual TextEditor::IAssistProcessor *createProcessor() const;
|
||||
virtual TextEditor::AssistInterface *createAssistInterface(
|
||||
const QString &filePath,
|
||||
QTextDocument *document, bool isObjCEnabled, int position,
|
||||
TextEditor::AssistReason reason) const;
|
||||
const QString &filePath, QTextDocument *document,
|
||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||
int position, TextEditor::AssistReason reason) const;
|
||||
|
||||
private:
|
||||
ClangCodeModel::ClangCompleter::Ptr m_clangCompletionWrapper;
|
||||
@@ -78,7 +78,8 @@ public:
|
||||
TextEditor::AssistReason reason,
|
||||
const QStringList &options,
|
||||
const QList<CppTools::ProjectPart::HeaderPath> &headerPaths,
|
||||
const Internal::PchInfo::Ptr &pchInfo);
|
||||
const Internal::PchInfo::Ptr &pchInfo,
|
||||
const CPlusPlus::LanguageFeatures &features);
|
||||
|
||||
ClangCodeModel::ClangCompleter::Ptr clangWrapper() const
|
||||
{ return m_clangWrapper; }
|
||||
@@ -94,12 +95,16 @@ public:
|
||||
const QList<CppTools::ProjectPart::HeaderPath> &headerPaths() const
|
||||
{ return m_headerPaths; }
|
||||
|
||||
CPlusPlus::LanguageFeatures languageFeatures() const
|
||||
{ return m_languageFeatures; }
|
||||
|
||||
private:
|
||||
ClangCodeModel::ClangCompleter::Ptr m_clangWrapper;
|
||||
ClangCodeModel::Internal::UnsavedFiles m_unsavedFiles;
|
||||
QStringList m_options;
|
||||
QList<CppTools::ProjectPart::HeaderPath> m_headerPaths;
|
||||
Internal::PchInfo::Ptr m_savedPchPointer;
|
||||
CPlusPlus::LanguageFeatures m_languageFeatures;
|
||||
};
|
||||
|
||||
class CLANG_EXPORT ClangCompletionAssistProcessor : public CppTools::CppCompletionAssistProcessor
|
||||
|
||||
Reference in New Issue
Block a user