forked from qt-creator/qt-creator
CppEditor: Convert parts of ModelManagerInterface to FilePath
Change-Id: If7503b6d6732e1735eb8d48ece6e80886d10c647 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -773,7 +773,7 @@ void ClangdClient::updateParserConfig(const Utils::FilePath &filePath,
|
||||
const auto projectPart = !config.preferredProjectPartId.isEmpty()
|
||||
? CppEditor::CppModelManager::instance()->projectPartForId(
|
||||
config.preferredProjectPartId)
|
||||
: projectPartForFile(filePath.toString());
|
||||
: projectPartForFile(filePath);
|
||||
if (!projectPart)
|
||||
return;
|
||||
|
||||
|
||||
@@ -426,8 +426,7 @@ IAssistProposal *CustomAssistProcessor::perform()
|
||||
}
|
||||
case CustomAssistMode::IncludePath: {
|
||||
HeaderPaths headerPaths;
|
||||
const ProjectPart::ConstPtr projectPart
|
||||
= projectPartForFile(interface()->filePath().toString());
|
||||
const ProjectPart::ConstPtr projectPart = projectPartForFile(interface()->filePath());
|
||||
if (projectPart)
|
||||
headerPaths = projectPart->headerPaths;
|
||||
completions = completeInclude(m_endPos, m_completionOperator, interface(), headerPaths);
|
||||
|
||||
@@ -92,7 +92,7 @@ CppEditor::BaseEditorDocumentParser::Configuration ClangEditorDocumentProcessor:
|
||||
return parser()->configuration();
|
||||
}
|
||||
|
||||
ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const QString &filePath)
|
||||
ClangEditorDocumentProcessor *ClangEditorDocumentProcessor::get(const Utils::FilePath &filePath)
|
||||
{
|
||||
return qobject_cast<ClangEditorDocumentProcessor*>(
|
||||
CppEditor::CppModelManager::cppEditorDocumentProcessor(filePath));
|
||||
|
||||
@@ -29,7 +29,7 @@ public:
|
||||
CppEditor::BaseEditorDocumentParser::Configuration parserConfig();
|
||||
|
||||
public:
|
||||
static ClangEditorDocumentProcessor *get(const QString &filePath);
|
||||
static ClangEditorDocumentProcessor *get(const Utils::FilePath &filePath);
|
||||
|
||||
signals:
|
||||
void parserConfigChanged(const Utils::FilePath &filePath,
|
||||
|
||||
@@ -162,7 +162,7 @@ static void updateParserConfig(ClangdClient *client)
|
||||
if (!client->documentOpen(editor->textDocument()))
|
||||
return;
|
||||
const Utils::FilePath filePath = editor->textDocument()->filePath();
|
||||
if (const auto processor = ClangEditorDocumentProcessor::get(filePath.toString()))
|
||||
if (const auto processor = ClangEditorDocumentProcessor::get(filePath))
|
||||
client->updateParserConfig(filePath, processor->parserConfig());
|
||||
}
|
||||
}
|
||||
@@ -395,7 +395,7 @@ void ClangModelManagerSupport::onCurrentEditorChanged(Core::IEditor *editor)
|
||||
return;
|
||||
|
||||
const ::Utils::FilePath filePath = editor->document()->filePath();
|
||||
if (auto processor = ClangEditorDocumentProcessor::get(filePath.toString())) {
|
||||
if (auto processor = ClangEditorDocumentProcessor::get(filePath)) {
|
||||
processor->semanticRehighlight();
|
||||
if (const auto client = clientForFile(filePath)) {
|
||||
client->updateParserConfig(filePath, processor->parserConfig());
|
||||
@@ -806,7 +806,7 @@ void ClangModelManagerSupport::onTextMarkContextMenuRequested(TextEditor::TextEd
|
||||
QTC_ASSERT(lineNumber >= 1, return);
|
||||
QTC_ASSERT(menu, return);
|
||||
|
||||
const auto filePath = widget->textDocument()->filePath().toString();
|
||||
const Utils::FilePath filePath = widget->textDocument()->filePath();
|
||||
ClangEditorDocumentProcessor *processor = ClangEditorDocumentProcessor::get(filePath);
|
||||
if (processor) {
|
||||
const auto assistInterface = createAssistInterface(widget, lineNumber);
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace {
|
||||
|
||||
Project *projectForCurrentEditor()
|
||||
{
|
||||
const QString filePath = currentCppEditorDocumentFilePath();
|
||||
const FilePath filePath = currentCppEditorDocumentFilePath();
|
||||
if (filePath.isEmpty())
|
||||
return nullptr;
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ using namespace Utils;
|
||||
namespace ClangCodeModel {
|
||||
namespace Internal {
|
||||
|
||||
ProjectPart::ConstPtr projectPartForFile(const QString &filePath)
|
||||
ProjectPart::ConstPtr projectPartForFile(const FilePath &filePath)
|
||||
{
|
||||
if (const auto parser = CppEditor::BaseEditorDocumentParser::get(filePath))
|
||||
return parser->projectPartInfo().projectPart;
|
||||
@@ -197,15 +197,14 @@ GenerateCompilationDbResult generateCompilationDB(QList<ProjectInfo::ConstPtr> p
|
||||
return GenerateCompilationDbResult(compileCommandsFile.fileName(), QString());
|
||||
}
|
||||
|
||||
QString currentCppEditorDocumentFilePath()
|
||||
FilePath currentCppEditorDocumentFilePath()
|
||||
{
|
||||
QString filePath;
|
||||
FilePath filePath;
|
||||
|
||||
const auto currentEditor = Core::EditorManager::currentEditor();
|
||||
if (currentEditor && CppEditor::CppModelManager::isCppEditor(currentEditor)) {
|
||||
const auto currentDocument = currentEditor->document();
|
||||
if (currentDocument)
|
||||
filePath = currentDocument->filePath().toString();
|
||||
if (const auto currentDocument = currentEditor->document())
|
||||
filePath = currentDocument->filePath();
|
||||
}
|
||||
|
||||
return filePath;
|
||||
|
||||
@@ -47,9 +47,9 @@ QJsonArray clangOptionsForFile(const CppEditor::ProjectFile &file,
|
||||
const QJsonArray &generalOptions,
|
||||
CppEditor::UsePrecompiledHeaders usePch, bool clStyle);
|
||||
|
||||
CppEditor::ProjectPart::ConstPtr projectPartForFile(const QString &filePath);
|
||||
CppEditor::ProjectPart::ConstPtr projectPartForFile(const Utils::FilePath &filePath);
|
||||
|
||||
QString currentCppEditorDocumentFilePath();
|
||||
Utils::FilePath currentCppEditorDocumentFilePath();
|
||||
|
||||
QString diagnosticCategoryPrefixRemoved(const QString &text);
|
||||
|
||||
|
||||
@@ -243,13 +243,13 @@ public:
|
||||
static Command::Ptr parse(BatchFileLineTokenizer &arguments, const CommandContext &context);
|
||||
|
||||
private:
|
||||
QString m_documentFilePath;
|
||||
Utils::FilePath m_documentFilePath;
|
||||
};
|
||||
|
||||
OpenDocumentCommand::OpenDocumentCommand(const CommandContext &context,
|
||||
const QString &documentFilePath)
|
||||
: Command(context)
|
||||
, m_documentFilePath(documentFilePath)
|
||||
, m_documentFilePath(Utils::FilePath::fromString(documentFilePath))
|
||||
{
|
||||
}
|
||||
|
||||
@@ -298,8 +298,7 @@ bool OpenDocumentCommand::run()
|
||||
{
|
||||
qCDebug(debug) << "line" << context().lineNumber << "OpenDocumentCommand" << m_documentFilePath;
|
||||
|
||||
const bool openEditorSucceeded = Core::EditorManager::openEditor(
|
||||
Utils::FilePath::fromString(m_documentFilePath));
|
||||
const bool openEditorSucceeded = Core::EditorManager::openEditor(m_documentFilePath);
|
||||
QTC_ASSERT(openEditorSucceeded, return false);
|
||||
|
||||
auto *processor = ClangEditorDocumentProcessor::get(m_documentFilePath);
|
||||
@@ -393,8 +392,8 @@ bool InsertTextCommand::run()
|
||||
|
||||
TextEditor::BaseTextEditor *editor = currentTextEditor();
|
||||
QTC_ASSERT(editor, return false);
|
||||
const QString documentFilePath = editor->document()->filePath().toString();
|
||||
auto *processor = ClangEditorDocumentProcessor::get(documentFilePath);
|
||||
const Utils::FilePath documentFilePath = editor->document()->filePath();
|
||||
auto processor = ClangEditorDocumentProcessor::get(documentFilePath);
|
||||
QTC_ASSERT(processor, return false);
|
||||
|
||||
editor->insert(m_textToInsert);
|
||||
|
||||
Reference in New Issue
Block a user