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


Java VariableAccessUtils.variableIsPassedAsMethodArgument方法代码示例

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


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

示例1: collectionContentsAreUpdated

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean collectionContentsAreUpdated(PsiVariable variable, PsiElement context) {
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, context, new UpdateCallProcessor()) ||
      collectionUpdateCalled(variable, context)) {
    return true;
  }
  final PsiExpression initializer = variable.getInitializer();
  if (initializer != null && !isEmptyCollectionInitializer(initializer)) {
    return true;
  }
  if (initializer instanceof PsiNewExpression) {
    final PsiNewExpression newExpression = (PsiNewExpression)initializer;
    final PsiAnonymousClass anonymousClass = newExpression.getAnonymousClass();
    if (anonymousClass != null) {
      if (collectionUpdateCalled(null, anonymousClass)) {
        return true;
      }
      final ThisPassedAsArgumentVisitor visitor = new ThisPassedAsArgumentVisitor();
      anonymousClass.accept(visitor);
      if (visitor.isPassed()) {
        return true;
      }
    }
  }
  return VariableAccessUtils.variableIsAssigned(variable, context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:MismatchedCollectionQueryUpdateInspectionBase.java

示例2: checkVariable

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private static boolean checkVariable(PsiVariable variable, PsiElement context) {
  if (context == null) {
    return false;
  }
  if (!TypeUtils.variableHasTypeOrSubtype(variable, CommonClassNames.JAVA_LANG_ABSTRACT_STRING_BUILDER)) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssigned(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssignedFrom(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsReturned(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, context)) {
    return false;
  }
  return !VariableAccessUtils.variableIsUsedInArrayInitializer(variable, context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:MismatchedStringBuilderQueryUpdateInspection.java

示例3: checkVariable

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean checkVariable(PsiVariable variable, PsiElement context) {
  if (context == null) {
    return false;
  }
  final PsiType type = variable.getType();
  if (!CollectionUtils.isCollectionClassOrInterface(type)) {
    return false;
  }
  if (VariableAccessUtils.variableIsAssignedFrom(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsReturned(variable, context)) {
    return false;
  }
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, context)) {
    return false;
  }
  return !VariableAccessUtils.variableIsUsedInArrayInitializer(variable, context);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:MismatchedCollectionQueryUpdateInspectionBase.java

示例4: collectionContentsAreQueried

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean collectionContentsAreQueried(PsiVariable variable, PsiElement context) {
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, context, new QueryCallProcessor()) ||
      collectionQueryCalled(variable, context)) {
    return true;
  }
  final PsiExpression initializer = variable.getInitializer();
  if (initializer != null && !isEmptyCollectionInitializer(initializer)) {
    return true;
  }
  return collectionQueriedByAssignment(variable, context);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:MismatchedCollectionQueryUpdateInspectionBase.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: visitLocalVariable

import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitLocalVariable(@NotNull PsiLocalVariable variable) {
  super.visitLocalVariable(variable);
  final PsiCodeBlock codeBlock = PsiTreeUtil.getParentOfType(variable, PsiCodeBlock.class);
  if (codeBlock == null) {
    return;
  }
  final PsiType type = variable.getType();
  if (!TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING_BUFFER, type) &&
      !TypeUtils.typeEquals(CommonClassNames.JAVA_LANG_STRING_BUILDER, type)) {
    return;
  }
  final PsiExpression initializer = variable.getInitializer();
  if (initializer == null) {
    return;
  }
  if (!isNewStringBufferOrStringBuilder(initializer)) {
    return;
  }
  if (VariableAccessUtils.variableIsAssigned(variable, codeBlock)) {
    return;
  }
  if (VariableAccessUtils.variableIsAssignedFrom(variable, codeBlock)) {
    return;
  }
  if (VariableAccessUtils.variableIsReturned(variable, codeBlock)) {
    return;
  }
  if (VariableAccessUtils.variableIsPassedAsMethodArgument(variable, codeBlock)) {
    return;
  }
  if (variableIsModified(variable, codeBlock)) {
    return;
  }
  registerVariableError(variable, variable, type);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:37,代码来源:StringBufferReplaceableByStringInspection.java

示例8: 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


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