use of com.intellij.psi.ResolveResult in project intellij-community by JetBrains.
the class PyTargetReference method multiResolve.
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
final ResolveResult[] results = super.multiResolve(incompleteCode);
boolean shadowed = false;
for (ResolveResult result : results) {
final PsiElement element = result.getElement();
if (element != null && (element.getContainingFile() != myElement.getContainingFile() || element instanceof PyFunction || element instanceof PyClass)) {
shadowed = true;
break;
}
}
if (results.length > 0 && !shadowed) {
return results;
}
// resolve to self if no other target found
return new ResolveResult[] { new PsiElementResolveResult(myElement) };
}
use of com.intellij.psi.ResolveResult in project intellij-plugins by JetBrains.
the class ActionScriptImportHandler method resolveTypeNameUsingImports.
@Nullable
private static JSImportedElementResolveResult resolveTypeNameUsingImports(@NotNull final String referencedName, PsiNamedElement parent) {
final Map<String, JSImportedElementResolveResult> map = myImportResolveCache.get(ourImportResolveCache, parent, null).getValue();
JSImportedElementResolveResult result = map.get(referencedName);
if (result == null) {
SinkResolveProcessor resolveProcessor = new SinkResolveProcessor(referencedName, new ResolveResultSink(null, referencedName));
INSTANCE.resolveTypeNameUsingImportsInner(resolveProcessor, parent);
final ResolveResult[] resolveResults = resolveProcessor.getResultsAsResolveResults();
assert resolveResults.length < 2;
if (resolveResults.length == 1 && resolveResults[0] instanceof JSResolveResult) {
JSResolveResult resolveResult = (JSResolveResult) resolveResults[0];
final PsiElement element = resolveResult.getElement();
String typeName = ((JSQualifiedNamedElement) element).getQualifiedName();
result = new JSImportedElementResolveResult(typeName, element, resolveResult.getActionScriptImport());
}
map.put(referencedName, result != null ? result : JSImportedElementResolveResult.EMPTY_RESULT);
}
return result != JSImportedElementResolveResult.EMPTY_RESULT ? result : null;
}
use of com.intellij.psi.ResolveResult in project intellij-plugins by JetBrains.
the class ActionScriptReferenceExpressionResolver method resolveConditionalCompilationVariable.
private static ResolveResult[] resolveConditionalCompilationVariable(final JSReferenceExpression jsReferenceExpression) {
final String namespace;
final String constantName;
final PsiElement parent = jsReferenceExpression.getParent();
if (parent instanceof JSE4XNamespaceReference) {
final PsiElement namespaceReference = ((JSE4XNamespaceReference) parent).getNamespaceReference();
final PsiElement parentParent = parent.getParent();
PsiElement sibling = parent.getNextSibling();
while (sibling instanceof PsiWhiteSpace) {
sibling = sibling.getNextSibling();
}
if (namespaceReference != null && parentParent instanceof JSReferenceExpression && sibling != null && sibling.getNextSibling() == null && sibling.getNode() != null && sibling.getNode().getElementType() == JSTokenTypes.IDENTIFIER) {
namespace = namespaceReference.getText();
constantName = sibling.getText();
} else {
return new ResolveResult[] { new JSResolveResult(jsReferenceExpression, null, "javascript.unresolved.symbol.message") };
}
} else {
final JSE4XNamespaceReference namespaceElement = PsiTreeUtil.getChildOfType(jsReferenceExpression, JSE4XNamespaceReference.class);
final PsiElement namespaceReference = namespaceElement == null ? null : namespaceElement.getNamespaceReference();
PsiElement sibling = namespaceElement == null ? null : namespaceElement.getNextSibling();
while (sibling instanceof PsiWhiteSpace) {
sibling = sibling.getNextSibling();
}
if (namespaceElement != null && sibling != null && sibling.getNextSibling() == null && sibling.getNode() != null && sibling.getNode().getElementType() == JSTokenTypes.IDENTIFIER) {
namespace = namespaceReference.getText();
constantName = sibling.getText();
} else {
return new ResolveResult[] { new JSResolveResult(jsReferenceExpression, null, "javascript.unresolved.symbol.message") };
}
}
for (JSConditionalCompilationDefinitionsProvider provider : JSConditionalCompilationDefinitionsProvider.EP_NAME.getExtensions()) {
if (provider.containsConstant(ModuleUtilCore.findModuleForPsiElement(jsReferenceExpression), namespace, constantName)) {
return new ResolveResult[] { new JSResolveResult(jsReferenceExpression) };
}
}
return new ResolveResult[] { new JSResolveResult(jsReferenceExpression, null, "javascript.unresolved.symbol.message") };
}
use of com.intellij.psi.ResolveResult in project intellij-plugins by JetBrains.
the class ActionScriptAccessibilityProcessingHandler method acceptsForMembersVisibility.
@Override
protected boolean acceptsForMembersVisibility(@NotNull JSPsiElementBase element, @NotNull SinkResolveProcessor resolveProcessor) {
if (!(element instanceof JSAttributeListOwner))
return true;
final JSAttributeList attributeList = ((JSAttributeListOwner) element).getAttributeList();
if (JSResolveUtil.getClassOfContext(place) != JSResolveUtil.getClassOfContext(element)) {
if (!acceptPrivateMembers) {
if (attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PRIVATE) {
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.PRIVATE_MEMBER_IS_NOT_ACCESSIBLE);
return false;
}
}
if (!acceptProtectedMembers) {
if (attributeList != null && attributeList.getAccessType() == JSAttributeList.AccessType.PROTECTED) {
// we are resolving in context of the class or element within context of the class
if ((myClassScopeTypeName != null || isParentClassContext(element))) {
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.PROTECTED_MEMBER_IS_NOT_ACCESSIBLE);
return false;
}
// if element / context out of class then protected element is ok due to includes
}
}
}
PsiElement elt = JSResolveUtil.findParent(element);
if (processStatics) {
if ((attributeList == null || !attributeList.hasModifier(JSAttributeList.ModifierType.STATIC))) {
if (JSResolveUtil.PROTOTYPE_FIELD_NAME.equals(resolveProcessor.getName()))
return true;
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.INSTANCE_MEMBER_INACCESSIBLE);
return false;
}
if (myTypeName != null && elt instanceof JSClass && !myTypeName.equals(((JSClass) elt).getQualifiedName())) {
// static members are inherited in TypeScript classes
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.STATIC_MEMBER_INACCESSIBLE);
return false;
}
} else if (myClassDeclarationStarted && !allowUnqualifiedStaticsFromInstance) {
// ActionScript only?
if (attributeList != null && attributeList.hasModifier(JSAttributeList.ModifierType.STATIC)) {
boolean referencingClass = false;
if (place instanceof JSReferenceExpression) {
JSExpression qualifier = ((JSReferenceExpression) place).getQualifier();
if (qualifier instanceof JSReferenceExpression) {
JSElement expression = JSSymbolUtil.calcRefExprValue((JSReferenceExpression) qualifier);
if (expression instanceof JSReferenceExpression) {
for (ResolveResult r : ((JSReferenceExpression) expression).multiResolve(false)) {
PsiElement rElement = r.getElement();
if (rElement instanceof JSClass) {
referencingClass = true;
break;
}
}
}
}
}
if (!referencingClass) {
resolveProcessor.addPossibleCandidateResult(element, JSResolveResult.STATIC_MEMBER_INACCESSIBLE);
return false;
}
}
}
if (processActionScriptNotAllowedNsAttributes(element, resolveProcessor, attributeList))
return false;
return true;
}
use of com.intellij.psi.ResolveResult in project intellij-plugins by JetBrains.
the class CfmlArgumentNameReference method resolveInner.
@NotNull
@Override
protected ResolveResult[] resolveInner() {
PsiElement nextSibling = getNextSibling();
while (nextSibling instanceof PsiWhiteSpace) {
nextSibling = nextSibling.getNextSibling();
}
if (nextSibling != null && nextSibling.getNode().getElementType() != CfmlTokenTypes.ASSIGN) {
return super.resolveInner();
}
CfmlParameter[] functionParameters = getFunctionParameters();
if (functionParameters != null) {
Collection<ResolveResult> result = new LinkedList<>();
String referenceName = getReferenceName();
for (CfmlParameter param : functionParameters) {
if (referenceName.equals(param.getName())) {
result.add(new PsiElementResolveResult(param));
}
}
return result.toArray(ResolveResult.EMPTY_ARRAY);
}
return ResolveResult.EMPTY_ARRAY;
}
Aggregations