use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration in project intellij-community by JetBrains.
the class GrIntroduceFieldProcessor method getAnchorForDeclaration.
@Nullable
private static PsiElement getAnchorForDeclaration(@NotNull GrTypeDefinition targetClass) {
final GrTypeDefinitionBody body = targetClass.getBody();
if (body == null)
return null;
PsiElement anchor = body.getLBrace();
final GrMembersDeclaration[] declarations = targetClass.getMemberDeclarations();
for (GrMembersDeclaration declaration : declarations) {
if (declaration instanceof GrVariableDeclaration)
anchor = declaration;
if (!(declaration instanceof GrVariableDeclaration))
return anchor;
}
return anchor;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration in project intellij-community by JetBrains.
the class GrDocCommentUtil method findDocOwner.
@Nullable
public static GrDocCommentOwner findDocOwner(GroovyDocPsiElement docElement) {
PsiElement element = docElement;
while (element != null && element.getParent() instanceof GroovyDocPsiElement) element = element.getParent();
if (element == null)
return null;
element = skipWhiteSpacesAndStopOnDoc(element, true);
if (element instanceof GrDocCommentOwner)
return (GrDocCommentOwner) element;
if (element instanceof GrMembersDeclaration) {
GrMember[] members = ((GrMembersDeclaration) element).getMembers();
if (members.length > 0 && members[0] instanceof GrDocCommentOwner) {
return (GrDocCommentOwner) members[0];
}
}
return null;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.members.GrMembersDeclaration in project intellij-community by JetBrains.
the class ClassGenerator method writeMembers.
public void writeMembers(StringBuilder text, PsiClass typeDefinition) {
if (typeDefinition instanceof GrEnumTypeDefinition) {
final GrEnumConstant[] enumConstants = ((GrEnumTypeDefinition) typeDefinition).getEnumConstants();
for (GrEnumConstant constant : enumConstants) {
classItemGenerator.writeEnumConstant(text, constant);
text.append(',');
}
if (enumConstants.length > 0) {
//text.removeFromTheEnd(1).append(";\n");
text.delete(text.length() - 1, text.length());
}
text.append(";\n");
}
writeAllMethods(text, classItemGenerator.collectMethods(typeDefinition), typeDefinition);
if (typeDefinition instanceof GrTypeDefinition) {
for (GrMembersDeclaration declaration : ((GrTypeDefinition) typeDefinition).getMemberDeclarations()) {
if (declaration instanceof GrVariableDeclaration) {
classItemGenerator.writeVariableDeclarations(text, (GrVariableDeclaration) declaration);
}
}
for (PsiClass inner : typeDefinition.getInnerClasses()) {
writeTypeDefinition(text, inner, false, false);
text.append('\n');
}
}
classItemGenerator.writePostponed(text, typeDefinition);
}
Aggregations