use of com.intellij.psi.PsiForStatement in project intellij-community by JetBrains.
the class ForLoopPredicate method satisfiedBy.
public boolean satisfiedBy(PsiElement element) {
if (!(element instanceof PsiJavaToken)) {
return false;
}
final PsiJavaToken token = (PsiJavaToken) element;
final IElementType tokenType = token.getTokenType();
if (!JavaTokenType.FOR_KEYWORD.equals(tokenType)) {
return false;
}
final PsiElement parent = element.getParent();
return parent instanceof PsiForStatement && !ErrorUtil.containsError(parent);
}
use of com.intellij.psi.PsiForStatement 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