本文整理匯總了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]));
}
}
}