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

项目:consulo-java    文件:JavaConstantExpressionEvaluator.java   
public static Object computeConstantExpression(PsiExpression expression, @Nullable Set<PsiVariable> visitedVars, boolean throwExceptionOnOverflow,
                                               final PsiConstantEvaluationHelper.AuxEvaluator auxEvaluator) {
  if (expression == null) return null;

  JavaConstantExpressionEvaluator evaluator = new JavaConstantExpressionEvaluator(visitedVars, throwExceptionOnOverflow, expression.getProject(), auxEvaluator);

  if (expression instanceof PsiCompiledElement) {
    // in case of compiled elements we are not allowed to use PSI walking
    // but really in Cls there are only so many cases to handle
    if (expression instanceof PsiPrefixExpression) {
      PsiElement operand = ((PsiPrefixExpression)expression).getOperand();
      if (operand == null) return null;
      Object value = evaluator.myConstantExpressionVisitor.handle(operand);
      ConstantExpressionVisitor.store(operand, value);
    }
    return evaluator.myConstantExpressionVisitor.handle(expression);
  }
  expression.accept(evaluator);
  Object cached = evaluator.getCached(expression);
  return cached == NO_VALUE ? null : cached;
}
项目:intellij-ce-playground    文件:ReplaceStaticVariableIncrementDecrement.java   
public ReplaceStaticVariableIncrementDecrement(PsiExpression reference, String originalClassName) {
  super(reference);
  this.originalClassName = originalClassName;
  final PsiPrefixExpression prefixExpr = PsiTreeUtil.getParentOfType(reference, PsiPrefixExpression.class);
  if (prefixExpr != null) {
    this.reference = prefixExpr;
  }
  else {
    this.reference = PsiTreeUtil.getParentOfType(reference, PsiPostfixExpression.class);
  }
}
项目:intellij-ce-playground    文件:ExtractIncrementIntention.java   
@Override
public String getTextForElement(PsiElement element) {
  final PsiJavaToken sign;
  if (element instanceof PsiPostfixExpression) {
    sign = ((PsiPostfixExpression)element).getOperationSign();
  }
  else {
    sign = ((PsiPrefixExpression)element).getOperationSign();
  }
  final String operator = sign.getText();
  return IntentionPowerPackBundle.message(
    "extract.increment.intention.name", operator);
}
项目:tools-idea    文件:ReplaceStaticVariableIncrementDecrement.java   
public ReplaceStaticVariableIncrementDecrement(PsiExpression reference, String originalClassName) {
  super(reference);
  this.originalClassName = originalClassName;
  final PsiPrefixExpression prefixExpr = PsiTreeUtil.getParentOfType(reference, PsiPrefixExpression.class);
  if (prefixExpr != null) {
    this.reference = prefixExpr;
  }
  else {
    this.reference = PsiTreeUtil.getParentOfType(reference, PsiPostfixExpression.class);
  }
}
项目:tools-idea    文件:UnaryPlusInspection.java   
@Override
public void visitPrefixExpression(
  PsiPrefixExpression prefixExpression) {
  super.visitPrefixExpression(prefixExpression);
  final PsiJavaToken token = prefixExpression.getOperationSign();
  final IElementType tokenType = token.getTokenType();
  if (!tokenType.equals(JavaTokenType.PLUS)) {
    return;
  }
  registerError(token);
}
项目:consulo-java    文件:ReplaceStaticVariableIncrementDecrement.java   
public ReplaceStaticVariableIncrementDecrement(PsiExpression reference, String originalClassName) {
  super(reference);
  this.originalClassName = originalClassName;
  final PsiPrefixExpression prefixExpr = PsiTreeUtil.getParentOfType(reference, PsiPrefixExpression.class);
  if (prefixExpr != null) {
    this.reference = prefixExpr;
  }
  else {
    this.reference = PsiTreeUtil.getParentOfType(reference, PsiPostfixExpression.class);
  }
}
项目:consulo-java    文件:UnaryPlusInspection.java   
@Override
public void visitPrefixExpression(
  PsiPrefixExpression prefixExpression) {
  super.visitPrefixExpression(prefixExpression);
  final PsiJavaToken token = prefixExpression.getOperationSign();
  final IElementType tokenType = token.getTokenType();
  if (!tokenType.equals(JavaTokenType.PLUS)) {
    return;
  }
  registerError(token);
}
项目:Android_Lint_SRP_Practice_Example    文件:PsiClassStructureDetector.java   
@Override
public void visitPrefixExpression(PsiPrefixExpression expression) {
    mVisitor.report("PsiPrefixExpression", expression.getText(), expression);
    super.visitExpression(expression);
}