Author: tfmorris
Date: 2007-09-11 22:15:30-0700
New Revision: 13544
Added:
trunk/src_new/org/argouml/uml/reveng/java/ParameterDeclaration.java
Modified:
trunk/src_new/org/argouml/uml/reveng/java/Modeller.java
trunk/src_new/org/argouml/uml/reveng/java/java.g
Log:
Strengthen typing. Add TODOs.
Modified: trunk/src_new/org/argouml/uml/reveng/java/Modeller.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/reveng/java/Modeller.java?view=diff&rev=13544&p1=trunk/src_new/org/argouml/uml/reveng/java/Modeller.java&p2=trunk/src_new/org/argouml/uml/reveng/java/Modeller.java&r1=13543&r2=13544
==============================================================================
--- trunk/src_new/org/argouml/uml/reveng/java/Modeller.java (original)
+++ trunk/src_new/org/argouml/uml/reveng/java/Modeller.java 2007-09-11 22:15:30-0700
@@ -26,12 +26,14 @@
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.List;
import java.util.Stack;
import java.util.StringTokenizer;
-import java.util.Vector;
+
import org.apache.log4j.Logger;
import org.argouml.application.api.Argo;
@@ -48,7 +50,7 @@
/**
* Modeller maps Java source code(parsed/recognised by ANTLR) to UML model
* elements, it applies some of the semantics in JSR-26. Note: JSR-26 was
- * withdrawn in March, 2004, so it obviously provides no guideance for
+ * withdrawn in March, 2004, so it obviously provides no guidance for
* more recent language features such as Java 5.
*
* @author Marcus Andersson
@@ -84,9 +86,9 @@
/**
* Last package name used in addPackage().
- * It is null for classes wich are not packaged.
+ * It is null for classes which are not packaged.
* Used in popClassifier() to create diagram for that
- * packaget.
+ * package.
*/
private String currentPackageName;
@@ -98,7 +100,7 @@
/**
* Stack up the state when descending inner classes.
*/
- private Stack parseStateStack;
+ private Stack<ParseState> parseStateStack;
/**
* Only attributes will be generated.
@@ -118,23 +120,28 @@
/**
* Arbitrary attributes.
*/
- private Hashtable attributes = new Hashtable();
+ private Hashtable<String, Object> attributes =
+ new Hashtable<String, Object>();
/**
- * Vector of parsed method calls.
+ * List of the names of parsed method calls.
*/
- private Vector methodCalls = new Vector();
+ private List<String> methodCalls = new ArrayList<String>();
/**
- * HashMap of parsed local variables.
+ * HashMap of parsed local variables. Indexed by variable name with string
+ * representation of the type stored as the value.
*/
- private Hashtable localVariables = new Hashtable();
+ private Hashtable<String, String> localVariables =
+ new Hashtable<String, String>();
/**
* New model elements that were created during this
* reverse engineering session.
+ * TODO: We want a stronger type here, but ArgoUML treats all elements
+ * as just simple Objects.
*/
- private Collection newElements;
+ private Collection<Object> newElements;
/**
@@ -150,9 +157,9 @@
noAssociations = settings.isAttributeSelected();
arraysAsDatatype = settings.isDatatypeSelected();
currentPackage = this.model;
- newElements = new HashSet();
+ newElements = new HashSet<Object>();
parseState = new ParseState(this.model, getPackage(JAVA_PACKAGE));
- parseStateStack = new Stack();
+ parseStateStack = new Stack<ParseState>();
fileName = theFileName;
}
@@ -322,47 +329,18 @@
return;
}
- String packageName = getPackageName(name);
- String classifierName = getClassifierName(name);
- Object mPackage = getPackage(packageName);
+ String packageName = getPackageName(name);
+ // TODO: In the case of an inner class, we probably want either the
+ // qualified name with both outer and inner class names, or just the
+ // outer class name
+ String classifierName = getClassifierName(name);
+ Object mPackage = getPackage(packageName);
// import on demand
if (classifierName.equals("*")) {
parseState.addPackageContext(mPackage);
- Object pkgImport = null;
-
- // TODO: This use of UML Permission is non-standard.
- // Change it to a Dependency with a <<javaImport>> stereotype
- // or something else - tfm - 20070802
-
- // try find an existing permission
- Iterator dependenciesIt =
- Model.getCoreHelper()
- .getDependencies(mPackage, parseState.getComponent())
- .iterator();
- while (dependenciesIt.hasNext()) {
-
- Object dependency = dependenciesIt.next();
- if (Model.getFacade().isAPermission(dependency)) {
-
- pkgImport = dependency;
- break;
- }
- }
-
- // if no existing permission was found.
- if (pkgImport == null) {
- pkgImport =
- Model.getCoreFactory()
- .buildPermission(parseState.getComponent(), mPackage);
- String newName =
- makePermissionName(
- Model.getFacade().getName(
- parseState.getComponent()),
- packageName);
- Model.getCoreHelper().setName(pkgImport, newName);
- newElements.add(pkgImport);
- }
+ Object srcFile = parseState.getComponent();
+ buildImport(mPackage, srcFile);
}
// single type import
else {
@@ -376,6 +354,8 @@
LOG.info("Modeller.java: "
+ "forced creation of unknown classifier "
+ classifierName);
+ // TODO: A better strategy would be to defer creating this
+ // until we have enough information to determine what it is
mClassifier = Model.getCoreFactory().buildClass(
classifierName, mPackage);
newElements.add(mClassifier);
@@ -386,44 +366,38 @@
}
if (mClassifier != null) {
parseState.addClassifierContext(mClassifier);
-
- // TODO: This use of UML Permission is non-standard.
- // Change it to a Dependency with a <<javaImport>> stereotype
- // or something else - tfm - 20070802
-
- // try find an existing permission
- Iterator dependenciesIt =
- Model.getCoreHelper()
- .getDependencies(mClassifier,
- parseState.getComponent())
- .iterator();
- Object perm = null;
- while (dependenciesIt.hasNext()) {
-
- Object dependency = dependenciesIt.next();
- if (Model.getFacade().isAPermission(dependency)) {
-
- perm = dependency;
- break;
- }
- }
-
- // if no existing permission was found.
- if (perm == null) {
- perm =
- Model.getCoreFactory()
- .buildPermission(parseState.getComponent(),
- mClassifier);
- String newName =
- makePermissionName(
- parseState.getComponent(), mClassifier);
- Model.getCoreHelper().setName(perm, newName);
- newElements.add(perm);
- }
+ Object srcFile = parseState.getComponent();
+ buildImport(mClassifier, srcFile);
}
}
}
+
+ /*
+ * Build a Java import equivalent in UML. First search for an existing
+ * permission. Create a new one if not found.
+ */
+ private Object buildImport(Object element, Object srcFile) {
+ // TODO: This use of UML Permission is non-standard.
+ // Change it to a Dependency with a <<javaImport>> stereotype
+ // or something else - tfm - 20070802
+ Collection dependencies = Model.getCoreHelper().getDependencies(
+ element, srcFile);
+ for (Object dependency : dependencies) {
+ if (Model.getFacade().isAPermission(dependency)) {
+ return dependency;
+ }
+ }
+
+ // Didn't find it. Let's create one.
+ Object pkgImport = Model.getCoreFactory().buildPermission(srcFile,
+ element);
+ String newName = makePermissionName(srcFile, element);
+ Model.getCoreHelper().setName(pkgImport, newName);
+ newElements.add(pkgImport);
+ return pkgImport;
+ }
+
private String makeAbstractionName(Object child, Object parent) {
return makeFromToName(child, parent);
}
@@ -435,14 +409,11 @@
private String makeGeneralizationName(Object child, Object parent) {
return makeFromToName(child, parent);
}
-
- private String makePermissionName(String from, String to) {
- return makeFromToName(from, to);
- }
-
+
private String makePermissionName(Object from, Object to) {
return makeFromToName(from, to);
}
+
private String makeFromToName(Object from, Object to) {
return makeFromToName(
Model.getFacade().getName(from),
@@ -471,10 +442,10 @@
public void addClass(String name,
short modifiers,
String superclassName,
- Vector interfaces,
+ List<String> interfaces,
String javadoc) {
- addClass(name, modifiers, new Vector(), superclassName, interfaces,
- javadoc, false);
+ addClass(name, modifiers, Collections.EMPTY_LIST, superclassName,
+ interfaces, javadoc, false);
}
/**
@@ -493,9 +464,9 @@
*/
void addClass(String name,
short modifiers,
- Vector typeParameters,
+ List<String> typeParameters,
String superclassName,
- Vector interfaces,
+ List<String> interfaces,
String javadoc,
boolean forceIt) {
if (typeParameters != null && typeParameters.size() > 0) {
@@ -571,21 +542,21 @@
String name = parseState.anonymousClass();
try {
Object mClassifier = getContext(type).get(getClassifierName(type));
- Vector interfaces = new Vector();
+ List<String> interfaces = new ArrayList<String>();
if (Model.getFacade().isAInterface(mClassifier)) {
interfaces.add(type);
}
addClass(name,
(short) 0,
- new Vector(),
+ Collections.EMPTY_LIST,
Model.getFacade().isAClass(mClassifier) ? type : null,
interfaces,
"",
forceIt);
} catch (ClassifierNotFoundException e) {
// Must add it anyway, or the class popping will mismatch.
- addClass(name, (short) 0, new Vector(), null, new Vector(), "",
- forceIt);
+ addClass(name, (short) 0, Collections.EMPTY_LIST, null,
+ Collections.EMPTY_LIST, "", forceIt);
LOG.info("Modeller.java: an anonymous class was created "
+ "although it could not be found in the classpath.");
}
@@ -610,9 +581,10 @@
*/
public void addInterface(String name,
short modifiers,
- Vector interfaces,
+ List<String> interfaces,
String javadoc) {
- addInterface(name, modifiers, new Vector(), interfaces, javadoc, false);
+ addInterface(name, modifiers, Collections.EMPTY_LIST, interfaces,
+ javadoc, false);
}
/**
@@ -627,8 +599,8 @@
*/
void addInterface(String name,
short modifiers,
- Vector typeParameters,
- Vector interfaces,
+ List<String> typeParameters,
+ List<String> interfaces,
String javadoc,
boolean forceIt) {
if (typeParameters != null && typeParameters.size() > 0) {
@@ -647,8 +619,7 @@
return;
}
- for (Iterator i = interfaces.iterator(); i.hasNext();) {
- String interfaceName = (String) i.next();
+ for (String interfaceName : interfaces) {
Object parentInterface = null;
try {
parentInterface =
@@ -691,13 +662,13 @@
*/
void addEnumeration(String name,
short modifiers,
- Vector interfaces,
+ List<String> interfaces,
String javadoc,
boolean forceIt) {
Object mClass =
addClassifier(Model.getCoreFactory().createClass(),
name, modifiers, javadoc,
- new Vector()); // no type params for now
+ Collections.EMPTY_LIST); // no type params for now
Model.getCoreHelper().addStereotype(
mClass,
@@ -735,10 +706,9 @@
* @param interfaces
* @param forceIt
*/
- private void addInterfaces(Object mClass, Vector interfaces,
+ private void addInterfaces(Object mClass, List<String> interfaces,
boolean forceIt) {
- for (Iterator i = interfaces.iterator(); i.hasNext();) {
- String interfaceName = (String) i.next();
+ for (String interfaceName : interfaces) {
Object mInterface = null;
try {
mInterface =
@@ -815,9 +785,8 @@
if (!Model.getFacade().isAClass(element)) {
return false;
}
- Collection stereotypes = Model.getFacade().getStereotypes(element);
- for (Iterator it = stereotypes.iterator(); it.hasNext();) {
- if ("enumeration".equals(Model.getFacade().getName(it.next()))) {
+ for (Object stereotype : Model.getFacade().getStereotypes(element)) {
+ if ("enumeration".equals(Model.getFacade().getName(stereotype))) {
return true;
}
}
@@ -873,7 +842,7 @@
String name,
short modifiers,
String javadoc,
- Vector typeParameters) {
+ List<String> typeParameters) {
Object mClassifier;
Object mNamespace;
@@ -912,7 +881,7 @@
// set up the component residency (only for top level classes)
if (parseState.getClassifier() == null) {
- // set the clasifier to be a resident in its component:
+ // set the classifier to be a resident in its component:
// (before we push a new parse state on the stack)
// This test is carried over from a previous implementation,
@@ -990,7 +959,7 @@
// Remove inner classes not in source
parseState.removeObsoleteInnerClasses();
- parseState = (ParseState) parseStateStack.pop();
+ parseState = parseStateStack.pop();
}
/**
@@ -1003,7 +972,7 @@
* @param name
* The name of the operation as a string
* @param parameters
- * A number of vectors, each representing a parameter.
+ * A List of parameter declarations containing types and names.
* @param javadoc
* The javadoc comment. null or "" if no comment available.
* @return The operation.
@@ -1011,9 +980,9 @@
public Object addOperation (short modifiers,
String returnType,
String name,
- Vector parameters,
+ List<ParameterDeclaration> parameters,
String javadoc) {
- return addOperation(modifiers, new Vector(), returnType, name,
+ return addOperation(modifiers, Collections.EMPTY_LIST, returnType, name,
parameters, javadoc, false);
}
@@ -1035,10 +1004,10 @@
* @return The operation.
*/
Object addOperation (short modifiers,
- Vector typeParameters,
+ List<String> typeParameters,
String returnType,
String name,
- Vector parameters,
+ List<ParameterDeclaration> parameters,
String javadoc,
boolean forceIt) {
if (typeParameters != null && typeParameters.size() > 0) {
@@ -1066,8 +1035,8 @@
Collection c = new ArrayList(Model.getFacade()
.getParameters(mOperation));
- for (Iterator i = c.iterator(); i.hasNext();) {
- Model.getCoreHelper().removeParameter(mOperation, i.next());
+ for (Object parameter : c) {
+ Model.getCoreHelper().removeParameter(mOperation, parameter);
}
Object mParameter;
@@ -1108,9 +1077,8 @@
}
}
- for (Iterator i = parameters.iterator(); i.hasNext();) {
- Vector parameter = (Vector) i.next();
- typeName = (String) parameter.elementAt(1);
+ for (ParameterDeclaration parameter : parameters) {
+ typeName = parameter.getType();
// TODO: A type name with a trailing "..." represents
// a variable length parameter list. It can only be
// the last parameter and it gets converted to an array
@@ -1118,7 +1086,7 @@
// way (ie convert "Foo..." to "Foo[]"). - tfm - 20070329
if (typeName.endsWith("...")) {
logError("Unsupported variable length parameter list notation",
- (String) parameter.elementAt(2));
+ parameter.getName());
}
mClassifier = null;
try {
@@ -1143,10 +1111,8 @@
}
}
if (mClassifier != null) {
- mParameter =
- buildInParameter(
- mOperation, mClassifier, (String) parameter
- .elementAt(2));
+ mParameter = buildInParameter(mOperation, mClassifier,
+ parameter.getName());
if (!Model.getFacade().isAClassifier(mClassifier)) {
// the type resolution failed to find a valid classifier.
logError("Modeller.java: a valid type for a parameter "
@@ -1500,7 +1466,7 @@
}
/**
- * Search recursivly for nested packages in the model. So if you
+ * Search recursively for nested packages in the model. So if you
* pass a package org.argouml.kernel , this method searches for a package
* kernel, that is owned by a package argouml, which is owned by a
* package org. This method is required to nest the parsed packages.
@@ -1754,11 +1720,25 @@
@return The package name.
*/
private String getPackageName(String name) {
- int lastDot = name.lastIndexOf('.');
- if (lastDot == -1) {
- return "";
- }
- return name.substring(0, lastDot);
+ int lastDot = name.lastIndexOf('.');
+ if (lastDot == -1) {
+ return "";
+ }
+ String pkgName = name.substring(0, lastDot);
+ return pkgName;
+
+ // TODO: Fix handling of inner classes along the lines of the following...
+
+ // If the last element begins with an uppercase character, assume
+ // that we've really got a class, not a package. A better strategy
+ // would be to defer until we can disambiguate, but this should be
+ // better than what we have now for the more common case of inner
+ // classes.
+// if (Character.isUpperCase(getRelativePackageName(pkgName).charAt(0))) {
+// return getPackageName(pkgName);
+// } else {
+// return pkgName;
+// }
}
/**
@@ -1927,7 +1907,7 @@
}
}
// now eliminate multiple entries in that comma separated list
- HashSet stSet = new HashSet();
+ HashSet<String> stSet = new HashSet<String>();
StringTokenizer st = new StringTokenizer(sTagData, ", ");
while (st.hasMoreTokens()) {
stSet.add(st.nextToken().trim());
@@ -2139,7 +2119,7 @@
* Get collection of method calls.
* @return vector containing collected method calls
*/
- public synchronized Vector getMethodCalls() {
+ public synchronized List<String> getMethodCalls() {
return methodCalls;
}
Added: trunk/src_new/org/argouml/uml/reveng/java/ParameterDeclaration.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/reveng/java/ParameterDeclaration.java?view=auto&rev=13544
==============================================================================
--- (empty file)
+++ trunk/src_new/org/argouml/uml/reveng/java/ParameterDeclaration.java 2007-09-11 22:15:30-0700
@@ -0,0 +1,76 @@
+// $Id: eclipse-argo-codetemplates.xml 11347 2006-10-26 22:37:44Z linus $
+// Copyright (c) 2007 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies. This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason. IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.uml.reveng.java;
+
+/**
+ * Class to hold components of a parameter declaration including type, name, and
+ * any modifiers (e.g. final).
+ *
+ * @author Tom Morris <[email protected]>
+ */
+class ParameterDeclaration {
+
+ private final short modifiers;
+ private final String type;
+ private final String name;
+
+ /**
+ * Construct a new parameter declaration object.
+ *
+ * @param modifiers a short bitfield containing a bit set for each modifier.
+ * See the ACC_ definitions in the java.g grammar file or the
+ * Java spec to find the meaning of each individual bit.
+ * @param type the type of the parameter, possibly followed by array
+ * notation brackets
+ * @param name the name of the parameter
+ */
+ ParameterDeclaration(final short modifiers, final String type,
+ final String name) {
+ this.modifiers = modifiers;
+ this.type = type;
+ this.name = name;
+ }
+
+ /**
+ * @return a bitfield containing the modifiers for the parameter.
+ */
+ public short getModifiers() {
+ return modifiers;
+ }
+
+ /**
+ * @return the type of the parameter in string form.
+ */
+ public String getType() {
+ return type;
+ }
+
+ /**
+ * @return the name of the parameter.
+ */
+ public String getName() {
+ return name;
+ }
+}
Modified: trunk/src_new/org/argouml/uml/reveng/java/java.g
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src_new/org/argouml/uml/reveng/java/java.g?view=diff&rev=13544&p1=trunk/src_new/org/argouml/uml/reveng/java/java.g&p2=trunk/src_new/org/argouml/uml/reveng/java/java.g&r1=13543&r2=13544
==============================================================================
--- trunk/src_new/org/argouml/uml/reveng/java/java.g (original)
+++ trunk/src_new/org/argouml/uml/reveng/java/java.g 2007-09-11 22:15:30-0700
@@ -202,12 +202,12 @@
* Modified by Thomas Neustupny (July 06, 2005)
* Update to Java 1.5 for the Import feature of ArgoUML
* o Removed all AST stuff
- * o Added a lot of stuff for the UML Modeller
- * o Not passing typeArguments and typeParameters to the Modeller (don't how they map to UML)
+ * o Added a lot of stuff for the UML Modeler
+ * o Not passing typeArguments and typeParameters to the Modeler (don't how they map to UML)
*
* Modified by Tom Morris (March 29, 2007)
* o Added support for enums
- * o Added support to pass variableLengthParameterDeclaration to Modeller
+ * o Added support to pass variableLengthParameterDeclaration to Modeler
* o Added stubs for typeParameters, typeArguments, annotations and
* annotationDefinitions and so we can warn when they're skipped.
*
@@ -420,7 +420,8 @@
*/
private void addDotCall(String id, String thisOrSuper, boolean parenths) {
StringBuffer sb = new StringBuffer();
- String prev = (String)getModeller().getMethodCalls().lastElement();
+ List<String> calls = getModeller().getMethodCalls();
+ String prev = calls.get(calls.size() - 1);
if (thisOrSuper != null) {
sb.append(thisOrSuper);
} else if (prev != null) {
@@ -545,7 +546,8 @@
classOrInterfaceType returns [String type=null]
{StringBuffer sb = new StringBuffer();
String name = null;
- Vector ta = null;}
+ // TODO: type arguments not currently returned
+ List<String> ta = null;}
: t1:IDENT {name = t1.getText();} (ta=typeArguments)?
{sb.append(name);}
(options{greedy=true;}: // match as many as possible
@@ -579,16 +581,16 @@
;
// Type arguments to a class or interface type
-typeArguments returns [Vector names = new Vector()]
+typeArguments returns [List<String> names = new ArrayList<String>()]
{int currentLtLevel = 0;
String n = null;}
:
{currentLtLevel = ltCounter;}
LT {ltCounter++;}
- n=typeArgument {names.addElement(n);}
+ n=typeArgument {names.add(n);}
(options{greedy=true;}: // match as many as possible
{inputState.guessing !=0 || ltCounter == currentLtLevel + 1}?
- COMMA! n=typeArgument {names.addElement(n);}
+ COMMA! n=typeArgument {names.add(n);}
)*
( // turn warning off since Antlr generates the right code,
@@ -610,7 +612,7 @@
| BSR! {ltCounter-=3;}
;
-// Restriction on wildcard types based on super class or derrived class
+// Restriction on wildcard types based on super class or derived class
typeArgumentBounds returns [String tab=null]
{String t=null;}
:
@@ -725,7 +727,7 @@
: annotationMemberValuePair ( COMMA annotationMemberValuePair )*
;
-annotationMemberValuePair returns [Vector amps = new Vector();]
+annotationMemberValuePair returns [List<String> amps = new ArrayList<String>()]
: IDENT ASSIGN annotationMemberValueInitializer
;
@@ -767,9 +769,9 @@
// Definition of a Java class
classDefinition[String javadoc, short modifiers]
-{String superClassName = null; Vector ic = null; Vector tparam=null;}
+{String superClassName = null; List<String> ic = null; List<String> tparam=null;}
: "class" className:IDENT
- // it _might_ have type paramaters
+ // it _might_ have type parameters
(tparam=typeParameters)?
// it _might_ have a superclass...
superClassName=superClassClause
@@ -792,9 +794,9 @@
// Definition of a Java Interface
interfaceDefinition[String javadoc, short modifiers]
-{Vector ie=null;Vector tparam=null;}
+{List<String> ie=null;List<String> tparam=null;}
: "interface" interfaceName:IDENT
- // it _might_ have type paramaters
+ // it _might_ have type parameters
(tparam=typeParameters)?
// it might extend some other interfaces
ie=interfaceExtends
@@ -806,7 +808,7 @@
;
enumDefinition[String javadoc, short modifiers]
-{Vector ic=null;}
+{List<String> ic=null;}
: "enum" enumName:IDENT
// it might implement some interfaces...
ic=implementsClause
@@ -831,14 +833,14 @@
// TODO: need a popClassifier or perhaps endAnnotationDefinintion here
;
-typeParameters returns [Vector names = new Vector()]
+typeParameters returns [List<String> names = new ArrayList<String>()]
{int currentLtLevel = 0; String n=null;}
:
{currentLtLevel = ltCounter;
getModeller().addTypeParameters();}
LT {ltCounter++;}
- n=typeParameter {names.addElement(n);}
- (COMMA n=typeParameter)* {names.addElement(n);}
+ n=typeParameter {names.add(n);}
+ (COMMA n=typeParameter)* {names.add(n);}
(typeArgumentsOrParametersEnd)?
// make sure we have gobbled up enough '>' characters
@@ -899,7 +901,7 @@
// An annotation field
annotationField
-{short mods=0; String t=null; Vector param=null; String a=null;
+{short mods=0; String t=null; List<ParameterDeclaration> param=null; String a=null;
boolean isOutestCompStat = !isInCompoundStatement();}
: mods=modifiers
( typeDefinitionInternal[mods]
@@ -945,7 +947,7 @@
//An enum constant field is just like a class field but without
//the posibility of a constructor definition or a static initializer
enumConstantField
-{short mods=0; String t=null; Vector param=null; String a=null; Vector tparam=null;
+{short mods=0; String t=null; List<ParameterDeclaration> param=null; String a=null; List<String> tparam=null;
boolean isOutestCompStat = !isInCompoundStatement();}
: mods=modifiers
( typeDefinitionInternal[mods]
@@ -982,27 +984,27 @@
;
// An interface can extend several other interfaces...
-interfaceExtends returns [Vector names=new Vector()]
+interfaceExtends returns [List<String> names=new ArrayList<String>()]
{String n=null;}
: (
"extends"
- n=classOrInterfaceType {names.addElement(n);}
- ( COMMA n=classOrInterfaceType {names.addElement(n);} )*
+ n=classOrInterfaceType {names.add(n);}
+ ( COMMA n=classOrInterfaceType {names.add(n);} )*
)?
;
// A class can implement several interfaces...
-implementsClause returns [Vector names=new Vector()]
+implementsClause returns [List<String> names=new ArrayList<String>()]
{String n=null;}
: (
- "implements" n=classOrInterfaceType {names.addElement(n);}
- ( COMMA n=classOrInterfaceType {names.addElement(n);} )*
+ "implements" n=classOrInterfaceType {names.add(n);}
+ ( COMMA n=classOrInterfaceType {names.add(n);} )*
)?
;
// Now the various things that can be defined inside a class
classField
-{short mods=0; String t=null; Vector param=null; String a=null; Vector tparam=null;
+{short mods=0; String t=null; List<ParameterDeclaration> param=null; String a=null; List<String> tparam=null;
boolean isOutestCompStat = !isInCompoundStatement();}
: // method, constructor, or variable declaration
mods=modifiers
@@ -1055,7 +1057,7 @@
// Now the various things that can be defined inside a interface
interfaceField
-{short mods=0; String t=null; Vector param=null; String a=null; Vector tparam=null;
+{short mods=0; String t=null; List<ParameterDeclaration> param=null; String a=null; List<String> tparam=null;
boolean isOutestCompStat = !isInCompoundStatement();}
: // method, constructor, or variable declaration
mods=modifiers
@@ -1199,7 +1201,7 @@
// for the method.
// This also watches for a list of exception classes in a "throws" clause.
ctorHead[ short mods]
- {Vector param = null;
+ {List<ParameterDeclaration> param = null;
boolean isOutestCompStat = !isInCompoundStatement();}
: name:IDENT // the name of the method
@@ -1207,7 +1209,7 @@
LPAREN param=parameterDeclarationList RPAREN
{if (isOutestCompStat && level > 0) {
- setMethod(getModeller().addOperation(mods, new Vector(), null,
+ setMethod(getModeller().addOperation(mods, Collections.EMPTY_LIST, null,
name.getText(), param, getJavadocComment(), (parserMode == MODE_IMPORT_PASS2)));
}}
// get the list of exceptions that this method is declared to throw
@@ -1222,8 +1224,8 @@
// A list of formal parameters
// Zero or more parameters
// If a parameter is variable length (e.g. String... myArg) it is the right-most parameter
-parameterDeclarationList returns [Vector paramList=new Vector()]
-{Vector currentParameter=null;}
+parameterDeclarationList returns [List<ParameterDeclaration> paramList=new ArrayList<ParameterDeclaration>()]
+{ParameterDeclaration currentParameter=null;}
// The semantic check in ( .... )* block is flagged as superfluous, and seems superfluous but
// is the only way I could make this work. If my understanding is correct this is a known bug
: ( ( parameterDeclaration )=> currentParameter=parameterDeclaration { paramList.add(currentParameter); }
@@ -1235,27 +1237,23 @@
;
// A formal parameter.
-parameterDeclaration returns [Vector pd=new Vector()]
+parameterDeclaration returns [ParameterDeclaration pd=null]
{short pm=0; String ts=null; String pdb=null;}
: pm=parameterModifier ts=typeSpec id:IDENT
pdb=declaratorBrackets
- { pd.add(new Short(pm));
- pd.add(ts + pdb);
- pd.add(id.getText());}
+ { pd = new ParameterDeclaration(pm, ts + pdb, id.getText());}
;
-variableLengthParameterDeclaration returns [Vector pd=new Vector()]
+variableLengthParameterDeclaration returns [ParameterDeclaration pd=null]
{short pm=0; String ts=null; String pdb=null;}
: pm=parameterModifier ts=typeSpec TRIPLE_DOT id:IDENT
pdb=declaratorBrackets
- { pd.add(new Short(pm));
- pd.add(ts + "..." + pdb); // interpretation handled by Modeller
- pd.add(id.getText());}
+ { pd = new ParameterDeclaration(pm, ts + "..." + pdb, id.getText());}
;
-parameterModifier returns [short mods=0;]
+parameterModifier returns [short mods=0]
//final can appear amongst annotations in any order - greedily consume any preceding
- //annotations to shut nond-eterminism warnings off
+ //annotations to shut non-determinism warnings off
: (options{greedy=true;} : annotation)* ("final" {mods |= ACC_FINAL;})? (annotation)*
;
@@ -1622,7 +1620,7 @@
postfixExpression
{ String thisOrSuper = null;
boolean parenths = LA(1) == LPAREN;
- Vector ta=null; }
+ List<String> ta=null; }
:
primaryExpression
(
@@ -1703,7 +1701,7 @@
* this or super.
*/
identPrimary
-{ StringBuffer sb = null; Vector ta=null;}
+{ StringBuffer sb = null; List<String> ta=null;}
: (ta=typeArguments)?
id:IDENT
{ if ((parserMode & MODE_REVENG_SEQUENCE) != 0) {
@@ -1810,7 +1808,7 @@
*
*/
newExpression
- {String t = null; Vector ta=null;}
+ {String t = null; List<String> ta=null;}
: "new" (ta=typeArguments)? t=type
( LPAREN argList RPAREN
{ if ((parserMode & MODE_REVENG_SEQUENCE) != 0) {
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.