Commit a40ff71e authored by Ralf Habacker's avatar Ralf Habacker

Add artifacts on php import.

parent 19d0e5e3
...@@ -573,6 +573,28 @@ UMLFolder *createSubDir(const QString& name, ...@@ -573,6 +573,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. * Create an artifact with the given name.
*/ */
......
...@@ -37,6 +37,10 @@ namespace Import_Utils { ...@@ -37,6 +37,10 @@ namespace Import_Utils {
UMLFolder *parentPkg, UMLFolder *parentPkg,
const QString &comment = QString()); const QString &comment = QString());
UMLObject *createArtifactFolder(const QString& name,
UMLPackage *parentPkg,
const QString &comment);
UMLObject *createArtifact(const QString& name, UMLObject *createArtifact(const QString& name,
UMLFolder *parentPkg = NULL, UMLFolder *parentPkg = NULL,
const QString &comment = QString()); const QString &comment = QString());
......
...@@ -12,12 +12,14 @@ ...@@ -12,12 +12,14 @@
#include "phpimport.h" #include "phpimport.h"
// app includes // app includes
#include "artifact.h"
#include "association.h" #include "association.h"
#include "attribute.h" #include "attribute.h"
#include "classifier.h" #include "classifier.h"
#include "debug_utils.h" #include "debug_utils.h"
#include "enum.h" #include "enum.h"
#include "import_utils.h" #include "import_utils.h"
#include "object_factory.h"
#include "operation.h" #include "operation.h"
#include "optionstate.h" #include "optionstate.h"
#include "package.h" #include "package.h"
...@@ -160,6 +162,26 @@ public: ...@@ -160,6 +162,26 @@ public:
return m_content.mid(begin, end-begin+1); 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) void visitSimpleNamespaceDeclarationStatement(NamespaceDeclarationStatementAst *node)
{ {
QStringList nsNames; QStringList nsNames;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment