{"action":"created","issue":{"url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/issues/6","repository_url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint","labels_url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/issues/6/labels{/name}","comments_url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/issues/6/comments","events_url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/issues/6/events","html_url":"https://github.com/XenHat/SublimeLinter-contrib-lslint/issues/6","id":263734486,"number":6,"title":"Enhancement request for preprocessors support","user":{"login":"Winterwolf","id":405685,"avatar_url":"https://avatars2.githubusercontent.com/u/405685?v=4","gravatar_id":"","url":"https://api.github.com/users/Winterwolf","html_url":"https://github.com/Winterwolf","followers_url":"https://api.github.com/users/Winterwolf/followers","following_url":"https://api.github.com/users/Winterwolf/following{/other_user}","gists_url":"https://api.github.com/users/Winterwolf/gists{/gist_id}","starred_url":"https://api.github.com/users/Winterwolf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Winterwolf/subscriptions","organizations_url":"https://api.github.com/users/Winterwolf/orgs","repos_url":"https://api.github.com/users/Winterwolf/repos","events_url":"https://api.github.com/users/Winterwolf/events{/privacy}","received_events_url":"https://api.github.com/users/Winterwolf/received_events","type":"User","site_admin":false},"labels":[{"id":361103993,"url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/labels/enhancement","name":"enhancement","color":"84b6eb","default":true},{"id":361103994,"url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/labels/help%20wanted","name":"help wanted","color":"128A0C","default":true}],"state":"open","locked":false,"assignee":{"login":"XenHat","id":980408,"avatar_url":"https://avatars3.githubusercontent.com/u/980408?v=4","gravatar_id":"","url":"https://api.github.com/users/XenHat","html_url":"https://github.com/XenHat","followers_url":"https://api.github.com/users/XenHat/followers","following_url":"https://api.github.com/users/XenHat/following{/other_user}","gists_url":"https://api.github.com/users/XenHat/gists{/gist_id}","starred_url":"https://api.github.com/users/XenHat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XenHat/subscriptions","organizations_url":"https://api.github.com/users/XenHat/orgs","repos_url":"https://api.github.com/users/XenHat/repos","events_url":"https://api.github.com/users/XenHat/events{/privacy}","received_events_url":"https://api.github.com/users/XenHat/received_events","type":"User","site_admin":false},"assignees":[{"login":"XenHat","id":980408,"avatar_url":"https://avatars3.githubusercontent.com/u/980408?v=4","gravatar_id":"","url":"https://api.github.com/users/XenHat","html_url":"https://github.com/XenHat","followers_url":"https://api.github.com/users/XenHat/followers","following_url":"https://api.github.com/users/XenHat/following{/other_user}","gists_url":"https://api.github.com/users/XenHat/gists{/gist_id}","starred_url":"https://api.github.com/users/XenHat/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/XenHat/subscriptions","organizations_url":"https://api.github.com/users/XenHat/orgs","repos_url":"https://api.github.com/users/XenHat/repos","events_url":"https://api.github.com/users/XenHat/events{/privacy}","received_events_url":"https://api.github.com/users/XenHat/received_events","type":"User","site_admin":false}],"milestone":null,"comments":87,"created_at":"2017-10-08T17:27:41Z","updated_at":"2017-10-14T15:39:01Z","closed_at":null,"author_association":"NONE","body":"Here is issue that I've posted on lslint repo few days ago: https://github.com/Makopo/lslint/issues/47.\r\nMy problem is that your plugin ignores files icluded by preprocessor and produces errors about undeclared variables."},"comment":{"url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/issues/comments/336643047","html_url":"https://github.com/XenHat/SublimeLinter-contrib-lslint/issues/6#issuecomment-336643047","issue_url":"https://api.github.com/repos/XenHat/SublimeLinter-contrib-lslint/issues/6","id":336643047,"user":{"login":"Sei-Lisa","id":1100142,"avatar_url":"https://avatars3.githubusercontent.com/u/1100142?v=4","gravatar_id":"","url":"https://api.github.com/users/Sei-Lisa","html_url":"https://github.com/Sei-Lisa","followers_url":"https://api.github.com/users/Sei-Lisa/followers","following_url":"https://api.github.com/users/Sei-Lisa/following{/other_user}","gists_url":"https://api.github.com/users/Sei-Lisa/gists{/gist_id}","starred_url":"https://api.github.com/users/Sei-Lisa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Sei-Lisa/subscriptions","organizations_url":"https://api.github.com/users/Sei-Lisa/orgs","repos_url":"https://api.github.com/users/Sei-Lisa/repos","events_url":"https://api.github.com/users/Sei-Lisa/events{/privacy}","received_events_url":"https://api.github.com/users/Sei-Lisa/received_events","type":"User","site_admin":false},"created_at":"2017-10-14T15:39:01Z","updated_at":"2017-10-14T15:39:01Z","author_association":"NONE","body":"Well, if anything, to not spam Winterwolf with technical details. But since I didn't find you online...\r\n\r\nThe question was not if you can *access* the filename. It's assumed that the main file is open in the editor, therefore you don't need to find its name in principle; you can assume that `\"<stdin>\"` means the main file and anything else means the file specified in the `#line` directive.\r\n\r\nThe question was if you can force the linter plugin to *open* a filename you give, in order to report errors in it. I presume that a C linter, for example, must be able to do exactly this, in order to report problems in the headers. Or any other language that supports includes, for the matter.\r\n\r\nIf it doesn't support it, maybe you can file a feature request asking to implement that.\r\n\r\nBut in case it's not supported, here's how I imagine the automatic detection of `#include`.\r\n\r\nThe basis of idea is that the preprocessor will insert a `#line` directive with a different filename at the exact point where it found the `#include`. Therefore, when an error is found in a different filename, your aim is to find the last `#line` directive which had `\"<stdin>\"` as a file before that line (call that L1), keeping track of where the first `#line` directive which changed the filename was (call that L2).\r\n\r\nThen you replace the error line with L2, and do the same conversion math you're doing now using L1, and that's the line number that will appear in the final output.\r\n\r\nExample:\r\n\r\n#### top.lsl\r\n\r\n```lsl\r\n   1 | string s; // just to add something\r\n   2 | #include \"level1.lsl\"\r\n   3 | default{state_entry(){llOwnerSay(s);}}\r\n```\r\n\r\n#### level1.lsl\r\n\r\n```lsl\r\n   1 | #include \"level2.lsl\"\r\n```\r\n\r\n#### level2.lsl\r\n\r\n```lsl\r\n   1 | integer x;\r\n```\r\n\r\nThe goal is to report the unused identifier at line 2 of our file, which is the line with the include. The mcpp output is:\r\n\r\n```\r\n   1 | #line 1 \"<stdin>\"\r\n   2 | string s;\r\n   3 | #line 2 \"<stdin>\"\r\n   4 | #line 1 \"level1.lsl\"\r\n   5 | #line 1 \"level2.lsl\"\r\n   6 | integer x;\r\n   7 | #line 2 \"level1.lsl\"\r\n   8 | #line 3 \"<stdin>\"\r\n   9 | default{state_entry(){}}\r\n```\r\n\r\nThe error lines reported by lslint are 2 and 6. For line 2, the last `#line` had `\"<stdin>\"` as file, therefore you do your usual thing.\r\n\r\nFor line 6, the last file was not `\"<stdin>\"`, so you have to make a replacement. The last `#line` directive that had `\"<stdin>\"` is line 3, and the first `#line` directive after that one is line 4. Therefore, you replace the error line number as if it actually happened in line 4, because that's where the `#include` was (which is why the filename has changed). Then you do the usual thing, but using 4 as the error line number.\r\n\r\nIf all goes well, the output should be:\r\n\r\n```\r\n WARN:: (  1,  8): variable `s' declared but never used.\r\n WARN:: (  2,  8): variable `t' declared but never used.\r\nTOTAL:: Errors: 0  Warnings: 2\r\n```\r\n"}}
{"actor":{"display_login":"Sei-Lisa"}}