@@ -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; | |||
} | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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)) { |
@@ -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; | |||
} | |||
} |
@@ -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"; | |||
@@ -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 "<nothing>"; | |||
}// 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; | |||
} | |||
} |
@@ -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) { |
@@ -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 "<nothing>"; | |||
}// 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; | |||
} | |||
} |