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


Java ExpressionUtils.isConstructorInvocation方法代码示例

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


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

示例1: visitMethodCallExpression

import com.siyeh.ig.psiutils.ExpressionUtils; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression reference = expression.getMethodExpression();
  final PsiExpression qualifier = reference.getQualifierExpression();
  if (qualifier == null) {
    return;
  }
  if (!isCallExpression(qualifier)) {
    return;
  }
  if (m_ignoreFieldInitializations) {
    final PsiElement field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
    if (field != null) {
      return;
    }
  }
  if (m_ignoreThisSuperCalls) {
    final PsiExpressionList expressionList = PsiTreeUtil.getParentOfType(expression, PsiExpressionList.class);
    if (expressionList != null) {
      final PsiElement parent = expressionList.getParent();
      if (ExpressionUtils.isConstructorInvocation(parent)) {
        return;
      }
    }
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:29,代码来源:ChainedMethodCallInspectionBase.java

示例2: isConstructorCall

import com.siyeh.ig.psiutils.ExpressionUtils; //导入方法依赖的package包/类
private boolean isConstructorCall(PsiStatement statement) {
  if (!(statement instanceof PsiExpressionStatement)) {
    return false;
  }
  final PsiExpressionStatement expressionStatement =
    (PsiExpressionStatement)statement;
  final PsiExpression expression =
    expressionStatement.getExpression();
  return ExpressionUtils.isConstructorInvocation(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:ImplicitCallToSuperInspection.java

示例3: visitMethodCallExpression

import com.siyeh.ig.psiutils.ExpressionUtils; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  PsiExpression outerExpression = expression;
  while (outerExpression != null && outerExpression.getParent() instanceof PsiExpression) {
    outerExpression = (PsiExpression)outerExpression.getParent();
  }
  if (outerExpression == null) {
    return;
  }
  final PsiElement parent = outerExpression.getParent();
  if (!(parent instanceof PsiExpressionList)) {
    return;
  }
  final PsiElement grandParent = parent.getParent();
  if (!(grandParent instanceof PsiCallExpression)) {
    return;
  }
  if (ExpressionUtils.isConstructorInvocation(grandParent)) {
    //ignore nested method calls at the start of a constructor,
    //where they can't be extracted
    return;
  }
  if (m_ignoreFieldInitializations) {
    final PsiElement field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
    if (field != null) {
      return;
    }
  }
  registerMethodCallError(expression);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:32,代码来源:NestedMethodCallInspection.java

示例4: getCallCandidates

import com.siyeh.ig.psiutils.ExpressionUtils; //导入方法依赖的package包/类
private static Set<Pair<PsiMethod, PsiSubstitutor>> getCallCandidates(PsiCall expression)
{
	Set<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.newLinkedHashSet();
	JavaResolveResult[] results;
	if(expression instanceof PsiMethodCallExpression)
	{
		results = ((PsiMethodCallExpression) expression).getMethodExpression().multiResolve(false);
	}
	else
	{
		results = new JavaResolveResult[]{expression.resolveMethodGenerics()};
	}

	PsiMethod toExclude = ExpressionUtils.isConstructorInvocation(expression) ? PsiTreeUtil.getParentOfType(expression, PsiMethod.class) : null;

	for(final JavaResolveResult candidate : results)
	{
		final PsiElement element = candidate.getElement();
		if(element instanceof PsiMethod)
		{
			final PsiClass psiClass = ((PsiMethod) element).getContainingClass();
			if(psiClass != null)
			{
				for(Pair<PsiMethod, PsiSubstitutor> overload : psiClass.findMethodsAndTheirSubstitutorsByName(((PsiMethod) element).getName(), true))
				{
					if(overload.first != toExclude)
					{
						candidates.add(Pair.create(overload.first, candidate.getSubstitutor().putAll(overload.second)));
					}
				}
				break;
			}
		}
	}
	return candidates;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:37,代码来源:SameSignatureCallParametersProvider.java

示例5: visitMethodCallExpression

import com.siyeh.ig.psiutils.ExpressionUtils; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  PsiExpression outerExpression = expression;
  while (outerExpression != null && outerExpression.getParent() instanceof PsiExpression) {
    outerExpression = (PsiExpression)outerExpression.getParent();
  }
  if (outerExpression == null) {
    return;
  }
  final PsiElement parent = outerExpression.getParent();
  if (!(parent instanceof PsiExpressionList)) {
    return;
  }
  final PsiElement grandParent = parent.getParent();
  if (!(grandParent instanceof PsiCallExpression)) {
    return;
  }
  if (ExpressionUtils.isConstructorInvocation(grandParent)) {
    //ignore nested method calls at the start of a constructor,
    //where they can't be extracted
    return;
  }
  if (m_ignoreFieldInitializations) {
    final PsiElement field = PsiTreeUtil.getParentOfType(expression, PsiField.class);
    if (field != null) {
      return;
    }
  }
  final PsiMethod method = expression.resolveMethod();
  if (method == null) {
    return;
  }
  if (ignoreStaticMethods || ignoreGetterCalls) {
    if (ignoreStaticMethods && method.hasModifierProperty(PsiModifier.STATIC)) {
      return;
    }
    if (ignoreGetterCalls && PropertyUtil.isSimpleGetter(method)) {
      return;
    }
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:44,代码来源:NestedMethodCallInspectionBase.java

示例6: isInsideConstructorCall

import com.siyeh.ig.psiutils.ExpressionUtils; //导入方法依赖的package包/类
static boolean isInsideConstructorCall(@NotNull PsiElement position)
{
	return ExpressionUtils.isConstructorInvocation(PsiTreeUtil.getParentOfType(position, PsiMethodCallExpression.class)) && !JavaKeywordCompletion.AFTER_DOT.accepts(position);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:5,代码来源:CheckInitialized.java


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