forked from qt-creator/qt-creator
TextEditor: use Utils::FilePath as file member in AssistInterface
Change-Id: I3bf9b013b9350411f918efdb9d1a36a2c22bf972 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -105,7 +105,7 @@ public:
|
||||
LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures();
|
||||
languageFeatures.objCEnabled = false;
|
||||
CppCompletionAssistInterface *ai
|
||||
= new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(),
|
||||
= new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath(),
|
||||
m_textDocument, m_position,
|
||||
ExplicitlyInvoked, m_snapshot,
|
||||
ProjectExplorer::HeaderPaths(),
|
||||
|
||||
@@ -424,17 +424,18 @@ IAssistProcessor *InternalCompletionAssistProvider::createProcessor() const
|
||||
return new InternalCppCompletionAssistProcessor;
|
||||
}
|
||||
|
||||
AssistInterface *InternalCompletionAssistProvider::createAssistInterface(const QString &filePath,
|
||||
const TextEditorWidget *textEditorWidget,
|
||||
const LanguageFeatures &languageFeatures,
|
||||
int position,
|
||||
AssistReason reason) const
|
||||
AssistInterface *InternalCompletionAssistProvider::createAssistInterface(
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditorWidget *textEditorWidget,
|
||||
const LanguageFeatures &languageFeatures,
|
||||
int position,
|
||||
AssistReason reason) const
|
||||
{
|
||||
QTC_ASSERT(textEditorWidget, return nullptr);
|
||||
|
||||
return new CppCompletionAssistInterface(filePath,
|
||||
textEditorWidget,
|
||||
BuiltinEditorDocumentParser::get(filePath),
|
||||
BuiltinEditorDocumentParser::get(filePath.toString()),
|
||||
languageFeatures,
|
||||
position,
|
||||
reason,
|
||||
@@ -1092,7 +1093,7 @@ int InternalCppCompletionAssistProcessor::startCompletionHelper()
|
||||
|
||||
int line = 0, column = 0;
|
||||
Utils::Text::convertPosition(m_interface->textDocument(), startOfExpression, &line, &column);
|
||||
const QString fileName = m_interface->fileName();
|
||||
const QString fileName = m_interface->filePath().toString();
|
||||
return startCompletionInternal(fileName, line, column - 1, expression, endOfExpression);
|
||||
}
|
||||
|
||||
@@ -1117,7 +1118,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
|
||||
const int startPos = tokens[start].bytesBegin() + tokens.startPosition();
|
||||
const QString expr = m_interface->textAt(startPos, m_interface->position() - startPos);
|
||||
|
||||
Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->fileName());
|
||||
Document::Ptr thisDocument = m_interface->snapshot().document(m_interface->filePath());
|
||||
if (!thisDocument)
|
||||
return false;
|
||||
|
||||
@@ -1260,7 +1261,7 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
|
||||
|
||||
// Make completion for all relevant includes
|
||||
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths();
|
||||
const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(),
|
||||
const ProjectExplorer::HeaderPath currentFilePath(m_interface->filePath().toFileInfo().path(),
|
||||
ProjectExplorer::HeaderPathType::User);
|
||||
if (!headerPaths.contains(currentFilePath))
|
||||
headerPaths.append(currentFilePath);
|
||||
@@ -1312,7 +1313,7 @@ bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const
|
||||
if (!m_interface->languageFeatures().objCEnabled)
|
||||
return false;
|
||||
|
||||
const QString fileName = m_interface->fileName();
|
||||
const QString fileName = m_interface->filePath().toString();
|
||||
|
||||
const Utils::MimeType mt = Utils::mimeTypeForFile(fileName);
|
||||
return mt.matchesName(QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE))
|
||||
|
||||
@@ -85,11 +85,11 @@ public:
|
||||
TextEditor::IAssistProcessor *createProcessor() const override;
|
||||
|
||||
TextEditor::AssistInterface *createAssistInterface(
|
||||
const QString &filePath,
|
||||
const TextEditor::TextEditorWidget *textEditorWidget,
|
||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||
int position,
|
||||
TextEditor::AssistReason reason) const override;
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditor::TextEditorWidget *textEditorWidget,
|
||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||
int position,
|
||||
TextEditor::AssistReason reason) const override;
|
||||
};
|
||||
|
||||
class InternalCppCompletionAssistProcessor : public CppCompletionAssistProcessor
|
||||
@@ -165,7 +165,7 @@ private:
|
||||
class CppCompletionAssistInterface : public TextEditor::AssistInterface
|
||||
{
|
||||
public:
|
||||
CppCompletionAssistInterface(const QString &filePath,
|
||||
CppCompletionAssistInterface(const Utils::FilePath &filePath,
|
||||
const TextEditor::TextEditorWidget *textEditorWidget,
|
||||
BuiltinEditorDocumentParser::Ptr parser,
|
||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||
@@ -179,7 +179,7 @@ public:
|
||||
, m_languageFeatures(languageFeatures)
|
||||
{}
|
||||
|
||||
CppCompletionAssistInterface(const QString &filePath,
|
||||
CppCompletionAssistInterface(const Utils::FilePath &filePath,
|
||||
QTextDocument *textDocument,
|
||||
int position,
|
||||
TextEditor::AssistReason reason,
|
||||
|
||||
@@ -41,6 +41,8 @@ class TextEditorWidget;
|
||||
class AssistInterface;
|
||||
}
|
||||
|
||||
namespace Utils { class FilePath; }
|
||||
|
||||
namespace CppTools {
|
||||
|
||||
class CPPTOOLS_EXPORT CppCompletionAssistProvider : public TextEditor::CompletionAssistProvider
|
||||
@@ -54,11 +56,11 @@ public:
|
||||
bool isContinuationChar(const QChar &c) const override;
|
||||
|
||||
virtual TextEditor::AssistInterface *createAssistInterface(
|
||||
const QString &filePath,
|
||||
const TextEditor::TextEditorWidget *textEditorWidget,
|
||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||
int position,
|
||||
TextEditor::AssistReason reason) const = 0;
|
||||
const Utils::FilePath &filePath,
|
||||
const TextEditor::TextEditorWidget *textEditorWidget,
|
||||
const CPlusPlus::LanguageFeatures &languageFeatures,
|
||||
int position,
|
||||
TextEditor::AssistReason reason) const = 0;
|
||||
|
||||
static int activationSequenceChar(const QChar &ch, const QChar &ch2,
|
||||
const QChar &ch3, unsigned *kind,
|
||||
|
||||
Reference in New Issue
Block a user