本文整理汇总了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;
}
示例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");
}
示例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());
}
示例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());
}
示例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());
}
示例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());
}
示例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);
}
});
}
示例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;
}
}
示例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);
}
示例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);
}
});
}
});
}
}
示例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()));
}
示例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()]);
}
示例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);
}
示例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);
}
}
}
}));
}
示例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();
}