Search in sources :

Example 1 with DartServerFindUsagesHandler

use of com.jetbrains.lang.dart.ide.findUsages.DartServerFindUsagesHandler in project intellij-plugins by JetBrains.

the class DartServerFindUsagesTest method testFileUsage.

public void testFileUsage() {
    final PsiFile barFile = myFixture.configureByText("bar.dart", "");
    // it is important that foo.dart is not open in the editor
    myFixture.addFileToProject("foo.dart", "import '" + barFile.getName() + "';");
    // warm up
    myFixture.doHighlighting();
    final FindUsagesManager manager = ((FindManagerImpl) FindManager.getInstance(getProject())).getFindUsagesManager();
    final FindUsagesHandler handler = manager.getFindUsagesHandler(getFile(), false);
    assertNotNull(handler);
    assertFalse(handler instanceof DartServerFindUsagesHandler);
    final Collection<PsiReference> usages = handler.findReferencesToHighlight(getFile(), GlobalSearchScope.allScope(getProject()));
    assertSize(1, usages);
    final PsiReference reference = usages.iterator().next();
    assertInstanceOf(reference, DartFileReference.class);
    assertEquals("foo.dart", reference.getElement().getContainingFile().getName());
    assertEquals("import '" + barFile.getName() + "';", reference.getElement().getParent().getText());
}
Also used : FindManagerImpl(com.intellij.find.impl.FindManagerImpl) FindUsagesHandler(com.intellij.find.findUsages.FindUsagesHandler) DartServerFindUsagesHandler(com.jetbrains.lang.dart.ide.findUsages.DartServerFindUsagesHandler) PsiReference(com.intellij.psi.PsiReference) PsiFile(com.intellij.psi.PsiFile) FindUsagesManager(com.intellij.find.findUsages.FindUsagesManager) DartServerFindUsagesHandler(com.jetbrains.lang.dart.ide.findUsages.DartServerFindUsagesHandler)

Aggregations

FindUsagesHandler (com.intellij.find.findUsages.FindUsagesHandler)1 FindUsagesManager (com.intellij.find.findUsages.FindUsagesManager)1 FindManagerImpl (com.intellij.find.impl.FindManagerImpl)1 PsiFile (com.intellij.psi.PsiFile)1 PsiReference (com.intellij.psi.PsiReference)1 DartServerFindUsagesHandler (com.jetbrains.lang.dart.ide.findUsages.DartServerFindUsagesHandler)1