use of org.eclipse.jdt.core.dom.Modifier in project sts4 by spring-projects.
the class BeansSymbolProvider method isMethodAbstract.
private boolean isMethodAbstract(Annotation node) {
if (node != null && node.getParent() != null && node.getParent() instanceof MethodDeclaration) {
MethodDeclaration method = (MethodDeclaration) node.getParent();
List<?> modifiers = method.modifiers();
for (Object modifier : modifiers) {
if (modifier instanceof Modifier && ((Modifier) modifier).isAbstract()) {
return true;
}
}
}
return false;
}
use of org.eclipse.jdt.core.dom.Modifier in project xtext-xtend by eclipse.
the class JavaASTFlattener method visit.
@Override
public boolean visit(final EnumDeclaration node) {
Javadoc _javadoc = node.getJavadoc();
boolean _tripleNotEquals = (_javadoc != null);
if (_tripleNotEquals) {
node.getJavadoc().accept(this);
}
this.appendModifiers(node, node.modifiers());
boolean _isPackageVisibility = this._aSTFlattenerUtils.isPackageVisibility(Iterables.<Modifier>filter(node.modifiers(), Modifier.class));
if (_isPackageVisibility) {
this.appendToBuffer("package ");
}
this.appendToBuffer("enum ");
node.getName().accept(this);
this.appendSpaceToBuffer();
boolean _isEmpty = node.superInterfaceTypes().isEmpty();
boolean _not = (!_isEmpty);
if (_not) {
this.addProblem(node, "Enum cannot have a supertype");
this.appendToBuffer("implements ");
this.visitAllSeparatedByComma(node.superInterfaceTypes());
this.appendSpaceToBuffer();
}
this.appendToBuffer("{");
this.increaseIndent();
this.appendLineWrapToBuffer();
this.visitAllSeparatedByComma(node.enumConstants());
boolean _isEmpty_1 = node.bodyDeclarations().isEmpty();
boolean _not_1 = (!_isEmpty_1);
if (_not_1) {
this.addProblem(node, "Enum cannot have any body declaration statements");
this.appendToBuffer(";");
this.appendLineWrapToBuffer();
this.visitAll(node.bodyDeclarations());
}
this.decreaseIndent();
this.appendToBuffer("}");
return false;
}
use of org.eclipse.jdt.core.dom.Modifier in project xtext-xtend by eclipse.
the class JavaASTFlattener method visit.
@Override
public boolean visit(final MethodDeclaration it) {
Javadoc _javadoc = it.getJavadoc();
boolean _tripleNotEquals = (_javadoc != null);
if (_tripleNotEquals) {
it.getJavadoc().accept(this);
}
final Function1<ASTNode, StringBuffer> _function = (ASTNode node) -> {
StringBuffer _xifexpression = null;
if ((node instanceof MethodDeclaration)) {
StringBuffer _xifexpression_1 = null;
boolean _isConstructor = ((MethodDeclaration) node).isConstructor();
boolean _not = (!_isConstructor);
if (_not) {
StringBuffer _xifexpression_2 = null;
boolean _isOverrideMethod = this._aSTFlattenerUtils.isOverrideMethod(((MethodDeclaration) node));
if (_isOverrideMethod) {
_xifexpression_2 = this.appendToBuffer("override ");
} else {
_xifexpression_2 = this.appendToBuffer("def ");
}
_xifexpression_1 = _xifexpression_2;
}
_xifexpression = _xifexpression_1;
}
return _xifexpression;
};
final Function1<ASTNode, StringBuffer> afterAnnotationProcessingCallback = _function;
this.appendModifiers(it, it.modifiers(), afterAnnotationProcessingCallback);
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 ");
}
}
}
boolean _isConstructor = it.isConstructor();
if (_isConstructor) {
this.appendToBuffer(" new");
}
boolean _isEmpty = it.typeParameters().isEmpty();
boolean _not_1 = (!_isEmpty);
if (_not_1) {
boolean _isConstructor_1 = it.isConstructor();
if (_isConstructor_1) {
this.addProblem(it, "Type parameters for constructors are not supported");
}
this.appendTypeParameters(it.typeParameters());
}
boolean _isConstructor_2 = it.isConstructor();
boolean _not_2 = (!_isConstructor_2);
if (_not_2) {
Type _returnType2 = it.getReturnType2();
boolean _tripleNotEquals_1 = (_returnType2 != null);
if (_tripleNotEquals_1) {
it.getReturnType2().accept(this);
} else {
this.appendToBuffer("void");
}
this.appendSpaceToBuffer();
it.getName().accept(this);
}
this.appendToBuffer("(");
final Consumer<SingleVariableDeclaration> _function_1 = (SingleVariableDeclaration p) -> {
Boolean _isAssignedInBody = this._aSTFlattenerUtils.isAssignedInBody(it.getBody(), p.getName());
if ((_isAssignedInBody).booleanValue()) {
if ((it.isConstructor() && (!it.getBody().statements().isEmpty()))) {
final Expression firstInBody = IterableExtensions.<Expression>head(this._aSTFlattenerUtils.findAssignmentsInBlock(it.getBody(), p));
if ((firstInBody != null)) {
ConstructorInvocation _findParentOfType = this._aSTFlattenerUtils.<ConstructorInvocation>findParentOfType(firstInBody, ConstructorInvocation.class);
boolean _tripleNotEquals_2 = (_findParentOfType != null);
if (_tripleNotEquals_2) {
this.addProblem(p, "Final parameter modified in constructor call");
} else {
SuperConstructorInvocation _findParentOfType_1 = this._aSTFlattenerUtils.<SuperConstructorInvocation>findParentOfType(firstInBody, SuperConstructorInvocation.class);
boolean _tripleNotEquals_3 = (_findParentOfType_1 != null);
if (_tripleNotEquals_3) {
this.addProblem(p, "Final parameter modified in super constructor call");
}
}
}
}
final VariableDeclarationFragment varFrag = p.getAST().newVariableDeclarationFragment();
varFrag.setName(p.getAST().newSimpleName(p.getName().toString()));
AST _aST = p.getAST();
SimpleName _name = p.getName();
String _plus = (_name + "_finalParam_");
p.setName(_aST.newSimpleName(_plus));
varFrag.setInitializer(p.getAST().newSimpleName(p.getName().toString()));
final VariableDeclarationStatement varDecl = p.getAST().newVariableDeclarationStatement(varFrag);
ASTNode _createInstance = p.getAST().createInstance(SimpleType.class);
final Type typeCopy = ((Type) _createInstance);
varDecl.setType(typeCopy);
it.getBody().statements().add(0, varDecl);
}
};
ListExtensions.<SingleVariableDeclaration>reverseView(it.parameters()).forEach(_function_1);
this.visitAllSeparatedByComma(it.parameters());
this.appendToBuffer(")");
this.appendExtraDimensions(it.getExtraDimensions());
List<? extends ASTNode> throwsTypes = CollectionLiterals.<ASTNode>newArrayList();
boolean _java8orHigher = this.java8orHigher();
boolean _not_3 = (!_java8orHigher);
if (_not_3) {
throwsTypes = it.thrownExceptions();
} else {
throwsTypes = this._aSTFlattenerUtils.genericChildListProperty(it, "thrownExceptionTypes");
}
boolean _isEmpty_1 = throwsTypes.isEmpty();
boolean _not_4 = (!_isEmpty_1);
if (_not_4) {
this.appendToBuffer(" throws ");
this.visitAllSeparatedByComma(throwsTypes);
}
this.appendSpaceToBuffer();
Block _body = it.getBody();
boolean _tripleNotEquals_2 = (_body != null);
if (_tripleNotEquals_2) {
it.getBody().accept(this);
} else {
this.appendLineWrapToBuffer();
}
return false;
}
use of org.eclipse.jdt.core.dom.Modifier in project AutoRefactor by JnRouvignac.
the class StaticConstantRatherThanInstanceConstantCleanUp method visit.
@Override
public boolean visit(final FieldDeclaration visited) {
if (visited.getType().isPrimitiveType() || ASTNodes.hasType(visited.getType().resolveBinding(), Byte.class.getCanonicalName(), Character.class.getCanonicalName(), Short.class.getCanonicalName(), Integer.class.getCanonicalName(), Long.class.getCanonicalName(), Boolean.class.getCanonicalName(), Float.class.getCanonicalName(), Double.class.getCanonicalName(), String.class.getCanonicalName())) {
Modifier finalModifier = null;
Collection<IExtendedModifier> modifiers = visited.modifiers();
for (Modifier modifier : getModifiersOnly(modifiers)) {
if (modifier.isStatic()) {
return true;
}
if (modifier.isFinal()) {
finalModifier = modifier;
}
}
if (finalModifier != null && visited.fragments() != null && visited.fragments().size() == 1) {
Expression initializer = ((VariableDeclarationFragment) visited.fragments().get(0)).getInitializer();
if (ASTNodes.isHardCoded(initializer)) {
addStaticModifier(finalModifier);
return false;
}
}
}
return true;
}
use of org.eclipse.jdt.core.dom.Modifier in project AutoRefactor by JnRouvignac.
the class ObsoleteRedundantModifiersCleanUp method removeFinalModifier.
private boolean removeFinalModifier(final List<IExtendedModifier> modifiers) {
boolean result = true;
for (Modifier modifier : getModifiersOnly(modifiers)) {
if (modifier.isFinal()) {
TextEditGroup group = new TextEditGroup(MultiFixMessages.ObsoleteRedundantModifiersCleanUp_description);
ASTRewrite rewrite = cuRewrite.getASTRewrite();
rewrite.remove(modifier, group);
result = false;
}
}
return result;
}
Aggregations