diff options
author | hjk <hjk@qt.io> | 2022-11-23 10:28:47 +0100 |
---|---|---|
committer | hjk <hjk@qt.io> | 2022-11-24 15:54:33 +0000 |
commit | 9d80e23256ea139e4ae90187bd8872e6a1fb3a75 (patch) | |
tree | ea7a5b9fe86757e9970d5ffab2d48614e84972da /src/libs/cplusplus/CppDocument.cpp | |
parent | 8d645a506de17b989259fd90ea4e382e06fbeab6 (diff) | |
download | qt-creator-9d80e23256ea139e4ae90187bd8872e6a1fb3a75.tar.gz |
CppEditor: Proliferate FilePath use
This includes one functional change: It drops some cleaning
of the path used to create the CppDocument, which is now
assumed to be done on the caller side.
Change-Id: I5e2a182028e4d5b56282ad85f4a5c665f081754f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Diffstat (limited to 'src/libs/cplusplus/CppDocument.cpp')
-rw-r--r-- | src/libs/cplusplus/CppDocument.cpp | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp index 6362bf0659..458e90af04 100644 --- a/src/libs/cplusplus/CppDocument.cpp +++ b/src/libs/cplusplus/CppDocument.cpp @@ -35,6 +35,7 @@ */ using namespace CPlusPlus; +using namespace Utils; namespace { @@ -243,8 +244,8 @@ private: } // anonymous namespace -Document::Document(const QString &fileName) - : _filePath(Utils::FilePath::fromUserInput(QDir::cleanPath(fileName))), +Document::Document(const FilePath &filePath) + : _filePath(filePath), _globalNamespace(nullptr), _revision(0), _editorRevision(0), @@ -254,9 +255,9 @@ Document::Document(const QString &fileName) _control->setDiagnosticClient(new DocumentDiagnosticClient(this, &_diagnosticMessages)); - const QByteArray localFileName = fileName.toUtf8(); + const QByteArray localFileName = filePath.path().toUtf8(); const StringLiteral *fileId = _control->stringLiteral(localFileName.constData(), - localFileName.size()); + localFileName.size()); _translationUnit = new TranslationUnit(_control, fileId); _translationUnit->setLanguageFeatures(LanguageFeatures::defaultFeatures()); } @@ -517,9 +518,9 @@ const Document::UndefinedMacroUse *Document::findUndefinedMacroUseAt(int utf16ch return nullptr; } -Document::Ptr Document::create(const QString &fileName) +Document::Ptr Document::create(const FilePath &filePath) { - Document::Ptr doc(new Document(fileName)); + Document::Ptr doc(new Document(filePath)); return doc; } @@ -717,11 +718,11 @@ static QList<Macro> macrosDefinedUntilLine(const QList<Macro> ¯os, int line) } Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source, - const Utils::FilePath &fileName, + const FilePath &filePath, int withDefinedMacrosFromDocumentUntilLine) const { - Document::Ptr newDoc = Document::create(fileName.toString()); - if (Document::Ptr thisDocument = document(fileName)) { + Document::Ptr newDoc = Document::create(filePath); + if (Document::Ptr thisDocument = document(filePath)) { newDoc->_revision = thisDocument->_revision; newDoc->_editorRevision = thisDocument->_editorRevision; newDoc->_lastModified = thisDocument->_lastModified; @@ -742,11 +743,11 @@ Document::Ptr Snapshot::preprocessedDocument(const QByteArray &source, } Document::Ptr Snapshot::documentFromSource(const QByteArray &preprocessedCode, - const QString &fileName) const + const FilePath &filePath) const { - Document::Ptr newDoc = Document::create(fileName); + Document::Ptr newDoc = Document::create(filePath); - if (Document::Ptr thisDocument = document(fileName)) { + if (Document::Ptr thisDocument = document(filePath)) { newDoc->_revision = thisDocument->_revision; newDoc->_editorRevision = thisDocument->_editorRevision; newDoc->_lastModified = thisDocument->_lastModified; |