本文整理汇总了Java中org.eclipse.jdt.core.dom.rewrite.ASTRewrite.remove方法的典型用法代码示例。如果您正苦于以下问题:Java ASTRewrite.remove方法的具体用法?Java ASTRewrite.remove怎么用?Java ASTRewrite.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.dom.rewrite.ASTRewrite
的用法示例。
在下文中一共展示了ASTRewrite.remove方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: rewriteAST
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; //导入方法依赖的package包/类
@Override
public void rewriteAST(CompilationUnitRewrite cuRewrite, LinkedProposalModel linkedModel) throws CoreException {
ASTRewrite rewrite= cuRewrite.getASTRewrite();
IBinding binding= fUnusedName.resolveBinding();
CompilationUnit root= (CompilationUnit) fUnusedName.getRoot();
String displayString= FixMessages.UnusedCodeFix_RemoveUnusedTypeParameter_description;
TextEditGroup group= createTextEditGroup(displayString, cuRewrite);
if (binding.getKind() == IBinding.TYPE) {
ITypeBinding decl= ((ITypeBinding) binding).getTypeDeclaration();
ASTNode declaration= root.findDeclaringNode(decl);
if (declaration.getParent() instanceof TypeDeclarationStatement) {
declaration= declaration.getParent();
}
rewrite.remove(declaration, group);
}
}
示例2: splitUpDeclarations
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; //导入方法依赖的package包/类
private void splitUpDeclarations(ASTRewrite rewrite, TextEditGroup group, VariableDeclarationFragment frag, VariableDeclarationStatement originalStatement, List<Expression> sideEffects) {
if (sideEffects.size() > 0) {
ListRewrite statementRewrite= rewrite.getListRewrite(originalStatement.getParent(), (ChildListPropertyDescriptor) originalStatement.getLocationInParent());
Statement previousStatement= originalStatement;
for (int i= 0; i < sideEffects.size(); i++) {
Expression sideEffect= sideEffects.get(i);
Expression movedInit= (Expression) rewrite.createMoveTarget(sideEffect);
ExpressionStatement wrapped= rewrite.getAST().newExpressionStatement(movedInit);
statementRewrite.insertAfter(wrapped, previousStatement, group);
previousStatement= wrapped;
}
VariableDeclarationStatement newDeclaration= null;
List<VariableDeclarationFragment> fragments= originalStatement.fragments();
int fragIndex= fragments.indexOf(frag);
ListIterator<VariableDeclarationFragment> fragmentIterator= fragments.listIterator(fragIndex+1);
while (fragmentIterator.hasNext()) {
VariableDeclarationFragment currentFragment= fragmentIterator.next();
VariableDeclarationFragment movedFragment= (VariableDeclarationFragment) rewrite.createMoveTarget(currentFragment);
if (newDeclaration == null) {
newDeclaration= rewrite.getAST().newVariableDeclarationStatement(movedFragment);
Type copiedType= (Type) rewrite.createCopyTarget(originalStatement.getType());
newDeclaration.setType(copiedType);
} else {
newDeclaration.fragments().add(movedFragment);
}
}
if (newDeclaration != null){
statementRewrite.insertAfter(newDeclaration, previousStatement, group);
if (originalStatement.fragments().size() == newDeclaration.fragments().size() + 1){
rewrite.remove(originalStatement, group);
}
}
}
}
示例3: getRemoveJavadocTagProposals
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; //导入方法依赖的package包/类
public static void getRemoveJavadocTagProposals(IInvocationContext context, IProblemLocation problem,
Collection<CUCorrectionProposal> proposals) {
ASTNode node= problem.getCoveringNode(context.getASTRoot());
while (node != null && !(node instanceof TagElement)) {
node= node.getParent();
}
if (node == null) {
return;
}
ASTRewrite rewrite= ASTRewrite.create(node.getAST());
rewrite.remove(node, null);
String label= CorrectionMessages.JavadocTagsSubProcessor_removetag_description;
proposals.add(new ASTRewriteCorrectionProposal(label, context.getCompilationUnit(), rewrite,
IProposalRelevance.REMOVE_TAG));
}
示例4: removeStatement
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; //导入方法依赖的package包/类
private void removeStatement(ASTRewrite rewrite, ASTNode statementNode, TextEditGroup group) {
if (ASTNodes.isControlStatementBody(statementNode.getLocationInParent())) {
rewrite.replace(statementNode, rewrite.getAST().newBlock(), group);
} else {
rewrite.remove(statementNode, group);
}
}
示例5: createChange
import org.eclipse.jdt.core.dom.rewrite.ASTRewrite; //导入方法依赖的package包/类
@Override
public CompilationUnitChange createChange(IProgressMonitor progressMonitor) throws CoreException {
final CompilationUnitChange change = new CompilationUnitChange("Remove unnecessary visibility modifiers",
_context.getCompilationUnit());
final AST ast = _context.getAST().getAST();
final ASTRewrite rewriter = ASTRewrite.create(ast);
for (final ASTNode node : _annotationsToRemove) {
rewriter.remove(node, null);
}
addAnnotation(ast, rewriter, "ParametersAreNonnullByDefault", _nodesToAnnotateWithParameterAreNonnullByDefault);
addAnnotation(ast, rewriter, "ReturnValuesAreNonnullByDefault",
_nodesToAnnotateWithReturnValuesAreNonnullByDefault);
change.setEdit(rewriter.rewriteAST());
final boolean addImportForParameters = !_nodesToAnnotateWithParameterAreNonnullByDefault.isEmpty();
final boolean addImportForReturns = !_nodesToAnnotateWithReturnValuesAreNonnullByDefault.isEmpty();
if (addImportForParameters || addImportForReturns) {
final ImportRewrite importRewrite = createImportRewriterWithProjectSettings();
if (addImportForParameters) {
importRewrite.addImport(Jsr305CleanUp.FQN_PARAMETERS_ARE_NONNULL_BY_DEFAULT);
}
if (addImportForReturns) {
importRewrite.addImport(Jsr305CleanUp.FQN_RETURN_VALUES_ARE_NONNULL_BY_DEFAULT);
}
change.addEdit(importRewrite.rewriteImports(progressMonitor));
}
return change;
}