package org.elixir_lang.reference.callable; import com.intellij.codeInsight.completion.CompletionType; import com.intellij.psi.PsiElement; import com.intellij.psi.PsiPolyVariantReference; import com.intellij.psi.ResolveResult; import com.intellij.psi.search.LocalSearchScope; import com.intellij.psi.search.SearchScope; import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase; import org.elixir_lang.psi.ElixirAlias; import org.elixir_lang.psi.call.Call; import java.util.Arrays; import java.util.List; public class Issue429Test extends LightCodeInsightFixtureTestCase { /* * Tests */ public void testUseScope() { myFixture.configureByFiles("get_use_scope.ex"); PsiElement callable = myFixture .getFile() .findElementAt(myFixture.getCaretOffset()) .getParent() .getPrevSibling() .getLastChild() .getLastChild() .getLastChild(); assertInstanceOf(callable, Call.class); SearchScope useScope = callable.getUseScope(); assertInstanceOf(useScope, LocalSearchScope.class); LocalSearchScope localSearchScope = (LocalSearchScope) useScope; PsiElement[] scope = localSearchScope.getScope(); assertEquals(1, scope.length); PsiElement singleScope = scope[0]; assertTrue( "Use Scope is not the surrounding if", singleScope.getText().startsWith("if auth == ") ); } /* * Protected Instance Methods */ @Override protected String getTestDataPath() { return "testData/org/elixir_lang/reference/callable/issue_429"; } }