User: ara_e_w Date: 02/06/26 12:44:31 Modified: src/xjavadoc AbstractClass.java AbstractProgramElement.java ParameterImpl.java SourceClass.java Log: - class level inner classes are now correctly resolved. No ProxyClass is used, I just changed the call order and ensured everything is lazyly calculated. anonymous classes and method level inner classes are not resolved yet, I should change the sourceClass to a stack (tomorrow night). - Some mini optimizations: _namedMethods/_namedConstructors/etc lazyly created, absolutely when nessecary (very rare usage). Revision Changes Path 1.31 +35 -16 xjavadoc/src/xjavadoc/AbstractClass.java Index: AbstractClass.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/AbstractClass.java,v retrieving revision 1.30 retrieving revision 1.31 diff -u -w -r1.30 -r1.31 --- AbstractClass.java 20 Jun 2002 19:57:37 -0000 1.30 +++ AbstractClass.java 26 Jun 2002 19:44:29 -0000 1.31 @@ -230,15 +230,13 @@ */ public final XMethod getMethod( String methodNameWithSignature ) { + initializeNamedMethodsHashMap(); + if( _namedMethods != null ) - { return ( XMethod ) _namedMethods.get( methodNameWithSignature ); - } else - { return null; } - } /** * Gets the Constructor attribute of the AbstractClass object @@ -249,15 +247,13 @@ */ public final XConstructor getConstructor( String constructorNameWithSignature ) { + initializeNamedConstructorsHashMap(); + if( _namedConstructors != null ) - { return ( XConstructor ) _namedConstructors.get( constructorNameWithSignature ); - } else - { return null; } - } /** * Returns an XField with the given name. Example: getField("id"); @@ -471,8 +467,6 @@ boolean result = false; XClass superclass = this; - boolean gogo = false; - while( superclass != null ) { if( superclass.getQualifiedName().equals( className ) ) @@ -753,10 +747,8 @@ if( _constructors == null ) { _constructors = new ArrayList(); - _namedConstructors = new HashMap(); } _constructors.add( constructor ); - _namedConstructors.put( constructor.getNameWithSignature(), constructor ); } /** @@ -796,12 +788,9 @@ public void addMethod( XMethod method ) { if( _methods == null ) - { _methods = new ArrayList(); - _namedMethods = new HashMap(); - } + _methods.add( method ); - _namedMethods.put( method.getNameWithSignature(), method ); } /** * Describe what the method does @@ -915,6 +904,36 @@ protected final boolean hasImportedPackages() { return _importedPackages != null && _importedPackages.size() != 0; + } + + private void initializeNamedMethodsHashMap() + { + if( _namedMethods != null || _methods == null ) + return; + + _namedMethods = new HashMap(); + + for( int i = 0; i < _methods.size(); i++ ) + { + XMethod method = ( XMethod ) _methods.get( i ); + + _namedMethods.put( method.getNameWithSignature(), method ); + } + } + + private void initializeNamedConstructorsHashMap() + { + if( _namedConstructors != null || _constructors == null ) + return; + + _namedConstructors = new HashMap(); + + for( int i = 0; i < _namedConstructors.size(); i++ ) + { + XConstructor constructor = ( XConstructor ) _constructors.get( i ); + + _namedConstructors.put( constructor.getNameWithSignature(), constructor ); + } } } 1.19 +12 -16 xjavadoc/src/xjavadoc/AbstractProgramElement.java Index: AbstractProgramElement.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/AbstractProgramElement.java,v retrieving revision 1.18 retrieving revision 1.19 diff -u -w -r1.18 -r1.19 --- AbstractProgramElement.java 7 Jun 2002 14:51:25 -0000 1.18 +++ AbstractProgramElement.java 26 Jun 2002 19:44:30 -0000 1.19 @@ -168,22 +168,6 @@ } /** - * Describe what the method does - * - * @return Describe the return value - * @todo-javadoc Write javadocs for method - * @todo-javadoc Write javadocs for return value - */ - public final String getQualifiedName() - { - if( _qualifiedName == null ) - { - throw new IllegalStateException( "setQualifiedName hasn't been called" ); - } - return _qualifiedName; - } - - /** * Get the doc * * @return the class level doc @@ -273,6 +257,18 @@ public final AbstractClass getContainingAbstractClass() { return _containingClass; + } + + /** + * Describe what the method does + * + * @return Describe the return value + * @todo-javadoc Write javadocs for method + * @todo-javadoc Write javadocs for return value + */ + public String getQualifiedName() + { + return _qualifiedName; } /** 1.9 +8 -6 xjavadoc/src/xjavadoc/ParameterImpl.java Index: ParameterImpl.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/ParameterImpl.java,v retrieving revision 1.8 retrieving revision 1.9 diff -u -w -r1.8 -r1.9 --- ParameterImpl.java 7 Jun 2002 14:51:25 -0000 1.8 +++ ParameterImpl.java 26 Jun 2002 19:44:30 -0000 1.9 @@ -10,7 +10,7 @@ * @author Ara Abrahamian ([EMAIL PROTECTED]) * @author <a href="mailto:[EMAIL PROTECTED]">Aslak Hellesøy</a> * @created Feb 11, 2002 - * @version $Revision: 1.8 $ + * @version $Revision: 1.9 $ */ final class ParameterImpl implements XParameter { @@ -116,10 +116,12 @@ _containingExecutableMember = containingExecutableMember; _parameterIndex = parameterIndex; - //sanity check. - if( getType() == null ) - { - throw new IllegalStateException( "getType() should not return null:" + _containingExecutableMember.getParameterType( _parameterIndex ) ); - } + /* + * /sanity check. + * if( getType() == null ) + * { + * throw new IllegalStateException( "getType() should not return null:" + _containingExecutableMember.getParameterType( _parameterIndex ) ); + * } + */ } } 1.33 +50 -28 xjavadoc/src/xjavadoc/SourceClass.java Index: SourceClass.java =================================================================== RCS file: /cvsroot/xdoclet/xjavadoc/src/xjavadoc/SourceClass.java,v retrieving revision 1.32 retrieving revision 1.33 diff -u -w -r1.32 -r1.33 --- SourceClass.java 20 Jun 2002 19:57:37 -0000 1.32 +++ SourceClass.java 26 Jun 2002 19:44:30 -0000 1.33 @@ -6,7 +6,6 @@ import java.util.*; import java.io.*; -import java.lang.reflect.Modifier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -30,12 +29,6 @@ * @todo-javadoc Describe the field */ public static int instanceCount = 0; - private final static String AMBIGUOUS = - "Ambiguous classes were found. xjavadoc can't decide since there is no" + - "qualified import for a class, and that class is not found on the" + - "classpath (perhaps it's a class that doesn't exist yet? Not yet" + - "generated?). Please include an import statement for Zap using its fully" + - "qualified name. Here are the classes:"; private final Log _log = LogFactory.getLog( getClass() ); /** * @todo-javadoc Describe the field @@ -54,10 +47,6 @@ /** * @todo-javadoc Describe the field */ - private boolean _isParseCompleted = false; - /** - * @todo-javadoc Describe the field - */ private Reader _in = null; /** @@ -83,7 +72,9 @@ public SourceClass( AbstractClass containingClass, String qualifiedName, File sourceFile ) { super( containingClass, qualifiedName ); + _sourceFile = sourceFile; + if( containingClass == null && qualifiedName == null ) { throw new IllegalArgumentException( "qualifiedName can't be null for outer classes!" ); @@ -163,6 +154,21 @@ return _compilationUnit != null; } + public String getQualifiedName() + { + if( super.getQualifiedName() == null && super.getContainingClass() != null ) + { + if( getName() == null ) + throw new IllegalStateException( "getQualifiedName before setName" ); + + String qualified_name = getContainingClass().getQualifiedName() + '.' + getName(); + + super.setQualifiedName( qualified_name ); + } + + return super.getQualifiedName(); + } + /** * Called by JavaParser at the end of the parsing * @@ -174,21 +180,6 @@ } /** - * Sets the Name attribute of the SourceClass object - * - * @param name The new Name value - */ - public void setName( String name ) - { - if( getContainingClass() != null ) - { - setQualifiedName( getContainingClass().getQualifiedName() + '.' + name ); - name = getContainingClass().getName() + '.' + name; - } - super.setName( name ); - } - - /** * Describe what the method does * * @return Describe the return value @@ -347,16 +338,30 @@ { result = XJavaDoc.getInstance().getXClass( qualifiedName ); } + else if( ( qualifiedName = unqualifiedNameInTheSameClassAsAnInnerClass( unqualifiedClassName ) ) != null ) + { + result = XJavaDoc.getInstance().getXClass( qualifiedName ); + } else if( ( qualifiedName = unqualifiedNameInInnerClasses( unqualifiedClassName ) ) != null ) { result = XJavaDoc.getInstance().getXClass( qualifiedName ); } else { - UnknownClass unknownClass = unknownClass = new UnknownClass( getContainingPackage().getName() + "." + unqualifiedClassName ); - + UnknownClass unknownClass = new UnknownClass( getContainingPackage().getName() + "." + unqualifiedClassName ); /* + * System.out.println( ">>>>>>>>>>>>>>>>not found<<<<<<<<<<<<<<<" ); + * try + * { + * throw new IllegalStateException(); + * } + * catch( IllegalStateException e ) + * { + * e.printStackTrace(); + * } + */ + /* * We couldn't qualify the class. If there are no package import statements, * we'll assume the class belongs to the same package as ourself. */ @@ -367,6 +372,7 @@ } else { + // We can't decide. Add a warning that will be displayed in the end. XJavaDoc.getInstance().logMessage( this, unknownClass, unqualifiedClassName, XJavaDoc.ONE_OR_MORE_IMPORTED_PACKAGES ); } @@ -547,5 +553,21 @@ } + private final String unqualifiedNameInTheSameClassAsAnInnerClass( final String unqualifiedClassName ) + { + //containing class=com.p.A, inner-reference=B ->com.p.A.B + String qualifiedClassName = getQualifiedName() + '.' + unqualifiedClassName; + + if( XJavaDoc.getInstance().classExists( qualifiedClassName ) ) + return qualifiedClassName; + + //containing class=com.p.A, inner-reference=A.B ->com.p.A.B + qualifiedClassName = getContainingPackage().getName() + '.' + unqualifiedClassName; + + if( XJavaDoc.getInstance().classExists( qualifiedClassName ) ) + return qualifiedClassName; + + return null; + } }
------------------------------------------------------- This sf.net email is sponsored by: Jabber Inc. Don't miss the IM event of the season | Special offer for OSDN members! JabberConf 2002, Aug. 20-22, Keystone, CO http://www.jabberconf.com/osdn _______________________________________________ Xdoclet-devel mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/xdoclet-devel