Search in sources :

Example 6 with PsiFileFactoryImpl

use of com.intellij.psi.impl.PsiFileFactoryImpl in project kotlin by JetBrains.

the class KtParsingTestCase method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    initApplication();
    ComponentAdapter component = getApplication().getPicoContainer().getComponentAdapter(ProgressManager.class.getName());
    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, MessageBusFactory.newMessageBus(getApplication()));
    registerComponentInstance(appContainer, SchemesManagerFactory.class, new MockSchemesManagerFactory());
    final MockEditorFactory editorFactory = new MockEditorFactory();
    registerComponentInstance(appContainer, EditorFactory.class, editorFactory);
    registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {

        @Override
        public Document fun(CharSequence charSequence) {
            return editorFactory.createDocument(charSequence);
        }
    }, HARD_REF_TO_DOCUMENT_KEY));
    registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager());
    registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
    registerApplicationService(DefaultASTFactory.class, new CoreASTFactory());
    registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
    registerApplicationService(ProgressManager.class, new CoreProgressManager());
    myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
    myProject.registerService(PsiManager.class, myPsiManager);
    this.registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.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 : MutablePicoContainer(org.picocontainer.MutablePicoContainer) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) MockFileDocumentManagerImpl(com.intellij.mock.MockFileDocumentManagerImpl) TreeAspect(com.intellij.pom.tree.TreeAspect) CachedValuesManagerImpl(com.intellij.util.CachedValuesManagerImpl) CoreASTFactory(com.intellij.core.CoreASTFactory) PsiBuilderFactoryImpl(com.intellij.lang.impl.PsiBuilderFactoryImpl) Function(com.intellij.util.Function) PsiCachedValuesFactory(com.intellij.psi.impl.PsiCachedValuesFactory) ProgressManager(com.intellij.openapi.progress.ProgressManager) CoreProgressManager(com.intellij.openapi.progress.impl.CoreProgressManager) ReferenceProvidersRegistryImpl(com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl) PsiFileFactoryImpl(com.intellij.psi.impl.PsiFileFactoryImpl) PomModelImpl(com.intellij.pom.core.impl.PomModelImpl) ComponentAdapter(org.picocontainer.ComponentAdapter)

Example 7 with PsiFileFactoryImpl

use of com.intellij.psi.impl.PsiFileFactoryImpl in project intellij by bazelbuild.

the class ProjectViewElementGenerator method createDummyFile.

private static PsiFile createDummyFile(Project project, String contents) {
    PsiFileFactory factory = PsiFileFactory.getInstance(project);
    LightVirtualFile virtualFile = new LightVirtualFile(DUMMY_FILENAME, ProjectViewFileType.INSTANCE, contents);
    PsiFile psiFile = ((PsiFileFactoryImpl) factory).trySetupPsiForFile(virtualFile, ProjectViewLanguage.INSTANCE, false, true);
    assert psiFile != null;
    return psiFile;
}
Also used : PsiFileFactory(com.intellij.psi.PsiFileFactory) LightVirtualFile(com.intellij.testFramework.LightVirtualFile) PsiFileFactoryImpl(com.intellij.psi.impl.PsiFileFactoryImpl) PsiFile(com.intellij.psi.PsiFile)

Aggregations

PsiFileFactoryImpl (com.intellij.psi.impl.PsiFileFactoryImpl)7 LightVirtualFile (com.intellij.testFramework.LightVirtualFile)5 PsiFile (com.intellij.psi.PsiFile)4 PsiFileFactory (com.intellij.psi.PsiFileFactory)4 PsiBuilderFactoryImpl (com.intellij.lang.impl.PsiBuilderFactoryImpl)2 ProgressManager (com.intellij.openapi.progress.ProgressManager)2 PomModelImpl (com.intellij.pom.core.impl.PomModelImpl)2 TreeAspect (com.intellij.pom.tree.TreeAspect)2 PsiCachedValuesFactory (com.intellij.psi.impl.PsiCachedValuesFactory)2 ReferenceProvidersRegistryImpl (com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl)2 CachedValuesManagerImpl (com.intellij.util.CachedValuesManagerImpl)2 CoreASTFactory (com.intellij.core.CoreASTFactory)1 StartupManagerImpl (com.intellij.ide.startup.impl.StartupManagerImpl)1 com.intellij.lang (com.intellij.lang)1 com.intellij.mock (com.intellij.mock)1 MockFileDocumentManagerImpl (com.intellij.mock.MockFileDocumentManagerImpl)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