List<String> (@NotNull PsiElement element, @Nullable Module module) { PsiElement parent = element; while (parent.getParent() != null && !(parent.getParent() instanceof PsiFile)) { parent = parent.getParent(); } if (isCreateTaskMethod(parent)) { final GrExpression[] arguments = ((GrMethodCallExpression)parent).getExpressionArguments(); if (arguments.length > 0 && arguments[0] instanceof GrLiteral && ((GrLiteral)arguments[0]).getValue() instanceof String) { return Collections.singletonList((String)((GrLiteral)arguments[0]).getValue()); } } else if (parent instanceof GrApplicationStatement) { PsiElement shiftExpression = parent.getChildren()[1].getChildren()[0]; if (GradleResolverUtil.isLShiftElement(shiftExpression)) { PsiElement shiftiesChild = shiftExpression.getChildren()[0]; if (shiftiesChild instanceof GrReferenceExpression) { return Collections.singletonList(shiftiesChild.getText()); } else if (shiftiesChild instanceof GrMethodCallExpression) { return Collections.singletonList(shiftiesChild.getChildren()[0].getText()); } } else if (shiftExpression instanceof GrMethodCallExpression) { return Collections.singletonList(shiftExpression.getChildren()[0].getText()); } } GrMethodCallExpression methodCallExpression = PsiTreeUtil.getParentOfType(element, GrMethodCallExpression.class); if (methodCallExpression != null) { String taskNameCandidate = methodCallExpression.getChildren()[0].getText(); Project project = element.getProject(); if (module == null) { module = getModule(element, project); } GradleExtensionsSettings.GradleExtensionsData extensionsData = GradleExtensionsSettings.getInstance(project).getExtensionsFor(module); if (extensionsData != null) { GradleExtensionsSettings.GradleTask gradleTask = extensionsData.tasksMap.get(taskNameCandidate); if (gradleTask != null) { return Collections.singletonList(taskNameCandidate); } } } return Collections.emptyList(); }