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 | |
parent | 8d645a506de17b989259fd90ea4e382e06fbeab6 (diff) |
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')
-rw-r--r-- | src/libs/cplusplus/CppDocument.cpp | 25 | ||||
-rw-r--r-- | src/libs/cplusplus/CppDocument.h | 6 | ||||
-rw-r--r-- | src/libs/cplusplus/LookupContext.cpp | 14 | ||||
-rw-r--r-- | src/libs/cplusplus/LookupContext.h | 3 | ||||
-rw-r--r-- | src/libs/cplusplus/ResolveExpression.cpp | 3 | ||||
-rw-r--r-- | src/libs/cplusplus/TypeOfExpression.cpp | 6 | ||||
-rw-r--r-- | src/libs/qmljs/qmljsfindexportedcpptypes.cpp | 6 |
7 files changed, 32 insertions, 31 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; diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h index fd98098763..13df3a8db0 100644 --- a/src/libs/cplusplus/CppDocument.h +++ b/src/libs/cplusplus/CppDocument.h @@ -32,7 +32,7 @@ class CPLUSPLUS_EXPORT Document Document(const Document &other); void operator =(const Document &other); - Document(const QString &fileName); + Document(const Utils::FilePath &fileName); public: typedef QSharedPointer<Document> Ptr; @@ -113,7 +113,7 @@ public: void check(CheckMode mode = FullCheck); - static Ptr create(const QString &fileName); + static Ptr create(const Utils::FilePath &filePath); class CPLUSPLUS_EXPORT DiagnosticMessage { @@ -406,7 +406,7 @@ public: int withDefinedMacrosFromDocumentUntilLine = -1) const; Document::Ptr documentFromSource(const QByteArray &preprocessedDocument, - const QString &fileName) const; + const Utils::FilePath &filePath) const; QSet<QString> allIncludesForDocument(const QString &fileName) const; diff --git a/src/libs/cplusplus/LookupContext.cpp b/src/libs/cplusplus/LookupContext.cpp index dee9e65d21..82ba363a0c 100644 --- a/src/libs/cplusplus/LookupContext.cpp +++ b/src/libs/cplusplus/LookupContext.cpp @@ -21,7 +21,9 @@ #include <QVarLengthArray> #include <QDebug> -using namespace CPlusPlus; +using namespace Utils; + +namespace CPlusPlus { static const bool debug = qEnvironmentVariableIsSet("QTC_LOOKUPCONTEXT_DEBUG"); @@ -86,8 +88,6 @@ static bool isNestedInstantiationEnclosingTemplate( return true; } -namespace CPlusPlus { - static inline bool compareName(const Name *name, const Name *other) { if (name == other) @@ -117,9 +117,6 @@ bool compareFullyQualifiedName(const QList<const Name *> &path, const QList<cons return true; } -} - -namespace CPlusPlus { namespace Internal { bool operator==(const FullyQualifiedName &left, const FullyQualifiedName &right) @@ -140,7 +137,7 @@ size_t qHash(const FullyQualifiedName &fullyQualifiedName) } return h; } -} + } ///////////////////////////////////////////////////////////////////// @@ -152,7 +149,7 @@ LookupContext::LookupContext() LookupContext::LookupContext(Document::Ptr thisDocument, const Snapshot &snapshot) - : _expressionDocument(Document::create(QLatin1String("<LookupContext>"))) + : _expressionDocument(Document::create(FilePath::fromPathPart(u"<LookupContext>"))) , _thisDocument(thisDocument) , _snapshot(snapshot) , _bindings(new CreateBindings(thisDocument, snapshot)) @@ -2059,3 +2056,4 @@ Symbol *CreateBindings::instantiateTemplateFunction(const Name *instantiationNam return cloner.symbol(specialization, &subst); } +} // CPlusPlus diff --git a/src/libs/cplusplus/LookupContext.h b/src/libs/cplusplus/LookupContext.h index 629f1842d2..196075ae42 100644 --- a/src/libs/cplusplus/LookupContext.h +++ b/src/libs/cplusplus/LookupContext.h @@ -330,5 +330,4 @@ private: bool CPLUSPLUS_EXPORT compareFullyQualifiedName(const QList<const Name *> &path, const QList<const Name *> &other); - -} // namespace CPlusPlus +} // CPlusPlus diff --git a/src/libs/cplusplus/ResolveExpression.cpp b/src/libs/cplusplus/ResolveExpression.cpp index ed0490b4e0..c3628d66b5 100644 --- a/src/libs/cplusplus/ResolveExpression.cpp +++ b/src/libs/cplusplus/ResolveExpression.cpp @@ -27,6 +27,7 @@ #include <map> using namespace CPlusPlus; +using namespace Utils; static const bool debug = qEnvironmentVariableIsSet("QTC_LOOKUPCONTEXT_DEBUG"); @@ -666,7 +667,7 @@ class ExpressionDocumentHelper public: // Set up an expression document with an external Control ExpressionDocumentHelper(const QByteArray &utf8code, Control *control) - : document(Document::create(QLatin1String("<completion>"))) + : document(Document::create(FilePath::fromPathPart(u"<completion>"))) { Control *oldControl = document->swapControl(control); delete oldControl->diagnosticClient(); diff --git a/src/libs/cplusplus/TypeOfExpression.cpp b/src/libs/cplusplus/TypeOfExpression.cpp index 2453ad829f..33002e1d29 100644 --- a/src/libs/cplusplus/TypeOfExpression.cpp +++ b/src/libs/cplusplus/TypeOfExpression.cpp @@ -13,6 +13,8 @@ #include <QSet> +using namespace Utils; + namespace CPlusPlus { TypeOfExpression::TypeOfExpression(): @@ -172,10 +174,10 @@ ExpressionAST *extractExpressionAST(Document::Ptr doc) Document::Ptr documentForExpression(const QByteArray &utf8code) { // create the expression's AST. - Document::Ptr doc = Document::create(QLatin1String("<completion>")); + Document::Ptr doc = Document::create(FilePath::fromPathPart(u"<completion>")); doc->setUtf8Source(utf8code); doc->parse(Document::ParseExpression); return doc; } -} // namespace CPlusPlus +} // CPlusPlus diff --git a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp index 427a73ef3f..641ffb5068 100644 --- a/src/libs/qmljs/qmljsfindexportedcpptypes.cpp +++ b/src/libs/qmljs/qmljsfindexportedcpptypes.cpp @@ -851,9 +851,9 @@ QStringList FindExportedCppTypes::operator()(const CPlusPlus::Document::Ptr &doc // context properties need lookup inside function scope, and thus require a full check CPlusPlus::Document::Ptr localDoc = document; - if (document->checkMode() != CPlusPlus::Document::FullCheck && !contextPropertyDescriptions.isEmpty()) { - localDoc = m_snapshot.documentFromSource(document->utf8Source(), - document->filePath().toString()); + if (document->checkMode() != CPlusPlus::Document::FullCheck + && !contextPropertyDescriptions.isEmpty()) { + localDoc = m_snapshot.documentFromSource(document->utf8Source(), document->filePath()); localDoc->check(); } |