private boolean isApplicableEditor(TextEditor textEditor) { final Document document = textEditor.getEditor().getDocument(); final PsiFile psiFile = PsiDocumentManager.getInstance(myProject).getPsiFile(document); // In theory, we should just check // LayoutDomFileDescription.isLayoutFile((XmlFile)psiFile); // here, but there are problems where files don't show up with layout preview // at startup, presumably because the resource directories haven't been properly // initialized yet. return isInResourceFolder(psiFile); }
@NotNull private TextChunk[] initChunks() { PsiFile psiFile = getPsiFile(); Document document = psiFile == null ? null : PsiDocumentManager.getInstance(getProject()).getDocument(psiFile); TextChunk[] chunks; if (document == null) { // element over light virtual file PsiElement element = getElement(); chunks = new TextChunk[] {new TextChunk(new TextAttributes(), element.getText())}; } else { chunks = ChunkExtractor.extractChunks(psiFile, this); } myTextChunks = new SoftReference<TextChunk[]>(chunks); return chunks; }
public Document getDocument() { PsiFile file = getUsageInfo().getFile(); if (file == null) return null; return PsiDocumentManager.getInstance(getProject()).getDocument(file); }