1 11 package org.eclipse.jdt.internal.codeassist.complete; 12 13 26 27 import org.eclipse.jdt.internal.compiler.ast.ParameterizedQualifiedTypeReference; 28 import org.eclipse.jdt.internal.compiler.ast.TypeReference; 29 import org.eclipse.jdt.internal.compiler.lookup.BlockScope; 30 import org.eclipse.jdt.internal.compiler.lookup.ClassScope; 31 import org.eclipse.jdt.internal.compiler.lookup.TypeBinding; 32 33 34 public class CompletionOnParameterizedQualifiedTypeReference extends ParameterizedQualifiedTypeReference { 35 public static final int K_TYPE = 0; 36 public static final int K_CLASS = 1; 37 public static final int K_INTERFACE = 2; 38 public static final int K_EXCEPTION = 3; 39 40 private int kind = K_TYPE; 41 public char[] completionIdentifier; 42 47 public CompletionOnParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, char[] completionIdentifier, long[] positions) { 48 this(tokens, typeArguments, completionIdentifier, positions, K_TYPE); 49 } 50 51 57 public CompletionOnParameterizedQualifiedTypeReference(char[][] tokens, TypeReference[][] typeArguments, char[] completionIdentifier, long[] positions, int kind) { 58 super(tokens, typeArguments, 0, positions); 59 this.completionIdentifier = completionIdentifier; 60 this.kind = kind; 61 } 62 63 public boolean isClass(){ 64 return this.kind == K_CLASS; 65 } 66 67 public boolean isInterface(){ 68 return this.kind == K_INTERFACE; 69 } 70 71 public boolean isException(){ 72 return this.kind == K_EXCEPTION; 73 } 74 75 public boolean isSuperType(){ 76 return this.kind == K_CLASS || this.kind == K_INTERFACE; 77 } 78 79 public TypeBinding resolveType(BlockScope scope, boolean checkBounds) { 80 super.resolveType(scope, checkBounds); 81 throw new CompletionNodeFound(this, this.resolvedType, scope); 82 } 83 84 public TypeBinding resolveType(ClassScope scope) { 85 super.resolveType(scope); 86 throw new CompletionNodeFound(this, this.resolvedType, scope); 87 } 88 89 public StringBuffer printExpression(int indent, StringBuffer output) { 90 switch (this.kind) { 91 case K_CLASS : 92 output.append("<CompleteOnClass:"); break; 94 case K_INTERFACE : 95 output.append("<CompleteOnInterface:"); break; 97 case K_EXCEPTION : 98 output.append("<CompleteOnException:"); break; 100 default : 101 output.append("<CompleteOnType:"); break; 103 } 104 int length = tokens.length; 105 for (int i = 0; i < length - 1; i++) { 106 output.append(tokens[i]); 107 TypeReference[] typeArgument = typeArguments[i]; 108 if (typeArgument != null) { 109 output.append('<'); 110 int max = typeArgument.length - 1; 111 for (int j = 0; j < max; j++) { 112 typeArgument[j].print(0, output); 113 output.append(", "); } 115 typeArgument[max].print(0, output); 116 output.append('>'); 117 } 118 output.append('.'); 119 } 120 output.append(tokens[length - 1]); 121 TypeReference[] typeArgument = typeArguments[length - 1]; 122 if (typeArgument != null) { 123 output.append('<'); 124 int max = typeArgument.length - 1; 125 for (int j = 0; j < max; j++) { 126 typeArgument[j].print(0, output); 127 output.append(", "); } 129 typeArgument[max].print(0, output); 130 output.append('>'); 131 } 132 output.append('.').append(completionIdentifier).append('>'); 133 return output; 134 } 135 } 136 | Popular Tags |