private Statement getCatchBody(String type, String name, String lineSeparator) throws CoreException { String s = StubUtility.getCatchBodyContent(fCUnit, type, name, fSelectedNodes[0], lineSeparator); if (s == null) { return null; } else { return (Statement) fRewriter.createStringPlaceholder(s, ASTNode.RETURN_STATEMENT); } } }
private Statement getCatchBody(String type, String name, String lineSeparator) throws CoreException { String s= StubUtility.getCatchBodyContent(fCUnit, type, name, fSelectedNodes[0], lineSeparator); if (s == null) { return null; } else { return (Statement)fRewriter.createStringPlaceholder(s, ASTNode.RETURN_STATEMENT); } } }
private Statement getCatchBody(String type, String name, String lineSeparator) throws CoreException { String s= StubUtility.getCatchBodyContent(fCUnit, type, name, fSelectedNodes[0], lineSeparator); if (s == null) { return null; } else { return (Statement)fRewriter.createStringPlaceholder(s, ASTNode.RETURN_STATEMENT); } } }
private ASTNode createNewNodeToInsertToCu(TypedSource source, ASTRewrite rewrite) { switch(source.getType()){ case IJavaElement.TYPE: return rewrite.createStringPlaceholder(source.getSource(), ASTNode.TYPE_DECLARATION); case IJavaElement.PACKAGE_DECLARATION: return rewrite.createStringPlaceholder(source.getSource(), ASTNode.PACKAGE_DECLARATION); case IJavaElement.IMPORT_DECLARATION: return rewrite.createStringPlaceholder(source.getSource(), ASTNode.IMPORT_DECLARATION); default: Assert.isTrue(false, String.valueOf(source.getType())); return null; } }
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IMethodBinding method, ImportRewriteContext importRewriteContext) { String receiver= getReceiver(context, method.getModifiers(), importRewriteContext); if (receiver == null) return null; return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.METHOD_INVOCATION); }
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IVariableBinding field, ImportRewriteContext importRewriteContext) { String receiver= getReceiver(context, field.getModifiers(), importRewriteContext); if (receiver == null) return null; return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.SIMPLE_NAME); }
private Expression createReceiver(ASTRewrite rewriter, CallContext context, IMethodBinding method) { String receiver= getReceiver(context, method.getModifiers()); if (receiver == null) return null; return (Expression)rewriter.createStringPlaceholder(receiver, ASTNode.METHOD_INVOCATION); }
protected static void copyJavadocNode(final ASTRewrite rewrite, final BodyDeclaration oldDeclaration, final BodyDeclaration newDeclaration) { final Javadoc predecessor= oldDeclaration.getJavadoc(); if (predecessor != null) { String newString= ASTNodes.getNodeSource(predecessor, false, true); if (newString != null) { newDeclaration.setJavadoc((Javadoc) rewrite.createStringPlaceholder(newString, ASTNode.JAVADOC)); } } }
private Expression createNewExpression(ParameterInfo info, List<ParameterInfo> parameterInfos, List<Expression> nodes, CompilationUnitRewrite cuRewrite, MethodDeclaration method) { if (info.isNewVarargs() && info.getDefaultValue().trim().length() == 0) return null; else { if (fDefaultValueAdvisor == null) return (Expression) cuRewrite.getASTRewrite().createStringPlaceholder(info.getDefaultValue(), ASTNode.METHOD_INVOCATION); else return fDefaultValueAdvisor.createDefaultExpression(nodes, info, parameterInfos, method, false, cuRewrite); } }
private Expression createNewExpression(ParameterInfo info, List<ParameterInfo> parameterInfos, List<Expression> nodes, CompilationUnitRewrite cuRewrite, MethodDeclaration method) { if (info.isNewVarargs() && info.getDefaultValue().trim().length() == 0) return null; else { if (fDefaultValueAdvisor == null) return (Expression) cuRewrite.getASTRewrite().createStringPlaceholder(info.getDefaultValue(), ASTNode.METHOD_INVOCATION); else return fDefaultValueAdvisor.createDefaultExpression(nodes, info, parameterInfos, method, false, cuRewrite); } }
private Expression createNewExpression(ParameterInfo info, List parameterInfos, List nodes, CompilationUnitRewrite cuRewrite, MethodDeclaration method) { if (info.isNewVarargs() && info.getDefaultValue().trim().length() == 0) return null; else { if (fDefaultValueAdvisor == null) return (Expression) cuRewrite.getASTRewrite().createStringPlaceholder(info.getDefaultValue(), ASTNode.METHOD_INVOCATION); else return fDefaultValueAdvisor.createDefaultExpression(nodes, info, parameterInfos, method, false, cuRewrite); } }
private Expression createNewExpressionRecursive(ParameterInfo info, List parameterInfos, List nodes, CompilationUnitRewrite cuRewrite, MethodDeclaration methodDeclaration) { if (fDefaultValueAdvisor != null && info.isAdded()) { return fDefaultValueAdvisor.createDefaultExpression(nodes, info, parameterInfos, methodDeclaration, true, cuRewrite); } return (Expression) getASTRewrite().createStringPlaceholder(info.getNewName(), ASTNode.METHOD_INVOCATION); }
private Javadoc getNewConstructorComment(ASTRewrite rewrite) throws CoreException { if (StubUtility.doAddComments(fCu.getJavaProject())){ String comment= CodeGeneration.getMethodComment(fCu, getEnclosingTypeName(), getEnclosingTypeName(), new String[0], new String[0], null, null, StubUtility.getLineDelimiterUsed(fCu)); if (comment != null && comment.length() > 0) { return (Javadoc) rewrite.createStringPlaceholder(comment, ASTNode.JAVADOC); } } return null; }
@Override public boolean visit(SimpleName node) { if (!node.isDeclaration() && considerBinding(node.resolveBinding(), node)) { fReferencingGetter = true; fRewriter.replace(node, fRewriter.createStringPlaceholder(fGetter + "()", ASTNode.METHOD_INVOCATION), //$NON-NLS-1$ createGroupDescription(READ_ACCESS)); } return true; }
private void copyMethodToDestination(IMethod method, CompilationUnitRewrite targetRewriter, CompilationUnit sourceCuNode, CompilationUnit targetCuNode) throws JavaModelException { MethodDeclaration newMethod= (MethodDeclaration) targetRewriter.getASTRewrite().createStringPlaceholder(getUnindentedSource(method), ASTNode.METHOD_DECLARATION); newMethod.setConstructor(method.isConstructor()); copyMemberToDestination(method, targetRewriter, sourceCuNode, targetCuNode, newMethod); }
public boolean visit(SimpleName node) { if (!node.isDeclaration() && considerBinding(node.resolveBinding(), node)) { fReferencingGetter= true; fRewriter.replace( node, fRewriter.createStringPlaceholder(fGetter + "()", ASTNode.METHOD_INVOCATION), //$NON-NLS-1$ createGroupDescription(READ_ACCESS)); } return true; }
private void copyTypeToDestination(IType type, CompilationUnitRewrite targetRewriter, CompilationUnit sourceCuNode, CompilationUnit targetCuNode) throws JavaModelException { AbstractTypeDeclaration newType= (AbstractTypeDeclaration) targetRewriter.getASTRewrite().createStringPlaceholder(getUnindentedSource(type), ASTNode.TYPE_DECLARATION); IType enclosingType= getEnclosingType(getJavaElementDestination()); if (enclosingType != null) { copyMemberToDestination(type, targetRewriter, sourceCuNode, targetCuNode, newType); } else { targetRewriter.getASTRewrite().getListRewrite(targetCuNode, CompilationUnit.TYPES_PROPERTY).insertLast(newType, null); } }
protected static ASTNode moveNode(CompilationUnitRewrite cuRewrite, ASTNode node) { ASTRewrite rewrite= cuRewrite.getASTRewrite(); if (rewrite.getAST() != node.getAST()) { String str= ASTNodes.getNodeSource(node, true, true); if (str != null) { return rewrite.createStringPlaceholder(str, node.getNodeType()); } return ASTNode.copySubtree(rewrite.getAST(), node); } return rewrite.createMoveTarget(node); } /**
protected static ASTNode moveNode(CompilationUnitRewrite cuRewrite, ASTNode node) { ASTRewrite rewrite= cuRewrite.getASTRewrite(); if (rewrite.getAST() != node.getAST()) { String str= ASTNodes.getNodeSource(node, true, true); if (str != null) { return rewrite.createStringPlaceholder(str, node.getNodeType()); } return ASTNode.copySubtree(rewrite.getAST(), node); } return rewrite.createMoveTarget(node); } /**
private void copyTypeToDestination(IType type, CompilationUnitRewrite targetRewriter, CompilationUnit sourceCuNode, CompilationUnit targetCuNode) throws JavaModelException { AbstractTypeDeclaration newType= (AbstractTypeDeclaration) targetRewriter.getASTRewrite().createStringPlaceholder(getUnindentedSource(type), ASTNode.TYPE_DECLARATION); IType enclosingType= getEnclosingType(getJavaElementDestination()); if (enclosingType != null) { copyMemberToDestination(type, targetRewriter, sourceCuNode, targetCuNode, newType); } else { targetRewriter.getASTRewrite().getListRewrite(targetCuNode, CompilationUnit.TYPES_PROPERTY).insertLast(newType, null); } }