{"action":"created","issue":{"url":"https://api.github.com/repos/usethesource/rascal/issues/1001","repository_url":"https://api.github.com/repos/usethesource/rascal","labels_url":"https://api.github.com/repos/usethesource/rascal/issues/1001/labels{/name}","comments_url":"https://api.github.com/repos/usethesource/rascal/issues/1001/comments","events_url":"https://api.github.com/repos/usethesource/rascal/issues/1001/events","html_url":"https://github.com/usethesource/rascal/issues/1001","id":188794262,"number":1001,"title":"Method location with position info points to incorrect location in file","user":{"login":"Chronophobe","id":4446132,"avatar_url":"https://avatars.githubusercontent.com/u/4446132?v=3","gravatar_id":"","url":"https://api.github.com/users/Chronophobe","html_url":"https://github.com/Chronophobe","followers_url":"https://api.github.com/users/Chronophobe/followers","following_url":"https://api.github.com/users/Chronophobe/following{/other_user}","gists_url":"https://api.github.com/users/Chronophobe/gists{/gist_id}","starred_url":"https://api.github.com/users/Chronophobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chronophobe/subscriptions","organizations_url":"https://api.github.com/users/Chronophobe/orgs","repos_url":"https://api.github.com/users/Chronophobe/repos","events_url":"https://api.github.com/users/Chronophobe/events{/privacy}","received_events_url":"https://api.github.com/users/Chronophobe/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-11-11T16:14:08Z","updated_at":"2016-11-16T10:32:00Z","closed_at":null,"body":"When looking at comments inside methods of a Java class, I encountered the following issue:\r\n\r\nRetrieving the location of the comment region (e.g. `|java+method:///Main/randomInt(int)|(130,28,<5,12>,<5,40>)` works fine, but then when accessing it by either clicking on it or using as a function such as `readFile`, it starts at the beginning of the source file rather than the beginning of the method declaration. \r\n\r\n```Java\r\npublic class Main {\r\n\t\r\n\tpublic static int randomInt(int x){\r\n\t\treturn 4; // https://www.xkcd.com/221/\r\n\t}\r\n\r\n}\r\n```\r\n```Rascal\r\nimport lang::java::jdt::m3::Core;\r\nimport IO;\r\n\r\nM3 classModel = createM3FromFile(|project://CommentTest/src/Main.java|);\r\nM3 methodModel = createM3FromFile(|java+method:///Main/randomInt(int)|);\r\n\r\n// prints: \"// https://www.xkcd.com/221/\"\r\nfor(<_, comment> <- classModel@documentation){\r\n    println(readFile(comment));\r\n}\r\n\r\n// prints: \"t randomInt(int x){\\n\\t\\treturn\"\r\nfor(<_, comment> <- methodModel@documentation){\r\n    println(readFile(comment));\r\n}\r\n```\r\n\r\nWhile `readFile(|java+method:///Main/randomInt(int)|)` returns just the source of the method (as expected)."},"comment":{"url":"https://api.github.com/repos/usethesource/rascal/issues/comments/260911070","html_url":"https://github.com/usethesource/rascal/issues/1001#issuecomment-260911070","issue_url":"https://api.github.com/repos/usethesource/rascal/issues/1001","id":260911070,"user":{"login":"Chronophobe","id":4446132,"avatar_url":"https://avatars.githubusercontent.com/u/4446132?v=3","gravatar_id":"","url":"https://api.github.com/users/Chronophobe","html_url":"https://github.com/Chronophobe","followers_url":"https://api.github.com/users/Chronophobe/followers","following_url":"https://api.github.com/users/Chronophobe/following{/other_user}","gists_url":"https://api.github.com/users/Chronophobe/gists{/gist_id}","starred_url":"https://api.github.com/users/Chronophobe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Chronophobe/subscriptions","organizations_url":"https://api.github.com/users/Chronophobe/orgs","repos_url":"https://api.github.com/users/Chronophobe/repos","events_url":"https://api.github.com/users/Chronophobe/events{/privacy}","received_events_url":"https://api.github.com/users/Chronophobe/received_events","type":"User","site_admin":false},"created_at":"2016-11-16T10:32:00Z","updated_at":"2016-11-16T10:32:00Z","body":"I'm using the stable version of Rascal (0.8.0.201510231502).\r\n\r\nThere are no exceptions being thrown, but upon further inspection of the `methodModel`, it actually shows messages about syntax errors. This makes sense knowing that the offsets are broken in the logical locations.\r\n\r\nThank you for the explanation and advice!"}}
{"actor":{"display_login":"Chronophobe"}}