1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.internal.transformation.macro; |
21 |
|
|
22 |
|
import java.util.Arrays; |
23 |
|
import java.util.List; |
24 |
|
|
25 |
|
import javax.inject.Named; |
26 |
|
import javax.inject.Singleton; |
27 |
|
|
28 |
|
import org.xwiki.component.annotation.Component; |
29 |
|
import org.xwiki.rendering.block.Block; |
30 |
|
import org.xwiki.rendering.block.ParagraphBlock; |
31 |
|
import org.xwiki.rendering.block.WordBlock; |
32 |
|
import org.xwiki.rendering.block.match.ClassBlockMatcher; |
33 |
|
import org.xwiki.rendering.macro.AbstractNoParameterMacro; |
34 |
|
import org.xwiki.rendering.macro.MacroExecutionException; |
35 |
|
import org.xwiki.rendering.transformation.MacroTransformationContext; |
36 |
|
|
37 |
|
@Component |
38 |
|
@Named("testsimpleinlinemacro") |
39 |
|
@Singleton |
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 4 |
Complexity Density: 0.8 |
|
40 |
|
public class TestSimpleInlineMacro extends AbstractNoParameterMacro |
41 |
|
{ |
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
42 |
8 |
public TestSimpleInlineMacro()... |
43 |
|
{ |
44 |
8 |
super("Simple Inline Macro"); |
45 |
|
} |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
47 |
5 |
@Override... |
48 |
|
public boolean supportsInlineMode() |
49 |
|
{ |
50 |
5 |
return true; |
51 |
|
} |
52 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
53 |
10 |
@Override... |
54 |
|
public List<Block> execute(Object parameters, String content, MacroTransformationContext context) |
55 |
|
throws MacroExecutionException |
56 |
|
{ |
57 |
10 |
int wordCount = context.getXDOM().getBlocks( |
58 |
|
new ClassBlockMatcher(WordBlock.class), Block.Axes.DESCENDANT).size(); |
59 |
|
|
60 |
10 |
List<Block> result = Arrays.<Block>asList(new WordBlock("simpleinlinemacro" + wordCount)); |
61 |
10 |
return context.isInline() ? result : Arrays.<Block>asList(new ParagraphBlock(result)); |
62 |
|
} |
63 |
|
} |