summaryrefslogtreecommitdiff
path: root/src/libs/cplusplus
diff options
context:
space:
mode:
Diffstat (limited to 'src/libs/cplusplus')
-rw-r--r--src/libs/cplusplus/CppDocument.cpp14
-rw-r--r--src/libs/cplusplus/CppDocument.h8
-rw-r--r--src/libs/cplusplus/FastPreprocessor.cpp21
-rw-r--r--src/libs/cplusplus/FastPreprocessor.h11
4 files changed, 29 insertions, 25 deletions
diff --git a/src/libs/cplusplus/CppDocument.cpp b/src/libs/cplusplus/CppDocument.cpp
index 5167e9ad2c..ac4986fb1a 100644
--- a/src/libs/cplusplus/CppDocument.cpp
+++ b/src/libs/cplusplus/CppDocument.cpp
@@ -299,11 +299,11 @@ void Document::setLastModified(const QDateTime &lastModified)
FilePaths Document::includedFiles() const
{
- QStringList files;
+ FilePaths files;
for (const Include &i : std::as_const(_resolvedIncludes))
files.append(i.resolvedFileName());
- files.removeDuplicates();
- return transform(files, &FilePath::fromString);
+ FilePath::removeDuplicates(files);
+ return files;
}
// This assumes to be called with a QDir::cleanPath cleaned fileName.
@@ -786,13 +786,13 @@ QSet<FilePath> Snapshot::allIncludesForDocument(const FilePath &filePath) const
}
QList<Snapshot::IncludeLocation> Snapshot::includeLocationsOfDocument(
- const QString &fileNameOrPath) const
+ const FilePath &fileNameOrPath) const
{
- const bool matchFullPath = FilePath::fromString(fileNameOrPath).isAbsolutePath();
+ const bool matchFullPath = fileNameOrPath.isAbsolutePath();
const auto isMatch = [&](const Document::Include &include) {
if (matchFullPath)
return include.resolvedFileName() == fileNameOrPath;
- return FilePath::fromString(include.resolvedFileName()).fileName() == fileNameOrPath;
+ return include.resolvedFileName().fileName() == fileNameOrPath.fileName();
};
QList<IncludeLocation> result;
for (const_iterator cit = begin(), citEnd = end(); cit != citEnd; ++cit) {
@@ -807,7 +807,7 @@ QList<Snapshot::IncludeLocation> Snapshot::includeLocationsOfDocument(
}
if (!matchFullPath && !foundMatch) {
for (const auto &includeFile : cit.value()->unresolvedIncludes()) {
- if (includeFile.unresolvedFileName() == fileNameOrPath)
+ if (includeFile.unresolvedFileName() == fileNameOrPath.path())
result.push_back({doc, includeFile.line()});
}
}
diff --git a/src/libs/cplusplus/CppDocument.h b/src/libs/cplusplus/CppDocument.h
index 599b8cbc71..44d880ccf6 100644
--- a/src/libs/cplusplus/CppDocument.h
+++ b/src/libs/cplusplus/CppDocument.h
@@ -218,13 +218,13 @@ public:
};
class Include {
- QString _resolvedFileName;
+ Utils::FilePath _resolvedFileName;
QString _unresolvedFileName;
int _line;
Client::IncludeType _type;
public:
- Include(const QString &unresolvedFileName, const QString &resolvedFileName, int line,
+ Include(const QString &unresolvedFileName, const Utils::FilePath &resolvedFileName, int line,
Client::IncludeType type)
: _resolvedFileName(resolvedFileName)
, _unresolvedFileName(unresolvedFileName)
@@ -232,7 +232,7 @@ public:
, _type(type)
{ }
- const QString &resolvedFileName() const
+ const Utils::FilePath &resolvedFileName() const
{ return _resolvedFileName; }
const QString &unresolvedFileName() const
@@ -404,7 +404,7 @@ public:
QSet<Utils::FilePath> allIncludesForDocument(const Utils::FilePath &filePath) const;
- QList<IncludeLocation> includeLocationsOfDocument(const QString &fileNameOrPath) const;
+ QList<IncludeLocation> includeLocationsOfDocument(const Utils::FilePath &fileNameOrPath) const;
Utils::FilePaths filesDependingOn(const Utils::FilePath &filePath) const;
diff --git a/src/libs/cplusplus/FastPreprocessor.cpp b/src/libs/cplusplus/FastPreprocessor.cpp
index c948776c4b..8cc01e6250 100644
--- a/src/libs/cplusplus/FastPreprocessor.cpp
+++ b/src/libs/cplusplus/FastPreprocessor.cpp
@@ -29,11 +29,11 @@ QByteArray FastPreprocessor::run(Document::Ptr newDoc,
_preproc.setKeepComments(true);
if (Document::Ptr doc = _snapshot.document(filePath)) {
- _merged.insert(filePath.toString());
+ _merged.insert(filePath);
for (Snapshot::const_iterator i = _snapshot.begin(), ei = _snapshot.end(); i != ei; ++i) {
if (isInjectedFile(i.key().toString()))
- mergeEnvironment(i.key().toString());
+ mergeEnvironment(i.key());
}
const QList<Document::Include> includes = doc->resolvedIncludes();
@@ -55,20 +55,21 @@ void FastPreprocessor::sourceNeeded(int line, const QString &fileName, IncludeTy
{
Q_UNUSED(initialIncludes)
Q_ASSERT(_currentDoc);
+ FilePath filePath = FilePath::fromString(fileName);
if (_addIncludesToCurrentDoc) {
- // CHECKME: Is that cleanName needed?
- const QString cleanName = QDir::cleanPath(fileName);
- _currentDoc->addIncludeFile(Document::Include(fileName, cleanName, line, mode));
+ // CHECKME: Is that cleanPath needed?
+ const FilePath cleanPath = filePath.cleanPath();
+ _currentDoc->addIncludeFile(Document::Include(fileName, cleanPath, line, mode));
}
- mergeEnvironment(fileName);
+ mergeEnvironment(filePath);
}
-void FastPreprocessor::mergeEnvironment(const QString &fileName)
+void FastPreprocessor::mergeEnvironment(const FilePath &filePath)
{
- if (! _merged.contains(fileName)) {
- _merged.insert(fileName);
+ if (! _merged.contains(filePath)) {
+ _merged.insert(filePath);
- if (Document::Ptr doc = _snapshot.document(fileName)) {
+ if (Document::Ptr doc = _snapshot.document(filePath)) {
const QList<Document::Include> includes = doc->resolvedIncludes();
for (const Document::Include &i : includes)
mergeEnvironment(i.resolvedFileName());
diff --git a/src/libs/cplusplus/FastPreprocessor.h b/src/libs/cplusplus/FastPreprocessor.h
index 0892e120b4..c4f30063fa 100644
--- a/src/libs/cplusplus/FastPreprocessor.h
+++ b/src/libs/cplusplus/FastPreprocessor.h
@@ -3,12 +3,15 @@
#pragma once
-#include "PreprocessorClient.h"
#include "CppDocument.h"
-#include "pp.h"
+#include "PreprocessorClient.h"
+#include "PreprocessorEnvironment.h"
+#include "pp-engine.h"
#include <cplusplus/Control.h>
+#include <utils/filepath.h>
+
#include <QSet>
#include <QString>
@@ -19,11 +22,11 @@ class CPLUSPLUS_EXPORT FastPreprocessor: public Client
Environment _env;
Snapshot _snapshot;
Preprocessor _preproc;
- QSet<QString> _merged;
+ QSet<Utils::FilePath> _merged;
Document::Ptr _currentDoc;
bool _addIncludesToCurrentDoc;
- void mergeEnvironment(const QString &fileName);
+ void mergeEnvironment(const Utils::FilePath &filePath);
public:
FastPreprocessor(const Snapshot &snapshot);