diff options
author | David Schulz <david.schulz@qt.io> | 2020-09-02 12:29:23 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2020-09-04 10:14:21 +0000 |
commit | dba4bff70344b5d601015ecdd80398affc4c4bcc (patch) | |
tree | d2f9637439357bffe0da619a488b9ce04eec104f | |
parent | 339db00f8563c7fc865a6166114e684021ac260e (diff) | |
download | qt-creator-dba4bff70344b5d601015ecdd80398affc4c4bcc.tar.gz |
TextEditor: use Utils::FilePath as file member in AssistInterface
Change-Id: I3bf9b013b9350411f918efdb9d1a36a2c22bf972
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
35 files changed, 133 insertions, 132 deletions
diff --git a/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp b/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp index 5468fe3cb0..8f2b5a9ffb 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp +++ b/src/plugins/clangcodemodel/clangcompletionassistinterface.cpp @@ -33,7 +33,7 @@ namespace Internal { ClangCompletionAssistInterface::ClangCompletionAssistInterface(BackendCommunicator &communicator, CompletionType type, const TextEditor::TextEditorWidget *textEditorWidget, int position, - const QString &fileName, + const Utils::FilePath &fileName, TextEditor::AssistReason reason, const ProjectExplorer::HeaderPaths &headerPaths, const CPlusPlus::LanguageFeatures &features) diff --git a/src/plugins/clangcodemodel/clangcompletionassistinterface.h b/src/plugins/clangcodemodel/clangcompletionassistinterface.h index fb797edbc0..ce3f0921c8 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistinterface.h +++ b/src/plugins/clangcodemodel/clangcompletionassistinterface.h @@ -42,7 +42,7 @@ public: CompletionType type, const TextEditor::TextEditorWidget *textEditorWidget, int position, - const QString &fileName, + const Utils::FilePath &fileName, TextEditor::AssistReason reason, const ProjectExplorer::HeaderPaths &headerPaths, const CPlusPlus::LanguageFeatures &features); diff --git a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp index 19c669542d..24ad1b9b2d 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp +++ b/src/plugins/clangcodemodel/clangcompletionassistprocessor.cpp @@ -135,7 +135,7 @@ QList<AssistProposalItemInterface *> ClangCompletionAssistProcessor::toAssistPro return c.completionKind == CodeCompletion::SignalCompletionKind; })) { 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) { @@ -492,8 +492,8 @@ bool ClangCompletionAssistProcessor::completeInclude(const QTextCursor &cursor) // Make completion for all relevant includes ProjectExplorer::HeaderPaths headerPaths = m_interface->headerPaths(); - const ProjectExplorer::HeaderPath currentFilePath(QFileInfo(m_interface->fileName()).path(), - ProjectExplorer::HeaderPathType::User); + const ProjectExplorer::HeaderPath currentFilePath(m_interface->filePath().toFileInfo().path(), + ProjectExplorer::HeaderPathType::User); if (!headerPaths.contains(currentFilePath)) headerPaths.append(currentFilePath); @@ -608,7 +608,7 @@ void ClangCompletionAssistProcessor::sendFileContent(const QByteArray &customFil const UnsavedFileContentInfo info = unsavedFileContent(customFileContent); BackendCommunicator &communicator = m_interface->communicator(); - communicator.documentsChanged({{m_interface->fileName(), + communicator.documentsChanged({{m_interface->filePath().toString(), Utf8String::fromByteArray(info.unsavedContent), info.isDocumentModified, uint(m_interface->textDocument()->revision())}}); @@ -677,7 +677,7 @@ bool ClangCompletionAssistProcessor::sendCompletionRequest(int position, const QByteArray &customFileContent, int functionNameStartPosition) { - const QString filePath = m_interface->fileName(); + const QString filePath = m_interface->filePath().toString(); auto &communicator = m_interface->communicator(); diff --git a/src/plugins/clangcodemodel/clangcompletionassistprovider.cpp b/src/plugins/clangcodemodel/clangcompletionassistprovider.cpp index c69d7ccb5a..f743a9aec9 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistprovider.cpp +++ b/src/plugins/clangcodemodel/clangcompletionassistprovider.cpp @@ -60,13 +60,14 @@ TextEditor::IAssistProcessor *ClangCompletionAssistProvider::createProcessor() c } TextEditor::AssistInterface *ClangCompletionAssistProvider::createAssistInterface( - const QString &filePath, - const TextEditor::TextEditorWidget *textEditorWidget, - const CPlusPlus::LanguageFeatures &/*languageFeatures*/, - int position, - TextEditor::AssistReason reason) const + const Utils::FilePath &filePath, + const TextEditor::TextEditorWidget *textEditorWidget, + const CPlusPlus::LanguageFeatures & /*languageFeatures*/, + int position, + TextEditor::AssistReason reason) const { - const CppTools::ProjectPart::Ptr projectPart = projectPartForFileBasedOnProcessor(filePath); + const CppTools::ProjectPart::Ptr projectPart = projectPartForFileBasedOnProcessor( + filePath.toString()); if (projectPart) { return new ClangCompletionAssistInterface(m_communicator, m_type, diff --git a/src/plugins/clangcodemodel/clangcompletionassistprovider.h b/src/plugins/clangcodemodel/clangcompletionassistprovider.h index 870c13d00d..0276249d96 100644 --- a/src/plugins/clangcodemodel/clangcompletionassistprovider.h +++ b/src/plugins/clangcodemodel/clangcompletionassistprovider.h @@ -46,11 +46,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; private: BackendCommunicator &m_communicator; diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp index 789ba940d2..6efcb8501e 100644 --- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp +++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp @@ -292,7 +292,7 @@ TextEditor::QuickFixOperations ClangEditorDocumentProcessor::extraRefactoringOpe { ClangFixItOperationsExtractor extractor(m_diagnosticManager.diagnosticsWithFixIts()); - return extractor.extract(assistInterface.fileName(), currentLine(assistInterface)); + return extractor.extract(assistInterface.filePath().toString(), currentLine(assistInterface)); } void ClangEditorDocumentProcessor::editorDocumentTimerRestarted() diff --git a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp index cbd1e66d02..8b22f6f145 100644 --- a/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp +++ b/src/plugins/clangcodemodel/clangmodelmanagersupport.cpp @@ -346,7 +346,7 @@ static TextEditor::AssistInterface createAssistInterface(TextEditor::TextEditorW { return TextEditor::AssistInterface(widget->document(), lineToPosition(widget->document(), lineNumber), - widget->textDocument()->filePath().toString(), + widget->textDocument()->filePath(), TextEditor::IdleEditor); } diff --git a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp index 1648902016..b721c147d6 100644 --- a/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp +++ b/src/plugins/cmakeprojectmanager/cmakefilecompletionassist.cpp @@ -59,9 +59,9 @@ CMakeFileCompletionAssist::CMakeFileCompletionAssist() : IAssistProposal *CMakeFileCompletionAssist::perform(const AssistInterface *interface) { Keywords kw; - QString fileName = interface->fileName(); - if (!fileName.isEmpty() && QFileInfo(fileName).isFile()) { - Project *p = SessionManager::projectForFile(Utils::FilePath::fromString(fileName)); + const Utils::FilePath &filePath = interface->filePath(); + if (!filePath.isEmpty() && filePath.toFileInfo().isFile()) { + Project *p = SessionManager::projectForFile(filePath); if (p && p->activeTarget()) { CMakeTool *cmake = CMakeKitAspect::cmakeTool(p->activeTarget()->kit()); if (cmake && cmake->isValid()) diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp index 38083da56f..ad5a4b988f 100644 --- a/src/plugins/cppeditor/cppeditorwidget.cpp +++ b/src/plugins/cppeditor/cppeditorwidget.cpp @@ -1026,7 +1026,7 @@ AssistInterface *CppEditorWidget::createAssistInterface(AssistKind kind, AssistR if (Document::Ptr doc = d->m_lastSemanticInfo.doc) features = doc->languageFeatures(); features.objCEnabled |= cppEditorDocument()->isObjCEnabled(); - return cap->createAssistInterface(textDocument()->filePath().toString(), + return cap->createAssistInterface(textDocument()->filePath(), this, features, position(), diff --git a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp index 6ee831e6ab..209ad213a9 100644 --- a/src/plugins/cppeditor/cppinsertvirtualmethods.cpp +++ b/src/plugins/cppeditor/cppinsertvirtualmethods.cpp @@ -706,7 +706,7 @@ public: return; bool isHeaderFile = false; - m_cppFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); + m_cppFileName = correspondingHeaderOrSource(interface.filePath().toString(), &isHeaderFile); m_factory->setHasImplementationFile(isHeaderFile && !m_cppFileName.isEmpty()); m_valid = true; diff --git a/src/plugins/cppeditor/cppquickfixassistant.cpp b/src/plugins/cppeditor/cppquickfixassistant.cpp index f0a07adea5..cbf78296bc 100644 --- a/src/plugins/cppeditor/cppquickfixassistant.cpp +++ b/src/plugins/cppeditor/cppquickfixassistant.cpp @@ -87,7 +87,7 @@ IAssistProcessor *CppQuickFixAssistProvider::createProcessor() const CppQuickFixInterface::CppQuickFixInterface(CppEditorWidget *editor, AssistReason reason) : AssistInterface(editor->document(), editor->position(), - editor->textDocument()->filePath().toString(), reason) + editor->textDocument()->filePath(), reason) , m_editor(editor) , m_semanticInfo(editor->semanticInfo()) , m_snapshot(CppModelManager::instance()->snapshot()) diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 04b59125da..942d13b5c5 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -671,7 +671,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; if (negation) { @@ -763,7 +763,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; changes.flip(currentFile->range(binary->left_expression), @@ -850,7 +850,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; changes.replace(currentFile->range(pattern->binary_op_token), QLatin1String("||")); @@ -937,7 +937,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; @@ -1028,7 +1028,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; @@ -1101,7 +1101,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; @@ -1175,7 +1175,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; @@ -1254,7 +1254,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); const Token binaryToken = currentFile->tokenAt(condition->binary_op_token); @@ -1493,7 +1493,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; @@ -1697,7 +1697,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; @@ -1759,7 +1759,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; changes.replace(start, end, replacement); @@ -1918,7 +1918,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); TypeOfExpression typeOfExpression; typeOfExpression.init(semanticInfo().doc, snapshot(), context().bindings()); @@ -2012,7 +2012,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); for (int i = 1; i < m_name.length(); ++i) { const QChar c = m_name.at(i); @@ -2080,7 +2080,7 @@ AddIncludeForUndefinedIdentifierOp::AddIncludeForUndefinedIdentifierOp( void AddIncludeForUndefinedIdentifierOp::perform() { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr file = refactoring.file(fileName()); + CppRefactoringFilePtr file = refactoring.file(filePath().toString()); insertNewIncludeDirective(m_include, file, semanticInfo().doc); } @@ -2103,7 +2103,7 @@ void AddForwardDeclForUndefinedIdentifierOp::perform() const QStringList namespaces = parts.mid(0, parts.length() - 1); CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr file = refactoring.file(fileName()); + CppRefactoringFilePtr file = refactoring.file(filePath().toString()); NSVisitor visitor(file.data(), namespaces, m_symbolPos); visitor.accept(file->cppDocument()->translationUnit()->ast()); @@ -2391,11 +2391,11 @@ void AddIncludeForUndefinedIdentifier::match(const CppQuickFixInterface &interfa qualifiedName.remove(0, 2); if (indexItems.first()->scopedSymbolName().endsWith(qualifiedName)) { const ProjectExplorer::Node * const node = ProjectExplorer::ProjectTree - ::nodeForFile(Utils::FilePath::fromString(interface.fileName())); + ::nodeForFile(interface.filePath()); ProjectExplorer::FileType fileType = node && node->asFileNode() ? node->asFileNode()->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; } if (fileType == ProjectExplorer::FileType::Header) { @@ -2450,7 +2450,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); int targetEndPos = currentFile->endOf(m_targetParam); ChangeSet changes; @@ -2530,7 +2530,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); currentFile->setChangeSet(m_change); currentFile->apply(); } @@ -2692,7 +2692,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ChangeSet changes; int start = currentFile->endOf(compoundStatement->lbrace_token); @@ -3062,7 +3062,7 @@ public: // rewrite the function 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); oo.includeWhiteSpaceInOperatorName = operatorNameText.contains(QLatin1Char(' ')); } @@ -3148,7 +3148,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe // Insert Position: Implementation File DeclaratorAST *declAST = simpleDecl->declarator_list->value; InsertDefOperation *op = nullptr; - ProjectFile::Kind kind = ProjectFile::classify(interface.fileName()); + ProjectFile::Kind kind = ProjectFile::classify(interface.filePath().toString()); const bool isHeaderFile = ProjectFile::isHeader(kind); if (isHeaderFile) { CppRefactoringChanges refactoring(interface.snapshot()); @@ -3192,7 +3192,7 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe result << new InsertDefOperation(interface, decl, declAST, InsertionLocation(), DefPosOutsideClass, - interface.fileName()); + interface.filePath().toString()); } // Insert Position: Inside Class @@ -3201,8 +3201,8 @@ void InsertDefFromDecl::match(const CppQuickFixInterface &interface, QuickFixOpe const CppRefactoringFilePtr file = interface.currentFile(); file->lineAndColumn(file->endOf(simpleDecl), &line, &column); const InsertionLocation loc - = InsertionLocation(interface.fileName(), QString(), QString(), - line, column); + = InsertionLocation(interface.filePath().toString(), QString(), + QString(), line, column); result << new InsertDefOperation(interface, decl, declAST, loc, DefPosInsideClass, QString(), isFreeFunction); @@ -3488,7 +3488,7 @@ private: QTC_ASSERT(!m_declarations.isEmpty(), return); 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. if (isHeaderFile) { InsertionPointLocator locator(refactoring); @@ -3568,12 +3568,12 @@ private: QTC_ASSERT(finder.decl(), continue); InsertionLocation loc; const QString targetFilePath = setting.defPos == DefPosImplementationFile - ? cppFile : fileName(); + ? cppFile : filePath().toString(); QTC_ASSERT(!targetFilePath.isEmpty(), continue); if (setting.defPos == DefPosInsideClass) { int 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]; InsertDefOperation::insertDefinition( @@ -3849,7 +3849,7 @@ public: OperationType op) { CppRefactoringChanges refactoring(quickFix->snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(quickFix->fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(quickFix->filePath().toString()); QTC_ASSERT(symbol, return); FullySpecifiedType fullySpecifiedType = symbol->type(); @@ -4407,7 +4407,7 @@ public: { QTC_ASSERT(!m_funcReturn || !m_relevantDecls.isEmpty(), return); CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); ExtractFunctionOptions options; if (m_functionNameGetter) @@ -5083,7 +5083,7 @@ public: } else if (Namespace *matchingNamespace = isNamespaceFunction(context(), func)) { // Dealing with free functions and inline member functions. bool isHeaderFile; - declFileName = correspondingHeaderOrSource(fileName(), &isHeaderFile); + declFileName = correspondingHeaderOrSource(filePath().toString(), &isHeaderFile); if (!QFile::exists(declFileName)) return FoundDeclaration(); result.file = refactoring.file(declFileName); @@ -5115,7 +5115,7 @@ public: FunctionDeclaratorAST *functionDeclaratorOfDefinition = functionDeclarator(m_functionDefinition); const CppRefactoringChanges refactoring(snapshot()); - const CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + const CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); deduceTypeNameOfLiteral(currentFile->cppDocument()); ChangeSet changes; @@ -5291,7 +5291,7 @@ public: , m_identifierAST(identifierAST) , m_symbol(symbol) , m_refactoring(snapshot()) - , m_file(m_refactoring.file(fileName())) + , m_file(m_refactoring.file(filePath().toString())) , m_document(interface.semanticInfo().doc) { setDescription( @@ -5663,7 +5663,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr file = refactoring.file(fileName()); + CppRefactoringFilePtr file = refactoring.file(filePath().toString()); InsertionPointLocator locator(refactoring); ChangeSet declarations; @@ -6088,7 +6088,8 @@ void MoveFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFixOp return; bool isHeaderFile = false; - const QString cppFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); + const QString cppFileName = correspondingHeaderOrSource(interface.filePath().toString(), + &isHeaderFile); if (isHeaderFile && !cppFileName.isEmpty()) { const MoveFuncDefRefactoringHelper::MoveType type = moveOutsideMemberDefinition @@ -6182,7 +6183,8 @@ void MoveAllFuncDefOutside::match(const CppQuickFixInterface &interface, QuickFi return; bool isHeaderFile = false; - const QString cppFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); + const QString cppFileName = correspondingHeaderOrSource(interface.filePath().toString(), + &isHeaderFile); if (isHeaderFile && !cppFileName.isEmpty()) { result << new MoveAllFuncDefOutsideOp(interface, MoveFuncDefRefactoringHelper::MoveToCppFile, @@ -6287,7 +6289,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe return; 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); // Determine declaration (file, range, text); @@ -6342,7 +6344,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe } else if (Namespace *matchingNamespace = isNamespaceFunction(interface.context(), func)) { // Dealing with free functions bool isHeaderFile = false; - declFileName = correspondingHeaderOrSource(interface.fileName(), &isHeaderFile); + declFileName = correspondingHeaderOrSource(interface.filePath().toString(), &isHeaderFile); if (isHeaderFile) return; @@ -6374,7 +6376,7 @@ void MoveFuncDefToDecl::match(const CppQuickFixInterface &interface, QuickFixOpe if (!declFileName.isEmpty() && !declText.isEmpty()) result << new MoveFuncDefToDeclOp(interface, - interface.fileName(), + interface.filePath().toString(), declFileName, funcAST, declText, defRange, declRange); @@ -6398,7 +6400,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr file = refactoring.file(fileName()); + CppRefactoringFilePtr file = refactoring.file(filePath().toString()); // Determine return type and new variable name TypeOfExpression typeOfExpression; @@ -6863,7 +6865,7 @@ public: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); const int startPos = currentFile->startOf(m_literal); const int endPos = currentFile->endOf(m_literal); @@ -6950,7 +6952,7 @@ private: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); currentFile->setChangeSet(m_changes); currentFile->apply(); } @@ -7252,7 +7254,7 @@ void ConvertQt4Connect::match(const CppQuickFixInterface &interface, QuickFixOpe void ExtraRefactoringOperations::match(const CppQuickFixInterface &interface, QuickFixOperations &result) { - const auto processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(interface.fileName()); + const auto processor = CppTools::CppToolsBridge::baseEditorDocumentProcessor(interface.filePath().toString()); if (processor) { const auto clangFixItOperations = processor->extraRefactoringOperations(interface); result.append(clangFixItOperations); @@ -7581,9 +7583,9 @@ private: void perform() override { CppRefactoringChanges refactoring(snapshot()); - CppRefactoringFilePtr currentFile = refactoring.file(fileName()); + CppRefactoringFilePtr currentFile = refactoring.file(filePath().toString()); if (refactorFile(currentFile, refactoring.snapshot(), currentFile->endOf(m_usingDirective), true)) - processIncludes(refactoring, fileName()); + processIncludes(refactoring, filePath().toString()); for (auto &file : m_changes) file->apply(); @@ -7660,7 +7662,7 @@ void RemoveUsingNamespace::match(const CppQuickFixInterface &interface, QuickFix UsingDirectiveAST *usingDirective = path.at(n)->asUsingDirective(); if (usingDirective && usingDirective->name->name->isNameId()) { 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 result << new RemoveUsingNamespaceOperation(interface, usingDirective, true); } diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp index 09b1695e9a..73a4035d53 100644 --- a/src/plugins/cpptools/cppcompletion_test.cpp +++ b/src/plugins/cpptools/cppcompletion_test.cpp @@ -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(), diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp index eabe85c62b..48d7ea6beb 100644 --- a/src/plugins/cpptools/cppcompletionassist.cpp +++ b/src/plugins/cpptools/cppcompletionassist.cpp @@ -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)) diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h index 5afdc43593..c15fa33ca8 100644 --- a/src/plugins/cpptools/cppcompletionassist.h +++ b/src/plugins/cpptools/cppcompletionassist.h @@ -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, diff --git a/src/plugins/cpptools/cppcompletionassistprovider.h b/src/plugins/cpptools/cppcompletionassistprovider.h index 66597ea84b..6f0a5577a2 100644 --- a/src/plugins/cpptools/cppcompletionassistprovider.h +++ b/src/plugins/cpptools/cppcompletionassistprovider.h @@ -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, diff --git a/src/plugins/glsleditor/glslcompletionassist.cpp b/src/plugins/glsleditor/glslcompletionassist.cpp index ef86585051..063562d207 100644 --- a/src/plugins/glsleditor/glslcompletionassist.cpp +++ b/src/plugins/glsleditor/glslcompletionassist.cpp @@ -547,7 +547,7 @@ bool GlslCompletionAssistProcessor::acceptsIdleEditor() const // ----------------------------- GlslCompletionAssistInterface::GlslCompletionAssistInterface(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &fileName, AssistReason reason, const QString &mimeType, const Document::Ptr &glslDoc) diff --git a/src/plugins/glsleditor/glslcompletionassist.h b/src/plugins/glsleditor/glslcompletionassist.h index 90a09c108a..3e13da730d 100644 --- a/src/plugins/glsleditor/glslcompletionassist.h +++ b/src/plugins/glsleditor/glslcompletionassist.h @@ -108,7 +108,7 @@ class GlslCompletionAssistInterface : public TextEditor::AssistInterface { public: GlslCompletionAssistInterface(QTextDocument *textDocument, - int position, const QString &fileName, + int position, const Utils::FilePath &fileName, TextEditor::AssistReason reason, const QString &mimeType, const Document::Ptr &glslDoc); diff --git a/src/plugins/glsleditor/glsleditor.cpp b/src/plugins/glsleditor/glsleditor.cpp index 1d290b2cf1..e00ce14c7b 100644 --- a/src/plugins/glsleditor/glsleditor.cpp +++ b/src/plugins/glsleditor/glsleditor.cpp @@ -371,7 +371,7 @@ AssistInterface *GlslEditorWidget::createAssistInterface( if (kind == Completion) return new GlslCompletionAssistInterface(document(), position(), - textDocument()->filePath().toString(), + textDocument()->filePath(), reason, textDocument()->mimeType(), m_glslDocument); diff --git a/src/plugins/languageclient/client.cpp b/src/plugins/languageclient/client.cpp index dad7a1d6b2..a541acc2f5 100644 --- a/src/plugins/languageclient/client.cpp +++ b/src/plugins/languageclient/client.cpp @@ -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 doc->filePath() == Utils::FilePath::fromString(fileName); + return doc->filePath() == fileName; }); } diff --git a/src/plugins/languageclient/client.h b/src/plugins/languageclient/client.h index 85609efdea..f31d18087d 100644 --- a/src/plugins/languageclient/client.h +++ b/src/plugins/languageclient/client.h @@ -179,7 +179,7 @@ public: HoverHandler *hoverHandler(); void rehighlight(); - bool documentUpdatePostponed(const QString &fileName) const; + bool documentUpdatePostponed(const Utils::FilePath &fileName) const; signals: void initialized(LanguageServerProtocol::ServerCapabilities capabilities); diff --git a/src/plugins/languageclient/languageclientcompletionassist.cpp b/src/plugins/languageclient/languageclientcompletionassist.cpp index fe460c1581..499cfc7b96 100644 --- a/src/plugins/languageclient/languageclientcompletionassist.cpp +++ b/src/plugins/languageclient/languageclientcompletionassist.cpp @@ -323,13 +323,12 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn ++delta; if (delta < TextEditorSettings::completionSettings().m_characterThreshold) return nullptr; - if (m_client->documentUpdatePostponed(interface->fileName())) { + if (m_client->documentUpdatePostponed(interface->filePath())) { m_postponedUpdateConnection = QObject::connect(m_client, &Client::documentUpdated, [this, interface](TextEditor::TextDocument *document) { - if (document->filePath() - == Utils::FilePath::fromString(interface->fileName())) + if (document->filePath() == interface->filePath()) perform(interface); }); return nullptr; @@ -355,8 +354,7 @@ IAssistProposal *LanguageClientCompletionAssistProcessor::perform(const AssistIn --column; // column is 0 based in the protocol params.setPosition({line, column}); params.setContext(context); - params.setTextDocument(TextDocumentIdentifier( - DocumentUri::fromFilePath(Utils::FilePath::fromString(interface->fileName())))); + params.setTextDocument(TextDocumentIdentifier(DocumentUri::fromFilePath(interface->filePath()))); CompletionRequest completionRequest(params); completionRequest.setResponseCallback([this](auto response) { this->handleCompletionResponse(response); diff --git a/src/plugins/languageclient/languageclientfunctionhint.cpp b/src/plugins/languageclient/languageclientfunctionhint.cpp index e43791dbcd..41de7a2f80 100644 --- a/src/plugins/languageclient/languageclientfunctionhint.cpp +++ b/src/plugins/languageclient/languageclientfunctionhint.cpp @@ -85,7 +85,7 @@ IAssistProposal *FunctionHintProcessor::perform(const AssistInterface *interface m_pos = interface->position(); QTextCursor cursor(interface->textDocument()); 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)))); request.setResponseCallback([this](auto response) { this->handleSignatureResponse(response); }); m_client->sendContent(request); diff --git a/src/plugins/languageclient/languageclientquickfix.cpp b/src/plugins/languageclient/languageclientquickfix.cpp index 6eb8359ab0..4aea17b7d4 100644 --- a/src/plugins/languageclient/languageclientquickfix.cpp +++ b/src/plugins/languageclient/languageclientquickfix.cpp @@ -112,7 +112,7 @@ IAssistProposal *LanguageClientQuickFixAssistProcessor::perform(const AssistInte cursor.select(QTextCursor::LineUnderCursor); Range range(cursor); params.setRange(range); - auto uri = DocumentUri::fromFilePath(Utils::FilePath::fromString(interface->fileName())); + auto uri = DocumentUri::fromFilePath(interface->filePath()); params.setTextDocument(TextDocumentIdentifier(uri)); CodeActionParams::CodeActionContext context; context.setDiagnostics(m_client->diagnosticsAt(uri, range)); diff --git a/src/plugins/nim/editor/nimcompletionassistprovider.cpp b/src/plugins/nim/editor/nimcompletionassistprovider.cpp index 9a808ff9d5..df3fa232a7 100644 --- a/src/plugins/nim/editor/nimcompletionassistprovider.cpp +++ b/src/plugins/nim/editor/nimcompletionassistprovider.cpp @@ -158,8 +158,7 @@ private: static Suggest::NimSuggest *nimSuggestInstance(const AssistInterface *interface) { - auto filename = Utils::FilePath::fromString(interface->fileName()); - return Nim::Suggest::NimSuggestCache::instance().get(filename); + return Nim::Suggest::NimSuggestCache::instance().get(interface->filePath()); } static std::shared_ptr<Suggest::NimSuggestClientRequest> sendRequest(const AssistInterface *interface, @@ -170,8 +169,7 @@ private: int line = 0, column = 0; Utils::Text::convertPosition(interface->textDocument(), pos, &line, &column); QTC_ASSERT(column >= 1, return nullptr); - auto filename = Utils::FilePath::fromString(interface->fileName()); - return suggest->sug(filename.toString(), line, column - 1, dirtyFile); + return suggest->sug(interface->filePath().toString(), line, column - 1, dirtyFile); } static std::unique_ptr<QTemporaryFile> writeDirtyFile(const TextEditor::AssistInterface *interface) diff --git a/src/plugins/qmldesigner/components/bindingeditor/bindingeditorwidget.cpp b/src/plugins/qmldesigner/components/bindingeditor/bindingeditorwidget.cpp index 91ffa990c4..6cd810df37 100644 --- a/src/plugins/qmldesigner/components/bindingeditor/bindingeditorwidget.cpp +++ b/src/plugins/qmldesigner/components/bindingeditor/bindingeditorwidget.cpp @@ -99,7 +99,7 @@ TextEditor::AssistInterface *BindingEditorWidget::createAssistInterface( { Q_UNUSED(assistKind) return new QmlJSEditor::QmlJSCompletionAssistInterface( - document(), position(), QString(), + document(), position(), Utils::FilePath(), assistReason, qmljsdocument->semanticInfo()); } diff --git a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp index c1298aa92e..03239faedc 100644 --- a/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp +++ b/src/plugins/qmldesigner/designercore/model/basetexteditmodifier.cpp @@ -145,7 +145,7 @@ QStringList BaseTextEditModifier::autoComplete(QTextDocument *textDocument, int = qobject_cast<QmlJSEditor::QmlJSEditorDocument *>(bte->textDocument())) return QmlJSEditor::qmlJSAutoComplete(textDocument, position, - document->filePath().toString(), + document->filePath(), explicitComplete ? TextEditor::ExplicitlyInvoked : TextEditor::ActivationCharacter, document->semanticInfo()); return QStringList(); diff --git a/src/plugins/qmljseditor/qmljscompletionassist.cpp b/src/plugins/qmljseditor/qmljscompletionassist.cpp index 1209e1ab58..cc38dc91ec 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.cpp +++ b/src/plugins/qmljseditor/qmljscompletionassist.cpp @@ -328,7 +328,7 @@ bool isLiteral(AST::Node *ast) QStringList qmlJSAutoComplete(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &fileName, TextEditor::AssistReason reason, const SemanticInfo &info) { @@ -552,8 +552,6 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface * if (assistInterface->reason() == IdleEditor && !acceptsIdleEditor()) return nullptr; - const QString &fileName = m_interface->fileName(); - m_startPosition = assistInterface->position(); while (isIdentifierChar(m_interface->textDocument()->characterAt(m_startPosition - 1), false, false)) --m_startPosition; @@ -567,10 +565,9 @@ IAssistProposal *QmlJSCompletionAssistProcessor::perform(const AssistInterface * return nullptr; const Document::Ptr document = semanticInfo.document; - const QFileInfo currentFileInfo(fileName); bool isQmlFile = false; - if (currentFileInfo.suffix() == QLatin1String("qml")) + if (m_interface->filePath().endsWith(".qml")) isQmlFile = true; const QList<AST::Node *> path = semanticInfo.rangePath(m_interface->position()); @@ -983,7 +980,7 @@ bool QmlJSCompletionAssistProcessor::completeUrl(const QString &relativeBasePath // ------------------------------ QmlJSCompletionAssistInterface::QmlJSCompletionAssistInterface(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &fileName, AssistReason reason, const SemanticInfo &info) : AssistInterface(textDocument, position, fileName, reason) diff --git a/src/plugins/qmljseditor/qmljscompletionassist.h b/src/plugins/qmljseditor/qmljscompletionassist.h index 844e3b42d8..e023a105e5 100644 --- a/src/plugins/qmljseditor/qmljscompletionassist.h +++ b/src/plugins/qmljseditor/qmljscompletionassist.h @@ -107,7 +107,7 @@ class QMLJSEDITOR_EXPORT QmlJSCompletionAssistInterface : public TextEditor::Ass public: QmlJSCompletionAssistInterface(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &fileName, TextEditor::AssistReason reason, const QmlJSTools::SemanticInfo &info); const QmlJSTools::SemanticInfo &semanticInfo() const; @@ -135,7 +135,7 @@ public: QStringList QMLJSEDITOR_EXPORT qmlJSAutoComplete(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &fileName, TextEditor::AssistReason reason, const QmlJSTools::SemanticInfo &info); diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 5cc23f7e6b..235aa91af5 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -1019,7 +1019,7 @@ AssistInterface *QmlJSEditorWidget::createAssistInterface( if (assistKind == Completion) { return new QmlJSCompletionAssistInterface(document(), position(), - textDocument()->filePath().toString(), + textDocument()->filePath(), reason, m_qmlJsEditorDocument->semanticInfo()); } else if (assistKind == QuickFix) { diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp index 37efbaf39c..03fdf54880 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp @@ -49,7 +49,7 @@ using namespace Internal; QmlJSQuickFixAssistInterface::QmlJSQuickFixAssistInterface(QmlJSEditorWidget *editor, AssistReason reason) : AssistInterface(editor->document(), editor->position(), - editor->textDocument()->filePath().toString(), reason) + editor->textDocument()->filePath(), reason) , m_semanticInfo(editor->qmlJsEditorDocument()->semanticInfo()) , m_currentFile(QmlJSRefactoringChanges::file(editor, m_semanticInfo.document)) {} diff --git a/src/plugins/texteditor/codeassist/assistinterface.cpp b/src/plugins/texteditor/codeassist/assistinterface.cpp index eb7119a451..0a25e1ff34 100644 --- a/src/plugins/texteditor/codeassist/assistinterface.cpp +++ b/src/plugins/texteditor/codeassist/assistinterface.cpp @@ -103,12 +103,12 @@ namespace TextEditor { AssistInterface::AssistInterface(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &filePath, AssistReason reason) : m_textDocument(textDocument) , m_isAsync(false) , m_position(position) - , m_fileName(fileName) + , m_filePath(filePath) , m_reason(reason) {} diff --git a/src/plugins/texteditor/codeassist/assistinterface.h b/src/plugins/texteditor/codeassist/assistinterface.h index 340713fc24..85a738309a 100644 --- a/src/plugins/texteditor/codeassist/assistinterface.h +++ b/src/plugins/texteditor/codeassist/assistinterface.h @@ -32,6 +32,8 @@ #include <QString> #include <QVector> +#include <utils/fileutils.h> + QT_BEGIN_NAMESPACE class QTextDocument; QT_END_NAMESPACE @@ -43,14 +45,14 @@ class TEXTEDITOR_EXPORT AssistInterface public: AssistInterface(QTextDocument *textDocument, int position, - const QString &fileName, + const Utils::FilePath &filePath, AssistReason reason); virtual ~AssistInterface(); virtual int position() const { return m_position; } virtual QChar characterAt(int position) 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 void prepareForAsyncUse(); virtual void recreateTextDocument(); @@ -60,7 +62,7 @@ private: QTextDocument *m_textDocument; bool m_isAsync; int m_position; - QString m_fileName; + Utils::FilePath m_filePath; AssistReason m_reason; QString m_text; QVector<int> m_userStates; diff --git a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp index 87a89e9890..bf9e591d7f 100644 --- a/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp +++ b/src/plugins/texteditor/codeassist/keywordscompletionassist.cpp @@ -298,7 +298,7 @@ void pathComplete(const AssistInterface *interface, QList<AssistProposalItemInte if (!items) return; - if (interface->fileName().isEmpty()) + if (interface->filePath().isEmpty()) return; // For pragmatic reasons, we don't support spaces in file names here. @@ -319,7 +319,7 @@ void pathComplete(const AssistInterface *interface, QList<AssistProposalItemInte return; 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('/')); QString prefix = word; diff --git a/src/plugins/texteditor/texteditor.cpp b/src/plugins/texteditor/texteditor.cpp index 204afbe6c2..ea255c21ad 100644 --- a/src/plugins/texteditor/texteditor.cpp +++ b/src/plugins/texteditor/texteditor.cpp @@ -8424,7 +8424,7 @@ AssistInterface *TextEditorWidget::createAssistInterface(AssistKind kind, AssistReason reason) const { 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 |