Search in sources :

Example 51 with Project

use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.

the class BaseSpellChecker method doLoadDictionaryAsync.

private void doLoadDictionaryAsync(Loader loader, Consumer<Dictionary> consumer) {
    StartupManager.getInstance(myProject).runWhenProjectIsInitialized(() -> {
        LOG.debug("Loading " + loader.getName());
        Application app = ApplicationManager.getApplication();
        app.executeOnPooledThread(() -> {
            if (app.isDisposed())
                return;
            CompressedDictionary dictionary = CompressedDictionary.create(loader, transform);
            LOG.debug(loader.getName() + " loaded!");
            consumer.consume(dictionary);
            while (!myDictionariesToLoad.isEmpty()) {
                if (app.isDisposed())
                    return;
                Pair<Loader, Consumer<Dictionary>> nextDictionary = myDictionariesToLoad.remove(0);
                Loader nextDictionaryLoader = nextDictionary.getFirst();
                dictionary = CompressedDictionary.create(nextDictionaryLoader, transform);
                LOG.debug(nextDictionaryLoader.getName() + " loaded!");
                nextDictionary.getSecond().consume(dictionary);
            }
            LOG.debug("Loading finished, restarting daemon...");
            myLoadingDictionaries.set(false);
            UIUtil.invokeLaterIfNeeded(() -> {
                if (app.isDisposed())
                    return;
                for (final Project project : ProjectManager.getInstance().getOpenProjects()) {
                    if (project.isInitialized() && project.isOpen() && !project.isDefault()) {
                        DaemonCodeAnalyzer instance = DaemonCodeAnalyzer.getInstance(project);
                        if (instance != null)
                            instance.restart();
                    }
                }
            });
        });
    });
}
Also used : Project(com.intellij.openapi.project.Project) Consumer(com.intellij.util.Consumer) CompressedDictionary(com.intellij.spellchecker.compress.CompressedDictionary) DaemonCodeAnalyzer(com.intellij.codeInsight.daemon.DaemonCodeAnalyzer) Loader(com.intellij.spellchecker.dictionary.Loader) Application(com.intellij.openapi.application.Application)

Example 52 with Project

use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.

the class PyCommandLineTestCase method createConfiguration.

protected <T extends AbstractPythonRunConfiguration> T createConfiguration(final ConfigurationType configurationType, Class<T> cls) {
    final ConfigurationFactory factory = configurationType.getConfigurationFactories()[0];
    final Project project = myFixture.getProject();
    return cls.cast(factory.createTemplateConfiguration(project));
}
Also used : Project(com.intellij.openapi.project.Project) ConfigurationFactory(com.intellij.execution.configurations.ConfigurationFactory)

Example 53 with Project

use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.

the class PyMoveTest method doMoveFileTest.

private void doMoveFileTest(String fileName, String toDirName) {
    Project project = myFixture.getProject();
    PsiManager manager = PsiManager.getInstance(project);
    String root = "/refactoring/move/" + getTestName(true);
    String rootBefore = root + "/before/src";
    String rootAfter = root + "/after/src";
    VirtualFile dir1 = myFixture.copyDirectoryToProject(rootBefore, "");
    PsiDocumentManager.getInstance(project).commitAllDocuments();
    VirtualFile virtualFile = dir1.findFileByRelativePath(fileName);
    assertNotNull(virtualFile);
    PsiElement file = manager.findFile(virtualFile);
    if (file == null) {
        file = manager.findDirectory(virtualFile);
    }
    assertNotNull(file);
    VirtualFile toVirtualDir = dir1.findFileByRelativePath(toDirName);
    assertNotNull(toVirtualDir);
    PsiDirectory toDir = manager.findDirectory(toVirtualDir);
    new MoveFilesOrDirectoriesProcessor(project, new PsiElement[] { file }, toDir, false, false, null, null).run();
    VirtualFile dir2 = getVirtualFileByName(PythonTestUtil.getTestDataPath() + rootAfter);
    try {
        PlatformTestUtil.assertDirectoriesEqual(dir2, dir1);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) Project(com.intellij.openapi.project.Project) IOException(java.io.IOException) MoveFilesOrDirectoriesProcessor(com.intellij.refactoring.move.moveFilesOrDirectories.MoveFilesOrDirectoriesProcessor)

Example 54 with Project

use of com.intellij.openapi.project.Project in project intellij-community by JetBrains.

the class XmlSchemaTypeInheritanceTest method testIndex.

public void testIndex() throws Exception {
    myFixture.copyDirectoryToProject("", "");
    final Project project = getProject();
    final List<Set<SchemaTypeInfo>> childrenOfType = SchemaTypeInheritanceIndex.getWorker(project, null).apply("http://a.b.c", "baseSimpleType");
    Assert.assertNotNull(childrenOfType);
    final Set<SchemaTypeInfo> expected = new HashSet<>();
    expected.add(new SchemaTypeInfo("extSimple4", true, "http://a.b.c"));
    expected.add(new SchemaTypeInfo("extSimple1", true, "http://a.b.c"));
    expected.add(new SchemaTypeInfo("extComplex2", true, "http://a.b.c"));
    expected.add(new SchemaTypeInfo("extComplex2", true, "http://a.b.c.d"));
    for (Set<SchemaTypeInfo> infos : childrenOfType) {
        for (SchemaTypeInfo info : infos) {
            expected.remove(info);
        }
    }
    Assert.assertTrue(expected.isEmpty());
    //
    final List<Set<SchemaTypeInfo>> childrenOfSimple4Type = SchemaTypeInheritanceIndex.getWorker(project, null).apply("http://a.b.c", "extSimple4");
    Assert.assertNotNull(childrenOfSimple4Type);
    final Set<SchemaTypeInfo> expectedSimple4 = new HashSet<>();
    expectedSimple4.add(new SchemaTypeInfo("extSimple5", true, "http://a.b.c"));
    expectedSimple4.add(new SchemaTypeInfo("wiseElement", false, "http://a.b.c"));
    for (Set<SchemaTypeInfo> infos : childrenOfSimple4Type) {
        for (SchemaTypeInfo info : infos) {
            expectedSimple4.remove(info);
        }
    }
    Assert.assertTrue(expectedSimple4.isEmpty());
}
Also used : Project(com.intellij.openapi.project.Project) HashSet(com.intellij.util.containers.hash.HashSet) Set(java.util.Set) HashSet(com.intellij.util.containers.hash.HashSet)

Example 55 with Project

use of com.intellij.openapi.project.Project in project Main by SpartanRefactoring.

the class ToolBoxController method applyListener.

private void applyListener() {
    List<String> updateList = new ArrayList<>();
    for (int i = 0; i < list.getNumOfElements(); i++) {
        JCheckBox checkbox = (JCheckBox) list.getModel().getElementAt(i);
        if (checkbox.isSelected()) {
            updateList.add(checkbox.getText());
        }
    }
    Toolbox.getInstance().updateTipperList(updateList);
    Project p = Utils.getProject();
    DaemonCodeAnalyzer.getInstance(p).restart();
}
Also used : Project(com.intellij.openapi.project.Project) ArrayList(java.util.ArrayList)

Aggregations

Project (com.intellij.openapi.project.Project)3623 VirtualFile (com.intellij.openapi.vfs.VirtualFile)874 NotNull (org.jetbrains.annotations.NotNull)580 Nullable (org.jetbrains.annotations.Nullable)478 Module (com.intellij.openapi.module.Module)368 PsiFile (com.intellij.psi.PsiFile)334 Editor (com.intellij.openapi.editor.Editor)301 PsiElement (com.intellij.psi.PsiElement)292 ArrayList (java.util.ArrayList)214 File (java.io.File)212 Document (com.intellij.openapi.editor.Document)180 GlobalSearchScope (com.intellij.psi.search.GlobalSearchScope)172 List (java.util.List)158 IOException (java.io.IOException)107 TextRange (com.intellij.openapi.util.TextRange)99 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)96 IncorrectOperationException (com.intellij.util.IncorrectOperationException)95 Presentation (com.intellij.openapi.actionSystem.Presentation)94 DataContext (com.intellij.openapi.actionSystem.DataContext)92 PsiDirectory (com.intellij.psi.PsiDirectory)90