use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.
the class GrThrowsClauseImpl method getReferenceElements.
@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()]);
}
use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.
the class PsiCodeFragmentImpl method clone.
@Override
protected PsiCodeFragmentImpl clone() {
final PsiCodeFragmentImpl clone = (PsiCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
clone.myPhysical = false;
clone.myOriginalFile = this;
clone.myPseudoImports = new LinkedHashMap<>(myPseudoImports);
FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
cloneViewProvider.forceCachedPsi(clone);
clone.myViewProvider = cloneViewProvider;
return clone;
}
use of com.intellij.psi.impl.PsiManagerEx in project intellij-community by JetBrains.
the class ASTDelegatePsiElement method getManager.
@Override
public PsiManagerEx getManager() {
Project project = ProjectCoreUtil.theOnlyOpenProject();
if (project != null) {
return PsiManagerEx.getInstanceEx(project);
}
PsiElement parent = this;
while (parent instanceof ASTDelegatePsiElement) {
parent = parent.getParent();
}
if (parent == null) {
throw new PsiInvalidElementAccessException(this);
}
return (PsiManagerEx) parent.getManager();
}
use of com.intellij.psi.impl.PsiManagerEx in project intellij-plugins by JetBrains.
the class DartExpressionCodeFragmentImpl method clone.
protected DartExpressionCodeFragmentImpl clone() {
final DartExpressionCodeFragmentImpl clone = (DartExpressionCodeFragmentImpl) cloneImpl((FileElement) calcTreeElement().clone());
clone.myPhysical = false;
clone.myOriginalFile = this;
final FileManager fileManager = ((PsiManagerEx) getManager()).getFileManager();
final SingleRootFileViewProvider cloneViewProvider = (SingleRootFileViewProvider) fileManager.createFileViewProvider(new LightVirtualFile(getName(), getLanguage(), getText()), false);
clone.myViewProvider = cloneViewProvider;
cloneViewProvider.forceCachedPsi(clone);
clone.init(getContentElementType(), getContentElementType());
return clone;
}
use of com.intellij.psi.impl.PsiManagerEx in project android by JetBrains.
the class ModuleResourceRepositoryTest method testPsiListenerWithVirtualFiles.
/**
* This tests that even if we initialize ResourceFolderRepository with VirtualFiles and the test code is careful to only work with
* VirtualFiles, we still get the PsiListener events.
*
* Namely, {@link com.intellij.psi.impl.file.impl.PsiVFSListener} skips notifying other listeners if the parent directory has never
* been initialized as PSI.
*/
public void testPsiListenerWithVirtualFiles() throws Exception {
final VirtualFile res1 = myFixture.copyFileToProject(LAYOUT, "res/layout/layout.xml").getParent().getParent();
// Stash the resource directory somewhere deep. Sometimes the test framework + VFS listener does automatically create
// a PsiDirectory for the top level. We only want a VirtualFile representation, and not the PsiDirectory representation.
final VirtualFile layout2 = myFixture.copyFileToProject(LAYOUT_OVERLAY, "foo/baz/bar/res/layout/foo_activity.xml");
final VirtualFile res2 = layout2.getParent().getParent();
assertNotSame(res1, res2);
// Check that we indeed don't have the PsiDirectory already cached, by poking at the implementation classes.
PsiManagerEx psiManager = (PsiManagerEx) PsiManager.getInstance(getProject());
FileManagerImpl fileManager = (FileManagerImpl) psiManager.getFileManager();
assertNull(fileManager.getCachedDirectory(res2));
assertNull(fileManager.getCachedPsiFile(layout2));
ModuleResourceRepository resources = ModuleResourceRepository.createForTest(myFacet, Arrays.asList(res1, res2));
assertNotNull(fileManager.getCachedDirectory(res2));
long generation = resources.getModificationCount();
assertTrue(resources.hasResourceItem(ResourceType.LAYOUT, "foo_activity"));
assertFalse(resources.hasResourceItem(ResourceType.LAYOUT, "bar_activity"));
WriteCommandAction.runWriteCommandAction(null, new Runnable() {
@Override
public void run() {
try {
layout2.rename(this, "bar_activity.xml");
} catch (IOException e) {
fail(e.toString());
}
}
});
assertTrue(resources.hasResourceItem(ResourceType.LAYOUT, "bar_activity"));
assertFalse(resources.hasResourceItem(ResourceType.LAYOUT, "foo_activity"));
assertTrue(resources.getModificationCount() > generation);
}
Aggregations