use of com.intellij.psi.impl.source.tree.FileElement in project intellij-community by JetBrains.
the class SingleRootFileViewProvider method getKnownTreeRoots.
@NotNull
public List<FileElement> getKnownTreeRoots() {
PsiFile psiFile = getCachedPsi(myBaseLanguage);
if (!(psiFile instanceof PsiFileImpl))
return Collections.emptyList();
FileElement element = ((PsiFileImpl) psiFile).getTreeElement();
return ContainerUtil.createMaybeSingletonList(element);
}
use of com.intellij.psi.impl.source.tree.FileElement in project intellij-community by JetBrains.
the class SingleRootFileViewProvider method checkLengthConsistency.
private void checkLengthConsistency() {
Document document = getCachedDocument();
if (document instanceof DocumentWindow) {
return;
}
if (document != null && ((PsiDocumentManagerBase) PsiDocumentManager.getInstance(myManager.getProject())).getSynchronizer().isInSynchronization(document)) {
return;
}
List<FileElement> knownTreeRoots = getKnownTreeRoots();
if (knownTreeRoots.isEmpty())
return;
int fileLength = myContent.getTextLength();
for (FileElement fileElement : knownTreeRoots) {
int nodeLength = fileElement.getTextLength();
if (nodeLength != fileLength) {
PsiUtilCore.ensureValid(fileElement.getPsi());
List<Attachment> attachments = ContainerUtil.newArrayList(new Attachment(myVirtualFile.getNameWithoutExtension() + ".tree.txt", fileElement.getText()), new Attachment(myVirtualFile.getNameWithoutExtension() + ".file.txt", myContent.toString()));
if (document != null) {
attachments.add(new Attachment(myVirtualFile.getNameWithoutExtension() + ".document.txt", document.getText()));
}
// exceptions here should be assigned to peter
LOG.error("Inconsistent " + fileElement.getElementType() + " tree in " + this + "; nodeLength=" + nodeLength + "; fileLength=" + fileLength, attachments.toArray(Attachment.EMPTY_ARRAY));
}
}
}
use of com.intellij.psi.impl.source.tree.FileElement in project intellij-community by JetBrains.
the class CodeInsightTestFixtureImpl method collectAndCheckHighlighting.
private long collectAndCheckHighlighting(@NotNull ExpectedHighlightingData data) {
final Project project = getProject();
PsiDocumentManager.getInstance(project).commitAllDocuments();
PsiFileImpl file = (PsiFileImpl) getHostFile();
//to load text
FileElement hardRefToFileElement = file.calcTreeElement();
//to initialize caches
if (!DumbService.isDumb(project)) {
CacheManager.SERVICE.getInstance(project).getFilesWithWord("XXX", UsageSearchContext.IN_COMMENTS, GlobalSearchScope.allScope(project), true);
}
final long start = System.currentTimeMillis();
final VirtualFileFilter fileTreeAccessFilter = myVirtualFileFilter;
Disposable disposable = Disposer.newDisposable();
if (fileTreeAccessFilter != null) {
PsiManagerEx.getInstanceEx(project).setAssertOnFileLoadingFilter(fileTreeAccessFilter, disposable);
}
// ProfilingUtil.startCPUProfiling();
List<HighlightInfo> infos;
try {
infos = doHighlighting();
removeDuplicatedRangesForInjected(infos);
} finally {
Disposer.dispose(disposable);
}
// ProfilingUtil.captureCPUSnapshot("testing");
final long elapsed = System.currentTimeMillis() - start;
data.checkResult(infos, file.getText());
if (data.hasLineMarkers()) {
Document document = getDocument(getFile());
data.checkLineMarkers(DaemonCodeAnalyzerImpl.getLineMarkers(document, getProject()), document.getText());
}
//noinspection ResultOfMethodCallIgnored
// use it so gc won't collect it
hardRefToFileElement.hashCode();
return elapsed;
}
use of com.intellij.psi.impl.source.tree.FileElement in project intellij-community by JetBrains.
the class GroovyCodeFragment method clone.
@Override
protected GroovyCodeFragment clone() {
final GroovyCodeFragment clone = (GroovyCodeFragment) cloneImpl((FileElement) calcTreeElement().clone());
clone.myOriginalFile = this;
clone.myPseudoImports.putAll(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.source.tree.FileElement 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;
}
Aggregations