List of usage examples for org.eclipse.jdt.internal.compiler.lookup TypeBinding genericTypeSignature
public char[] genericTypeSignature()
From source file:com.codenvy.ide.ext.java.server.internal.codeassist.impl.Engine.java
License:Open Source License
public static char[] getSignature(TypeBinding typeBinding) { char[] result = null; result = typeBinding.genericTypeSignature(); if (result != null) { result = CharOperation.replaceOnCopy(result, '/', '.'); }/*from w w w . j av a 2 s . c o m*/ return result; }
From source file:org.eclipse.objectteams.otdt.internal.core.compiler.bytecode.ConstantPoolObjectMapper.java
License:Open Source License
/** * Map a type binding and convert it to a UTF8-Object. * @param typeBinding/* www .j a v a 2s . c o m*/ * @param useGenerics should type parameters be respected (else use erasure) * @return ConstantPoolObject of type Utf8Tag */ public ConstantPoolObject mapTypeUtf8(TypeBinding typeBinding, boolean useGenerics) { //System.out.println("Sign of "+typeBinding+"="+new String(typeBinding.signature())); char[] prefix = null; if (typeBinding.isArrayType()) { // need to disassemble arrays, because we want to analyze the element type: ArrayBinding array = (ArrayBinding) typeBinding; prefix = new char[array.dimensions()]; Arrays.fill(prefix, '['); typeBinding = array.leafComponentType; } if (typeBinding.isClass() || typeBinding.isInterface()) { ConstantPoolObject clazzCPO = new ConstantPoolObject(ClassTag, mapClass(this._srcMethod, typeBinding, getTeam(this._dstMethod))); typeBinding = clazzCPO.getClassObject(); } char[] signature = useGenerics ? typeBinding.genericTypeSignature() : typeBinding.signature(); if (prefix != null) signature = CharOperation.concat(prefix, signature); return new ConstantPoolObject(Utf8Tag, signature); }
From source file:org.eclipse.recommenders.utils.rcp.CompilerBindings.java
License:Open Source License
/** * TODO nested anonymous types are not resolved correctly. JDT uses line numbers for inner types instead of $1,..,$n *//* w w w .ja va 2 s .c o m*/ public static Optional<ITypeName> toTypeName(@Nullable TypeBinding binding) { // XXX generics fail if (binding == null) { return absent(); } // final boolean boundParameterizedType = binding.isBoundParameterizedType(); final boolean parameterizedType = binding.isParameterizedType(); // if (binding.isBoundParameterizedType()) { // return null; // } if (binding.isArrayType()) { final int dimensions = binding.dimensions(); final TypeBinding leafComponentType = binding.leafComponentType(); final String arrayDimensions = StringUtils.repeat("[", dimensions); final Optional<ITypeName> typeName = toTypeName(leafComponentType); if (!typeName.isPresent()) { return absent(); } final ITypeName res = VmTypeName.get(arrayDimensions + typeName.get().getIdentifier()); return fromNullable(res); } // TODO: handling of generics is bogus! if (binding instanceof TypeVariableBinding) { final TypeVariableBinding generic = (TypeVariableBinding) binding; if (generic.declaringElement instanceof TypeBinding) { // XXX: for this? binding = (TypeBinding) generic.declaringElement; } else if (generic.superclass != null) { // example Tuple<T1 extends List, T2 extends Number) --> for // generic.superclass (T2)=Number // we replace the generic by its superclass binding = generic.superclass; } } String signature = String.valueOf(binding.genericTypeSignature()); // if (binding instanceof BinaryTypeBinding) { // signature = StringUtils.substringBeforeLast(signature, ";"); // } if (signature.length() == 1) { // no handling needed. primitives always look the same. } else if (signature.endsWith(";")) { signature = StringUtils.substringBeforeLast(signature, ";"); } else { signature = "L" + SignatureUtil.stripSignatureToFQN(signature); } final ITypeName res = VmTypeName.get(signature); return fromNullable(res); }