Commit 3c553a2b authored by Oliver Kellogg's avatar Oliver Kellogg Committed by Ralf Habacker
Browse files

(In reply to comment #2)

> (In reply to comment #1)
> > A workaround I found is adding the line indicated with '+'.
> > ms_seenFiles.append(includeFile);
>
> The problem is that the current file is added to the list of seen files
> after importing, which failed when an included file includes the current
> file.

I tested this on current clucene/src/core/CLucene git master and I confirm
your finding.
I therefore commit both comment #2 and a clean version of comment #3:

umbrello/codeimport/classimport.h
- New virtual function initPerFile() lets concrete importers provide
  initializations which are executed before each single file parsed.
  This is different from initialize() in that initialize() is executed only
  once for all files parsed.

umbrello/codeimport/classimport.cpp
- Provide empty default implementation for new function initPerFile()
- In function importFiles(), call importFile() instead of parseFile()
- In function importFile(), call initPerFile() instead of initialize()

umbrello/codeimport/cppimport.{h,cpp}
- Reimplement function initPerFile() from ClassImport.
- In function feedTheModel(), append includeFile to ms_seenFiles prior to
  calling feedTheModel(includeFile) if includeFile is not found in
  ms_seenFiles.

umbrello/codeimport/import_utils.cpp
- In function createUMLObject(), if name.startsWith("::") then remove the
  leading "::" from name, and set parentPkg to logicalView.

umbrello/model_utils.cpp
- In function findUMLObject(), if name.startsWith("::") then remove the
  leading "::" from name, and set currentObj to NULL.

BUG:335914
FIXED-IN:4.13.3
(cherry picked from commit 60fc2177)
parent 35947651
......@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2006-2013 *
* copyright (C) 2006-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
......@@ -56,7 +56,16 @@ ClassImport *ClassImport::createImporterByFileExt(const QString &fileName, CodeI
}
/**
* Import files. :TODO: can be deleted
* Do initializations before importing a single file.
* This is called by importFile() before calling parseFile().
* @todo check if the default implementation should do anything
*/
void ClassImport::initPerFile()
{
}
/**
* Import files.
* @param fileNames List of files to import.
*/
bool ClassImport::importFiles(const QStringList& fileNames)
......@@ -69,7 +78,7 @@ bool ClassImport::importFiles(const QStringList& fileNames)
foreach (const QString& fileName, fileNames) {
umldoc->writeToStatusBar(i18n("Importing file: %1 Progress: %2/%3",
fileName, processedFilesCount, fileNames.size()));
if (!parseFile(fileName))
if (!importFile(fileName))
result = false;
processedFilesCount++;
}
......@@ -79,12 +88,12 @@ bool ClassImport::importFiles(const QStringList& fileNames)
}
/**
* Import files.
* @param files List of files to import.
* Import a single file.
* @param fileName The file to import.
*/
bool ClassImport::importFile(const QString& fileName)
{
initialize();
initPerFile();
return parseFile(fileName);
}
......
......@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2005-2013 *
* copyright (C) 2005-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
......@@ -50,6 +50,8 @@ protected:
*/
virtual void initialize() = 0;
virtual void initPerFile();
/**
* Import a single file.
* To be implemented by inheriting classes.
......
......@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2005-2013 *
* copyright (C) 2005-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
......@@ -88,6 +88,7 @@ void CppImport::feedTheModel(const QString& fileName)
}
uDebug() << fileName << ": " << includeFile << " => " << it.value().first;
if (ms_seenFiles.indexOf(includeFile) == -1)
ms_seenFiles.append(includeFile);
feedTheModel(includeFile);
}
}
......@@ -122,6 +123,13 @@ void CppImport::initialize()
ms_driver->addIncludePath(*i);
}
}
}
/**
* Reimplement method from ClassImport
*/
void CppImport::initPerFile()
{
ms_seenFiles.clear();
}
......
......@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2005-2013 *
* copyright (C) 2005-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
......@@ -32,6 +32,8 @@ protected:
void initialize();
void initPerFile();
bool parseFile(const QString& fileName);
private:
......
......@@ -4,7 +4,7 @@
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
* copyright (C) 2005-2013 *
* copyright (C) 2005-2014 *
* Umbrello UML Modeller Authors <umbrello-devel@kde.org> *
***************************************************************************/
......@@ -202,6 +202,9 @@ UMLObject *createUMLObject(UMLObject::ObjectType type,
DEBUG(DBG_SRC) << "Import_Utils::createUMLObject(" << name
<< "): Association as parent package is not supported yet, using Logical View";
parentPkg = logicalView;
} else if (name.startsWith("::")) {
name = name.mid(2);
parentPkg = logicalView;
}
UMLObject * o = umldoc->findUMLObject(name, type, parentPkg);
bNewUMLObjectWasCreated = false;
......
......@@ -143,6 +143,11 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
{
const bool caseSensitive = UMLApp::app()->activeLanguageIsCaseSensitive();
QString name = inName;
const bool atGlobalScope = name.startsWith("::");
if (atGlobalScope) {
name = name.mid(2);
currentObj = NULL;
}
QStringList components;
#ifdef TRY_BUGFIX_120682
// If we have a pointer or a reference in cpp we need to remove
......@@ -170,7 +175,7 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
currentObj = static_cast<UMLObject*>(currentObj->parent());
}
pkg = dynamic_cast<UMLPackage*>(currentObj);
if (pkg == NULL)
if (pkg == NULL || pkg->baseType() == UMLObject::ot_Association)
pkg = currentObj->umlPackage();
// Remember packages that we've seen - for avoiding cycles.
UMLPackageList seenPkgs;
......@@ -226,8 +231,8 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
foundType != UMLObject::ot_Class &&
foundType != UMLObject::ot_Interface &&
foundType != UMLObject::ot_Component) {
uDebug() << "found \"" << name
<< "\" is not a package (?)";
uDebug() << "found " << UMLObject::toString(foundType) << name
<< " is not a package (?)";
continue;
}
UMLPackage *pkg = static_cast<UMLPackage*>(obj);
......@@ -261,8 +266,8 @@ UMLObject* findUMLObject(const UMLObjectList& inList,
foundType != UMLObject::ot_Class &&
foundType != UMLObject::ot_Interface &&
foundType != UMLObject::ot_Component) {
uDebug() << "found \"" << name
<< "\" is not a package (?)";
uDebug() << "found " << name << "(" << UMLObject::toString(foundType) << ")"
<< " is not a package (?)";
continue;
}
UMLPackage *pkg = static_cast<UMLPackage*>(obj);
......
Supports Markdown
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