diff options
Diffstat (limited to 'src/core/model')
-rw-r--r-- | src/core/model/Node.cpp | 4 | ||||
-rw-r--r-- | src/core/model/Node.hpp | 22 | ||||
-rw-r--r-- | src/core/model/Project.cpp | 42 | ||||
-rw-r--r-- | src/core/model/Project.hpp | 51 |
4 files changed, 39 insertions, 80 deletions
diff --git a/src/core/model/Node.cpp b/src/core/model/Node.cpp index eb0e4a7..dbc85e2 100644 --- a/src/core/model/Node.cpp +++ b/src/core/model/Node.cpp @@ -363,7 +363,7 @@ bool Node::checkDuplicate(Handle<Node> elem, logger.error(std::string("Element with name \"") + name + std::string("\" defined multiple times in parent ") + type().name + std::string(" \"") + - Utils::join(path(), ".") + std::string("\"")); + Utils::join(path(), ".") + std::string("\""), *elem); return false; } return true; @@ -375,7 +375,7 @@ bool Node::validateName(Logger &logger) const { if (!Utils::isIdentifier(name)) { logger.error(type().name + std::string(" name \"") + name + - std::string("\" is not a valid identifier")); + std::string("\" is not a valid identifier"), this); return false; } return true; diff --git a/src/core/model/Node.hpp b/src/core/model/Node.hpp index c5761a8..6fc7dba 100644 --- a/src/core/model/Node.hpp +++ b/src/core/model/Node.hpp @@ -35,6 +35,7 @@ #include <string> #include <vector> +#include <core/common/Location.hpp> #include <core/managed/Managed.hpp> #include <core/managed/ManagedContainer.hpp> @@ -137,6 +138,12 @@ private: Owned<Node> parent; /** + * Location from which the node was read (specifies the source file and the + * range in that source file). + */ + SourceLocation location; + + /** * A "dirty" flag that signifies if this Node has been already validated * or not. */ @@ -519,6 +526,21 @@ public: * @return the current ValidationState of this Node. */ ValidationState getValidationState() const { return validationState; } + + /** + * Returns the location in the source file. + * + * @return a source location descriptor. + */ + SourceLocation getLocation() const { return location; } + + /** + * Sets the location of the node to the given value. + * + * @param location describes the exact position of the Node in a source + * file. + */ + void setLocation(const SourceLocation &location) {this->location = location;} }; /** diff --git a/src/core/model/Project.cpp b/src/core/model/Project.cpp index fc08660..a0f1f08 100644 --- a/src/core/model/Project.cpp +++ b/src/core/model/Project.cpp @@ -30,17 +30,13 @@ namespace model { Project::Project(Manager &mgr) : Node(mgr), systemTypesystem(acquire(new SystemTypesystem(mgr))), - documents(this), - domains(this), - typesystems(this) + documents(this) { } bool Project::doValidate(Logger &logger) const { - return continueValidation(documents, logger) & - continueValidation(domains, logger) & - continueValidation(typesystems, logger); + return continueValidation(documents, logger); } Rooted<SystemTypesystem> Project::getSystemTypesystem() @@ -50,16 +46,8 @@ Rooted<SystemTypesystem> Project::getSystemTypesystem() Rooted<Typesystem> Project::createTypesystem(const std::string &name) { - Rooted<Typesystem> typesystem{ + return Rooted<Typesystem>{ new Typesystem{getManager(), systemTypesystem, name}}; - addTypesystem(typesystem); - return typesystem; -} - -void Project::addTypesystem(Handle<Typesystem> typesystem) -{ - invalidate(); - typesystems.push_back(typesystem); } Rooted<Document> Project::createDocument(const std::string &name) @@ -69,39 +57,25 @@ Rooted<Document> Project::createDocument(const std::string &name) return document; } -void Project::addDocument(Handle<Document> document) -{ - invalidate(); - documents.push_back(document); -} - Rooted<Domain> Project::createDomain(const std::string &name) { - Rooted<Domain> domain{new Domain(getManager(), systemTypesystem, name)}; - addDomain(domain); - return domain; + return Rooted<Domain>{new Domain(getManager(), systemTypesystem, name)}; } -void Project::addDomain(Handle<Domain> domain) +void Project::addDocument(Handle<Document> document) { invalidate(); - domains.push_back(domain); + documents.push_back(document); } -const NodeVector<Document> &Project::getDocuments() { return documents; } - -const NodeVector<Domain> &Project::getDomains() { return domains; } - -const NodeVector<Typesystem> &Project::getTypesystems() { return typesystems; } +const NodeVector<Document> &Project::getDocuments() const { return documents; } } namespace RttiTypes { const Rtti Project = RttiBuilder<model::Project>("Project") .parent(&Node) .composedOf(&Document) - .composedOf(&Typesystem) - .composedOf(&SystemTypesystem) - .composedOf(&Domain); + .composedOf(&SystemTypesystem); } } diff --git a/src/core/model/Project.hpp b/src/core/model/Project.hpp index 576bd60..4e2a43b 100644 --- a/src/core/model/Project.hpp +++ b/src/core/model/Project.hpp @@ -44,8 +44,9 @@ class Document; class Domain; /** - * The Project class constitutes the top-level node in which documents, domains, - * typesystems and other resources are embedded. + * The Project class constitutes the top-level node in which a collection of + * documents are stored. It also contains an instance of the SystemTypesystem + * and allows for simple creation of new Typesystem and Domain instances. */ class Project : public Node { private: @@ -60,16 +61,6 @@ private: */ NodeVector<Document> documents; - /** - * List containing all loaded domains. - */ - NodeVector<Domain> domains; - - /** - * List containing all loaded typesystems. - */ - NodeVector<Typesystem> typesystems; - protected: /** * Validates the project and all parts it consists of. @@ -103,13 +94,6 @@ public: Rooted<Typesystem> createTypesystem(const std::string &name); /** - * Adds a single new typesystem to the project. - * - * @param typesystem is the typesystem that should be added to the project. - */ - void addTypesystem(Handle<Typesystem> typesystem); - - /** * Returns a new document with the given name and adds it to the list of * documents. * @@ -118,13 +102,6 @@ public: Rooted<Document> createDocument(const std::string &name); /** - * Adds the given document to the list of documents in the project. - * - * @param document is the document that should be added to the project. - */ - void addDocument(Handle<Document> document); - - /** * Returns a new domain with the given name and adds it to the list of * domains. Provides a reference of the system typesystem to the domain. * @@ -133,32 +110,18 @@ public: Rooted<Domain> createDomain(const std::string &name); /** - * Adds the given domain to the list of domains in the project. + * Adds the given document to the list of documents in the project. * - * @param domain is the document that should be added to the project. + * @param document is the document that should be added to the project. */ - void addDomain(Handle<Domain> domain); + void addDocument(Handle<Document> document); /** * Returns all documents of this project. * * @return a reference pointing at the document list. */ - const NodeVector<Document> &getDocuments(); - - /** - * Returns all domains of this project. - * - * @return a reference pointing at the domain list. - */ - const NodeVector<Domain> &getDomains(); - - /** - * Returns all typesystems of this project. - * - * @return a reference pointing at the typesystem list. - */ - const NodeVector<Typesystem> &getTypesystems(); + const NodeVector<Document> &getDocuments() const; }; } |