本文整理汇总了Java中com.intellij.psi.FileViewProvider.findElementAt方法的典型用法代码示例。如果您正苦于以下问题:Java FileViewProvider.findElementAt方法的具体用法?Java FileViewProvider.findElementAt怎么用?Java FileViewProvider.findElementAt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.FileViewProvider
的用法示例。
在下文中一共展示了FileViewProvider.findElementAt方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getLineExtensions
import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
public Collection<LineExtensionInfo> getLineExtensions(@NotNull Project project, @NotNull VirtualFile file, int lineNumber) {
List<LineExtensionInfo> res = ContainerUtil.newSmartList();
PsiDocumentManager psiDocumentManager = PsiDocumentManager.getInstance(project);
final Document doc = FileDocumentManager.getInstance().getDocument(file);
if (doc != null && lineNumber < doc.getLineCount()) {
PsiFile psiFile = psiDocumentManager.getPsiFile(doc);
if (psiFile != null) {
int offset = doc.getLineStartOffset(lineNumber);
FileViewProvider viewProvider = psiFile.getViewProvider();
PsiElement element = viewProvider.findElementAt(offset);
while (element != null) {
int startOffset = element.getTextRange().getStartOffset();
if (startOffset >= doc.getTextLength()) break;
int startOffsetLine = doc.getLineNumber(startOffset);
if (startOffsetLine < lineNumber) {
element = PsiTreeUtil.nextVisibleLeaf(element);
continue;
}
if (startOffsetLine > lineNumber) break;
try {
element = addExtensions(res, element);
} catch (IndexNotReadyException ignored) { element = null; }
}
}
}
return res;
}
示例2: doCollectInformation
import com.intellij.psi.FileViewProvider; //导入方法依赖的package包/类
@Override
public void doCollectInformation(@NotNull ProgressIndicator progress) {
if (ApplicationManager.getApplication().isUnitTestMode()) {
return;
}
if (!WebEditorOptions.getInstance().isTagTreeHighlightingEnabled()) {
return;
}
final int offset = myEditor.getCaretModel().getOffset();
PsiElement[] elements = BreadcrumbsXmlWrapper.getLinePsiElements(offset,
myFile.getVirtualFile(),
myProject, myInfoProvider);
if (elements == null || elements.length == 0 || !XmlTagTreeHighlightingUtil.containsTagsWithSameName(elements)) {
elements = PsiElement.EMPTY_ARRAY;
final FileViewProvider provider = myFile.getViewProvider();
for (Language language : provider.getLanguages()) {
PsiElement element = provider.findElementAt(offset, language);
if (!isTagStartOrEnd(element)) {
element = null;
}
if (element == null && offset > 0) {
element = provider.findElementAt(offset - 1, language);
if (!isTagStartOrEnd(element)) element = null;
}
final XmlTag tag = PsiTreeUtil.getParentOfType(element, XmlTag.class);
if (tag != null) {
elements = new PsiElement[] {tag};
}
}
}
for (int i = elements.length - 1; i >= 0; i--) {
if (elements[i] instanceof XmlTag) {
myPairsToHighlight.add(getTagRanges((XmlTag)elements[i]));
}
}
}