IBinaryTypeAnnotation otherAnnotation = wrapper.annotation; int[] typePath = this.annotation.getTypePath(); int[] otherTypePath = otherAnnotation.getTypePath(); if (this.annotation.getTargetType() != otherAnnotation.getTargetType()) { return false; if (this.annotation.getBoundIndex() != otherAnnotation.getBoundIndex()) { return false; if (this.annotation.getMethodFormalParameterIndex() != otherAnnotation.getMethodFormalParameterIndex()) { return false; if (this.annotation.getSupertypeIndex() != otherAnnotation.getSupertypeIndex()) { return false; if (this.annotation.getThrowsTypeIndex() != otherAnnotation.getThrowsTypeIndex()) { return false; if (this.annotation.getTypeParameterIndex() != otherAnnotation.getTypeParameterIndex()) { return false; return IndexTester.isEqual(this.annotation.getAnnotation(), otherAnnotation.getAnnotation());
@Override public int hashCode() { int hashCode; int[] typePath = this.annotation.getTypePath(); hashCode = Arrays.hashCode(typePath); hashCode = hashCode * 31 + this.annotation.getTargetType(); hashCode = hashCode * 31 + this.annotation.getTypeParameterIndex(); return hashCode; }
@Override public IBinaryAnnotation[] getAnnotationsAtCursor(int currentTypeId) { int length = this.typeAnnotations.length; IBinaryAnnotation[] filtered = new IBinaryAnnotation[length]; long ptr = 1; int count = 0; for (int i = 0; i < length; i++, ptr<<=1) { if ((this.matches & ptr) == 0) continue; IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTypePath().length > this.pathPtr) continue; filtered[count++] = candidate.getAnnotation(); } if (count == 0) return NO_ANNOTATIONS; if (count < length) System.arraycopy(filtered, 0, filtered = new IBinaryAnnotation[count], 0, count); return filtered; } }
@Override public ITypeAnnotationWalker toTypeParameterBounds(boolean isClassTypeParameter, int parameterRank) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; int targetType = isClassTypeParameter ? AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER_BOUND : AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER_BOUND; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != targetType || (short)candidate.getTypeParameterIndex() != parameterRank) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
public static String annotationToString(IBinaryTypeAnnotation typeAnnotation) { StringBuffer buffer = new StringBuffer(); buffer.append(typeAnnotation.getAnnotation()); buffer.append(' '); buffer.append("target_type=").append(typeAnnotation.getTargetType()); //$NON-NLS-1$ buffer.append(", info=").append(typeAnnotation.getSupertypeIndex()); //$NON-NLS-1$ buffer.append(", info2=").append(typeAnnotation.getBoundIndex()); //$NON-NLS-1$ int[] theTypePath = typeAnnotation.getTypePath(); if (theTypePath != null && theTypePath.length != 0) { buffer.append(", location=["); //$NON-NLS-1$
@Override public ITypeAnnotationWalker toMethodParameter(short index) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != AnnotationTargetTypeConstants.METHOD_FORMAL_PARAMETER || (short)candidate.getMethodFormalParameterIndex() != index) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
/** Walk to the specified supertype: -1 is superclass, else the superinterface at the given index. */ public TypeAnnotationWalker toSupertype(short index) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != AnnotationTargetTypeConstants.CLASS_EXTENDS || (short)candidate.getSupertypeIndex() != index) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
@Override public ITypeAnnotationWalker toThrows(int index) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != AnnotationTargetTypeConstants.THROWS || candidate.getThrowsTypeIndex() != index) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
private boolean affectsSignature(IBinaryTypeAnnotation typeAnnotation) { if (typeAnnotation == null) return false; int targetType = typeAnnotation.getTargetType(); if (targetType >= AnnotationTargetTypeConstants.LOCAL_VARIABLE && targetType <= AnnotationTargetTypeConstants.METHOD_REFERENCE_TYPE_ARGUMENT) return false; // affects detail within a block return true; }
protected TypeAnnotationWalker toNextDetail(int detailKind) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; int[] path = candidate.getTypePath(); if (this.pathPtr >= path.length || path[this.pathPtr] != detailKind) { newMatches &= ~mask; } } return restrict(newMatches, this.pathPtr+2); }
@Override public ITypeAnnotationWalker toTypeBound(short boundIndex) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if ((short)candidate.getBoundIndex() != boundIndex) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
private void updateTypeAnnotations(IBinaryTypeAnnotation[] typeAnnotations) { if (typeAnnotations != null) { for (IBinaryTypeAnnotation typeAnnotation : typeAnnotations) { if (!affectsSignature(typeAnnotation)) { continue; } updateAnnotation(typeAnnotation.getAnnotation()); } } }
@Override public ITypeAnnotationWalker toTypeParameter(boolean isClassTypeParameter, int rank) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int targetType = isClassTypeParameter ? AnnotationTargetTypeConstants.CLASS_TYPE_PARAMETER : AnnotationTargetTypeConstants.METHOD_TYPE_PARAMETER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != targetType || candidate.getTypeParameterIndex() != rank) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
public static String annotationToString(IBinaryTypeAnnotation typeAnnotation) { StringBuffer buffer = new StringBuffer(); buffer.append(typeAnnotation.getAnnotation()); buffer.append(' '); buffer.append("target_type=").append(typeAnnotation.getTargetType()); //$NON-NLS-1$ buffer.append(", info=").append(typeAnnotation.getSupertypeIndex()); //$NON-NLS-1$ buffer.append(", info2=").append(typeAnnotation.getBoundIndex()); //$NON-NLS-1$ int[] theTypePath = typeAnnotation.getTypePath(); if (theTypePath != null && theTypePath.length != 0) { buffer.append(", location=["); //$NON-NLS-1$
/** Walk to the index'th visible formal method parameter (i.e., not counting synthetic args). */ public TypeAnnotationWalker toMethodParameter(short index) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != AnnotationTargetTypeConstants.METHOD_FORMAL_PARAMETER || (short)candidate.getMethodFormalParameterIndex() != index) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
/** Walk to the specified supertype: -1 is superclass, else the superinterface at the given index. */ public TypeAnnotationWalker toSupertype(short index) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != AnnotationTargetTypeConstants.CLASS_EXTENDS || (short)candidate.getSupertypeIndex() != index) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
@Override public ITypeAnnotationWalker toThrows(int index) { long newMatches = this.matches; if (newMatches == 0) return EMPTY_ANNOTATION_WALKER; int length = this.typeAnnotations.length; long mask = 1; for (int i = 0; i < length; i++, mask = mask << 1) { IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTargetType() != AnnotationTargetTypeConstants.THROWS || candidate.getThrowsTypeIndex() != index) { newMatches &= ~mask; } } return restrict(newMatches, 0); }
@Override public IBinaryAnnotation[] getAnnotationsAtCursor(int currentTypeId) { int length = this.typeAnnotations.length; IBinaryAnnotation[] filtered = new IBinaryAnnotation[length]; long ptr = 1; int count = 0; for (int i = 0; i < length; i++, ptr<<=1) { if ((this.matches & ptr) == 0) continue; IBinaryTypeAnnotation candidate = this.typeAnnotations[i]; if (candidate.getTypePath().length > this.pathPtr) continue; filtered[count++] = candidate.getAnnotation(); } if (count == 0) return NO_ANNOTATIONS; if (count < length) System.arraycopy(filtered, 0, filtered = new IBinaryAnnotation[count], 0, count); return filtered; } }
@Override public int hashCode() { int hashCode; int[] typePath = this.annotation.getTypePath(); hashCode = Arrays.hashCode(typePath); hashCode = hashCode * 31 + this.annotation.getTargetType(); hashCode = hashCode * 31 + this.annotation.getTypeParameterIndex(); return hashCode; }
private boolean affectsSignature(IBinaryTypeAnnotation typeAnnotation) { if (typeAnnotation == null) return false; int targetType = typeAnnotation.getTargetType(); if (targetType >= AnnotationTargetTypeConstants.LOCAL_VARIABLE && targetType <= AnnotationTargetTypeConstants.METHOD_REFERENCE_TYPE_ARGUMENT) return false; // affects detail within a block return true; }