1 11 package org.eclipse.jdt.internal.codeassist.select; 12 13 31 32 import org.eclipse.jdt.internal.compiler.ast.SingleNameReference; 33 import org.eclipse.jdt.internal.compiler.lookup.Binding; 34 import org.eclipse.jdt.internal.compiler.lookup.BlockScope; 35 import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; 36 import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; 37 import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; 38 import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; 39 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 40 41 public class SelectionOnSingleNameReference extends SingleNameReference { 42 public SelectionOnSingleNameReference(char[] source, long pos) { 43 super(source, pos); 44 } 45 public TypeBinding resolveType(BlockScope scope) { 46 if (this.actualReceiverType != null) { 47 this.binding = scope.getField(this.actualReceiverType, token, this); 48 if (this.binding != null && this.binding.isValidBinding()) { 49 throw new SelectionNodeFound(binding); 50 } 51 } 52 binding = scope.getBinding(token, Binding.VARIABLE | Binding.TYPE | Binding.PACKAGE, this, true ); 54 if (!binding.isValidBinding()) { 55 if (binding instanceof ProblemFieldBinding) { 56 if (binding.problemId() == ProblemReasons.NotVisible 58 || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName 59 || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation 60 || binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext){ 61 throw new SelectionNodeFound(binding); 62 } 63 scope.problemReporter().invalidField(this, (FieldBinding) binding); 64 } else if (binding instanceof ProblemReferenceBinding) { 65 if (binding.problemId() == ProblemReasons.NotVisible){ 67 throw new SelectionNodeFound(binding); 68 } 69 scope.problemReporter().invalidType(this, (TypeBinding) binding); 70 } else { 71 scope.problemReporter().unresolvableReference(this, binding); 72 } 73 throw new SelectionNodeFound(); 74 } 75 76 throw new SelectionNodeFound(binding); 77 } 78 public StringBuffer printExpression(int indent, StringBuffer output) { 79 output.append("<SelectOnName:"); return super.printExpression(0, output).append('>'); 81 } 82 } 83 | Popular Tags |