vtst / ow

Various Eclipse plugins for web development
http://www.normalesup.org/~simonet/soft/
74 stars 29 forks source link

Less: import statement #131

Closed FagnerMartinsBrack closed 11 years ago

FagnerMartinsBrack commented 11 years ago

main.less

@import "mixins.less";
@import "wells.less";

mixins.less:

.box-shadow( @shadow ) {
  -webkit-box-shadow: @shadow;
     -moz-box-shadow: @shadow;
          box-shadow: @shadow;
}

wells.less:

.well {
  .box-shadow( inset 0 1px 1px rgba( 0, 0, 0, .05 ) );
}

outputs (when compiling bootstrap.less):

.well {
  -webkit-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
  -moz-box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, 0.05);
}

An error is thrown into the line of the well.less file and should not The mixin '.box-shadow' is undefined in this context.. I can arrange a project for you if you are not able to reproduce this.

vtst commented 11 years ago

This is a problem which is unfortunately difficult to solve in an IDE. Indeed, one cannot check the file "wells.less" by itself, as it may be correct or not, depending on which file it is included. You could have another main2.less somewhere in your project (or somewhere else) that imports wells.less without importing mixins.less.

Requiring explicit imports sounds like a good programming practice. I think also this is one of the reason for the change of the semantics of the import statements ("import once") in the LESS compiler.

FagnerMartinsBrack commented 11 years ago

But if I use the import somewhere my code will be repeatedly generated. Is there any solution for this? It is completely unusable without such feature. Maybe create an option to disable any import verification.

You could use Intellij IDEA as example for this implementation. I do not use it, but ppl said they have a good less syntax highlight and validation.

I am really sad for the lack of support Eclipse itself has with less language. I hope it changes in the future =(

FagnerMartinsBrack commented 11 years ago

This is really important. I have no idea of workaround using the current implementation of less and the plugin =/

FagnerMartinsBrack commented 11 years ago

The thing is the following also happens in the same situation: `Couldn't resolve reference to VariableCrossReference '@headings-color'. type.less

vtst commented 11 years ago

Can you send me a link to the code of the project you are working on, so that I can see if I have a solution for it?

FagnerMartinsBrack commented 11 years ago

Ok I messed around and solved it with @import-once in all files. But the thing is I can't use a single import in a main file. That's a problem, but at least is not a blocker one.

vtst commented 11 years ago

You can now disable error messages on undefined mixins and variables thanks to #135.

FagnerMartinsBrack commented 11 years ago

Thanks man, appreciated that ;)