From 8d8939ac74bdfb9d9e543e667b49c9dff81f0d38 Mon Sep 17 00:00:00 2001 From: acolyer Date: Wed, 22 Jun 2005 15:15:49 +0000 Subject: rename weaver.patterns.TypeVariable to weaver.patterns.TypeVariablePattern --- .../patterns/AbstractPatternNodeVisitor.java | 2 +- .../weaver/patterns/IdentityPointcutVisitor.java | 2 +- .../weaver/patterns/PatternNodeVisitor.java | 4 +- .../org/aspectj/weaver/patterns/PatternParser.java | 14 +- .../weaver/patterns/ScopeWithTypeVariables.java | 2 +- .../org/aspectj/weaver/patterns/TypeVariable.java | 216 --------------------- .../weaver/patterns/TypeVariablePattern.java | 216 +++++++++++++++++++++ .../weaver/patterns/TypeVariablePatternList.java | 14 +- .../aspectj/weaver/patterns/ParserTestCase.java | 64 +++--- 9 files changed, 267 insertions(+), 267 deletions(-) delete mode 100644 weaver/src/org/aspectj/weaver/patterns/TypeVariable.java create mode 100644 weaver/src/org/aspectj/weaver/patterns/TypeVariablePattern.java diff --git a/weaver/src/org/aspectj/weaver/patterns/AbstractPatternNodeVisitor.java b/weaver/src/org/aspectj/weaver/patterns/AbstractPatternNodeVisitor.java index 11c4ea60c..5c93d020a 100644 --- a/weaver/src/org/aspectj/weaver/patterns/AbstractPatternNodeVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/AbstractPatternNodeVisitor.java @@ -397,7 +397,7 @@ public abstract class AbstractPatternNodeVisitor implements PatternNodeVisitor { return node; } - public Object visit(TypeVariable node, Object data) { + public Object visit(TypeVariablePattern node, Object data) { return node; } diff --git a/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java b/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java index 90a302d1b..bd1269ef0 100644 --- a/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/IdentityPointcutVisitor.java @@ -232,7 +232,7 @@ public class IdentityPointcutVisitor implements PatternNodeVisitor { return node; } - public Object visit(TypeVariable node, Object data) { + public Object visit(TypeVariablePattern node, Object data) { return node; } diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternNodeVisitor.java b/weaver/src/org/aspectj/weaver/patterns/PatternNodeVisitor.java index 87a61a694..4e97357d0 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternNodeVisitor.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternNodeVisitor.java @@ -86,7 +86,7 @@ public interface PatternNodeVisitor { Object visit(NamePattern node, Object data); Object visit(SignaturePattern node, Object data); Object visit(ThrowsPattern node, Object data); - Object visit(TypeVariable node, Object data); + Object visit(TypeVariablePattern node, Object data); Object visit(TypeVariablePatternList node,Object data); // Catch-all @@ -549,7 +549,7 @@ public interface PatternNodeVisitor { return null; } - public Object visit(TypeVariable node, Object data) { + public Object visit(TypeVariablePattern node, Object data) { append(node); return null; } diff --git a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java index ade7b62db..a80e9bdea 100644 --- a/weaver/src/org/aspectj/weaver/patterns/PatternParser.java +++ b/weaver/src/org/aspectj/weaver/patterns/PatternParser.java @@ -1183,14 +1183,14 @@ public class PatternParser { public TypeVariablePatternList maybeParseTypeVariableList() { if (!maybeEat("<")) return null; List typeVars = new ArrayList(); - TypeVariable t = parseTypeVariable(); + TypeVariablePattern t = parseTypeVariable(); typeVars.add(t); while (maybeEat(",")) { - TypeVariable nextT = parseTypeVariable(); + TypeVariablePattern nextT = parseTypeVariable(); typeVars.add(nextT); } eat(">"); - TypeVariable[] tvs = new TypeVariable[typeVars.size()]; + TypeVariablePattern[] tvs = new TypeVariablePattern[typeVars.size()]; typeVars.toArray(tvs); return new TypeVariablePatternList(tvs); } @@ -1201,11 +1201,11 @@ public class PatternParser { List typeVars = new ArrayList(); do { String typeVarName = parseIdentifier(); - TypeVariable tv = new TypeVariable(typeVarName); + TypeVariablePattern tv = new TypeVariablePattern(typeVarName); typeVars.add(tv); } while (maybeEat(",")); eat(">","',' or '>'"); - TypeVariable[] tvs = new TypeVariable[typeVars.size()]; + TypeVariablePattern[] tvs = new TypeVariablePattern[typeVars.size()]; typeVars.toArray(tvs); return new TypeVariablePatternList(tvs); } @@ -1223,7 +1223,7 @@ public class PatternParser { return new TypePatternList(tps); } - public TypeVariable parseTypeVariable() { + public TypeVariablePattern parseTypeVariable() { TypePattern upperBound = null; TypePattern[] additionalInterfaceBounds = null; TypePattern lowerBound = null; @@ -1235,7 +1235,7 @@ public class PatternParser { } else if (maybeEatIdentifier("super")) { lowerBound = parseTypePattern(); } - return new TypeVariable(typeVariableName,upperBound,additionalInterfaceBounds,lowerBound); + return new TypeVariablePattern(typeVariableName,upperBound,additionalInterfaceBounds,lowerBound); } private TypePattern[] maybeParseAdditionalInterfaceBounds() { diff --git a/weaver/src/org/aspectj/weaver/patterns/ScopeWithTypeVariables.java b/weaver/src/org/aspectj/weaver/patterns/ScopeWithTypeVariables.java index dcab3ba4f..b6d450ad6 100644 --- a/weaver/src/org/aspectj/weaver/patterns/ScopeWithTypeVariables.java +++ b/weaver/src/org/aspectj/weaver/patterns/ScopeWithTypeVariables.java @@ -36,7 +36,7 @@ public class ScopeWithTypeVariables implements IScope { * @see org.aspectj.weaver.patterns.IScope#lookupType(java.lang.String, org.aspectj.weaver.IHasPosition) */ public TypeX lookupType(String name, IHasPosition location) { - TypeVariable typeVariableMatch = typeVariables.lookupTypeVariable(name); + TypeVariablePattern typeVariableMatch = typeVariables.lookupTypeVariable(name); if (typeVariableMatch != null) { return typeVariableMatch.resolvedType(); } else { diff --git a/weaver/src/org/aspectj/weaver/patterns/TypeVariable.java b/weaver/src/org/aspectj/weaver/patterns/TypeVariable.java deleted file mode 100644 index 8c667f010..000000000 --- a/weaver/src/org/aspectj/weaver/patterns/TypeVariable.java +++ /dev/null @@ -1,216 +0,0 @@ -/* ******************************************************************* - * Copyright (c) 2005 Contributors. - * All rights reserved. - * This program and the accompanying materials are made available - * under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution and is available at - * http://eclipse.org/legal/epl-v10.html - * - * Contributors: - * Adrian Colyer Initial implementation - * ******************************************************************/ -package org.aspectj.weaver.patterns; - -import java.io.DataOutputStream; -import java.io.IOException; - -import org.aspectj.weaver.ISourceContext; -import org.aspectj.weaver.ResolvedTypeX; -import org.aspectj.weaver.TypeX; -import org.aspectj.weaver.VersionedDataInputStream; - -/** - * @author colyer - * Represents a type variable as declared as part of a type declaration, parameter declaration, - * or type parameter specification. - *

For example:

- * - */ -public class TypeVariable extends PatternNode { - - private static final String anything = "?"; - - private String name; // eg. "T" - private TypePattern upperBound; // default is object unless of the form T extends Bar - private TypePattern[] interfaceBounds; // additional upper bounds (must be interfaces) arising from - // declarations of the form T extends Bar & IGoo, IDoo - private TypePattern lowerBound; // only set if type variable is of the form T super Bar - private ResolvedTypeX resolvedType; // only set if resolved - - /** - * Create a named type variable with upper bound Object and no lower bounds. - * Use this constructor for the simple "T" case - */ - public TypeVariable(String variableName) { - this.name = variableName; - this.upperBound = new ExactTypePattern(TypeX.OBJECT,false,false); - this.lowerBound = null; - this.interfaceBounds = null; - } - - /** - * Create a named type variable with the given upper bound and no lower bounds - * Use this constructor for the T extends Foo case - * @param variableName - * @param upperBound - */ - public TypeVariable(String variableName, TypePattern upperBound) { - this.name = variableName; - this.upperBound = upperBound; - this.lowerBound = null; - this.interfaceBounds = null; - } - - public TypeVariable(String variableName, TypePattern upperLimit, TypePattern[] interfaceBounds, TypePattern lowerBound) { - this.name = variableName; - this.upperBound = upperLimit; - if (upperBound == null) upperBound = new ExactTypePattern(TypeX.OBJECT,false,false); - this.interfaceBounds = interfaceBounds; - this.lowerBound = lowerBound; - } - - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this,data); - } - - public String getName() { - return name; - } - - public boolean isAnythingPattern() { - return name.equals(anything); - } - - public TypePattern getRawTypePattern() { - return upperBound; - } - - public TypePattern getUpperBound() { - return upperBound; - } - - public boolean hasLowerBound() { return (lowerBound != null); } - - public TypePattern getLowerBound() { - return lowerBound; - } - - public boolean hasAdditionalInterfaceBounds() { - return (interfaceBounds != null); - } - - public TypePattern[] getAdditionalInterfaceBounds() { - if (interfaceBounds != null) { - return interfaceBounds; - } else { - return new TypePattern[0]; - } - } - - public ResolvedTypeX resolvedType() { - throw new UnsupportedOperationException("Haven't implement ResolvedTypeX for TypeVariables yet..."); - //return this.resolvedType; - } - - public boolean equals(Object obj) { - if (!(obj instanceof TypeVariable)) return false; - TypeVariable other = (TypeVariable) obj; - if (!name.equals(other.name)) return false; - if (!upperBound.equals(other.upperBound)) return false; - if (lowerBound != null) { - if (other.lowerBound == null) return false; - if (!lowerBound.equals(other.lowerBound)) return false; - } else { - if (other.lowerBound != null) return false; - } - if (interfaceBounds != null) { - if (other.interfaceBounds == null) return false; - if (interfaceBounds.length != other.interfaceBounds.length) return false; - for (int i = 0; i < interfaceBounds.length; i++) { - if (!interfaceBounds[i].equals(other.interfaceBounds[i])) return false; - } - } else { - if (other.interfaceBounds != null) return false; - } - return true; - } - - public int hashCode() { - int hashCode = 17 + (37 * name.hashCode()); - hashCode = hashCode * 37 + upperBound.hashCode(); - if (lowerBound != null) hashCode = hashCode * 37 + lowerBound.hashCode(); - if (interfaceBounds != null) { - for (int i = 0; i < interfaceBounds.length; i++) { - hashCode = 37*hashCode + interfaceBounds[i].hashCode(); - } - } - return hashCode; - } - - public String toString() { - StringBuffer sb = new StringBuffer(); - sb.append(name); - sb.append(getExtendsClause()); - if (interfaceBounds != null) { - sb.append(" & "); - for (int i = 0; i < interfaceBounds.length; i++) { - sb.append(interfaceBounds[i].toString()); - if (i < interfaceBounds.length) sb.append(","); - } - } - if (lowerBound != null) { - sb.append(" super "); - sb.append(lowerBound.toString()); - } - return sb.toString(); - } - - private String getExtendsClause() { - if (upperBound instanceof ExactTypePattern) { - ExactTypePattern bound = (ExactTypePattern) upperBound; - if (bound.type == TypeX.OBJECT) return ""; - } - return " extends " + upperBound.toString(); - } - - public void write(DataOutputStream s) throws IOException { - s.writeUTF(name); - upperBound.write(s); - if (interfaceBounds == null) { - s.writeInt(0); - } else { - s.writeInt(interfaceBounds.length); - for (int i = 0; i < interfaceBounds.length; i++) { - interfaceBounds[i].write(s); - } - } - s.writeBoolean(hasLowerBound()); - if (hasLowerBound()) lowerBound.write(s); - writeLocation(s); - } - - public static TypeVariable read(VersionedDataInputStream s, ISourceContext context) throws IOException { - TypeVariable tv = null; - String name = s.readUTF(); - TypePattern upperBound = TypePattern.read(s, context); - TypePattern[] additionalInterfaceBounds = null; - int numInterfaceBounds = s.readInt(); - if (numInterfaceBounds > 0) { - additionalInterfaceBounds = new TypePattern[numInterfaceBounds]; - for (int i = 0; i < additionalInterfaceBounds.length; i++) { - additionalInterfaceBounds[i] = TypePattern.read(s, context); - } - } - boolean hasLowerBound = s.readBoolean(); - TypePattern lowerBound = null; - if (hasLowerBound) lowerBound = TypePattern.read(s,context); - tv = new TypeVariable(name,upperBound,additionalInterfaceBounds,lowerBound); - tv.readLocation(context, s); - return tv; - } - -} diff --git a/weaver/src/org/aspectj/weaver/patterns/TypeVariablePattern.java b/weaver/src/org/aspectj/weaver/patterns/TypeVariablePattern.java new file mode 100644 index 000000000..6b0262456 --- /dev/null +++ b/weaver/src/org/aspectj/weaver/patterns/TypeVariablePattern.java @@ -0,0 +1,216 @@ +/* ******************************************************************* + * Copyright (c) 2005 Contributors. + * All rights reserved. + * This program and the accompanying materials are made available + * under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution and is available at + * http://eclipse.org/legal/epl-v10.html + * + * Contributors: + * Adrian Colyer Initial implementation + * ******************************************************************/ +package org.aspectj.weaver.patterns; + +import java.io.DataOutputStream; +import java.io.IOException; + +import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.ResolvedTypeX; +import org.aspectj.weaver.TypeX; +import org.aspectj.weaver.VersionedDataInputStream; + +/** + * @author colyer + * Represents a type variable as declared as part of a type declaration, parameter declaration, + * or type parameter specification. + *

For example:

+ * + */ +public class TypeVariablePattern extends PatternNode { + + private static final String anything = "?"; + + private String name; // eg. "T" + private TypePattern upperBound; // default is object unless of the form T extends Bar + private TypePattern[] interfaceBounds; // additional upper bounds (must be interfaces) arising from + // declarations of the form T extends Bar & IGoo, IDoo + private TypePattern lowerBound; // only set if type variable is of the form T super Bar + private ResolvedTypeX resolvedType; // only set if resolved + + /** + * Create a named type variable with upper bound Object and no lower bounds. + * Use this constructor for the simple "T" case + */ + public TypeVariablePattern(String variableName) { + this.name = variableName; + this.upperBound = new ExactTypePattern(TypeX.OBJECT,false,false); + this.lowerBound = null; + this.interfaceBounds = null; + } + + /** + * Create a named type variable with the given upper bound and no lower bounds + * Use this constructor for the T extends Foo case + * @param variableName + * @param upperBound + */ + public TypeVariablePattern(String variableName, TypePattern upperBound) { + this.name = variableName; + this.upperBound = upperBound; + this.lowerBound = null; + this.interfaceBounds = null; + } + + public TypeVariablePattern(String variableName, TypePattern upperLimit, TypePattern[] interfaceBounds, TypePattern lowerBound) { + this.name = variableName; + this.upperBound = upperLimit; + if (upperBound == null) upperBound = new ExactTypePattern(TypeX.OBJECT,false,false); + this.interfaceBounds = interfaceBounds; + this.lowerBound = lowerBound; + } + + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this,data); + } + + public String getName() { + return name; + } + + public boolean isAnythingPattern() { + return name.equals(anything); + } + + public TypePattern getRawTypePattern() { + return upperBound; + } + + public TypePattern getUpperBound() { + return upperBound; + } + + public boolean hasLowerBound() { return (lowerBound != null); } + + public TypePattern getLowerBound() { + return lowerBound; + } + + public boolean hasAdditionalInterfaceBounds() { + return (interfaceBounds != null); + } + + public TypePattern[] getAdditionalInterfaceBounds() { + if (interfaceBounds != null) { + return interfaceBounds; + } else { + return new TypePattern[0]; + } + } + + public ResolvedTypeX resolvedType() { + throw new UnsupportedOperationException("Haven't implement ResolvedTypeX for TypeVariables yet..."); + //return this.resolvedType; + } + + public boolean equals(Object obj) { + if (!(obj instanceof TypeVariablePattern)) return false; + TypeVariablePattern other = (TypeVariablePattern) obj; + if (!name.equals(other.name)) return false; + if (!upperBound.equals(other.upperBound)) return false; + if (lowerBound != null) { + if (other.lowerBound == null) return false; + if (!lowerBound.equals(other.lowerBound)) return false; + } else { + if (other.lowerBound != null) return false; + } + if (interfaceBounds != null) { + if (other.interfaceBounds == null) return false; + if (interfaceBounds.length != other.interfaceBounds.length) return false; + for (int i = 0; i < interfaceBounds.length; i++) { + if (!interfaceBounds[i].equals(other.interfaceBounds[i])) return false; + } + } else { + if (other.interfaceBounds != null) return false; + } + return true; + } + + public int hashCode() { + int hashCode = 17 + (37 * name.hashCode()); + hashCode = hashCode * 37 + upperBound.hashCode(); + if (lowerBound != null) hashCode = hashCode * 37 + lowerBound.hashCode(); + if (interfaceBounds != null) { + for (int i = 0; i < interfaceBounds.length; i++) { + hashCode = 37*hashCode + interfaceBounds[i].hashCode(); + } + } + return hashCode; + } + + public String toString() { + StringBuffer sb = new StringBuffer(); + sb.append(name); + sb.append(getExtendsClause()); + if (interfaceBounds != null) { + sb.append(" & "); + for (int i = 0; i < interfaceBounds.length; i++) { + sb.append(interfaceBounds[i].toString()); + if (i < interfaceBounds.length) sb.append(","); + } + } + if (lowerBound != null) { + sb.append(" super "); + sb.append(lowerBound.toString()); + } + return sb.toString(); + } + + private String getExtendsClause() { + if (upperBound instanceof ExactTypePattern) { + ExactTypePattern bound = (ExactTypePattern) upperBound; + if (bound.type == TypeX.OBJECT) return ""; + } + return " extends " + upperBound.toString(); + } + + public void write(DataOutputStream s) throws IOException { + s.writeUTF(name); + upperBound.write(s); + if (interfaceBounds == null) { + s.writeInt(0); + } else { + s.writeInt(interfaceBounds.length); + for (int i = 0; i < interfaceBounds.length; i++) { + interfaceBounds[i].write(s); + } + } + s.writeBoolean(hasLowerBound()); + if (hasLowerBound()) lowerBound.write(s); + writeLocation(s); + } + + public static TypeVariablePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException { + TypeVariablePattern tv = null; + String name = s.readUTF(); + TypePattern upperBound = TypePattern.read(s, context); + TypePattern[] additionalInterfaceBounds = null; + int numInterfaceBounds = s.readInt(); + if (numInterfaceBounds > 0) { + additionalInterfaceBounds = new TypePattern[numInterfaceBounds]; + for (int i = 0; i < additionalInterfaceBounds.length; i++) { + additionalInterfaceBounds[i] = TypePattern.read(s, context); + } + } + boolean hasLowerBound = s.readBoolean(); + TypePattern lowerBound = null; + if (hasLowerBound) lowerBound = TypePattern.read(s,context); + tv = new TypeVariablePattern(name,upperBound,additionalInterfaceBounds,lowerBound); + tv.readLocation(context, s); + return tv; + } + +} diff --git a/weaver/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java b/weaver/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java index 1107d4e81..a01633130 100644 --- a/weaver/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java +++ b/weaver/src/org/aspectj/weaver/patterns/TypeVariablePatternList.java @@ -23,19 +23,19 @@ import org.aspectj.weaver.VersionedDataInputStream; */ public class TypeVariablePatternList extends PatternNode { - public static final TypeVariablePatternList EMPTY = new TypeVariablePatternList(new TypeVariable[0]); + public static final TypeVariablePatternList EMPTY = new TypeVariablePatternList(new TypeVariablePattern[0]); - private TypeVariable[] patterns; + private TypeVariablePattern[] patterns; - public TypeVariablePatternList(TypeVariable[] typeVars) { + public TypeVariablePatternList(TypeVariablePattern[] typeVars) { this.patterns = typeVars; } - public TypeVariable[] getTypeVariablePatterns() { + public TypeVariablePattern[] getTypeVariablePatterns() { return this.patterns; } - public TypeVariable lookupTypeVariable(String name) { + public TypeVariablePattern lookupTypeVariable(String name) { for (int i = 0; i < patterns.length; i++) { if (patterns[i].getName().equals(name)) { return patterns[i]; @@ -56,9 +56,9 @@ public class TypeVariablePatternList extends PatternNode { TypeVariablePatternList ret = EMPTY; int length = s.readInt(); if (length > 0) { - TypeVariable[] patterns = new TypeVariable[length]; + TypeVariablePattern[] patterns = new TypeVariablePattern[length]; for (int i = 0; i < patterns.length; i++) { - patterns[i] = TypeVariable.read(s,context); + patterns[i] = TypeVariablePattern.read(s,context); } ret = new TypeVariablePatternList(patterns); } diff --git a/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java b/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java index 2b07aa6b6..9fb105ca8 100644 --- a/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java +++ b/weaver/testsrc/org/aspectj/weaver/patterns/ParserTestCase.java @@ -232,37 +232,37 @@ public class ParserTestCase extends TestCase { public void testParseSimpleTypeVariable() { PatternParser parser = new PatternParser("T"); - TypeVariable tv = parser.parseTypeVariable(); - TypeVariable expected = new TypeVariable("T"); + TypeVariablePattern tv = parser.parseTypeVariable(); + TypeVariablePattern expected = new TypeVariablePattern("T"); assertEquals("Expected simple type variable T",expected,tv); } public void testParseExtendingTypeVariable() { PatternParser parser = new PatternParser("T extends Number"); - TypeVariable tv = parser.parseTypeVariable(); - TypeVariable expected = new TypeVariable("T",new PatternParser("Number").parseTypePattern()); + TypeVariablePattern tv = parser.parseTypeVariable(); + TypeVariablePattern expected = new TypeVariablePattern("T",new PatternParser("Number").parseTypePattern()); assertEquals("Expected type variable T extends Number",expected,tv); } public void testParseExtendingTypeVariableWithPattern() { PatternParser parser = new PatternParser("T extends Number+"); - TypeVariable tv = parser.parseTypeVariable(); - TypeVariable expected = new TypeVariable("T",new PatternParser("Number+").parseTypePattern()); + TypeVariablePattern tv = parser.parseTypeVariable(); + TypeVariablePattern expected = new TypeVariablePattern("T",new PatternParser("Number+").parseTypePattern()); assertEquals("Expected type variable T extends Number+",expected,tv); } public void testParseExtendingTypeVariableWithInterface() { PatternParser parser = new PatternParser("T extends Number & Comparable"); - TypeVariable tv = parser.parseTypeVariable(); - TypeVariable expected = new TypeVariable("T",new PatternParser("Number").parseTypePattern(), + TypeVariablePattern tv = parser.parseTypeVariable(); + TypeVariablePattern expected = new TypeVariablePattern("T",new PatternParser("Number").parseTypePattern(), new TypePattern[] {new PatternParser("Comparable").parseTypePattern()},null); assertEquals("Expected type variable T extends Number",expected,tv); } public void testParseExtendingTypeVariableWithInterfaceList() { PatternParser parser = new PatternParser("T extends Number & Comparable & Cloneable"); - TypeVariable tv = parser.parseTypeVariable(); - TypeVariable expected = new TypeVariable("T",new PatternParser("Number").parseTypePattern(), + TypeVariablePattern tv = parser.parseTypeVariable(); + TypeVariablePattern expected = new TypeVariablePattern("T",new PatternParser("Number").parseTypePattern(), new TypePattern[] {new PatternParser("Comparable").parseTypePattern(), new PatternParser("Cloneable").parseTypePattern()},null); assertEquals("Expected type variable T extends Number",expected,tv); @@ -271,8 +271,8 @@ public class ParserTestCase extends TestCase { public void testParseTypeParameterList() { PatternParser parser = new PatternParser(""); TypeVariablePatternList list = parser.maybeParseTypeVariableList(); - TypeVariable[] patterns = list.getTypeVariablePatterns(); - TypeVariable expected = new TypeVariable("T"); + TypeVariablePattern[] patterns = list.getTypeVariablePatterns(); + TypeVariablePattern expected = new TypeVariablePattern("T"); assertEquals("Expected simple type variable T",expected,patterns[0]); assertEquals("One pattern in list",1,patterns.length); } @@ -280,12 +280,12 @@ public class ParserTestCase extends TestCase { public void testParseTypeParameterListWithSeveralTypeParameters() { PatternParser parser = new PatternParser(""); TypeVariablePatternList list = parser.maybeParseTypeVariableList(); - TypeVariable[] patterns = list.getTypeVariablePatterns(); - TypeVariable expected0 = new TypeVariable("T"); + TypeVariablePattern[] patterns = list.getTypeVariablePatterns(); + TypeVariablePattern expected0 = new TypeVariablePattern("T"); assertEquals("Expected simple type variable T",expected0,patterns[0]); - TypeVariable expected1 = new TypeVariable("S",new PatternParser("Number").parseTypePattern()); + TypeVariablePattern expected1 = new TypeVariablePattern("S",new PatternParser("Number").parseTypePattern()); assertEquals("Expected type variable S extends Number",expected1,patterns[1]); - TypeVariable expected2 = new TypeVariable("R"); + TypeVariablePattern expected2 = new TypeVariablePattern("R"); assertEquals("Expected simple type variable R",expected2,patterns[2]); assertEquals("3 patterns in list",3,patterns.length); @@ -294,8 +294,8 @@ public class ParserTestCase extends TestCase { public void testParseAllowedSuperInTypeVariable() { PatternParser parser = new PatternParser("T super Number+"); - TypeVariable tv = parser.parseTypeVariable(); - TypeVariable expected = new TypeVariable("T",new ExactTypePattern(TypeX.OBJECT,false,false),null,new PatternParser("Number+").parseTypePattern()); + TypeVariablePattern tv = parser.parseTypeVariable(); + TypeVariablePattern expected = new TypeVariablePattern("T",new ExactTypePattern(TypeX.OBJECT,false,false),null,new PatternParser("Number+").parseTypePattern()); assertEquals("Expected type variable T super Number+",expected,tv); } @@ -362,11 +362,11 @@ public class ParserTestCase extends TestCase { public void testSimpleTypeVariableList() { PatternParser parser = new PatternParser(""); TypeVariablePatternList tl = parser.maybeParseSimpleTypeVariableList(); - TypeVariable[] patterns = tl.getTypeVariablePatterns(); + TypeVariablePattern[] patterns = tl.getTypeVariablePatterns(); assertEquals("3 patterns",3,patterns.length); - assertEquals("T",new TypeVariable("T"),patterns[0]); - assertEquals("S",new TypeVariable("S"),patterns[1]); - assertEquals("V",new TypeVariable("V"),patterns[2]); + assertEquals("T",new TypeVariablePattern("T"),patterns[0]); + assertEquals("S",new TypeVariablePattern("S"),patterns[1]); + assertEquals("V",new TypeVariablePattern("V"),patterns[2]); } public void testSimpleTypeVariableListError() { @@ -382,7 +382,7 @@ public class ParserTestCase extends TestCase { public void testParseCallPCDWithTypeVariables() { PatternParser parser = new PatternParser("call(* Foo.*(T))"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvps = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvps = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type variable",1,tvps.length); assertEquals("T",tvps[0].getName()); } @@ -530,7 +530,7 @@ public class ParserTestCase extends TestCase { public void testExecutionWithTypeVariables() { PatternParser parser = new PatternParser("execution(T Bar.doSomething())"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -538,7 +538,7 @@ public class ParserTestCase extends TestCase { public void testInitializationWithTypeVariables() { PatternParser parser = new PatternParser("initialization(Bar.new())"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -546,7 +546,7 @@ public class ParserTestCase extends TestCase { public void testPreInitializationWithTypeVariables() { PatternParser parser = new PatternParser("preinitialization(Bar.new())"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -554,7 +554,7 @@ public class ParserTestCase extends TestCase { public void testStaticInitializationWithTypeVariables() { PatternParser parser = new PatternParser("staticinitialization(Bar)"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -562,7 +562,7 @@ public class ParserTestCase extends TestCase { public void testWithinWithTypeVariables() { PatternParser parser = new PatternParser("within(Bar)"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -580,7 +580,7 @@ public class ParserTestCase extends TestCase { public void testWithinCodeWithTypeVariables() { PatternParser parser = new PatternParser("withincode(Bar.new())"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("3 type patterns",3,tvs.length); assertEquals("T",tvs[0].getName()); assertEquals("S",tvs[1].getName()); @@ -590,7 +590,7 @@ public class ParserTestCase extends TestCase { public void testCallWithTypeVariables() { PatternParser parser = new PatternParser("call(* Bar.*(..))"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -598,7 +598,7 @@ public class ParserTestCase extends TestCase { public void testGetWithTypeVariables() { PatternParser parser = new PatternParser("get(* Bar.*)"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } @@ -606,7 +606,7 @@ public class ParserTestCase extends TestCase { public void testSetWithTypeVariables() { PatternParser parser = new PatternParser("set(* Bar.*)"); Pointcut pc = parser.parsePointcut(); - TypeVariable[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); + TypeVariablePattern[] tvs = pc.getTypeVariables().getTypeVariablePatterns(); assertEquals("1 type pattern",1,tvs.length); assertEquals("T",tvs[0].getName()); } -- cgit v1.2.3