forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -330,5 +330,4 @@ private:
|
||||
bool CPLUSPLUS_EXPORT compareFullyQualifiedName(const QList<const Name *> &path,
|
||||
const QList<const Name *> &other);
|
||||
|
||||
|
||||
} // namespace CPlusPlus
|
||||
} // CPlusPlus
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user