use of org.jetbrains.plugins.groovy.dsl.holders.NonCodeMembersHolder in project intellij-community by JetBrains.
the class GroovyDslDefaultMembers method add.
/**
* Add a member to a context's ctype
*/
public PsiMember add(PsiMember member, GdslMembersHolderConsumer consumer) {
final NonCodeMembersHolder holder = new NonCodeMembersHolder();
holder.addDeclaration(member);
consumer.addMemberHolder(holder);
return member;
}
use of org.jetbrains.plugins.groovy.dsl.holders.NonCodeMembersHolder in project intellij-community by JetBrains.
the class GroovyDslDefaultMembers method delegatesTo.
/**
* **********************************************************************************
* Methods and properties of the GroovyDSL language
* **********************************************************************************
*/
public void delegatesTo(@Nullable PsiElement elem, GdslMembersHolderConsumer consumer) {
if (elem instanceof PsiClass) {
final PsiClass clazz = (PsiClass) elem;
final NonCodeMembersHolder holder = new NonCodeMembersHolder();
if (clazz instanceof GrTypeDefinition) {
final PsiClassType type = JavaPsiFacade.getElementFactory(consumer.getProject()).createType(clazz);
final ResolverProcessor processor = CompletionProcessor.createPropertyCompletionProcessor(clazz);
final GroovyPsiElement context = (GroovyPsiElement) clazz;
ResolveUtil.processAllDeclarations(type, processor, ResolveState.initial(), context);
for (GroovyResolveResult result : processor.getCandidates()) {
final PsiElement element = result.getElement();
if (element instanceof PsiMethod && !((PsiMethod) element).isConstructor() || element instanceof PsiField) {
holder.addDeclaration(element);
}
}
} else {
for (PsiMethod method : clazz.getAllMethods()) {
if (!method.isConstructor())
holder.addDeclaration(method);
}
for (PsiField field : clazz.getAllFields()) {
holder.addDeclaration(field);
}
}
consumer.addMemberHolder(holder);
} else if (elem instanceof GrExpression) {
GrExpression expr = (GrExpression) elem;
final PsiType type = expr.getType();
if (type instanceof PsiClassType) {
PsiClassType ctype = (PsiClassType) type;
delegatesTo(ctype.resolve(), consumer);
}
}
}
Aggregations