protected ITypeAnnotationWalker restrict(long newMatches, int newPathPtr) { if (this.matches == newMatches && this.pathPtr == newPathPtr) return this; if (newMatches == 0 || this.typeAnnotations == null || this.typeAnnotations.length == 0) return EMPTY_ANNOTATION_WALKER; return new TypeAnnotationWalker(this.typeAnnotations, newMatches, newPathPtr); }
@Override public IBinaryAnnotation[] getAnnotationsAtCursor() { IBinaryAnnotation[] normalAnnotations = this.isEmpty ? null : super.getAnnotationsAtCursor(); if (this.atDefaultLocation) { if (normalAnnotations == null || normalAnnotations.length == 0) return new IBinaryAnnotation[] { this.nonNullAnnotation }; int len = normalAnnotations.length; IBinaryAnnotation[] newAnnots = new IBinaryAnnotation[len+1]; System.arraycopy(normalAnnotations, 0, newAnnots, 0, len); newAnnots[len] = this.nonNullAnnotation; return newAnnots; } return normalAnnotations; } }
/** * Descend down one level of array dimensions. */ public TypeAnnotationWalker toNextArrayDimension() { return toNextDetail(AnnotationTargetTypeConstants.NEXT_ARRAY_DIMENSION); }
parameters[i - startIndex] = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames, walker.toMethodParameter(visibleIdx++)); exceptions = new ReferenceBinding[size]; for (int i = 0; i < size; i++) exceptions[i] = this.environment.getTypeFromConstantPoolName(exceptionTypes[i], 0, -1, false, missingTypeNames, walker.toThrows(i)); returnType = this.environment.getTypeFromSignature(methodDescriptor, index + 1, -1, false, this, missingTypeNames, walker.toMethodReturn()); // index is currently pointing at the ')' short rank = 0; while (wrapper.signature[wrapper.start] != Util.C_PARAM_END) types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, walker.toMethodParameter(rank++))); returnType = this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, walker.toMethodReturn()); walker.toThrows(excRank++))); } while (!wrapper.atEnd() && wrapper.signature[wrapper.start] == Util.C_EXCEPTION_START); exceptions = new ReferenceBinding[types.size()]; exceptions = new ReferenceBinding[size]; for (int i = 0; i < size; i++) exceptions[i] = this.environment.getTypeFromConstantPoolName(exceptionTypes[i], 0, -1, false, missingTypeNames, walker.toThrows(i)); IBinaryAnnotation[] receiverAnnotations = walker.toReceiver().getAnnotationsAtCursor(); if (receiverAnnotations != null && receiverAnnotations.length > 0) { result.receiver = this.environment.createAnnotatedType(this, createAnnotations(receiverAnnotations, this.environment, missingTypeNames)); if (annotations == null || annotations.length == 0) if (method.isConstructor()) annotations = walker.toMethodReturn().getAnnotationsAtCursor(); // FIXME: When both exist, order could become an issue.
protected ITypeAnnotationWalker toTarget(int targetType) { 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) { if (this.typeAnnotations[i].getTargetType() != targetType) newMatches &= ~mask; } return restrict(newMatches, 0); }
/** * Walk to the receiver type of a method. * Note: Type annotations on receiver are not currently used by the compiler. */ public TypeAnnotationWalker toReceiver() { return toTarget(AnnotationTargetTypeConstants.METHOD_RECEIVER); }
@Override public TypeAnnotationWalker toTypeArgument(int rank) { this.nextIsDefaultLocation = (this.defaultNullness & Binding.DefaultLocationTypeArgument) != 0; if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toTypeArgument(rank); }
@Override public ITypeAnnotationWalker toField() { // don't set nextIsDefaultLocation, because field-level nullness is handled by BinaryTypeBinding.scanFieldForNullAnnotation if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toField(); }
@Override public ITypeAnnotationWalker toSupertype(short index, char[] superTypeSignature) { if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toSupertype(index, superTypeSignature); }
@Override public ITypeAnnotationWalker toMethodReturn() { // don't set nextIsDefaultLocation, because signature-level nullness is handled by ImplicitNullAnnotationVerifier (triggered per invocation via MessageSend.resolveType() et al) if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toMethodReturn(); }
@Override public ITypeAnnotationWalker toMethodParameter(short index) { // don't set nextIsDefaultLocation, because signature-level nullness is handled by ImplicitNullAnnotationVerifier (triggered per invocation via MessageSend.resolveType() et al) if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toMethodParameter(index); }
parameters[i - startIndex] = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames, walker.toMethodParameter(visibleIdx++)); exceptions = new ReferenceBinding[size]; for (int i = 0; i < size; i++) exceptions[i] = this.environment.getTypeFromConstantPoolName(exceptionTypes[i], 0, -1, false, missingTypeNames, walker.toThrows(i)); returnType = this.environment.getTypeFromSignature(methodDescriptor, index + 1, -1, false, this, missingTypeNames, walker.toMethodReturn()); // index is currently pointing at the ')' short rank = 0; while (wrapper.signature[wrapper.start] != Util.C_PARAM_END) types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, walker.toMethodParameter(rank++))); returnType = this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, walker.toMethodReturn()); walker.toThrows(excRank++))); } while (!wrapper.atEnd() && wrapper.signature[wrapper.start] == Util.C_EXCEPTION_START); exceptions = new ReferenceBinding[types.size()]; exceptions = new ReferenceBinding[size]; for (int i = 0; i < size; i++) exceptions[i] = this.environment.getTypeFromConstantPoolName(exceptionTypes[i], 0, -1, false, missingTypeNames, walker.toThrows(i)); IBinaryAnnotation[] receiverAnnotations = walker.toReceiver().getAnnotationsAtCursor(); if (receiverAnnotations != null && receiverAnnotations.length > 0) { result.receiver = this.environment.createAnnotatedType(this, createAnnotations(receiverAnnotations, this.environment, missingTypeNames)); if (annotations == null || annotations.length == 0) if (method.isConstructor()) annotations = walker.toMethodReturn().getAnnotationsAtCursor(); // FIXME: When both exist, order could become an issue.
protected ITypeAnnotationWalker toTarget(int targetType) { 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) { if (this.typeAnnotations[i].getTargetType() != targetType) newMatches &= ~mask; } return restrict(newMatches, 0); }
/** * Walk to the receiver type of a method. * Note: Type annotations on receiver are not currently used by the compiler. */ public TypeAnnotationWalker toReceiver() { return toTarget(AnnotationTargetTypeConstants.METHOD_RECEIVER); }
@Override public ITypeAnnotationWalker toTypeArgument(int rank) { this.nextIsDefaultLocation = (this.defaultNullness & Binding.DefaultLocationTypeArgument) != 0; this.nextIsTypeBound = false; this.nextArrayContentIsNonNull = false; if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toTypeArgument(rank); }
@Override public ITypeAnnotationWalker toField() { // don't set nextIsDefaultLocation, because field-level nullness is handled by BinaryTypeBinding.scanFieldForNullAnnotation if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toField(); }
@Override public ITypeAnnotationWalker toSupertype(short index, char[] superTypeSignature) { if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toSupertype(index, superTypeSignature); }
@Override public ITypeAnnotationWalker toMethodReturn() { // don't set nextIsDefaultLocation, because signature-level nullness is handled by ImplicitNullAnnotationVerifier (triggered per invocation via MessageSend.resolveType() et al) if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toMethodReturn(); }
@Override public TypeAnnotationWalker toMethodParameter(short index) { // don't set nextIsDefaultLocation, because signature-level nullness is handled by ImplicitNullAnnotationVerifier if (this.isEmpty) return restrict(this.matches, this.pathPtr); return super.toMethodParameter(index); }
parameters[i - startIndex] = this.environment.getTypeFromSignature(methodDescriptor, index, end, false, this, missingTypeNames, walker.toMethodParameter(visibleIdx++)); exceptions = new ReferenceBinding[size]; for (int i = 0; i < size; i++) exceptions[i] = this.environment.getTypeFromConstantPoolName(exceptionTypes[i], 0, -1, false, missingTypeNames, walker.toThrows(i)); returnType = this.environment.getTypeFromSignature(methodDescriptor, index + 1, -1, false, this, missingTypeNames, walker.toMethodReturn()); // index is currently pointing at the ')' short rank = 0; while (wrapper.signature[wrapper.start] != Util.C_PARAM_END) types.add(this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, walker.toMethodParameter(rank++))); returnType = this.environment.getTypeFromTypeSignature(wrapper, typeVars, this, missingTypeNames, walker.toMethodReturn()); walker.toThrows(excRank++))); } while (!wrapper.atEnd() && wrapper.signature[wrapper.start] == Util.C_EXCEPTION_START); exceptions = new ReferenceBinding[types.size()]; exceptions = new ReferenceBinding[size]; for (int i = 0; i < size; i++) exceptions[i] = this.environment.getTypeFromConstantPoolName(exceptionTypes[i], 0, -1, false, missingTypeNames, walker.toThrows(i)); IBinaryAnnotation[] receiverAnnotations = walker.toReceiver().getAnnotationsAtCursor(); if (receiverAnnotations != null && receiverAnnotations.length > 0) { result.receiver = this.environment.createAnnotatedType(this, createAnnotations(receiverAnnotations, this.environment, missingTypeNames)); if (annotations == null || annotations.length == 0) if (method.isConstructor()) annotations = walker.toMethodReturn().getAnnotationsAtCursor(); // FIXME: When both exist, order could become an issue.