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);
}
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);
}
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;
}
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);
}
}
Aggregations