Search in sources :

Example 6 with StartupManagerImpl

use of com.intellij.ide.startup.impl.StartupManagerImpl in project intellij-community by JetBrains.

the class DaemonAnalyzerTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    final LocalInspectionTool[] tools = configureLocalInspectionTools();
    InspectionsKt.configureInspections(tools, getProject(), getTestRootDisposable());
    DaemonCodeAnalyzerImpl daemonCodeAnalyzer = (DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject());
    daemonCodeAnalyzer.prepareForTest();
    final StartupManagerImpl startupManager = (StartupManagerImpl) StartupManagerEx.getInstanceEx(getProject());
    startupManager.runStartupActivities();
    startupManager.startCacheUpdate();
    startupManager.runPostStartupActivities();
    DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
    if (isStressTest()) {
        // hack to avoid slowdowns in PyExtensionFactory
        IntentionManager.getInstance().getAvailableIntentionActions();
        // to cache stuff
        PathManagerEx.getTestDataPath();
        // pre-load tons of classes
        ReferenceProvidersRegistry.getInstance();
        // zillion of Dom Sem classes
        InjectedLanguageManager.getInstance(getProject());
        // pile of annotator classes loads
        LanguageAnnotators.INSTANCE.allForLanguage(JavaLanguage.INSTANCE);
        LanguageAnnotators.INSTANCE.allForLanguage(StdLanguages.XML);
        ProblemHighlightFilter.EP_NAME.getExtensions();
        Extensions.getExtensions(ImplicitUsageProvider.EP_NAME);
        Extensions.getExtensions(XmlSchemaProvider.EP_NAME);
        Extensions.getExtensions(XmlFileNSInfoProvider.EP_NAME);
        Extensions.getExtensions(ExternalAnnotatorsFilter.EXTENSION_POINT_NAME);
        Extensions.getExtensions(IndexPatternBuilder.EP_NAME);
    }
}
Also used : StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl) LocalInspectionTool(com.intellij.codeInspection.LocalInspectionTool)

Example 7 with StartupManagerImpl

use of com.intellij.ide.startup.impl.StartupManagerImpl in project intellij-community by JetBrains.

the class DaemonAnalyzerTestCase method tearDown.

@Override
protected void tearDown() throws Exception {
    try {
        // return default value to avoid unnecessary save
        DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(true);
        final Project project = getProject();
        if (project != null) {
            ((StartupManagerImpl) StartupManager.getInstance(project)).checkCleared();
            ((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(project)).cleanupAfterTest();
        }
    } finally {
        super.tearDown();
    }
//((VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance()).assertPointersDisposed();
}
Also used : Project(com.intellij.openapi.project.Project) StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) DaemonCodeAnalyzerImpl(com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)

Example 8 with StartupManagerImpl

use of com.intellij.ide.startup.impl.StartupManagerImpl in project kotlin by JetBrains.

the class KotlinAndroidTestCase method setUp.

@Override
protected void setUp() throws Exception {
    // sdk path workaround, set real android sdk path and platform for android plugin to work
    System.setProperty(KotlinAndroidTestCaseBase.SDK_PATH_PROPERTY, PathManager.getHomePath() + "/../dependencies/androidSDK");
    System.setProperty(KotlinAndroidTestCaseBase.PLATFORM_DIR_PROPERTY, "android-23");
    VfsRootAccess.allowRootAccess(KotlinTestUtils.getHomeDirectory());
    super.setUp();
    // this will throw an exception if we don't have a full Android SDK, so we need to do this first thing before any other setup
    String sdkPath = getTestSdkPath();
    final TestFixtureBuilder<IdeaProjectTestFixture> projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder(getName());
    myFixture = JavaTestFixtureFactory.getFixtureFactory().createCodeInsightFixture(projectBuilder.getFixture());
    final JavaModuleFixtureBuilder moduleFixtureBuilder = projectBuilder.addModule(JavaModuleFixtureBuilder.class);
    final String dirPath = myFixture.getTempDirPath() + getContentRootPath();
    final File dir = new File(dirPath);
    if (!dir.exists()) {
        assertTrue(dir.mkdirs());
    }
    tuneModule(moduleFixtureBuilder, dirPath);
    final List<MyAdditionalModuleData> modules = new ArrayList<MyAdditionalModuleData>();
    configureAdditionalModules(projectBuilder, modules);
    myFixture.setUp();
    myFixture.setTestDataPath(getTestDataPath());
    myModule = moduleFixtureBuilder.getFixture().getModule();
    // Must be done before addAndroidFacet, and must always be done, even if !myCreateManifest.
    // We will delete it at the end of setUp; this is needed when unit tests want to rewrite
    // the manifest on their own.
    createManifest();
    androidSdk = createAndroidSdk(getTestSdkPath(), getPlatformDir());
    myFacet = addAndroidFacet(myModule, sdkPath, getPlatformDir(), isToAddSdk());
    for (File resDir : getResourceDirs(dirPath)) {
        if (resDir.exists()) {
            myFixture.copyDirectoryToProject(resDir.getName(), resDir.getName());
        } else {
            Logger.getInstance(this.getClass()).info("No res directory found in test");
        }
    }
    myAdditionalModules = new ArrayList<Module>();
    for (MyAdditionalModuleData data : modules) {
        final Module additionalModule = data.myModuleFixtureBuilder.getFixture().getModule();
        myAdditionalModules.add(additionalModule);
        final AndroidFacet facet = addAndroidFacet(additionalModule, sdkPath, getPlatformDir());
        facet.setLibraryProject(data.myLibrary);
        final String rootPath = getContentRootPath(data.myDirName);
        myFixture.copyDirectoryToProject("res", rootPath + "/res");
        myFixture.copyFileToProject(SdkConstants.FN_ANDROID_MANIFEST_XML, rootPath + '/' + SdkConstants.FN_ANDROID_MANIFEST_XML);
        ModuleRootModificationUtil.addDependency(myModule, additionalModule);
    }
    if (!myCreateManifest) {
        deleteManifest();
    }
    if (RenderSecurityManager.RESTRICT_READS) {
        // Unit test class loader includes disk directories which security manager does not allow access to
        RenderSecurityManager.sEnabled = false;
    }
    ((StartupManagerImpl) StartupManager.getInstance(getProject())).runPostStartupActivities();
    kotlinInternalModeOriginalValue = KotlinInternalMode.Instance.getEnabled();
    KotlinInternalMode.Instance.setEnabled(true);
}
Also used : IdeaProjectTestFixture(com.intellij.testFramework.fixtures.IdeaProjectTestFixture) StartupManagerImpl(com.intellij.ide.startup.impl.StartupManagerImpl) JavaModuleFixtureBuilder(com.intellij.testFramework.builders.JavaModuleFixtureBuilder) ArrayList(java.util.ArrayList) Module(com.intellij.openapi.module.Module) VirtualFile(com.intellij.openapi.vfs.VirtualFile) File(java.io.File) AndroidFacet(org.jetbrains.android.facet.AndroidFacet)

Aggregations

StartupManagerImpl (com.intellij.ide.startup.impl.StartupManagerImpl)8 DaemonCodeAnalyzerImpl (com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl)2 Project (com.intellij.openapi.project.Project)2 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 LocalInspectionTool (com.intellij.codeInspection.LocalInspectionTool)1 PerformanceWatcher (com.intellij.diagnostic.PerformanceWatcher)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 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 Module (com.intellij.openapi.module.Module)1