private static boolean methodCallExpressionsAreEquivalent( @NotNull GrMethodCall methodExp1, @NotNull GrMethodCall methodExp2) { final GrExpression methodExpression1 = methodExp1.getInvokedExpression(); final GrExpression methodExpression2 = methodExp2.getInvokedExpression(); if (!expressionsAreEquivalent(methodExpression1, methodExpression2)) { return false; } final GrArgumentList argumentList1 = methodExp1.getArgumentList(); if (argumentList1 == null) { return false; } final GrArgumentList argumentList2 = methodExp2.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; } final GrClosableBlock[] closures1 = methodExp1.getClosureArguments(); final GrClosableBlock[] closures2 = methodExp2.getClosureArguments(); return expressionListsAreEquivalent(closures1, closures2); }
@NotNull private Collection<? extends MavenRemoteRepository> findMavenRemoteRepositories( @Nullable GrClosableBlock repositoriesBlock) { Set<MavenRemoteRepository> myRemoteRepositories = ContainerUtil.newHashSet(); for (GrMethodCall repo : PsiTreeUtil.getChildrenOfTypeAsList(repositoriesBlock, GrMethodCall.class)) { final String expressionText = repo.getInvokedExpression().getText(); if ("mavenCentral".equals(expressionText)) { myRemoteRepositories.add(mavenCentralRemoteRepository); } else if ("mavenRepo".equals(expressionText)) { for (GrNamedArgument namedArgument : repo.getNamedArguments()) { if ("url".equals(namedArgument.getLabelName())) { URI urlArgumentValue = resolveUriFromSimpleExpression(namedArgument.getExpression()); if (urlArgumentValue != null) { String textUri = urlArgumentValue.toString(); myRemoteRepositories.add( new MavenRemoteRepository(textUri, null, textUri, null, null, null)); } break; } } } else if ("maven".equals(expressionText) && repo.getClosureArguments().length > 0) { List<GrApplicationStatement> applicationStatementList = PsiTreeUtil.getChildrenOfTypeAsList( repo.getClosureArguments()[0], GrApplicationStatement.class); if (!applicationStatementList.isEmpty()) { GrApplicationStatement statement = applicationStatementList.get(0); if (statement == null) continue; GrExpression expression = statement.getInvokedExpression(); if ("url".equals(expression.getText())) { URI urlArgumentValue = resolveUriFromSimpleExpression(statement.getExpressionArguments()[0]); if (urlArgumentValue != null) { String textUri = urlArgumentValue.toString(); myRemoteRepositories.add( new MavenRemoteRepository(textUri, null, textUri, null, null, null)); } } } List<GrAssignmentExpression> assignmentExpressionList = PsiTreeUtil.getChildrenOfTypeAsList( repo.getClosureArguments()[0], GrAssignmentExpression.class); if (!assignmentExpressionList.isEmpty()) { GrAssignmentExpression statement = assignmentExpressionList.get(0); if (statement == null) continue; GrExpression expression = statement.getLValue(); if ("url".equals(expression.getText())) { URI urlArgumentValue = resolveUriFromSimpleExpression(statement.getRValue()); if (urlArgumentValue != null) { String textUri = urlArgumentValue.toString(); myRemoteRepositories.add( new MavenRemoteRepository(textUri, null, textUri, null, null, null)); } } } } } return myRemoteRepositories; }