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:
David Schulz
2020-09-02 12:29:23 +02:00
parent 339db00f85
commit dba4bff703
35 changed files with 133 additions and 132 deletions

View File

@@ -33,7 +33,7 @@ namespace Internal {
ClangCompletionAssistInterface::ClangCompletionAssistInterface(BackendCommunicator &communicator, CompletionType type, ClangCompletionAssistInterface::ClangCompletionAssistInterface(BackendCommunicator &communicator, CompletionType type,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const ProjectExplorer::HeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features) const CPlusPlus::LanguageFeatures &features)

View File

@@ -42,7 +42,7 @@ public:
CompletionType type, CompletionType type,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const ProjectExplorer::HeaderPaths &headerPaths, const ProjectExplorer::HeaderPaths &headerPaths,
const CPlusPlus::LanguageFeatures &features); const CPlusPlus::LanguageFeatures &features);

View File

@@ -135,7 +135,7 @@ QList<AssistProposalItemInterface *> ClangCompletionAssistProcessor::toAssistPro
return c.completionKind == CodeCompletion::SignalCompletionKind; return c.completionKind == CodeCompletion::SignalCompletionKind;
})) { })) {
considerOnlySignals = CppTools::CppModelManager::instance() considerOnlySignals = CppTools::CppModelManager::instance()
->positionRequiresSignal(m_interface->fileName(), m_content, m_position); ->positionRequiresSignal(m_interface->filePath().toString(), m_content, m_position);
} }
for (const CodeCompletion &codeCompletion : completions) { for (const CodeCompletion &codeCompletion : completions) {
@@ -492,8 +492,8 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor)
// Make completion for all relevant includes // Make completion for all relevant includes
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths(); 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); ProjectExplorer::HeaderPathType::User);
if (!headerPaths.contains(currentFilePath)) if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath); headerPaths.append(currentFilePath);
@@ -608,7 +608,7 @@ void ClangCompletionAssistProcessor::sendFileContent(const QByteArray &customFil
const UnsavedFileContentInfo info = unsavedFileContent(customFileContent); const UnsavedFileContentInfo info = unsavedFileContent(customFileContent);
BackendCommunicator &communicator = m_interface->communicator(); BackendCommunicator &communicator = m_interface->communicator();
communicator.documentsChanged({{m_interface->fileName(), communicator.documentsChanged({{m_interface->filePath().toString(),
Utf8String::fromByteArray(info.unsavedContent), Utf8String::fromByteArray(info.unsavedContent),
info.isDocumentModified, info.isDocumentModified,
uint(m_interface->textDocument()->revision())}}); uint(m_interface->textDocument()->revision())}});
@@ -677,7 +677,7 @@ bool ClangCompletionAssistProcessor::sendCompletionRequest(int position,
const QByteArray &customFileContent, const QByteArray &customFileContent,
int functionNameStartPosition) int functionNameStartPosition)
{ {
const QString filePath = m_interface->fileName(); const QString filePath = m_interface->filePath().toString();
auto &communicator = m_interface->communicator(); auto &communicator = m_interface->communicator();

View File

@@ -60,13 +60,14 @@ TextEditor::IAssistProcessor *ClangCompletionAssistProvider::createProcessor() c
} }
TextEditor::AssistInterface *ClangCompletionAssistProvider::createAssistInterface( TextEditor::AssistInterface *ClangCompletionAssistProvider::createAssistInterface(
const QString &filePath, const Utils::FilePath &filePath,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
const CPlusPlus::LanguageFeatures &/*languageFeatures*/, const CPlusPlus::LanguageFeatures & /*languageFeatures*/,
int position, int position,
TextEditor::AssistReason reason) const TextEditor::AssistReason reason) const
{ {
const CppTools::ProjectPart::Ptr projectPart = projectPartForFileBasedOnProcessor(filePath); const CppTools::ProjectPart::Ptr projectPart = projectPartForFileBasedOnProcessor(
filePath.toString());
if (projectPart) { if (projectPart) {
return new ClangCompletionAssistInterface(m_communicator, return new ClangCompletionAssistInterface(m_communicator,
m_type, m_type,

View File

@@ -46,11 +46,11 @@ public:
TextEditor::IAssistProcessor *createProcessor() const override; TextEditor::IAssistProcessor *createProcessor() const override;
TextEditor::AssistInterface *createAssistInterface( TextEditor::AssistInterface *createAssistInterface(
const QString &filePath, const Utils::FilePath &filePath,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
const CPlusPlus::LanguageFeatures &languageFeatures, const CPlusPlus::LanguageFeatures &languageFeatures,
int position, int position,
TextEditor::AssistReason reason) const override; TextEditor::AssistReason reason) const override;
private: private:
BackendCommunicator &m_communicator; BackendCommunicator &m_communicator;

View File

@@ -292,7 +292,7 @@ TextEditor::QuickFixOperations ClangEditorDocumentProcessor::extraRefactoringOpe
{ {
ClangFixItOperationsExtractor extractor(m_diagnosticManager.diagnosticsWithFixIts()); ClangFixItOperationsExtractor extractor(m_diagnosticManager.diagnosticsWithFixIts());
return extractor.extract(assistInterface.fileName(), currentLine(assistInterface)); return extractor.extract(assistInterface.filePath().toString(), currentLine(assistInterface));
} }
void ClangEditorDocumentProcessor::editorDocumentTimerRestarted() void ClangEditorDocumentProcessor::editorDocumentTimerRestarted()

View File

@@ -346,7 +346,7 @@ static TextEditor::AssistInterface createAssistInterface(TextEditor::TextEditorW
{ {
return TextEditor::AssistInterface(widget->document(), return TextEditor::AssistInterface(widget->document(),
lineToPosition(widget->document(), lineNumber), lineToPosition(widget->document(), lineNumber),
widget->textDocument()->filePath().toString(), widget->textDocument()->filePath(),
TextEditor::IdleEditor); TextEditor::IdleEditor);
} }

View File

@@ -59,9 +59,9 @@ CMakeFileCompletionAssist::CMakeFileCompletionAssist() :
IAssistProposal *CMakeFileCompletionAssist::perform(const AssistInterface *interface) IAssistProposal *CMakeFileCompletionAssist::perform(const AssistInterface *interface)
{ {
Keywords kw; Keywords kw;
QString fileName = interface->fileName(); const Utils::FilePath &filePath = interface->filePath();
if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) { if (!filePath.isEmpty() && filePath.toFileInfo().isFile()) {
Project *p = SessionManager::projectForFile(Utils::FilePath::fromString(fileName)); Project *p = SessionManager::projectForFile(filePath);
if (p && p->activeTarget()) { if (p && p->activeTarget()) {
CMakeTool *cmake = CMakeKitAspect::cmakeTool(p->activeTarget()->kit()); CMakeTool *cmake = CMakeKitAspect::cmakeTool(p->activeTarget()->kit());
if (cmake && cmake->isValid()) if (cmake && cmake->isValid())

View File

@@ -1026,7 +1026,7 @@ AssistInterface *CppEditorWidget::createAssistInterface(AssistKind kind, AssistR
if (Document::Ptr doc = d->m_lastSemanticInfo.doc) if (Document::Ptr doc = d->m_lastSemanticInfo.doc)
features = doc->languageFeatures(); features = doc->languageFeatures();
features.objCEnabled |= cppEditorDocument()->isObjCEnabled(); features.objCEnabled |= cppEditorDocument()->isObjCEnabled();
return cap->createAssistInterface(textDocument()->filePath().toString(), return cap->createAssistInterface(textDocument()->filePath(),
this, this,
features, features,
position(), position(),

View File

@@ -706,7 +706,7 @@ public:
return; return;
bool isHeaderFile = false; bool isHeaderFile = false;
m_cppFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); m_cppFileName = correspondingHeaderOrSource(interface.filePath().toString(), &isHeaderFile);
m_factory->setHasImplementationFile(isHeaderFile && !m_cppFileName.isEmpty()); m_factory->setHasImplementationFile(isHeaderFile && !m_cppFileName.isEmpty());
m_valid = true; m_valid = true;

View File

@@ -87,7 +87,7 @@ IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const
CppQuickFixInterface::CppQuickFixInterface(CppEditorWidget *editor, CppQuickFixInterface::CppQuickFixInterface(CppEditorWidget *editor,
AssistReason reason) AssistReason reason)
: AssistInterface(editor->document(), editor->position(), : AssistInterface(editor->document(), editor->position(),
editor->textDocument()->filePath().toString(), reason) editor->textDocument()->filePath(), reason)
, m_editor(editor) , m_editor(editor)
, m_semanticInfo(editor->semanticInfo()) , m_semanticInfo(editor->semanticInfo())
, m_snapshot(CppModelManager::instance()->snapshot()) , m_snapshot(CppModelManager::instance()->snapshot())

View File

@@ -671,7 +671,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
if (negation) { if (negation) {
@@ -763,7 +763,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
changes.flip(currentFile->range(binary->left_expression), changes.flip(currentFile->range(binary->left_expression),
@@ -850,7 +850,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
changes.replace(currentFile->range(pattern->binary_op_token), QLatin1String("||")); changes.replace(currentFile->range(pattern->binary_op_token), QLatin1String("||"));
@@ -937,7 +937,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
@@ -1028,7 +1028,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
@@ -1101,7 +1101,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
@@ -1175,7 +1175,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
@@ -1254,7 +1254,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
const Token binaryToken = currentFile->tokenAt(condition->binary_op_token); const Token binaryToken = currentFile->tokenAt(condition->binary_op_token);
@@ -1493,7 +1493,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
@@ -1697,7 +1697,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
@@ -1759,7 +1759,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
changes.replace(start, end, replacement); changes.replace(start, end, replacement);
@@ -1918,7 +1918,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
TypeOfExpression typeOfExpression; TypeOfExpression typeOfExpression;
typeOfExpression.init(semanticInfo().doc, snapshot(), context().bindings()); typeOfExpression.init(semanticInfo().doc, snapshot(), context().bindings());
@@ -2012,7 +2012,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
for (int i = 1; i < m_name.length(); ++i) { for (int i = 1; i < m_name.length(); ++i) {
const QChar c = m_name.at(i); const QChar c = m_name.at(i);
@@ -2080,7 +2080,7 @@ AddIncludeForUndefinedIdentifierOp::AddIncludeForUndefinedIdentifierOp(
void AddIncludeForUndefinedIdentifierOp::perform() void AddIncludeForUndefinedIdentifierOp::perform()
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr file = refactoring.file(fileName()); CppRefactoringFilePtr file = refactoring.file(filePath().toString());
insertNewIncludeDirective(m_include, file, semanticInfo().doc); insertNewIncludeDirective(m_include, file, semanticInfo().doc);
} }
@@ -2103,7 +2103,7 @@ void AddForwardDeclForUndefinedIdentifierOp::perform()
const QStringList namespaces = parts.mid(0, parts.length() - 1); const QStringList namespaces = parts.mid(0, parts.length() - 1);
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr file = refactoring.file(fileName()); CppRefactoringFilePtr file = refactoring.file(filePath().toString());
NSVisitor visitor(file.data(), namespaces, m_symbolPos); NSVisitor visitor(file.data(), namespaces, m_symbolPos);
visitor.accept(file->cppDocument()->translationUnit()->ast()); visitor.accept(file->cppDocument()->translationUnit()->ast());
@@ -2391,11 +2391,11 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa
qualifiedName.remove(0, 2); qualifiedName.remove(0, 2);
if (indexItems.first()->scopedSymbolName().endsWith(qualifiedName)) { if (indexItems.first()->scopedSymbolName().endsWith(qualifiedName)) {
const ProjectExplorer::Node * const node = ProjectExplorer::ProjectTree const ProjectExplorer::Node * const node = ProjectExplorer::ProjectTree
::nodeForFile(Utils::FilePath::fromString(interface.fileName())); ::nodeForFile(interface.filePath());
ProjectExplorer::FileType fileType = node && node->asFileNode() ProjectExplorer::FileType fileType = node && node->asFileNode()
? node->asFileNode()->fileType() : ProjectExplorer::FileType::Unknown; ? node->asFileNode()->fileType() : ProjectExplorer::FileType::Unknown;
if (fileType == ProjectExplorer::FileType::Unknown if (fileType == ProjectExplorer::FileType::Unknown
&& ProjectFile::isHeader(ProjectFile::classify(interface.fileName()))) { && ProjectFile::isHeader(ProjectFile::classify(interface.filePath().toString()))) {
fileType = ProjectExplorer::FileType::Header; fileType = ProjectExplorer::FileType::Header;
} }
if (fileType == ProjectExplorer::FileType::Header) { if (fileType == ProjectExplorer::FileType::Header) {
@@ -2450,7 +2450,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
int targetEndPos = currentFile->endOf(m_targetParam); int targetEndPos = currentFile->endOf(m_targetParam);
ChangeSet changes; ChangeSet changes;
@@ -2530,7 +2530,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
currentFile->setChangeSet(m_change); currentFile->setChangeSet(m_change);
currentFile->apply(); currentFile->apply();
} }
@@ -2692,7 +2692,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ChangeSet changes; ChangeSet changes;
int start = currentFile->endOf(compoundStatement->lbrace_token); int start = currentFile->endOf(compoundStatement->lbrace_token);
@@ -3062,7 +3062,7 @@ public:
// rewrite the function name // rewrite the function name
if (nameIncludesOperatorName(decl->name())) { if (nameIncludesOperatorName(decl->name())) {
CppRefactoringFilePtr file = refactoring.file(op->fileName()); CppRefactoringFilePtr file = refactoring.file(op->filePath().toString());
const QString operatorNameText = file->textOf(declAST->core_declarator); const QString operatorNameText = file->textOf(declAST->core_declarator);
oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' ')); oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' '));
} }
@@ -3148,7 +3148,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
// Insert Position: Implementation File // Insert Position: Implementation File
DeclaratorAST *declAST = simpleDecl->declarator_list->value; DeclaratorAST *declAST = simpleDecl->declarator_list->value;
InsertDefOperation *op = nullptr; InsertDefOperation *op = nullptr;
ProjectFile::Kind kind = ProjectFile::classify(interface.fileName()); ProjectFile::Kind kind = ProjectFile::classify(interface.filePath().toString());
const bool isHeaderFile = ProjectFile::isHeader(kind); const bool isHeaderFile = ProjectFile::isHeader(kind);
if (isHeaderFile) { if (isHeaderFile) {
CppRefactoringChanges refactoring(interface.snapshot()); CppRefactoringChanges refactoring(interface.snapshot());
@@ -3192,7 +3192,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
result << new InsertDefOperation(interface, decl, declAST, result << new InsertDefOperation(interface, decl, declAST,
InsertionLocation(), InsertionLocation(),
DefPosOutsideClass, DefPosOutsideClass,
interface.fileName()); interface.filePath().toString());
} }
// Insert Position: Inside Class // Insert Position: Inside Class
@@ -3201,8 +3201,8 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
const CppRefactoringFilePtr file = interface.currentFile(); const CppRefactoringFilePtr file = interface.currentFile();
file->lineAndColumn(file->endOf(simpleDecl), &line, &column); file->lineAndColumn(file->endOf(simpleDecl), &line, &column);
const InsertionLocation loc const InsertionLocation loc
= InsertionLocation(interface.fileName(), QString(), QString(), = InsertionLocation(interface.filePath().toString(), QString(),
line, column); QString(), line, column);
result << new InsertDefOperation(interface, decl, declAST, loc, result << new InsertDefOperation(interface, decl, declAST, loc,
DefPosInsideClass, QString(), DefPosInsideClass, QString(),
isFreeFunction); isFreeFunction);
@@ -3488,7 +3488,7 @@ private:
QTC_ASSERT(!m_declarations.isEmpty(), return); QTC_ASSERT(!m_declarations.isEmpty(), return);
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
const bool isHeaderFile = ProjectFile::isHeader(ProjectFile::classify(fileName())); const bool isHeaderFile = ProjectFile::isHeader(ProjectFile::classify(filePath().toString()));
QString cppFile; // Only set if the class is defined in a header file. QString cppFile; // Only set if the class is defined in a header file.
if (isHeaderFile) { if (isHeaderFile) {
InsertionPointLocator locator(refactoring); InsertionPointLocator locator(refactoring);
@@ -3568,12 +3568,12 @@ private:
QTC_ASSERT(finder.decl(), continue); QTC_ASSERT(finder.decl(), continue);
InsertionLocation loc; InsertionLocation loc;
const QString targetFilePath = setting.defPos == DefPosImplementationFile const QString targetFilePath = setting.defPos == DefPosImplementationFile
? cppFile : fileName(); ? cppFile : filePath().toString();
QTC_ASSERT(!targetFilePath.isEmpty(), continue); QTC_ASSERT(!targetFilePath.isEmpty(), continue);
if (setting.defPos == DefPosInsideClass) { if (setting.defPos == DefPosInsideClass) {
int line, column; int line, column;
currentFile()->lineAndColumn(currentFile()->endOf(finder.decl()), &line, &column); currentFile()->lineAndColumn(currentFile()->endOf(finder.decl()), &line, &column);
loc = InsertionLocation(fileName(), QString(), QString(), line, column); loc = InsertionLocation(filePath().toString(), QString(), QString(), line, column);
} }
auto &changeSet = changeSets[targetFilePath]; auto &changeSet = changeSets[targetFilePath];
InsertDefOperation::insertDefinition( InsertDefOperation::insertDefinition(
@@ -3849,7 +3849,7 @@ public:
OperationType op) OperationType op)
{ {
CppRefactoringChanges refactoring(quickFix->snapshot()); CppRefactoringChanges refactoring(quickFix->snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(quickFix->fileName()); CppRefactoringFilePtr currentFile = refactoring.file(quickFix->filePath().toString());
QTC_ASSERT(symbol, return); QTC_ASSERT(symbol, return);
FullySpecifiedType fullySpecifiedType = symbol->type(); FullySpecifiedType fullySpecifiedType = symbol->type();
@@ -4407,7 +4407,7 @@ public:
{ {
QTC_ASSERT(!m_funcReturn || !m_relevantDecls.isEmpty(), return); QTC_ASSERT(!m_funcReturn || !m_relevantDecls.isEmpty(), return);
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
ExtractFunctionOptions options; ExtractFunctionOptions options;
if (m_functionNameGetter) if (m_functionNameGetter)
@@ -5083,7 +5083,7 @@ public:
} else if (Namespace *matchingNamespace = isNamespaceFunction(context(), func)) { } else if (Namespace *matchingNamespace = isNamespaceFunction(context(), func)) {
// Dealing with free functions and inline member functions. // Dealing with free functions and inline member functions.
bool isHeaderFile; bool isHeaderFile;
declFileName = correspondingHeaderOrSource(fileName(), &isHeaderFile); declFileName = correspondingHeaderOrSource(filePath().toString(), &isHeaderFile);
if (!QFile::exists(declFileName)) if (!QFile::exists(declFileName))
return FoundDeclaration(); return FoundDeclaration();
result.file = refactoring.file(declFileName); result.file = refactoring.file(declFileName);
@@ -5115,7 +5115,7 @@ public:
FunctionDeclaratorAST *functionDeclaratorOfDefinition FunctionDeclaratorAST *functionDeclaratorOfDefinition
= functionDeclarator(m_functionDefinition); = functionDeclarator(m_functionDefinition);
const CppRefactoringChanges refactoring(snapshot()); const CppRefactoringChanges refactoring(snapshot());
const CppRefactoringFilePtr currentFile = refactoring.file(fileName()); const CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
deduceTypeNameOfLiteral(currentFile->cppDocument()); deduceTypeNameOfLiteral(currentFile->cppDocument());
ChangeSet changes; ChangeSet changes;
@@ -5291,7 +5291,7 @@ public:
, m_identifierAST(identifierAST) , m_identifierAST(identifierAST)
, m_symbol(symbol) , m_symbol(symbol)
, m_refactoring(snapshot()) , m_refactoring(snapshot())
, m_file(m_refactoring.file(fileName())) , m_file(m_refactoring.file(filePath().toString()))
, m_document(interface.semanticInfo().doc) , m_document(interface.semanticInfo().doc)
{ {
setDescription( setDescription(
@@ -5663,7 +5663,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr file = refactoring.file(fileName()); CppRefactoringFilePtr file = refactoring.file(filePath().toString());
InsertionPointLocator locator(refactoring); InsertionPointLocator locator(refactoring);
ChangeSet declarations; ChangeSet declarations;
@@ -6088,7 +6088,8 @@ void MoveFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOp
return; return;
bool isHeaderFile = false; bool isHeaderFile = false;
const QString cppFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); const QString cppFileName = correspondingHeaderOrSource(interface.filePath().toString(),
&isHeaderFile);
if (isHeaderFile && !cppFileName.isEmpty()) { if (isHeaderFile && !cppFileName.isEmpty()) {
const MoveFuncDefRefactoringHelper::MoveType type = moveOutsideMemberDefinition const MoveFuncDefRefactoringHelper::MoveType type = moveOutsideMemberDefinition
@@ -6182,7 +6183,8 @@ void MoveAllFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFi
return; return;
bool isHeaderFile = false; bool isHeaderFile = false;
const QString cppFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); const QString cppFileName = correspondingHeaderOrSource(interface.filePath().toString(),
&isHeaderFile);
if (isHeaderFile && !cppFileName.isEmpty()) { if (isHeaderFile && !cppFileName.isEmpty()) {
result << new MoveAllFuncDefOutsideOp(interface, result << new MoveAllFuncDefOutsideOp(interface,
MoveFuncDefRefactoringHelper::MoveToCppFile, MoveFuncDefRefactoringHelper::MoveToCppFile,
@@ -6287,7 +6289,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
return; return;
const CppRefactoringChanges refactoring(interface.snapshot()); const CppRefactoringChanges refactoring(interface.snapshot());
const CppRefactoringFilePtr defFile = refactoring.file(interface.fileName()); const CppRefactoringFilePtr defFile = refactoring.file(interface.filePath().toString());
const ChangeSet::Range defRange = defFile->range(completeDefAST); const ChangeSet::Range defRange = defFile->range(completeDefAST);
// Determine declaration (file, range, text); // Determine declaration (file, range, text);
@@ -6342,7 +6344,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
} else if (Namespace *matchingNamespace = isNamespaceFunction(interface.context(), func)) { } else if (Namespace *matchingNamespace = isNamespaceFunction(interface.context(), func)) {
// Dealing with free functions // Dealing with free functions
bool isHeaderFile = false; bool isHeaderFile = false;
declFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); declFileName = correspondingHeaderOrSource(interface.filePath().toString(), &isHeaderFile);
if (isHeaderFile) if (isHeaderFile)
return; return;
@@ -6374,7 +6376,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe
if (!declFileName.isEmpty() && !declText.isEmpty()) if (!declFileName.isEmpty() && !declText.isEmpty())
result << new MoveFuncDefToDeclOp(interface, result << new MoveFuncDefToDeclOp(interface,
interface.fileName(), interface.filePath().toString(),
declFileName, declFileName,
funcAST, declText, funcAST, declText,
defRange, declRange); defRange, declRange);
@@ -6398,7 +6400,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr file = refactoring.file(fileName()); CppRefactoringFilePtr file = refactoring.file(filePath().toString());
// Determine return type and new variable name // Determine return type and new variable name
TypeOfExpression typeOfExpression; TypeOfExpression typeOfExpression;
@@ -6863,7 +6865,7 @@ public:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
const int startPos = currentFile->startOf(m_literal); const int startPos = currentFile->startOf(m_literal);
const int endPos = currentFile->endOf(m_literal); const int endPos = currentFile->endOf(m_literal);
@@ -6950,7 +6952,7 @@ private:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
currentFile->setChangeSet(m_changes); currentFile->setChangeSet(m_changes);
currentFile->apply(); currentFile->apply();
} }
@@ -7252,7 +7254,7 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe
void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface, void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface,
QuickFixOperations &result) QuickFixOperations &result)
{ {
const auto processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(interface.fileName()); const auto processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(interface.filePath().toString());
if (processor) { if (processor) {
const auto clangFixItOperations = processor->extraRefactoringOperations(interface); const auto clangFixItOperations = processor->extraRefactoringOperations(interface);
result.append(clangFixItOperations); result.append(clangFixItOperations);
@@ -7581,9 +7583,9 @@ private:
void perform() override void perform() override
{ {
CppRefactoringChanges refactoring(snapshot()); CppRefactoringChanges refactoring(snapshot());
CppRefactoringFilePtr currentFile = refactoring.file(fileName()); CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString());
if (refactorFile(currentFile, refactoring.snapshot(), currentFile->endOf(m_usingDirective), true)) if (refactorFile(currentFile, refactoring.snapshot(), currentFile->endOf(m_usingDirective), true))
processIncludes(refactoring, fileName()); processIncludes(refactoring, filePath().toString());
for (auto &file : m_changes) for (auto &file : m_changes)
file->apply(); file->apply();
@@ -7660,7 +7662,7 @@ void RemoveUsingNamespace::match(const CppQuickFixInterface &interface, QuickFix
UsingDirectiveAST *usingDirective = path.at(n)->asUsingDirective(); UsingDirectiveAST *usingDirective = path.at(n)->asUsingDirective();
if (usingDirective && usingDirective->name->name->isNameId()) { if (usingDirective && usingDirective->name->name->isNameId()) {
result << new RemoveUsingNamespaceOperation(interface, usingDirective, false); result << new RemoveUsingNamespaceOperation(interface, usingDirective, false);
const bool isHeader = ProjectFile::isHeader(ProjectFile::classify(interface.fileName())); const bool isHeader = ProjectFile::isHeader(ProjectFile::classify(interface.filePath().toString()));
if (isHeader && path.at(n - 1)->asTranslationUnit()) // using namespace at global scope if (isHeader && path.at(n - 1)->asTranslationUnit()) // using namespace at global scope
result << new RemoveUsingNamespaceOperation(interface, usingDirective, true); result << new RemoveUsingNamespaceOperation(interface, usingDirective, true);
} }

View File

@@ -105,7 +105,7 @@ public:
LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures(); LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures();
languageFeatures.objCEnabled = false; languageFeatures.objCEnabled = false;
CppCompletionAssistInterface *ai CppCompletionAssistInterface *ai
= new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath().toString(), = new CppCompletionAssistInterface(m_editorWidget->textDocument()->filePath(),
m_textDocument, m_position, m_textDocument, m_position,
ExplicitlyInvoked, m_snapshot, ExplicitlyInvoked, m_snapshot,
ProjectExplorer::HeaderPaths(), ProjectExplorer::HeaderPaths(),

View File

@@ -424,17 +424,18 @@ IAssistProcessor *InternalCompletionAssistProvider::createProcessor() const
return new InternalCppCompletionAssistProcessor; return new InternalCppCompletionAssistProcessor;
} }
AssistInterface *InternalCompletionAssistProvider::createAssistInterface(const QString &filePath, AssistInterface *InternalCompletionAssistProvider::createAssistInterface(
const TextEditorWidget *textEditorWidget, const Utils::FilePath &filePath,
const LanguageFeatures &languageFeatures, const TextEditorWidget *textEditorWidget,
int position, const LanguageFeatures &languageFeatures,
AssistReason reason) const int position,
AssistReason reason) const
{ {
QTC_ASSERT(textEditorWidget, return nullptr); QTC_ASSERT(textEditorWidget, return nullptr);
return new CppCompletionAssistInterface(filePath, return new CppCompletionAssistInterface(filePath,
textEditorWidget, textEditorWidget,
BuiltinEditorDocumentParser::get(filePath), BuiltinEditorDocumentParser::get(filePath.toString()),
languageFeatures, languageFeatures,
position, position,
reason, reason,
@@ -1092,7 +1093,7 @@ int InternalCppCompletionAssistProcessor::startCompletionHelper()
int line = 0, column = 0; int line = 0, column = 0;
Utils::Text::convertPosition(m_interface->textDocument(), startOfExpression, &line, &column); 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); return startCompletionInternal(fileName, line, column - 1, expression, endOfExpression);
} }
@@ -1117,7 +1118,7 @@ bool InternalCppCompletionAssistProcessor::tryObjCCompletion()
const int startPos = tokens[start].bytesBegin() + tokens.startPosition(); const int startPos = tokens[start].bytesBegin() + tokens.startPosition();
const QString expr = m_interface->textAt(startPos, m_interface->position() - startPos); 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) if (!thisDocument)
return false; return false;
@@ -1260,7 +1261,7 @@ bool InternalCppCompletionAssistProcessor::completeInclude(const QTextCursor &cu
// Make completion for all relevant includes // Make completion for all relevant includes
ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths(); 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); ProjectExplorer::HeaderPathType::User);
if (!headerPaths.contains(currentFilePath)) if (!headerPaths.contains(currentFilePath))
headerPaths.append(currentFilePath); headerPaths.append(currentFilePath);
@@ -1312,7 +1313,7 @@ bool InternalCppCompletionAssistProcessor::objcKeywordsWanted() const
if (!m_interface->languageFeatures().objCEnabled) if (!m_interface->languageFeatures().objCEnabled)
return false; return false;
const QString fileName = m_interface->fileName(); const QString fileName = m_interface->filePath().toString();
const Utils::MimeType mt = Utils::mimeTypeForFile(fileName); const Utils::MimeType mt = Utils::mimeTypeForFile(fileName);
return mt.matchesName(QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)) return mt.matchesName(QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE))

View File

@@ -85,11 +85,11 @@ public:
TextEditor::IAssistProcessor *createProcessor() const override; TextEditor::IAssistProcessor *createProcessor() const override;
TextEditor::AssistInterface *createAssistInterface( TextEditor::AssistInterface *createAssistInterface(
const QString &filePath, const Utils::FilePath &filePath,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
const CPlusPlus::LanguageFeatures &languageFeatures, const CPlusPlus::LanguageFeatures &languageFeatures,
int position, int position,
TextEditor::AssistReason reason) const override; TextEditor::AssistReason reason) const override;
}; };
class InternalCppCompletionAssistProcessor : public CppCompletionAssistProcessor class InternalCppCompletionAssistProcessor : public CppCompletionAssistProcessor
@@ -165,7 +165,7 @@ private:
class CppCompletionAssistInterface : public TextEditor::AssistInterface class CppCompletionAssistInterface : public TextEditor::AssistInterface
{ {
public: public:
CppCompletionAssistInterface(const QString &filePath, CppCompletionAssistInterface(const Utils::FilePath &filePath,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
BuiltinEditorDocumentParser::Ptr parser, BuiltinEditorDocumentParser::Ptr parser,
const CPlusPlus::LanguageFeatures &languageFeatures, const CPlusPlus::LanguageFeatures &languageFeatures,
@@ -179,7 +179,7 @@ public:
, m_languageFeatures(languageFeatures) , m_languageFeatures(languageFeatures)
{} {}
CppCompletionAssistInterface(const QString &filePath, CppCompletionAssistInterface(const Utils::FilePath &filePath,
QTextDocument *textDocument, QTextDocument *textDocument,
int position, int position,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,

View File

@@ -41,6 +41,8 @@ class TextEditorWidget;
class AssistInterface; class AssistInterface;
} }
namespace Utils { class FilePath; }
namespace CppTools { namespace CppTools {
class CPPTOOLS_EXPORT CppCompletionAssistProvider : public TextEditor::CompletionAssistProvider class CPPTOOLS_EXPORT CppCompletionAssistProvider : public TextEditor::CompletionAssistProvider
@@ -54,11 +56,11 @@ public:
bool isContinuationChar(const QChar &c) const override; bool isContinuationChar(const QChar &c) const override;
virtual TextEditor::AssistInterface *createAssistInterface( virtual TextEditor::AssistInterface *createAssistInterface(
const QString &filePath, const Utils::FilePath &filePath,
const TextEditor::TextEditorWidget *textEditorWidget, const TextEditor::TextEditorWidget *textEditorWidget,
const CPlusPlus::LanguageFeatures &languageFeatures, const CPlusPlus::LanguageFeatures &languageFeatures,
int position, int position,
TextEditor::AssistReason reason) const = 0; TextEditor::AssistReason reason) const = 0;
static int activationSequenceChar(const QChar &ch, const QChar &ch2, static int activationSequenceChar(const QChar &ch, const QChar &ch2,
const QChar &ch3, unsigned *kind, const QChar &ch3, unsigned *kind,

View File

@@ -547,7 +547,7 @@ bool GlslCompletionAssistProcessor::acceptsIdleEditor() const
// ----------------------------- // -----------------------------
GlslCompletionAssistInterface::GlslCompletionAssistInterface(QTextDocument *textDocument, GlslCompletionAssistInterface::GlslCompletionAssistInterface(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
AssistReason reason, AssistReason reason,
const QString &mimeType, const QString &mimeType,
const Document::Ptr &glslDoc) const Document::Ptr &glslDoc)

View File

@@ -108,7 +108,7 @@ class GlslCompletionAssistInterface : public TextEditor::AssistInterface
{ {
public: public:
GlslCompletionAssistInterface(QTextDocument *textDocument, GlslCompletionAssistInterface(QTextDocument *textDocument,
int position, const QString &fileName, int position, const Utils::FilePath &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const QString &mimeType, const QString &mimeType,
const Document::Ptr &glslDoc); const Document::Ptr &glslDoc);

View File

@@ -371,7 +371,7 @@ AssistInterface *GlslEditorWidget::createAssistInterface(
if (kind == Completion) if (kind == Completion)
return new GlslCompletionAssistInterface(document(), return new GlslCompletionAssistInterface(document(),
position(), position(),
textDocument()->filePath().toString(), textDocument()->filePath(),
reason, reason,
textDocument()->mimeType(), textDocument()->mimeType(),
m_glslDocument); m_glslDocument);

View File

@@ -1308,10 +1308,10 @@ void Client::rehighlight()
} }
} }
bool Client::documentUpdatePostponed(const QString &fileName) const bool Client::documentUpdatePostponed(const Utils::FilePath &fileName) const
{ {
return Utils::contains(m_documentsToUpdate.keys(), [fileName](const TextEditor::TextDocument *doc) { return Utils::contains(m_documentsToUpdate.keys(), [fileName](const TextEditor::TextDocument *doc) {
return doc->filePath() == Utils::FilePath::fromString(fileName); return doc->filePath() == fileName;
}); });
} }

View File

@@ -179,7 +179,7 @@ public:
HoverHandler *hoverHandler(); HoverHandler *hoverHandler();
void rehighlight(); void rehighlight();
bool documentUpdatePostponed(const QString &fileName) const; bool documentUpdatePostponed(const Utils::FilePath &fileName) const;
signals: signals:
void initialized(LanguageServerProtocol::ServerCapabilities capabilities); void initialized(LanguageServerProtocol::ServerCapabilities capabilities);

View File

@@ -323,13 +323,12 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn
++delta; ++delta;
if (delta < TextEditorSettings::completionSettings().m_characterThreshold) if (delta < TextEditorSettings::completionSettings().m_characterThreshold)
return nullptr; return nullptr;
if (m_client->documentUpdatePostponed(interface->fileName())) { if (m_client->documentUpdatePostponed(interface->filePath())) {
m_postponedUpdateConnection m_postponedUpdateConnection
= QObject::connect(m_client, = QObject::connect(m_client,
&Client::documentUpdated, &Client::documentUpdated,
[this, interface](TextEditor::TextDocument *document) { [this, interface](TextEditor::TextDocument *document) {
if (document->filePath() if (document->filePath() == interface->filePath())
== Utils::FilePath::fromString(interface->fileName()))
perform(interface); perform(interface);
}); });
return nullptr; return nullptr;
@@ -355,8 +354,7 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn
--column; // column is 0 based in the protocol --column; // column is 0 based in the protocol
params.setPosition({line, column}); params.setPosition({line, column});
params.setContext(context); params.setContext(context);
params.setTextDocument(TextDocumentIdentifier( params.setTextDocument(TextDocumentIdentifier(DocumentUri::fromFilePath(interface->filePath())));
DocumentUri::fromFilePath(Utils::FilePath::fromString(interface->fileName()))));
CompletionRequest completionRequest(params); CompletionRequest completionRequest(params);
completionRequest.setResponseCallback([this](auto response) { completionRequest.setResponseCallback([this](auto response) {
this->handleCompletionResponse(response); this->handleCompletionResponse(response);

View File

@@ -85,7 +85,7 @@ IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface
m_pos = interface->position(); m_pos = interface->position();
QTextCursor cursor(interface->textDocument()); QTextCursor cursor(interface->textDocument());
cursor.setPosition(m_pos); cursor.setPosition(m_pos);
auto uri = DocumentUri::fromFilePath(Utils::FilePath::fromString(interface->fileName())); auto uri = DocumentUri::fromFilePath(interface->filePath());
SignatureHelpRequest request((TextDocumentPositionParams(TextDocumentIdentifier(uri), Position(cursor)))); SignatureHelpRequest request((TextDocumentPositionParams(TextDocumentIdentifier(uri), Position(cursor))));
request.setResponseCallback([this](auto response) { this->handleSignatureResponse(response); }); request.setResponseCallback([this](auto response) { this->handleSignatureResponse(response); });
m_client->sendContent(request); m_client->sendContent(request);

View File

@@ -112,7 +112,7 @@ IAssistProposal *LanguageClientQuickFixAssistProcessor::perform(const AssistInte
cursor.select(QTextCursor::LineUnderCursor); cursor.select(QTextCursor::LineUnderCursor);
Range range(cursor); Range range(cursor);
params.setRange(range); params.setRange(range);
auto uri = DocumentUri::fromFilePath(Utils::FilePath::fromString(interface->fileName())); auto uri = DocumentUri::fromFilePath(interface->filePath());
params.setTextDocument(TextDocumentIdentifier(uri)); params.setTextDocument(TextDocumentIdentifier(uri));
CodeActionParams::CodeActionContext context; CodeActionParams::CodeActionContext context;
context.setDiagnostics(m_client->diagnosticsAt(uri, range)); context.setDiagnostics(m_client->diagnosticsAt(uri, range));

View File

@@ -158,8 +158,7 @@ private:
static Suggest::NimSuggest *nimSuggestInstance(const AssistInterface *interface) static Suggest::NimSuggest *nimSuggestInstance(const AssistInterface *interface)
{ {
auto filename = Utils::FilePath::fromString(interface->fileName()); return Nim::Suggest::NimSuggestCache::instance().get(interface->filePath());
return Nim::Suggest::NimSuggestCache::instance().get(filename);
} }
static std::shared_ptr<Suggest::NimSuggestClientRequest> sendRequest(const AssistInterface *interface, static std::shared_ptr<Suggest::NimSuggestClientRequest> sendRequest(const AssistInterface *interface,
@@ -170,8 +169,7 @@ private:
int line = 0, column = 0; int line = 0, column = 0;
Utils::Text::convertPosition(interface->textDocument(), pos, &line, &column); Utils::Text::convertPosition(interface->textDocument(), pos, &line, &column);
QTC_ASSERT(column >= 1, return nullptr); QTC_ASSERT(column >= 1, return nullptr);
auto filename = Utils::FilePath::fromString(interface->fileName()); return suggest->sug(interface->filePath().toString(), line, column - 1, dirtyFile);
return suggest->sug(filename.toString(), line, column - 1, dirtyFile);
} }
static std::unique_ptr<QTemporaryFile> writeDirtyFile(const TextEditor::AssistInterface *interface) static std::unique_ptr<QTemporaryFile> writeDirtyFile(const TextEditor::AssistInterface *interface)

View File

@@ -99,7 +99,7 @@ TextEditor::AssistInterface *BindingEditorWidget::createAssistInterface(
{ {
Q_UNUSED(assistKind) Q_UNUSED(assistKind)
return new QmlJSEditor::QmlJSCompletionAssistInterface( return new QmlJSEditor::QmlJSCompletionAssistInterface(
document(), position(), QString(), document(), position(), Utils::FilePath(),
assistReason, qmljsdocument->semanticInfo()); assistReason, qmljsdocument->semanticInfo());
} }

View File

@@ -145,7 +145,7 @@ QStringList BaseTextEditModifier::autoComplete(QTextDocument *textDocument, int
= qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(bte->textDocument())) = qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(bte->textDocument()))
return QmlJSEditor::qmlJSAutoComplete(textDocument, return QmlJSEditor::qmlJSAutoComplete(textDocument,
position, position,
document->filePath().toString(), document->filePath(),
explicitComplete ? TextEditor::ExplicitlyInvoked : TextEditor::ActivationCharacter, explicitComplete ? TextEditor::ExplicitlyInvoked : TextEditor::ActivationCharacter,
document->semanticInfo()); document->semanticInfo());
return QStringList(); return QStringList();

View File

@@ -328,7 +328,7 @@ bool isLiteral(AST::Node *ast)
QStringList qmlJSAutoComplete(QTextDocument *textDocument, QStringList qmlJSAutoComplete(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const SemanticInfo &info) const SemanticInfo &info)
{ {
@@ -552,8 +552,6 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor()) if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor())
return nullptr; return nullptr;
const QString &fileName = m_interface->fileName();
m_startPosition = assistInterface->position(); m_startPosition = assistInterface->position();
while (isIdentifierChar(m_interface->textDocument()->characterAt(m_startPosition - 1), false, false)) while (isIdentifierChar(m_interface->textDocument()->characterAt(m_startPosition - 1), false, false))
--m_startPosition; --m_startPosition;
@@ -567,10 +565,9 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface *
return nullptr; return nullptr;
const Document::Ptr document = semanticInfo.document; const Document::Ptr document = semanticInfo.document;
const QFileInfo currentFileInfo(fileName);
bool isQmlFile = false; bool isQmlFile = false;
if (currentFileInfo.suffix() == QLatin1String("qml")) if (m_interface->filePath().endsWith(".qml"))
isQmlFile = true; isQmlFile = true;
const QList<AST::Node *> path = semanticInfo.rangePath(m_interface->position()); const QList<AST::Node *> path = semanticInfo.rangePath(m_interface->position());
@@ -983,7 +980,7 @@ bool QmlJSCompletionAssistProcessor::completeUrl(const QString &relativeBasePath
// ------------------------------ // ------------------------------
QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(QTextDocument *textDocument, QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
AssistReason reason, AssistReason reason,
const SemanticInfo &info) const SemanticInfo &info)
: AssistInterface(textDocument, position, fileName, reason) : AssistInterface(textDocument, position, fileName, reason)

View File

@@ -107,7 +107,7 @@ class QMLJSEDITOR_EXPORT QmlJSCompletionAssistInterface : public TextEditor::Ass
public: public:
QmlJSCompletionAssistInterface(QTextDocument *textDocument, QmlJSCompletionAssistInterface(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const QmlJSTools::SemanticInfo &info); const QmlJSTools::SemanticInfo &info);
const QmlJSTools::SemanticInfo &semanticInfo() const; const QmlJSTools::SemanticInfo &semanticInfo() const;
@@ -135,7 +135,7 @@ public:
QStringList QMLJSEDITOR_EXPORT qmlJSAutoComplete(QTextDocument *textDocument, QStringList QMLJSEDITOR_EXPORT qmlJSAutoComplete(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &fileName,
TextEditor::AssistReason reason, TextEditor::AssistReason reason,
const QmlJSTools::SemanticInfo &info); const QmlJSTools::SemanticInfo &info);

View File

@@ -1019,7 +1019,7 @@ AssistInterface *QmlJSEditorWidget::createAssistInterface(
if (assistKind == Completion) { if (assistKind == Completion) {
return new QmlJSCompletionAssistInterface(document(), return new QmlJSCompletionAssistInterface(document(),
position(), position(),
textDocument()->filePath().toString(), textDocument()->filePath(),
reason, reason,
m_qmlJsEditorDocument->semanticInfo()); m_qmlJsEditorDocument->semanticInfo());
} else if (assistKind == QuickFix) { } else if (assistKind == QuickFix) {

View File

@@ -49,7 +49,7 @@ using namespace Internal;
QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor, QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor,
AssistReason reason) AssistReason reason)
: AssistInterface(editor->document(), editor->position(), : AssistInterface(editor->document(), editor->position(),
editor->textDocument()->filePath().toString(), reason) editor->textDocument()->filePath(), reason)
, m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo()) , m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo())
, m_currentFile(QmlJSRefactoringChanges::file(editor, m_semanticInfo.document)) , m_currentFile(QmlJSRefactoringChanges::file(editor, m_semanticInfo.document))
{} {}

View File

@@ -103,12 +103,12 @@ namespace TextEditor {
AssistInterface::AssistInterface(QTextDocument *textDocument, AssistInterface::AssistInterface(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &filePath,
AssistReason reason) AssistReason reason)
: m_textDocument(textDocument) : m_textDocument(textDocument)
, m_isAsync(false) , m_isAsync(false)
, m_position(position) , m_position(position)
, m_fileName(fileName) , m_filePath(filePath)
, m_reason(reason) , m_reason(reason)
{} {}

View File

@@ -32,6 +32,8 @@
#include <QString> #include <QString>
#include <QVector> #include <QVector>
#include <utils/fileutils.h>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QTextDocument; class QTextDocument;
QT_END_NAMESPACE QT_END_NAMESPACE
@@ -43,14 +45,14 @@ class TEXTEDITOR_EXPORT AssistInterface
public: public:
AssistInterface(QTextDocument *textDocument, AssistInterface(QTextDocument *textDocument,
int position, int position,
const QString &fileName, const Utils::FilePath &filePath,
AssistReason reason); AssistReason reason);
virtual ~AssistInterface(); virtual ~AssistInterface();
virtual int position() const { return m_position; } virtual int position() const { return m_position; }
virtual QChar characterAt(int position) const; virtual QChar characterAt(int position) const;
virtual QString textAt(int position, int length) const; virtual QString textAt(int position, int length) const;
virtual QString fileName() const { return m_fileName; } virtual Utils::FilePath filePath() const { return m_filePath; }
virtual QTextDocument *textDocument() const { return m_textDocument; } virtual QTextDocument *textDocument() const { return m_textDocument; }
virtual void prepareForAsyncUse(); virtual void prepareForAsyncUse();
virtual void recreateTextDocument(); virtual void recreateTextDocument();
@@ -60,7 +62,7 @@ private:
QTextDocument *m_textDocument; QTextDocument *m_textDocument;
bool m_isAsync; bool m_isAsync;
int m_position; int m_position;
QString m_fileName; Utils::FilePath m_filePath;
AssistReason m_reason; AssistReason m_reason;
QString m_text; QString m_text;
QVector<int> m_userStates; QVector<int> m_userStates;

View File

@@ -298,7 +298,7 @@ void pathComplete(const AssistInterface *interface, QList<AssistProposalItemInte
if (!items) if (!items)
return; return;
if (interface->fileName().isEmpty()) if (interface->filePath().isEmpty())
return; return;
// For pragmatic reasons, we don't support spaces in file names here. // For pragmatic reasons, we don't support spaces in file names here.
@@ -319,7 +319,7 @@ void pathComplete(const AssistInterface *interface, QList<AssistProposalItemInte
return; return;
const QString word = interface->textAt(startPos, interface->position() - startPos); const QString word = interface->textAt(startPos, interface->position() - startPos);
QDir baseDir = QFileInfo(interface->fileName()).absoluteDir(); QDir baseDir = interface->filePath().toFileInfo().absoluteDir();
const int lastSlashPos = word.lastIndexOf(QLatin1Char('/')); const int lastSlashPos = word.lastIndexOf(QLatin1Char('/'));
QString prefix = word; QString prefix = word;

View File

@@ -8424,7 +8424,7 @@ AssistInterface *TextEditorWidget::createAssistInterface(AssistKind kind,
AssistReason reason) const AssistReason reason) const
{ {
Q_UNUSED(kind) Q_UNUSED(kind)
return new AssistInterface(document(), position(), d->m_document->filePath().toString(), reason); return new AssistInterface(document(), position(), d->m_document->filePath(), reason);
} }
QString TextEditorWidget::foldReplacementText(const QTextBlock &) const QString TextEditorWidget::foldReplacementText(const QTextBlock &) const