private static Set<String> getPreviousExceptionNames(List<Type> list, ASTNode missingNode) { Set<String> previousNames= new HashSet<>(); for (int i= 0; i < list.size() && missingNode != list.get(i); i++) { Type curr= list.get(i); previousNames.add(ASTNodes.getTypeName(curr)); } return previousNames; }
private static Set<String> getPreviousExceptionNames(List<Type> list, ASTNode missingNode) { Set<String> previousNames= new HashSet<>(); for (int i= 0; i < list.size() && missingNode != list.get(i); i++) { Type curr= list.get(i); previousNames.add(ASTNodes.getTypeName(curr)); } return previousNames; }
private static Set<String> getPreviousExceptionNames(List<Type> list, ASTNode missingNode) { Set<String> previousNames= new HashSet<>(); for (int i= 0; i < list.size() && missingNode != list.get(i); i++) { Type curr= list.get(i); previousNames.add(ASTNodes.getTypeName(curr)); } return previousNames; }
private TagElement insertThrowsTag(ListRewrite tagRewriter, List<Type> exceptions, int currentIndex, TagElement newTagElement) { HashSet<String> previousNames= new HashSet<>(); for (int n = 0; n < currentIndex; n++) { Type curr= exceptions.get(n); previousNames.add(ASTNodes.getTypeName(curr)); } JavadocTagsSubProcessor.insertTag(tagRewriter, newTagElement, previousNames); return newTagElement; }
private TagElement insertThrowsTag(ListRewrite tagRewriter, List<Type> exceptions, int currentIndex, TagElement newTagElement) { HashSet<String> previousNames= new HashSet<>(); for (int n = 0; n < currentIndex; n++) { Type curr= exceptions.get(n); previousNames.add(ASTNodes.getTypeName(curr)); } JavadocTagsSubProcessor.insertTag(tagRewriter, newTagElement, previousNames); return newTagElement; }
private TagElement insertThrowsTag(ListRewrite tagRewriter, List<Type> exceptions, int currentIndex, TagElement newTagElement) { HashSet<String> previousNames= new HashSet<>(); for (int n = 0; n < currentIndex; n++) { Type curr= exceptions.get(n); previousNames.add(ASTNodes.getTypeName(curr)); } JavadocTagsSubProcessor.insertTag(tagRewriter, newTagElement, previousNames); return newTagElement; }
private TagElement findThrowsTag(MethodDeclaration decl, Type exception) { Javadoc javadoc= decl.getJavadoc(); if (javadoc != null) { String name= ASTNodes.getTypeName(exception); return JavadocTagsSubProcessor.findThrowsTag(javadoc, name); } return null; }
private TagElement findThrowsTag(MethodDeclaration decl, Type exception) { Javadoc javadoc= decl.getJavadoc(); if (javadoc != null) { String name= ASTNodes.getTypeName(exception); return JavadocTagsSubProcessor.findThrowsTag(javadoc, name); } return null; }
private TagElement findThrowsTag(MethodDeclaration decl, Type exception) { Javadoc javadoc= decl.getJavadoc(); if (javadoc != null) { String name= ASTNodes.getTypeName(exception); return JavadocTagsSubProcessor.findThrowsTag(javadoc, name); } return null; }
/** * @param decl the method declaration * @return the exception names * @deprecated to avoid deprecation warnings */ @Deprecated private static String[] getExceptionNames(MethodDeclaration decl) { String[] exceptionNames; if (decl.getAST().apiLevel() >= AST.JLS8) { List<Type> exceptions= decl.thrownExceptionTypes(); exceptionNames= new String[exceptions.size()]; for (int i= 0; i < exceptionNames.length; i++) { exceptionNames[i]= ASTNodes.getTypeName(exceptions.get(i)); } } else { List<Name> exceptions= decl.thrownExceptions(); exceptionNames= new String[exceptions.size()]; for (int i= 0; i < exceptionNames.length; i++) { exceptionNames[i]= ASTNodes.getSimpleNameIdentifier(exceptions.get(i)); } } return exceptionNames; }
/** * @param decl the method declaration * @return the exception names * @deprecated to avoid deprecation warnings */ @Deprecated private static String[] getExceptionNames(MethodDeclaration decl) { String[] exceptionNames; if (decl.getAST().apiLevel() >= AST.JLS8) { List<Type> exceptions= decl.thrownExceptionTypes(); exceptionNames= new String[exceptions.size()]; for (int i= 0; i < exceptionNames.length; i++) { exceptionNames[i]= ASTNodes.getTypeName(exceptions.get(i)); } } else { List<Name> exceptions= decl.thrownExceptions(); exceptionNames= new String[exceptions.size()]; for (int i= 0; i < exceptionNames.length; i++) { exceptionNames[i]= ASTNodes.getSimpleNameIdentifier(exceptions.get(i)); } } return exceptionNames; }
private static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, Type expectedType, Collection<String> excluded, boolean evaluateDefault) { int dim= 0; if (expectedType.isArrayType()) { ArrayType arrayType= (ArrayType)expectedType; dim= arrayType.getDimensions(); expectedType= arrayType.getElementType(); } if (expectedType.isParameterizedType()) { expectedType= ((ParameterizedType)expectedType).getType(); } String typeName= ASTNodes.getTypeName(expectedType); if (typeName.length() > 0) { return getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, evaluateDefault); } return EMPTY; }
private static String[] getVariableNameSuggestions(int variableKind, IJavaProject project, Type expectedType, Collection<String> excluded, boolean evaluateDefault) { int dim= 0; if (expectedType.isArrayType()) { ArrayType arrayType= (ArrayType)expectedType; dim= arrayType.getDimensions(); expectedType= arrayType.getElementType(); } if (expectedType.isParameterizedType()) { expectedType= ((ParameterizedType)expectedType).getType(); } String typeName= ASTNodes.getTypeName(expectedType); if (typeName.length() > 0) { return getVariableNameSuggestions(variableKind, project, typeName, dim, excluded, evaluateDefault); } return EMPTY; }
@Override protected boolean shouldReport(IProblem problem, CompilationUnit cu) { if (!super.shouldReport(problem, cu)) return false; ASTNode node= ASTNodeSearchUtil.getAstNode(cu, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); if (node instanceof Type) { Type type= (Type) node; if (problem.getID() == IProblem.UndefinedType && getClassName().equals(ASTNodes.getTypeName(type))) { return false; } } if (node instanceof Name) { Name name= (Name) node; if (problem.getID() == IProblem.ImportNotFound && getPackage().indexOf(name.getFullyQualifiedName()) != -1) return false; if (problem.getID() == IProblem.MissingTypeInMethod) { StructuralPropertyDescriptor locationInParent= name.getLocationInParent(); String[] arguments= problem.getArguments(); if ((locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY) && arguments.length > 3 && arguments[3].endsWith(getClassName())) return false; } } return true; }
@Override protected boolean shouldReport(IProblem problem, CompilationUnit cu) { if (!super.shouldReport(problem, cu)) return false; ASTNode node= ASTNodeSearchUtil.getAstNode(cu, problem.getSourceStart(), problem.getSourceEnd() - problem.getSourceStart() + 1); if (node instanceof Type) { Type type= (Type) node; if (problem.getID() == IProblem.UndefinedType && getClassName().equals(ASTNodes.getTypeName(type))) { return false; } } if (node instanceof Name) { Name name= (Name) node; if (problem.getID() == IProblem.ImportNotFound && getPackage().indexOf(name.getFullyQualifiedName()) != -1) return false; if (problem.getID() == IProblem.MissingTypeInMethod) { StructuralPropertyDescriptor locationInParent= name.getLocationInParent(); String[] arguments= problem.getArguments(); if ((locationInParent == MethodInvocation.NAME_PROPERTY || locationInParent == SuperMethodInvocation.NAME_PROPERTY) && arguments.length > 3 && arguments[3].endsWith(getClassName())) return false; } } return true; }