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

项目:intellij-ce-playground    文件:DoWhileConditionFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
  if (psiElement instanceof PsiDoWhileStatement) {
    final Document doc = editor.getDocument();
    final PsiDoWhileStatement stmt = (PsiDoWhileStatement) psiElement;
    if (stmt.getBody() == null || !(stmt.getBody() instanceof PsiBlockStatement) && stmt.getWhileKeyword() == null) {
      final int startOffset = stmt.getTextRange().getStartOffset();
      doc.replaceString(startOffset, startOffset + "do".length(), "do {} while()");
      return;
    }

    if (stmt.getCondition() == null) {
      if (stmt.getWhileKeyword() == null) {
        final int endOffset = stmt.getTextRange().getEndOffset();
        doc.insertString(endOffset, "while()");
      } else if (stmt.getLParenth() == null || stmt.getRParenth() == null) {
        final TextRange whileRange = stmt.getWhileKeyword().getTextRange();
        doc.replaceString(whileRange.getStartOffset(), whileRange.getEndOffset(), "while()");
      } else {
        processor.registerUnresolvedError(stmt.getLParenth().getTextRange().getEndOffset());
      }
    }
  }
}
项目:intellij-ce-playground    文件:DoWhileLoopPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.DO_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiDoWhileStatement)) {
    return false;
  }
  final PsiDoWhileStatement doWhileStatement =
    (PsiDoWhileStatement)parent;
  return !(doWhileStatement.getCondition() == null ||
           doWhileStatement.getBody() == null);
}
项目:tools-idea    文件:DoWhileConditionFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException {
  if (psiElement instanceof PsiDoWhileStatement) {
    final Document doc = editor.getDocument();
    final PsiDoWhileStatement stmt = (PsiDoWhileStatement) psiElement;
    if (stmt.getBody() == null || !(stmt.getBody() instanceof PsiBlockStatement) && stmt.getWhileKeyword() == null) {
      final int startOffset = stmt.getTextRange().getStartOffset();
      doc.replaceString(startOffset, startOffset + "do".length(), "do {} while()");
      return;
    }

    if (stmt.getCondition() == null) {
      if (stmt.getWhileKeyword() == null) {
        final int endOffset = stmt.getTextRange().getEndOffset();
        doc.insertString(endOffset, "while()");
      } else if (stmt.getLParenth() == null || stmt.getRParenth() == null) {
        final TextRange whileRange = stmt.getWhileKeyword().getTextRange();
        doc.replaceString(whileRange.getStartOffset(), whileRange.getEndOffset(), "while()");
      } else {
        processor.registerUnresolvedError(stmt.getLParenth().getTextRange().getEndOffset());
      }
    }
  }
}
项目:tools-idea    文件:DoWhileLoopPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.DO_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiDoWhileStatement)) {
    return false;
  }
  final PsiDoWhileStatement doWhileStatement =
    (PsiDoWhileStatement)parent;
  return !(doWhileStatement.getCondition() == null ||
           doWhileStatement.getBody() == null);
}
项目:consulo-java    文件:DoWhileLoopPredicate.java   
public boolean satisfiedBy(PsiElement element) {
  if (!(element instanceof PsiJavaToken)) {
    return false;
  }
  final PsiJavaToken token = (PsiJavaToken)element;
  final IElementType tokenType = token.getTokenType();
  if (!JavaTokenType.DO_KEYWORD.equals(tokenType)) {
    return false;
  }
  final PsiElement parent = element.getParent();
  if (!(parent instanceof PsiDoWhileStatement)) {
    return false;
  }
  final PsiDoWhileStatement doWhileStatement =
    (PsiDoWhileStatement)parent;
  return !(doWhileStatement.getCondition() == null ||
           doWhileStatement.getBody() == null);
}
项目:consulo-java    文件:DoWhileConditionFixer.java   
@Override
public void apply(Editor editor, JavaSmartEnterProcessor processor, PsiElement psiElement) throws IncorrectOperationException
{
    if(psiElement instanceof PsiDoWhileStatement)
    {
        final Document doc = editor.getDocument();
        final PsiDoWhileStatement stmt = (PsiDoWhileStatement) psiElement;
        if(stmt.getBody() == null || !(stmt.getBody() instanceof PsiBlockStatement) && stmt.getWhileKeyword() == null)
        {
            final int startOffset = stmt.getTextRange().getStartOffset();
            doc.replaceString(startOffset, startOffset + "do".length(), "do {} while()");
            return;
        }

        if(stmt.getCondition() == null)
        {
            if(stmt.getWhileKeyword() == null)
            {
                final int endOffset = stmt.getTextRange().getEndOffset();
                doc.insertString(endOffset, "while()");
            }
            else if(stmt.getLParenth() == null || stmt.getRParenth() == null)
            {
                final TextRange whileRange = stmt.getWhileKeyword().getTextRange();
                doc.replaceString(whileRange.getStartOffset(), whileRange.getEndOffset(), "while()");
            }
            else
            {
                processor.registerUnresolvedError(stmt.getLParenth().getTextRange().getEndOffset());
            }
        }
    }
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitDoWhileStatement(PsiDoWhileStatement statement) {
    mVisitor.report("PsiDoWhileStatement", statement.getText(), statement);
    super.visitStatement(statement);
}
项目:intellij-ce-playground    文件:InfiniteLoopStatementInspection.java   
@Override
public void visitDoWhileStatement(
  @NotNull PsiDoWhileStatement statement) {
  super.visitDoWhileStatement(statement);
  checkStatement(statement);
}
项目:tools-idea    文件:InfiniteLoopStatementInspection.java   
@Override
public void visitDoWhileStatement(
  @NotNull PsiDoWhileStatement statement) {
  super.visitDoWhileStatement(statement);
  checkStatement(statement);
}
项目:consulo-java    文件:InfiniteLoopStatementInspection.java   
@Override
public void visitDoWhileStatement(@NotNull PsiDoWhileStatement statement)
{
    super.visitDoWhileStatement(statement);
    checkStatement(statement);
}