1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
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 |
|
@link |
39 |
|
|
40 |
|
|
41 |
|
@since |
42 |
|
@version |
43 |
|
|
44 |
|
@Component |
45 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 5 |
Complexity Density: 0.62 |
|
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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
55 |
35 |
@Override... |
56 |
|
public void initialize() throws InitializationException |
57 |
|
{ |
58 |
35 |
super.cache = cache; |
59 |
35 |
super.compiler = cachedLESSCompiler; |
60 |
|
} |
61 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
62 |
54 |
@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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
69 |
36 |
@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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
76 |
89 |
@Override... |
77 |
|
protected String cloneResult(String toClone) |
78 |
|
{ |
79 |
89 |
return new String(toClone); |
80 |
|
} |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
82 |
1 |
@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 |
|
} |