1 11 package org.eclipse.jdt.internal.codeassist.select; 12 13 33 34 import org.eclipse.jdt.core.compiler.CharOperation; 35 import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference; 36 import org.eclipse.jdt.internal.compiler.lookup.BlockScope; 37 import org.eclipse.jdt.internal.compiler.lookup.FieldBinding; 38 import org.eclipse.jdt.internal.compiler.lookup.ProblemFieldBinding; 39 import org.eclipse.jdt.internal.compiler.lookup.ProblemReasons; 40 import org.eclipse.jdt.internal.compiler.lookup.ProblemReferenceBinding; 41 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 42 43 public class SelectionOnQualifiedNameReference extends QualifiedNameReference { 44 45 public SelectionOnQualifiedNameReference(char[][] previousIdentifiers, char[] selectionIdentifier, long[] positions) { 46 super( 47 CharOperation.arrayConcat(previousIdentifiers, selectionIdentifier), 48 positions, 49 (int) (positions[0] >>> 32), 50 (int) positions[positions.length - 1]); 51 } 52 public StringBuffer printExpression(int indent, StringBuffer output) { 53 54 output.append("<SelectOnName:"); for (int i = 0, length = tokens.length; i < length; i++) { 56 if (i > 0) output.append('.'); 57 output.append(tokens[i]); 58 } 59 return output.append('>'); 60 } 61 public TypeBinding resolveType(BlockScope scope) { 62 binding = scope.getBinding(tokens, this); 64 if (!binding.isValidBinding()) { 65 if (binding instanceof ProblemFieldBinding) { 66 if (binding.problemId() == ProblemReasons.NotVisible 68 || binding.problemId() == ProblemReasons.InheritedNameHidesEnclosingName 69 || binding.problemId() == ProblemReasons.NonStaticReferenceInConstructorInvocation 70 || binding.problemId() == ProblemReasons.NonStaticReferenceInStaticContext) { 71 throw new SelectionNodeFound(binding); 72 } 73 scope.problemReporter().invalidField(this, (FieldBinding) binding); 74 } else if (binding instanceof ProblemReferenceBinding) { 75 if (binding.problemId() == ProblemReasons.NotVisible){ 77 throw new SelectionNodeFound(binding); 78 } 79 scope.problemReporter().invalidType(this, (TypeBinding) binding); 80 } else { 81 scope.problemReporter().unresolvableReference(this, binding); 82 } 83 throw new SelectionNodeFound(); 84 } 85 throw new SelectionNodeFound(binding); 86 } 87 } 88 | Popular Tags |