{"action":"created","comment":{"url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments/37962516","id":37962516,"diff_hunk":"@@ -1873,4 +1881,104 @@ private boolean expectedFunction(@Nullable PsiElement resolve) {\n       return true;\n     }\n   }\n+\n+  public static class ErlangFunctionCallNamedParameter<T extends PsiElement> extends PatternCondition<T> {\n+    private final List<String> NAMES;\n+\n+    public ErlangFunctionCallNamedParameter(@NotNull String... names) {\n+      super(\"functionCallNamedParameter\");\n+      NAMES = ContainerUtil.newArrayList(names);\n+    }\n+\n+    @Override\n+    public boolean accepts(@NotNull T element, ProcessingContext context) {\n+      ErlangQAtom atom = element instanceof ErlangQAtom ? (ErlangQAtom) element : null;\n+      ErlangMaxExpression expr = ObjectUtils.tryCast(atom != null ? atom.getParent() : null, ErlangMaxExpression.class);\n+      ErlangArgumentList args = ObjectUtils.tryCast(expr != null ? expr.getParent() : null, ErlangArgumentList.class);\n+      if (expr == null || args == null) return false;\n+\n+      int position = args.getExpressionList().indexOf(expr);\n+      if (position == -1) return false;\n+\n+      ErlangFunctionCallExpression call = ObjectUtils.tryCast(args.getParent(), ErlangFunctionCallExpression.class);\n+      ErlangFunction function = resolveToFunction(call);\n+      if (function == null) return false;\n+\n+      for (ErlangFunctionClause clause : function.getFunctionClauseList()) {\n+        if (elementSuits(clause, position)) return true;\n+      }\n+      return false;\n+    }\n+\n+    private boolean elementSuits(@NotNull ErlangFunctionClause clause, int position) {\n+      List<ErlangArgumentDefinition> definitions = clause.getArgumentDefinitionList().getArgumentDefinitionList();\n+      ErlangArgumentDefinition definition = definitions.size() > position ? definitions.get(position) : null;\n+      ErlangMaxExpression maxExpression = PsiTreeUtil.getChildOfType(definition, ErlangMaxExpression.class);\n+      ErlangQVar var = PsiTreeUtil.getChildOfType(maxExpression, ErlangQVar.class);\n+      if (var != null && NAMES.contains(var.getName())) {\n+        return true;\n+      }\n+      return false;\n+    }\n+  }\n+\n+  public static class ErlangSpecParameter<T extends PsiElement> extends PatternCondition<T> {\n+    public ErlangSpecParameter() {\n+      super(\"SpecParameter\");\n+    }\n+\n+    @Override\n+    public boolean accepts(@NotNull T element, ProcessingContext context) {\n+      ErlangQAtom atom = element instanceof ErlangQAtom ? (ErlangQAtom) element : null;\n+      ErlangMaxExpression expr = ObjectUtils.tryCast(atom != null ? atom.getParent() : null, ErlangMaxExpression.class);\n+      ErlangArgumentList args = ObjectUtils.tryCast(expr != null ? expr.getParent() : null, ErlangArgumentList.class);\n+      ErlangSpecification specification = getSpecification(args);\n+      if (atom == null || expr == null || args == null || specification == null) return false;\n+\n+      int position = args.getExpressionList().indexOf(expr);\n+      if (position == -1) return false;\n+\n+      ErlangFunTypeSigs signature = specification.getSignature();\n+      if (signature == null) return false;\n+\n+      for (ErlangTypeSig typeSig : signature.getTypeSigList()) {\n+        List<ErlangType> types = typeSig.getFunType().getFunTypeArguments().getTypeList();\n+        if (types.size() <= position) continue;\n+\n+        ErlangQVar typeVar = types.get(position).getQVar();\n+        if (argumentIsModule(typeVar, typeSig)) {","path":"src/org/intellij/erlang/psi/impl/ErlangPsiImplUtil.java","position":84,"original_position":84,"commit_id":"e2f58e8dd9dd4932e7a8072be41c3b03e195a0d4","original_commit_id":"e2f58e8dd9dd4932e7a8072be41c3b03e195a0d4","user":{"login":"deadok22","id":1259620,"avatar_url":"https://avatars.githubusercontent.com/u/1259620?v=3","gravatar_id":"","url":"https://api.github.com/users/deadok22","html_url":"https://github.com/deadok22","followers_url":"https://api.github.com/users/deadok22/followers","following_url":"https://api.github.com/users/deadok22/following{/other_user}","gists_url":"https://api.github.com/users/deadok22/gists{/gist_id}","starred_url":"https://api.github.com/users/deadok22/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadok22/subscriptions","organizations_url":"https://api.github.com/users/deadok22/orgs","repos_url":"https://api.github.com/users/deadok22/repos","events_url":"https://api.github.com/users/deadok22/events{/privacy}","received_events_url":"https://api.github.com/users/deadok22/received_events","type":"User","site_admin":false},"body":"What if there's no type variable?\r\n\r\n```erlang\r\n-spec myspawn(module(), atom(), list()) -> atom().\r\nmyspawn(M, F, A) -> ok.\r\n\r\ninit() ->\r\n  myspawn(aaa, init, []).\r\n```\r\n\r\nRemember to get fixed cases covered in tests.","created_at":"2015-08-26T09:30:28Z","updated_at":"2015-08-26T09:30:28Z","html_url":"https://github.com/ignatov/intellij-erlang/pull/675#discussion_r37962516","pull_request_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675","_links":{"self":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments/37962516"},"html":{"href":"https://github.com/ignatov/intellij-erlang/pull/675#discussion_r37962516"},"pull_request":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675"}}},"pull_request":{"url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675","id":43142503,"html_url":"https://github.com/ignatov/intellij-erlang/pull/675","diff_url":"https://github.com/ignatov/intellij-erlang/pull/675.diff","patch_url":"https://github.com/ignatov/intellij-erlang/pull/675.patch","issue_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/675","number":675,"state":"open","locked":false,"title":"Add resolving to modules and functions as function call parameters","user":{"login":"telezhnaya","id":11246099,"avatar_url":"https://avatars.githubusercontent.com/u/11246099?v=3","gravatar_id":"","url":"https://api.github.com/users/telezhnaya","html_url":"https://github.com/telezhnaya","followers_url":"https://api.github.com/users/telezhnaya/followers","following_url":"https://api.github.com/users/telezhnaya/following{/other_user}","gists_url":"https://api.github.com/users/telezhnaya/gists{/gist_id}","starred_url":"https://api.github.com/users/telezhnaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telezhnaya/subscriptions","organizations_url":"https://api.github.com/users/telezhnaya/orgs","repos_url":"https://api.github.com/users/telezhnaya/repos","events_url":"https://api.github.com/users/telezhnaya/events{/privacy}","received_events_url":"https://api.github.com/users/telezhnaya/received_events","type":"User","site_admin":false},"body":"I understand that it is very bad to check type as string equality. I'll do something with that.\r\n\r\nAnother moment is that module doesn't resolve if spec argument could have several types or has hierarchical structure, for example:\r\n```erlang\r\n-spec monitor(Type, Item) -> MonitorRef when\r\n      Type :: process,\r\n      Item :: pid() | RegName | {RegName, Node},\r\n      RegName :: module(),\r\n      Node :: node(),\r\n      MonitorRef :: reference().\r\n```\r\n\r\nBy the way, it's the only example from standard library. All other examples are so simple. Like that:\r\n```erlang\r\n-spec check_old_code(Module) -> boolean() when\r\n      Module :: module().\r\n```\r\nAnd they are working correctly.\r\n\r\nAlso this code may have similar mistakes as here https://github.com/ignatov/intellij-erlang/pull/673 because I quite not understand some of your comments.\r\n\r\nSo I just want to know your general opinion.","created_at":"2015-08-24T06:06:16Z","updated_at":"2015-08-26T09:30:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"96aee20a7d15ea587093b4e4cefd0f11521aec4b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675/commits","review_comments_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675/comments","review_comment_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/675/comments","statuses_url":"https://api.github.com/repos/ignatov/intellij-erlang/statuses/e2f58e8dd9dd4932e7a8072be41c3b03e195a0d4","head":{"label":"telezhnaya:resolve","ref":"resolve","sha":"e2f58e8dd9dd4932e7a8072be41c3b03e195a0d4","user":{"login":"telezhnaya","id":11246099,"avatar_url":"https://avatars.githubusercontent.com/u/11246099?v=3","gravatar_id":"","url":"https://api.github.com/users/telezhnaya","html_url":"https://github.com/telezhnaya","followers_url":"https://api.github.com/users/telezhnaya/followers","following_url":"https://api.github.com/users/telezhnaya/following{/other_user}","gists_url":"https://api.github.com/users/telezhnaya/gists{/gist_id}","starred_url":"https://api.github.com/users/telezhnaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telezhnaya/subscriptions","organizations_url":"https://api.github.com/users/telezhnaya/orgs","repos_url":"https://api.github.com/users/telezhnaya/repos","events_url":"https://api.github.com/users/telezhnaya/events{/privacy}","received_events_url":"https://api.github.com/users/telezhnaya/received_events","type":"User","site_admin":false},"repo":{"id":38743302,"name":"intellij-erlang","full_name":"telezhnaya/intellij-erlang","owner":{"login":"telezhnaya","id":11246099,"avatar_url":"https://avatars.githubusercontent.com/u/11246099?v=3","gravatar_id":"","url":"https://api.github.com/users/telezhnaya","html_url":"https://github.com/telezhnaya","followers_url":"https://api.github.com/users/telezhnaya/followers","following_url":"https://api.github.com/users/telezhnaya/following{/other_user}","gists_url":"https://api.github.com/users/telezhnaya/gists{/gist_id}","starred_url":"https://api.github.com/users/telezhnaya/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/telezhnaya/subscriptions","organizations_url":"https://api.github.com/users/telezhnaya/orgs","repos_url":"https://api.github.com/users/telezhnaya/repos","events_url":"https://api.github.com/users/telezhnaya/events{/privacy}","received_events_url":"https://api.github.com/users/telezhnaya/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/telezhnaya/intellij-erlang","description":"Erlang IDE (IntelliJ-based)","fork":true,"url":"https://api.github.com/repos/telezhnaya/intellij-erlang","forks_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/forks","keys_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/teams","hooks_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/hooks","issue_events_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/issues/events{/number}","events_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/events","assignees_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/assignees{/user}","branches_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/branches{/branch}","tags_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/tags","blobs_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/git/refs{/sha}","trees_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/statuses/{sha}","languages_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/languages","stargazers_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/stargazers","contributors_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/contributors","subscribers_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/subscribers","subscription_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/subscription","commits_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/commits{/sha}","git_commits_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/git/commits{/sha}","comments_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/comments{/number}","issue_comment_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/issues/comments{/number}","contents_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/contents/{+path}","compare_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/merges","archive_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/downloads","issues_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/issues{/number}","pulls_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/pulls{/number}","milestones_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/milestones{/number}","notifications_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/labels{/name}","releases_url":"https://api.github.com/repos/telezhnaya/intellij-erlang/releases{/id}","created_at":"2015-07-08T09:00:53Z","updated_at":"2015-07-08T09:00:56Z","pushed_at":"2015-08-26T08:24:09Z","git_url":"git://github.com/telezhnaya/intellij-erlang.git","ssh_url":"git@github.com:telezhnaya/intellij-erlang.git","clone_url":"https://github.com/telezhnaya/intellij-erlang.git","svn_url":"https://github.com/telezhnaya/intellij-erlang","homepage":"https://www.jetbrains.com/idea/features/erlang.html","size":69441,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ignatov:master","ref":"master","sha":"9002eb91298dd8b180d36e371d3bdca544a9b4be","user":{"login":"ignatov","id":426890,"avatar_url":"https://avatars.githubusercontent.com/u/426890?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatov","html_url":"https://github.com/ignatov","followers_url":"https://api.github.com/users/ignatov/followers","following_url":"https://api.github.com/users/ignatov/following{/other_user}","gists_url":"https://api.github.com/users/ignatov/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatov/subscriptions","organizations_url":"https://api.github.com/users/ignatov/orgs","repos_url":"https://api.github.com/users/ignatov/repos","events_url":"https://api.github.com/users/ignatov/events{/privacy}","received_events_url":"https://api.github.com/users/ignatov/received_events","type":"User","site_admin":false},"repo":{"id":5168907,"name":"intellij-erlang","full_name":"ignatov/intellij-erlang","owner":{"login":"ignatov","id":426890,"avatar_url":"https://avatars.githubusercontent.com/u/426890?v=3","gravatar_id":"","url":"https://api.github.com/users/ignatov","html_url":"https://github.com/ignatov","followers_url":"https://api.github.com/users/ignatov/followers","following_url":"https://api.github.com/users/ignatov/following{/other_user}","gists_url":"https://api.github.com/users/ignatov/gists{/gist_id}","starred_url":"https://api.github.com/users/ignatov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ignatov/subscriptions","organizations_url":"https://api.github.com/users/ignatov/orgs","repos_url":"https://api.github.com/users/ignatov/repos","events_url":"https://api.github.com/users/ignatov/events{/privacy}","received_events_url":"https://api.github.com/users/ignatov/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ignatov/intellij-erlang","description":"Erlang IDE (IntelliJ-based)","fork":false,"url":"https://api.github.com/repos/ignatov/intellij-erlang","forks_url":"https://api.github.com/repos/ignatov/intellij-erlang/forks","keys_url":"https://api.github.com/repos/ignatov/intellij-erlang/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ignatov/intellij-erlang/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ignatov/intellij-erlang/teams","hooks_url":"https://api.github.com/repos/ignatov/intellij-erlang/hooks","issue_events_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/events{/number}","events_url":"https://api.github.com/repos/ignatov/intellij-erlang/events","assignees_url":"https://api.github.com/repos/ignatov/intellij-erlang/assignees{/user}","branches_url":"https://api.github.com/repos/ignatov/intellij-erlang/branches{/branch}","tags_url":"https://api.github.com/repos/ignatov/intellij-erlang/tags","blobs_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/refs{/sha}","trees_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ignatov/intellij-erlang/statuses/{sha}","languages_url":"https://api.github.com/repos/ignatov/intellij-erlang/languages","stargazers_url":"https://api.github.com/repos/ignatov/intellij-erlang/stargazers","contributors_url":"https://api.github.com/repos/ignatov/intellij-erlang/contributors","subscribers_url":"https://api.github.com/repos/ignatov/intellij-erlang/subscribers","subscription_url":"https://api.github.com/repos/ignatov/intellij-erlang/subscription","commits_url":"https://api.github.com/repos/ignatov/intellij-erlang/commits{/sha}","git_commits_url":"https://api.github.com/repos/ignatov/intellij-erlang/git/commits{/sha}","comments_url":"https://api.github.com/repos/ignatov/intellij-erlang/comments{/number}","issue_comment_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues/comments{/number}","contents_url":"https://api.github.com/repos/ignatov/intellij-erlang/contents/{+path}","compare_url":"https://api.github.com/repos/ignatov/intellij-erlang/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ignatov/intellij-erlang/merges","archive_url":"https://api.github.com/repos/ignatov/intellij-erlang/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ignatov/intellij-erlang/downloads","issues_url":"https://api.github.com/repos/ignatov/intellij-erlang/issues{/number}","pulls_url":"https://api.github.com/repos/ignatov/intellij-erlang/pulls{/number}","milestones_url":"https://api.github.com/repos/ignatov/intellij-erlang/milestones{/number}","notifications_url":"https://api.github.com/repos/ignatov/intellij-erlang/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ignatov/intellij-erlang/labels{/name}","releases_url":"https://api.github.com/repos/ignatov/intellij-erlang/releases{/id}","created_at":"2012-07-24T17:41:30Z","updated_at":"2015-08-18T23:53:32Z","pushed_at":"2015-08-26T08:24:50Z","git_url":"git://github.com/ignatov/intellij-erlang.git","ssh_url":"git@github.com:ignatov/intellij-erlang.git","clone_url":"https://github.com/ignatov/intellij-erlang.git","svn_url":"https://github.com/ignatov/intellij-erlang","homepage":"https://www.jetbrains.com/idea/features/erlang.html","size":74426,"stargazers_count":396,"watchers_count":396,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":44,"mirror_url":null,"open_issues_count":122,"forks":44,"open_issues":122,"watchers":396,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675"},"html":{"href":"https://github.com/ignatov/intellij-erlang/pull/675"},"issue":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/issues/675"},"comments":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/issues/675/comments"},"review_comments":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675/comments"},"review_comment":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/pulls/675/commits"},"statuses":{"href":"https://api.github.com/repos/ignatov/intellij-erlang/statuses/e2f58e8dd9dd4932e7a8072be41c3b03e195a0d4"}}}}