Package com.github.sommeri.less4j

Examples of com.github.sommeri.less4j.LessSource


    private BytestreamCache invokeLessCompiler(Resource source, ResourceDependencies dependencies) throws IOException
    {
        try
        {
            LessSource lessSource = new ResourceLessSource(source, dependencies);

            LessCompiler.CompilationResult compilationResult = compile(compiler, lessSource);

            // Currently, ignoring any warnings.
View Full Code Here


    private BytestreamCache invokeLessCompiler(Resource source, ResourceDependencies dependencies) throws IOException
    {
        try
        {
            LessSource lessSource = new ResourceLessSource(source, dependencies);

            LessCompiler.CompilationResult compilationResult = compiler.compile(lessSource);

            // Currently, ignoring any warnings.
View Full Code Here

        this.scopeClass = scopeClass;
    }

    @Override
    public LessSource relativeSource(String filename) throws FileNotFound, CannotReadFile {
        final LessSource relative;
        boolean addParent = true;

        if (StringUtils.startsWith(filename, WEBJARS_SCHEME)) {
            relative = resolveWebJarsDependency(filename);
        } else if (StringUtils.startsWith(filename, CLASSPATH_SCHEME)) {
View Full Code Here

      List<LessCompiler.Problem> errors = e.getErrors();
      ArrayList<Message> messages = new ArrayList<Message>(errors.size());
      for (LessCompiler.Problem error : errors) {
        String text = error.getMessage() != null ? error.getMessage() : "There is an error in your .less file";
        String errorName = error.getType().name();
        LessSource source = error.getSource();
        Message msg;
        if (source != null) {
          msg = new Message(MetaModelPluginImpl.COMPILATION_ERROR, errorName, source.getName(), error.getLine(), text);
        } else {
          msg = new Message(MetaModelPluginImpl.GENERAL_PROBLEM, errorName, text);
        }
        MetaModelPluginImpl.log.info(msg.toDisplayString());
        messages.add(msg);
View Full Code Here

  private void inheritCommentsFromToken(ASTCssNode node) {
    HiddenTokenAwareTree underlyingStructure = node.getUnderlyingStructure();
    if (underlyingStructure==null)
      return ;
   
    LessSource source = underlyingStructure.getSource();
    List<Comment> preceding = convertToComments(underlyingStructure.getPreceding(), source);
    node.setOpeningComments(preceding);

    List<Comment> following = convertToComments(underlyingStructure.getFollowing(), source);
    node.setTrailingComments(following);
View Full Code Here

    String fragments = filenameParts.length > 1 ? "#" + filenameParts[1] : "";

    if (mimetype==null)
      mimetype = guessMimetype(filename);

    LessSource source = token.getSource();
    try {
      LessSource dataSource = source.relativeSource(filename);
      byte[] data = dataSource.getBytes();

      // **** less.js comment - flag is not implemented yet ****
      // IE8 cannot handle a data-uri larger than 32KB. If this is exceeded
      // and the --ieCompat flag is enabled, return a normal url() instead.
      int fileSizeInKB = data.length / 1024;
View Full Code Here

    // FIXME ! they should be relativized
    if (treatAsCss(node, filename))
      return null;

    filename = addLessSuffixIfNeeded(filename, urlParams);
    LessSource importedSource;
    try {
      importedSource = source.relativeSource(filename);
    } catch (FileNotFound ex) {
      problemsHandler.errorFileNotFound(node, filename);
      return null;
    } catch (CannotReadFile e) {
      problemsHandler.errorFileCanNotBeRead(node, filename);
      return null;
    } catch (StringSourceException ex) {
      // imports are relative to current file and we do not know its location
      problemsHandler.warnLessImportNoBaseDirectory(node.getUrlExpression());
      return null;
    }

    // import once should not import a file that was already imported
    if (isImportOnce(node) && alreadyVisited(importedSource)) {
      astManipulator.removeFromBody(node);
      return null;
    }
    importedSources.add(importedSource);

    String importedContent;
    try {
      importedContent = importedSource.getContent();
    } catch (FileNotFound e) {
      problemsHandler.errorFileNotFound(node, filename);
      return null;
    } catch (CannotReadFile e) {
      problemsHandler.errorFileCanNotBeRead(node, filename);
View Full Code Here

    FilePosition result = new FilePosition(underlyingStructure.getLine() - 1, underlyingStructure.getCharPositionInLine());
    return result;
  }

  private String toSourceName(HiddenTokenAwareTree underlyingStructure) {
    LessSource source = underlyingStructure.getSource();
    return toSourceName(source);
  }
View Full Code Here

      return source.getURI() == null ? null : source.getURI().toString();
    }
  }

  private String toSourceContent(HiddenTokenAwareTree underlyingStructure, String sourceName) {
    LessSource source = underlyingStructure.getSource();
    return toSourceContent(underlyingStructure, sourceName, source);
  }
View Full Code Here

    }
    return result;
  }

  private CompilationResult createCompilationResult(ASTCssNode cssStyleSheet, LessSource lessSource, Collection<LessSource> additionalSourceFiles, Configuration options) {
    LessSource cssDestination = options == null ? null : options.getCssResultLocation();
    if (cssDestination==null) {
      String guessedCssName = URIUtils.changeSuffix(lessSource.getName(), Constants.CSS_SUFFIX);
      URI guessedURI = URIUtils.changeSuffix(lessSource.getURI(), Constants.CSS_SUFFIX);
      cssDestination = new LessSource.StringSource("", guessedCssName, guessedURI);
    }
View Full Code Here

TOP

Related Classes of com.github.sommeri.less4j.LessSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.