Refine search
public boolean visit(Javadoc javaDoc) { if (currentMethod != null) { SMethod method = getSMethod(currentMethod.getName().getIdentifier()); if (method == null) { LOGGER.error("Method " + currentMethod.getName().getIdentifier() + " not found in class"); } else { for (Object tag : javaDoc.tags()) { Object fragment = tagElement.fragments().get(i); if (i == 0 && fragment instanceof SimpleName) { parameter = method.getParameter(((SimpleName) fragment).getIdentifier()); } else if (i == 1 && parameter != null && fragment instanceof TextElement) { parameter.setDoc(((TextElement) fragment).getText());
if (modifier instanceof org.eclipse.jdt.core.dom.Annotation) { org.eclipse.jdt.core.dom.Annotation annotation = (org.eclipse.jdt.core.dom.Annotation)modifier; String qualifiedAnnotationName = annotation.resolveTypeBinding().getQualifiedName(); if (!"java.lang.Override".equals(qualifiedAnnotationName) && !"java.lang.SuppressWarnings".equals(qualifiedAnnotationName)) annotations.add(annotation); .append(declaration.getReturnType2().toString()) .append(" ").append(declaration.getName().getFullyQualifiedName()) .append("(");
public static org.eclipse.jdt.core.dom.AbstractTypeDeclaration findTypeDeclaration(IType searchType, List<?> nodes) { for (Object object : nodes) { if (object instanceof org.eclipse.jdt.core.dom.AbstractTypeDeclaration) { org.eclipse.jdt.core.dom.AbstractTypeDeclaration typeDeclaration = (org.eclipse.jdt.core.dom.AbstractTypeDeclaration) object; if (typeDeclaration.getName().toString().equals(searchType.getElementName())) return typeDeclaration; } } return null; }
protected void rewrite(SimpleName node, ITypeBinding type) { AST ast= node.getAST(); Type result= fCuRewrite.getImportRewrite().addImport(type, fCuRewrite.getAST()); fCuRewrite.getImportRemover().registerAddedImport(type.getQualifiedName()); Name dummy= ASTNodeFactory.newName(fCuRewrite.getAST(), ASTFlattener.asString(result)); QualifiedName name= ast.newQualifiedName(dummy, ast.newSimpleName(node.getIdentifier())); fCuRewrite.getASTRewrite().replace(node, name, fCuRewrite.createGroupDescription(REFERENCE_UPDATE)); fCuRewrite.getImportRemover().registerRemovedNode(node); fProcessed.add(node); fNeedsImport= true; }
ASTNode clone0(AST target) { SimpleName result = new SimpleName(target); result.setSourceRange(getStartPosition(), getLength()); result.setIdentifier(getIdentifier()); return result; }
String proposeLocalName(SimpleName fieldName, CompilationUnit root, IJavaProject javaProject) { // don't propose names that are already in use: Collection<String> variableNames= new ScopeAnalyzer(root).getUsedVariableNames(this.enclosingMethod.getStartPosition(), this.enclosingMethod.getLength()); String[] names = new String[variableNames.size()+1]; variableNames.toArray(names); // don't propose the field name itself, either: String identifier= fieldName.getIdentifier(); names[names.length-1] = identifier; return StubUtility.getLocalNameSuggestions(javaProject, identifier, 0, names)[0]; }
private ASTNode getFieldReference(SimpleName oldNameNode, ASTRewrite rewrite) { String name= oldNameNode.getIdentifier(); AST ast= rewrite.getAST(); if (isParameterName(name) || StubUtility.useThisForFieldAccess(fTargetRewrite.getCu().getJavaProject())) { FieldAccess fieldAccess= ast.newFieldAccess(); fieldAccess.setExpression(ast.newThisExpression()); fieldAccess.setName((SimpleName) rewrite.createMoveTarget(oldNameNode)); return fieldAccess; } return rewrite.createMoveTarget(oldNameNode); }
final Object internalGetSetObjectProperty(SimplePropertyDescriptor property, boolean get, Object value) { if (property == IDENTIFIER_PROPERTY) { if (get) { return getIdentifier(); } else { setIdentifier((String) value); return null; } } // allow default implementation to flag the error return super.internalGetSetObjectProperty(property, get, value); }
@Override public boolean consumes(SemanticToken token) { // 1: match types in type parameter lists SimpleName name= token.getNode(); ASTNode node= name.getParent(); if (node.getNodeType() != ASTNode.SIMPLE_TYPE && node.getNodeType() != ASTNode.TYPE_PARAMETER) return false; // 2: match generic type variable references IBinding binding= token.getBinding(); return binding instanceof ITypeBinding && ((ITypeBinding) binding).isTypeVariable(); } }
@Override protected SimpleName getNewName(ASTRewrite rewrite) { ASTNode invocationNode= getInvocationNode(); String name; if (invocationNode instanceof MethodInvocation) { name= ((MethodInvocation)invocationNode).getName().getIdentifier(); } else if (invocationNode instanceof SuperMethodInvocation) { name= ((SuperMethodInvocation)invocationNode).getName().getIdentifier(); } else { name= getSenderBinding().getName(); // name of the class } AST ast= rewrite.getAST(); SimpleName newNameNode= ast.newSimpleName(name); return newNameNode; }
public final boolean visit(final SuperFieldAccess node) { if (!fAnonymousClassDeclaration && !fTypeDeclarationStatement) { final AST ast= node.getAST(); final FieldAccess access= ast.newFieldAccess(); access.setExpression(ast.newThisExpression()); access.setName(ast.newSimpleName(node.getName().getIdentifier())); fRewrite.replace(node, access, null); if (!fSourceRewriter.getCu().equals(fTargetRewriter.getCu())) fSourceRewriter.getImportRemover().registerRemovedNode(node); return true; } return false; }
public static ASTRewriteCorrectionProposal getMakeTypeAbstractProposal(ICompilationUnit cu, TypeDeclaration typeDeclaration, int relevance) { AST ast= typeDeclaration.getAST(); ASTRewrite rewrite= ASTRewrite.create(ast); Modifier newModifier= ast.newModifier(Modifier.ModifierKeyword.ABSTRACT_KEYWORD); rewrite.getListRewrite(typeDeclaration, TypeDeclaration.MODIFIERS2_PROPERTY).insertLast(newModifier, null); String label= Messages.format(CorrectionMessages.ModifierCorrectionSubProcessor_addabstract_description, typeDeclaration.getName().getIdentifier()); Image image= JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE); LinkedCorrectionProposal proposal= new LinkedCorrectionProposal(label, cu, rewrite, relevance, image); proposal.addLinkedPosition(rewrite.track(newModifier), true, "modifier"); //$NON-NLS-1$ return proposal; }
private SimpleName getNewName(ASTRewrite rewrite) { AST ast= rewrite.getAST(); String name; if (fInvocationNode.getLocationInParent() == MemberValuePair.NAME_PROPERTY) { name= ((SimpleName) fInvocationNode).getIdentifier(); } else { name= "value"; //$NON-NLS-1$ } SimpleName newNameNode= ast.newSimpleName(name); return newNameNode; }
@Override ASTNode clone0(AST target) { SimpleName result = new SimpleName(target); result.setSourceRange(getStartPosition(), getLength()); result.setIdentifier(getIdentifier()); if (this.ast.apiLevel >= AST.JLS10_INTERNAL && Long.compare(this.ast.scanner.complianceLevel, 10) >= 0) { result.setVar(isVar()); } return result; }
public String getIntroducedVariableName() { if (fElementDeclaration != null) { return fElementDeclaration.getName().getIdentifier(); } else { ForStatement forStatement= getForStatement(); IJavaProject javaProject= ((CompilationUnit)forStatement.getRoot()).getJavaElement().getJavaProject(); String[] proposals= getVariableNameProposals(fArrayAccess.resolveTypeBinding(), javaProject); return proposals[0]; } }
public boolean isEnumNameMethodInvocation (MethodInvocation node) { return node.getName().getIdentifier().equals("name") && node.getExpression() != null && node.getExpression().resolveTypeBinding().isEnum(); }
@Override public String getName() { return method.getName().getFullyQualifiedName(); }
private QualifiedType createQualifiedType(TypeReference typeReference, long[] positions, org.eclipse.jdt.internal.compiler.ast.Annotation[][] typeAnnotations, char[][] tokens, int index, Type qualifier) { SimpleName simpleName = createSimpleName(typeReference, positions, tokens, index); QualifiedType qualifiedType = new QualifiedType(this.ast); qualifiedType.setQualifier(qualifier); qualifiedType.setName(simpleName); int start = qualifier.getStartPosition(); int end = simpleName.getStartPosition() + simpleName.getLength() - 1; setSourceRangeAnnotationsAndRecordNodes(typeReference, qualifiedType, typeAnnotations, index, start, end); return qualifiedType; }
private static String findAffectedParameterName(ASTNode selectedNode) { VariableDeclaration argDecl= (selectedNode instanceof VariableDeclaration) ? (VariableDeclaration) selectedNode : (VariableDeclaration) ASTNodes.getParent(selectedNode, VariableDeclaration.class); if (argDecl != null) return argDecl.getName().getIdentifier(); if (selectedNode.getNodeType() == ASTNode.SIMPLE_NAME) { IBinding binding= ((SimpleName) selectedNode).resolveBinding(); if (binding.getKind() == IBinding.VARIABLE && ((IVariableBinding) binding).isParameter()) return ((SimpleName) selectedNode).getIdentifier(); } return null; }
@Override public boolean visit(SimpleName node) { if (fIgnoreBinding != null && Bindings.equals(fIgnoreBinding, node.resolveBinding())) { return false; } if (fIgnoreRange != null && fIgnoreRange.covers(node)) { return false; } fScope.addName(node.getIdentifier()); return false; }