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


Java GrArgumentList类代码示例

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


GrArgumentList类属于org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments包,在下文中一共展示了GrArgumentList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getContributingMethod

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Nullable
private static PsiMethod getContributingMethod(PsiElement place,
                                               PsiClass contributorClass,
                                               String methodName) {
  GrMethodCall call = PsiTreeUtil.getParentOfType(place, GrMethodCall.class);
  if (call == null) {
    return null;
  }

  GrArgumentList args = call.getArgumentList();
  int argsCount = GradleResolverUtil.getGrMethodArumentsCount(args);

  PsiMethod[] methodsByName = findMethodByName(contributorClass, methodName);

  // first check to see if we can narrow down by # of arguments
  for (PsiMethod method : methodsByName) {
    if (method.getParameterList().getParametersCount() == argsCount) {
      return method;
    }
  }

  // if we couldn't narrow down by # of arguments, just use the first one
  return methodsByName.length > 0 ? methodsByName[0] : null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:AndroidDslContributor.java

示例2: getGrMethodArumentsCount

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
public static int getGrMethodArumentsCount(@NotNull GrArgumentList args) {
  int argsCount = 0;
  boolean namedArgProcessed = false;
  for (GroovyPsiElement arg : args.getAllArguments()) {
    if (arg instanceof GrNamedArgument) {
      if (!namedArgProcessed) {
        namedArgProcessed = true;
        argsCount++;
      }
    }
    else {
      argsCount++;
    }
  }
  return argsCount;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:GradleResolverUtil.java

示例3: doFix

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Override
public void doFix(Project project, ProblemDescriptor descriptor) throws IncorrectOperationException {
  final GrConditionalExpression expression = (GrConditionalExpression) descriptor.getPsiElement();
  final GrBinaryExpression binaryCondition = (GrBinaryExpression)PsiUtil.skipParentheses(expression.getCondition(), false);
  final GrMethodCallExpression call;
  if (GrInspectionUtil.isInequality(binaryCondition)) {
    call = (GrMethodCallExpression) expression.getThenBranch();
  } else {
    call = (GrMethodCallExpression) expression.getElseBranch();
  }
  final GrReferenceExpression methodExpression = (GrReferenceExpression) call.getInvokedExpression();
  final GrExpression qualifier = methodExpression.getQualifierExpression();
  final String methodName = methodExpression.getReferenceName();
  final GrArgumentList argumentList = call.getArgumentList();
  if (argumentList == null) {
    return;
  }
  replaceExpression(expression, qualifier.getText() + "?." + methodName + argumentList.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyConditionalCanBeConditionalCallInspection.java

示例4: argumentListsAreEquivalent

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
private static boolean argumentListsAreEquivalent(@Nullable GrArgumentList list1, @Nullable GrArgumentList list2) {
  if (list1 == null && list2 == null) {
    return true;
  }
  if (list1 == null || list2 == null) {
    return false;
  }
  final GrExpression[] args1 = list1.getExpressionArguments();
  final GrExpression[] args2 = list2.getExpressionArguments();
  if (!expressionListsAreEquivalent(args1, args2)) {
    return false;
  }
  final GrNamedArgument[] namedArgs1 = list1.getNamedArguments();
  final GrNamedArgument[] namedArgs2 = list2.getNamedArguments();
  if (!namedArgumentListsAreEquivalent(namedArgs1, namedArgs2)) {
    return false;
  }
  return true;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EquivalenceChecker.java

示例5: processIntention

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
        throws IncorrectOperationException {
    final GrMethodCallExpression expression =
            (GrMethodCallExpression) element;
    final GrReferenceExpression invokedExpression = (GrReferenceExpression) expression.getInvokedExpression();
    final GrExpression qualifier = invokedExpression.getQualifierExpression();
    final GrArgumentList argList = expression.getArgumentList();
    final GrClosableBlock[] closureArgs = expression.getClosureArguments();
    final StringBuilder newExpression = new StringBuilder();
    newExpression.append(qualifier.getText());
    if (argList != null) {
        newExpression.append(argList.getText());
    }
    for (GrClosableBlock closureArg : closureArgs) {
        newExpression.append(closureArg.getText());
    }
    PsiImplUtil.replaceExpression(newExpression.toString(), expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MakeClosureCallImplicitIntention.java

示例6: withArguments

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
public GroovyMethodCallPattern withArguments(final ElementPattern<? extends GrExpression>... arguments) {
  return with(new PatternCondition<GrCallExpression>("withArguments") {
    @Override
    public boolean accepts(@NotNull GrCallExpression callExpression, ProcessingContext context) {
      final GrArgumentList argumentList = callExpression.getArgumentList();
      if (argumentList == null) return false;
      final GrExpression[] actualArguments = argumentList.getExpressionArguments();
      if (arguments.length != actualArguments.length) {
        return false;
      }
      for (int i = 0; i < actualArguments.length; i++) {
        if (!arguments[i].accepts(actualArguments[i], context)) {
          return false;
        }
      }
      return true;
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyMethodCallPattern.java

示例7: hasFieldInitialization

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
private static boolean hasFieldInitialization(GrNewExpression newExpression) {
  final GrArgumentList argumentList = newExpression.getArgumentList();
  if (argumentList == null) return false;
  if (argumentList.getNamedArguments().length == 0) return false;

  final GrCodeReferenceElement refElement = newExpression.getReferenceElement();
  if (refElement == null) return false;
  final GroovyResolveResult resolveResult = newExpression.advancedResolve();
  final PsiElement constructor = resolveResult.getElement();
  if (constructor instanceof PsiMethod) {
    return ((PsiMethod)constructor).getParameterList().getParametersCount() == 0;
  }

  final PsiElement resolved = refElement.resolve();
  return resolved instanceof PsiClass;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ExpressionGenerator.java

示例8: analyzeForNamedArguments

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
/**
 * @param owner       Method or closure
 * @param occurrences references to owner
 * @return true if there we use owner's first parameter as map, false if we need to add ne one as fist map
 */
private static FIRST_PARAMETER_KIND analyzeForNamedArguments(final GrParametersOwner owner, final Collection<PsiElement> occurrences) {
  boolean thereAreNamedArguments = false;
  for (PsiElement occurrence : occurrences) {
    if (occurrence instanceof GrReferenceExpression && occurrence.getParent() instanceof GrCall) {
      final GrCall call = (GrCall)occurrence.getParent();
      final GrArgumentList args = call.getArgumentList();
      if (args != null && args.getNamedArguments().length > 0) {
        thereAreNamedArguments = true;
      }
    }
    if (thereAreNamedArguments) break;
  }
  if (thereAreNamedArguments) {
    if (firstOwnerParameterMustBeMap(owner)) {
      return FIRST_PARAMETER_KIND.MUST_BE_MAP;
    }
    return FIRST_PARAMETER_KIND.ERROR;
  }
  return FIRST_PARAMETER_KIND.IS_NOT_MAP;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ConvertParameterToMapEntryIntention.java

示例9: visitMethodCallExpression

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Override
public void visitMethodCallExpression(GrMethodCallExpression methodCall) {
  final GrExpression invokedExpression = methodCall.getInvokedExpression();
  if (myExpression.equals(invokedExpression)) {
    myResult = new TypeConstraint[]{SubtypeConstraint.create(GroovyCommonClassNames.GROOVY_LANG_CLOSURE, methodCall)};
    return;
  }

  final GrClosableBlock[] closureArgs = methodCall.getClosureArguments();
  if (ArrayUtil.contains(myExpression, closureArgs)) {
    final GrArgumentList argumentList = methodCall.getArgumentList();
    final GrNamedArgument[] namedArgs = argumentList.getNamedArguments();
    final GrExpression[] expressionArgs = argumentList.getExpressionArguments();
    final GroovyResolveResult[] callVariants = ResolveUtil.getCallVariants(myExpression);
    processCallVariants(methodCall, callVariants, namedArgs, expressionArgs, closureArgs);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GroovyExpectedTypesProvider.java

示例10: findCall

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Nullable
private static GrCall findCall(@NotNull GrClosableBlock closure) {
  PsiElement parent = closure.getParent();
  if (parent instanceof GrCall && ArrayUtil.contains(closure, ((GrCall)parent).getClosureArguments())) {
    return (GrCall)parent;
  }

  if (parent instanceof GrArgumentList) {
    PsiElement pparent = parent.getParent();
    if (pparent instanceof GrCall) {
      return (GrCall)pparent;
    }
  }

  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ClosureParamsEnhancer.java

示例11: isExpressionUsed

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
public static boolean isExpressionUsed(PsiElement expr) {
  while (expr.getParent() instanceof GrParenthesizedExpression) expr = expr.getParent();

  final PsiElement parent = expr.getParent();
  if (parent instanceof GrBinaryExpression ||
      parent instanceof GrUnaryExpression ||
      parent instanceof GrConditionalExpression ||
      parent instanceof GrAssignmentExpression ||
      parent instanceof GrInstanceOfExpression ||
      parent instanceof GrSafeCastExpression ||
      parent instanceof GrTupleExpression ||
      parent instanceof GrArgumentList ||
      parent instanceof GrReturnStatement ||
      parent instanceof GrAssertStatement ||
      parent instanceof GrThrowStatement ||
      parent instanceof GrSwitchStatement ||
      parent instanceof GrVariable) {
    return true;
  }
  return isReturnStatement(expr);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:PsiUtil.java

示例12: getOrCreateInitializingClass

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@NotNull
@Override
public PsiEnumConstantInitializer getOrCreateInitializingClass() {
  final GrEnumConstantInitializer initializingClass = getInitializingClass();
  if (initializingClass != null) return initializingClass;

  final GrEnumConstantInitializer initializer =
    GroovyPsiElementFactory.getInstance(getProject()).createEnumConstantFromText("foo{}").getInitializingClass();
  LOG.assertTrue(initializer != null);
  final GrArgumentList argumentList = getArgumentList();
  if (argumentList != null) {
    return (PsiEnumConstantInitializer)addAfter(initializer, argumentList);
  }
  else {
    return (PsiEnumConstantInitializer)addAfter(initializer, getNameIdentifierGroovy());
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:GrEnumConstantImpl.java

示例13: calcNamedArgumentsForCall

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Nullable
private static Map<String, NamedArgumentDescriptor> calcNamedArgumentsForCall(@NotNull PsiElement mapOrArgumentList) {
  PsiElement argumentList = mapOrArgumentList instanceof GrArgumentList ? mapOrArgumentList : mapOrArgumentList.getParent();
  if (argumentList instanceof GrArgumentList) {
    if (mapOrArgumentList instanceof GrListOrMap) {
      if (((GrArgumentList)argumentList).getNamedArguments().length > 0 ||
          ((GrArgumentList)argumentList).getExpressionArgumentIndex((GrListOrMap)mapOrArgumentList) > 0) {
        return Collections.emptyMap();
      }
    }

    if (argumentList.getParent() instanceof GrCall) {
      return GroovyNamedArgumentProvider.getNamedArgumentsFromAllProviders((GrCall)argumentList.getParent(), null, true);
    }
  }
  return Collections.emptyMap();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:MapArgumentCompletionProvider.java

示例14: processIntention

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Override
public void processIntention(@NotNull PsiElement element, Project project, Editor editor)
        throws IncorrectOperationException {
    final GrMethodCallExpression expression =
            (GrMethodCallExpression) element;
    final GrExpression invokedExpression = expression.getInvokedExpression();
    final GrArgumentList argList = expression.getArgumentList();
    final GrClosableBlock[] closureArgs = expression.getClosureArguments();
    final StringBuilder newExpression = new StringBuilder();
    newExpression.append(invokedExpression.getText());
    newExpression.append(".call");
    if (argList != null) {
        newExpression.append(argList.getText());
    }
    for (GrClosableBlock closureArg : closureArgs) {
        newExpression.append(closureArg.getText());
    }
    PsiImplUtil.replaceExpression(newExpression.toString(), expression);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:MakeClosureCallExplicitIntention.java

示例15: writeEnumConstant

import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入依赖的package包/类
@Override
public void writeEnumConstant(StringBuilder builder, GrEnumConstant constant) {
  GenerationUtil.writeDocComment(builder, constant, false);
  builder.append(constant.getName());

  final GrArgumentList argumentList = constant.getArgumentList();
  if (argumentList != null) {
    final GroovyResolveResult resolveResult = constant.advancedResolve();
    GrClosureSignature signature = GrClosureSignatureUtil.createSignature(resolveResult);
    new ArgumentListGenerator(builder, context.extend()).generate(
      signature,
      argumentList.getExpressionArguments(),
      argumentList.getNamedArguments(),
      GrClosableBlock.EMPTY_ARRAY,
      constant
    );
  }

  final GrEnumConstantInitializer anonymousBlock = constant.getInitializingClass();
  if (anonymousBlock != null) {
    builder.append("{\n");
    new ClassGenerator(classNameProvider, this).writeMembers(builder, anonymousBlock);
    builder.append("\n}");
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:ClassItemGeneratorImpl.java


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