本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList.getNamedArguments方法的典型用法代码示例。如果您正苦于以下问题:Java GrArgumentList.getNamedArguments方法的具体用法?Java GrArgumentList.getNamedArguments怎么用?Java GrArgumentList.getNamedArguments使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList
的用法示例。
在下文中一共展示了GrArgumentList.getNamedArguments方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
示例2: 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);
}
}
示例3: getCurrentParameterIndex
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private static int getCurrentParameterIndex(GroovyPsiElement place, int offset) {
if (place instanceof GrArgumentList) {
GrArgumentList list = (GrArgumentList)place;
int idx = (list.getNamedArguments().length > 0) ? 1 : 0;
for (PsiElement child = list.getFirstChild(); child != null; child = child.getNextSibling()) {
if (child.getTextRange().contains(offset)) {
if (child instanceof GrNamedArgument) return 0;
return idx;
}
if (child.getNode().getElementType() == GroovyTokenTypes.mCOMMA) idx++;
if (isNamedArgWithPriorComma(child)) idx--;
}
}
return -1;
}
示例4: 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;
}
示例5: 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;
}
示例6: applicationStatementsAreEquivalent
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private static boolean applicationStatementsAreEquivalent(GrApplicationStatement statement1,
GrApplicationStatement statement2) {
final GrExpression funExpression1 = statement1.getInvokedExpression();
final GrExpression funExpression2 = statement2.getInvokedExpression();
if (!expressionsAreEquivalent(funExpression1, funExpression2)) {
return false;
}
final GrArgumentList argumentList1 = statement1.getArgumentList();
if (argumentList1 == null) {
return false;
}
final GrArgumentList argumentList2 = statement2.getArgumentList();
if (argumentList2 == null) {
return false;
}
final GrExpression[] args1 = argumentList1.getExpressionArguments();
final GrExpression[] args2 = argumentList2.getExpressionArguments();
if (!expressionListsAreEquivalent(args1, args2)) {
return false;
}
final GrNamedArgument[] namedArgs1 = argumentList1.getNamedArguments();
final GrNamedArgument[] namedArgs2 = argumentList2.getNamedArguments();
if (!namedArgumentListsAreEquivalent(namedArgs1, namedArgs2)) {
return false;
}
return true;
}
示例7: getAllArguments
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
/**
* Returns all arguments passed to method. First argument is null if Named Arguments is present.
*/
public static GrExpression[] getAllArguments(@NotNull GrCall call) {
GrArgumentList argumentList = call.getArgumentList();
if (argumentList == null) return GrExpression.EMPTY_ARRAY;
GrClosableBlock[] closureArguments = call.getClosureArguments();
GrExpression[] expressionArguments = argumentList.getExpressionArguments();
GrNamedArgument[] namedArguments = argumentList.getNamedArguments();
int length = expressionArguments.length + closureArguments.length;
int k = 0;
if (namedArguments.length > 0) {
length++;
k = 1;
}
GrExpression[] res = new GrExpression[length];
for (GrExpression expressionArgument : expressionArguments) {
res[k++] = expressionArgument;
}
for (GrClosableBlock closureArgument : closureArguments) {
res[k++] = closureArgument;
}
return res;
}
示例8: getCallByNamedParameter
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Nullable
public static GrCall getCallByNamedParameter(GrNamedArgument namedArgument) {
PsiElement parent = namedArgument.getParent();
PsiElement eMethodCall;
if (parent instanceof GrArgumentList) {
eMethodCall = parent.getParent();
}
else {
if (!(parent instanceof GrListOrMap)) return null;
PsiElement eArgumentList = parent.getParent();
if (!(eArgumentList instanceof GrArgumentList)) return null;
GrArgumentList argumentList = (GrArgumentList)eArgumentList;
if (argumentList.getNamedArguments().length > 0) return null;
if (argumentList.getExpressionArgumentIndex((GrListOrMap)parent) != 0) return null;
eMethodCall = eArgumentList.getParent();
}
if (!(eMethodCall instanceof GrCall)) return null;
return (GrCall)eMethodCall;
}
示例9: checkDefaultMapConstructor
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private void checkDefaultMapConstructor(GrArgumentList argList, PsiElement element) {
if (argList == null) return;
final GrNamedArgument[] args = argList.getNamedArguments();
for (GrNamedArgument arg : args) {
final GrArgumentLabel label = arg.getLabel();
if (label == null) continue;
if (label.getName() == null) {
final PsiElement nameElement = label.getNameElement();
if (nameElement instanceof GrExpression) {
final PsiType argType = ((GrExpression)nameElement).getType();
if (argType != null && !TypesUtil.isAssignableByMethodCallConversion(TypesUtil.createType(CommonClassNames.JAVA_LANG_STRING, arg), argType, arg)) {
registerError(nameElement, GroovyBundle.message("property.name.expected"));
}
}
else if (!"*".equals(nameElement.getText())) {
registerError(nameElement, GroovyBundle.message("property.name.expected"));
}
}
else {
final PsiElement resolved = label.resolve();
if (resolved == null) {
if (element instanceof PsiMember && !(element instanceof PsiClass)) {
element = ((PsiMember)element).getContainingClass();
}
List<LocalQuickFix> fixes = new ArrayList<LocalQuickFix>(2);
if (element instanceof GrTypeDefinition) {
fixes.add(GroovyQuickFixFactory.getInstance().createCreateFieldFromConstructorLabelFix((GrTypeDefinition)element, label.getNamedArgument()));
}
if (element instanceof PsiClass) {
fixes.add(GroovyQuickFixFactory.getInstance().createDynamicPropertyFix(label, (PsiClass)element));
}
registerError(label, GroovyBundle.message("no.such.property", label.getName()), fixes.toArray(new LocalQuickFix[fixes.size()]),
ProblemHighlightType.GENERIC_ERROR_OR_WARNING);
}
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:42,代码来源:GroovyConstructorNamedArgumentsInspection.java
示例10: getNamedArguments
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
@NotNull
public GrNamedArgument[] getNamedArguments() {
GrArgumentList argList = getArgumentList();
return argList != null ? argList.getNamedArguments() : GrNamedArgument.EMPTY_ARRAY;
}
示例11: getNamedArguments
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@NotNull
@Override
public GrNamedArgument[] getNamedArguments() {
GrArgumentList list = getArgumentList();
return list.getNamedArguments();
}
示例12: getNamedArguments
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@NotNull
@Override
public GrNamedArgument[] getNamedArguments() {
final GrArgumentList argumentList = getArgumentList();
return argumentList == null ? GrNamedArgument.EMPTY_ARRAY : argumentList.getNamedArguments();
}
示例13: getReplacementStatement
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Nullable
private static String getReplacementStatement(@NotNull PsiMethod method, @NotNull GrMethodCall methodCall) {
PsiClass containingClass = method.getContainingClass();
if (containingClass == null) return null;
String qualifiedName = containingClass.getQualifiedName();
if (!"junit.framework.Assert".equals(qualifiedName) && !"groovy.util.GroovyTestCase".equals(qualifiedName)) return null;
String[] replacementStatements = ourStatementMap.get(method.getName());
if (replacementStatements == null) return null;
GrArgumentList argumentList = methodCall.getArgumentList();
if (argumentList == null) return null;
if (argumentList.getNamedArguments().length > 0) return null;
GrExpression[] arguments = argumentList.getExpressionArguments();
if (arguments.length >= replacementStatements.length) return null;
return replacementStatements[arguments.length];
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ConvertJunitAssertionToAssertStatementIntention.java