| Summary: | code import sometimes prompts for a new datatype name | ||
|---|---|---|---|
| Product: | [Applications] umbrello | Reporter: | Jonathan Riddell <jr> |
| Component: | general | Assignee: | Umbrello Development Group <umbrello-devel> |
| Status: | RESOLVED FIXED | ||
| Severity: | normal | ||
| Priority: | NOR | ||
| Version First Reported In: | unspecified | ||
| Target Milestone: | --- | ||
| Platform: | unspecified | ||
| OS: | Linux | ||
| Latest Commit: | Version Fixed/Implemented In: | ||
| Sentry Crash Report: | |||
|
Description
Jonathan Riddell
2004-11-15 01:46:45 UTC
*** Bug has been marked as fixed ***. Most occurrences of this problem are fixed, but one persists:
While the processing of include files is not yet functioning,
defining scopes is a big problem.
Take for example the following file:
// test.h - demonstrates the problem with scope synthesis
#include <othertype.h> // include files are not currently parsed
namespace MyNS {
class Test {
Othertype str;
};
}
// end of file
Now, where should the UML object for Othertype be created?
At the global level, or inside MyNS - we have no way of knowing.
othertype.h may look like this:
// othertype.h
namespace MyNS {
class Othertype {
};
}
CVS commit by okellogg: BUG:93298 - included files are now imported (if they can be found) M +3 -2 ChangeLog 1.58 --- kdesdk/umbrello/ChangeLog #1.57:1.58 @@ -22,6 +22,7 @@ 89582 89699 89860 89903 90102 90106 90206 90755 91298 91433 91434 91494 91869 91922 92116 92123 92222 92300 92301 -92781 92995 93122 93219 93297 93501 93595 93696 94173 94728 -94795 94883 95082 95252 95722 95924 95951 95954 96216 96221 +92781 92995 93122 93219 93297 93298 93501 93595 93696 94173 +94728 94795 94883 95082 95252 95722 95924 95951 95954 96216 +96221 Version 1.3 The problem still occurs with anonymous types, for example
class LaClasse {
public:
struct {
int _a;
bool _b;
} _anonymous;
};
Workaround: Give the type a name.
CVS commit by okellogg:
Put scope qualified datatypes in the global scope.
This removes another occasion of gratuitous prompting for a type name.
CCBUG:93298
M +3 -6 classimport.cpp 1.67
M +15 -1 model_utils.cpp 1.19
--- kdesdk/umbrello/umbrello/classimport.cpp #1.66:1.67
@@ -116,5 +116,6 @@ UMLObject *ClassImport::createUMLObject(
parentPkg = static_cast<UMLPackage*>(o);
}
- name.remove(QRegExp("^.*::")); // may also zap "const "
+ // All scope qualified datatypes live in the global scope.
+ m_putAtGlobalScope = true;
}
Uml::Object_Type t = type;
@@ -125,13 +126,9 @@ UMLObject *ClassImport::createUMLObject(
if (isConst || isPointer || isRef) {
// Create the full given type (including adornments.)
- if (isPointer || isRef) {
- type = Uml::ot_Datatype;
- } else if (type == Uml::ot_UMLObject)
- type = Uml::ot_Class;
if (isConst)
name.prepend("const ");
if (m_putAtGlobalScope)
parentPkg = NULL;
- o = m_umldoc->createUMLObject(type, name, parentPkg);
+ o = m_umldoc->createUMLObject(Uml::ot_Datatype, name);
UMLDatatype *dt = static_cast<UMLDatatype*>(o);
UMLClassifier *c = dynamic_cast<UMLClassifier*>(origType);
--- kdesdk/umbrello/umbrello/model_utils.cpp #1.18:1.19
@@ -98,7 +98,21 @@ UMLObject* findUMLObject(UMLObjectList i
Uml::Object_Type type /* = ot_UMLObject */,
UMLObject *currentObj /* = NULL */) {
- QStringList components = QStringList::split("::", name);
+ QStringList components;
+ if (name.contains("::"))
+ components = QStringList::split("::", name);
+ else if (name.contains("."))
+ components = QStringList::split(".", name);
QString nameWithoutFirstPrefix;
if (components.size() > 1) {
+ if (name.contains(QRegExp("[^\\w:\\.]"))) {
+ // It's obviously a datatype.
+ // Scope qualified datatypes live in the global scope.
+ for (UMLObjectListIt oit(inList); oit.current(); ++oit) {
+ UMLObject *obj = oit.current();
+ if (obj->getName() == name)
+ return obj;
+ }
+ return NULL;
+ }
name = components.front();
components.pop_front();
|