Version: 1.5.4+ : svn 570819 (using KDE KDE 3.5.0) Installed from: Slackware Packages Compiler: gcc OS: Linux Import Test10 below. Test11 is not resolved correctly. public class Test10{ private Test11[] data; } public class Test11{ } The problem also occurs in classes not belonging to the default package.
Created attachment 17283 [details] patch : add support for resolving array types correctly
SVN commit 570932 by okellogg: Attachment 17283 [details] from JP Fournier fixes type resolution for array types. BUG:132035 M +1 -0 ChangeLog M +28 -9 umbrello/codeimport/javaimport.cpp --- branches/KDE/3.5/kdesdk/umbrello/ChangeLog #570931:570932 @@ -7,6 +7,7 @@ * Java import - method parameter types not resolved correctly (131825) * Java import: unable to import AzareusCore (131961) * Java import: error on multidimensional arrays (132017) +* Java import - array types not resolved correctly (132035) Version 1.5.4 --- branches/KDE/3.5/kdesdk/umbrello/umbrello/codeimport/javaimport.cpp #570931:570932 @@ -161,6 +161,16 @@ ///Resolve the specified className UMLObject* JavaImport::resolveClass (QString className) { + kdDebug() << "importJava trying to resolve " << className << endl; + // keep track if we are dealing with an array + // + bool isArray = className.contains('['); + // remove any [] so that the class itself can be resolved + // + QString baseClassName = className; + baseClassName.remove('['); + baseClassName.remove(']'); + // java has a few implicit imports. Most relevant for this is the // current package, which is in the same directory as the current file // being parsed @@ -175,10 +185,15 @@ // current class // QString myDir = file.join( "/" ); - QString myFile = "/" + myDir + "/" + className + ".java"; + QString myFile = "/" + myDir + "/" + baseClassName + ".java"; if ( QFile::exists(myFile) ) { spawnImport( myFile ); - return findObject ( className, m_scope[m_scopeIndex]); + if ( isArray ) { + // we have imported the type. For arrays we want to return + // the array type + return Import_Utils::createUMLObject(Uml::ot_Class, className, m_scope[m_scopeIndex]); + } + return findObject(baseClassName, m_scope[m_scopeIndex]); } // the class we want is not in the same package as the one being imported. @@ -200,11 +215,11 @@ QString import = (*pathIt); QStringList split = QStringList::split( '.', import ); split.pop_back(); // remove the * or the classname - if ( import.endsWith( "*" ) || import.endsWith( className) ) { + if ( import.endsWith( "*" ) || import.endsWith( baseClassName) ) { // check if the file we want is in this imported package // convert the org.test type package into a filename // - QString aFile = sourceRoot + split.join("/") + "/" + className + ".java"; + QString aFile = sourceRoot + split.join("/") + "/" + baseClassName + ".java"; if ( QFile::exists(aFile) ) { spawnImport( aFile ); // we need to set the package for the class that will be resolved @@ -215,13 +230,17 @@ for (QStringList::Iterator it = split.begin(); it != split.end(); ++it) { QString name = (*it); UMLObject *ns = Import_Utils::createUMLObject(Uml::ot_Package, - name, parent); + name, parent); current = static_cast<UMLPackage*>(ns); parent = current; } // for + if ( isArray ) { + // we have imported the type. For arrays we want to return + // the array type + return Import_Utils::createUMLObject(Uml::ot_Class, className, current); + } // now that we have the right package, the class should be findable - // - return findObject ( className, current); + return findObject(baseClassName, current); } // if file exists } // if import matches } //foreach import @@ -491,7 +510,7 @@ // by prepending the package, unwanted placeholder types will not get created typeName = obj->getFullyQualifiedName("."); } - UMLAttribute *att = Import_Utils::addMethodParameter(op, typeName, parName); + /* UMLAttribute *att = */ Import_Utils::addMethodParameter(op, typeName, parName); if (advance() != ",") break; m_srcIndex++; @@ -556,7 +575,7 @@ o = Import_Utils::insertAttribute(m_klass, m_currentAccess, name, typeName, m_comment, m_isStatic); } - UMLAttribute *attr = static_cast<UMLAttribute*>(o); + // UMLAttribute *attr = static_cast<UMLAttribute*>(o); if (nextToken != ",") { // reset the modifiers m_isStatic = m_isAbstract = false;