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


Java PsiExpressionList类代码示例

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


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


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