1. Project Clover database Tue Dec 20 2016 21:24:09 CET
  2. Package org.xwiki.lesscss.internal.compiler

File DefaultLESSCompiler.java

 

Coverage histogram

../../../../../img/srcFileCovDistChart10.png
0% of files have more coverage

Code metrics

0
8
5
1
89
53
5
0.62
1.6
5
1

Classes

Class Line # Actions
DefaultLESSCompiler 46 8 0% 5 0
1.0100%
 

Contributing tests

This file is covered by 6 tests. .

Source view

1    /*
2    * See the NOTICE file distributed with this work for additional
3    * information regarding copyright ownership.
4    *
5    * This is free software; you can redistribute it and/or modify it
6    * under the terms of the GNU Lesser General Public License as
7    * published by the Free Software Foundation; either version 2.1 of
8    * the License, or (at your option) any later version.
9    *
10    * This software is distributed in the hope that it will be useful,
11    * but WITHOUT ANY WARRANTY; without even the implied warranty of
12    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13    * Lesser General Public License for more details.
14    *
15    * You should have received a copy of the GNU Lesser General Public
16    * License along with this software; if not, write to the Free
17    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
19    */
20    package org.xwiki.lesscss.internal.compiler;
21   
22    import java.io.PrintWriter;
23    import java.io.StringWriter;
24   
25    import javax.inject.Inject;
26    import javax.inject.Singleton;
27   
28    import org.xwiki.component.annotation.Component;
29    import org.xwiki.component.phase.Initializable;
30    import org.xwiki.component.phase.InitializationException;
31    import org.xwiki.lesscss.internal.cache.LESSResourcesCache;
32    import org.xwiki.lesscss.compiler.LESSCompiler;
33    import org.xwiki.lesscss.compiler.LESSCompilerException;
34    import org.xwiki.lesscss.internal.cache.AbstractCachedCompiler;
35    import org.xwiki.lesscss.resources.LESSResourceReference;
36   
37    /**
38    * Default implementation for {@link org.xwiki.lesscss.compiler.LESSCompiler}. It uses the CachedIntegratedLESSCompiler
39    * through the AbstractCachedCompiler to cache the result of the compilation.
40    *
41    * @since 6.4M2
42    * @version $Id: 25401458f7bc13a5afa2b415ea83122064f4a36e $
43    */
44    @Component
45    @Singleton
 
46    public class DefaultLESSCompiler extends AbstractCachedCompiler<String> implements LESSCompiler,
47    Initializable
48    {
49    @Inject
50    private LESSResourcesCache cache;
51   
52    @Inject
53    private CachedLESSCompiler cachedLESSCompiler;
54   
 
55  35 toggle @Override
56    public void initialize() throws InitializationException
57    {
58  35 super.cache = cache;
59  35 super.compiler = cachedLESSCompiler;
60    }
61   
 
62  54 toggle @Override
63    public String compile(LESSResourceReference lessResourceReference, boolean includeSkinStyle, boolean useVelocity,
64    boolean force) throws LESSCompilerException
65    {
66  54 return super.getResult(lessResourceReference, includeSkinStyle, useVelocity, force);
67    }
68   
 
69  36 toggle @Override
70    public String compile(LESSResourceReference lessResourceReference, boolean includeSkinStyle, boolean useVelocity,
71    String skin, boolean force) throws LESSCompilerException
72    {
73  36 return super.getResult(lessResourceReference, includeSkinStyle, useVelocity, skin, force);
74    }
75   
 
76  89 toggle @Override
77    protected String cloneResult(String toClone)
78    {
79  89 return new String(toClone);
80    }
81   
 
82  1 toggle @Override
83    protected String exceptionAsResult(LESSCompilerException exception)
84    {
85  1 StringWriter serializedException = new StringWriter();
86  1 exception.printStackTrace(new PrintWriter(serializedException));
87  1 return String.format("/* %s */", serializedException.toString());
88    }
89    }