SublimeLinter-contrib-dmd: dmd feedback as you type

Bastiaan Veelo Bastiaan at Veelo.net
Wed Nov 29 09:59:58 UTC 2017


On Tuesday, 28 November 2017 at 18:07:35 UTC, Manuel Maier wrote:
> On Monday, 27 November 2017 at 11:26:51 UTC, Bastiaan Veelo 
> wrote:
>> On Sunday, 26 November 2017 at 10:15:05 UTC, Manuel Maier 
>> wrote:
>>> Have you considered invoking dub instead of dmd if there's a 
>>> dub.json/.sdl file? I imagine when people use 
>>> "preBuildCommands" to generate code, for example, the linter 
>>> might report false positives. Same goes for custom D versions 
>>> (e.g. `version(Have_foo) { ... }`).
>>
>> No I haven't considered using dub. Does dub allow the 
>> processing of a single file from the project without 
>> generating code? Note that you don't want to build the whole 
>> project upon every activation of the linter, because of speed 
>> but also because of errors that do not apply to the file in 
>> the current view.
>
> Not sure about that, would need some investigating. From what I 
> can tell, dub docs have improved quite a bit in the past year.

I had a look, and I don't think it does support this.

>>> There's also the --single feature of dub: 
>>> https://code.dlang.org/advanced_usage Such files may not work 
>>> correctly with this linter at this time I presume.
>>
>> I don't see why not?
>
> Sorry, let me rephrase. What I meant is that, with dub, you can 
> add dependencies (e.g. some http library) and define D 
> versions. So even tho it's only a single file, the invocation 
> of dmd alone is not sufficient to understand the code 
> completely.

Then I guess "dub describe" would report that dependency. We 
could add support for that, when a file starts with a dub 
shebang. The plugin does not detect versions from dub yet, but I 
am not sure it needs to. IIANM then the code inside version() 
blocks is required to be syntactically correct, and it could well 
be that dmd will bark at syntax errors inside version blocks even 
when they are not selected. Possibly some errors relating to 
symbol resolution and mixins may still go undetected though.

If there are multiple versions, you would ultimately want to lint 
all available ones? This can become a bit hairy.

> I guess it would be most useful if I created some test cases 
> and documented them.

Yes.

>>> All in all they way this plugin works is a great idea! The 
>>> more it knows about the full commandline of the resulting dmd 
>>> invocation, the more accurate it is.
>>
>> If you have a case where it isn't sufficient, I am interested 
>> to see how it can be improved. You can experiment with it as 
>> explained here: 
>> https://forum.dlang.org/post/zugbovfvfviapcjqdhxw@forum.dlang.org
>
> Haven't experimented with it yet so it's all just speculation 
> so far. I'm quite interested in a dub linter. As far as I can 
> tell from a first glance at your plugin code, it doesn't seem 
> too complicated.

You are right, and starting a new linter is easy as well, and 
well documented:
http://sublimelinter.readthedocs.io/en/latest/creating_a_linter.html

> I think I will investigate whether dub is suitable for this 
> endeavor and implement that aspect of the plugin myself. If I 
> have enough time in the coming days, of course. Will keep you 
> posted!

Have fun,
Bastiaan.


More information about the Digitalmars-d-announce mailing list