Search in sources :

Example 1 with ProgressManagerImpl

use of com.intellij.openapi.progress.impl.ProgressManagerImpl in project intellij-community by JetBrains.

the class ParsingTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initApplication();
    ComponentAdapter component = getApplication().getPicoContainer().getComponentAdapter(ProgressManager.class.getName());
    if (component == null) {
        getApplication().getPicoContainer().registerComponent(new AbstractComponentAdapter(ProgressManager.class.getName(), Object.class) {

            @Override
            public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
                return new ProgressManagerImpl();
            }

            @Override
            public void verify(PicoContainer container) throws PicoIntrospectionException {
            }
        });
    }
    Extensions.registerAreaClass("IDEA_PROJECT", null);
    myProject = new MockProjectEx(getTestRootDisposable());
    myPsiManager = new MockPsiManager(myProject);
    myFileFactory = new PsiFileFactoryImpl(myPsiManager);
    MutablePicoContainer appContainer = getApplication().getPicoContainer();
    registerComponentInstance(appContainer, MessageBus.class, getApplication().getMessageBus());
    registerComponentInstance(appContainer, SchemeManagerFactory.class, new MockSchemeManagerFactory());
    final MockEditorFactory editorFactory = new MockEditorFactory();
    registerComponentInstance(appContainer, EditorFactory.class, editorFactory);
    registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(charSequence -> editorFactory.createDocument(charSequence), FileDocumentManagerImpl.HARD_REF_TO_DOCUMENT_KEY));
    registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager());
    registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
    registerApplicationService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
    registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
    myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
    myProject.registerService(PsiManager.class, myPsiManager);
    myProject.registerService(StartupManager.class, new StartupManagerImpl(myProject));
    registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
    registerExtensionPoint(MetaLanguage.EP_NAME, MetaLanguage.class);
    for (ParserDefinition definition : myDefinitions) {
        addExplicitExtension(LanguageParserDefinitions.INSTANCE, definition.getFileNodeType().getLanguage(), definition);
    }
    if (myDefinitions.length > 0) {
        configureFromParserDefinition(myDefinitions[0], myFileExt);
    }
    // That's for reparse routines
    final PomModelImpl pomModel = new PomModelImpl(myProject);
    myProject.registerService(PomModel.class, pomModel);
    new TreeAspect(pomModel);
}
Also used : CharsetToolkit(com.intellij.openapi.vfs.CharsetToolkit) AbstractComponentAdapter(org.picocontainer.defaults.AbstractComponentAdapter) ReferenceProvidersRegistryImpl(com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl) NonNls(org.jetbrains.annotations.NonNls) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) org.picocontainer(org.picocontainer) BlockSupportImpl(com.intellij.psi.impl.source.text.BlockSupportImpl) PathManagerEx(com.intellij.openapi.application.ex.PathManagerEx) StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) PsiCachedValuesFactory(com.intellij.psi.impl.PsiCachedValuesFactory) com.intellij.lang(com.intellij.lang) StartupManager(com.intellij.openapi.startup.StartupManager) PomModel(com.intellij.pom.PomModel) Disposer(com.intellij.openapi.util.Disposer) ReferenceProvidersRegistry(com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry) FileUtil(com.intellij.openapi.util.io.FileUtil) TestCase(junit.framework.TestCase) DebugUtil(com.intellij.psi.impl.DebugUtil) PsiFileFactoryImpl(com.intellij.psi.impl.PsiFileFactoryImpl) DiffLog(com.intellij.psi.impl.source.text.DiffLog) Extensions(com.intellij.openapi.extensions.Extensions) ProgressManager(com.intellij.openapi.progress.ProgressManager) FileTypeManager(com.intellij.openapi.fileTypes.FileTypeManager) LoadTextUtil(com.intellij.openapi.fileEditor.impl.LoadTextUtil) FileTypeFactory(com.intellij.openapi.fileTypes.FileTypeFactory) SchemeManagerFactory(com.intellij.openapi.options.SchemeManagerFactory) CachedValuesManagerImpl(com.intellij.util.CachedValuesManagerImpl) Set(java.util.Set) PsiBuilderFactoryImpl(com.intellij.lang.impl.PsiBuilderFactoryImpl) FileDocumentManager(com.intellij.openapi.fileEditor.FileDocumentManager) IOException(java.io.IOException) TextRange(com.intellij.openapi.util.TextRange) FileDocumentManagerImpl(com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl) Disposable(com.intellij.openapi.Disposable) File(java.io.File) CachedValuesManager(com.intellij.psi.util.CachedValuesManager) ExtensionPointName(com.intellij.openapi.extensions.ExtensionPointName) EmptyProgressIndicator(com.intellij.openapi.progress.EmptyProgressIndicator) PomModelImpl(com.intellij.pom.core.impl.PomModelImpl) EditorFactory(com.intellij.openapi.editor.EditorFactory) com.intellij.mock(com.intellij.mock) com.intellij.psi(com.intellij.psi) NotNull(org.jetbrains.annotations.NotNull) TreeAspect(com.intellij.pom.tree.TreeAspect) MessageBus(com.intellij.util.messages.MessageBus) StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) TreeAspect(com.intellij.pom.tree.TreeAspect) AbstractComponentAdapter(org.picocontainer.defaults.AbstractComponentAdapter) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) CachedValuesManagerImpl(com.intellij.util.CachedValuesManagerImpl) PsiBuilderFactoryImpl(com.intellij.lang.impl.PsiBuilderFactoryImpl) PsiCachedValuesFactory(com.intellij.psi.impl.PsiCachedValuesFactory) PomModelImpl(com.intellij.pom.core.impl.PomModelImpl) AbstractComponentAdapter(org.picocontainer.defaults.AbstractComponentAdapter) ProgressManager(com.intellij.openapi.progress.ProgressManager) ReferenceProvidersRegistryImpl(com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl) PsiFileFactoryImpl(com.intellij.psi.impl.PsiFileFactoryImpl)

Example 2 with ProgressManagerImpl

use of com.intellij.openapi.progress.impl.ProgressManagerImpl in project intellij-elixir by KronicDeth.

the class ParsingTestCase method registerModuleManager.

private void registerModuleManager(MessageBus messageBus) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException, NoSuchMethodException {
    Class<?> moduleManagerComponentClass = Class.forName("com.intellij.openapi.module.impl.ModuleManagerComponent");
    Constructor<?> moduleManagerComponentConstructor;
    ModuleManager moduleManager = null;
    try {
        // IntelliJ > 2016.3
        moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class);
        moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject);
    } catch (NoSuchMethodException e1) {
        try {
            // IntelliJ 2016.3
            moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class, MessageBus.class);
            moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject, messageBus);
        } catch (NoSuchMethodException e2) {
            moduleManagerComponentConstructor = moduleManagerComponentClass.getConstructor(Project.class, ProgressManager.class, MessageBus.class);
            moduleManager = (ModuleManager) moduleManagerComponentConstructor.newInstance(myProject, new ProgressManagerImpl(), messageBus);
        }
    }
    myProject.registerService(ModuleManager.class, moduleManager);
}
Also used : Project(com.intellij.openapi.project.Project) MessageBus(com.intellij.util.messages.MessageBus) ProgressManager(com.intellij.openapi.progress.ProgressManager) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) ModuleManager(com.intellij.openapi.module.ModuleManager)

Example 3 with ProgressManagerImpl

use of com.intellij.openapi.progress.impl.ProgressManagerImpl in project intellij-community by JetBrains.

the class FindUsagesManager method startProcessUsages.

@NotNull
public static ProgressIndicator startProcessUsages(@NotNull final FindUsagesHandler handler, @NotNull final PsiElement[] primaryElements, @NotNull final PsiElement[] secondaryElements, @NotNull final Processor<Usage> processor, @NotNull final FindUsagesOptions findUsagesOptions, @NotNull final Runnable onComplete) {
    ApplicationManager.getApplication().assertIsDispatchThread();
    final ProgressIndicatorBase indicator = new ProgressIndicatorBase();
    Task.Backgroundable task = new Task.Backgroundable(handler.getProject(), "Finding Usages") {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            UsageSearcher usageSearcher = ReadAction.compute(() -> {
                PsiElement2UsageTargetAdapter[] primaryTargets = PsiElement2UsageTargetAdapter.convert(primaryElements);
                PsiElement2UsageTargetAdapter[] secondaryTargets = PsiElement2UsageTargetAdapter.convert(secondaryElements);
                return createUsageSearcher(primaryTargets, secondaryTargets, handler, findUsagesOptions, null);
            });
            usageSearcher.generate(processor);
        }
    };
    ((ProgressManagerImpl) ProgressManager.getInstance()).runProcessWithProgressAsynchronously(task, indicator, onComplete);
    return indicator;
}
Also used : Task(com.intellij.openapi.progress.Task) ProgressIndicatorBase(com.intellij.openapi.progress.util.ProgressIndicatorBase) ProgressIndicator(com.intellij.openapi.progress.ProgressIndicator) ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) NotNull(org.jetbrains.annotations.NotNull) NotNull(org.jetbrains.annotations.NotNull)

Example 4 with ProgressManagerImpl

use of com.intellij.openapi.progress.impl.ProgressManagerImpl in project intellij-community by JetBrains.

the class BackgroundTaskQueue method runTaskInCurrentThread.

private void runTaskInCurrentThread(@NotNull BackgroundableTaskData data) {
    Task.Backgroundable task = data.myTask;
    ProgressIndicator indicator = data.myIndicator;
    if (indicator == null)
        indicator = new EmptyProgressIndicator();
    ModalityState modalityState = data.myModalityState;
    if (modalityState == null)
        modalityState = ModalityState.NON_MODAL;
    ProgressManagerImpl pm = (ProgressManagerImpl) ProgressManager.getInstance();
    // prohibit simultaneous execution from different threads
    synchronized (TEST_TASK_LOCK) {
        pm.runProcessWithProgressInCurrentThread(task, indicator, modalityState);
    }
}
Also used : ProgressManagerImpl(com.intellij.openapi.progress.impl.ProgressManagerImpl) ModalityState(com.intellij.openapi.application.ModalityState)

Aggregations

ProgressManagerImpl (com.intellij.openapi.progress.impl.ProgressManagerImpl)4 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 MessageBus (com.intellij.util.messages.MessageBus)2 StartupManagerImpl (com.intellij.ide.startup.impl.StartupManagerImpl)1 com.intellij.lang (com.intellij.lang)1 PsiBuilderFactoryImpl (com.intellij.lang.impl.PsiBuilderFactoryImpl)1 com.intellij.mock (com.intellij.mock)1 Disposable (com.intellij.openapi.Disposable)1 ModalityState (com.intellij.openapi.application.ModalityState)1 PathManagerEx (com.intellij.openapi.application.ex.PathManagerEx)1 EditorFactory (com.intellij.openapi.editor.EditorFactory)1 ExtensionPointName (com.intellij.openapi.extensions.ExtensionPointName)1 Extensions (com.intellij.openapi.extensions.Extensions)1 FileDocumentManager (com.intellij.openapi.fileEditor.FileDocumentManager)1 FileDocumentManagerImpl (com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl)1 LoadTextUtil (com.intellij.openapi.fileEditor.impl.LoadTextUtil)1 FileTypeFactory (com.intellij.openapi.fileTypes.FileTypeFactory)1 FileTypeManager (com.intellij.openapi.fileTypes.FileTypeManager)1 ModuleManager (com.intellij.openapi.module.ModuleManager)1 SchemeManagerFactory (com.intellij.openapi.options.SchemeManagerFactory)1