1 11 package org.eclipse.jdt.internal.compiler.lookup; 12 13 import org.eclipse.jdt.core.compiler.CharOperation; 14 15 20 public class RawTypeBinding extends ParameterizedTypeBinding { 21 22 27 public RawTypeBinding(ReferenceBinding type, ReferenceBinding enclosingType, LookupEnvironment environment){ 28 super(type, null, enclosingType, environment); 29 if (enclosingType == null || (enclosingType.modifiers & ExtraCompilerModifiers.AccGenericSignature) == 0) 30 this.modifiers &= ~ExtraCompilerModifiers.AccGenericSignature; } 32 33 public char[] computeUniqueKey(boolean isLeaf) { 34 StringBuffer sig = new StringBuffer (10); 35 if (isMemberType() && enclosingType().isParameterizedType()) { 36 char[] typeSig = enclosingType().computeUniqueKey(false); 37 for (int i = 0; i < typeSig.length-1; i++) sig.append(typeSig[i]); sig.append('.').append(sourceName()).append('<').append('>').append(';'); 39 } else { 40 sig.append(genericType().computeUniqueKey(false)); 41 sig.insert(sig.length()-1, "<>"); } 43 44 int sigLength = sig.length(); 45 char[] uniqueKey = new char[sigLength]; 46 sig.getChars(0, sigLength, uniqueKey, 0); 47 return uniqueKey; 48 } 49 50 53 public ParameterizedMethodBinding createParameterizedMethod(MethodBinding originalMethod) { 54 if (originalMethod.typeVariables == Binding.NO_TYPE_VARIABLES || originalMethod.isStatic()) { 55 return super.createParameterizedMethod(originalMethod); 56 } 57 return this.environment.createParameterizedGenericMethod(originalMethod, this); 58 } 59 60 public int kind() { 61 return RAW_TYPE; 62 } 63 64 67 public String debugName() { 68 StringBuffer nameBuffer = new StringBuffer (10); 69 nameBuffer.append(actualType().sourceName()).append("#RAW"); return nameBuffer.toString(); 71 } 72 73 77 public char[] genericTypeSignature() { 78 79 if (this.genericTypeSignature == null) { 80 StringBuffer sig = new StringBuffer (10); 81 if (this.isMemberType() && this.enclosingType().isParameterizedType()) { 82 char[] typeSig = this.enclosingType().genericTypeSignature(); 83 for (int i = 0; i < typeSig.length-1; i++) sig.append(typeSig[i]); sig.append('.').append(this.sourceName()).append(';'); 85 int sigLength = sig.length(); 86 this.genericTypeSignature = new char[sigLength]; 87 sig.getChars(0, sigLength, this.genericTypeSignature, 0); 88 } else { 89 this.genericTypeSignature = genericType().signature(); } 91 } 92 return this.genericTypeSignature; 93 } 94 95 public boolean isEquivalentTo(TypeBinding otherType) { 96 if (this == otherType) 97 return true; 98 if (otherType == null) 99 return false; 100 switch(otherType.kind()) { 101 102 case Binding.WILDCARD_TYPE : 103 return ((WildcardBinding) otherType).boundCheck(this); 104 105 case Binding.GENERIC_TYPE : 106 case Binding.PARAMETERIZED_TYPE : 107 case Binding.RAW_TYPE : 108 return erasure() == otherType.erasure(); 109 } 110 return false; 111 } 112 113 public boolean isIntersectingWith(TypeBinding otherType) { 114 if (this == otherType) 115 return true; 116 if (otherType == null) 117 return false; 118 switch(otherType.kind()) { 119 120 case Binding.GENERIC_TYPE : 121 case Binding.PARAMETERIZED_TYPE : 122 case Binding.RAW_TYPE : 123 return erasure() == otherType.erasure(); 124 } 125 return false; 126 } 127 128 132 public boolean isParameterizedType() { 133 return false; 134 } 135 public boolean isRawType() { 136 return true; 137 } 138 139 protected void initializeArguments() { 140 TypeVariableBinding[] typeVariables = genericType().typeVariables(); 141 int length = typeVariables.length; 142 TypeBinding[] typeArguments = new TypeBinding[length]; 143 for (int i = 0; i < length; i++) { 144 typeArguments[i] = this.environment.convertToRawType(typeVariables[i].erasure()); 146 } 147 this.arguments = typeArguments; 148 } 149 152 public char[] readableName() { 153 char[] readableName; 154 if (isMemberType()) { 155 readableName = CharOperation.concat(enclosingType().readableName(), sourceName, '.'); 156 } else { 157 readableName = CharOperation.concatWith(actualType().compoundName, '.'); 158 } 159 return readableName; 160 } 161 162 165 public char[] shortReadableName() { 166 char[] shortReadableName; 167 if (isMemberType()) { 168 shortReadableName = CharOperation.concat(enclosingType().shortReadableName(), sourceName, '.'); 169 } else { 170 shortReadableName = actualType().sourceName; 171 } 172 return shortReadableName; 173 } 174 } 175 | Popular Tags |