• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java PsiExpressionList类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



PsiExpressionList类属于com.intellij.psi包,在下文中一共展示了PsiExpressionList类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: isBuildingChildScope

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
private PsiElement isBuildingChildScope(PsiMethodCallExpression call) {
    try {
        // Dot
        PsiElement nextSibling = call.getNextSibling();
        // Parenthesis
        nextSibling = nextSibling.getNextSibling();
        // Chained method name
        nextSibling = nextSibling.getParent();
        // Chained method
        PsiElement chainedMethod = nextSibling.getParent();
        if (chainedMethod instanceof PsiMethodCallExpression) {
            PsiExpressionList list = ((PsiMethodCallExpression) chainedMethod).getArgumentList();
            // If chained method is taking an argument that returns an instance of something
            // (such as a new Module), it is probably safe to assume that the user is building a
            // child scope
            if (list.getFirstChild() != null
                    && list.getFirstChild().getNextSibling() instanceof PsiNewExpression) {
                return chainedMethod;
            }
        }
    } catch (Exception e) {
        // A for effort
    }
    return null;
}
 
开发者ID:bgogetap,项目名称:Scoper,代码行数:26,代码来源:IncorrectChildScopeBuilding.java


示例2: doUnwrap

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
protected void doUnwrap(PsiElement element, Context context) throws IncorrectOperationException {
  PsiConditionalExpression cond = (PsiConditionalExpression)element.getParent();

  PsiElement savedBlock;
  
  if (cond.getElseExpression() == element) {
    savedBlock = element;
  }
  else {
    savedBlock = cond.getThenExpression();
  }

  context.extractElement(savedBlock, cond);

  if (cond.getParent() instanceof PsiExpressionList) {
    context.delete(cond);
  }
  else {
    context.deleteExactly(cond);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:JavaConditionalUnwrapper.java


示例3: visitMethodCallExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  if (!MethodCallUtils.isEqualsCall(expression)) {
    return;
  }
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  final PsiExpression qualifier = methodExpression.getQualifierExpression();
  if (qualifier == null) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length != 1) {
    return;
  }
  final PsiExpression argument = arguments[0];
  if (!EquivalenceChecker.expressionsAreEquivalent(qualifier, argument) ||
      SideEffectChecker.mayHaveSideEffects(qualifier)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:EqualsWithItselfInspection.java


示例4: visitMethodCallExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(
  @NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final String methodName = MethodCallUtils.getMethodName(expression);
  if (!HardcodedMethodConstants.TO_STRING.equals(methodName)) {
    return;
  }
  final PsiType targetType = MethodCallUtils.getTargetType(expression);
  if (!TypeUtils.typeEquals(CommonClassNames.JAVA_UTIL_DATE,
                            targetType)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList.getExpressions().length != 0) {
    return;
  }
  if (NonNlsUtils.isNonNlsAnnotatedUse(expression)) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:DateToStringInspection.java


示例5: visitNewExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
  super.visitNewExpression(expression);
  if (!ExpressionUtils.hasType(expression, "java.text.SimpleDateFormat")) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList == null) {
    return;
  }
  final PsiExpression[] arguments = argumentList.getExpressions();
  for (PsiExpression argument : arguments) {
    if (ExpressionUtils.hasType(argument, "java.util.Locale")) {
      return;
    }
  }
  registerNewExpressionError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:SimpleDateFormatWithoutLocaleInspection.java


示例6: visitMethodCallExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  final String name = methodExpression.getReferenceName();
  if (!"setScale".equals(name) && !"divide".equals(name)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (PsiUtilCore.hasErrorElementChild(argumentList)) {
    return;
  }
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length != 1) {
    return;
  }
  if (!TypeUtils.expressionHasTypeOrSubtype(expression, "java.math.BigDecimal")) {
    return;
  }
  registerMethodCallError(expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:BigDecimalMethodWithoutRoundingCalledInspection.java


示例7: visitNewExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
  super.visitNewExpression(expression);
  final PsiType type = expression.getType();

  if (type == null) {
    return;
  }
  if (!CollectionUtils.isCollectionWithInitialCapacity(type)) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList == null) {
    return;
  }
  final PsiExpression[] parameters = argumentList.getExpressions();
  if (parameters.length != 0) {
    return;
  }
  registerError(expression);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:CollectionsMustHaveInitialCapacityInspection.java


示例8: visitNewExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression) {
  super.visitNewExpression(expression);
  if (!ExpressionUtils.hasType(expression, "java.text.SimpleDateFormat")) {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  if (argumentList == null) {
    return;
  }
  final PsiExpression[] arguments = argumentList.getExpressions();
  for (PsiExpression argument : arguments) {
    if (ExpressionUtils.hasType(argument, "java.util.Locale")) {
      return;
    }
  }
  registerError(expression);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:SimpleDateFormatWithoutLocaleInspection.java


示例9: visitMethodCallExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
/**
 * Check MethodCallExpressions for calls for default (argument less) constructor
 * Produce an error if resolved constructor method is build by lombok and contains some arguments
 */
@Override
public void visitMethodCallExpression(PsiMethodCallExpression methodCall) {
  super.visitMethodCallExpression(methodCall);

  PsiExpressionList list = methodCall.getArgumentList();
  PsiReferenceExpression referenceToMethod = methodCall.getMethodExpression();

  boolean isThisOrSuper = referenceToMethod.getReferenceNameElement() instanceof PsiKeyword;
  final int parameterCount = list.getExpressions().length;
  if (isThisOrSuper && parameterCount == 0) {

    JavaResolveResult[] results = referenceToMethod.multiResolve(true);
    JavaResolveResult resolveResult = results.length == 1 ? results[0] : JavaResolveResult.EMPTY;
    PsiElement resolved = resolveResult.getElement();

    if (resolved instanceof LombokLightMethodBuilder && ((LombokLightMethodBuilder) resolved).getParameterList().getParameters().length != 0) {
      holder.registerProblem(methodCall, "Default constructor doesn't exist", ProblemHighlightType.ERROR);
    }
  }
}
 
开发者ID:mplushnikov,项目名称:lombok-intellij-plugin,代码行数:25,代码来源:LombokInspection.java


示例10: findListIndex

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@UnsignedOrNotFound
public static int findListIndex(@Unsigned int offset,
                         @InstanceOf({PsiParameterList.class, PsiExpressionList.class})
                         @Nullable PsiElement listElement)
{
    if ( listElement == null ) {
        return -1;
    }
    int index = -1;
    for( PsiElement element : listElement.getChildren() ) {
        if ( element.getTextRange().contains(offset) ) {
            return index;
        }
        if ( PsiUtil.isJavaToken(element, JavaTokenType.LPARENTH) || PsiUtil.isJavaToken(element, JavaTokenType.COMMA) ) {
            index++;
        }
        if ( PsiUtil.isJavaToken(element, JavaTokenType.RPARENTH) ) {
            return -1;
        }
    }
    return - 1;
}
 
开发者ID:Abnaxos,项目名称:guards,代码行数:23,代码来源:Psi.java


示例11: applyFix

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
{
	final PsiMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(descriptor.getPsiElement(), PsiMethodCallExpression.class);
	if(methodCallExpression != null)
	{
		ExpressionUtils.bindCallTo(methodCallExpression, myTargetMethodName);
		if(myClearArguments)
		{
			PsiExpressionList argList = methodCallExpression.getArgumentList();
			PsiExpression[] args = argList.getExpressions();
			if(args.length > 0)
			{
				argList.deleteChildRange(args[0], args[args.length - 1]);
			}
		}
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:DfaOptionalSupport.java


示例12: applyFix

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor)
{
	PsiElement problemElement = descriptor.getPsiElement();
	if(problemElement == null)
	{
		return;
	}

	PsiMethodCallExpression call = problemElement.getParent() instanceof PsiExpressionList && problemElement.getParent().getParent() instanceof PsiMethodCallExpression ?
			(PsiMethodCallExpression) problemElement.getParent().getParent() : null;
	PsiMethod targetMethod = call == null ? null : call.resolveMethod();

	JavaPsiFacade facade = JavaPsiFacade.getInstance(project);
	problemElement.replace(facade.getElementFactory().createExpressionFromText(myReplacementText, null));

	if(targetMethod != null)
	{
		ExtractMethodUtil.addCastsToEnsureResolveTarget(targetMethod, call);
	}
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:ReplaceWithConstantValueFix.java


示例13: visitNewExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression newExpression) {
  if (passed) {
    return;
  }
  super.visitNewExpression(newExpression);
  final PsiExpressionList argumentList = newExpression.getArgumentList();
  if (argumentList == null) {
    return;
  }
  final PsiExpression[] arguments = argumentList.getExpressions();
  for (PsiExpression argument : arguments) {
    if (VariableAccessUtils.mayEvaluateToVariable(argument, variable)) {
      passed = true;
      break;
    }
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:19,代码来源:VariablePassedAsArgumentVisitor.java


示例14: visitMethodCallExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
  if (passed) {
    return;
  }
  super.visitMethodCallExpression(call);
  final PsiExpressionList argumentList = call.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  for (PsiExpression argument : arguments) {
    if (!VariableAccessUtils.mayEvaluateToVariable(argument, variable, myBuilderPattern)) {
      continue;
    }
    final PsiMethod method = call.resolveMethod();
    if (method != null) {
      final PsiClass aClass = method.getContainingClass();
      if (aClass != null) {
        final String name = aClass.getQualifiedName();
        if (excludes.contains(name)) {
          continue;
        }
      }
    }
    passed = true;
  }
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:26,代码来源:VariablePassedAsArgumentExcludedVisitor.java


示例15: visitNewExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitNewExpression(@NotNull PsiNewExpression expression)
{
	super.visitNewExpression(expression);
	if(myIgnoreFields && expression.getParent() instanceof PsiField)
	{
		return;
	}

	final PsiType type = expression.getType();
	if(!isCollectionWithInitialCapacity(type))
	{
		return;
	}
	final PsiExpressionList argumentList = expression.getArgumentList();
	if(argumentList == null || argumentList.getExpressions().length != 0)
	{
		return;
	}
	registerNewExpressionError(expression);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:22,代码来源:CollectionsMustHaveInitialCapacityInspection.java


示例16: createPsiVisitor

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public JavaElementVisitor createPsiVisitor(@NonNull final JavaContext context) {
    return new JavaElementVisitor() {
        @Override
        public void visitLambdaExpression(PsiLambdaExpression expression) {

            if (!(expression.getParent() instanceof PsiExpressionList)) {
                return;
            }

            PsiExpressionList exprList = (PsiExpressionList) expression.getParent();
            if (!(exprList.getParent() instanceof PsiMethodCallExpression)) {
                return;
            }
            PsiMethodCallExpression call = (PsiMethodCallExpression) exprList.getParent();

            if (call.getType() == null) {
                return;
            }

            String callType = call.getType().getCanonicalText();

            if (!callType.startsWith("de.mobilej.thinr.Thinr")) {
                return;
            }

            markLeakSuspects(expression, expression, context);
        }
    };
}
 
开发者ID:bjoernQ,项目名称:thinr,代码行数:31,代码来源:ThinrDetector.java


示例17: getQuickNavigateInfo

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Nullable
@Override
public String getQuickNavigateInfo(PsiElement element, PsiElement originalElement) {
    if (ServiceManager.getService(element.getProject(), CamelService.class).isCamelPresent()) {
        PsiExpressionList exps = PsiTreeUtil.getNextSiblingOfType(originalElement, PsiExpressionList.class);
        if (exps != null) {
            if (exps.getExpressions().length >= 1) {
                // grab first string parameter (as the string would contain the camel endpoint uri
                final PsiClassType stringType = PsiType.getJavaLangString(element.getManager(), element.getResolveScope());
                PsiExpression exp = Arrays.stream(exps.getExpressions()).filter(
                    e -> e.getType() != null && stringType.isAssignableFrom(e.getType()))
                    .findFirst().orElse(null);
                if (exp instanceof PsiLiteralExpression) {
                    Object o = ((PsiLiteralExpression) exp).getValue();
                    String val = o != null ? o.toString() : null;
                    // okay only allow this popup to work when its from a RouteBuilder class
                    PsiClass clazz = PsiTreeUtil.getParentOfType(originalElement, PsiClass.class);
                    if (clazz != null) {
                        PsiClassType[] types = clazz.getExtendsListTypes();
                        boolean found = Arrays.stream(types).anyMatch(p -> p.getClassName().equals("RouteBuilder"));
                        if (found) {
                            String componentName = StringUtils.asComponentName(val);
                            if (componentName != null) {
                                // the quick info cannot be so wide so wrap at 120 chars
                                return generateCamelComponentDocumentation(componentName, val, 120, element.getProject());
                            }
                        }
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:36,代码来源:CamelDocumentationProvider.java


示例18: getFlags

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public int getFlags(PsiElement elementInHost, PsiFile regexp) {
  final PsiExpressionList list = PsiTreeUtil.getParentOfType(elementInHost, PsiExpressionList.class);
  if (list != null && list.getExpressions().length == 2 && list.getExpressionTypes()[1] == PsiType.INT) {
    final Object result = JavaConstantExpressionEvaluator.computeConstantExpression(list.getExpressions()[1], false);
    if (result instanceof Integer) {
      //noinspection MagicConstant
      return ((Integer)result).intValue();
    }
  }
  return 0;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:JavaRegExpModifierProvider.java


示例19: isOK

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
public boolean isOK(PsiExpression occurrence) {
  PsiElement parent = occurrence.getParent();
  while(parent instanceof PsiExpression) {
    parent = parent.getParent();
  }
  if(!(parent instanceof PsiExpressionList)) return true;
  parent = parent.getParent();
  if(!(parent instanceof PsiMethodCallExpression)) return true;
  final String text = ((PsiMethodCallExpression) parent).getMethodExpression().getText();
  return !getKeywordText().equals(text);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:12,代码来源:NotInSuperOrThisCallFilterBase.java


示例20: visitMethodCallExpression

import com.intellij.psi.PsiExpressionList; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(@NotNull PsiMethodCallExpression expression) {
  super.visitMethodCallExpression(expression);
  final PsiReferenceExpression methodExpression = expression.getMethodExpression();
  @NonNls final String methodName = methodExpression.getReferenceName();
  if (methodName == null) {
    return;
  }
  final boolean resultSet;
  if (methodName.startsWith("get") || methodName.startsWith("update")) {
    resultSet = true;
  } else if (methodName.startsWith("set")) {
    resultSet = false;
  } else {
    return;
  }
  final PsiExpressionList argumentList = expression.getArgumentList();
  final PsiExpression[] arguments = argumentList.getExpressions();
  if (arguments.length == 0) {
    return;
  }
  final PsiExpression argument = arguments[0];
  final Object val = ExpressionUtils.computeConstantExpression(argument);
  if (!(val instanceof Integer) || ((Integer)val).intValue() != 0) {
    return;
  }
  final PsiExpression qualifier = methodExpression.getQualifierExpression();
  if (resultSet) {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.ResultSet")) {
      registerError(argument, Boolean.TRUE);
    }
  } else if (arguments.length > 1) {
    if (TypeUtils.expressionHasTypeOrSubtype(qualifier, "java.sql.PreparedStatement")) {
      registerError(argument, Boolean.FALSE);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:ResultSetIndexZeroInspection.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GenericVisitorAdapter类代码示例发布时间:2022-05-22
下一篇:
Java FileTypeBox类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap