Commit 76fa9516 authored by Ralf Habacker's avatar Ralf Habacker
Browse files

Move creating of uml artifact objects into separate method Import_Utils::createArtifact().

CCBUG:336810
parent 3b638620
......@@ -175,21 +175,6 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
{
QString name = inName;
UMLDoc *umldoc = UMLApp::app()->document();
if (type == UMLObject::ot_Artifact) {
if (!Settings::optionState().codeImportState.createArtifacts)
return 0;
QFileInfo fi(name);
UMLFolder *componentView = umldoc->rootFolder(Uml::ModelType::Component);
UMLObject *o = umldoc->findUMLObjectRaw(componentView, fi.fileName(), type);
if (o)
return o;
o = Object_Factory::createUMLObject(type, fi.fileName(), componentView, false);
UMLArtifact *a = static_cast<UMLArtifact*>(o);
a->setDrawAsType(UMLArtifact::file);
a->setDoc(comment);
DEBUG(DBG_SRC) << name << comment;
return o;
}
UMLFolder *logicalView = umldoc->rootFolder(Uml::ModelType::Logical);
if (parentPkg == NULL) {
// DEBUG(DBG_SRC) << "Import_Utils::createUMLObject(" << name
......@@ -568,6 +553,32 @@ void createGeneralization(UMLClassifier *child, UMLClassifier *parent)
umldoc->addAssociation(assoc);
}
/**
* Create an artifact with the given name.
*/
UMLObject *createArtifact(const QString& name,
UMLPackage *parentPkg,
const QString &comment)
{
Q_UNUSED(parentPkg);
UMLObject::ObjectType type = UMLObject::ot_Artifact;
if (!Settings::optionState().codeImportState.createArtifacts)
return 0;
UMLDoc *umldoc = UMLApp::app()->document();
UMLFolder *componentView = umldoc->rootFolder(Uml::ModelType::Component);
QFileInfo fi(name);
UMLObject *o = umldoc->findUMLObjectRaw(componentView, fi.fileName(), type);
if (o)
return o;
o = Object_Factory::createUMLObject(type, fi.fileName(), componentView, false);
UMLArtifact *a = static_cast<UMLArtifact*>(o);
a->setDrawAsType(UMLArtifact::file);
a->setDoc(comment);
DEBUG(DBG_SRC) << name << comment;
return o;
}
/**
* Create a generalization from the existing child UMLObject to the given
* parent class name.
......
......@@ -29,6 +29,10 @@ class UMLEnum;
*/
namespace Import_Utils {
UMLObject *createArtifact(const QString& name,
UMLPackage *parentPkg = NULL,
const QString &comment = QString());
UMLObject* createUMLObject(UMLObject::ObjectType type,
const QString& name,
UMLPackage *parentPkg = NULL,
......
......@@ -59,7 +59,7 @@ void CppTree2Uml::parseTranslationUnit(const ParsedFile &file)
m_currentDeclarator = 0;
m_anon = 0;
Import_Utils::createUMLObject(UMLObject::ot_Artifact, file.fileName(), 0, file->comment());
Import_Utils::createArtifact(file.fileName(), 0, file->comment());
TreeParser::parseTranslationUnit(file);
}
......
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