lesscss-java icon indicating copy to clipboard operation
lesscss-java copied to clipboard

LessSource.getImports() only returns imports with type (css), (less) or none set

Open JanThiel opened this issue 11 years ago • 0 comments

Hi,

I use the LessSource.getImports method to build up a dependency tree of Less files. Now I switched from Less 1.3.3

@import mixins.less

to Less 1.7

@import (reference) mixins.less

Sadly after this change those imports are not being recognized as Imports anymore. This is due to the Regex Pattern defined in LessSource.java#45

    /**
     * The <code>Pattern</code> used to match imported files.
     */
    private static final Pattern IMPORT_PATTERN = Pattern.compile("^(?!\\s*//\\s*).*(@import\\s+(url\\(|\\((less|css)\\))?\\s*(\"|')(.+)\\s*(\"|')(\\))?(.*);).*$", MULTILINE);

There are to possibilities to solve this.

  1. Add the missing import directives (reference, inline, once)
  2. Add another function, that returns all "non standard" Imports (which would be: reference, inline, multiple). Anyway "once" would be still missing in the regular .getImports.

Personally, I would go for option 1, as it is - what I believe - is expected behaviour. An import is an import and should therefore be returned. Anyway you should then account for the "multiple" directive and only return the file once in the Map.

Brgds

Jan

JanThiel avatar Sep 09 '14 11:09 JanThiel