1 11 package org.eclipse.jdt.internal.compiler.ast; 12 13 import org.eclipse.jdt.internal.compiler.ASTVisitor; 14 import org.eclipse.jdt.internal.compiler.impl.Constant; 15 import org.eclipse.jdt.internal.compiler.lookup.*; 16 17 public class JavadocFieldReference extends FieldReference { 18 19 public int tagSourceStart, tagSourceEnd; 20 public int tagValue; 21 public MethodBinding methodBinding; 22 23 public JavadocFieldReference(char[] source, long pos) { 24 super(source, pos); 25 this.bits |= InsideJavadoc; 26 } 27 28 36 37 40 protected TypeBinding internalResolveType(Scope scope) { 41 42 this.constant = Constant.NotAConstant; 43 if (this.receiver == null) { 44 this.receiverType = scope.enclosingSourceType(); 45 } else if (scope.kind == Scope.CLASS_SCOPE) { 46 this.receiverType = this.receiver.resolveType((ClassScope) scope); 47 } else { 48 this.receiverType = this.receiver.resolveType((BlockScope)scope); 49 } 50 if (this.receiverType == null) { 51 return null; 52 } 53 54 Binding fieldBinding = (this.receiver != null && this.receiver.isThis()) 55 ? scope.classScope().getBinding(this.token, this.bits & RestrictiveFlagMASK, this, true ) 56 : scope.getField(this.receiverType, this.token, this); 57 if (!fieldBinding.isValidBinding()) { 58 switch (fieldBinding.problemId()) { 60 case ProblemReasons.NonStaticReferenceInConstructorInvocation: 61 case ProblemReasons.NonStaticReferenceInStaticContext: 62 case ProblemReasons.InheritedNameHidesEnclosingName : 63 FieldBinding closestMatch = ((ProblemFieldBinding)fieldBinding).closestMatch; 64 if (closestMatch != null) { 65 fieldBinding = closestMatch; } 67 } 68 } 69 if (!fieldBinding.isValidBinding() || !(fieldBinding instanceof FieldBinding)) { 71 if (this.receiverType instanceof ReferenceBinding) { 72 ReferenceBinding refBinding = (ReferenceBinding) this.receiverType; 73 MethodBinding[] methodBindings = refBinding.getMethods(this.token); 74 if (methodBindings == null) { 75 scope.problemReporter().javadocInvalidField(this.sourceStart, this.sourceEnd, fieldBinding, this.receiverType, scope.getDeclarationModifiers()); 76 } else { 77 switch (methodBindings.length) { 78 case 0: 79 scope.problemReporter().javadocInvalidField(this.sourceStart, this.sourceEnd, fieldBinding, this.receiverType, scope.getDeclarationModifiers()); 81 break; 82 case 1: 83 this.methodBinding = methodBindings[0]; 85 break; 86 default: 87 this.methodBinding = methodBindings[0]; 89 scope.problemReporter().javadocAmbiguousMethodReference(this.sourceStart, this.sourceEnd, fieldBinding, scope.getDeclarationModifiers()); 90 break; 91 } 92 } 93 } 94 return null; 95 } 96 this.binding = (FieldBinding) fieldBinding; 97 98 if (isFieldUseDeprecated(this.binding, scope, (this.bits & IsStrictlyAssigned) != 0)) { 99 scope.problemReporter().javadocDeprecatedField(this.binding, this, scope.getDeclarationModifiers()); 100 } 101 return this.resolvedType = this.binding.type; 102 } 103 104 public boolean isSuperAccess() { 105 return (this.bits & ASTNode.SuperAccess) != 0; 106 } 107 108 public StringBuffer printExpression(int indent, StringBuffer output) { 109 110 if (this.receiver != null) { 111 this.receiver.printExpression(0, output); 112 } 113 output.append('#').append(this.token); 114 return output; 115 } 116 117 public TypeBinding resolveType(BlockScope scope) { 118 return internalResolveType(scope); 119 } 120 121 public TypeBinding resolveType(ClassScope scope) { 122 return internalResolveType(scope); 123 } 124 125 129 public void traverse(ASTVisitor visitor, BlockScope scope) { 130 131 if (visitor.visit(this, scope)) { 132 if (this.receiver != null) { 133 this.receiver.traverse(visitor, scope); 134 } 135 } 136 visitor.endVisit(this, scope); 137 } 138 public void traverse(ASTVisitor visitor, ClassScope scope) { 139 140 if (visitor.visit(this, scope)) { 141 if (this.receiver != null) { 142 this.receiver.traverse(visitor, scope); 143 } 144 } 145 visitor.endVisit(this, scope); 146 } 147 } 148 | Popular Tags |