List of usage examples for org.eclipse.jdt.core Signature getTypeParameterBounds
public static String[] getTypeParameterBounds(String formalTypeParameterSignature) throws IllegalArgumentException
From source file:com.codenvy.ide.ext.java.server.internal.core.ClassFileInfo.java
License:Open Source License
/** * Creates the handles and infos for the type parameter of the given binary member. * Adds new handles to the given vector. *///from w ww . j ava2 s . com private void generateTypeParameterInfos(BinaryMember parent, char[] signature, HashMap newElements, ArrayList typeParameterHandles) { if (signature == null) return; char[][] typeParameterSignatures = Signature.getTypeParameters(signature); for (int i = 0, typeParameterCount = typeParameterSignatures.length; i < typeParameterCount; i++) { char[] typeParameterSignature = typeParameterSignatures[i]; char[] typeParameterName = Signature.getTypeVariable(typeParameterSignature); CharOperation.replace(typeParameterSignature, '/', '.'); char[][] typeParameterBoundSignatures = Signature.getTypeParameterBounds(typeParameterSignature); int boundLength = typeParameterBoundSignatures.length; char[][] typeParameterBounds = new char[boundLength][]; for (int j = 0; j < boundLength; j++) { typeParameterBounds[j] = Signature.toCharArray(typeParameterBoundSignatures[j]); } TypeParameter typeParameter = new TypeParameter(parent, parent.manager, new String(typeParameterName)); TypeParameterElementInfo info = new TypeParameterElementInfo(); info.bounds = typeParameterBounds; info.boundsSignatures = typeParameterBoundSignatures; typeParameterHandles.add(typeParameter); // ensure that 2 binary methods with the same signature but with different return types have different occurence counts. // (case of bridge methods in 1.5) while (newElements.containsKey(typeParameter)) typeParameter.occurrenceCount++; newElements.put(typeParameter, info); } // throw new UnsupportedOperationException(); }
From source file:org.eclipse.recommenders.completion.rcp.utils.ProposalUtils.java
License:Open Source License
private static char[] resolveTypeVariable(char[] typeVariableName, char[][] typeParameters) { for (char[] typeParameter : typeParameters) { if (CharOperation.equals(typeVariableName, Signature.getTypeVariable(typeParameter))) { char[][] typeParameterBounds = Signature.getTypeParameterBounds(typeParameter); if (typeParameterBounds.length > 0) { return typeParameterBounds[0]; } else { return JAVA_LANG_OBJECT; }//from ww w . j a v a 2s. co m } } // No match found. Assume Object. return JAVA_LANG_OBJECT; }
From source file:org.jboss.tools.common.java.ParametedTypeFactory.java
License:Open Source License
public ParametedType getParametedTypeForParameter(IMember context, String typeParameterSignature, ParametedType result) throws JavaModelException { IType contextType = context instanceof IType ? (IType) context : context.getDeclaringType(); String key = context == null ? typeParameterSignature : contextType.getFullyQualifiedName() + "+" + typeParameterSignature; String t = Signature.getTypeVariable(typeParameterSignature); String[] bounds = Signature.getTypeParameterBounds(typeParameterSignature); t = Signature.C_RESOLVED + t + Signature.C_SEMICOLON; if (result == null || t.equals(result.getSignature()) || result.getSignature().endsWith("[" + t)) { if (bounds.length > 0 && bounds[0].length() > 0) { ParametedType st = getParametedType(contextType, bounds[0]); if (st != null) { result = new TypeDeclaration(st, context.getResource(), 0, 0); result.setUpper(true);/*ww w .j a va 2s .co m*/ } } else if (result != null) { result.setSignature(t); } if (result == null) { result = new ParametedType(); result.setFactory(this); result.setSignature(t); } result.setVariable(true); cache.put(key, result); return result; } return null; }