use of org.eclipse.jdt.core.dom.AbstractTypeDeclaration in project che by eclipse.
the class PromoteTempToFieldRefactoring method getNamesOfFieldsInDeclaringType.
private String[] getNamesOfFieldsInDeclaringType() {
final AbstractTypeDeclaration type = getEnclosingType();
if (type instanceof TypeDeclaration) {
FieldDeclaration[] fields = ((TypeDeclaration) type).getFields();
List<String> result = new ArrayList<String>(fields.length);
for (int i = 0; i < fields.length; i++) {
for (Iterator<VariableDeclarationFragment> iter = fields[i].fragments().iterator(); iter.hasNext(); ) {
VariableDeclarationFragment field = iter.next();
result.add(field.getName().getIdentifier());
}
}
return result.toArray(new String[result.size()]);
}
return new String[] {};
}
use of org.eclipse.jdt.core.dom.AbstractTypeDeclaration in project che by eclipse.
the class JavaTextSelection method resolveInClassInitializer.
public boolean resolveInClassInitializer() {
if (fInClassInitializerRequested)
return fInClassInitializer;
fInClassInitializerRequested = true;
resolveSelectedNodes();
ASTNode node = getStartNode();
if (node == null) {
fInClassInitializer = true;
} else {
while (node != null) {
int nodeType = node.getNodeType();
if (node instanceof AbstractTypeDeclaration) {
fInClassInitializer = false;
break;
} else if (nodeType == ASTNode.ANONYMOUS_CLASS_DECLARATION) {
fInClassInitializer = false;
break;
} else if (nodeType == ASTNode.INITIALIZER) {
fInClassInitializer = true;
break;
}
node = node.getParent();
}
}
return fInClassInitializer;
}
use of org.eclipse.jdt.core.dom.AbstractTypeDeclaration in project che by eclipse.
the class JavaTextSelection method resolveInVariableInitializer.
public boolean resolveInVariableInitializer() {
if (fInVariableInitializerRequested)
return fInVariableInitializer;
fInVariableInitializerRequested = true;
resolveSelectedNodes();
ASTNode node = getStartNode();
ASTNode last = null;
while (node != null) {
int nodeType = node.getNodeType();
if (node instanceof AbstractTypeDeclaration) {
fInVariableInitializer = false;
break;
} else if (nodeType == ASTNode.ANONYMOUS_CLASS_DECLARATION) {
fInVariableInitializer = false;
break;
} else if (nodeType == ASTNode.VARIABLE_DECLARATION_FRAGMENT && ((VariableDeclarationFragment) node).getInitializer() == last) {
fInVariableInitializer = true;
break;
} else if (nodeType == ASTNode.SINGLE_VARIABLE_DECLARATION && ((SingleVariableDeclaration) node).getInitializer() == last) {
fInVariableInitializer = true;
break;
} else if (nodeType == ASTNode.ANNOTATION_TYPE_MEMBER_DECLARATION && ((AnnotationTypeMemberDeclaration) node).getDefault() == last) {
fInVariableInitializer = true;
break;
}
last = node;
node = node.getParent();
}
return fInVariableInitializer;
}
use of org.eclipse.jdt.core.dom.AbstractTypeDeclaration in project che by eclipse.
the class JavadocContentAccess2 method getJavadocNode.
private static Javadoc getJavadocNode(IJavaElement element, String rawJavadoc) {
//FIXME: take from SharedASTProvider if available
//Caveat: Javadoc nodes are not available when Javadoc processing has been disabled!
//https://bugs.eclipse.org/bugs/show_bug.cgi?id=212207
//$NON-NLS-1$
String source = rawJavadoc + "class C{}";
CompilationUnit root = createAST(element, source);
if (root == null)
return null;
List<AbstractTypeDeclaration> types = root.types();
if (types.size() != 1)
return null;
AbstractTypeDeclaration type = types.get(0);
return type.getJavadoc();
}
use of org.eclipse.jdt.core.dom.AbstractTypeDeclaration in project che by eclipse.
the class DelegateCreator method getTypeBodyDeclarationsProperty.
private ChildListPropertyDescriptor getTypeBodyDeclarationsProperty() {
ASTNode parent = fDeclaration.getParent();
if (parent instanceof AbstractTypeDeclaration)
return ((AbstractTypeDeclaration) parent).getBodyDeclarationsProperty();
else if (parent instanceof AnonymousClassDeclaration)
return AnonymousClassDeclaration.BODY_DECLARATIONS_PROPERTY;
Assert.isTrue(false);
return null;
}
Aggregations