You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2007/10/13 01:38:58 UTC
svn commit: r584326 [6/7] - in
/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java:
doc/ src/ src/symtab/ src/util/ src/xref/
Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/ScopedDef.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/ScopedDef.java?rev=584326&r1=584325&r2=584326&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/ScopedDef.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/ScopedDef.java Fri Oct 12 16:37:59 2007
@@ -1,3 +1,5 @@
+package org.apache.maven.jxr.java.src.symtab;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,12 +16,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.maven.jxr.java.src.symtab;
import org.apache.log4j.Logger;
import org.apache.maven.jxr.java.src.xref.JavaToken;
-
import java.util.Hashtable;
/**
@@ -28,7 +28,9 @@
*
* @version $Id: $
*/
-public abstract class ScopedDef extends Definition {
+public abstract class ScopedDef
+ extends Definition
+{
/** Logger for this class */
private static final Logger log = Logger.getLogger( ScopedDef.class );
@@ -61,7 +63,8 @@
/**
* Default constructor is public for deserialization.
*/
- public ScopedDef() {
+ public ScopedDef()
+ {
// Create a new hashtable for fast element lookup
elements = new JavaHashtable();
@@ -74,11 +77,12 @@
* @param occ
* @param parentScope
*/
- ScopedDef(String name, // the scoped name
- Occurrence occ, // where it's defined
- ScopedDef parentScope) { // scope containing the def
+ ScopedDef( String name, // the scoped name
+ Occurrence occ, // where it's defined
+ ScopedDef parentScope )
+ { // scope containing the def
- super(name, occ, parentScope);
+ super( name, occ, parentScope );
// Create a new hashtable for fast element lookup
elements = new JavaHashtable();
@@ -89,7 +93,8 @@
*
* @return
*/
- public Hashtable getSymbols() {
+ public Hashtable getSymbols()
+ {
return elements;
}
@@ -98,40 +103,44 @@
*
* @param def
*/
- void add(Definition def) {
+ void add( Definition def )
+ {
// Check to see if we already have a definition
- Definition oldDef = (Definition) elements.get(def.getName());
+ Definition oldDef = (Definition) elements.get( def.getName() );
// If so, we'll create a MultiDef to hold them
- if (oldDef != null) {
+ if ( oldDef != null )
+ {
// If the symbol there so far was not a MultiDef
- if (!(oldDef instanceof MultiDef)) {
+ if ( !( oldDef instanceof MultiDef ) )
+ {
// remove the old definition
- elements.remove(oldDef);
+ elements.remove( oldDef );
// create a new MultiDef
- MultiDef newMulti = new MultiDef(def.getName(), oldDef);
+ MultiDef newMulti = new MultiDef( def.getName(), oldDef );
// add the old symbol to the MultiDef
- newMulti.addDef(oldDef);
+ newMulti.addDef( oldDef );
oldDef = newMulti;
// add the MultiDef back into the scope
- elements.put(def.getName(), oldDef);
+ elements.put( def.getName(), oldDef );
}
// We now have a multidef, so add the new symbol to it
- ((MultiDef) oldDef).addDef(def);
+ ( (MultiDef) oldDef ).addDef( def );
}
// Otherwise, just add the new symbol to the scope
- else {
- elements.put(def.getName(), def);
- def.setParentScope(this);
+ else
+ {
+ elements.put( def.getName(), def );
+ def.setParentScope( this );
}
}
@@ -140,19 +149,21 @@
*
* @param t
*/
- void addUnresolved(JavaToken t) {
+ void addUnresolved( JavaToken t )
+ {
// be lazy in our creation of the reference vector
// (many definitions might not contain refs to other symbols)
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("addUnresolved(JavaToken) - Adding unresolved reference to:"+getQualifiedName());
+ log.debug( "addUnresolved(JavaToken) - Adding unresolved reference to:" + getQualifiedName() );
}
- if (unresolvedStuff == null) {
+ if ( unresolvedStuff == null )
+ {
unresolvedStuff = new JavaVector();
}
- unresolvedStuff.addElement(t);
+ unresolvedStuff.addElement( t );
}
/**
@@ -160,7 +171,8 @@
*
* @return
*/
- public JavaHashtable getElements() {
+ public JavaHashtable getElements()
+ {
return elements;
}
@@ -169,7 +181,8 @@
*
* @return
*/
- boolean hasElements() {
+ boolean hasElements()
+ {
return !elements.isEmpty();
}
@@ -180,32 +193,38 @@
*
* @return
*/
- public boolean isDefaultOrBaseScope() {
+ public boolean isDefaultOrBaseScope()
+ {
return iAmDefaultOrBaseScope;
}
/**
* @see org.apache.maven.jxr.java.src.symtab.Definition#lookup(java.lang.String, int, java.lang.Class)
*/
- Definition lookup(String name, int numParams, Class type) {
+ Definition lookup( String name, int numParams, Class type )
+ {
// Try to find the name in our scope
- Definition d = (Definition) elements.get(name);
+ Definition d = (Definition) elements.get( name );
// if we found multiple defs of the same name, ask the multidef
// to do the resolution for us.
- if (d instanceof MultiDef) {
- d = d.lookup(name, numParams, type);
+ if ( d instanceof MultiDef )
+ {
+ d = d.lookup( name, numParams, type );
}
// if we got a method back, check to see that the params apply
- else if (d instanceof MethodDef) {
- if (((MethodDef) d).getParamCount() != numParams) {
+ else if ( d instanceof MethodDef )
+ {
+ if ( ( (MethodDef) d ).getParamCount() != numParams )
+ {
d = null;
}
}
- if ((d != null) && !d.isA(type)) {
+ if ( ( d != null ) && !d.isA( type ) )
+ {
d = null;
}
@@ -217,10 +236,12 @@
*
* @param tagList
*/
- void tagElements(HTMLTagContainer tagList) {
+ void tagElements( HTMLTagContainer tagList )
+ {
- if (elements != null) {
- elements.tagElements(tagList);
+ if ( elements != null )
+ {
+ elements.tagElements( tagList );
}
}
@@ -230,19 +251,20 @@
/**
* @see org.apache.maven.jxr.java.src.symtab.Definition#resolveTypes(org.apache.maven.jxr.java.src.symtab.SymbolTable)
*/
- void resolveTypes(SymbolTable symbolTable) {
- if (log.isDebugEnabled())
+ void resolveTypes( SymbolTable symbolTable )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("resolveTypes(SymbolTable) - SymbolTable symbolTable=" + symbolTable);
- log.debug("resolveTypes(SymbolTable) - resolving types for "+this.getQualifiedName());
+ log.debug( "resolveTypes(SymbolTable) - SymbolTable symbolTable=" + symbolTable );
+ log.debug( "resolveTypes(SymbolTable) - resolving types for " + this.getQualifiedName() );
}
resolveLevel++;
- symbolTable.pushScope(this); // push the current scope
- elements.resolveTypes(symbolTable); // resolve elements in this scope
- symbolTable.popScope(); // pop back out of the scope
- super.resolveTypes(symbolTable); // let superclass resolve if needed
+ symbolTable.pushScope( this ); // push the current scope
+ elements.resolveTypes( symbolTable ); // resolve elements in this scope
+ symbolTable.popScope(); // pop back out of the scope
+ super.resolveTypes( symbolTable ); // let superclass resolve if needed
resolveLevel--;
}
@@ -250,27 +272,29 @@
/**
* @see org.apache.maven.jxr.java.src.symtab.Definition#resolveRefs(org.apache.maven.jxr.java.src.symtab.SymbolTable)
*/
- void resolveRefs(SymbolTable symbolTable) {
+ void resolveRefs( SymbolTable symbolTable )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("resolveRefs(SymbolTable) - SymbolTable symbolTable=" + symbolTable);
- log.debug("resolveRefs(SymbolTable) - resolving types for "+this.getQualifiedName());
+ log.debug( "resolveRefs(SymbolTable) - SymbolTable symbolTable=" + symbolTable );
+ log.debug( "resolveRefs(SymbolTable) - resolving types for " + this.getQualifiedName() );
}
resolveLevel++;
- symbolTable.pushScope(this); // push the current scope
+ symbolTable.pushScope( this ); // push the current scope
- if (unresolvedStuff != null) { // resolve refs to other syms
- unresolvedStuff.resolveRefs(symbolTable);
+ if ( unresolvedStuff != null )
+ { // resolve refs to other syms
+ unresolvedStuff.resolveRefs( symbolTable );
unresolvedStuff = null;
}
- elements.resolveRefs(symbolTable);
- symbolTable.popScope(); // pop back out of the scope
- super.resolveRefs(symbolTable); // let superclass resolve if needed
+ elements.resolveRefs( symbolTable );
+ symbolTable.popScope(); // pop back out of the scope
+ super.resolveRefs( symbolTable ); // let superclass resolve if needed
resolveLevel--;
}
@@ -280,14 +304,16 @@
*
* @param val
*/
- void setDefaultOrBaseScope(boolean val) {
+ void setDefaultOrBaseScope( boolean val )
+ {
iAmDefaultOrBaseScope = val;
}
/**
* @see org.apache.maven.jxr.java.src.symtab.Definition#getOccurrenceTag(org.apache.maven.jxr.java.src.symtab.Occurrence)
*/
- public HTMLTag getOccurrenceTag(Occurrence occ) {
+ public HTMLTag getOccurrenceTag( Occurrence occ )
+ {
return null;
}
}
Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/StringTable.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/StringTable.java?rev=584326&r1=584325&r2=584326&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/StringTable.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/StringTable.java Fri Oct 12 16:37:59 2007
@@ -1,3 +1,5 @@
+package org.apache.maven.jxr.java.src.symtab;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.maven.jxr.java.src.symtab;
import java.util.Hashtable;
@@ -25,7 +26,8 @@
*
* @version $Id: $
*/
-class StringTable {
+class StringTable
+{
// ==========================================================================
// == Class Variables
@@ -48,19 +50,22 @@
* @param name
* @return
*/
- String getName(String name) {
+ String getName( String name )
+ {
- if (name == null) {
+ if ( name == null )
+ {
return null;
}
- String uniqueName = (String) names.get(name);
+ String uniqueName = (String) names.get( name );
- if (uniqueName != null) {
+ if ( uniqueName != null )
+ {
return uniqueName;
}
- names.put(name, name);
+ names.put( name, name );
return name;
}
@@ -68,7 +73,8 @@
/**
* @see java.lang.Object#toString()
*/
- public String toString() {
+ public String toString()
+ {
return "StringTable";
}
}
Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/SymbolTable.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/SymbolTable.java?rev=584326&r1=584325&r2=584326&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/SymbolTable.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/SymbolTable.java Fri Oct 12 16:37:59 2007
@@ -1,3 +1,5 @@
+package org.apache.maven.jxr.java.src.symtab;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,14 +16,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.maven.jxr.java.src.symtab;
import org.apache.log4j.Logger;
import org.apache.maven.jxr.java.src.util.JSCollections;
import org.apache.maven.jxr.java.src.util.SortableString;
import org.apache.maven.jxr.java.src.xref.JavaToken;
-
import java.io.File;
import java.util.Enumeration;
import java.util.Hashtable;
@@ -36,7 +36,8 @@
*
* @version $Id: $
*/
-public class SymbolTable {
+public class SymbolTable
+{
/** Logger for this class */
private static final Logger log = Logger.getLogger( SymbolTable.class );
@@ -118,7 +119,8 @@
*
* @return
*/
- public Hashtable getPackages() {
+ public Hashtable getPackages()
+ {
return packages;
}
@@ -128,19 +130,23 @@
* @param f
* @param tagList
*/
- public static void createReferenceTags(File f, Vector tagList) {
+ public static void createReferenceTags( File f, Vector tagList )
+ {
- Vector v = (Vector) _fileReferences.get(f);
+ Vector v = (Vector) _fileReferences.get( f );
- if (v != null) {
+ if ( v != null )
+ {
Enumeration enumList = v.elements();
- while (enumList.hasMoreElements()) {
+ while ( enumList.hasMoreElements() )
+ {
Occurrence occ = (Occurrence) enumList.nextElement();
HTMLTag occTag = occ.getOccurrenceTag();
- if (occTag != null) {
- tagList.addElement(occTag);
+ if ( occTag != null )
+ {
+ tagList.addElement( occTag );
}
}
}
@@ -151,18 +157,20 @@
*
* @param occ
*/
- public static void addFileReference(Occurrence occ) {
+ public static void addFileReference( Occurrence occ )
+ {
File f = occ.getFile();
- Vector v = (Vector) _fileReferences.get(f);
+ Vector v = (Vector) _fileReferences.get( f );
- if (v == null) {
+ if ( v == null )
+ {
v = new Vector();
- _fileReferences.put(f, v);
+ _fileReferences.put( f, v );
}
- v.add(occ);
+ v.add( occ );
}
/**
@@ -171,12 +179,14 @@
* @param f
* @param tagList
*/
- public static void getCommentTags(File f, Vector tagList) {
+ public static void getCommentTags( File f, Vector tagList )
+ {
- Vector commentList = (Vector) _fileComments.get(f);
+ Vector commentList = (Vector) _fileComments.get( f );
- if (commentList != null) {
- tagList.addAll(commentList);
+ if ( commentList != null )
+ {
+ tagList.addAll( commentList );
}
}
@@ -186,12 +196,14 @@
* @param f
* @param tagList
*/
- public static void getLiteralTags(File f, Vector tagList) {
+ public static void getLiteralTags( File f, Vector tagList )
+ {
- Vector literalList = (Vector) _fileLiterals.get(f);
+ Vector literalList = (Vector) _fileLiterals.get( f );
- if (literalList != null) {
- tagList.addAll(literalList);
+ if ( literalList != null )
+ {
+ tagList.addAll( literalList );
}
}
@@ -201,12 +213,14 @@
* @param f
* @param tagList
*/
- public static void getKeywordTags(File f, Vector tagList) {
+ public static void getKeywordTags( File f, Vector tagList )
+ {
- Vector keywordList = (Vector) _fileKeywords.get(f);
+ Vector keywordList = (Vector) _fileKeywords.get( f );
- if (keywordList != null) {
- tagList.addAll(keywordList);
+ if ( keywordList != null )
+ {
+ tagList.addAll( keywordList );
}
}
@@ -215,7 +229,8 @@
*
* @return
*/
- public JavaHashtable getImports() {
+ public JavaHashtable getImports()
+ {
return importedClasses;
}
@@ -224,7 +239,8 @@
*
* @param imp
*/
- public void setImports(JavaHashtable imp) {
+ public void setImports( JavaHashtable imp )
+ {
importedClasses = imp;
}
@@ -233,7 +249,8 @@
*
* @return
*/
- public JavaVector getDemand() {
+ public JavaVector getDemand()
+ {
return demand;
}
@@ -242,7 +259,8 @@
*
* @param dem
*/
- public void setDemand(JavaVector dem) {
+ public void setDemand( JavaVector dem )
+ {
demand = dem;
}
@@ -251,9 +269,11 @@
*
* @return
*/
- public static SymbolTable getSymbolTable() {
+ public static SymbolTable getSymbolTable()
+ {
- if (singleton == null) {
+ if ( singleton == null )
+ {
singleton = new SymbolTable();
}
@@ -263,21 +283,21 @@
/**
* Constructor to create a new symbol table
*/
- private SymbolTable() {
+ private SymbolTable()
+ {
// allocate storage for the packages and scope lists
packages = new JavaHashtable();
activeScopes = new JavaStack();
// Create a package object to represent java.lang
- javaLang = new PackageDef(getUniqueName("java.lang"),
- new Occurrence(null, 0), null);
+ javaLang = new PackageDef( getUniqueName( "java.lang" ), new Occurrence( null, 0 ), null );
// Create a block to hold predefined types
- baseScope = new BlockDef(null, null, null);
+ baseScope = new BlockDef( null, null, null );
- pushScope(baseScope);
- baseScope.setDefaultOrBaseScope(true);
+ pushScope( baseScope );
+ baseScope.setDefaultOrBaseScope( true );
// define the predefined types
// treat them as being an inheritance hierarchy to make widening
@@ -289,34 +309,25 @@
// cross-reference tool. However, treating the primitives
// as an inheritance hierarchy is included to show a
// technique that might be used in a real cross-reference tool.)
- PrimitiveDef pBoolean = new PrimitiveDef(getUniqueName("boolean"),
- getObject(), baseScope);
- PrimitiveDef pDouble = new PrimitiveDef(getUniqueName("double"),
- getObject(), baseScope);
- PrimitiveDef pFloat = new PrimitiveDef(getUniqueName("float"),
- pDouble, baseScope);
- PrimitiveDef pLong = new PrimitiveDef(getUniqueName("long"), pFloat,
- baseScope);
- PrimitiveDef pInt = new PrimitiveDef(getUniqueName("int"), pLong,
- baseScope);
- PrimitiveDef pShort = new PrimitiveDef(getUniqueName("short"), pInt,
- baseScope);
- PrimitiveDef pByte = new PrimitiveDef(getUniqueName("byte"), pShort,
- baseScope);
- PrimitiveDef pChar = new PrimitiveDef(getUniqueName("char"), pInt,
- baseScope);
- PrimitiveDef pVoid = new PrimitiveDef(getUniqueName("void"),
- getObject(), baseScope);
-
- baseScope.add(pBoolean);
- baseScope.add(pDouble);
- baseScope.add(pFloat);
- baseScope.add(pLong);
- baseScope.add(pInt);
- baseScope.add(pShort);
- baseScope.add(pByte);
- baseScope.add(pChar);
- baseScope.add(pVoid);
+ PrimitiveDef pBoolean = new PrimitiveDef( getUniqueName( "boolean" ), getObject(), baseScope );
+ PrimitiveDef pDouble = new PrimitiveDef( getUniqueName( "double" ), getObject(), baseScope );
+ PrimitiveDef pFloat = new PrimitiveDef( getUniqueName( "float" ), pDouble, baseScope );
+ PrimitiveDef pLong = new PrimitiveDef( getUniqueName( "long" ), pFloat, baseScope );
+ PrimitiveDef pInt = new PrimitiveDef( getUniqueName( "int" ), pLong, baseScope );
+ PrimitiveDef pShort = new PrimitiveDef( getUniqueName( "short" ), pInt, baseScope );
+ PrimitiveDef pByte = new PrimitiveDef( getUniqueName( "byte" ), pShort, baseScope );
+ PrimitiveDef pChar = new PrimitiveDef( getUniqueName( "char" ), pInt, baseScope );
+ PrimitiveDef pVoid = new PrimitiveDef( getUniqueName( "void" ), getObject(), baseScope );
+
+ baseScope.add( pBoolean );
+ baseScope.add( pDouble );
+ baseScope.add( pFloat );
+ baseScope.add( pLong );
+ baseScope.add( pInt );
+ baseScope.add( pShort );
+ baseScope.add( pByte );
+ baseScope.add( pChar );
+ baseScope.add( pVoid );
}
/**
@@ -324,7 +335,8 @@
*
* @param outDirPath
*/
- public void setOutDirPath(String outDirPath) {
+ public void setOutDirPath( String outDirPath )
+ {
this.outDirPath = outDirPath;
}
@@ -333,7 +345,8 @@
*
* @return
*/
- public String getOutDirPath() {
+ public String getOutDirPath()
+ {
return outDirPath;
}
@@ -347,8 +360,9 @@
*
* @param pkg
*/
- void addDemand(PackageDef pkg) {
- demand.addElement(pkg);
+ void addDemand( PackageDef pkg )
+ {
+ demand.addElement( pkg );
}
/**
@@ -356,12 +370,14 @@
*
* @param f
*/
- public static void createDirs(File f) {
+ public static void createDirs( File f )
+ {
String parentDir = f.getParent();
- File directory = new File(parentDir);
+ File directory = new File( parentDir );
- if (!directory.exists()) {
+ if ( !directory.exists() )
+ {
directory.mkdirs();
}
}
@@ -372,21 +388,24 @@
* @param f
* @param classDef
*/
- public static void addFileClassDef(File f, ClassDef classDef) {
+ public static void addFileClassDef( File f, ClassDef classDef )
+ {
- if (_fileClassDefs == null) {
- _fileClassDefs = new Hashtable(2);
+ if ( _fileClassDefs == null )
+ {
+ _fileClassDefs = new Hashtable( 2 );
}
- Vector v = (Vector) _fileClassDefs.get(f);
+ Vector v = (Vector) _fileClassDefs.get( f );
- if (v == null) {
- v = new Vector(2, 2);
+ if ( v == null )
+ {
+ v = new Vector( 2, 2 );
- _fileClassDefs.put(f, v);
+ _fileClassDefs.put( f, v );
}
- v.addElement(classDef);
+ v.addElement( classDef );
}
/**
@@ -395,32 +414,37 @@
* @param f
* @return
*/
- public static String getClassList(File f) {
+ public static String getClassList( File f )
+ {
- if (_fileClassDefs == null) {
+ if ( _fileClassDefs == null )
+ {
return null;
}
- Vector v = (Vector) _fileClassDefs.get(f);
+ Vector v = (Vector) _fileClassDefs.get( f );
- if (v == null) {
+ if ( v == null )
+ {
return null;
}
String list = "";
- for (int i = 0; i < v.size(); i++) {
- Definition d = (Definition) v.elementAt(i);
+ for ( int i = 0; i < v.size(); i++ )
+ {
+ Definition d = (Definition) v.elementAt( i );
String name = d.getName();
list += name;
- if (i < v.size() - 1) {
+ if ( i < v.size() - 1 )
+ {
list += ", ";
}
}
- return (list);
+ return ( list );
}
/**
@@ -430,65 +454,69 @@
* @param className
* @param packageName
*/
- public void addImport(JavaToken tok, String className, String packageName) {
+ public void addImport( JavaToken tok, String className, String packageName )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("addImport(JavaToken, String, String) - String className=" + className);
- log.debug("addImport(JavaToken, String, String) - String packageName=" + packageName);
+ log.debug( "addImport(JavaToken, String, String) - String className=" + className );
+ log.debug( "addImport(JavaToken, String, String) - String packageName=" + packageName );
}
- if (importedClasses == null) { // lazy instantiation
+ if ( importedClasses == null )
+ { // lazy instantiation
importedClasses = new JavaHashtable();
}
// if there is no package name, use the default package
- if (packageName.equals(".") || packageName.equals("")) {
- importedClasses.put(getUniqueName("~default~"),
- getDefaultPackage());
+ if ( packageName.equals( "." ) || packageName.equals( "" ) )
+ {
+ importedClasses.put( getUniqueName( "~default~" ), getDefaultPackage() );
return;
}
// otherwise, chop the extra "." that the parser adds...
- else {
- packageName = packageName.substring(1);
+ else
+ {
+ packageName = packageName.substring( 1 );
}
// if there is no class, we are importing a package on demand
// so create a dummy package definition (if one doesn't already
// exist)
- if (className == null) {
- Definition d = (Definition) packages.get(packageName);
+ if ( className == null )
+ {
+ Definition d = (Definition) packages.get( packageName );
- if (d == null) {
- d = new PackageDef(
- getUniqueName(packageName),
- new Occurrence(
- currentFile, tok.getLine(), tok.getColumn()), null);
+ if ( d == null )
+ {
+ d = new PackageDef( getUniqueName( packageName ), new Occurrence( currentFile, tok.getLine(), tok
+ .getColumn() ), null );
- packages.put(packageName, d);
+ packages.put( packageName, d );
}
- importedClasses.put(d.getName(), d);
+ importedClasses.put( d.getName(), d );
// reference(tok);
}
// otherwise, create a placeholder class for class/interface ref
- else {
+ else
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("addImport(JavaToken, String, String) - Created placeholder for:"+getUniqueName(className));
+ log.debug( "addImport(JavaToken, String, String) - Created placeholder for:"
+ + getUniqueName( className ) );
}
- importedClasses.put(
- getUniqueName(className),
- new DummyClass(
- getUniqueName(className),
- new Occurrence(currentFile, tok.getLine(), tok.getColumn()),
- getUniqueName(packageName)));
+ importedClasses.put( getUniqueName( className ), new DummyClass( getUniqueName( className ),
+ new Occurrence( currentFile,
+ tok.getLine(), tok
+ .getColumn() ),
+ getUniqueName( packageName ) ) );
// reference(tok);
}
@@ -499,19 +527,21 @@
*
* @param def
*/
- void addToCurrentScope(Definition def) {
+ void addToCurrentScope( Definition def )
+ {
// add the definition to the current scope
- getCurrentScope().add(def);
+ getCurrentScope().add( def );
// set the parent scope for the definition
- def.setParentScope(getCurrentScope());
+ def.setParentScope( getCurrentScope() );
}
/**
* We are done with imports, so clear the list
*/
- void closeImports() {
+ void closeImports()
+ {
demand = null;
importedClasses = null;
}
@@ -522,16 +552,16 @@
* @param tok
* @return
*/
- public Definition defineBlock(JavaToken tok) {
+ public Definition defineBlock( JavaToken tok )
+ {
// create a new block definition and push it
// as the current scope
- BlockDef def = new BlockDef(null, getOccurrence(tok),
- getCurrentScope());
+ BlockDef def = new BlockDef( null, getOccurrence( tok ), getCurrentScope() );
- addToCurrentScope(def);
+ addToCurrentScope( def );
- return pushScope(def);
+ return pushScope( def );
}
/**
@@ -541,31 +571,29 @@
* @param superClass
* @param interfaces
*/
- public void defineClass(JavaToken theClass, // class being created
- JavaToken superClass, // its superclass
- JavaVector interfaces) { // interfaces it implements
+ public void defineClass( JavaToken theClass, // class being created
+ JavaToken superClass, // its superclass
+ JavaVector interfaces )
+ { // interfaces it implements
// note -- we leave interfaces as a vector of JavaTokens for now
// we'll resolve them in pass 2.
// create a new class definition for the class
- ClassDef def = new ClassDef(getUniqueName(theClass),
- getOccurrence(theClass),
- (superClass == null)
- ? null
- : getDummyClass(superClass), interfaces,
- getCurrentScope());
+ ClassDef def = new ClassDef( getUniqueName( theClass ), getOccurrence( theClass ),
+ ( superClass == null ) ? null : getDummyClass( superClass ), interfaces,
+ getCurrentScope() );
- def.setType(ClassDef.CLASS);
+ def.setType( ClassDef.CLASS );
// add the imported classes/packages to the class
- def.setImports(importedClasses);
+ def.setImports( importedClasses );
// add the class to the current scope
- addToCurrentScope(def);
- SymbolTable.addFileClassDef(currentFile, def);
+ addToCurrentScope( def );
+ SymbolTable.addFileClassDef( currentFile, def );
// make the claa be the new current scope
- pushScope(def);
+ pushScope( def );
}
/**
@@ -574,25 +602,23 @@
* @param theInterface
* @param superInterfaces
*/
- public void defineInterface(JavaToken theInterface,
- JavaVector superInterfaces) {
+ public void defineInterface( JavaToken theInterface, JavaVector superInterfaces )
+ {
// note -- we leave superInterfaces as a vector of JavaTokens for now.
// we'll resolve in pass 2.
// create the new interface object
- ClassDef def = new ClassDef(getUniqueName(theInterface),
- getOccurrence(theInterface),
- null, // no super class...
- superInterfaces, getCurrentScope());
+ ClassDef def = new ClassDef( getUniqueName( theInterface ), getOccurrence( theInterface ), null, // no super class...
+ superInterfaces, getCurrentScope() );
- def.setType(ClassDef.INTERFACE);
+ def.setType( ClassDef.INTERFACE );
// add it to the current scope
- addToCurrentScope(def);
- SymbolTable.addFileClassDef(currentFile, def);
+ addToCurrentScope( def );
+ SymbolTable.addFileClassDef( currentFile, def );
// make the interface the current scope
- pushScope(def);
+ pushScope( def );
}
/**
@@ -600,11 +626,10 @@
*
* @param theLabel
*/
- public void defineLabel(JavaToken theLabel) {
+ public void defineLabel( JavaToken theLabel )
+ {
- addToCurrentScope(new LabelDef(getUniqueName(theLabel),
- getOccurrence(theLabel),
- getCurrentScope()));
+ addToCurrentScope( new LabelDef( getUniqueName( theLabel ), getOccurrence( theLabel ), getCurrentScope() ) );
}
/**
@@ -614,7 +639,8 @@
* @param column
* @param text
*/
- public void defineComment(int line, int column, String text) {
+ public void defineComment( int line, int column, String text )
+ {
int length = text.length();
@@ -627,17 +653,17 @@
* }
*/
String packageName = getCurrentPackageName();
- HTMLTag t = new HTMLTag(currentFile, line, column,
- packageName, length);
- Vector commentList = (Vector) _fileComments.get(currentFile);
+ HTMLTag t = new HTMLTag( currentFile, line, column, packageName, length );
+ Vector commentList = (Vector) _fileComments.get( currentFile );
- if (commentList == null) {
+ if ( commentList == null )
+ {
commentList = new Vector();
- _fileComments.put(currentFile, commentList);
+ _fileComments.put( currentFile, commentList );
}
- commentList.addElement(t);
+ commentList.addElement( t );
}
/**
@@ -647,21 +673,22 @@
* @param column
* @param text
*/
- public void defineLiteral(int line, int column, String text) {
+ public void defineLiteral( int line, int column, String text )
+ {
int length = text.length();
String packageName = getCurrentPackageName();
- HTMLTag t = new HTMLTag(currentFile, line, column,
- packageName, length, HTMLTag.TYPE_LITERAL);
- Vector literalList = (Vector) _fileLiterals.get(currentFile);
+ HTMLTag t = new HTMLTag( currentFile, line, column, packageName, length, HTMLTag.TYPE_LITERAL );
+ Vector literalList = (Vector) _fileLiterals.get( currentFile );
- if (literalList == null) {
+ if ( literalList == null )
+ {
literalList = new Vector();
- _fileLiterals.put(currentFile, literalList);
+ _fileLiterals.put( currentFile, literalList );
}
- literalList.addElement(t);
+ literalList.addElement( t );
}
/**
@@ -671,21 +698,22 @@
* @param column
* @param text
*/
- public void defineKeyword(int line, int column, String text) {
+ public void defineKeyword( int line, int column, String text )
+ {
int length = text.length();
String packageName = getCurrentPackageName();
- HTMLTag t = new HTMLTag(currentFile, line, column,
- packageName, length, HTMLTag.TYPE_KEYWORD);
- Vector keywordList = (Vector) _fileKeywords.get(currentFile);
+ HTMLTag t = new HTMLTag( currentFile, line, column, packageName, length, HTMLTag.TYPE_KEYWORD );
+ Vector keywordList = (Vector) _fileKeywords.get( currentFile );
- if (keywordList == null) {
+ if ( keywordList == null )
+ {
keywordList = new Vector();
- _fileKeywords.put(currentFile, keywordList);
+ _fileKeywords.put( currentFile, keywordList );
}
- keywordList.addElement(t);
+ keywordList.addElement( t );
}
/**
@@ -694,47 +722,47 @@
* @param theMethod
* @param type
*/
- public void defineMethod(JavaToken theMethod, JavaToken type) {
+ public void defineMethod( JavaToken theMethod, JavaToken type )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("defineMethod(JavaToken, JavaToken) - JavaToken theMethod=" + theMethod.getText());
+ log.debug( "defineMethod(JavaToken, JavaToken) - JavaToken theMethod=" + theMethod.getText() );
}
// if there is no type, this is a constructor
String name;
String className = null;
- if (type == null) {
+ if ( type == null )
+ {
// name = "~constructor~";
name = theMethod.getText();
className = theMethod.getText();
- currentMethod = new MethodDef(getUniqueName(name), className,
- getOccurrence(theMethod),
- getDummyClass(type),
- getCurrentScope());
+ currentMethod = new MethodDef( getUniqueName( name ), className, getOccurrence( theMethod ),
+ getDummyClass( type ), getCurrentScope() );
}
// otherwise use its real name
- else {
- if (theMethod == null) {
+ else
+ {
+ if ( theMethod == null )
+ {
theMethod = type;
type = null;
}
name = theMethod.getText();
- currentMethod = new MethodDef(getUniqueName(name),
- getOccurrence(theMethod),
- getDummyClass(type),
- getCurrentScope());
+ currentMethod = new MethodDef( getUniqueName( name ), getOccurrence( theMethod ), getDummyClass( type ),
+ getCurrentScope() );
}
// add the method to the current scope
- addToCurrentScope(currentMethod);
+ addToCurrentScope( currentMethod );
// make the method be the current scope
- pushScope(currentMethod);
+ pushScope( currentMethod );
}
/**
@@ -743,8 +771,9 @@
*
* @param tok
*/
- public void definePackage(JavaToken tok) {
- definePackage(getUniqueName(tok));
+ public void definePackage( JavaToken tok )
+ {
+ definePackage( getUniqueName( tok ) );
}
/**
@@ -753,13 +782,14 @@
* @param name
* @return
*/
- PackageDef definePackage(String name) {
+ PackageDef definePackage( String name )
+ {
// find/add this package
- PackageDef pkg = lookupPackage(name);
+ PackageDef pkg = lookupPackage( name );
// make the package be the current scope
- pushScope(pkg);
+ pushScope( pkg );
return pkg;
}
@@ -770,20 +800,23 @@
* @param theVariable
* @param type
*/
- public void defineVar(JavaToken theVariable, JavaToken type) {
+ public void defineVar( JavaToken theVariable, JavaToken type )
+ {
// create the variable definition
- VariableDef v = new VariableDef(getUniqueName(theVariable),
- getOccurrence(theVariable),
- getDummyClass(type), getCurrentScope());
+ VariableDef v = new VariableDef( getUniqueName( theVariable ), getOccurrence( theVariable ),
+ getDummyClass( type ), getCurrentScope() );
// if we are in a method's parameter def, add to its parameters
- if (currentMethod != null) {
- currentMethod.add(v);
+ if ( currentMethod != null )
+ {
+ currentMethod.add( v );
// otherwise, add to the current scope
- } else {
- addToCurrentScope(v);
+ }
+ else
+ {
+ addToCurrentScope( v );
}
}
@@ -792,10 +825,11 @@
*
* @param exceptions
*/
- public void endMethodHead(JavaVector exceptions) {
+ public void endMethodHead( JavaVector exceptions )
+ {
// set its thrown exception list
- currentMethod.setExceptions(exceptions);
+ currentMethod.setExceptions( exceptions );
// reset the method indicator
// NOTE: this is not a problem for inner classes; you cannot define an
@@ -811,62 +845,68 @@
* @param type
* @return
*/
- Definition findInImports(String name, Class type) {
+ Definition findInImports( String name, Class type )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("findInImports(String, Class) - String name=" + name);
- log.debug("findInImports(String, Class) - importedClasses=" + importedClasses);
- log.debug("findInImports(String, Class) - demand=" + demand);
+ log.debug( "findInImports(String, Class) - String name=" + name );
+ log.debug( "findInImports(String, Class) - importedClasses=" + importedClasses );
+ log.debug( "findInImports(String, Class) - demand=" + demand );
}
Definition def = null;
// look at the stuff we imported
// (the name could be a class name)
- if (importedClasses != null) {
- def = (Definition) importedClasses.get(name);
+ if ( importedClasses != null )
+ {
+ def = (Definition) importedClasses.get( name );
}
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("findInImports(String, Class) - def=" + def);
+ log.debug( "findInImports(String, Class) - def=" + def );
}
// TBD: best place for this?
- if (def instanceof DummyClass) {
- String packageName = ((DummyClass) def).getPackage();
+ if ( def instanceof DummyClass )
+ {
+ String packageName = ( (DummyClass) def ).getPackage();
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("findInImports(String, Class) - DummyClass's packageName is "+packageName);
+ log.debug( "findInImports(String, Class) - DummyClass's packageName is " + packageName );
}
- if (packageName != null) {
- PackageDef pd = (PackageDef) packages.get(packageName);
+ if ( packageName != null )
+ {
+ PackageDef pd = (PackageDef) packages.get( packageName );
- def = pd.lookup(def.getName(), type);
+ def = pd.lookup( def.getName(), type );
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("findInImports(String, Class) - pd.lookup returned "+def);
+ log.debug( "findInImports(String, Class) - pd.lookup returned " + def );
}
}
}
// otherwise, take a look in the import-on-demand packages to
// see if the class is defined
- if ((def == null) && (demand != null) && (name.charAt(0) != '~')) {
+ if ( ( def == null ) && ( demand != null ) && ( name.charAt( 0 ) != '~' ) )
+ {
Enumeration e = demand.elements();
- while ((def == null) && e.hasMoreElements()) {
+ while ( ( def == null ) && e.hasMoreElements() )
+ {
PackageDef pd = (PackageDef) e.nextElement();
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("findInImports(String, Class) - searching in package "+pd.getName());
+ log.debug( "findInImports(String, Class) - searching in package " + pd.getName() );
}
- def = pd.lookup(name, type);
+ def = pd.lookup( name, type );
}
}
@@ -879,8 +919,9 @@
* @param name
* @return
*/
- Definition findPackage(String name) {
- return (Definition) packages.get(name);
+ Definition findPackage( String name )
+ {
+ return (Definition) packages.get( name );
}
/**
@@ -889,14 +930,16 @@
* @param name
* @return
*/
- PackageDef lookupPackage(String name) {
+ PackageDef lookupPackage( String name )
+ {
- PackageDef result = (PackageDef) packages.get(name);
+ PackageDef result = (PackageDef) packages.get( name );
- if (result == null) {
- result = new PackageDef(getUniqueName(name), null, null);
+ if ( result == null )
+ {
+ result = new PackageDef( getUniqueName( name ), null, null );
- packages.put(name, result);
+ packages.put( name, result );
}
return result;
@@ -907,9 +950,11 @@
*
* @return
*/
- ScopedDef getCurrentScope() {
+ ScopedDef getCurrentScope()
+ {
- if (activeScopes.empty()) {
+ if ( activeScopes.empty() )
+ {
return null;
}
@@ -921,16 +966,17 @@
*
* @return
*/
- PackageDef getDefaultPackage() {
+ PackageDef getDefaultPackage()
+ {
// if the default package has not yet been defined, create it
// (lazy instantiation)
- if (defaultPackage == null) {
- defaultPackage = new PackageDef(getUniqueName("~default~"), null,
- null);
+ if ( defaultPackage == null )
+ {
+ defaultPackage = new PackageDef( getUniqueName( "~default~" ), null, null );
- packages.put(getUniqueName("~default~"), defaultPackage);
- defaultPackage.setDefaultOrBaseScope(true);
+ packages.put( getUniqueName( "~default~" ), defaultPackage );
+ defaultPackage.setDefaultOrBaseScope( true );
}
return defaultPackage;
@@ -942,13 +988,15 @@
* @param tok
* @return
*/
- public DummyClass getDummyClass(JavaToken tok) {
+ public DummyClass getDummyClass( JavaToken tok )
+ {
- if (tok == null) {
+ if ( tok == null )
+ {
return null;
}
- return new DummyClass(getUniqueName(tok), getOccurrence(tok));
+ return new DummyClass( getUniqueName( tok ), getOccurrence( tok ) );
}
/**
@@ -956,15 +1004,17 @@
*
* @return
*/
- ClassDef getObject() {
+ ClassDef getObject()
+ {
- if (object == null) { // lazy instantiation
+ if ( object == null )
+ { // lazy instantiation
object = new DummyClass();
- object.setType(ClassDef.CLASS);
+ object.setType( ClassDef.CLASS );
// add it to package java.lang
- javaLang.add(object);
+ javaLang.add( object );
}
return object;
@@ -976,16 +1026,16 @@
* @param tok
* @return
*/
- Occurrence getOccurrence(JavaToken tok) {
+ Occurrence getOccurrence( JavaToken tok )
+ {
- if (tok == null) {
- return new Occurrence(null, 0);
+ if ( tok == null )
+ {
+ return new Occurrence( null, 0 );
}
- return new Occurrence(currentFile, tok.getLine(), tok.getColumn(),
- getCurrentPackageName(),
- getCurrentClassName(),
- getCurrentMethodName());
+ return new Occurrence( currentFile, tok.getLine(), tok.getColumn(), getCurrentPackageName(),
+ getCurrentClassName(), getCurrentMethodName() );
}
/**
@@ -993,7 +1043,8 @@
*
* @return
*/
- Definition getScope() {
+ Definition getScope()
+ {
return qualifiedScope;
}
@@ -1003,8 +1054,9 @@
* @param tok
* @return
*/
- String getUniqueName(JavaToken tok) {
- return getUniqueName(tok.getText());
+ String getUniqueName( JavaToken tok )
+ {
+ return getUniqueName( tok.getText() );
}
/**
@@ -1013,8 +1065,9 @@
* @param name
* @return
*/
- String getUniqueName(String name) {
- return names.getName(name);
+ String getUniqueName( String name )
+ {
+ return names.getName( name );
}
/**
@@ -1026,8 +1079,9 @@
* @param type
* @return
*/
- Definition lookup(String name, Class type) {
- return lookup(name, -1, type);
+ Definition lookup( String name, Class type )
+ {
+ return lookup( name, -1, type );
}
/**
@@ -1038,12 +1092,13 @@
* @param type
* @return
*/
- Definition lookup(String name, int numParams, Class type) {
+ Definition lookup( String name, int numParams, Class type )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - String name=" + name);
- log.debug("lookup(String, int, Class) - int numParams=" + numParams);
+ log.debug( "lookup(String, int, Class) - String name=" + name );
+ log.debug( "lookup(String, int, Class) - int numParams=" + numParams );
}
Definition def = null;
@@ -1053,7 +1108,8 @@
// If we have a dot ('.') in the name, we must first resolve the package,
// class or interface that starts the name, the progress through the
// name
- if (name.indexOf('.') > 0) {
+ if ( name.indexOf( '.' ) > 0 )
+ {
// /NOTE: class names can have the same name as a package and
// context will determine the result!!!!
@@ -1072,96 +1128,105 @@
// break up the string into an enumerartion of substrings that were
// separated by dots ('.')
- st = new StringTokenizer(name, ".");
+ st = new StringTokenizer( name, "." );
// We'll walk through to find the longest package name that we
// know about, then start checking to see if the rest of the
// elements are validly scoped within that package
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - String name=" + name);
+ log.debug( "lookup(String, int, Class) - String name=" + name );
}
boolean doneWithPackage = false;
- while (st.hasMoreElements()) {
+ while ( st.hasMoreElements() )
+ {
String id = (String) st.nextElement();
Definition testIt = null;
- if (testName == null) {
+ if ( testName == null )
+ {
testName = id;
// see if the first part of the name is an imported class
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - calling findInImports " + testName);
+ log.debug( "lookup(String, int, Class) - calling findInImports " + testName );
}
- def = findInImports(testName, type);
+ def = findInImports( testName, type );
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - findInImports returned " + def);
+ log.debug( "lookup(String, int, Class) - findInImports returned " + def );
}
- if (def != null) {
- if (log.isDebugEnabled())
+ if ( def != null )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - Found in imports:"
- + def.getName());
+ log.debug( "lookup(String, int, Class) - Found in imports:" + def.getName() );
}
doneWithPackage = true;
id = (String) st.nextElement();
}
- } else {
+ }
+ else
+ {
testName += "." + id;
}
// keep track of the longest name that is a package
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - Looking for package:"+testName);
+ log.debug( "lookup(String, int, Class) - Looking for package:" + testName );
}
- testIt = (PackageDef) packages.get(testName);
+ testIt = (PackageDef) packages.get( testName );
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - doneWithPackage=" + doneWithPackage
- + " testIt=" + ((testIt == null)
- ? "null"
- : testIt.getName()) + " afterPackage="
- + afterPackage);
+ log.debug( "lookup(String, int, Class) - doneWithPackage=" + doneWithPackage + " testIt="
+ + ( ( testIt == null ) ? "null" : testIt.getName() ) + " afterPackage=" + afterPackage );
}
- if (!doneWithPackage && (testIt != null)) {
+ if ( !doneWithPackage && ( testIt != null ) )
+ {
def = testIt;
afterPackage = null;
- } else if (afterPackage == null) {
+ }
+ else if ( afterPackage == null )
+ {
afterPackage = id;
- } else {
+ }
+ else
+ {
afterPackage += "." + id;
}
}
}
// otherwise, just try to find the name in the imported classes/packages
- else if (numParams == -1) {
- def = findInImports(name, type);
+ else if ( numParams == -1 )
+ {
+ def = findInImports( name, type );
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - findInImports returned " + def);
- if ((def != null) && (def.getParentScope() != null)) {
- log.debug("lookup(String, int, Class) - parentScope" + def.getParentScope());
+ log.debug( "lookup(String, int, Class) - findInImports returned " + def );
+ if ( ( def != null ) && ( def.getParentScope() != null ) )
+ {
+ log.debug( "lookup(String, int, Class) - parentScope" + def.getParentScope() );
}
}
- if (def != null) {
+ if ( def != null )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - lookup Returning import:"+def.getQualifiedName());
+ log.debug( "lookup(String, int, Class) - lookup Returning import:" + def.getQualifiedName() );
}
return def;
}
@@ -1173,96 +1238,110 @@
// a final part of the name. If so, we need to push the scope of the
// leftmost part of the identifier. If not, we just want to analyze
// the entire name as a unit.
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- if (def == null) {
- log.debug("lookup(String, int, Class) - def=null");
- } else {
- log.debug("lookup(String, int, Class) - def="+def.getName());
+ if ( def == null )
+ {
+ log.debug( "lookup(String, int, Class) - def=null" );
+ }
+ else
+ {
+ log.debug( "lookup(String, int, Class) - def=" + def.getName() );
}
- log.debug("lookup(String, int, Class) - afterpackage=" + afterPackage);
+ log.debug( "lookup(String, int, Class) - afterpackage=" + afterPackage );
}
- if ((def != null) && (afterPackage != null)) {
- if (log.isDebugEnabled())
+ if ( ( def != null ) && ( afterPackage != null ) )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - Setting scope=" + def.getName());
+ log.debug( "lookup(String, int, Class) - Setting scope=" + def.getName() );
}
- setScope(def);
- } else {
- if (log.isDebugEnabled())
+ setScope( def );
+ }
+ else
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - afterPackage=" + name);
+ log.debug( "lookup(String, int, Class) - afterPackage=" + name );
}
afterPackage = name;
}
// Here we know we have more to look at...
- if (afterPackage != null) { // more to chew on...
+ if ( afterPackage != null )
+ { // more to chew on...
// check to see if we still have any DOTs in the name
// if so, we'll need to figure out where certain names start/end
- st = new StringTokenizer(afterPackage, ".");
+ st = new StringTokenizer( afterPackage, "." );
// find and load the classes up to the last
- while (st.hasMoreElements()) {
+ while ( st.hasMoreElements() )
+ {
String id = (String) st.nextElement();
// if a explicit scope qualification was specified, look only there
- if (qualifiedScope != null) {
- if (log.isDebugEnabled())
+ if ( qualifiedScope != null )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - Checking qualified scope:"
- + qualifiedScope);
+ log.debug( "lookup(String, int, Class) - Checking qualified scope:" + qualifiedScope );
}
- def = qualifiedScope.lookup(id, numParams, type);
+ def = qualifiedScope.lookup( id, numParams, type );
resetScope();
}
// Otherwise, first try a scoped lookup
- else {
- if (log.isDebugEnabled())
+ else
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - Checking activeScopes for:" + id);
+ log.debug( "lookup(String, int, Class) - Checking activeScopes for:" + id );
}
- def = activeScopes.lookup(id, numParams, type);
+ def = activeScopes.lookup( id, numParams, type );
- if (def == null) {
- def = activeScopes.lookup(id, -1, type);
+ if ( def == null )
+ {
+ def = activeScopes.lookup( id, -1, type );
}
}
- if (def == null) {
- if (log.isDebugEnabled())
+ if ( def == null )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - " + id + " Not found in activescopes");
+ log.debug( "lookup(String, int, Class) - " + id + " Not found in activescopes" );
}
break;
}
- if (st.hasMoreElements()) {
- setScope(def);
+ if ( st.hasMoreElements() )
+ {
+ setScope( def );
}
}
}
- if (def == null) {
- if (log.isDebugEnabled())
+ if ( def == null )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - lookup returning null:" + name);
+ log.debug( "lookup(String, int, Class) - lookup returning null:" + name );
}
- } else {
- if (log.isDebugEnabled())
+ }
+ else
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookup(String, int, Class) - lookup returning:"
- + def.getQualifiedName());
+ log.debug( "lookup(String, int, Class) - lookup returning:" + def.getQualifiedName() );
}
}
@@ -1275,38 +1354,44 @@
* @param d
* @return
*/
- ClassDef lookupDummy(Definition d) {
+ ClassDef lookupDummy( Definition d )
+ {
// construct a qualified class name
String className;
- String pkg = ((DummyClass) d).getPackage();
+ String pkg = ( (DummyClass) d ).getPackage();
Definition newD = null;
- if (pkg == null) {
+ if ( pkg == null )
+ {
className = d.getName();
- } else {
+ }
+ else
+ {
className = pkg + "." + d.getName();
- if (packages.get(pkg) == null) {
- packages.put(pkg, new PackageDef(pkg, null, null));
+ if ( packages.get( pkg ) == null )
+ {
+ packages.put( pkg, new PackageDef( pkg, null, null ) );
}
}
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookupDummy(Definition) - String className=" + className);
+ log.debug( "lookupDummy(Definition) - String className=" + className );
}
- newD = lookup(className, ClassDef.class);
+ newD = lookup( className, ClassDef.class );
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("lookupDummy(Definition) - String newD=" + newD);
+ log.debug( "lookupDummy(Definition) - String newD=" + newD );
}
- if ((newD != null) && !(newD instanceof ClassDef)) {
- if (log.isDebugEnabled())
+ if ( ( newD != null ) && !( newD instanceof ClassDef ) )
+ {
+ if ( log.isDebugEnabled() )
{
- log.debug("lookupDummy(Definition) - newD is a " + newD);
- log.debug("lookupDummy(Definition) - d="+d + "parentScope = "+d.getParentScope());
+ log.debug( "lookupDummy(Definition) - newD is a " + newD );
+ log.debug( "lookupDummy(Definition) - d=" + d + "parentScope = " + d.getParentScope() );
}
}
@@ -1318,56 +1403,65 @@
*
* @param imports
*/
- void openImports(JavaHashtable imports) {
+ void openImports( JavaHashtable imports )
+ {
// start a new demand list
demand = new JavaVector();
// add package java.lang to the demand list...
- demand.addElement(javaLang);
+ demand.addElement( javaLang );
importedClasses = new JavaHashtable();
// if this class has something to import...
- if (imports != null) {
+ if ( imports != null )
+ {
// walk through the list of imports
Enumeration e = imports.elements();
- while (e.hasMoreElements()) {
+ while ( e.hasMoreElements() )
+ {
// add the package or class to the demand or import list
// based on the type of import it was
Definition d = (Definition) e.nextElement();
- if (d instanceof PackageDef) {
+ if ( d instanceof PackageDef )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("openImports(JavaHashtable) - Adding package "+d.getName()+" to imports");
+ log.debug( "openImports(JavaHashtable) - Adding package " + d.getName() + " to imports" );
}
- addDemand((PackageDef) d);
- } else {
- if (d instanceof DummyClass) {
+ addDemand( (PackageDef) d );
+ }
+ else
+ {
+ if ( d instanceof DummyClass )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("openImports(JavaHashtable) - found DummyClass " + d.getName() + " package "
- + ( (DummyClass) d ).getPackage() + " in import list");
+ log.debug( "openImports(JavaHashtable) - found DummyClass " + d.getName() + " package "
+ + ( (DummyClass) d ).getPackage() + " in import list" );
}
- Definition newD = lookupDummy(d);
+ Definition newD = lookupDummy( d );
- if (newD != null) {
+ if ( newD != null )
+ {
- if (log.isDebugEnabled())
+ if ( log.isDebugEnabled() )
{
- log.debug("openImports(JavaHashtable) - Adding class "+newD.getName()+" to imports");
+ log.debug( "openImports(JavaHashtable) - Adding class " + newD.getName()
+ + " to imports" );
}
d = newD;
}
}
- importedClasses.put(d.getName(), d);
+ importedClasses.put( d.getName(), d );
}
}
}
@@ -1376,9 +1470,11 @@
/**
* Clear the scope stack (except the base scope for primitives)
*/
- public void popAllScopes() {
+ public void popAllScopes()
+ {
- while (activeScopes.peek() != baseScope) {
+ while ( activeScopes.peek() != baseScope )
+ {
activeScopes.pop();
}
@@ -1388,7 +1484,8 @@
/**
* Pop off the current scope from the stack
*/
- public void popScope() {
+ public void popScope()
+ {
activeScopes.pop();
}
@@ -1398,13 +1495,15 @@
* @param scope
* @return
*/
- Definition pushScope(Definition scope) {
+ Definition pushScope( Definition scope )
+ {
- if (!(scope instanceof ScopedDef)) {
- throw new RuntimeException("Not a ScopedDef");
+ if ( !( scope instanceof ScopedDef ) )
+ {
+ throw new RuntimeException( "Not a ScopedDef" );
}
- activeScopes.push(scope);
+ activeScopes.push( scope );
return scope;
}
@@ -1414,20 +1513,24 @@
*
* @return
*/
- String getCurrentPackageName() {
+ String getCurrentPackageName()
+ {
String packageName = "";
- if (activeScopes == null) {
+ if ( activeScopes == null )
+ {
return packageName;
}
Enumeration e = activeScopes.elements();
- while (e.hasMoreElements()) {
+ while ( e.hasMoreElements() )
+ {
ScopedDef d = (ScopedDef) e.nextElement();
- if (d instanceof PackageDef) {
+ if ( d instanceof PackageDef )
+ {
packageName = d.getName();
break;
@@ -1442,20 +1545,24 @@
*
* @return
*/
- String getCurrentClassName() {
+ String getCurrentClassName()
+ {
String className = "?";
- if (activeScopes == null) {
+ if ( activeScopes == null )
+ {
return className;
}
Enumeration e = activeScopes.elements();
- while (e.hasMoreElements()) {
+ while ( e.hasMoreElements() )
+ {
ScopedDef d = (ScopedDef) e.nextElement();
- if (d instanceof ClassDef) {
+ if ( d instanceof ClassDef )
+ {
className = d.getName();
break;
@@ -1470,20 +1577,24 @@
*
* @return
*/
- String getCurrentMethodName() {
+ String getCurrentMethodName()
+ {
String methodName = "?";
- if (activeScopes == null) {
+ if ( activeScopes == null )
+ {
return methodName;
}
Enumeration e = activeScopes.elements();
- while (e.hasMoreElements()) {
+ while ( e.hasMoreElements() )
+ {
ScopedDef d = (ScopedDef) e.nextElement();
- if (d instanceof MethodDef) {
+ if ( d instanceof MethodDef )
+ {
methodName = d.getName();
break;
@@ -1498,13 +1609,14 @@
*
* @param t
*/
- public void reference(JavaToken t) {
+ public void reference( JavaToken t )
+ {
- t.setFile(currentFile);
- t.setPackageName(getCurrentPackageName());
- t.setClassName(getCurrentClassName());
- t.setMethodName(getCurrentMethodName());
- getCurrentScope().addUnresolved(t);
+ t.setFile( currentFile );
+ t.setPackageName( getCurrentPackageName() );
+ t.setClassName( getCurrentClassName() );
+ t.setMethodName( getCurrentMethodName() );
+ getCurrentScope().addUnresolved( t );
}
/**
@@ -1512,29 +1624,31 @@
*
* @return
*/
- public Hashtable generatePackageTags() {
+ public Hashtable generatePackageTags()
+ {
Vector tagList;
Vector sortedList;
- Hashtable tagTable = new Hashtable(2);
+ Hashtable tagTable = new Hashtable( 2 );
// Write out information about each package
Enumeration e = packages.elements();
- while (e.hasMoreElements()) {
+ while ( e.hasMoreElements() )
+ {
PackageDef p = (PackageDef) e.nextElement();
tagList = p.generateClassList();
- if (tagList != null) {
- sortedList = JSCollections.sortEnumeration(tagList.elements());
+ if ( tagList != null )
+ {
+ sortedList = JSCollections.sortEnumeration( tagList.elements() );
- tagTable.put(new SortableString(p.getScopedClassName()),
- sortedList);
+ tagTable.put( new SortableString( p.getScopedClassName() ), sortedList );
}
}
- return (tagTable);
+ return ( tagTable );
}
// public void generateReferenceFiles(String path)
@@ -1551,34 +1665,39 @@
* unset the qualifiedScope so normal scoped lookup applies on the next
* name to look up
*/
- void resetScope() {
- setScope((Definition) null);
+ void resetScope()
+ {
+ setScope( (Definition) null );
}
/**
* resolve types of anything that needs resolution in the symbol table
*/
- public void resolveTypes() {
+ public void resolveTypes()
+ {
// for each package, resolve its references
- if (defaultPackage != null) {
- defaultPackage.resolveTypes(this);
+ if ( defaultPackage != null )
+ {
+ defaultPackage.resolveTypes( this );
}
- packages.resolveTypes(this);
+ packages.resolveTypes( this );
}
/**
* resolve types of anything that needs resolution in the symbol table
*/
- public void resolveRefs() {
+ public void resolveRefs()
+ {
// for each package, resolve its references
- if (defaultPackage != null) {
- defaultPackage.resolveRefs(this);
+ if ( defaultPackage != null )
+ {
+ defaultPackage.resolveRefs( this );
}
- packages.resolveRefs(this);
+ packages.resolveRefs( this );
}
/**
@@ -1586,15 +1705,17 @@
*
* @param outDirPath
*/
- public void persistRefs(String outDirPath) {
+ public void persistRefs( String outDirPath )
+ {
- ReferencePersistor rp = new ReferencePersistor(outDirPath);
+ ReferencePersistor rp = new ReferencePersistor( outDirPath );
- if (defaultPackage != null) {
- defaultPackage.accept(rp);
+ if ( defaultPackage != null )
+ {
+ defaultPackage.accept( rp );
}
- packages.accept(rp);
+ packages.accept( rp );
rp.done();
}
@@ -1603,17 +1724,19 @@
*
* @param file
*/
- public void setFile(File file) {
+ public void setFile( File file )
+ {
currentFile = file;
}
/**
* set the lookup scope to the nearest enclosing class (for "this.x")
*/
- public void setNearestClassScope() {
+ public void setNearestClassScope()
+ {
// find the nearest class scope
- setScope(activeScopes.findTopmostClass());
+ setScope( activeScopes.findTopmostClass() );
}
/**
@@ -1623,13 +1746,15 @@
*
* @param t
*/
- void setScope(JavaToken t) {
+ void setScope( JavaToken t )
+ {
- Definition def = lookup(t.getText(), null);
+ Definition def = lookup( t.getText(), null );
- if (def != null) {
- def.addReference(getOccurrence(t));
- setScope(def);
+ if ( def != null )
+ {
+ def.addReference( getOccurrence( t ) );
+ setScope( def );
}
}
@@ -1639,13 +1764,16 @@
*
* @param d
*/
- void setScope(Definition d) {
+ void setScope( Definition d )
+ {
- while ((d != null) && (d instanceof TypedDef)) {
- d = ((TypedDef) d).getType();
+ while ( ( d != null ) && ( d instanceof TypedDef ) )
+ {
+ d = ( (TypedDef) d ).getType();
}
- if ((d == null) || (d instanceof ScopedDef)) {
+ if ( ( d == null ) || ( d instanceof ScopedDef ) )
+ {
qualifiedScope = d;
}
}
@@ -1657,24 +1785,28 @@
*
* @param name
*/
- void setScope(String name) {
+ void setScope( String name )
+ {
- Definition def = lookup(name, null);
+ Definition def = lookup( name, null );
- if (def != null) {
- setScope(def);
+ if ( def != null )
+ {
+ setScope( def );
}
}
/**
* @see java.lang.Object#toString()
*/
- public String toString() {
+ public String toString()
+ {
String str = "";
Enumeration e = packages.elements();
- while (e.hasMoreElements()) {
+ while ( e.hasMoreElements() )
+ {
PackageDef p = (PackageDef) e.nextElement();
str += p.toString();
@@ -1688,8 +1820,9 @@
* parser if the source file being parsed does not contain a package
* specification.
*/
- public void useDefaultPackage() {
- pushScope(getDefaultPackage());
+ public void useDefaultPackage()
+ {
+ pushScope( getDefaultPackage() );
}
/** Field readLevel */
@@ -1700,7 +1833,8 @@
*
* @param name
*/
- static public void startReadExternal(String name) {
+ static public void startReadExternal( String name )
+ {
// for (int i=0; i<readLevel; i++)
// System.out.print(' ');
@@ -1711,7 +1845,8 @@
/**
* Method endReadExternal
*/
- static public void endReadExternal() {
+ static public void endReadExternal()
+ {
// readLevel--;
}
Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/Taggable.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/Taggable.java?rev=584326&r1=584325&r2=584326&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/Taggable.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/Taggable.java Fri Oct 12 16:37:59 2007
@@ -1,3 +1,5 @@
+package org.apache.maven.jxr.java.src.symtab;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,19 +16,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.maven.jxr.java.src.symtab;
/**
* This interface is used as a handle to all classes that can be tagged
*
* @version $Id: $
*/
-interface Taggable {
+interface Taggable
+{
/**
* Create tag information about an object
*
* @param tagList
*/
- void generateTags(HTMLTagContainer tagList);
+ void generateTags( HTMLTagContainer tagList );
}
Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/TypedDef.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/TypedDef.java?rev=584326&r1=584325&r2=584326&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/TypedDef.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/src/symtab/TypedDef.java Fri Oct 12 16:37:59 2007
@@ -1,3 +1,5 @@
+package org.apache.maven.jxr.java.src.symtab;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@@ -14,7 +16,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.maven.jxr.java.src.symtab;
/**
* This interface represents definitions that have a "type" associated with
@@ -23,7 +24,8 @@
*
* @version $Id: $
*/
-interface TypedDef {
+interface TypedDef
+{
/**
* returns the symbol representing the type associated with a definition