1 11 package org.eclipse.jdt.internal.codeassist.complete; 12 13 26 27 import org.eclipse.jdt.internal.compiler.ast.*; 28 import org.eclipse.jdt.internal.compiler.lookup.*; 29 30 public class CompletionOnQualifiedTypeReference extends QualifiedTypeReference { 31 public static final int K_TYPE = 0; 32 public static final int K_CLASS = 1; 33 public static final int K_INTERFACE = 2; 34 public static final int K_EXCEPTION = 3; 35 36 private int kind = K_TYPE; 37 public char[] completionIdentifier; 38 public CompletionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] completionIdentifier, long[] positions) { 39 this(previousIdentifiers, completionIdentifier, positions, K_TYPE); 40 } 41 public CompletionOnQualifiedTypeReference(char[][] previousIdentifiers, char[] completionIdentifier, long[] positions, int kind) { 42 super(previousIdentifiers, positions); 43 this.completionIdentifier = completionIdentifier; 44 this.kind = kind; 45 } 46 public void aboutToResolve(Scope scope) { 47 getTypeBinding(scope); 48 } 49 52 public TypeReference copyDims(int dim){ 53 return this; 54 } 55 protected TypeBinding getTypeBinding(Scope scope) { 56 Binding binding = scope.parent.getTypeOrPackage(tokens); if (!binding.isValidBinding()) { 59 scope.problemReporter().invalidType(this, (TypeBinding) binding); 60 throw new CompletionNodeFound(); 61 } 62 63 throw new CompletionNodeFound(this, binding, scope); 64 } 65 public boolean isClass(){ 66 return this.kind == K_CLASS; 67 } 68 69 public boolean isInterface(){ 70 return this.kind == K_INTERFACE; 71 } 72 73 public boolean isException(){ 74 return this.kind == K_EXCEPTION; 75 } 76 77 public boolean isSuperType(){ 78 return this.kind == K_CLASS || this.kind == K_INTERFACE; 79 } 80 public StringBuffer printExpression(int indent, StringBuffer output) { 81 switch (this.kind) { 82 case K_CLASS : 83 output.append("<CompleteOnClass:"); break; 85 case K_INTERFACE : 86 output.append("<CompleteOnInterface:"); break; 88 case K_EXCEPTION : 89 output.append("<CompleteOnException:"); break; 91 default : 92 output.append("<CompleteOnType:"); break; 94 } 95 for (int i = 0; i < tokens.length; i++) { 96 output.append(tokens[i]); 97 output.append('.'); 98 } 99 output.append(completionIdentifier).append('>'); 100 return output; 101 } 102 } 103 | Popular Tags |