Java 类com.intellij.psi.impl.source.tree.injected.InjectedLanguageManagerImpl 实例源码

项目:intellij-ce-playground    文件:LightPlatformTestCase.java   
@Override
protected void setUp() throws Exception {
  EdtTestUtil.runInEdtAndWait(new ThrowableRunnable<Throwable>() {
    @Override
    public void run() throws Exception {
      LightPlatformTestCase.super.setUp();
      initApplication();
      ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest());

      ourApplication.setDataProvider(LightPlatformTestCase.this);
      LightProjectDescriptor descriptor = new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK());
      doSetup(descriptor, configureLocalInspectionTools(), getTestRootDisposable());
      InjectedLanguageManagerImpl.pushInjectors(getProject());

      storeSettings();

      myThreadTracker = new ThreadTracker();
      ModuleRootManager.getInstance(ourModule).orderEntries().getAllLibrariesAndSdkClassesRoots();
      VirtualFilePointerManagerImpl filePointerManager = (VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance();
      filePointerManager.storePointers();
    }
  });
}
项目:intellij-ce-playground    文件:LightIdeaTestFixtureImpl.java   
@Override
public void tearDown() throws Exception {
  Project project = getProject();
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
  CodeStyleSettings oldCodeStyleSettings = myOldCodeStyleSettings;
  myOldCodeStyleSettings = null;
  List<Throwable> exceptions = new SmartList<Throwable>();
  try {
    UsefulTestCase.doCheckForSettingsDamage(oldCodeStyleSettings, getCurrentCodeStyleSettings(), exceptions);

    LightPlatformTestCase.doTearDown(project, LightPlatformTestCase.getApplication(), true, exceptions);
    super.tearDown();
    InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
    PersistentFS.getInstance().clearIdCache();
    PlatformTestCase.cleanupApplicationCaches(project);
  }
  finally {
    CompoundRuntimeException.throwIfNotEmpty(exceptions);
  }
}
项目:tools-idea    文件:LightPlatformTestCase.java   
@Override
protected void tearDown() throws Exception {
  Project project = getProject();
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
  checkForSettingsDamage();
  VirtualFilePointerManagerImpl filePointerManager = (VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance();
  doTearDown(project, ourApplication, true);

  try {
    super.tearDown();
  }
  finally {
    myThreadTracker.checkLeak();
    InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
    filePointerManager.assertPointersAreDisposed();
  }
}
项目:consulo    文件:LightPlatformTestCase.java   
@Override
@RequiredDispatchThread
protected void setUp() throws Exception {
  super.setUp();
  initApplication();
  //ourApplication.setDataProvider(this);
  doSetup(createTestModuleDescriptor(), configureLocalInspectionTools(), myAvailableInspectionTools);
  InjectedLanguageManagerImpl.pushInjectors(getProject());

  storeSettings();

  myThreadTracker = new ThreadTracker();
  ApplicationInfoImpl.setInPerformanceTest(isPerformanceTest());
  ModuleRootManager.getInstance(ourModule).orderEntries().getAllLibrariesAndSdkClassesRoots();
  VirtualFilePointerManagerImpl filePointerManager = (VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance();
  filePointerManager.storePointers();
}
项目:consulo    文件:LightPlatformTestCase.java   
@Override
protected void tearDown() throws Exception {
  Project project = getProject();
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
  checkForSettingsDamage();
  VirtualFilePointerManagerImpl filePointerManager = (VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance();
  doTearDown(project, ourApplication, true);

  try {
    super.tearDown();
  }
  finally {
    myThreadTracker.checkLeak();
    InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
    filePointerManager.assertPointersAreDisposed();
  }
}
项目:intellij-ce-playground    文件:LightIdeaTestFixtureImpl.java   
@Override
public void setUp() throws Exception {
  super.setUp();

  IdeaTestApplication application = LightPlatformTestCase.initApplication();
  LightPlatformTestCase.doSetup(myProjectDescriptor, LocalInspectionTool.EMPTY_ARRAY, getTestRootDisposable());
  InjectedLanguageManagerImpl.pushInjectors(getProject());

  myOldCodeStyleSettings = getCurrentCodeStyleSettings().clone();
  myOldCodeStyleSettings.getIndentOptions(StdFileTypes.JAVA);

  application.setDataProvider(new TestDataProvider(getProject()));
}
项目:intellij-ce-playground    文件:HeavyIdeaTestFixtureImpl.java   
@Override
public void setUp() throws Exception {
  super.setUp();

  initApplication();
  setUpProject();

  EncodingManager.getInstance(); // adds listeners
  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();
  InjectedLanguageManagerImpl.pushInjectors(getProject());
}
项目:intellij-ce-playground    文件:PlatformTestCase.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  if (ourTestCase != null) {
    String message = "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.";
    ourTestCase = null;
    fail(message);
  }
  IdeaLogger.ourErrorsOccurred = null;

  LOG.info(getClass().getName() + ".setUp()");

  initApplication();

  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();

  setUpProject();

  storeSettings();
  ourTestCase = this;
  if (myProject != null) {
    ProjectManagerEx.getInstanceEx().openTestProject(myProject);
    CodeStyleSettingsManager.getInstance(myProject).setTemporarySettings(new CodeStyleSettings());
    InjectedLanguageManagerImpl.pushInjectors(getProject());
  }

  DocumentCommitThread.getInstance().clearQueue();
  UIUtil.dispatchAllInvocationEvents();
}
项目:tools-idea    文件:LightPlatformTestCase.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  initApplication();
  ourApplication.setDataProvider(this);
  doSetup(new SimpleLightProjectDescriptor(getModuleType(), getProjectJDK()), configureLocalInspectionTools(), myAvailableInspectionTools);
  InjectedLanguageManagerImpl.pushInjectors(getProject());

  storeSettings();

  myThreadTracker = new ThreadTracker();
  ModuleRootManager.getInstance(ourModule).orderEntries().getAllLibrariesAndSdkClassesRoots();
  VirtualFilePointerManagerImpl filePointerManager = (VirtualFilePointerManagerImpl)VirtualFilePointerManager.getInstance();
  filePointerManager.storePointers();
}
项目:tools-idea    文件:LightIdeaTestFixtureImpl.java   
@Override
public void setUp() throws Exception {
  super.setUp();

  IdeaTestApplication application = LightPlatformTestCase.initApplication();
  LightPlatformTestCase.doSetup(myProjectDescriptor, LocalInspectionTool.EMPTY_ARRAY, new THashMap<String, InspectionToolWrapper>());
  InjectedLanguageManagerImpl.pushInjectors(getProject());

  myOldCodeStyleSettings = getCurrentCodeStyleSettings().clone();
  myOldCodeStyleSettings.getIndentOptions(StdFileTypes.JAVA);

  application.setDataProvider(new TestDataProvider(getProject()));
}
项目:tools-idea    文件:LightIdeaTestFixtureImpl.java   
@Override
public void tearDown() throws Exception {
  Project project = getProject();
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();
  CodeStyleSettings oldCodeStyleSettings = myOldCodeStyleSettings;
  myOldCodeStyleSettings = null;
  UsefulTestCase.doCheckForSettingsDamage(oldCodeStyleSettings, getCurrentCodeStyleSettings());

  LightPlatformTestCase.doTearDown(project, LightPlatformTestCase.getApplication(), true);
  super.tearDown();
  InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
  PersistentFS.getInstance().clearIdCache();
    ((DirectoryIndexImpl)DirectoryIndex.getInstance(project)).assertAncestorConsistent();
}
项目:tools-idea    文件:HeavyIdeaTestFixtureImpl.java   
@Override
public void setUp() throws Exception {
  super.setUp();

  initApplication();
  setUpProject();

  EncodingManager.getInstance(); // adds listeners
  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();
  InjectedLanguageManagerImpl.pushInjectors(getProject());
}
项目:tools-idea    文件:PlatformTestCase.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  if (ourTestCase != null) {
    String message = "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.";
    ourTestCase = null;
    fail(message);
  }
  IdeaLogger.ourErrorsOccurred = null;

  LOG.info(getClass().getName() + ".setUp()");

  initApplication();

  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();

  setUpProject();

  storeSettings();
  ourTestCase = this;
  if (myProject != null) {
    ProjectManagerEx.getInstanceEx().openTestProject(myProject);
    CodeStyleSettingsManager.getInstance(myProject).setTemporarySettings(new CodeStyleSettings());
    InjectedLanguageManagerImpl.pushInjectors(getProject());
  }

  DocumentCommitThread.getInstance().clearQueue();
}
项目:consulo    文件:LightIdeaTestFixtureImpl.java   
@Override
public void setUp() throws Exception {
  super.setUp();

  ApplicationStarter application = LightPlatformTestCase.initApplication();
  LightPlatformTestCase.doSetup(myProjectDescriptor, LocalInspectionTool.EMPTY_ARRAY, new THashMap<String, InspectionToolWrapper>());
  InjectedLanguageManagerImpl.pushInjectors(getProject());

 // application.setDataProvider(new TestDataProvider(getProject()));
}
项目:consulo    文件:LightIdeaTestFixtureImpl.java   
@Override
public void tearDown() throws Exception {
  Project project = getProject();
  CodeStyleSettingsManager.getInstance(project).dropTemporarySettings();

  LightPlatformTestCase.doTearDown(project, LightPlatformTestCase.getApplication(), true);
  super.tearDown();
  InjectedLanguageManagerImpl.checkInjectorsAreDisposed(project);
  PersistentFS.getInstance().clearIdCache();
}
项目:consulo    文件:HeavyIdeaTestFixtureImpl.java   
@Override
public void setUp() throws Exception {
  super.setUp();

  initApplication();
  setUpProject();

  EncodingManager.getInstance(); // adds listeners
  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();
  InjectedLanguageManagerImpl.pushInjectors(getProject());
}
项目:consulo    文件:PlatformTestCase.java   
@Override
protected void setUp() throws Exception {
  super.setUp();
  if (ourTestCase != null) {
    String message = "Previous test " + ourTestCase + " hasn't called tearDown(). Probably overridden without super call.";
    ourTestCase = null;
    fail(message);
  }
  IdeaLogger.ourErrorsOccurred = null;

  LOGGER.info(getClass().getName() + ".setUp()");

  initApplication();

  myEditorListenerTracker = new EditorListenerTracker();
  myThreadTracker = new ThreadTracker();

  setUpProject();

  storeSettings();
  ourTestCase = this;
  if (myProject != null) {
    ProjectManagerEx.getInstanceEx().openTestProject(myProject);
    CodeStyleSettingsManager.getInstance(myProject).setTemporarySettings(new CodeStyleSettings());
    InjectedLanguageManagerImpl.pushInjectors(getProject());
  }

  UIUtil.dispatchAllInvocationEvents();
}
项目:consulo    文件:PsiDocumentManagerImpl.java   
@Override
protected boolean finishCommitInWriteAction(@Nonnull Document document,
                                            @Nonnull List<BooleanRunnable> finishProcessors,
                                            @Nonnull List<BooleanRunnable> reparseInjectedProcessors,
                                            boolean synchronously,
                                            boolean forceNoPsiCommit) {
  if (ApplicationManager.getApplication().isWriteAccessAllowed()) { // can be false for non-physical PSI
    InjectedLanguageManagerImpl.disposeInvalidEditors();
  }
  return super.finishCommitInWriteAction(document, finishProcessors, reparseInjectedProcessors, synchronously, forceNoPsiCommit);
}
项目:intellij-ce-playground    文件:InjectedGeneralHighlightingPass.java   
@NotNull
private Set<PsiFile> getInjectedPsiFiles(@NotNull final List<PsiElement> elements1,
                                         @NotNull final List<PsiElement> elements2,
                                         @NotNull final ProgressIndicator progress) {
  ApplicationManager.getApplication().assertReadAccessAllowed();
  final Set<PsiFile> outInjected = new THashSet<PsiFile>();

  List<DocumentWindow> injected = InjectedLanguageUtil.getCachedInjectedDocuments(myFile);
  final Collection<PsiElement> hosts = new THashSet<PsiElement>(elements1.size() + elements2.size() + injected.size());

  //rehighlight all injected PSI regardless the range,
  //since change in one place can lead to invalidation of injected PSI in (completely) other place.
  for (DocumentWindow documentRange : injected) {
    progress.checkCanceled();
    if (!documentRange.isValid()) continue;
    PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(documentRange);
    if (file == null) continue;
    PsiElement context = InjectedLanguageManager.getInstance(file.getProject()).getInjectionHost(file);
    if (context != null
        && context.isValid()
        && !file.getProject().isDisposed()
        && (myUpdateAll || myRestrictRange.intersects(context.getTextRange()))) {
      hosts.add(context);
    }
  }
  InjectedLanguageManagerImpl injectedLanguageManager = InjectedLanguageManagerImpl.getInstanceImpl(myProject);
  Processor<PsiElement> collectInjectableProcessor = new CommonProcessors.CollectProcessor<PsiElement>(hosts);
  injectedLanguageManager.processInjectableElements(elements1, collectInjectableProcessor);
  injectedLanguageManager.processInjectableElements(elements2, collectInjectableProcessor);

  final PsiLanguageInjectionHost.InjectedPsiVisitor visitor = new PsiLanguageInjectionHost.InjectedPsiVisitor() {
    @Override
    public void visit(@NotNull PsiFile injectedPsi, @NotNull List<PsiLanguageInjectionHost.Shred> places) {
      synchronized (outInjected) {
        outInjected.add(injectedPsi);
      }
    }
  };
  if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(new ArrayList<PsiElement>(hosts), progress, true,
                                                                 new Processor<PsiElement>() {
                                                                   @Override
                                                                   public boolean process(PsiElement element) {
                                                                     ApplicationManager.getApplication().assertReadAccessAllowed();
                                                                     progress.checkCanceled();
                                                                     InjectedLanguageUtil.enumerate(element, myFile, false, visitor);
                                                                     return true;
                                                                   }
                                                                 })) {
    throw new ProcessCanceledException();
  }
  synchronized (outInjected) {
    return outInjected;
  }
}
项目:consulo    文件:InjectedGeneralHighlightingPass.java   
@Nonnull
private Set<PsiFile> getInjectedPsiFiles(@Nonnull final List<PsiElement> elements1, @Nonnull final List<PsiElement> elements2, @Nonnull final ProgressIndicator progress) {
  ApplicationManager.getApplication().assertReadAccessAllowed();

  List<DocumentWindow> injected = InjectedLanguageManager.getInstance(myProject).getCachedInjectedDocumentsInRange(myFile, myFile.getTextRange());
  final Collection<PsiElement> hosts = new THashSet<>(elements1.size() + elements2.size() + injected.size());

  //rehighlight all injected PSI regardless the range,
  //since change in one place can lead to invalidation of injected PSI in (completely) other place.
  for (DocumentWindow documentRange : injected) {
    ProgressManager.checkCanceled();
    if (!documentRange.isValid()) continue;
    PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(documentRange);
    if (file == null) continue;
    PsiElement context = InjectedLanguageManager.getInstance(file.getProject()).getInjectionHost(file);
    if (context != null && context.isValid() && !file.getProject().isDisposed() && (myUpdateAll || myRestrictRange.intersects(context.getTextRange()))) {
      hosts.add(context);
    }
  }
  InjectedLanguageManagerImpl injectedLanguageManager = InjectedLanguageManagerImpl.getInstanceImpl(myProject);
  Processor<PsiElement> collectInjectableProcessor = Processors.cancelableCollectProcessor(hosts);
  injectedLanguageManager.processInjectableElements(elements1, collectInjectableProcessor);
  injectedLanguageManager.processInjectableElements(elements2, collectInjectableProcessor);

  final Set<PsiFile> outInjected = new THashSet<>();
  final PsiLanguageInjectionHost.InjectedPsiVisitor visitor = (injectedPsi, places) -> {
    synchronized (outInjected) {
      outInjected.add(injectedPsi);
    }
  };
  if (!JobLauncher.getInstance().invokeConcurrentlyUnderProgress(new ArrayList<>(hosts), progress, true, element -> {
    ApplicationManager.getApplication().assertReadAccessAllowed();
    ProgressManager.checkCanceled();
    InjectedLanguageManager.getInstance(myFile.getProject()).enumerateEx(element, myFile, false, visitor);
    return true;
  })) {
    throw new ProcessCanceledException();
  }
  synchronized (outInjected) {
    return outInjected;
  }
}