private boolean hasParameters() { try { IType type= (IType) getJavaElement(); if (type == null) return false; return type.getTypeParameters().length > 0; } catch (JavaModelException e) { return false; } } }
private boolean hasParameters() { try { final IType type = (IType) getJavaElement(); if (type == null) { return false; } return type.getTypeParameters().length > 0; } catch (final JavaModelException e) { return false; } }
private boolean hasParameters() { try { final IType type = (IType) getJavaElement(); if (type == null) { return false; } return type.getTypeParameters().length > 0; } catch (final JavaModelException e) { return false; } }
private boolean hasParameters() { try { IType type= (IType) getJavaElement(); if (type == null) return false; return type.getTypeParameters().length > 0; } catch (JavaModelException e) { return false; } }
private boolean hasParameters() { try { IType type= (IType) getJavaElement(); if (type == null) return false; return type.getTypeParameters().length > 0; } catch (JavaModelException e) { return false; } }
public static Collection<String> getTypeParameterNames(IType type) throws IllegalArgumentException, JavaModelException { if (type == null) { throw new IllegalArgumentException("type == null"); } ITypeParameter[] tp = type.getTypeParameters(); Collection<String> typeParameterNames = HashSetFactory.make(tp.length); for (ITypeParameter p : tp) { typeParameterNames.add(p.getElementName()); } return typeParameterNames; }
private static boolean isParameterizedElement(IJavaElement element) { while (element != null) { ITypeParameter[] typeParameters= null; try { if (element instanceof IType) { typeParameters= ((IType)element).getTypeParameters(); } else if (element instanceof IMethod) { typeParameters= ((IMethod)element).getTypeParameters(); } } catch (JavaModelException e) { return false; } if (typeParameters == null) return false; if (typeParameters.length > 0) return true; element= element.getParent(); } return false; } }
public boolean isApplicable(JavaSearchQuery query) { QuerySpecification spec= query.getSpecification(); if (spec instanceof ElementQuerySpecification) { ElementQuerySpecification elementSpec= (ElementQuerySpecification) spec; Object element= elementSpec.getElement(); ITypeParameter[] typeParameters= null; try { if (element instanceof IType) { typeParameters= ((IType)element).getTypeParameters(); } else if (element instanceof IMethod) { typeParameters= ((IMethod)element).getTypeParameters(); } } catch (JavaModelException e) { return false; } return typeParameters != null && typeParameters.length > 0; } return false; } }
private String createTypeComment(IType type, String lineDelimiter) throws CoreException { String[] typeParameterNames= StubUtility.getTypeParameterNames(type.getTypeParameters()); return CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParameterNames, lineDelimiter); }
private String createTypeComment(IType type, String lineDelimiter) throws CoreException { String[] typeParameterNames= StubUtility.getTypeParameterNames(type.getTypeParameters()); return CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParameterNames, lineDelimiter); }
private String createTypeTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IType type) throws CoreException, BadLocationException { String[] typeParamNames= StubUtility.getTypeParameterNames(type.getTypeParameters()); String comment= CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParamNames, lineDelimiter); if (comment != null) { boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$ if (!isFirstComment(document, command, type, javadocComment)) return null; return prepareTemplateComment(comment.trim(), indentation, type.getJavaProject(), lineDelimiter); } return null; }
private String createTypeComment(IType type, String lineDelimiter) throws CoreException { String[] typeParameterNames= StubUtility.getTypeParameterNames(type.getTypeParameters()); return CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParameterNames, lineDelimiter); }
private String createTypeTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IType type) throws CoreException, BadLocationException { String[] typeParamNames= StubUtility.getTypeParameterNames(type.getTypeParameters()); String comment= CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParamNames, lineDelimiter); if (comment != null) { boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$ if (!isFirstComment(document, command, type, javadocComment)) return null; return prepareTemplateComment(comment.trim(), indentation, type.getJavaProject(), lineDelimiter); } return null; }
private String createTypeTags(IDocument document, DocumentCommand command, String indentation, String lineDelimiter, IType type) throws CoreException, BadLocationException { String[] typeParamNames= StubUtility.getTypeParameterNames(type.getTypeParameters()); String comment= CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParamNames, lineDelimiter); if (comment != null) { boolean javadocComment= comment.startsWith("/**"); //$NON-NLS-1$ if (!isFirstComment(document, command, type, javadocComment)) return null; return prepareTemplateComment(comment.trim(), indentation, type.getJavaProject(), lineDelimiter); } return null; }
static int mapTypeParameterIndex(IType[] path, int pathIndex, int paramIndex) throws JavaModelException, ArrayIndexOutOfBoundsException { if (pathIndex == 0) { // break condition: we've reached the top of the hierarchy return paramIndex; } IType subType= path[pathIndex]; IType superType= path[pathIndex - 1]; String superSignature= findMatchingSuperTypeSignature(subType, superType); ITypeParameter param= subType.getTypeParameters()[paramIndex]; int index= findMatchingTypeArgumentIndex(superSignature, param.getElementName()); if (index == -1) { // not mapped through return -1; } return mapTypeParameterIndex(path, pathIndex - 1, index); }
private String createTypeTags(IDocument document, int offset, String indentation, String lineDelimiter, IType type) throws CoreException, BadLocationException { if (!accept(offset, type)) { return null; } String[] typeParamNames = StubUtility.getTypeParameterNames(type.getTypeParameters()); String comment = CodeGeneration.getTypeComment(type.getCompilationUnit(), type.getTypeQualifiedName('.'), typeParamNames, lineDelimiter); if (comment != null) { return prepareTemplateComment(comment.trim(), indentation, type.getJavaProject(), lineDelimiter); } return null; }
private Type createEnclosingType(final AST ast) throws JavaModelException { Assert.isNotNull(ast); final ITypeParameter[] parameters= fType.getDeclaringType().getTypeParameters(); final Type type= ASTNodeFactory.newType(ast, fType.getDeclaringType().getTypeQualifiedName('.')); if (parameters.length > 0) { final ParameterizedType parameterized= ast.newParameterizedType(type); for (int index= 0; index < parameters.length; index++) parameterized.typeArguments().add(ast.newSimpleType(ast.newSimpleName(parameters[index].getElementName()))); return parameterized; } return type; }
private Type createEnclosingType(final AST ast) throws JavaModelException { Assert.isNotNull(ast); final ITypeParameter[] parameters= fType.getDeclaringType().getTypeParameters(); final Type type= ASTNodeFactory.newType(ast, fType.getDeclaringType().getTypeQualifiedName('.')); if (parameters.length > 0) { final ParameterizedType parameterized= ast.newParameterizedType(type); for (int index= 0; index < parameters.length; index++) parameterized.typeArguments().add(ast.newSimpleType(ast.newSimpleName(parameters[index].getElementName()))); return parameterized; } return type; }
private Type createEnclosingType(final AST ast) throws JavaModelException { Assert.isNotNull(ast); final ITypeParameter[] parameters= fType.getDeclaringType().getTypeParameters(); final Type type= ASTNodeFactory.newType(ast, JavaModelUtil.getTypeQualifiedName(fType.getDeclaringType())); if (parameters.length > 0) { final ParameterizedType parameterized= ast.newParameterizedType(type); for (int index= 0; index < parameters.length; index++) parameterized.typeArguments().add(ast.newSimpleType(ast.newSimpleName(parameters[index].getElementName()))); return parameterized; } return type; }
private static final boolean resolveTypeParameter(final IMethod method, final String identifier, final StringBuilder result) throws JavaModelException { IType type = method.getDeclaringType(); if (resolveTypeParameter(type, method.getTypeParameters(), identifier, result)) { return true; } while (type != null) { if (resolveTypeParameter(type, type.getTypeParameters(), identifier, result)) { return true; } type = type.getDeclaringType(); } return false; }