use of org.eclipse.jdt.core.dom.ITypeBinding in project che by eclipse.
the class ASTNodeFactory method newType.
private static Type newType(LambdaExpression lambdaExpression, VariableDeclarationFragment declaration, AST ast, ImportRewrite importRewrite, ImportRewriteContext context) {
IMethodBinding method = lambdaExpression.resolveMethodBinding();
if (method != null) {
ITypeBinding[] parameterTypes = method.getParameterTypes();
int index = lambdaExpression.parameters().indexOf(declaration);
ITypeBinding typeBinding = parameterTypes[index];
if (importRewrite != null) {
return importRewrite.addImport(typeBinding, ast, context);
} else {
String qualifiedName = typeBinding.getQualifiedName();
if (qualifiedName.length() > 0) {
return newType(ast, qualifiedName);
}
}
}
//$NON-NLS-1$
return ast.newSimpleType(ast.newSimpleName("Object"));
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project che by eclipse.
the class Bindings method findMethodInHierarchy.
/**
* Finds the method specified by <code>methodName</code> and </code>parameters</code> in
* the type hierarchy denoted by the given type. Returns <code>null</code> if no such method
* exists. If the method is defined in more than one super type only the first match is
* returned. First the super class is examined and then the implemented interfaces.
*
* @param type The type to search the method in
* @param methodName The name of the method to find
* @param parameters The parameter types of the method to find. If <code>null</code> is passed, only the name is matched and parameters are ignored.
* @return the method binding representing the method
*/
public static IMethodBinding findMethodInHierarchy(ITypeBinding type, String methodName, ITypeBinding[] parameters) {
IMethodBinding method = findMethodInType(type, methodName, parameters);
if (method != null)
return method;
ITypeBinding superClass = type.getSuperclass();
if (superClass != null) {
method = findMethodInHierarchy(superClass, methodName, parameters);
if (method != null)
return method;
}
ITypeBinding[] interfaces = type.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
method = findMethodInHierarchy(interfaces[i], methodName, parameters);
if (method != null)
return method;
}
return null;
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project che by eclipse.
the class Bindings method collectSuperTypes.
private static void collectSuperTypes(ITypeBinding curr, Set<ITypeBinding> collection) {
if (collection.add(curr)) {
ITypeBinding[] interfaces = curr.getInterfaces();
for (int i = 0; i < interfaces.length; i++) {
collectSuperTypes(interfaces[i], collection);
}
ITypeBinding superClass = curr.getSuperclass();
if (superClass != null) {
collectSuperTypes(superClass, collection);
}
}
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project che by eclipse.
the class StubUtility method getParameterTypeNamesForSeeTag.
/*
* Returns the parameters type names used in see tags. Currently, these are always fully qualified.
*/
public static String[] getParameterTypeNamesForSeeTag(IMethodBinding binding) {
ITypeBinding[] typeBindings = binding.getParameterTypes();
String[] result = new String[typeBindings.length];
for (int i = 0; i < result.length; i++) {
ITypeBinding curr = typeBindings[i];
// Javadoc references use erased type
curr = curr.getErasure();
result[i] = curr.getQualifiedName();
}
return result;
}
use of org.eclipse.jdt.core.dom.ITypeBinding in project che by eclipse.
the class StubUtility2 method createThrownExceptions.
private static void createThrownExceptions(MethodDeclaration decl, IMethodBinding method, ImportRewrite imports, ImportRewriteContext context, AST ast) {
ITypeBinding[] excTypes = method.getExceptionTypes();
if (ast.apiLevel() >= AST.JLS8) {
List<Type> thrownExceptions = decl.thrownExceptionTypes();
for (int i = 0; i < excTypes.length; i++) {
Type excType = imports.addImport(excTypes[i], ast, context);
thrownExceptions.add(excType);
}
} else {
List<Name> thrownExceptions = getThrownExceptions(decl);
for (int i = 0; i < excTypes.length; i++) {
String excTypeName = imports.addImport(excTypes[i], context);
thrownExceptions.add(ASTNodeFactory.newName(ast, excTypeName));
}
}
}
Aggregations