use of org.eclipse.jdt.core.dom.FieldDeclaration in project xtext-xtend by eclipse.
the class JavaASTFlattener method visit.
@Override
public boolean visit(final Initializer it) {
Javadoc _javadoc = it.getJavadoc();
boolean _tripleNotEquals = (_javadoc != null);
if (_tripleNotEquals) {
it.getJavadoc().accept(this);
}
this.appendModifiers(it, it.modifiers());
boolean _isStatic = this._aSTFlattenerUtils.isStatic(it.modifiers());
if (_isStatic) {
if (((it.getParent() instanceof TypeDeclaration) && IterableExtensions.<FieldDeclaration>forall(IterableExtensions.<FieldDeclaration>filter(((Iterable<FieldDeclaration>) Conversions.doWrapArray(((TypeDeclaration) it.getParent()).getFields())), ((Function1<FieldDeclaration, Boolean>) (FieldDeclaration it_1) -> {
return Boolean.valueOf((this._aSTFlattenerUtils.isStatic(it_1.modifiers()) && this._aSTFlattenerUtils.isFinal(it_1.modifiers())));
})), ((Function1<FieldDeclaration, Boolean>) (FieldDeclaration f) -> {
final Function1<VariableDeclarationFragment, Boolean> _function = (VariableDeclarationFragment fragment) -> {
Boolean _isAssignedInBody = this._aSTFlattenerUtils.isAssignedInBody(it.getBody(), fragment);
return Boolean.valueOf((!(_isAssignedInBody).booleanValue()));
};
return Boolean.valueOf(IterableExtensions.<VariableDeclarationFragment>forall(f.fragments(), _function));
})))) {
this.appendToBuffer(" final Void static_initializer = {");
this.appendLineWrapToBuffer();
it.getBody().accept(this);
this.appendToBuffer("null }");
this.appendLineWrapToBuffer();
} else {
this.addProblem(it, "Static initializer is not fully supported");
this.appendToBuffer("{/*FIXME ");
it.getBody().accept(this);
this.appendToBuffer("*/}");
}
} else {
ASTNode _parent = it.getParent();
if ((_parent instanceof AnonymousClassDeclaration)) {
StringConcatenation _builder = new StringConcatenation();
_builder.append("Initializer is not supported in ");
String _simpleName = ASTNode.nodeClassForType(it.getParent().getNodeType()).getSimpleName();
_builder.append(_simpleName);
this.addProblem(it, _builder.toString());
}
it.getBody().accept(this);
}
return false;
}
use of org.eclipse.jdt.core.dom.FieldDeclaration in project AutoRefactor by JnRouvignac.
the class ASTBuilder method declareField.
/**
* Builds a new {@link FieldDeclaration} instance.
*
* @param type
* the declared variable type
* @param fragment
* the variable declaration fragment
* @return a new field declaration
*/
public FieldDeclaration declareField(Type type, VariableDeclarationFragment fragment) {
final FieldDeclaration fd = ast.newFieldDeclaration(fragment);
fd.setType(type);
return fd;
}
use of org.eclipse.jdt.core.dom.FieldDeclaration in project eclipse-pmd by acanda.
the class SingularFieldQuickFix method updateFieldDeclaration.
/**
* Updates the field declaration. If the replaced field was the only fragment, the entire field declaration is
* removed. Otherwise the field declaration stays and only the respective fragment is removed.
*/
private void updateFieldDeclaration(final VariableDeclarationFragment node) {
final FieldDeclaration fieldDeclaration = (FieldDeclaration) node.getParent();
@SuppressWarnings("unchecked") final List<VariableDeclarationFragment> fragments = fieldDeclaration.fragments();
if (fragments.size() > 1) {
for (final VariableDeclarationFragment fragment : fragments) {
if (fragment.getName().getIdentifier().equals(node.getName().getIdentifier())) {
fragment.delete();
}
}
} else {
fieldDeclaration.delete();
}
}
Aggregations