/* ******************************************************************* | |||||
* 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; | |||||
} | |||||
} |
/* ******************************************************************* | |||||
* 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(); | |||||
} | |||||
} |
/* ******************************************************************* | /* ******************************************************************* | ||||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | |||||
* Copyright (c) 2002, 2010 Palo Alto Research Center, Incorporated (PARC). | |||||
* All rights reserved. | * All rights reserved. | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
* under the terms of the Eclipse Public License v1.0 | * under the terms of the Eclipse Public License v1.0 | ||||
* | * | ||||
* Contributors: | * Contributors: | ||||
* PARC initial implementation | * PARC initial implementation | ||||
* Nieraj Singh | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver.patterns; | package org.aspectj.weaver.patterns; | ||||
public class BindingTypePattern extends ExactTypePattern implements BindingPattern { | public class BindingTypePattern extends ExactTypePattern implements BindingPattern { | ||||
private int formalIndex; | private int formalIndex; | ||||
private String bindingName; | |||||
public BindingTypePattern(UnresolvedType type, int index, boolean isVarArgs) { | public BindingTypePattern(UnresolvedType type, int index, boolean isVarArgs) { | ||||
super(type, false, isVarArgs); | super(type, false, isVarArgs); | ||||
public BindingTypePattern(FormalBinding binding, boolean isVarArgs) { | public BindingTypePattern(FormalBinding binding, boolean isVarArgs) { | ||||
this(binding.getType(), binding.getIndex(), isVarArgs); | this(binding.getType(), binding.getIndex(), isVarArgs); | ||||
this.bindingName = binding.getName(); | |||||
} | } | ||||
public int getFormalIndex() { | public int getFormalIndex() { | ||||
return formalIndex; | return formalIndex; | ||||
} | } | ||||
public String getBindingName() { | |||||
return bindingName; | |||||
} | |||||
public boolean equals(Object other) { | public boolean equals(Object other) { | ||||
if (!(other instanceof BindingTypePattern)) { | if (!(other instanceof BindingTypePattern)) { |
/* ******************************************************************* | |||||
* 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; | |||||
} | |||||
} |
* | * | ||||
* Contributors: | * Contributors: | ||||
* Adrian Colyer Initial implementation | * Adrian Colyer Initial implementation | ||||
* Nieraj Singh | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver.patterns; | package org.aspectj.weaver.patterns; | ||||
return hasMethod(type); | return hasMethod(type); | ||||
} | } | ||||
} | } | ||||
public ISignaturePattern getSignaturePattern() { | |||||
return signaturePattern; | |||||
} | |||||
private final static String declareAtPrefix = "ajc$declare_at"; | private final static String declareAtPrefix = "ajc$declare_at"; | ||||
/* ******************************************************************* | |||||
* 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; | |||||
} | |||||
} |
* under the terms of the Eclipse Public License v1.0 | * under the terms of the Eclipse Public License v1.0 | ||||
* which accompanies this distribution and is available at | * which accompanies this distribution and is available at | ||||
* http://www.eclipse.org/legal/epl-v10.html | * http://www.eclipse.org/legal/epl-v10.html | ||||
* | |||||
* Contributors: | |||||
* Andy Clement | |||||
* Nieraj Singh | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver.patterns; | package org.aspectj.weaver.patterns; | ||||
super(false); | super(false); | ||||
this.category = category; | this.category = category; | ||||
} | } | ||||
public int getTypeCategory() { | |||||
return category; | |||||
} | |||||
@Override | @Override | ||||
protected boolean matchesExactly(ResolvedType type) { | protected boolean matchesExactly(ResolvedType type) { |
/* ******************************************************************* | /* ******************************************************************* | ||||
* Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC). | |||||
* Copyright (c) 2002, 2010 Palo Alto Research Center, Incorporated (PARC). | |||||
* All rights reserved. | * All rights reserved. | ||||
* This program and the accompanying materials are made available | * This program and the accompanying materials are made available | ||||
* under the terms of the Eclipse Public License v1.0 | * under the terms of the Eclipse Public License v1.0 | ||||
* | * | ||||
* Contributors: | * Contributors: | ||||
* PARC initial implementation | * PARC initial implementation | ||||
* Nieraj Singh | |||||
* ******************************************************************/ | * ******************************************************************/ | ||||
package org.aspectj.weaver.patterns; | package org.aspectj.weaver.patterns; | ||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.lang.reflect.Modifier; | |||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import java.util.Map; | import java.util.Map; | ||||
import org.aspectj.bridge.MessageUtil; | import org.aspectj.bridge.MessageUtil; | ||||
import org.aspectj.util.FuzzyBoolean; | import org.aspectj.util.FuzzyBoolean; | ||||
import org.aspectj.weaver.BCException; | import org.aspectj.weaver.BCException; | ||||
import org.aspectj.weaver.CompressingDataOutputStream; | |||||
import org.aspectj.weaver.ISourceContext; | import org.aspectj.weaver.ISourceContext; | ||||
import org.aspectj.weaver.IntMap; | import org.aspectj.weaver.IntMap; | ||||
import org.aspectj.weaver.ResolvedType; | import org.aspectj.weaver.ResolvedType; | ||||
} | } | ||||
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; | |||||
} | |||||
} |