use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl in project intellij-community by JetBrains.
the class ResolverProcessorImpl method execute.
@Override
public boolean execute(@NotNull PsiElement element, @NotNull ResolveState state) {
if (element instanceof PsiLocalVariableImpl) {
// the debugger creates a Java code block context and our expressions to evaluate resolve there
return true;
}
if (myResolveTargetKinds == null || myResolveTargetKinds.contains(getDeclarationKind(element))) {
//don't check field for name because they can be aliased imported
if (element instanceof PsiVariable && !(element instanceof PsiField) && myName != null && !myName.equals(((PsiVariable) element).getName())) {
return true;
}
PsiNamedElement namedElement = (PsiNamedElement) element;
PsiSubstitutor substitutor = state.get(PsiSubstitutor.KEY);
if (substitutor == null)
substitutor = PsiSubstitutor.EMPTY;
if (myTypeArguments.length > 0 && namedElement instanceof PsiClass) {
substitutor = substitutor.putAll((PsiClass) namedElement, myTypeArguments);
}
if (namedElement instanceof PsiClass && !(namedElement instanceof PsiTypeParameter)) {
final PsiClass aClass = (PsiClass) namedElement;
if (myProcessedClasses == null)
myProcessedClasses = new HashSet<>();
if (!myProcessedClasses.add(aClass.getQualifiedName())) {
return true;
}
}
boolean isAccessible = isAccessible(namedElement);
final PsiElement resolveContext = state.get(RESOLVE_CONTEXT);
final SpreadState spreadState = state.get(SpreadState.SPREAD_STATE);
boolean isStaticsOK = isStaticsOK(namedElement, resolveContext, false);
addCandidate(new GroovyResolveResultImpl(namedElement, resolveContext, spreadState, substitutor, isAccessible, isStaticsOK));
return !(isAccessible && isStaticsOK);
}
return true;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl in project intellij-community by JetBrains.
the class GrDocParameterReferenceImpl method multiResolve.
@Override
@NotNull
public ResolveResult[] multiResolve(boolean incompleteCode) {
final String name = getName();
if (name == null)
return ResolveResult.EMPTY_ARRAY;
ArrayList<GroovyResolveResult> candidates = new ArrayList<>();
final PsiElement owner = GrDocCommentUtil.findDocOwner(this);
if (owner instanceof GrMethod) {
final GrMethod method = (GrMethod) owner;
final GrParameter[] parameters = method.getParameters();
for (GrParameter parameter : parameters) {
if (name.equals(parameter.getName())) {
candidates.add(new GroovyResolveResultImpl(parameter, true));
}
}
return candidates.toArray(new ResolveResult[candidates.size()]);
} else {
final PsiElement firstChild = getFirstChild();
if (owner instanceof GrTypeParameterListOwner && firstChild != null) {
final ASTNode node = firstChild.getNode();
if (node != null && GroovyDocTokenTypes.mGDOC_TAG_VALUE_LT.equals(node.getElementType())) {
final PsiTypeParameter[] typeParameters = ((PsiTypeParameterListOwner) owner).getTypeParameters();
for (PsiTypeParameter typeParameter : typeParameters) {
if (name.equals(typeParameter.getName())) {
candidates.add(new GroovyResolveResultImpl(typeParameter, true));
}
}
}
}
}
return ResolveResult.EMPTY_ARRAY;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl in project intellij-community by JetBrains.
the class GrAnnotationNameValuePairImpl method multiResolveFromAnnotationType.
private static GroovyResolveResult[] multiResolveFromAnnotationType(@NotNull PsiClass resolved, @NotNull String name) {
PsiMethod[] methods = resolved.findMethodsByName(name, false);
if (methods.length == 0)
return GroovyResolveResult.EMPTY_ARRAY;
final GroovyResolveResult[] results = new GroovyResolveResult[methods.length];
for (int i = 0; i < methods.length; i++) {
PsiMethod method = methods[i];
results[i] = new GroovyResolveResultImpl(method, true);
}
return results;
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl in project intellij-community by JetBrains.
the class AnnotationAttributeCompletionResultProcessor method process.
public void process(@NotNull Consumer<LookupElement> consumer, @NotNull PrefixMatcher matcher) {
GrCodeReferenceElement ref = myAnnotation.getClassReference();
PsiElement resolved = ref.resolve();
if (resolved instanceof PsiClass) {
final PsiAnnotation annotationCollector = GrAnnotationCollector.findAnnotationCollector((PsiClass) resolved);
if (annotationCollector != null) {
final ArrayList<GrAnnotation> annotations = ContainerUtil.newArrayList();
GrAnnotationCollector.collectAnnotations(annotations, myAnnotation, annotationCollector);
Set<String> usedNames = ContainerUtil.newHashSet();
for (GrAnnotation annotation : annotations) {
final PsiElement resolvedAliased = annotation.getClassReference().resolve();
if (resolvedAliased instanceof PsiClass && ((PsiClass) resolvedAliased).isAnnotationType()) {
for (PsiMethod method : ((PsiClass) resolvedAliased).getMethods()) {
if (usedNames.add(method.getName())) {
for (LookupElement element : GroovyCompletionUtil.createLookupElements(new GroovyResolveResultImpl(method, true), false, matcher, null)) {
consumer.consume(element);
}
}
}
}
}
} else if (((PsiClass) resolved).isAnnotationType()) {
for (PsiMethod method : ((PsiClass) resolved).getMethods()) {
for (LookupElement element : GroovyCompletionUtil.createLookupElements(new GroovyResolveResultImpl(method, true), false, matcher, null)) {
consumer.consume(element);
}
}
}
}
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.GroovyResolveResultImpl in project intellij-community by JetBrains.
the class CompleteCodeReferenceElement method feedLookupElements.
private void feedLookupElements(@NotNull PsiNamedElement psi, boolean afterNew) {
GroovyResolveResultImpl candidate = new GroovyResolveResultImpl(psi, true);
List<? extends LookupElement> elements = GroovyCompletionUtil.createLookupElements(candidate, afterNew, myMatcher, null);
for (LookupElement element : elements) {
myConsumer.consume(element);
}
}
Aggregations