Java 类com.intellij.psi.PsiWhileStatement 实例源码

项目:intellij-ce-playground    文件:WhileLoopPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.WHILE_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiWhileStatement)) {
    return false;
  }
  final PsiWhileStatement whileStatement = (PsiWhileStatement)parent;
  return !(whileStatement.getCondition() == null ||
           whileStatement.getBody() == null);
}
项目:tools-idea    文件:WhileLoopPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.WHILE_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiWhileStatement)) {
    return false;
  }
  final PsiWhileStatement whileStatement = (PsiWhileStatement)parent;
  return !(whileStatement.getCondition() == null ||
           whileStatement.getBody() == null);
}
项目:consulo-java    文件:WhileLoopPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.WHILE_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiWhileStatement)) {
    return false;
  }
  final PsiWhileStatement whileStatement = (PsiWhileStatement)parent;
  return !(whileStatement.getCondition() == null ||
           whileStatement.getBody() == null);
}
项目:consulo-java    文件:WhileConditionFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException
{
    if(psiElement instanceof PsiWhileStatement)
    {
        final Document doc = editor.getDocument();
        final PsiWhileStatement whileStatement = (PsiWhileStatement) psiElement;
        final PsiJavaToken rParenth = whileStatement.getRParenth();
        final PsiJavaToken lParenth = whileStatement.getLParenth();
        final PsiExpression condition = whileStatement.getCondition();

        if(condition == null)
        {
            if(lParenth == null || rParenth == null)
            {
                int stopOffset = doc.getLineEndOffset(doc.getLineNumber(whileStatement.getTextRange().getStartOffset()));
                final PsiStatement block = whileStatement.getBody();
                if(block != null)
                {
                    stopOffset = Math.min(stopOffset, block.getTextRange().getStartOffset());
                }
                stopOffset = Math.min(stopOffset, whileStatement.getTextRange().getEndOffset());

                doc.replaceString(whileStatement.getTextRange().getStartOffset(), stopOffset, "while ()");
                processor.registerUnresolvedError(whileStatement.getTextRange().getStartOffset() + "while (".length());
            }
            else
            {
                processor.registerUnresolvedError(lParenth.getTextRange().getEndOffset());
            }
        }
        else if(rParenth == null)
        {
            doc.insertString(condition.getTextRange().getEndOffset(), ")");
        }
    }
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitWhileStatement(PsiWhileStatement statement) {
    mVisitor.report("PsiWhileStatement", statement.getText(), statement);
    super.visitStatement(statement);
}
项目:intellij-ce-playground    文件:InfiniteLoopStatementInspection.java   
@Override
public void visitWhileStatement(
  @NotNull PsiWhileStatement statement) {
  super.visitWhileStatement(statement);
  checkStatement(statement);
}
项目:tools-idea    文件:InfiniteLoopStatementInspection.java   
@Override
public void visitWhileStatement(
  @NotNull PsiWhileStatement statement) {
  super.visitWhileStatement(statement);
  checkStatement(statement);
}
项目:consulo-java    文件:InfiniteLoopStatementInspection.java   
@Override
public void visitWhileStatement(@NotNull PsiWhileStatement statement)
{
    super.visitWhileStatement(statement);
    checkStatement(statement);
}