Search in sources :

Example 46 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class FindManagerTest method runAsyncTest.

private void runAsyncTest(String text, FindModel findModel) throws InterruptedException {
    final Ref<FindResult> result = new Ref<>();
    final CountDownLatch progressStarted = new CountDownLatch(1);
    final ProgressIndicatorBase progressIndicatorBase = new ProgressIndicatorBase();
    final Thread thread = new Thread(() -> ProgressManager.getInstance().runProcess(() -> {
        try {
            progressStarted.countDown();
            result.set(myFindManager.findString(text, 0, findModel, new LightVirtualFile("foo.java")));
        } catch (ProcessCanceledException ex) {
            result.set(new FindResultImpl());
        }
    }, progressIndicatorBase), "runAsyncTest");
    thread.start();
    progressStarted.await();
    thread.join(100);
    progressIndicatorBase.cancel();
    thread.join(500);
    assertNotNull(result.get());
    assertTrue(!result.get().isStringFound());
    thread.join();
}
Also used : Ref(com.intellij.openapi.util.Ref) ProgressIndicatorBase(com.intellij.openapi.progress.util.ProgressIndicatorBase) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) CountDownLatch(java.util.concurrent.CountDownLatch) ProcessCanceledException(com.intellij.openapi.progress.ProcessCanceledException)

Example 47 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class FindManagerTest method testFindExceptComments2.

public void testFindExceptComments2() {
    FindModel findModel = FindManagerTestUtils.configureFindModel("oo");
    String text = "//oooo";
    findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
    LightVirtualFile file = new LightVirtualFile("A.java", text);
    FindResult findResult = myFindManager.findString(text, 0, findModel, file);
    assertFalse(findResult.isStringFound());
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 48 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class FindManagerTest method testFindExceptComments.

public void testFindExceptComments() {
    FindModel findModel = FindManagerTestUtils.configureFindModel("done");
    String prefix = "/*";
    String text = prefix + "done*/done";
    findModel.setSearchContext(FindModel.SearchContext.EXCEPT_COMMENTS);
    LightVirtualFile file = new LightVirtualFile("A.java", text);
    FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
    assertTrue(findResult.isStringFound());
    assertTrue(findResult.getStartOffset() > prefix.length());
    findModel.setRegularExpressions(true);
    findResult = myFindManager.findString(text, prefix.length(), findModel, file);
    assertTrue(findResult.isStringFound());
    assertTrue(findResult.getStartOffset() > prefix.length());
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 49 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class FindManagerTest method testRegExpInString.

public void testRegExpInString() {
    FindModel findModel = FindManagerTestUtils.configureFindModel("^*$");
    String prefix = "<foo bar=\"";
    String text = prefix + "\" />";
    findModel.setSearchContext(FindModel.SearchContext.IN_STRING_LITERALS);
    findModel.setRegularExpressions(true);
    LightVirtualFile file = new LightVirtualFile("A.xml", text);
    FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
    assertTrue(findResult.isStringFound());
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Example 50 with LightVirtualFile

use of com.intellij.testFramework.LightVirtualFile in project intellij-community by JetBrains.

the class FindManagerTest method testFindExceptLiterals.

public void testFindExceptLiterals() {
    FindModel findModel = FindManagerTestUtils.configureFindModel("done");
    String prefix = "\"";
    String text = prefix + "done\"done";
    findModel.setSearchContext(FindModel.SearchContext.EXCEPT_STRING_LITERALS);
    LightVirtualFile file = new LightVirtualFile("A.java", text);
    FindResult findResult = myFindManager.findString(text, prefix.length(), findModel, file);
    assertTrue(findResult.isStringFound());
    assertTrue(findResult.getStartOffset() > prefix.length());
    findModel.setRegularExpressions(true);
    findResult = myFindManager.findString(text, prefix.length(), findModel, file);
    assertTrue(findResult.isStringFound());
    assertTrue(findResult.getStartOffset() > prefix.length());
}
Also used : LightVirtualFile(com.intellij.testFramework.LightVirtualFile)

Aggregations

LightVirtualFile (com.intellij.testFramework.LightVirtualFile)69 VirtualFile (com.intellij.openapi.vfs.VirtualFile)19 NotNull (org.jetbrains.annotations.NotNull)10 Nullable (org.jetbrains.annotations.Nullable)10 IpnbFile (org.jetbrains.plugins.ipnb.format.IpnbFile)7 Document (com.intellij.openapi.editor.Document)6 FileElement (com.intellij.psi.impl.source.tree.FileElement)6 FileType (com.intellij.openapi.fileTypes.FileType)5 PsiManagerEx (com.intellij.psi.impl.PsiManagerEx)5 FileManager (com.intellij.psi.impl.file.impl.FileManager)5 Project (com.intellij.openapi.project.Project)4 SingleRootFileViewProvider (com.intellij.psi.SingleRootFileViewProvider)4 Language (com.intellij.lang.Language)3 FileViewProvider (com.intellij.psi.FileViewProvider)3 PsiFile (com.intellij.psi.PsiFile)3 PsiFileFactoryImpl (com.intellij.psi.impl.PsiFileFactoryImpl)3 File (java.io.File)3 IpnbCell (org.jetbrains.plugins.ipnb.format.cells.IpnbCell)3 VirtualFileWindow (com.intellij.injected.editor.VirtualFileWindow)2 MockDocument (com.intellij.mock.MockDocument)2