use of com.intellij.psi.impl.PsiManagerImpl in project intellij-community by JetBrains.
the class DomStubTest method prepareFile.
protected XmlFile prepareFile(String path) {
VirtualFile virtualFile = myFixture.copyFileToProject(path);
assertNotNull(virtualFile);
XmlFile file = (XmlFile) ((PsiManagerEx) getPsiManager()).getFileManager().findFile(virtualFile);
assertFalse(file.getNode().isParsed());
ObjectStubTree tree = StubTreeLoader.getInstance().readOrBuild(getProject(), virtualFile, file);
assertNotNull("Can't build stubs for " + path, tree);
((PsiManagerImpl) getPsiManager()).cleanupForNextTest();
file = (XmlFile) getPsiManager().findFile(virtualFile);
assertNotNull(file);
return file;
}
use of com.intellij.psi.impl.PsiManagerImpl in project intellij-community by JetBrains.
the class FileBasedIndexImpl method registerIndexableSet.
@Override
public void registerIndexableSet(@NotNull IndexableFileSet set, @Nullable Project project) {
myIndexableSets.add(set);
myIndexableSetToProjectMap.put(set, project);
if (project != null) {
((PsiManagerImpl) PsiManager.getInstance(project)).addTreeChangePreprocessor(event -> {
if (event.isGenericChange() && event.getCode() == PsiTreeChangeEventImpl.PsiEventType.CHILDREN_CHANGED) {
PsiFile file = event.getFile();
if (file != null) {
waitUntilIndicesAreInitialized();
VirtualFile virtualFile = file.getVirtualFile();
if (!clearUpToDateStateForPsiIndicesOfUnsavedDocuments(virtualFile)) {
if (virtualFile instanceof VirtualFileWithId) {
int fileId = ((VirtualFileWithId) virtualFile).getId();
boolean wasIndexed = false;
List<ID<?, ?>> candidates = getAffectedIndexCandidates(virtualFile);
for (ID<?, ?> psiBackedIndex : myPsiDependentIndices) {
if (!candidates.contains(psiBackedIndex))
continue;
if (getInputFilter(psiBackedIndex).acceptInput(virtualFile)) {
getIndex(psiBackedIndex).resetIndexedStateForFile(fileId);
wasIndexed = true;
}
}
if (wasIndexed) {
myChangedFilesCollector.scheduleForUpdate(virtualFile);
IndexingStamp.flushCache(fileId);
}
}
}
}
}
});
}
}
use of com.intellij.psi.impl.PsiManagerImpl in project intellij-community by JetBrains.
the class PsiFileImplUtil method doDelete.
public static void doDelete(@NotNull PsiFile file) throws IncorrectOperationException {
final PsiManagerImpl manager = (PsiManagerImpl) file.getManager();
final VirtualFile vFile = file.getVirtualFile();
try {
vFile.delete(manager);
} catch (IOException e) {
throw new IncorrectOperationException(e);
}
}
use of com.intellij.psi.impl.PsiManagerImpl in project intellij-community by JetBrains.
the class PlatformTestCase method cleanupApplicationCaches.
public static void cleanupApplicationCaches(Project project) {
if (project != null && !project.isDisposed()) {
UndoManagerImpl globalInstance = (UndoManagerImpl) UndoManager.getGlobalInstance();
if (globalInstance != null) {
globalInstance.dropHistoryInTests();
}
((UndoManagerImpl) UndoManager.getInstance(project)).dropHistoryInTests();
((DocumentReferenceManagerImpl) DocumentReferenceManager.getInstance()).cleanupForNextTest();
((PsiManagerImpl) PsiManager.getInstance(project)).cleanupForNextTest();
}
final ProjectManager projectManager = ProjectManager.getInstance();
assert projectManager != null : "The ProjectManager is not initialized yet";
ProjectManagerImpl projectManagerImpl = (ProjectManagerImpl) projectManager;
if (projectManagerImpl.isDefaultProjectInitialized()) {
Project defaultProject = projectManager.getDefaultProject();
((PsiManagerImpl) PsiManager.getInstance(defaultProject)).cleanupForNextTest();
}
AsyncHighlighterUpdater.completeAsyncTasks();
((FileBasedIndexImpl) FileBasedIndex.getInstance()).cleanupForNextTest();
LocalFileSystemImpl localFileSystem = (LocalFileSystemImpl) LocalFileSystem.getInstance();
if (localFileSystem != null) {
localFileSystem.cleanupForNextTest();
}
}
use of com.intellij.psi.impl.PsiManagerImpl in project intellij-community by JetBrains.
the class PsiEventsTest method testTreeChangePreprocessorThrowsException.
public void testTreeChangePreprocessorThrowsException() throws Exception {
VirtualFile vFile = createFile("a.xml", "<tag/>").getVirtualFile();
Document document = FileDocumentManager.getInstance().getDocument(vFile);
assert document != null;
PsiTreeChangePreprocessor preprocessor = event -> {
if (!event.getCode().name().startsWith("BEFORE") && !event.isGenericChange()) {
throw new NullPointerException();
}
};
((PsiManagerImpl) getPsiManager()).addTreeChangePreprocessor(preprocessor);
try {
WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, " "));
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
fail("NPE expected");
} catch (NullPointerException ignore) {
} finally {
((PsiManagerImpl) getPsiManager()).removeTreeChangePreprocessor(preprocessor);
}
WriteCommandAction.runWriteCommandAction(myProject, () -> document.insertString(0, " "));
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
assertEquals(" <tag/>", getPsiManager().findFile(vFile).getText());
}
Aggregations