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


Java PsiUtil.isOnAssignmentLeftHand方法代码示例

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


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

示例1: getTypeByExpression

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public static PsiType getTypeByExpression(PsiExpression expr) {
  PsiType type = expr.getType();
  if (type == null) {
    if (expr instanceof PsiArrayInitializerExpression) {
      PsiExpression[] initializers = ((PsiArrayInitializerExpression)expr).getInitializers();
      if (initializers.length > 0) {
        PsiType initType = getTypeByExpression(initializers[0]);
        if (initType == null) return null;
        return initType.createArrayType();
      }
    }

    if (expr instanceof PsiReferenceExpression && PsiUtil.isOnAssignmentLeftHand(expr)) {
      return getTypeByExpression(((PsiAssignmentExpression)expr.getParent()).getRExpression());
    }
    return null;
  }
  PsiClass refClass = PsiUtil.resolveClassInType(type);
  if (refClass instanceof PsiAnonymousClass) {
    type = ((PsiAnonymousClass)refClass).getBaseClassType();
  }

  return GenericsUtil.getVariableTypeByExpressionType(type);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:RefactoringChangeUtil.java

示例2: addContainerItemModification

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean addContainerItemModification(@NotNull PsiExpression expression,
                                                    @NotNull Processor<SliceUsage> processor,
                                                    @NotNull SliceUsage parent,
                                                    @NotNull PsiSubstitutor parentSubstitutor,
                                                    int indexNesting,
                                                    @NotNull String syntheticField) {
  PsiElement parentElement = expression.getParent();
  if (parentElement instanceof PsiArrayAccessExpression &&
      ((PsiArrayAccessExpression)parentElement).getArrayExpression() == expression &&
      PsiUtil.isAccessedForWriting((PsiExpression)parentElement)) {

    if (PsiUtil.isOnAssignmentLeftHand((PsiExpression)parentElement)) {
      PsiExpression rightSide = ((PsiAssignmentExpression)parentElement.getParent()).getRExpression();
      return rightSide == null || handToProcessor(rightSide, processor, parent, parentSubstitutor, indexNesting -1, syntheticField);
    }
  }
  PsiElement grand = parentElement == null ? null : parentElement.getParent();
  if (grand instanceof PsiCallExpression) {
    if (!processContainerPutArguments((PsiCallExpression)grand, processor, parent, parentSubstitutor, indexNesting, syntheticField)) return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:SliceUtil.java

示例3: isInClassInitialization

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean isInClassInitialization(
  PsiExpression expression) {
  final PsiClass expressionClass =
    ClassUtils.getContainingClass(expression);
  final PsiMember member =
    PsiTreeUtil.getParentOfType(expression,
                                PsiClassInitializer.class, PsiField.class);
  if (member == null) {
    return false;
  }
  final PsiClass memberClass = member.getContainingClass();
  if (!memberClass.equals(expressionClass)) {
    return false;
  }
  if (!member.hasModifierProperty(PsiModifier.STATIC)) {
    return false;
  }
  if (member instanceof PsiClassInitializer) {
    return !PsiUtil.isOnAssignmentLeftHand(expression);
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:NonFinalStaticVariableUsedInClassInitializationVisitor.java

示例4: visitReferenceExpression

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Override
public void visitReferenceExpression(
  @NotNull PsiReferenceExpression expression) {
  super.visitReferenceExpression(expression);
  if (m_ignoreStaticFieldAccesses) {
    return;
  }
  final PsiElement element = expression.resolve();
  if (!(element instanceof PsiField)) {
    return;
  }
  final PsiField field = (PsiField)element;
  if (field.hasModifierProperty(PsiModifier.FINAL) &&
      PsiUtil.isOnAssignmentLeftHand(expression)) {
    return;
  }
  if (!isUnqualifiedStaticAccess(expression)) {
    return;
  }
  registerError(expression, expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UnqualifiedStaticUsageInspection.java

示例5: filterIfFieldAlreadyAssigned

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static PsiMethod[] filterIfFieldAlreadyAssigned(@NotNull PsiField field, @NotNull PsiMethod[] ctors) {
  final List<PsiMethod> result = new ArrayList<PsiMethod>(Arrays.asList(ctors));
  for (PsiReference reference : ReferencesSearch.search(field, new LocalSearchScope(ctors))) {
    final PsiElement element = reference.getElement();
    if (element instanceof PsiReferenceExpression && PsiUtil.isOnAssignmentLeftHand((PsiExpression)element)) {
      result.remove(PsiTreeUtil.getParentOfType(element, PsiMethod.class));
    }
  }
  return result.toArray(new PsiMethod[result.size()]);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:InitializeFinalFieldInConstructorFix.java

示例6: filterConstructorsIfFieldAlreadyAssigned

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static ArrayList<PsiMethod> filterConstructorsIfFieldAlreadyAssigned(PsiMethod[] constructors, PsiField field) {
  final ArrayList<PsiMethod> result = new ArrayList<PsiMethod>(Arrays.asList(constructors));
  for (PsiReference reference : ReferencesSearch.search(field, new LocalSearchScope(constructors))) {
    final PsiElement element = reference.getElement();
    if (element instanceof PsiReferenceExpression && PsiUtil.isOnAssignmentLeftHand((PsiExpression)element)) {
      result.remove(PsiTreeUtil.getParentOfType(element, PsiMethod.class));
    }
  }
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:CreateConstructorParameterFromFieldFix.java

示例7: findUsages

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
@Nullable
public NonCodeUsageSearchInfo findUsages(@NotNull final PsiElement element, @NotNull final PsiElement[] allElementsToDelete, @NotNull final List<UsageInfo> usages) {
  Condition<PsiElement> insideDeletedCondition = getUsageInsideDeletedFilter(allElementsToDelete);
  if (element instanceof PsiClass) {
    findClassUsages((PsiClass) element, allElementsToDelete, usages);
    if (element instanceof PsiTypeParameter) {
      findTypeParameterExternalUsages((PsiTypeParameter)element, usages);
    }
  }
  else if (element instanceof PsiMethod) {
    insideDeletedCondition = findMethodUsages((PsiMethod) element, allElementsToDelete, usages);
  }
  else if (element instanceof PsiField) {
    insideDeletedCondition = findFieldUsages((PsiField)element, usages, allElementsToDelete);
  }
  else if (element instanceof PsiParameter) {
    LOG.assertTrue(((PsiParameter) element).getDeclarationScope() instanceof PsiMethod);
    findParameterUsages((PsiParameter)element, usages);
  }
  else if (element instanceof PsiLocalVariable) {
    for (PsiReference reference : ReferencesSearch.search(element)) {
      PsiReferenceExpression referencedElement = (PsiReferenceExpression)reference.getElement();
      final PsiStatement statement = PsiTreeUtil.getParentOfType(referencedElement, PsiStatement.class);

      boolean isSafeToDelete = PsiUtil.isAccessedForWriting(referencedElement);
      boolean hasSideEffects = false;
      if (PsiUtil.isOnAssignmentLeftHand(referencedElement)) {
        hasSideEffects =
          RemoveUnusedVariableUtil
            .checkSideEffects(((PsiAssignmentExpression)referencedElement.getParent()).getRExpression(), ((PsiLocalVariable)element),
                              new ArrayList<PsiElement>());
      }
      usages.add(new SafeDeleteReferenceJavaDeleteUsageInfo(statement, element, isSafeToDelete && !hasSideEffects));
    }
  }
  return new NonCodeUsageSearchInfo(insideDeletedCondition, element);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:JavaSafeDeleteProcessor.java


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