aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJake Petroules <jake.petroules@qt.io>2016-11-28 18:05:18 -0800
committerJake Petroules <jake.petroules@qt.io>2016-11-30 11:18:56 +0000
commitdae30e962e2db8e4cfb8ecbee75feebdce8a3e7f (patch)
tree8a9304ba54740a09f9b61c3ff2d48e15b6be5978
parenta05604a1ad38158b88193f7ba575b4258ef3b75e (diff)
Fully qualify references
This helps with building an "amalgamation" build of Qbs where all source files are concatenated. Refereneces to these symbols are otherwise ambiguous. Change-Id: If8cb43b7822fc02df4957a9b5f6b132eae749d7a Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
-rw-r--r--src/lib/corelib/api/projectfileupdater.cpp16
-rw-r--r--src/plugins/scanner/cpp/Lexer.cpp4
-rw-r--r--src/plugins/scanner/cpp/cppscanner.cpp5
3 files changed, 13 insertions, 12 deletions
diff --git a/src/lib/corelib/api/projectfileupdater.cpp b/src/lib/corelib/api/projectfileupdater.cpp
index 74f084b64..2881d45b0 100644
--- a/src/lib/corelib/api/projectfileupdater.cpp
+++ b/src/lib/corelib/api/projectfileupdater.cpp
@@ -244,7 +244,7 @@ void ProjectFileGroupInserter::doApply(QString &fileContent, UiProgram *ast)
changeSet.apply(&fileContent);
}
-static QString getNodeRepresentation(const QString &fileContent, const Node *node)
+static QString getNodeRepresentation(const QString &fileContent, const QbsQmlJS::AST::Node *node)
{
const quint32 start = node->firstSourceLocation().offset;
const quint32 end = node->lastSourceLocation().end();
@@ -329,12 +329,12 @@ void ProjectFileFilesAdder::doApply(QString &fileContent, UiProgram *ast)
UiScriptBinding * const filesBinding = bindingFinder.binding();
if (filesBinding) {
QString filesRepresentation;
- if (filesBinding->statement->kind != Node::Kind_ExpressionStatement)
+ if (filesBinding->statement->kind != QbsQmlJS::AST::Node::Kind_ExpressionStatement)
throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex.")); // TODO: rename, add new and concat.
const ExpressionStatement * const exprStatement
= static_cast<ExpressionStatement *>(filesBinding->statement);
switch (exprStatement->expression->kind) {
- case Node::Kind_ArrayLiteral: {
+ case QbsQmlJS::AST::Node::Kind_ArrayLiteral: {
const ElementList *elem
= static_cast<ArrayLiteral *>(exprStatement->expression)->elements;
QStringList oldFileReprs;
@@ -356,7 +356,7 @@ void ProjectFileFilesAdder::doApply(QString &fileContent, UiProgram *ast)
completeFilesRepr(filesRepresentation, bindingIndentation);
break;
}
- case Node::Kind_StringLiteral: {
+ case QbsQmlJS::AST::Node::Kind_StringLiteral: {
const QString existingElement
= static_cast<StringLiteral *>(exprStatement->expression)->value.toString();
sortedFiles << existingElement;
@@ -432,7 +432,7 @@ void ProjectFileFilesRemover::doApply(QString &fileContent, UiProgram *ast)
m_product.location());
}
- if (bindingFinder.binding()->statement->kind != Node::Kind_ExpressionStatement)
+ if (bindingFinder.binding()->statement->kind != QbsQmlJS::AST::Node::Kind_ExpressionStatement)
throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex."));
const CodeLocation bindingLocation
= toCodeLocation(projectFile(), bindingFinder.binding()->firstSourceLocation());
@@ -448,12 +448,12 @@ void ProjectFileFilesRemover::doApply(QString &fileContent, UiProgram *ast)
const ExpressionStatement * const exprStatement
= static_cast<ExpressionStatement *>(bindingFinder.binding()->statement);
switch (exprStatement->expression->kind) {
- case Node::Kind_ArrayLiteral: {
+ case QbsQmlJS::AST::Node::Kind_ArrayLiteral: {
QStringList filesToRemove = m_files;
QStringList newFilesList;
const ElementList *elem = static_cast<ArrayLiteral *>(exprStatement->expression)->elements;
while (elem) {
- if (elem->expression->kind != Node::Kind_StringLiteral) {
+ if (elem->expression->kind != QbsQmlJS::AST::Node::Kind_StringLiteral) {
throw ErrorInfo(Tr::tr("JavaScript construct in source file is too complex."),
bindingLocation);
}
@@ -478,7 +478,7 @@ void ProjectFileFilesRemover::doApply(QString &fileContent, UiProgram *ast)
filesString, Rewriter::ScriptBinding);
break;
}
- case Node::Kind_StringLiteral: {
+ case QbsQmlJS::AST::Node::Kind_StringLiteral: {
if (m_files.count() != 1) {
throw ErrorInfo(Tr::tr("Was requested to remove %1 files, but there is only "
"one in the list.").arg(m_files.count()), bindingLocation);
diff --git a/src/plugins/scanner/cpp/Lexer.cpp b/src/plugins/scanner/cpp/Lexer.cpp
index 769c3176a..4e06f93b4 100644
--- a/src/plugins/scanner/cpp/Lexer.cpp
+++ b/src/plugins/scanner/cpp/Lexer.cpp
@@ -60,7 +60,7 @@
#include "Lexer.h"
#include <cctype>
-using namespace CPlusPlus;
+namespace CPlusPlus {
Lexer::Lexer(const char *firstChar, const char *lastChar)
: _state(State_Default),
@@ -668,4 +668,4 @@ void Lexer::scan_helper(Token *tok)
} // switch
}
-
+}
diff --git a/src/plugins/scanner/cpp/cppscanner.cpp b/src/plugins/scanner/cpp/cppscanner.cpp
index ab8454ac9..a0f91c3a0 100644
--- a/src/plugins/scanner/cpp/cppscanner.cpp
+++ b/src/plugins/scanner/cpp/cppscanner.cpp
@@ -129,7 +129,8 @@ public:
}
};
-static void scanCppFile(void *opaq, Lexer &yylex, bool scanForFileTags, bool scanForDependencies)
+static void scanCppFile(void *opaq, CPlusPlus::Lexer &yylex, bool scanForFileTags,
+ bool scanForDependencies)
{
const QLatin1Literal includeLiteral("include");
const QLatin1Literal importLiteral("import");
@@ -235,7 +236,7 @@ static Opaq *openScanner(const unsigned short *filePath, Opaq::FileType fileType
return 0;
opaque->fileContent = reinterpret_cast<char *>(vmap);
- Lexer lex(opaque->fileContent, opaque->fileContent + mapl);
+ CPlusPlus::Lexer lex(opaque->fileContent, opaque->fileContent + mapl);
scanCppFile(opaque.data(), lex, flags & ScanForFileTagsFlag, flags & ScanForDependenciesFlag);
return opaque.take();
}