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 CompletionOnSingleTypeReference extends SingleTypeReference { 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 boolean isCompletionNode; 38 public boolean isConstructorType; 39 public CompletionOnFieldType fieldTypeCompletionNode; 40 41 public CompletionOnSingleTypeReference(char[] source, long pos) { 42 this(source, pos, K_TYPE); 43 } 44 public CompletionOnSingleTypeReference(char[] source, long pos, int kind) { 45 super(source, pos); 46 isCompletionNode = true; 47 this.kind = kind; 48 } 49 public void aboutToResolve(Scope scope) { 50 getTypeBinding(scope); 51 } 52 55 public TypeReference copyDims(int dim){ 56 return this; 57 } 58 protected TypeBinding getTypeBinding(Scope scope) { 59 if (this.fieldTypeCompletionNode != null) { 60 throw new CompletionNodeFound(this.fieldTypeCompletionNode, scope); 61 } 62 if(isCompletionNode) { 63 throw new CompletionNodeFound(this, scope); 64 } else { 65 return super.getTypeBinding(scope); 66 } 67 } 68 public boolean isClass(){ 69 return this.kind == K_CLASS; 70 } 71 public boolean isInterface(){ 72 return this.kind == K_INTERFACE; 73 } 74 public boolean isException(){ 75 return this.kind == K_EXCEPTION; 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 return output.append(token).append('>'); 96 } 97 public TypeBinding resolveTypeEnclosing(BlockScope scope, ReferenceBinding enclosingType) { 98 if (this.fieldTypeCompletionNode != null) { 99 throw new CompletionNodeFound(this.fieldTypeCompletionNode, scope); 100 } 101 if(isCompletionNode) { 102 throw new CompletionNodeFound(this, enclosingType, scope); 103 } else { 104 return super.resolveTypeEnclosing(scope, enclosingType); 105 } 106 } 107 } 108 | Popular Tags |