本文整理汇总了Java中org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList.getExpressionArguments方法的典型用法代码示例。如果您正苦于以下问题:Java GrArgumentList.getExpressionArguments方法的具体用法?Java GrArgumentList.getExpressionArguments怎么用?Java GrArgumentList.getExpressionArguments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList
的用法示例。
在下文中一共展示了GrArgumentList.getExpressionArguments方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: pullDependenciesIntoMap
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
/**
* Looks for 'compile "*"' statements and tries to parse them into Gradle coordinates. If successful,
* adds the new coordinate to the map and removes the corresponding PsiElement from the tree.
* @return true if new items were added to the map
*/
private static boolean pullDependenciesIntoMap(@NotNull PsiElement root, Multimap<String, GradleCoordinate> map,
@Nullable List<String> unparseableDependencies) {
boolean wasMapUpdated = false;
for (PsiElement existingElem : root.getChildren()) {
if (existingElem instanceof GrCall) {
PsiElement reference = existingElem.getFirstChild();
if (reference instanceof GrReferenceExpression && reference.getText().equalsIgnoreCase(COMPILE)) {
boolean parsed = false;
GrCall call = (GrCall)existingElem;
GrArgumentList arguments = call.getArgumentList();
// Don't try merging dependencies if one of them has a closure block attached.
if (arguments != null && call.getClosureArguments().length == 0) {
GrExpression[] expressionArguments = arguments.getExpressionArguments();
if (expressionArguments.length == 1 && expressionArguments[0] instanceof GrLiteral) {
Object value = ((GrLiteral)expressionArguments[0]).getValue();
if (value instanceof String) {
String coordinateText = (String)value;
GradleCoordinate coordinate = GradleCoordinate.parseCoordinateString(coordinateText);
if (coordinate != null) {
parsed = true;
if (!map.get(coordinate.getId()).contains(coordinate)) {
map.put(coordinate.getId(), coordinate);
existingElem.delete();
wasMapUpdated = true;
}
}
}
}
}
if (!parsed && unparseableDependencies != null) {
unparseableDependencies.add(existingElem.getText());
}
}
}
}
return wasMapUpdated;
}
示例4: 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;
}
示例5: hasEnclosingInstanceInArgList
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private static boolean hasEnclosingInstanceInArgList(@NotNull GrArgumentList list, @NotNull PsiClass enclosingClass) {
if (PsiImplUtil.hasNamedArguments(list)) return false;
GrExpression[] args = list.getExpressionArguments();
if (args.length == 0) return false;
PsiType type = args[0].getType();
PsiClassType enclosingClassType = JavaPsiFacade.getElementFactory(list.getProject()).createType(enclosingClass);
return TypesUtil.isAssignableByMethodCallConversion(enclosingClassType, type, list);
}
示例6: visitMethodCallExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
super.visitMethodCallExpression(grMethodCallExpression);
final GrArgumentList args = grMethodCallExpression.getArgumentList();
if (args == null) {
return;
}
if (args.getExpressionArguments().length != 2) {
return;
}
if (PsiImplUtil.hasNamedArguments(args)) {
return;
}
final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
if (!(methodExpression instanceof GrReferenceExpression)) {
return;
}
final GrReferenceExpression referenceExpression = (GrReferenceExpression) methodExpression;
final String name = referenceExpression.getReferenceName();
if (!"put".equals(name)) {
return;
}
final GrExpression qualifier = referenceExpression.getQualifierExpression();
if (qualifier == null || PsiUtil.isThisOrSuperRef(qualifier)) {
return;
}
if (referenceExpression.getDotTokenType() == GroovyTokenTypes.mOPTIONAL_DOT) return;
final PsiType type = qualifier.getType();
if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
return;
}
registerMethodCallError(grMethodCallExpression);
}
示例7: visitMethodCallExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
super.visitMethodCallExpression(grMethodCallExpression);
final GrArgumentList args = grMethodCallExpression.getArgumentList();
if (args == null) {
return;
}
if (args.getExpressionArguments().length != 1) {
return;
}
if (PsiImplUtil.hasNamedArguments(args)) {
return;
}
final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
if (!(methodExpression instanceof GrReferenceExpression)) {
return;
}
final GrReferenceExpression referenceExpression = (GrReferenceExpression) methodExpression;
final String name = referenceExpression.getReferenceName();
if (!"get".equals(name)) {
return;
}
final GrExpression qualifier = referenceExpression.getQualifierExpression();
if (qualifier == null || PsiUtil.isThisOrSuperRef(qualifier)) {
return;
}
if (referenceExpression.getDotTokenType() == GroovyTokenTypes.mOPTIONAL_DOT) return;
final PsiType type = qualifier.getType();
if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_MAP)) {
return;
}
registerMethodCallError(grMethodCallExpression);
}
示例8: visitMethodCallExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
super.visitMethodCallExpression(grMethodCallExpression);
final GrArgumentList args = grMethodCallExpression.getArgumentList();
if (args == null) {
return;
}
if (args.getExpressionArguments().length != 1) {
return;
}
if (PsiImplUtil.hasNamedArguments(args)) {
return;
}
final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
if (!(methodExpression instanceof GrReferenceExpression)) {
return;
}
final GrReferenceExpression referenceExpression = (GrReferenceExpression) methodExpression;
final String name = referenceExpression.getReferenceName();
if (!"get".equals(name)) {
return;
}
final GrExpression qualifier = referenceExpression.getQualifierExpression();
if (qualifier == null || PsiUtil.isThisOrSuperRef(qualifier)) {
return;
}
if (referenceExpression.getDotTokenType() == GroovyTokenTypes.mOPTIONAL_DOT) return;
final PsiType type = qualifier.getType();
if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_LIST)) {
return;
}
registerMethodCallError(grMethodCallExpression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GroovyListGetCanBeKeyedAccessInspection.java
示例9: visitMethodCallExpression
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public void visitMethodCallExpression(GrMethodCallExpression grMethodCallExpression) {
super.visitMethodCallExpression(grMethodCallExpression);
final GrArgumentList args = grMethodCallExpression.getArgumentList();
if (args == null) {
return;
}
if (args.getExpressionArguments().length != 2) {
return;
}
if (PsiImplUtil.hasNamedArguments(args)) {
return;
}
final GrExpression methodExpression = grMethodCallExpression.getInvokedExpression();
if (!(methodExpression instanceof GrReferenceExpression)) {
return;
}
final GrReferenceExpression referenceExpression = (GrReferenceExpression) methodExpression;
final String name = referenceExpression.getReferenceName();
if (!"set".equals(name)) {
return;
}
final GrExpression qualifier = referenceExpression.getQualifierExpression();
if (qualifier == null || PsiUtil.isThisOrSuperRef(qualifier)) {
return;
}
if (referenceExpression.getDotTokenType() == GroovyTokenTypes.mOPTIONAL_DOT) return;
final PsiType type = qualifier.getType();
if (!InheritanceUtil.isInheritor(type, CommonClassNames.JAVA_UTIL_LIST)) {
return;
}
registerMethodCallError(grMethodCallExpression);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GroovyListSetCanBeKeyedAccessInspection.java
示例10: checkConstructorApplicability
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private <T extends GroovyPsiElement> boolean checkConstructorApplicability(@NotNull GroovyResolveResult constructorResolveResult,
@NotNull CallInfo<T> info,
boolean checkUnknownArgs) {
final PsiElement element = constructorResolveResult.getElement();
LOG.assertTrue(element instanceof PsiMethod && ((PsiMethod)element).isConstructor(), element);
final PsiMethod constructor = (PsiMethod)element;
final GrArgumentList argList = info.getArgumentList();
if (argList != null) {
final GrExpression[] exprArgs = argList.getExpressionArguments();
if (exprArgs.length == 0 && !PsiUtil.isConstructorHasRequiredParameters(constructor)) return true;
}
PsiType[] types = info.getArgumentTypes();
PsiClass containingClass = constructor.getContainingClass();
if (types != null && containingClass != null) {
final PsiType[] newTypes = GrInnerClassConstructorUtil.addEnclosingArgIfNeeded(types, info.getCall(), containingClass);
if (newTypes.length != types.length) {
return checkMethodApplicability(constructorResolveResult, checkUnknownArgs, new DelegatingCallInfo<T>(info) {
@Nullable
@Override
public PsiType[] getArgumentTypes() {
return newTypes;
}
});
}
}
return checkMethodApplicability(constructorResolveResult, checkUnknownArgs, info);
}
示例11: getNamedArguments
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public void getNamedArguments(@NotNull GrCall call,
@Nullable PsiElement resolve,
@Nullable String argumentName,
boolean forCompletion,
Map<String, NamedArgumentDescriptor> result) {
if (!(call instanceof GrNewExpression)) return;
if (resolve != null) {
if (!(resolve instanceof PsiMethod)) return;
PsiMethod method = (PsiMethod)resolve;
if (!method.isConstructor()) return;
}
GrNewExpression newCall = (GrNewExpression)call;
GrArgumentList argumentList = newCall.getArgumentList();
if (argumentList == null) return;
GrExpression[] expressionArguments = argumentList.getExpressionArguments();
if (expressionArguments.length > 1 || (expressionArguments.length == 1 && !(expressionArguments[0] instanceof GrReferenceExpression))) {
return;
}
for (GroovyResolveResult resolveResult : newCall.multiResolveClass()) {
PsiElement element = resolveResult.getElement();
if (!(element instanceof PsiClass)) continue;
PsiClass aClass = (PsiClass)element;
if (!isClassHasConstructorWithMap(aClass)) continue;
PsiClassType classType = JavaPsiFacade.getElementFactory(aClass.getProject()).createType(aClass);
processClass(call, classType, argumentName, result);
}
}
示例12: extractArguments
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
private void extractArguments(GrArgumentList argumentList) {
GrExpression[] expr = argumentList.getExpressionArguments();
if (expr.length == 1 && expr[0] instanceof GrLiteral) {
Object value = ((GrLiteral)expr[0]).getValue();
if (value instanceof String) {
String s = (String)value;
if (StringUtil.isJavaIdentifier(s)) {
add((String)value);
}
}
}
}
示例13: 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;
}
示例14: fun
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public PsiType fun(GrMethodCall methodCall, PsiMethod method) {
GrArgumentList argumentList = methodCall.getArgumentList();
if (argumentList == null) return null;
GrExpression[] arguments = argumentList.getExpressionArguments();
if (arguments.length == 0) return null;
return arguments[0].getType();
}
示例15: apply
import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; //导入方法依赖的package包/类
@Override
public void apply(@NotNull Editor editor, @NotNull GroovySmartEnterProcessor processor, @NotNull PsiElement psiElement) {
final GrArgumentList argList = psiElement instanceof GrCall ? ((GrCall)psiElement).getArgumentList() : null;
if (argList == null || argList instanceof GrCommandArgumentList) return;
GrCall call = (GrCall)psiElement;
PsiElement parenth = argList.getLastChild();
if (parenth != null && ")".equals(parenth.getText()) || PsiImplUtil.hasClosureArguments(call)) return;
int endOffset = -1;
for (PsiElement child = argList.getFirstChild(); child != null; child = child.getNextSibling()) {
if (!(child instanceof PsiErrorElement)) continue;
final PsiErrorElement errorElement = (PsiErrorElement)child;
if (errorElement.getErrorDescription().contains("')'")) {
endOffset = errorElement.getTextRange().getStartOffset();
break;
}
}
if (endOffset == -1) {
endOffset = argList.getTextRange().getEndOffset();
}
final GrExpression[] params = argList.getExpressionArguments();
if (params.length > 0 && GrForBodyFixer.startLine(editor.getDocument(), argList) !=
GrForBodyFixer.startLine(editor.getDocument(), params[0])) {
endOffset = argList.getTextRange().getStartOffset() + 1;
}
endOffset = CharArrayUtil.shiftBackward(editor.getDocument().getCharsSequence(), endOffset - 1, " \t\n") + 1;
editor.getDocument().insertString(endOffset, ")");
}