use of com.intellij.ide.startup.impl.StartupManagerImpl in project intellij-community by JetBrains.
the class ProjectManagerImpl method openProject.
@Override
public boolean openProject(@NotNull final Project project) {
if (isLight(project)) {
((ProjectImpl) project).setTemporarilyDisposed(false);
boolean isInitialized = StartupManagerEx.getInstanceEx(project).startupActivityPassed();
if (isInitialized) {
addToOpened(project);
// events already fired
return true;
}
}
for (Project p : getOpenProjects()) {
if (ProjectUtil.isSameProject(project.getProjectFilePath(), p)) {
GuiUtils.invokeLaterIfNeeded(() -> ProjectUtil.focusProjectWindow(p, false), ModalityState.NON_MODAL);
return false;
}
}
if (!addToOpened(project)) {
return false;
}
Runnable process = () -> {
TransactionGuard.getInstance().submitTransactionAndWait(() -> fireProjectOpened(project));
StartupManagerImpl startupManager = (StartupManagerImpl) StartupManager.getInstance(project);
startupManager.runStartupActivities();
// Startup activities (e.g. the one in FileBasedIndexProjectHandler) have scheduled dumb mode to begin "later"
// Now we schedule-and-wait to the same event queue to guarantee that the dumb mode really begins now:
// Post-startup activities should not ever see unindexed and at the same time non-dumb state
TransactionGuard.getInstance().submitTransactionAndWait(startupManager::startCacheUpdate);
startupManager.runPostStartupActivitiesFromExtensions();
GuiUtils.invokeLaterIfNeeded(() -> {
if (!project.isDisposed()) {
startupManager.runPostStartupActivities();
Application application = ApplicationManager.getApplication();
if (!(application.isHeadlessEnvironment() || application.isUnitTestMode())) {
StorageUtilKt.checkUnknownMacros(project, true);
}
}
if (ApplicationManager.getApplication().isActive()) {
JFrame projectFrame = WindowManager.getInstance().getFrame(project);
if (projectFrame != null) {
IdeFocusManager.getInstance(project).requestFocus(projectFrame, true);
}
}
}, ModalityState.NON_MODAL);
};
ProgressIndicator indicator = myProgressManager.getProgressIndicator();
if (indicator != null) {
indicator.setText("Preparing workspace...");
process.run();
return true;
}
boolean ok = myProgressManager.runProcessWithProgressSynchronously(process, ProjectBundle.message("project.load.progress"), canCancelProjectLoading(), project);
if (!ok) {
closeProject(project, false, false, true);
notifyProjectOpenFailed();
return false;
}
return true;
}
use of com.intellij.ide.startup.impl.StartupManagerImpl 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.ide.startup.impl.StartupManagerImpl in project android by JetBrains.
the class GradleFilePsiMerger method mergeGradleFiles.
/**
* Merges the given source build.gradle content into the given destination build.gradle content,
* and resolves and dynamic Gradle dependencies into specific versions. If a support library
* filter is provided, the support libraries will be limited to match that filter. This is
* typically set to the compileSdkVersion, such that you don't end up mixing and matching
* compileSdkVersions and support libraries from different versions, which is not supported.
*/
public static String mergeGradleFiles(@NotNull String source, @NotNull String dest, @Nullable Project project, @Nullable final String supportLibVersionFilter) {
source = source.replace("\r", "");
dest = dest.replace("\r", "");
final Project project2;
boolean projectNeedsCleanup = false;
if (project != null && !project.isDefault()) {
project2 = project;
} else {
project2 = ((ProjectManagerImpl) ProjectManager.getInstance()).newProject("MergingOnly", "", false, true);
assert project2 != null;
((StartupManagerImpl) StartupManager.getInstance(project2)).runStartupActivities();
projectNeedsCleanup = true;
}
final GroovyFile templateBuildFile = (GroovyFile) PsiFileFactory.getInstance(project2).createFileFromText(SdkConstants.FN_BUILD_GRADLE, GroovyFileType.GROOVY_FILE_TYPE, source);
final GroovyFile existingBuildFile = (GroovyFile) PsiFileFactory.getInstance(project2).createFileFromText(SdkConstants.FN_BUILD_GRADLE, GroovyFileType.GROOVY_FILE_TYPE, dest);
String result = (new WriteCommandAction<String>(project2, "Merge Gradle Files", existingBuildFile) {
@Override
protected void run(@NotNull Result<String> result) throws Throwable {
mergePsi(templateBuildFile, existingBuildFile, project2, supportLibVersionFilter);
PsiElement formatted = CodeStyleManager.getInstance(project2).reformat(existingBuildFile);
result.setResult(formatted.getText());
}
}).execute().getResultObject();
if (projectNeedsCleanup) {
ApplicationManager.getApplication().runWriteAction(() -> {
Disposer.dispose(project2);
});
}
return result;
}
use of com.intellij.ide.startup.impl.StartupManagerImpl in project intellij-community by JetBrains.
the class UnindexedFilesUpdater method updateUnindexedFiles.
private void updateUnindexedFiles(ProgressIndicator indicator) {
PerformanceWatcher.Snapshot snapshot = PerformanceWatcher.takeSnapshot();
PushedFilePropertiesUpdater.getInstance(myProject).pushAllPropertiesNow();
boolean trackResponsiveness = !ApplicationManager.getApplication().isUnitTestMode();
if (trackResponsiveness)
snapshot.logResponsivenessSinceCreation("Pushing properties");
indicator.setIndeterminate(true);
indicator.setText(IdeBundle.message("progress.indexing.scanning"));
myIndex.clearIndicesIfNecessary();
CollectingContentIterator finder = myIndex.createContentIterator(indicator);
snapshot = PerformanceWatcher.takeSnapshot();
myIndex.iterateIndexableFilesConcurrently(finder, myProject, indicator);
myIndex.filesUpdateEnumerationFinished();
if (trackResponsiveness)
snapshot.logResponsivenessSinceCreation("Indexable file iteration");
List<VirtualFile> files = finder.getFiles();
if (!ApplicationManager.getApplication().isUnitTestMode()) {
// full VFS refresh makes sense only after it's loaded, i.e. after scanning files to index is finished
((StartupManagerImpl) StartupManager.getInstance(myProject)).scheduleInitialVfsRefresh();
}
if (files.isEmpty()) {
return;
}
snapshot = PerformanceWatcher.takeSnapshot();
if (trackResponsiveness)
LOG.info("Unindexed files update started: " + files.size() + " files to update");
indicator.setIndeterminate(false);
indicator.setText(IdeBundle.message("progress.indexing.updating"));
indexFiles(indicator, files);
if (trackResponsiveness)
snapshot.logResponsivenessSinceCreation("Unindexed files update");
}
use of com.intellij.ide.startup.impl.StartupManagerImpl in project intellij-community by JetBrains.
the class PlatformTestCase method runStartupActivities.
protected void runStartupActivities() {
final StartupManagerImpl startupManager = (StartupManagerImpl) StartupManager.getInstance(myProject);
startupManager.runStartupActivities();
startupManager.startCacheUpdate();
startupManager.runPostStartupActivities();
}
Aggregations