use of com.intellij.psi.impl.light.LightVariableBuilder in project intellij-community by JetBrains.
the class GantMemberContributor method processDynamicElements.
@Override
public void processDynamicElements(@NotNull PsiType qualifierType, PsiClass aClass, @NotNull PsiScopeProcessor processor, @NotNull PsiElement place, @NotNull ResolveState state) {
if (aClass != null && ClassUtil.getSuperClassesWithCache(aClass).containsKey("groovy.util.AntBuilder")) {
processAntTasks(processor, place, state);
return;
}
if (!(place instanceof GrReferenceExpression) || ((GrReferenceExpression) place).isQualified()) {
return;
}
GrClosableBlock closure = PsiTreeUtil.getContextOfType(place, GrClosableBlock.class, true);
boolean antTasksProcessed = false;
while (closure != null) {
final PsiElement parent = closure.getParent();
if (parent instanceof GrMethodCall) {
final PsiMethod method = ((GrMethodCall) parent).resolveMethod();
if (method instanceof AntBuilderMethod) {
antTasksProcessed = true;
if (!processAntTasks(processor, place, state)) {
return;
}
if (!((AntBuilderMethod) method).processNestedElements(processor)) {
return;
}
break;
}
}
closure = PsiTreeUtil.getContextOfType(closure, GrClosableBlock.class, true);
}
// ------- gant-specific
PsiFile file = place.getContainingFile();
if (file == null || !GroovyScriptUtil.isSpecificScriptFile(file, GantScriptType.INSTANCE)) {
return;
}
if (aClass instanceof GroovyScriptClass) {
for (GrArgumentLabel label : GantUtils.getScriptTargets((GroovyFile) file)) {
final String targetName = label.getName();
if (targetName != null) {
final PsiNamedElement variable = new LightVariableBuilder(targetName, GroovyCommonClassNames.GROOVY_LANG_CLOSURE, label).setBaseIcon(JetgroovyIcons.Groovy.Gant_target);
if (!ResolveUtil.processElement(processor, variable, state)) {
return;
}
}
}
}
if (!antTasksProcessed) {
processAntTasks(processor, place, state);
}
}
Aggregations