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


Java PropertyUtil.getFieldOfSetter方法代码示例

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


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

示例1: visitMethodCallExpression

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  if (!countGettersAndSetters) {
    return;
  }
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final PsiExpression qualifier =
    methodExpression.getQualifierExpression();
  if (qualifier != null && !(qualifier instanceof PsiThisExpression)) {
    return;
  }
  final PsiMethod method = (PsiMethod)methodExpression.resolve();
  PsiField field = PropertyUtil.getFieldOfGetter(method);
  if (field == null) {
    field = PropertyUtil.getFieldOfSetter(method);
  }
  if (field == null) {
    return;
  }
  if (m_inInitializer) {
  }
  else if (m_inSynchronizedContextCount > 0) {
    m_synchronizedAccesses.add(field);
  }
  else {
    m_unsynchronizedAccesses.add(field);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:VariableAccessVisitor.java

示例2: visitMethodCallExpression

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  if (!countGettersAndSetters) {
    return;
  }
  final PsiReferenceExpression methodExpression =
    expression.getMethodExpression();
  final PsiExpression qualifier =
    methodExpression.getQualifierExpression();
  if (qualifier != null && !(qualifier instanceof PsiThisExpression)) {
    return;
  }
  final PsiMethod method = (PsiMethod)methodExpression.resolve();
  PsiField field = PropertyUtil.getFieldOfGetter(method);
  if (field == null) {
    field = PropertyUtil.getFieldOfSetter(method);
  }
  if (field == null) {
    return;
  }
  if (m_inInitializer) {
  }
  else if (m_inSynchronizedContext) {
    m_synchronizedAccesses.add(field);
  }
  else {
    m_unsynchronizedAccesses.add(field);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:31,代码来源:VariableAccessVisitor.java

示例3: visitMethodCallExpression

import com.intellij.psi.util.PropertyUtil; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiExpressionList argumentList1 = expression.getArgumentList();
  final PsiExpression[] arguments1 = argumentList1.getExpressions();
  if (arguments1.length != 1) {
    return;
  }
  final PsiExpression argument = arguments1[0];
  if (!(argument instanceof PsiMethodCallExpression)) {
    return;
  }
  final PsiMethodCallExpression methodCallExpression = (PsiMethodCallExpression)argument;
  final PsiExpressionList argumentList2 = methodCallExpression.getArgumentList();
  final PsiExpression[] arguments2 = argumentList2.getExpressions();
  if (arguments2.length != 0) {
    return;
  }
  final PsiReferenceExpression methodExpression1 = expression.getMethodExpression();
  final PsiExpression qualifierExpression1 = ParenthesesUtils.stripParentheses(methodExpression1.getQualifierExpression());
  final PsiReferenceExpression methodExpression2 = methodCallExpression.getMethodExpression();
  final PsiExpression qualifierExpression2 = ParenthesesUtils.stripParentheses(methodExpression2.getQualifierExpression());
  if (qualifierExpression1 instanceof PsiReferenceExpression && qualifierExpression2 instanceof PsiReferenceExpression) {
    if (!EquivalenceChecker.expressionsAreEquivalent(qualifierExpression1, qualifierExpression2)) {
      return;
    }
  }
  else if((qualifierExpression1 != null &&
          !(qualifierExpression1 instanceof PsiThisExpression) &&
          !(qualifierExpression1 instanceof PsiSuperExpression))
          ||
          qualifierExpression2 != null &&
          !(qualifierExpression2 instanceof PsiThisExpression) &&
          !(qualifierExpression2 instanceof PsiSuperExpression)) {
    return;
  }
  final PsiMethod method1 = expression.resolveMethod();
  final PsiField fieldOfSetter = PropertyUtil.getFieldOfSetter(method1);
  if (fieldOfSetter == null) {
    return;
  }
  final PsiMethod method2 = methodCallExpression.resolveMethod();
  final PsiField fieldOfGetter = PropertyUtil.getFieldOfGetter(method2);
  if (!fieldOfSetter.equals(fieldOfGetter)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:49,代码来源:PropertyValueSetToItselfInspection.java


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