public void nullDefaultAnnotationIsRedundant(ASTNode location, Annotation[] annotations, Binding outer) { Annotation annotation = findAnnotation(annotations, TypeIds.BitNonNullByDefaultAnnotation); int start = annotation != null ? annotation.sourceStart : location.sourceStart; int end = annotation != null ? annotation.sourceEnd : location.sourceStart; String[] args = NoArgument; String[] shortArgs = NoArgument; if (outer != null) { args = new String[] { new String(outer.readableName()) }; shortArgs = new String[] { new String(outer.shortReadableName()) }; } int problemId = IProblem.RedundantNullDefaultAnnotation; if (outer instanceof PackageBinding) { problemId = IProblem.RedundantNullDefaultAnnotationPackage; } else if (outer instanceof ReferenceBinding) { problemId = IProblem.RedundantNullDefaultAnnotationType; } else if (outer instanceof MethodBinding) { problemId = IProblem.RedundantNullDefaultAnnotationMethod; } this.handle(problemId, args, shortArgs, start, end); }
private void internalResolve(Scope scope, boolean staticContext) { // detect variable/type name collisions if (this.binding != null) { Binding existingType = scope.parent.getBinding(this.name, Binding.TYPE, this, false/*do not resolve hidden field*/); if (existingType != null && this.binding != existingType && existingType.isValidBinding() && (existingType.kind() != Binding.TYPE_PARAMETER || !staticContext)) { scope.problemReporter().typeHiding(this, existingType); } } }
@Override public boolean isDeprecated(Element e) { if (!(e instanceof ElementImpl)) { return false; } return (((ElementImpl)e)._binding.getAnnotationTagBits() & TagBits.AnnotationDeprecated) != 0; }
switch (recipient.kind()) { case Binding.LOCAL: recipientTargetMask = recipient.isParameter() ? TagBits.AnnotationForParameter : TagBits.AnnotationForLocalVariable; break; case Binding.FIELD: return; switch (recipient.kind()) { case Binding.LOCAL: LocalVariableBinding local = (LocalVariableBinding) recipient; AnnotationBinding [] recipientAnnotations = recipient.getAnnotations(); int length = recipientAnnotations == null ? 0 : recipientAnnotations.length; int newLength = 0; recipient.setAnnotations(recipientAnnotations, scope);
if (left != null && !left.isVolatile() && left == getDirectBinding(this.expression)) { scope.problemReporter().assignmentHasNoEffect(this, left.shortReadableName());
public char[] shortReadableName(){ return readableName(); } public AnnotationBinding[] getAnnotations() {
protected TypeBinding getTypeBinding(Scope scope) { // it can be a package, type or member type Binding binding = scope.parent.getTypeOrPackage(this.tokens); // step up from the ClassScope if (!binding.isValidBinding()) { scope.problemReporter().invalidType(this, (TypeBinding) binding); if (binding.problemId() == ProblemReasons.NotFound) { throw new CompletionNodeFound(this, binding, scope); } throw new CompletionNodeFound(); } throw new CompletionNodeFound(this, binding, scope); } public boolean isClass(){
public static boolean isAnnotationTargetAllowed(BlockScope scope, TypeBinding annotationType, Binding recipient) { long metaTagBits = annotationType.getAnnotationTagBits(); // could be forward reference if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) { return true; } return isAnnotationTargetAllowed(recipient, scope, annotationType, recipient.kind(), metaTagBits)==AnnotationTargetAllowed.YES; }
@Override public JavaElement resolved(Binding binding) { SourceRefElement resolvedHandle = new ResolvedBinaryMethod(this.parent, this.name, this.parameterTypes, new String(binding.computeUniqueKey())); resolvedHandle.occurrenceCount = this.occurrenceCount; return resolvedHandle; }/* * @private Debugging purposes
@Override public Name getSimpleName() { return new NameImpl(_binding.shortReadableName()); }
if (this instanceof NameReference) { final Binding receiverBinding = ((NameReference) this).binding; if (receiverBinding.isParameter() && (((LocalVariableBinding) receiverBinding).tagBits & TagBits.ForcedToBeRawType) != 0) { return true; // parameter is forced to be raw since super method uses raw types. } else if (receiverBinding instanceof FieldBinding) {
public static boolean isValid(/*@Nullable*/Binding binding) { return binding != null && binding.isValidBinding(); } public boolean isVolatile() {
public final boolean isValidBinding() { return problemId() == ProblemReasons.NoError; } public boolean isVolatile() {
@NonNull @Override public Iterable<ResolvedAnnotation> getAnnotations() { List<ResolvedAnnotation> all = Lists.newArrayListWithExpectedSize(2); AnnotationBinding[] annotations = mBinding.getAnnotations(); int count = annotations.length; if (count == 0) { Binding pkgInfo = mBinding.getTypeOrPackage(TypeConstants.PACKAGE_INFO_NAME); if (pkgInfo != null) { annotations = pkgInfo.getAnnotations(); } count = annotations.length; } if (count > 0) { for (AnnotationBinding annotation : annotations) { if (annotation != null) { all.add(new EcjResolvedAnnotation(annotation)); } } } // Merge external annotations ExternalAnnotationRepository manager = ExternalAnnotationRepository.get(client); Collection<ResolvedAnnotation> external = manager.getAnnotations(this); if (external != null) { all.addAll(external); } all = ensureUnique(all); return all; }
switch (recipient.kind()) { case Binding.LOCAL: recipientTargetMask = recipient.isParameter() ? TagBits.AnnotationForParameter : TagBits.AnnotationForLocalVariable; break; case Binding.FIELD: return; switch (recipient.kind()) { case Binding.LOCAL: LocalVariableBinding local = (LocalVariableBinding) recipient; AnnotationBinding [] recipientAnnotations = recipient.getAnnotations(); int length = recipientAnnotations == null ? 0 : recipientAnnotations.length; int newLength = 0; recipient.setAnnotations(recipientAnnotations, scope);
if (left != null && !left.isVolatile() && left == getDirectBinding(this.expression)) { scope.problemReporter().assignmentHasNoEffect(this, left.shortReadableName());
@Override public String toString() { return new String(_binding.readableName()); } }
protected TypeBinding getTypeBinding(Scope scope) { // it can be a package, type or member type Binding binding = scope.parent.getTypeOrPackage(this.tokens); // step up from the ClassScope if (!binding.isValidBinding()) { scope.problemReporter().invalidType(this, (TypeBinding) binding); if (binding.problemId() == ProblemReasons.NotFound) { throw new CompletionNodeFound(this, binding, scope); } throw new CompletionNodeFound(); } throw new CompletionNodeFound(this, binding, scope); } public boolean isClass(){
public static boolean isAnnotationTargetAllowed(BlockScope scope, TypeBinding annotationType, Binding recipient) { long metaTagBits = annotationType.getAnnotationTagBits(); // could be forward reference if ((metaTagBits & TagBits.AnnotationTargetMASK) == 0) { return true; } return isAnnotationTargetAllowed(recipient, scope, annotationType, recipient.kind(), metaTagBits); }
@Override public JavaElement resolved(Binding binding) { SourceRefElement resolvedHandle = new ResolvedSourceField(this.parent, this.name, new String(binding.computeUniqueKey())); resolvedHandle.occurrenceCount = this.occurrenceCount; return resolvedHandle; } /**