use of org.eclipse.jdt.core.dom.Modifier in project AutoRefactor by JnRouvignac.
the class ObsoleteRedundantModifiersCleanUp method maybeRemovePublicStaticFinalModifiers.
private boolean maybeRemovePublicStaticFinalModifiers(final FieldDeclaration visited) {
// Remove modifiers implied by the context
boolean result = true;
List<IExtendedModifier> modifiers = visited.modifiers();
for (Modifier modifier : getModifiersOnly(modifiers)) {
if (modifier.isPublic() || modifier.isStatic() || modifier.isFinal()) {
TextEditGroup group = new TextEditGroup(MultiFixMessages.ObsoleteRedundantModifiersCleanUp_description);
ASTRewrite rewrite = cuRewrite.getASTRewrite();
rewrite.remove(modifier, group);
result = false;
}
}
return result;
}
use of org.eclipse.jdt.core.dom.Modifier in project AutoRefactor by JnRouvignac.
the class ObsoleteRedundantModifiersCleanUp method removeStaticAbstractModifier.
private boolean removeStaticAbstractModifier(final List<IExtendedModifier> modifiers) {
boolean result = true;
for (Modifier modifier : getModifiersOnly(modifiers)) {
if (modifier.isStatic() || modifier.isAbstract()) {
TextEditGroup group = new TextEditGroup(MultiFixMessages.ObsoleteRedundantModifiersCleanUp_description);
ASTRewrite rewrite = cuRewrite.getASTRewrite();
rewrite.remove(modifier, group);
result = false;
}
}
return result;
}
use of org.eclipse.jdt.core.dom.Modifier in project AutoRefactor by JnRouvignac.
the class ObsoleteRedundantModifiersCleanUp method reorderModifiers.
private void reorderModifiers(final List<IExtendedModifier> reorderedModifiers) {
ASTRewrite rewrite = cuRewrite.getASTRewrite();
TextEditGroup group = new TextEditGroup(MultiFixMessages.ObsoleteRedundantModifiersCleanUp_description);
for (int i = 0; i < reorderedModifiers.size(); i++) {
IExtendedModifier extendedModifier = reorderedModifiers.get(i);
if (extendedModifier.isModifier()) {
rewrite.moveToIndex((Modifier) extendedModifier, i, ASTNodes.createMoveTarget(rewrite, (Modifier) extendedModifier), group);
} else {
rewrite.moveToIndex((Annotation) extendedModifier, i, ASTNodes.createMoveTarget(rewrite, (Annotation) extendedModifier), group);
}
}
}
use of org.eclipse.jdt.core.dom.Modifier in project AutoRefactor by JnRouvignac.
the class ObsoleteRedundantModifiersCleanUp method removePublicAbstractModifiers.
private boolean removePublicAbstractModifiers(final BodyDeclaration visited) {
List<IExtendedModifier> modifiers = visited.modifiers();
boolean result = true;
for (Modifier modifier : getModifiersOnly(modifiers)) {
if (modifier.isPublic() || modifier.isAbstract()) {
TextEditGroup group = new TextEditGroup(MultiFixMessages.ObsoleteRedundantModifiersCleanUp_description);
ASTRewrite rewrite = cuRewrite.getASTRewrite();
rewrite.remove(modifier, group);
result = false;
}
}
return result;
}
use of org.eclipse.jdt.core.dom.Modifier in project xtext-xtend by eclipse.
the class JavaASTFlattener method visit.
@Override
public boolean visit(final FieldDeclaration it) {
Javadoc _javadoc = it.getJavadoc();
boolean _tripleNotEquals = (_javadoc != null);
if (_tripleNotEquals) {
it.getJavadoc().accept(this);
}
final Consumer<VariableDeclarationFragment> _function = (VariableDeclarationFragment frag) -> {
this.appendModifiers(it, it.modifiers());
boolean _isPackageVisibility = this._aSTFlattenerUtils.isPackageVisibility(Iterables.<Modifier>filter(it.modifiers(), Modifier.class));
if (_isPackageVisibility) {
ASTNode _parent = it.getParent();
if ((_parent instanceof TypeDeclaration)) {
ASTNode _parent_1 = it.getParent();
boolean _isInterface = ((TypeDeclaration) _parent_1).isInterface();
boolean _not = (!_isInterface);
if (_not) {
this.appendToBuffer("package ");
}
}
}
it.getType().accept(this);
this.appendExtraDimensions(frag.getExtraDimensions());
this.appendSpaceToBuffer();
frag.accept(this);
};
it.fragments().forEach(_function);
return false;
}
Aggregations