use of org.eclipse.text.edits.TextEditGroup in project che by eclipse.
the class AccessAnalyzer method createGroupDescription.
private TextEditGroup createGroupDescription(String name) {
TextEditGroup result = new TextEditGroup(name);
fGroupDescriptions.add(result);
return result;
}
use of org.eclipse.text.edits.TextEditGroup in project che by eclipse.
the class SelfEncapsulateFieldRefactoring method addGetterSetterChanges.
private List<TextEditGroup> addGetterSetterChanges(CompilationUnit root, ASTRewrite rewriter, String lineDelimiter, boolean usingLocalSetter, boolean usingLocalGetter) throws CoreException {
List<TextEditGroup> result = new ArrayList<TextEditGroup>(2);
AST ast = root.getAST();
FieldDeclaration decl = (FieldDeclaration) ASTNodes.getParent(fFieldDeclaration, ASTNode.FIELD_DECLARATION);
int position = 0;
int numberOfMethods = 0;
List<BodyDeclaration> members = ASTNodes.getBodyDeclarations(decl.getParent());
for (Iterator<BodyDeclaration> iter = members.iterator(); iter.hasNext(); ) {
BodyDeclaration element = iter.next();
if (element.getNodeType() == ASTNode.METHOD_DECLARATION) {
if (fInsertionIndex == -1) {
break;
} else if (fInsertionIndex == numberOfMethods) {
position++;
break;
}
numberOfMethods++;
}
position++;
}
TextEditGroup description;
ListRewrite rewrite = fRewriter.getListRewrite(decl.getParent(), getBodyDeclarationsProperty(decl.getParent()));
if (!usingLocalGetter) {
description = new TextEditGroup(RefactoringCoreMessages.SelfEncapsulateField_add_getter);
result.add(description);
rewrite.insertAt(createGetterMethod(ast, rewriter, lineDelimiter), position++, description);
}
if (!JdtFlags.isFinal(fField) && !usingLocalSetter) {
description = new TextEditGroup(RefactoringCoreMessages.SelfEncapsulateField_add_setter);
result.add(description);
rewrite.insertAt(createSetterMethod(ast, rewriter, lineDelimiter), position, description);
}
if (!JdtFlags.isPrivate(fField))
result.add(makeDeclarationPrivate(rewriter, decl));
return result;
}
use of org.eclipse.text.edits.TextEditGroup in project che by eclipse.
the class SelfEncapsulateFieldRefactoring method makeDeclarationPrivate.
private TextEditGroup makeDeclarationPrivate(ASTRewrite rewriter, FieldDeclaration decl) {
TextEditGroup description = new TextEditGroup(RefactoringCoreMessages.SelfEncapsulateField_change_visibility);
VariableDeclarationFragment[] vdfs = new VariableDeclarationFragment[] { fFieldDeclaration };
int includedModifiers = Modifier.PRIVATE;
int excludedModifiers = Modifier.PROTECTED | Modifier.PUBLIC;
VariableDeclarationRewrite.rewriteModifiers(decl, vdfs, includedModifiers, excludedModifiers, rewriter, description);
return description;
}
use of org.eclipse.text.edits.TextEditGroup in project che by eclipse.
the class ChangeSignatureProcessor method addExplicitSuperConstructorCall.
private void addExplicitSuperConstructorCall(MethodDeclaration constructor, CompilationUnitRewrite cuRewrite) {
SuperConstructorInvocation superCall = constructor.getAST().newSuperConstructorInvocation();
addArgumentsToNewSuperConstructorCall(superCall, cuRewrite);
String msg = RefactoringCoreMessages.ChangeSignatureRefactoring_add_super_call;
TextEditGroup description = cuRewrite.createGroupDescription(msg);
cuRewrite.getASTRewrite().getListRewrite(constructor.getBody(), Block.STATEMENTS_PROPERTY).insertFirst(superCall, description);
}
use of org.eclipse.text.edits.TextEditGroup in project che by eclipse.
the class TextChangeCompatibility method addTextEdit.
public static void addTextEdit(TextChange change, String name, TextEdit edit) throws MalformedTreeException {
Assert.isNotNull(change);
Assert.isNotNull(name);
Assert.isNotNull(edit);
TextEdit root = change.getEdit();
if (root == null) {
root = new MultiTextEdit();
change.setEdit(root);
}
insert(root, edit);
change.addTextEditGroup(new TextEditGroup(name, edit));
}
Aggregations