summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Habacker <[email protected]>2017-06-23 19:34:31 +0200
committerRalf Habacker <[email protected]>2017-06-28 19:31:53 +0200
commita40ff71e50781166e5d271b43ad6c6aa3fc41dfa (patch)
treeb3367fb74bafa5de2126955ec0a3d0c37e708011
parent19d0e5e3a6b872b5e3773ebfbe7f6f60df45644d (diff)
Add artifacts on php import.
-rw-r--r--umbrello/codeimport/import_utils.cpp22
-rw-r--r--umbrello/codeimport/import_utils.h4
-rw-r--r--umbrello/codeimport/phpimport.cpp22
3 files changed, 48 insertions, 0 deletions
diff --git a/umbrello/codeimport/import_utils.cpp b/umbrello/codeimport/import_utils.cpp
index 117385a..c2dfa4f 100644
--- a/umbrello/codeimport/import_utils.cpp
+++ b/umbrello/codeimport/import_utils.cpp
@@ -574,6 +574,28 @@ UMLFolder *createSubDir(const QString& name,
/**
+ * Create a folder for artifacts
+ */
+UMLObject *createArtifactFolder(const QString& name,
+ UMLPackage *parentPkg,
+ const QString &comment)
+{
+ Q_UNUSED(parentPkg);
+
+ UMLObject::ObjectType type = UMLObject::ot_Folder;
+ UMLDoc *umldoc = UMLApp::app()->document();
+ UMLFolder *componentView = umldoc->rootFolder(Uml::ModelType::Component);
+ UMLObject *o = umldoc->findUMLObjectRaw(componentView, name, type);
+ if (o)
+ return o;
+ o = Object_Factory::createUMLObject(type, name, componentView, false);
+ UMLFolder *a = o->asUMLFolder();
+ a->setDoc(comment);
+ DEBUG(DBG_SRC) << name << comment;
+ return o;
+}
+
+/**
* Create an artifact with the given name.
*/
UMLObject *createArtifact(const QString& name,
diff --git a/umbrello/codeimport/import_utils.h b/umbrello/codeimport/import_utils.h
index 2682e9a..8c6b29b 100644
--- a/umbrello/codeimport/import_utils.h
+++ b/umbrello/codeimport/import_utils.h
@@ -37,6 +37,10 @@ namespace Import_Utils {
UMLFolder *parentPkg,
const QString &comment = QString());
+ UMLObject *createArtifactFolder(const QString& name,
+ UMLPackage *parentPkg,
+ const QString &comment);
+
UMLObject *createArtifact(const QString& name,
UMLFolder *parentPkg = NULL,
const QString &comment = QString());
diff --git a/umbrello/codeimport/phpimport.cpp b/umbrello/codeimport/phpimport.cpp
index 252c3ab..311cac2 100644
--- a/umbrello/codeimport/phpimport.cpp
+++ b/umbrello/codeimport/phpimport.cpp
@@ -12,12 +12,14 @@
#include "phpimport.h"
// app includes
+#include "artifact.h"
#include "association.h"
#include "attribute.h"
#include "classifier.h"
#include "debug_utils.h"
#include "enum.h"
#include "import_utils.h"
+#include "object_factory.h"
#include "operation.h"
#include "optionstate.h"
#include "package.h"
@@ -160,6 +162,26 @@ public:
return m_content.mid(begin, end-begin+1);
}
+ void visitStart(StartAst *node)
+ {
+ if (Settings::optionState().codeImportState.createArtifacts) {
+ QFileInfo fi(m_fileName);
+ UMLObject *o = Import_Utils::createArtifactFolder(fi.canonicalPath(), 0, QString());
+ UMLPackage *p = o->asUMLPackage();
+ QString fileName = fi.fileName();
+ o = UMLApp::app()->document()->findUMLObject(fileName, UMLObject::ot_Artifact, p);
+ if (!o)
+ o = Object_Factory::createNewUMLObject(UMLObject::ot_Artifact, fileName, p, true);
+ UMLArtifact *a = o->asUMLArtifact();
+ if (a)
+ a->setDrawAsType(UMLArtifact::file);
+ else
+ uError() << "could not add artifact" << m_fileName;
+ //a->setDoc(comment);
+ }
+ DefaultVisitor::visitStart(node);
+ }
+
void visitSimpleNamespaceDeclarationStatement(NamespaceDeclarationStatementAst *node)
{
QStringList nsNames;