当前位置: 首页>>代码示例>>Java>>正文


Java PsiManagerEx类代码示例

本文整理汇总了Java中com.intellij.psi.impl.PsiManagerEx的典型用法代码示例。如果您正苦于以下问题:Java PsiManagerEx类的具体用法?Java PsiManagerEx怎么用?Java PsiManagerEx使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


PsiManagerEx类属于com.intellij.psi.impl包,在下文中一共展示了PsiManagerEx类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shouldAbbreviateName

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
private static boolean shouldAbbreviateName(PsiPackage aPackage) {
  final Project project = aPackage.getProject();
  ConcurrentMap<PsiPackage, Boolean> map = project.getUserData(SHOULD_ABBREV_PACK_KEY);
  if (map == null) {
    final ConcurrentMap<PsiPackage, Boolean> newMap = ContainerUtil.createConcurrentWeakMap();
    map = ((UserDataHolderEx)project).putUserDataIfAbsent(SHOULD_ABBREV_PACK_KEY, newMap);
    if (map == newMap) {
      ((PsiManagerEx)PsiManager.getInstance(project)).registerRunnableToRunOnChange(new Runnable() {
        @Override
        public void run() {
          newMap.clear();
        }
      });
    }
  }

  Boolean ret = map.get(aPackage);
  if (ret != null) return ret;
  ret = scanPackages(aPackage, 1);
  map.put(aPackage, ret);
  return ret;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TreeViewUtil.java

示例2: testAllTheseConcurrentThreadsDoNotCrashAnything

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public void testAllTheseConcurrentThreadsDoNotCrashAnything() throws Exception {
  long time = System.currentTimeMillis();
  for (int i = 0; i < 20/*00000*/; i++) {
    //System.out.println("i = " + i);
    getPsiManager().dropResolveCaches();
    ((PsiManagerEx)getPsiManager()).getFileManager().cleanupForNextTest();
    DaemonCodeAnalyzer.getInstance(getProject()).restart();

    configureFromFileText("Stress.java", text);
    List<HighlightInfo> infos = doHighlighting();
    assertEmpty(DaemonAnalyzerTestCase.filter(infos, HighlightSeverity.ERROR));
    UIUtil.dispatchAllInvocationEvents();
    FileEditorManagerEx.getInstanceEx(getProject()).closeAllFiles();
  }
  System.out.println(System.currentTimeMillis() - time+"ms");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:HighlightStressTest.java

示例3: testClassShouldNotDisappearWithoutEvents_NoDocument

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_NoDocument() throws IOException {
  PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
  final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());

  final VirtualFile file = myFixture.addFileToProject("Foo.java", "class Foo {}").getVirtualFile();
  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
  long count1 = tracker.getJavaStructureModificationCount();

  // gc softly-referenced file and document
  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
  assertNull(psiManager.getFileManager().getCachedPsiFile(file));

  VfsUtil.saveText(file, "");
  assertNull(FileDocumentManager.getInstance().getCachedDocument(file));

  assertNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
  assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PsiModificationTrackerTest.java

示例4: testClassShouldNotDisappearWithoutEvents_VirtualFileDeleted

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_VirtualFileDeleted() throws IOException {
  PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
  final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());

  final VirtualFile file = myFixture.addFileToProject("Foo.java", "class Foo {}").getVirtualFile();
  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
  long count1 = tracker.getJavaStructureModificationCount();

  // gc softly-referenced file and document
  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
  assertNull(psiManager.getFileManager().getCachedPsiFile(file));
  file.delete(this);

  assertNull(JavaPsiFacade.getInstance(getProject()).findClass("Foo", GlobalSearchScope.allScope(getProject())));
  assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiModificationTrackerTest.java

示例5: testClassShouldNotDisappearWithoutEvents_ParentVirtualDirectoryDeleted

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public void testClassShouldNotDisappearWithoutEvents_ParentVirtualDirectoryDeleted() throws IOException {
  PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
  final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());

  final VirtualFile file = myFixture.addFileToProject("foo/Foo.java", "package foo; class Foo {}").getVirtualFile();
  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
  long count1 = tracker.getJavaStructureModificationCount();

  // gc softly-referenced file and document
  PlatformTestUtil.tryGcSoftlyReachableObjects();
  assertNull(FileDocumentManager.getInstance().getCachedDocument(file));
  assertNull(psiManager.getFileManager().getCachedPsiFile(file));
  file.getParent().delete(this);

  assertNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", GlobalSearchScope.allScope(getProject())));
  assertFalse(count1 == tracker.getJavaStructureModificationCount());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PsiModificationTrackerTest.java

示例6: testVirtualFileRename_WithPsi

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public void testVirtualFileRename_WithPsi() throws IOException {
  PsiModificationTracker tracker = PsiManager.getInstance(getProject()).getModificationTracker();
  final PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(getProject());
  GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());

  final VirtualFile file = myFixture.addFileToProject("foo/Foo.java", "package foo; class Foo {}").getVirtualFile();
  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", scope));
  long count1 = tracker.getModificationCount();
  long hc = psiManager.findFile(file).hashCode();
  long stamp1 = psiManager.findFile(file).getModificationStamp();

  file.rename(this, "Bar.java");

  assertNotNull(JavaPsiFacade.getInstance(getProject()).findClass("foo.Foo", scope));
  assertTrue(count1 != tracker.getModificationCount());
  assertTrue(stamp1 != psiManager.findFile(file).getModificationStamp());
  assertEquals(hc, psiManager.findFile(file).hashCode());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:PsiModificationTrackerTest.java

示例7: hasErrors

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public static boolean hasErrors(@NotNull final Project project, @NotNull final VirtualFile virtualFile) {
  if (project.isDisposed() || !virtualFile.isValid()) {
    return false;
  }
  return ApplicationManager.getApplication().runReadAction(new Computable<Boolean>() {
    @Override
    public Boolean compute() {
      if (project.isDisposed()) {
        return false;
      }
      PsiManagerEx psiManager = (PsiManagerEx)PsiManager.getInstance(project);
      PsiFile psiFile = psiManager.getFileManager().findFile(virtualFile);
      return psiFile != null && hasErrors(psiFile);
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:PsiErrorElementUtil.java

示例8: getManager

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public PsiManagerEx getManager() {
  Project project = ProjectCoreUtil.theOnlyOpenProject();
  if (project != null) {
    return (PsiManagerEx)PsiManager.getInstance(project);
  }
  TreeElement element;
  for (element = this; element.getTreeParent() != null; element = element.getTreeParent()) {
  }

  if (element instanceof FileElement) { //TODO!!
    return element.getManager();
  }
  else {
    if (getTreeParent() != null) {
      return getTreeParent().getManager();
    }
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:TreeElement.java

示例9: doActualPsiChange

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
@Override
void doActualPsiChange(@NotNull PsiFile file, @NotNull ASTDiffBuilder astDiffBuilder) {
  ASTNode child = myOldNode;
  ASTNode parent = myOldParent;

  PsiElement psiParent = parent.getPsi();
  PsiElement psiChild = file.isPhysical() ? child.getPsi() : null;

  if (psiParent != null && psiChild != null) {
    PsiTreeChangeEventImpl event = new PsiTreeChangeEventImpl(file.getManager());
    event.setParent(psiParent);
    event.setChild(psiChild);
    event.setFile(file);
    ((PsiManagerEx)file.getManager()).beforeChildRemoval(event);
  }

  astDiffBuilder.nodeDeleted(parent, child);

  ((TreeElement)child).rawRemove();
  ((CompositeElement)parent).subtreeChanged();

  DebugUtil.checkTreeStructure(parent);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:DiffLog.java

示例10: reloadPsi

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
private static void reloadPsi(final VirtualFile file, final Project project) {
  final FileManagerImpl fileManager = (FileManagerImpl)((PsiManagerEx)PsiManager.getInstance(project)).getFileManager();
  if (fileManager.findCachedViewProvider(file) != null) {
    UIUtil.invokeLaterIfNeeded(new Runnable() {
      @Override
      public void run() {
        if (project.isDisposed()) {
          return;
        }
        ApplicationManager.getApplication().runWriteAction(new Runnable() {
          @Override
          public void run() {
            fileManager.forceReload(file);
          }
        });
      }
    });
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PushedFilePropertiesUpdaterImpl.java

示例11: getParameterTypes

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
@Override
public PsiType[] getParameterTypes() {
  ArrayList<PsiType> types = new ArrayList<PsiType>();
  PsiManagerEx manager = getManager();
  GlobalSearchScope scope = GlobalSearchScope.allScope(getProject());
  PsiElementFactory factory = JavaPsiFacade.getInstance(getProject()).getElementFactory();
  for (GrDocMethodParameter parameter : getParameters()) {
    GrDocReferenceElement typeElement = parameter.getTypeElement();
    try {
      PsiType type = factory.createTypeFromText(typeElement.getText(), this);
      type = TypesUtil.boxPrimitiveType(type, manager, scope);
      types.add(type);
    } catch (IncorrectOperationException e) {
      LOG.info(e);
      types.add(null);
    }
  }
  return types.toArray(PsiType.createArray(types.size()));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GrDocMethodParamsImpl.java

示例12: getReferenceElements

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
@Override
@NotNull
public PsiJavaCodeReferenceElement[] getReferenceElements() {
  PsiClassType[] types = getReferencedTypes();
  if (types.length == 0) return PsiJavaCodeReferenceElement.EMPTY_ARRAY;

  PsiManagerEx manager = getManager();

  List<PsiJavaCodeReferenceElement> result = ContainerUtil.newArrayList();
  for (PsiClassType type : types) {
    PsiClassType.ClassResolveResult resolveResult = type.resolveGenerics();
    PsiClass resolved = resolveResult.getElement();
    if (resolved != null) {
      result.add(new LightClassReference(manager, type.getCanonicalText(), resolved, resolveResult.getSubstitutor()));
    }
  }
  return result.toArray(new PsiJavaCodeReferenceElement[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GrThrowsClauseImpl.java

示例13: testInMemoryFileHandledGracefully

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
@Test
public void testInMemoryFileHandledGracefully() {
  createBuildFile(new WorkspacePath("java/com/google/BUILD"), "glob(['**/*.java'])");

  LightVirtualFile inMemoryFile =
      new LightVirtualFile("mockProjectViewFile", ProjectViewLanguage.INSTANCE, "");

  FileManager fileManager =
      ((PsiManagerEx) PsiManager.getInstance(getProject())).getFileManager();
  fileManager.setViewProvider(
      inMemoryFile, fileManager.createFileViewProvider(inMemoryFile, true));

  PsiFile psiFile = fileManager.findFile(inMemoryFile);

  FindUsages.findAllReferences(psiFile);
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:17,代码来源:GlobFindUsagesTest.java

示例14: enableLanguageSupport

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
private static void enableLanguageSupport(Project project) {
  OCLanguage.LANGUAGE_SUPPORT_DISABLED.set(project, false);
  UIUtil.invokeLaterIfNeeded(
      () ->
          ApplicationManager.getApplication()
              .runWriteAction(
                  () -> {
                    if (project.isDisposed()) {
                      return;
                    }
                    Language langToReset = PlainTextLanguage.INSTANCE;
                    FileManager fileManager =
                        ((PsiManagerEx) PsiManager.getInstance(project)).getFileManager();
                    for (PsiFile file : fileManager.getAllCachedFiles()) {
                      if (file.getLanguage() == langToReset) {
                        VirtualFile vf = OCInclusionContextUtil.getVirtualFile(file);
                        if (vf != null) {
                          fileManager.setViewProvider(vf, null);
                        }
                      }
                    }
                  }));
}
 
开发者ID:bazelbuild,项目名称:intellij,代码行数:24,代码来源:StubOCWorkspaceManager.java

示例15: decompile

import com.intellij.psi.impl.PsiManagerEx; //导入依赖的package包/类
public static String decompile(PsiManager manager, VirtualFile file) {
  ClsFileImpl psiFile = null;

  final FileViewProvider provider = ((PsiManagerEx)manager).getFileManager().findViewProvider(file);
  if (provider != null) {
    final PsiFile psi = provider.getPsi(provider.getBaseLanguage());
    if (psi instanceof ClsFileImpl) {
      psiFile = (ClsFileImpl)psi;
    }
  }

  if (psiFile == null) {
    psiFile = new ClsFileImpl((PsiManagerImpl)manager, new ClassFileViewProvider(manager, file), true);
  }

  final StringBuilder buffer = new StringBuilder();
  psiFile.appendMirrorText(0, buffer);
  return buffer.toString();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:ClsFileImpl.java


注:本文中的com.intellij.psi.impl.PsiManagerEx类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。