aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Kandeler <christian.kandeler@theqtcompany.com>2015-07-30 15:01:28 +0200
committerChristian Kandeler <christian.kandeler@theqtcompany.com>2015-07-30 13:10:39 +0000
commit1eaaa3a1d1782304f0976ad083062a0ed2c82a4c (patch)
treecf80c3afdcdb3f5d4d785334968740fb16948ab7
parenta76a6f0417913230fd8b4d4ec8c53c5def6b0a9e (diff)
De-friend ItemReaderASTVisitor from FileContext.
Change-Id: I6b0397b1a8952bf6f48319c3c5d41344f12fc6ea Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
-rw-r--r--src/lib/corelib/language/filecontext.cpp10
-rw-r--r--src/lib/corelib/language/filecontext.h8
-rw-r--r--src/lib/corelib/language/filecontextbase.h4
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.cpp26
-rw-r--r--src/lib/corelib/language/itemreaderastvisitor.h1
5 files changed, 25 insertions, 24 deletions
diff --git a/src/lib/corelib/language/filecontext.cpp b/src/lib/corelib/language/filecontext.cpp
index cf6784be8..d8760f31a 100644
--- a/src/lib/corelib/language/filecontext.cpp
+++ b/src/lib/corelib/language/filecontext.cpp
@@ -30,6 +30,8 @@
#include "filecontext.h"
+#include "item.h"
+
namespace qbs {
namespace Internal {
@@ -43,5 +45,13 @@ FileContextPtr FileContext::create()
return FileContextPtr(new FileContext);
}
+void FileContext::ensureIdScope(ItemPool *itemPool)
+{
+ if (!m_idScope) {
+ m_idScope = Item::create(itemPool);
+ m_idScope->setTypeName(QLatin1String("IdScope"));
+ }
+}
+
} // namespace Internal
} // namespace qbs
diff --git a/src/lib/corelib/language/filecontext.h b/src/lib/corelib/language/filecontext.h
index f0f71f155..14219cd5b 100644
--- a/src/lib/corelib/language/filecontext.h
+++ b/src/lib/corelib/language/filecontext.h
@@ -37,19 +37,19 @@
namespace qbs {
namespace Internal {
class Item;
+class ItemPool;
class FileContext : public FileContextBase
{
- friend class ItemReaderASTVisitor;
-
- FileContext();
-
public:
static FileContextPtr create();
Item *idScope() const { return m_idScope; }
+ void ensureIdScope(ItemPool *itemPool);
private:
+ FileContext();
+
Item *m_idScope;
};
diff --git a/src/lib/corelib/language/filecontextbase.h b/src/lib/corelib/language/filecontextbase.h
index 4be7b7de7..aa2bbbfbe 100644
--- a/src/lib/corelib/language/filecontextbase.h
+++ b/src/lib/corelib/language/filecontextbase.h
@@ -45,10 +45,10 @@ public:
void setContent(const QString &content) { m_content = content; }
const QString &content() const { return m_content; }
- void setJsImports(const JsImports &jsImports) { m_jsImports = jsImports; }
+ void addJsImport(const JsImport &jsImport) { m_jsImports << jsImport; }
JsImports jsImports() const { return m_jsImports; }
- void setJsExtensions(const QStringList &extensions) { m_jsExtensions = extensions; }
+ void addJsExtension(const QString &extension) { m_jsExtensions << extension; }
QStringList jsExtensions() const { return m_jsExtensions; }
void setSearchPaths(const QStringList &paths) { m_searchPaths = paths; }
diff --git a/src/lib/corelib/language/itemreaderastvisitor.cpp b/src/lib/corelib/language/itemreaderastvisitor.cpp
index 3b1f64fea..712008d96 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.cpp
+++ b/src/lib/corelib/language/itemreaderastvisitor.cpp
@@ -82,7 +82,7 @@ bool ItemReaderASTVisitor::visit(AST::UiProgram *ast)
{
Q_UNUSED(ast);
m_sourceValue.clear();
- m_file->m_searchPaths = m_searchPaths;
+ m_file->setSearchPaths(m_searchPaths);
if (Q_UNLIKELY(!ast->members->member))
throw ErrorInfo(Tr::tr("No root item found in %1.").arg(m_file->filePath()));
@@ -173,11 +173,11 @@ bool ItemReaderASTVisitor::visit(AST::UiImportList *uiImportList)
throw ErrorInfo(Tr::tr("Import of built-in extension '%1' "
"must not have 'as' specifier.").arg(extensionName));
}
- if (Q_UNLIKELY(m_file->m_jsExtensions.contains(extensionName))) {
+ if (Q_UNLIKELY(m_file->jsExtensions().contains(extensionName))) {
m_logger.printWarning(Tr::tr("Built-in extension '%1' already "
"imported.").arg(extensionName));
} else {
- m_file->m_jsExtensions << extensionName;
+ m_file->addJsExtension(extensionName);
}
continue;
}
@@ -274,7 +274,7 @@ bool ItemReaderASTVisitor::visit(AST::UiImportList *uiImportList)
for (QHash<QString, JsImport>::const_iterator it = jsImports.constBegin();
it != jsImports.constEnd(); ++it)
{
- m_file->m_jsImports += it.value();
+ m_file->addJsImport(it.value());
}
return false;
@@ -321,11 +321,11 @@ bool ItemReaderASTVisitor::visit(AST::UiObjectDefinition *ast)
= m_visitorState.readFile(baseTypeFileName, m_searchPaths, m_itemPool);
inheritItem(item, rootItem);
- if (rootItem->m_file->m_idScope) {
+ if (rootItem->m_file->idScope()) {
// Make ids from the derived file visible in the base file.
// ### Do we want to turn off this feature? It's QMLish but kind of strange.
- ensureIdScope(item->m_file);
- rootItem->m_file->m_idScope->setPrototype(item->m_file->m_idScope);
+ item->m_file->ensureIdScope(m_itemPool);
+ rootItem->m_file->idScope()->setPrototype(item->m_file->idScope());
}
}
@@ -395,8 +395,8 @@ bool ItemReaderASTVisitor::visit(AST::UiScriptBinding *ast)
if (Q_UNLIKELY(!idExp || idExp->name.isEmpty()))
throw ErrorInfo(Tr::tr("id: must be followed by identifier"));
m_item->m_id = idExp->name.toString();
- ensureIdScope(m_file);
- m_file->m_idScope->m_properties[m_item->m_id] = ItemValue::create(m_item);
+ m_file->ensureIdScope(m_itemPool);
+ m_file->idScope()->m_properties[m_item->m_id] = ItemValue::create(m_item);
return false;
}
@@ -559,14 +559,6 @@ void ItemReaderASTVisitor::inheritItem(Item *dst, const Item *src)
}
}
-void ItemReaderASTVisitor::ensureIdScope(const FileContextPtr &file)
-{
- if (!file->m_idScope) {
- file->m_idScope = Item::create(m_itemPool);
- file->m_idScope->m_typeName = QLatin1String("IdScope");
- }
-}
-
void ItemReaderASTVisitor::setupAlternatives(Item *item)
{
QList<Item *>::iterator it = item->m_children.begin();
diff --git a/src/lib/corelib/language/itemreaderastvisitor.h b/src/lib/corelib/language/itemreaderastvisitor.h
index 077ab29cd..cf85b852f 100644
--- a/src/lib/corelib/language/itemreaderastvisitor.h
+++ b/src/lib/corelib/language/itemreaderastvisitor.h
@@ -77,7 +77,6 @@ private:
const JSSourceValueConstPtr &value);
void checkImportVersion(const QbsQmlJS::AST::SourceLocation &versionToken) const;
static void inheritItem(Item *dst, const Item *src);
- void ensureIdScope(const FileContextPtr &file);
void setupAlternatives(Item *item);
static void replaceConditionScopes(const JSSourceValuePtr &value, Item *newScope);
void handlePropertiesBlock(Item *item, const Item *block);