use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrBindingVariable in project intellij-community by JetBrains.
the class GrAssignmentExpressionImpl method processLValue.
private static boolean processLValue(@NotNull PsiScopeProcessor processor, @NotNull ResolveState state, @NotNull PsiElement place, @NotNull GroovyFileImpl file, @NotNull GrExpression lValue) {
if (!(lValue instanceof GrReferenceExpression))
return true;
final GrReferenceExpression lReference = (GrReferenceExpression) lValue;
if (lReference.isQualified())
return true;
final String name = lReference.getReferenceName();
if (name == null)
return true;
String hintName = ResolveUtil.getNameHint(processor);
if (hintName != null && !name.equals(hintName))
return true;
if (lReference != place && lReference.resolve() != null && !(lReference.resolve() instanceof GrBindingVariable))
return true;
final ConcurrentMap<String, GrBindingVariable> bindings = file.getBindings();
GrBindingVariable variable = bindings.get(name);
if (variable == null) {
variable = ConcurrencyUtil.cacheOrGet(bindings, name, new GrBindingVariable(file, name, true));
}
if (!variable.hasWriteAccess())
return true;
return processor.execute(variable, state);
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrBindingVariable in project intellij-community by JetBrains.
the class PropertyResolverProcessor method getCandidates.
@NotNull
@Override
public GroovyResolveResult[] getCandidates() {
//do not have more than one correct result. And if it exists it is the last
final List<GroovyResolveResult> candidates = getCandidatesInternal();
final int size = candidates.size();
if (size == 0)
return GroovyResolveResult.EMPTY_ARRAY;
GroovyResolveResult last = candidates.get(size - 1);
if (last.getElement() instanceof GrBindingVariable && size > 1) {
last = candidates.get(size - 2);
}
if (isCorrectLocalVarOrParam(last)) {
return new GroovyResolveResult[] { last };
}
for (GroovyResolveResult candidate : candidates) {
if (candidate.isStaticsOK()) {
return new GroovyResolveResult[] { candidate };
}
}
return candidates.toArray(new GroovyResolveResult[candidates.size()]);
}
use of org.jetbrains.plugins.groovy.lang.psi.impl.synthetic.GrBindingVariable in project intellij-community by JetBrains.
the class GroovyResolverProcessorImpl method getCandidates.
@NotNull
public List<GroovyResolveResult> getCandidates() {
List<GroovyResolveResult> candidates;
// return package if whole ref text is valid class name
if (myAcceptableKinds.contains(GroovyResolveKind.PACKAGE) && myIsPartOfFqn) {
candidates = getCandidates(GroovyResolveKind.PACKAGE);
if (!candidates.isEmpty()) {
final GroovyResolveResult candidate = candidates.get(0);
final PsiElement element = candidate.getElement();
assert element instanceof PsiPackage;
final GrReferenceExpressionImpl topRef = getContextReferenceExpression(myRef);
if (topRef != null) {
final String fqn = topRef.getTextSkipWhiteSpaceAndComments();
if (JavaPsiFacade.getInstance(myRef.getProject()).findClass(fqn, myRef.getResolveScope()) != null) {
return candidates;
}
}
}
}
candidates = getCandidates(GroovyResolveKind.VARIABLE);
if (!candidates.isEmpty()) {
return candidates;
}
candidates = getCandidates(GroovyResolveKind.METHOD);
if (!candidates.isEmpty()) {
final List<GroovyResolveResult> results = filterMethodCandidates(candidates);
return myRef.hasMemberPointer() ? collapseReflectedMethods(results) : results;
}
candidates = getCandidates(GroovyResolveKind.ENUM_CONST);
if (!candidates.isEmpty()) {
return candidates;
}
candidates = getCandidates(GroovyResolveKind.FIELD);
if (!candidates.isEmpty()) {
assert candidates.size() == 1;
final GroovyResolveResult candidate = candidates.get(0);
final PsiElement element = candidate.getElement();
if (element instanceof PsiField) {
final PsiClass containingClass = ((PsiField) element).getContainingClass();
if (containingClass != null && PsiUtil.getContextClass(myRef) == containingClass)
return candidates;
} else if (!(element instanceof GrBindingVariable)) {
return candidates;
}
}
if (myIsPartOfFqn) {
candidates = getCandidates(GroovyResolveKind.PACKAGE, GroovyResolveKind.CLASS);
if (!candidates.isEmpty()) {
return candidates;
}
}
candidates = getCandidates(GroovyResolveKind.PROPERTY);
if (!candidates.isEmpty()) {
return candidates.size() <= 1 ? candidates : ContainerUtil.newSmartList(candidates.get(0));
}
candidates = getCandidates(GroovyResolveKind.FIELD);
if (!candidates.isEmpty()) {
return candidates;
}
candidates = getCandidates(GroovyResolveKind.PACKAGE, GroovyResolveKind.CLASS);
if (!candidates.isEmpty()) {
return candidates;
}
candidates = getCandidates(GroovyResolveKind.PROPERTY);
if (!candidates.isEmpty()) {
return candidates;
}
candidates = getCandidates(GroovyResolveKind.BINDING);
if (!candidates.isEmpty()) {
return candidates;
}
for (GroovyResolveKind kind : myAcceptableKinds) {
Collection<GroovyResolveResult> results = myInapplicableCandidates.get(kind);
if (!results.isEmpty()) {
return ContainerUtil.newArrayList(ResolveUtil.filterSameSignatureCandidates(filterCorrectParameterCount(results)));
}
}
return Collections.emptyList();
}
Aggregations