本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}