From: aclement Date: Mon, 22 Nov 2010 19:45:03 +0000 (+0000) Subject: https://bugs.eclipse.org/bugs/show_bug.cgi?id=329268 from Nieraj X-Git-Tag: V1_6_11M1~38 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=34959ca9032e8f78923fd66cd0c1a30613c526e7;p=aspectj.git https://bugs.eclipse.org/bugs/show_bug.cgi?id=329268 from Nieraj --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnyTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnyTypePattern.java new file mode 100644 index 000000000..f36855399 --- /dev/null +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnyTypePattern.java @@ -0,0 +1,112 @@ +/* ******************************************************************* + * Copyright (c) 2002, 2010 Palo Alto Research Center, Incorporated (PARC) and others. + * 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation + * ******************************************************************/ +package org.aspectj.weaver.patterns; + +import java.io.IOException; +import java.util.Map; + +import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.World; + +public class AnyTypePattern extends TypePattern { + + /** + * Constructor for EllipsisTypePattern. + * + * @param includeSubtypes + */ + public AnyTypePattern() { + super(false, false, new TypePatternList()); + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) + */ + @Override + protected boolean couldEverMatchSameTypesAs(TypePattern other) { + return true; + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType) + */ + @Override + protected boolean matchesExactly(ResolvedType type) { + return true; + } + + @Override + protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { + return true; + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) + */ + @Override + public FuzzyBoolean matchesInstanceof(ResolvedType type) { + return FuzzyBoolean.YES; + } + + @Override + public void write(CompressingDataOutputStream s) throws IOException { + s.writeByte(ANY_KEY); + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matches(IType, MatchKind) + */ + // public FuzzyBoolean matches(IType type, MatchKind kind) { + // return FuzzyBoolean.YES; + // } + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesSubtypes(IType) + */ + @Override + protected boolean matchesSubtypes(ResolvedType type) { + return true; + } + + @Override + public boolean isStar() { + return true; + } + + @Override + public String toString() { + return "*"; + } + + @Override + public boolean equals(Object obj) { + return (obj instanceof AnyTypePattern); + } + + @Override + public int hashCode() { + return 37; + } + + @Override + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public TypePattern parameterizeWith(Map arg0, World w) { + return this; + } +} \ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnyWithAnnotationTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnyWithAnnotationTypePattern.java new file mode 100644 index 000000000..fa154f38c --- /dev/null +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/AnyWithAnnotationTypePattern.java @@ -0,0 +1,142 @@ +/* ******************************************************************* + * Copyright (c) 2002, 2010 Palo Alto Research Center, Incorporated (PARC) and others. + * 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation + * ******************************************************************/ +package org.aspectj.weaver.patterns; + +import java.io.IOException; +import java.lang.reflect.Modifier; +import java.util.Map; + +import org.aspectj.bridge.MessageUtil; +import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.ISourceContext; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.VersionedDataInputStream; +import org.aspectj.weaver.WeaverMessages; +import org.aspectj.weaver.World; + + +/** + * This type represents a type pattern of '*' but with an annotation specified, e.g. '@Color *' + */ +public class AnyWithAnnotationTypePattern extends TypePattern { + + public AnyWithAnnotationTypePattern(AnnotationTypePattern atp) { + super(false, false); + annotationPattern = atp; + } + + @Override + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + protected boolean couldEverMatchSameTypesAs(TypePattern other) { + return true; + } + + @Override + protected boolean matchesExactly(ResolvedType type) { + annotationPattern.resolve(type.getWorld()); + boolean b = false; + if (type.temporaryAnnotationTypes != null) { + b = annotationPattern.matches(type, type.temporaryAnnotationTypes).alwaysTrue(); + } else { + b = annotationPattern.matches(type).alwaysTrue(); + } + return b; + } + + @Override + public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) { + if (requireExactType) { + scope.getWorld().getMessageHandler().handleMessage( + MessageUtil.error(WeaverMessages.format(WeaverMessages.WILDCARD_NOT_ALLOWED), getSourceLocation())); + return NO; + } + return super.resolveBindings(scope, bindings, allowBinding, requireExactType); + } + + @Override + protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { + annotationPattern.resolve(type.getWorld()); + return annotationPattern.matches(annotatedType).alwaysTrue(); + } + + @Override + public FuzzyBoolean matchesInstanceof(ResolvedType type) { + if (Modifier.isFinal(type.getModifiers())) { + return FuzzyBoolean.fromBoolean(matchesExactly(type)); + } + return FuzzyBoolean.MAYBE; + } + + @Override + public TypePattern parameterizeWith(Map typeVariableMap, World w) { + AnyWithAnnotationTypePattern ret = new AnyWithAnnotationTypePattern(this.annotationPattern.parameterizeWith( + typeVariableMap, w)); + ret.copyLocationFrom(this); + return ret; + } + + @Override + public void write(CompressingDataOutputStream s) throws IOException { + s.writeByte(TypePattern.ANY_WITH_ANNO); + annotationPattern.write(s); + writeLocation(s); + } + + public static TypePattern read(VersionedDataInputStream s, ISourceContext c) throws IOException { + AnnotationTypePattern annPatt = AnnotationTypePattern.read(s, c); + AnyWithAnnotationTypePattern ret = new AnyWithAnnotationTypePattern(annPatt); + ret.readLocation(c, s); + return ret; + } + + // public FuzzyBoolean matches(IType type, MatchKind kind) { + // return FuzzyBoolean.YES; + // } + + @Override + protected boolean matchesSubtypes(ResolvedType type) { + return true; + } + + @Override + public boolean isStar() { + return false; + } + + @Override + public String toString() { + return "(" + annotationPattern + " *)"; + } + + public AnnotationTypePattern getAnnotationTypePattern() { + return annotationPattern; + } + + @Override + public boolean equals(Object obj) { + if (!(obj instanceof AnyWithAnnotationTypePattern)) { + return false; + } + AnyWithAnnotationTypePattern awatp = (AnyWithAnnotationTypePattern) obj; + return (annotationPattern.equals(awatp.annotationPattern)); + } + + @Override + public int hashCode() { + return annotationPattern.hashCode(); + } +} diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java index c24e779be..c0d5434ef 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/BindingTypePattern.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * Copyright (c) 2002, 2010 Palo Alto Research Center, Incorporated (PARC). * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 @@ -8,6 +8,7 @@ * * Contributors: * PARC initial implementation + * Nieraj Singh * ******************************************************************/ package org.aspectj.weaver.patterns; @@ -25,6 +26,7 @@ import org.aspectj.weaver.World; public class BindingTypePattern extends ExactTypePattern implements BindingPattern { private int formalIndex; + private String bindingName; public BindingTypePattern(UnresolvedType type, int index, boolean isVarArgs) { super(type, false, isVarArgs); @@ -33,11 +35,16 @@ public class BindingTypePattern extends ExactTypePattern implements BindingPatte public BindingTypePattern(FormalBinding binding, boolean isVarArgs) { this(binding.getType(), binding.getIndex(), isVarArgs); + this.bindingName = binding.getName(); } public int getFormalIndex() { return formalIndex; } + + public String getBindingName() { + return bindingName; + } public boolean equals(Object other) { if (!(other instanceof BindingTypePattern)) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/EllipsisTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/EllipsisTypePattern.java new file mode 100644 index 000000000..2abc51327 --- /dev/null +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/EllipsisTypePattern.java @@ -0,0 +1,109 @@ +/* ******************************************************************* + * Copyright (c) 2002, 2010 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation + * ******************************************************************/ +package org.aspectj.weaver.patterns; + +import java.io.IOException; +import java.util.Map; + +import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.World; + +public class EllipsisTypePattern extends TypePattern { + + /** + * Constructor for EllipsisTypePattern. + * + * @param includeSubtypes + */ + public EllipsisTypePattern() { + super(false, false, new TypePatternList()); + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) + */ + @Override + protected boolean couldEverMatchSameTypesAs(TypePattern other) { + return true; + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType) + */ + @Override + protected boolean matchesExactly(ResolvedType type) { + return false; + } + + @Override + protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { + return false; + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) + */ + @Override + public FuzzyBoolean matchesInstanceof(ResolvedType type) { + return FuzzyBoolean.NO; + } + + @Override + public void write(CompressingDataOutputStream s) throws IOException { + s.writeByte(ELLIPSIS_KEY); + } + + @Override + public boolean isEllipsis() { + return true; + } + + @Override + public String toString() { + return ".."; + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + return (obj instanceof EllipsisTypePattern); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return 17 * 37; + } + + @Override + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public TypePattern parameterizeWith(Map typeVariableMap, World w) { + return this; + } + +} \ No newline at end of file diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java index c0715c857..43a7582af 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/HasMemberTypePattern.java @@ -8,6 +8,7 @@ * * Contributors: * Adrian Colyer Initial implementation + * Nieraj Singh * ******************************************************************/ package org.aspectj.weaver.patterns; @@ -49,6 +50,10 @@ public class HasMemberTypePattern extends TypePattern { return hasMethod(type); } } + + public ISignaturePattern getSignaturePattern() { + return signaturePattern; + } private final static String declareAtPrefix = "ajc$declare_at"; diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NoTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NoTypePattern.java new file mode 100644 index 000000000..26dacba0b --- /dev/null +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NoTypePattern.java @@ -0,0 +1,117 @@ +/* ******************************************************************* + * Copyright (c) 2002, 2010 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://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * PARC initial implementation + * ******************************************************************/ +package org.aspectj.weaver.patterns; + +import java.io.IOException; +import java.util.Map; + +import org.aspectj.util.FuzzyBoolean; +import org.aspectj.weaver.CompressingDataOutputStream; +import org.aspectj.weaver.ResolvedType; +import org.aspectj.weaver.World; + +public class NoTypePattern extends TypePattern { + + public NoTypePattern() { + super(false, false, new TypePatternList()); + } + + /* + * (non-Javadoc) + * + * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) + */ + @Override + protected boolean couldEverMatchSameTypesAs(TypePattern other) { + return false; + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType) + */ + @Override + protected boolean matchesExactly(ResolvedType type) { + return false; + } + + @Override + protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { + return false; + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) + */ + @Override + public FuzzyBoolean matchesInstanceof(ResolvedType type) { + return FuzzyBoolean.NO; + } + + @Override + public void write(CompressingDataOutputStream s) throws IOException { + s.writeByte(NO_KEY); + } + + /** + * @see org.aspectj.weaver.patterns.TypePattern#matches(IType, MatchKind) + */ + // public FuzzyBoolean matches(IType type, MatchKind kind) { + // return FuzzyBoolean.YES; + // } + /** + * @see org.aspectj.weaver.patterns.TypePattern#matchesSubtypes(IType) + */ + @Override + protected boolean matchesSubtypes(ResolvedType type) { + return false; + } + + @Override + public boolean isStar() { + return false; + } + + @Override + public String toString() { + return ""; + }// FIXME AV - bad! toString() cannot be parsed back (not idempotent) + + /* + * (non-Javadoc) + * + * @see java.lang.Object#equals(java.lang.Object) + */ + @Override + public boolean equals(Object obj) { + return (obj instanceof NoTypePattern); + } + + /* + * (non-Javadoc) + * + * @see java.lang.Object#hashCode() + */ + @Override + public int hashCode() { + return 17 * 37 * 37; + } + + @Override + public Object accept(PatternNodeVisitor visitor, Object data) { + return visitor.visit(this, data); + } + + @Override + public TypePattern parameterizeWith(Map arg0, World w) { + return this; + } +} diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java index beffd131e..3e0934fe8 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypeCategoryTypePattern.java @@ -5,6 +5,10 @@ * under the terms of the Eclipse Public License v1.0 * which accompanies this distribution and is available at * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Andy Clement + * Nieraj Singh * ******************************************************************/ package org.aspectj.weaver.patterns; @@ -44,6 +48,10 @@ public class TypeCategoryTypePattern extends TypePattern { super(false); this.category = category; } + + public int getTypeCategory() { + return category; + } @Override protected boolean matchesExactly(ResolvedType type) { diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java index 023a259de..9e091301a 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/TypePattern.java @@ -1,5 +1,5 @@ /* ******************************************************************* - * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). + * Copyright (c) 2002, 2010 Palo Alto Research Center, Incorporated (PARC). * All rights reserved. * This program and the accompanying materials are made available * under the terms of the Eclipse Public License v1.0 @@ -8,19 +8,18 @@ * * Contributors: * PARC initial implementation + * Nieraj Singh * ******************************************************************/ package org.aspectj.weaver.patterns; import java.io.IOException; -import java.lang.reflect.Modifier; import java.util.Iterator; import java.util.Map; import org.aspectj.bridge.MessageUtil; import org.aspectj.util.FuzzyBoolean; import org.aspectj.weaver.BCException; -import org.aspectj.weaver.CompressingDataOutputStream; import org.aspectj.weaver.ISourceContext; import org.aspectj.weaver.IntMap; import org.aspectj.weaver.ResolvedType; @@ -357,392 +356,5 @@ public abstract class TypePattern extends PatternNode { } -class EllipsisTypePattern extends TypePattern { - /** - * Constructor for EllipsisTypePattern. - * - * @param includeSubtypes - */ - public EllipsisTypePattern() { - super(false, false, new TypePatternList()); - } - - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) - */ - @Override - protected boolean couldEverMatchSameTypesAs(TypePattern other) { - return true; - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType) - */ - @Override - protected boolean matchesExactly(ResolvedType type) { - return false; - } - - @Override - protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { - return false; - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) - */ - @Override - public FuzzyBoolean matchesInstanceof(ResolvedType type) { - return FuzzyBoolean.NO; - } - - @Override - public void write(CompressingDataOutputStream s) throws IOException { - s.writeByte(ELLIPSIS_KEY); - } - - @Override - public boolean isEllipsis() { - return true; - } - - @Override - public String toString() { - return ".."; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return (obj instanceof EllipsisTypePattern); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return 17 * 37; - } - - @Override - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - @Override - public TypePattern parameterizeWith(Map typeVariableMap, World w) { - return this; - } - -} - -class AnyTypePattern extends TypePattern { - - /** - * Constructor for EllipsisTypePattern. - * - * @param includeSubtypes - */ - public AnyTypePattern() { - super(false, false, new TypePatternList()); - } - - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) - */ - @Override - protected boolean couldEverMatchSameTypesAs(TypePattern other) { - return true; - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType) - */ - @Override - protected boolean matchesExactly(ResolvedType type) { - return true; - } - - @Override - protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { - return true; - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) - */ - @Override - public FuzzyBoolean matchesInstanceof(ResolvedType type) { - return FuzzyBoolean.YES; - } - - @Override - public void write(CompressingDataOutputStream s) throws IOException { - s.writeByte(ANY_KEY); - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matches(IType, MatchKind) - */ - // public FuzzyBoolean matches(IType type, MatchKind kind) { - // return FuzzyBoolean.YES; - // } - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesSubtypes(IType) - */ - @Override - protected boolean matchesSubtypes(ResolvedType type) { - return true; - } - - @Override - public boolean isStar() { - return true; - } - - @Override - public String toString() { - return "*"; - } - - @Override - public boolean equals(Object obj) { - return (obj instanceof AnyTypePattern); - } - - @Override - public int hashCode() { - return 37; - } - - @Override - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - @Override - public TypePattern parameterizeWith(Map arg0, World w) { - return this; - } -} - -/** - * This type represents a type pattern of '*' but with an annotation specified, e.g. '@Color *' - */ -class AnyWithAnnotationTypePattern extends TypePattern { - - public AnyWithAnnotationTypePattern(AnnotationTypePattern atp) { - super(false, false); - annotationPattern = atp; - } - - @Override - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - @Override - protected boolean couldEverMatchSameTypesAs(TypePattern other) { - return true; - } - - @Override - protected boolean matchesExactly(ResolvedType type) { - annotationPattern.resolve(type.getWorld()); - boolean b = false; - if (type.temporaryAnnotationTypes != null) { - b = annotationPattern.matches(type, type.temporaryAnnotationTypes).alwaysTrue(); - } else { - b = annotationPattern.matches(type).alwaysTrue(); - } - return b; - } - - @Override - public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) { - if (requireExactType) { - scope.getWorld().getMessageHandler().handleMessage( - MessageUtil.error(WeaverMessages.format(WeaverMessages.WILDCARD_NOT_ALLOWED), getSourceLocation())); - return NO; - } - return super.resolveBindings(scope, bindings, allowBinding, requireExactType); - } - - @Override - protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { - annotationPattern.resolve(type.getWorld()); - return annotationPattern.matches(annotatedType).alwaysTrue(); - } - - @Override - public FuzzyBoolean matchesInstanceof(ResolvedType type) { - if (Modifier.isFinal(type.getModifiers())) { - return FuzzyBoolean.fromBoolean(matchesExactly(type)); - } - return FuzzyBoolean.MAYBE; - } - - @Override - public TypePattern parameterizeWith(Map typeVariableMap, World w) { - AnyWithAnnotationTypePattern ret = new AnyWithAnnotationTypePattern(this.annotationPattern.parameterizeWith( - typeVariableMap, w)); - ret.copyLocationFrom(this); - return ret; - } - - @Override - public void write(CompressingDataOutputStream s) throws IOException { - s.writeByte(TypePattern.ANY_WITH_ANNO); - annotationPattern.write(s); - writeLocation(s); - } - public static TypePattern read(VersionedDataInputStream s, ISourceContext c) throws IOException { - AnnotationTypePattern annPatt = AnnotationTypePattern.read(s, c); - AnyWithAnnotationTypePattern ret = new AnyWithAnnotationTypePattern(annPatt); - ret.readLocation(c, s); - return ret; - } - - // public FuzzyBoolean matches(IType type, MatchKind kind) { - // return FuzzyBoolean.YES; - // } - - @Override - protected boolean matchesSubtypes(ResolvedType type) { - return true; - } - - @Override - public boolean isStar() { - return false; - } - - @Override - public String toString() { - return "(" + annotationPattern + " *)"; - } - - @Override - public boolean equals(Object obj) { - if (!(obj instanceof AnyWithAnnotationTypePattern)) { - return false; - } - AnyWithAnnotationTypePattern awatp = (AnyWithAnnotationTypePattern) obj; - return (annotationPattern.equals(awatp.annotationPattern)); - } - - @Override - public int hashCode() { - return annotationPattern.hashCode(); - } -} - -class NoTypePattern extends TypePattern { - - public NoTypePattern() { - super(false, false, new TypePatternList()); - } - - /* - * (non-Javadoc) - * - * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern) - */ - @Override - protected boolean couldEverMatchSameTypesAs(TypePattern other) { - return false; - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesExactly(IType) - */ - @Override - protected boolean matchesExactly(ResolvedType type) { - return false; - } - - @Override - protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) { - return false; - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesInstanceof(IType) - */ - @Override - public FuzzyBoolean matchesInstanceof(ResolvedType type) { - return FuzzyBoolean.NO; - } - - @Override - public void write(CompressingDataOutputStream s) throws IOException { - s.writeByte(NO_KEY); - } - - /** - * @see org.aspectj.weaver.patterns.TypePattern#matches(IType, MatchKind) - */ - // public FuzzyBoolean matches(IType type, MatchKind kind) { - // return FuzzyBoolean.YES; - // } - /** - * @see org.aspectj.weaver.patterns.TypePattern#matchesSubtypes(IType) - */ - @Override - protected boolean matchesSubtypes(ResolvedType type) { - return false; - } - - @Override - public boolean isStar() { - return false; - } - - @Override - public String toString() { - return ""; - }// FIXME AV - bad! toString() cannot be parsed back (not idempotent) - - /* - * (non-Javadoc) - * - * @see java.lang.Object#equals(java.lang.Object) - */ - @Override - public boolean equals(Object obj) { - return (obj instanceof NoTypePattern); - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#hashCode() - */ - @Override - public int hashCode() { - return 17 * 37 * 37; - } - - @Override - public Object accept(PatternNodeVisitor visitor, Object data) { - return visitor.visit(this, data); - } - - @Override - public TypePattern parameterizeWith(Map arg0, World w) { - return this; - } -}