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

项目:retrofit2-lint    文件:UnusedCallObjectDetector.java   
private boolean isCallResultUsed(PsiMethodCallExpression call) {
    if (hasChainedMethodCall(call)) {
        return true;
    } else if (getBoundVariable(call, true) != null) {
        // TODO: Check that variable is actually used
        return true;
    } else if (PsiTreeUtil.getParentOfType(call, PsiReturnStatement.class) != null) {
        return true;
    } else if (PsiTreeUtil.getParentOfType(call, PsiMethodCallExpression.class) != null) {
        return true;
    }
    return false;
}
项目:intellij-ce-playground    文件:ReturnFromFinallyBlockInspection.java   
@Override
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
  super.visitReturnStatement(statement);
  if (!ControlFlowUtils.isInFinallyBlock(statement)) {
    return;
  }
  registerStatementError(statement);
}
项目:tools-idea    文件:ReturnFromFinallyBlockInspection.java   
@Override
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
  super.visitReturnStatement(statement);
  if (!ControlFlowUtils.isInFinallyBlock(statement)) {
    return;
  }
  registerStatementError(statement);
}
项目:consulo-java    文件:VariableReturnedVisitor.java   
@Override
public void visitReturnStatement(@NotNull PsiReturnStatement returnStatement) {
  if (returned) {
    return;
  }
  super.visitReturnStatement(returnStatement);
  final PsiExpression returnValue = returnStatement.getReturnValue();
  if (VariableAccessUtils.mayEvaluateToVariable(returnValue, variable, myBuilderPattern)) {
    returned = true;
  }
}
项目:consulo-java    文件:Intention.java   
protected static void addStatementBefore(String newStatementText, PsiReturnStatement anchor) {
  final Project project = anchor.getProject();
  final PsiElementFactory factory = JavaPsiFacade.getElementFactory(project);
  final PsiStatement newStatement = factory.createStatementFromText(newStatementText, anchor);
  final PsiElement addedStatement = anchor.getParent().addBefore(newStatement, anchor);
  CodeStyleManager.getInstance(project).reformat(addedStatement);
}
项目:consulo-java    文件:IfStatementWithIdenticalBranchesInspection.java   
private void checkIfStatementWithoutElseBranch(
  PsiIfStatement ifStatement) {
  final PsiStatement thenBranch = ifStatement.getThenBranch();
  if (ControlFlowUtils.statementMayCompleteNormally(thenBranch)) {
    return;
  }
  PsiStatement nextStatement = getNextStatement(ifStatement);
  if (thenBranch instanceof PsiBlockStatement) {
    final PsiBlockStatement blockStatement =
      (PsiBlockStatement)thenBranch;
    final PsiCodeBlock codeBlock = blockStatement.getCodeBlock();
    final PsiStatement[] statements = codeBlock.getStatements();
    final PsiStatement lastStatement =
      statements[statements.length - 1];
    for (PsiStatement statement : statements) {
      if (nextStatement == null) {
        if (statement == lastStatement &&
            statement instanceof PsiReturnStatement) {
          final PsiReturnStatement returnStatement =
            (PsiReturnStatement)statement;
          if (returnStatement.getReturnValue() == null) {
            registerStatementError(ifStatement);
          }
        }
        return;
      }
      else if (!EquivalenceChecker.getCanonicalPsiEquivalence().statementsAreEquivalent(
        statement, nextStatement)) {
        return;
      }
      nextStatement = getNextStatement(nextStatement);
    }
  }
  else if (!EquivalenceChecker.getCanonicalPsiEquivalence().statementsAreEquivalent(
    thenBranch, nextStatement)) {
    return;
  }
  registerStatementError(ifStatement);
}
项目:consulo-java    文件:ReturnFromFinallyBlockInspection.java   
@Override
public void visitReturnStatement(@NotNull PsiReturnStatement statement) {
  super.visitReturnStatement(statement);
  if (!ControlFlowUtils.isInFinallyBlock(statement)) {
    return;
  }
  registerStatementError(statement);
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitReturnStatement(PsiReturnStatement statement) {
    mVisitor.report("PsiReturnStatement", statement.getText(), statement);
    super.visitStatement(statement);
}
项目:intellij-ce-playground    文件:WrapReturnValue.java   
public WrapReturnValue(@NotNull PsiReturnStatement statement, @NotNull String type) {
  super(statement);
  myStatement = statement;
  myType = type;
}
项目:intellij-ce-playground    文件:ReturnWrappedValue.java   
public ReturnWrappedValue(PsiReturnStatement statement) {
  super(statement);
  myStatement = statement;
}
项目:tools-idea    文件:CheckReturnValueInstruction.java   
public CheckReturnValueInstruction(final PsiReturnStatement aReturn) {
  myReturn = aReturn;
}
项目:tools-idea    文件:CheckReturnValueInstruction.java   
public PsiReturnStatement getReturn() {
  return myReturn;
}
项目:tools-idea    文件:WrapReturnValue.java   
public WrapReturnValue(PsiReturnStatement statement, String type) {
    super(statement);
    this.type = type;
    this.statement = statement;
}
项目:tools-idea    文件:ReturnWrappedValue.java   
public ReturnWrappedValue(PsiReturnStatement statement) {
    super(statement);
    this.statement = statement;
}
项目:consulo-java    文件:WrapReturnValue.java   
public WrapReturnValue(PsiReturnStatement statement, String type) {
    super(statement);
    this.type = type;
    this.statement = statement;
}
项目:consulo-java    文件:ReturnWrappedValue.java   
public ReturnWrappedValue(PsiReturnStatement statement) {
    super(statement);
    this.statement = statement;
}
项目:consulo-java    文件:JavaSimpleGetterProvider.java   
@Override
public boolean isInsideSimpleGetter(@NotNull PsiElement element)
{
    PsiMethod method = PsiTreeUtil.getParentOfType(element, PsiMethod.class);
    if(method == null)
    {
        return false;
    }

    final PsiCodeBlock body = method.getBody();
    if(body == null)
    {
        return false;
    }

    final PsiStatement[] statements = body.getStatements();
    if(statements.length != 1)
    {
        return false;
    }

    final PsiStatement statement = statements[0];
    if(!(statement instanceof PsiReturnStatement))
    {
        return false;
    }

    final PsiExpression value = ((PsiReturnStatement) statement).getReturnValue();
    if(!(value instanceof PsiReferenceExpression))
    {
        return false;
    }

    final PsiReferenceExpression reference = (PsiReferenceExpression) value;
    final PsiExpression qualifier = reference.getQualifierExpression();
    //noinspection HardCodedStringLiteral
    if(qualifier != null && !"this".equals(qualifier.getText()))
    {
        return false;
    }

    final PsiElement referent = reference.resolve();
    if(referent == null)
    {
        return false;
    }

    if(!(referent instanceof PsiField))
    {
        return false;
    }

    return Comparing.equal(((PsiField) referent).getContainingClass(), method.getContainingClass());
}
项目:intellij-ce-playground    文件:LeaveCodeBlockEnterProcessor.java   
/**
 * Handles situations like the one below:
 * <pre>
 *   void foo(int i) {
 *     if (i < 0) {
 *       return;[caret]
 *     }
 *   }
 * </pre>
 * 
 * <b>Output:</b>
 * <pre>
 *   void foo(int i) {
 *     if (i < 0) {
 *       return;
 *     }
 *     [caret]
 *   }
 * </pre>
 * 
 * @param element
 * @return
 */
private static boolean isControlFlowBreak(@Nullable PsiElement element) {
  return element instanceof PsiReturnStatement || element instanceof PsiThrowStatement;
}
项目:tools-idea    文件:LeaveCodeBlockEnterProcessor.java   
/**
 * Handles situations like the one below:
 * <pre>
 *   void foo(int i) {
 *     if (i < 0) {
 *       return;[caret]
 *     }
 *   }
 * </pre>
 * 
 * <b>Output:</b>
 * <pre>
 *   void foo(int i) {
 *     if (i < 0) {
 *       return;
 *     }
 *     [caret]
 *   }
 * </pre>
 * 
 * @param element
 * @return
 */
private static boolean isControlFlowBreak(@Nullable PsiElement element) {
  return element instanceof PsiReturnStatement || element instanceof PsiThrowStatement;
}
项目:consulo-java    文件:LeaveCodeBlockEnterProcessor.java   
/**
 * Handles situations like the one below:
 * <pre>
 *   void foo(int i) {
 *     if (i < 0) {
 *       return;[caret]
 *     }
 *   }
 * </pre>
 * <p>
 * <b>Output:</b>
 * <pre>
 *   void foo(int i) {
 *     if (i < 0) {
 *       return;
 *     }
 *     [caret]
 *   }
 * </pre>
 *
 * @param element
 * @return
 */
private static boolean isControlFlowBreak(@Nullable PsiElement element)
{
    return element instanceof PsiReturnStatement || element instanceof PsiThrowStatement;
}
项目:intellij-ce-playground    文件:ReturnStatementsVisitor.java   
void visit(final List<PsiReturnStatement> returnStatements) throws IncorrectOperationException;
项目:tools-idea    文件:ReturnStatementsVisitor.java   
void visit(final List<PsiReturnStatement> returnStatements) throws IncorrectOperationException;
项目:consulo-java    文件:ReturnStatementsVisitor.java   
void visit(final List<PsiReturnStatement> returnStatements) throws IncorrectOperationException;