use of com.intellij.psi.ResolveResult in project intellij-community by JetBrains.
the class PyResolveTest method testToConstructorInherited.
public void testToConstructorInherited() {
ResolveResult[] targets = multiResolve();
// to class, to init
assertEquals(2, targets.length);
PsiElement elt;
// class
elt = targets[0].getElement();
assertTrue(elt instanceof PyClass);
assertEquals("Bar", ((PyClass) elt).getName());
// init
elt = targets[1].getElement();
assertTrue(elt instanceof PyFunction);
PyFunction fun = (PyFunction) elt;
assertEquals(PyNames.INIT, fun.getName());
PyClass cls = fun.getContainingClass();
assertNotNull(cls);
assertEquals("Foo", cls.getName());
}
use of com.intellij.psi.ResolveResult in project intellij-community by JetBrains.
the class RngHighlightingTest method testResolveIncludedRef2.
public void testResolveIncludedRef2() throws Throwable {
myTestFixture.copyFileToProject("include.rng");
final PsiReference ref = myTestFixture.getReferenceAtCaretPositionWithAssertion("resolve-include-ref-2.rng");
assertTrue("PolyVariantRef", ref instanceof PsiPolyVariantReference);
final PsiElement element = ref.resolve();
assertNull(element);
final ResolveResult[] results = ((PsiPolyVariantReference) ref).multiResolve(false);
assertEquals(2, results.length);
for (ResolveResult result : results) {
PsiElement e = result.getElement();
assertTrue(e instanceof XmlTag);
final int contentLength = ((XmlTag) e).getSubTags().length;
if (e.getContainingFile() == ref.getElement().getContainingFile()) {
assertEquals(1, contentLength);
} else {
assertEquals(0, contentLength);
}
}
}
use of com.intellij.psi.ResolveResult in project intellij-community by JetBrains.
the class PyResolveTest method testUnresolvedImport.
public void testUnresolvedImport() {
final ResolveResult[] results = multiResolve();
assertEquals(1, results.length);
UsefulTestCase.assertInstanceOf(results[0], ImportedResolveResult.class);
ImportedResolveResult result = (ImportedResolveResult) results[0];
assertNull(result.getElement());
}
use of com.intellij.psi.ResolveResult in project intellij-community by JetBrains.
the class IpnbPyReference method multiResolve.
@NotNull
@Override
public ResolveResult[] multiResolve(boolean incompleteCode) {
ResolveResult[] results = super.multiResolve(incompleteCode);
if (results.length == 0) {
PsiFile file = myElement.getContainingFile();
if (file instanceof IpnbPyFragment) {
final IpnbFilePanel panel = ((IpnbPyFragment) file).getFilePanel();
final List<IpnbEditablePanel> panels = panel.getIpnbPanels();
final String referencedName = myElement.getReferencedName();
if (referencedName == null)
return ResolveResult.EMPTY_ARRAY;
for (IpnbEditablePanel editablePanel : panels) {
if (!(editablePanel instanceof IpnbCodePanel))
continue;
final Editor editor = ((IpnbCodePanel) editablePanel).getEditor();
final IpnbPyFragment psiFile = (IpnbPyFragment) PsiDocumentManager.getInstance(myElement.getProject()).getPsiFile(editor.getDocument());
if (psiFile == null)
continue;
final PyResolveProcessor processor = new PyResolveProcessor(referencedName);
PyResolveUtil.scopeCrawlUp(processor, psiFile, referencedName, psiFile);
final List<RatedResolveResult> resultList = getResultsFromProcessor(referencedName, processor, psiFile, psiFile);
if (resultList.size() > 0) {
List<RatedResolveResult> ret = RatedResolveResult.sorted(resultList);
return ret.toArray(new RatedResolveResult[ret.size()]);
}
}
}
}
return results;
}
use of com.intellij.psi.ResolveResult in project intellij-elixir by KronicDeth.
the class ImportTest method testImportModuleExceptNameArity.
public void testImportModuleExceptNameArity() {
myFixture.configureByFiles("import_module_except_name_arity.ex", "imported.ex");
PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
assertNotNull(elementAtCaret);
PsiElement maybeCall = elementAtCaret.getParent().getParent();
assertInstanceOf(maybeCall, Call.class);
Call call = (Call) maybeCall;
assertEquals("imported", call.functionName());
assertEquals(0, call.resolvedFinalArity());
PsiReference reference = call.getReference();
assertNotNull(reference);
assertInstanceOf(reference, PsiPolyVariantReference.class);
PsiPolyVariantReference polyVariantReference = (PsiPolyVariantReference) reference;
ResolveResult[] resolveResults = polyVariantReference.multiResolve(false);
assertEquals(2, resolveResults.length);
}
Aggregations