当前位置: 首页>>代码示例>>Java>>正文


Java VariableAccessUtils.variableIsUsedInInnerClass方法代码示例

本文整理汇总了Java中com.siyeh.ig.psiutils.VariableAccessUtils.variableIsUsedInInnerClass方法的典型用法代码示例。如果您正苦于以下问题:Java VariableAccessUtils.variableIsUsedInInnerClass方法的具体用法?Java VariableAccessUtils.variableIsUsedInInnerClass怎么用?Java VariableAccessUtils.variableIsUsedInInnerClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.siyeh.ig.psiutils.VariableAccessUtils的用法示例。


在下文中一共展示了VariableAccessUtils.variableIsUsedInInnerClass方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkParameter

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private void checkParameter(PsiMethod method, PsiParameter parameter) {
  if (!parameter.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass != null) {
    if (containingClass.isInterface() || containingClass.isAnnotationType()) {
      registerModifierError(PsiModifier.FINAL, parameter, parameter);
      return;
    }
  }
  if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
    registerModifierError(PsiModifier.FINAL, parameter, parameter);
    return;
  }
  if (onlyWarnOnAbstractMethods) {
    return;
  }
  if (VariableAccessUtils.variableIsUsedInInnerClass(parameter, method)) {
    return;
  }
  registerModifierError(PsiModifier.FINAL, parameter, parameter);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java

示例2: visitTryStatement

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitTryStatement(PsiTryStatement statement) {
  super.visitTryStatement(statement);
  if (onlyWarnOnAbstractMethods || !reportParameters) {
    return;
  }
  final PsiCatchSection[] catchSections = statement.getCatchSections();
  for (PsiCatchSection catchSection : catchSections) {
    final PsiParameter parameter = catchSection.getParameter();
    final PsiCodeBlock catchBlock = catchSection.getCatchBlock();
    if (parameter == null || catchBlock == null) {
      continue;
    }
    if (!parameter.hasModifierProperty(PsiModifier.FINAL)) {
      continue;
    }
    if (!VariableAccessUtils.variableIsUsedInInnerClass(
      parameter, catchBlock)) {
      registerModifierError(PsiModifier.FINAL, parameter, parameter);
    }
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java

示例3: visitTryStatement

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitTryStatement(PsiTryStatement statement) {
  super.visitTryStatement(statement);
  if (onlyWarnOnAbstractMethods || !reportParameters) {
    return;
  }
  final PsiCatchSection[] catchSections =
    statement.getCatchSections();
  for (PsiCatchSection catchSection : catchSections) {
    final PsiParameter parameter = catchSection.getParameter();
    final PsiCodeBlock catchBlock = catchSection.getCatchBlock();
    if (parameter == null || catchBlock == null) {
      continue;
    }
    if (!parameter.hasModifierProperty(PsiModifier.FINAL)) {
      continue;
    }
    if (!VariableAccessUtils.variableIsUsedInInnerClass(
      parameter, catchBlock)) {
      registerModifierError(PsiModifier.FINAL, parameter,
                            parameter, PsiModifier.FINAL);
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:25,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java

示例4: visitForeachStatement

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitForeachStatement(
  PsiForeachStatement statement) {
  super.visitForeachStatement(statement);
  if (onlyWarnOnAbstractMethods || !reportParameters) {
    return;
  }
  final PsiParameter parameter = statement.getIterationParameter();
  if (!parameter.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  if (VariableAccessUtils.variableIsUsedInInnerClass(parameter,
                                                     statement)) {
    return;
  }
  registerModifierError(PsiModifier.FINAL, parameter,
                        parameter, PsiModifier.FINAL);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java

示例5: visitMethodCallExpression

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  @NonNls final String name = methodExpression.getReferenceName();
  if (!"current".equals(name)) {
    return;
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  final PsiClass aClass = method.getContainingClass();
  if (!InheritanceUtil.isInheritor(aClass, "java.util.concurrent.ThreadLocalRandom")) {
    return;
  }
  if (isArgumentToMethodCall(expression)) {
    registerMethodCallError(expression);
  }
  else {
    final PsiVariable variable = assignedToVariable(expression);
    if (variable instanceof PsiField) {
      registerMethodCallError(expression);
    }
    else if (variable instanceof PsiLocalVariable) {
      final PsiCodeBlock context = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
      if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, context) ||
          VariableAccessUtils.variableIsUsedInInnerClass(variable, context)) {
        registerMethodCallError(expression);
      }
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:SharedThreadLocalRandomInspection.java

示例6: isReplaceableStringBuffer

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private static boolean isReplaceableStringBuffer(PsiVariable variable, PsiElement context) {
  if (context == null) {
    return false;
  }
  final PsiType type = variable.getType();
  if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING_BUFFER, type)) {
    return false;
  }
  final PsiExpression initializer = variable.getInitializer();
  if (initializer == null) {
    return false;
  }
  if (getNewStringBuffer(initializer) == null) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssigned(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssignedFrom(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsReturned(variable, context, true)) {
    return false;
  }
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, excludes, context, true)) {
    return false;
  }
  if (VariableAccessUtils.variableIsUsedInInnerClass(variable, context)) {
    return false;
  }
  return true;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:33,代码来源:StringBufferReplaceableByStringBuilderInspection.java

示例7: visitForeachStatement

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitForeachStatement(PsiForeachStatement statement) {
  super.visitForeachStatement(statement);
  if (onlyWarnOnAbstractMethods || !reportParameters) {
    return;
  }
  final PsiParameter parameter = statement.getIterationParameter();
  if (!parameter.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  if (VariableAccessUtils.variableIsUsedInInnerClass(parameter, statement)) {
    return;
  }
  registerModifierError(PsiModifier.FINAL, parameter, parameter);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java

示例8: isCopyVariable

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean isCopyVariable(PsiVariable variable) {
  final PsiExpression initializer = ParenthesesUtils.stripParentheses(variable.getInitializer());
  if (!(initializer instanceof PsiReferenceExpression)) {
    return false;
  }
  final PsiReferenceExpression reference = (PsiReferenceExpression)initializer;
  final PsiElement referent = reference.resolve();
  if (referent == null) {
    return false;
  }
  if (!(referent instanceof PsiLocalVariable || referent instanceof PsiParameter)) {
    return false;
  }
  if (!(referent instanceof PsiResourceVariable) && variable instanceof PsiResourceVariable) {
    return false;
  }
  final PsiCodeBlock containingScope = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
  if (containingScope == null) {
    return false;
  }
  if (!variable.hasModifierProperty(PsiModifier.FINAL) &&
      VariableAccessUtils.variableIsAssigned(variable, containingScope, false)) {
    return false;
  }
  final PsiVariable initialization = (PsiVariable)referent;
  if (!initialization.hasModifierProperty(PsiModifier.FINAL) &&
      VariableAccessUtils.variableIsAssigned(initialization, containingScope, false)) {
    return false;
  }
  if (!initialization.hasModifierProperty(PsiModifier.FINAL) && variable.hasModifierProperty(PsiModifier.FINAL)) {
    if (VariableAccessUtils.variableIsUsedInInnerClass(variable, containingScope)) {
      return false;
    }
  }
  return !TypeConversionUtil.boxingConversionApplicable(variable.getType(), initialization.getType());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:UnnecessaryLocalVariableInspectionBase.java

示例9: checkParameter

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private void checkParameter(PsiMethod method, PsiParameter parameter) {
  if (!parameter.hasModifierProperty(PsiModifier.FINAL)) {
    return;
  }
  final PsiClass containingClass = method.getContainingClass();
  if (containingClass != null) {
    if (containingClass.isInterface() ||
        containingClass.isAnnotationType()) {
      registerModifierError(PsiModifier.FINAL, parameter,
                            parameter, PsiModifier.FINAL);
      return;
    }
  }
  if (method.hasModifierProperty(PsiModifier.ABSTRACT)) {
    registerModifierError(PsiModifier.FINAL, parameter,
                          parameter, PsiModifier.FINAL);
    return;
  }
  if (onlyWarnOnAbstractMethods) {
    return;
  }
  if (VariableAccessUtils.variableIsUsedInInnerClass(parameter,
                                                     method)) {
    return;
  }
  registerModifierError(PsiModifier.FINAL, parameter,
                        parameter, PsiModifier.FINAL);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:29,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java

示例10: isCopyVariable

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean isCopyVariable(PsiVariable variable) {
  final PsiExpression initializer = variable.getInitializer();
  if (!(initializer instanceof PsiReferenceExpression)) {
    return false;
  }
  final PsiReferenceExpression reference = (PsiReferenceExpression)initializer;
  final PsiElement referent = reference.resolve();
  if (referent == null) {
    return false;
  }
  if (!(referent instanceof PsiLocalVariable || referent instanceof PsiParameter)) {
    return false;
  }
  final PsiCodeBlock containingScope = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
  if (containingScope == null) {
    return false;
  }
  if (!variable.hasModifierProperty(PsiModifier.FINAL) &&
      VariableAccessUtils.variableIsAssigned(variable, containingScope, false)) {
    return false;
  }
  final PsiVariable initialization = (PsiVariable)referent;
  if (!initialization.hasModifierProperty(PsiModifier.FINAL) &&
      VariableAccessUtils.variableIsAssigned(initialization, containingScope, false)) {
    return false;
  }
  if (!initialization.hasModifierProperty(PsiModifier.FINAL) && variable.hasModifierProperty(PsiModifier.FINAL)) {
    if (VariableAccessUtils.variableIsUsedInInnerClass(variable, containingScope)) {
      return false;
    }
  }
  return !TypeConversionUtil.boxingConversionApplicable(variable.getType(), initialization.getType());
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:34,代码来源:UnnecessaryLocalVariableInspection.java

示例11: isReplaceableStringBuffer

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private static boolean isReplaceableStringBuffer(PsiVariable variable, PsiElement context) {
  if (context == null) {
    return false;
  }
  final PsiType type = variable.getType();
  if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING_BUFFER, type)) {
    return false;
  }
  final PsiExpression initializer = variable.getInitializer();
  if (initializer == null) {
    return false;
  }
  if (getNewStringBuffer(initializer) == null) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssigned(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssignedFrom(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsReturned(variable, context, true)) {
    return false;
  }
  if (VariableAccessUtils.variableIsUsedInInnerClass(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, context, true, new Processor<PsiCall>() {
    @Override
    public boolean process(PsiCall call) {
      final PsiMethod method = call.resolveMethod();
      if (method == null) {
        return false;
      }
      final PsiClass aClass = method.getContainingClass();
      return aClass != null && excludes.contains(aClass.getQualifiedName());
    }
  })) {
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:43,代码来源:StringBufferReplaceableByStringBuilderInspection.java

示例12: isNecessaryFinal

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean isNecessaryFinal(PsiElement method, PsiVariable parameter) {
  return !PsiUtil.isLanguageLevel8OrHigher(parameter) && VariableAccessUtils.variableIsUsedInInnerClass(parameter, method);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:4,代码来源:UnnecessaryFinalOnLocalVariableOrParameterInspection.java


注:本文中的com.siyeh.ig.psiutils.VariableAccessUtils.variableIsUsedInInnerClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。