Commit 1a9d3283 authored by Oliver Kellogg's avatar Oliver Kellogg
Browse files

import_rose.cpp : Align active programming language with model content

- Global `progLang' of type Uml::ProgrammingLanguage::Enum captures
  programming language specified by Rose model.
- In function readAttributes loop of stream.readLine(), if nt is
  PetalNode::nt_string and stringOrNodeOpener is not "(" then test name
  for "language".  If equal then derive progLang from value.string.
- In function loadFromMDL, after parsing the model file,
  - if progLang hash not been established by the model and no code
    generator hash been allocated at UMLApp then allocate generator
    for C++ as default;
  - else if progLang is not the same as the active generator at UMLApp
    then call UMLApp::app()->setGenerator(progLang).

CCBUG: 81364
parent 7d16382f
......@@ -38,6 +38,12 @@ namespace Import_Rose {
*/
QString dirPrefix;
/**
* Set language if encountered in file.
* The last language encountered wins.
*/
Uml::ProgrammingLanguage::Enum progLang = Uml::ProgrammingLanguage::Reserved;
uint nClosures; // Multiple closing parentheses may appear on a single
// line. The parsing is done line-by-line and using
// recursive descent. This means that we can only handle
......@@ -375,6 +381,20 @@ PetalNode *readAttributes(QStringList initialArgs, QTextStream& stream)
bool seenClosing = checkClosing(tokens);
PetalNode::NameValue attr(name, value);
attrs.append(attr);
if (name == QLatin1String("language")) {
QString language(value.string);
language.remove(QLatin1Char('\"'));
if (language == QLatin1String("Analysis"))
progLang = Uml::ProgrammingLanguage::Reserved;
else if (language == QLatin1String("CORBA"))
progLang = Uml::ProgrammingLanguage::IDL;
else if (language == QLatin1String("C++") || language == QLatin1String("VC++"))
progLang = Uml::ProgrammingLanguage::Cpp;
else if (language == QLatin1String("Java"))
progLang = Uml::ProgrammingLanguage::Java;
else if (language == QLatin1String("Ada"))
progLang = Uml::ProgrammingLanguage::Ada;
}
if (seenClosing) {
break;
}
......@@ -497,6 +517,15 @@ UMLPackage* loadFromMDL(QFile& file, UMLPackage *parentPkg /* = 0 */)
if (root == 0)
return 0;
if (progLang == Uml::ProgrammingLanguage::Reserved &&
UMLApp::app()->generator() == nullptr) {
UMLApp::app()->setGenerator(Uml::ProgrammingLanguage::Cpp);
} else if (progLang != UMLApp::app()->activeLanguage()) {
uDebug() << "loadFromMDL: Setting active language to "
<< Uml::ProgrammingLanguage::toString(progLang);
UMLApp::app()->setGenerator(progLang);
}
if (parentPkg) {
UMLPackage *child = petalTree2Uml(root, parentPkg);
delete root;
......
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