Java Code Examples for com.intellij.psi.util.PsiTreeUtil#getDeepestLast()
The following examples show how to use
com.intellij.psi.util.PsiTreeUtil#getDeepestLast() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Identikit.java From consulo with Apache License 2.0 | 6 votes |
public PsiElement findInside(@Nonnull PsiElement element, int startOffset, int endOffset) { PsiElement anchor = AbstractFileViewProvider.findElementAt(element, startOffset); // finds child in this tree only, unlike PsiElement.findElementAt() if (anchor == null && startOffset == element.getTextLength()) { anchor = PsiTreeUtil.getDeepestLast(element); } if (anchor == null) return null; PsiElement result = findParent(startOffset, endOffset, anchor); if (endOffset == startOffset) { while ((result == null || result.getTextRange().getStartOffset() != startOffset) && anchor.getTextRange().getStartOffset() == endOffset) { anchor = PsiTreeUtil.prevLeaf(anchor, false); if (anchor == null) break; result = findParent(startOffset, endOffset, anchor); } } return result; }
Example 2
Source File: CompletionInitializationUtil.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull private static PsiElement findCompletionPositionLeaf(OffsetsInFile offsets, int offset, PsiFile originalFile) { PsiElement insertedElement = offsets.getFile().findElementAt(offset); if (insertedElement == null && offsets.getFile().getTextLength() == offset) { insertedElement = PsiTreeUtil.getDeepestLast(offsets.getFile()); } CompletionAssertions.assertCompletionPositionPsiConsistent(offsets, offset, originalFile, insertedElement); return insertedElement; }