本文整理汇总了Java中com.siyeh.ig.psiutils.VariableAccessUtils.variableIsAssigned方法的典型用法代码示例。如果您正苦于以下问题:Java VariableAccessUtils.variableIsAssigned方法的具体用法?Java VariableAccessUtils.variableIsAssigned怎么用?Java VariableAccessUtils.variableIsAssigned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.siyeh.ig.psiutils.VariableAccessUtils
的用法示例。
在下文中一共展示了VariableAccessUtils.variableIsAssigned方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findInitialization
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private static int findInitialization(PsiElement[] elements, PsiVariable variable, boolean hasInitializer) {
int result = -1;
final int statementsLength = elements.length;
for (int i = 0; i < statementsLength; i++) {
final PsiElement element = elements[i];
if (isNormalAssignment(element, variable)) {
if (result >= 0 && !hasInitializer) {
return -1;
}
if (hasInitializer) {
return i;
}
result = i;
}
else if (VariableAccessUtils.variableIsAssigned(variable, element)) {
return hasInitializer ? i : -1;
}
}
return result;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:TryFinallyCanBeTryWithResourcesInspection.java
示例2: checkVariable
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private static boolean checkVariable(PsiVariable variable,
PsiElement context) {
if (context == null) {
return false;
}
final PsiType type = variable.getType();
if (type.getArrayDimensions() == 0) {
return false;
}
if (VariableAccessUtils.variableIsAssigned(variable, context)) {
return false;
}
if (VariableAccessUtils.variableIsAssignedFrom(variable, context)) {
return false;
}
if (VariableAccessUtils.variableIsReturned(variable, context)) {
return false;
}
return !VariableAccessUtils.variableIsUsedInArrayInitializer(variable, context);
}
示例3: 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
示例4: 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
示例5: visitWhileStatement
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitWhileStatement(@NotNull PsiWhileStatement statement) {
super.visitWhileStatement(statement);
final PsiStatement body = statement.getBody();
if (ignoreNonEmtpyLoops && !statementIsEmpty(body)) {
return;
}
final PsiExpression condition = statement.getCondition();
final PsiField field = getFieldIfSimpleFieldComparison(condition);
if (field == null) {
return;
}
if (body != null && (VariableAccessUtils.variableIsAssigned(field, body) ||
containsWaitCall(body))) {
return;
}
registerStatementError(statement);
}
示例6: checkVariable
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private static boolean checkVariable(PsiVariable variable,
PsiElement context) {
if (context == null) {
return false;
}
final PsiType type = variable.getType();
if (type.getArrayDimensions() == 0) {
return false;
}
if (VariableAccessUtils.variableIsAssigned(variable, context)) {
return false;
}
if (VariableAccessUtils.variableIsAssignedFrom(variable, context)) {
return false;
}
if (VariableAccessUtils.variableIsReturned(variable, context)) {
return false;
}
return !VariableAccessUtils.variableIsUsedInArrayInitializer(
variable, context);
}
示例7: collectionContentsAreUpdated
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean collectionContentsAreUpdated(PsiVariable variable, PsiElement context) {
if (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:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:MismatchedCollectionQueryUpdateInspectionBase.java
示例8: checkVariableUsage
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private void checkVariableUsage(PsiReferenceExpression referenceExpression, PsiElement thenContext, PsiElement elseContext) {
if (thenContext == null) {
return;
}
final PsiElement target = referenceExpression.resolve();
if (!(target instanceof PsiVariable)) {
return;
}
final PsiVariable variable = (PsiVariable)target;
if (contextExits(thenContext) || VariableAccessUtils.variableIsAssigned(variable, thenContext)) {
return;
}
if (elseContext != null && (contextExits(elseContext) || VariableAccessUtils.variableIsUsed(variable, elseContext))) {
return;
}
registerError(referenceExpression);
}
示例9: visitWhileStatement
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
@Override
public void visitWhileStatement(@NotNull PsiWhileStatement statement) {
super.visitWhileStatement(statement);
final PsiStatement body = statement.getBody();
if (ignoreNonEmtpyLoops && !statementIsEmpty(body)) {
return;
}
final PsiExpression condition = statement.getCondition();
final PsiField field = getFieldIfSimpleFieldComparison(condition);
if (field == null) {
return;
}
if (body != null && VariableAccessUtils.variableIsAssigned(field, body)) {
return;
}
registerStatementError(statement);
}
示例10: checkVariableUsage
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private void checkVariableUsage(PsiReferenceExpression referenceExpression,
PsiElement thenContext, PsiElement elseContext) {
if (thenContext == null) {
return;
}
final PsiElement target = referenceExpression.resolve();
if (!(target instanceof PsiVariable)) {
return;
}
final PsiVariable variable = (PsiVariable)target;
if (contextExits(thenContext) || VariableAccessUtils.variableIsAssigned(variable, thenContext)) {
return;
}
if (elseContext != null &&
(contextExits(elseContext) || VariableAccessUtils.variableIsUsed(variable, elseContext))) {
return;
}
registerError(referenceExpression);
}
示例11: checkVariableUsage
import com.siyeh.ig.psiutils.VariableAccessUtils; //导入方法依赖的package包/类
private boolean checkVariableUsage(PsiReferenceExpression referenceExpression, PsiElement thenContext, PsiElement elseContext) {
final PsiElement target = referenceExpression.resolve();
if (!(target instanceof PsiVariable)) {
return false;
}
final PsiVariable variable = (PsiVariable)target;
if (thenContext != null && (contextExits(thenContext) || VariableAccessUtils.variableIsAssigned(variable, thenContext))) {
return false;
}
if (elseContext == null || VariableAccessUtils.variableIsUsed(variable, elseContext)) {
return false;
}
return true;
}
示例12: 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
示例13: 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
示例14: 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);
}
示例15: 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());
}