use of com.intellij.psi.PsiForeachStatement in project intellij-community by JetBrains.
the class ForStatementHeaderSelectioner method select.
@Override
public List<TextRange> select(PsiElement e, CharSequence editorText, int cursorOffset, Editor editor) {
PsiJavaToken lParen = e instanceof PsiForStatement ? ((PsiForStatement) e).getLParenth() : e instanceof PsiForeachStatement ? ((PsiForeachStatement) e).getLParenth() : null;
PsiJavaToken rParen = e instanceof PsiForStatement ? ((PsiForStatement) e).getRParenth() : e instanceof PsiForeachStatement ? ((PsiForeachStatement) e).getRParenth() : null;
if (lParen == null || rParen == null)
return null;
TextRange result = new TextRange(lParen.getTextRange().getEndOffset(), rParen.getTextRange().getStartOffset());
return result.containsOffset(cursorOffset) ? Collections.singletonList(result) : null;
}
Aggregations