1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
package org.xwiki.rendering.wikimodel.confluence; |
21 |
|
|
22 |
|
import java.io.Reader; |
23 |
|
import java.io.StringReader; |
24 |
|
import java.util.ArrayDeque; |
25 |
|
import java.util.Deque; |
26 |
|
|
27 |
|
import org.xwiki.rendering.wikimodel.CompositeListener; |
28 |
|
import org.xwiki.rendering.wikimodel.IWemListener; |
29 |
|
import org.xwiki.rendering.wikimodel.WikiParameters; |
30 |
|
import org.xwiki.rendering.wikimodel.WikiParserException; |
31 |
|
|
32 |
|
|
33 |
|
|
34 |
|
|
35 |
|
|
36 |
|
|
37 |
|
@version |
38 |
|
@since |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
40 |
|
public class ConfluenceExtendedWikiParser extends ConfluenceWikiParser |
41 |
|
{ |
|
|
| 55.7% |
Uncovered Elements: 31 (70) |
Complexity: 23 |
Complexity Density: 0.61 |
|
42 |
|
public static class EnhancedListener extends CompositeListener |
43 |
|
{ |
44 |
|
private Deque<Boolean> fSkipDocument = new ArrayDeque<Boolean>(); |
45 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
46 |
5 |
public EnhancedListener(IWemListener... listeners)... |
47 |
|
{ |
48 |
5 |
super(listeners); |
49 |
|
} |
50 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
51 |
5 |
@Override... |
52 |
|
public void beginDocument(WikiParameters params) |
53 |
|
{ |
54 |
5 |
if (!skipDocument()) { |
55 |
5 |
super.beginDocument(params); |
56 |
|
} |
57 |
|
} |
58 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
59 |
7 |
@Override... |
60 |
|
public void beginSection( |
61 |
|
int docLevel, |
62 |
|
int headerLevel, |
63 |
|
WikiParameters params) |
64 |
|
{ |
65 |
7 |
if (!skipDocument()) { |
66 |
7 |
super.beginSection(docLevel, headerLevel, params); |
67 |
|
} |
68 |
|
} |
69 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
70 |
7 |
@Override... |
71 |
|
public void beginSectionContent( |
72 |
|
int docLevel, |
73 |
|
int headerLevel, |
74 |
|
WikiParameters params) |
75 |
|
{ |
76 |
7 |
if (!skipDocument()) { |
77 |
7 |
super.beginSectionContent(docLevel, headerLevel, params); |
78 |
|
} |
79 |
7 |
push(false); |
80 |
|
} |
81 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
82 |
5 |
@Override... |
83 |
|
public void endDocument(WikiParameters params) |
84 |
|
{ |
85 |
5 |
if (!skipDocument()) { |
86 |
5 |
super.endDocument(params); |
87 |
|
} |
88 |
|
} |
89 |
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
90 |
7 |
@Override... |
91 |
|
public void endSection( |
92 |
|
int docLevel, |
93 |
|
int headerLevel, |
94 |
|
WikiParameters params) |
95 |
|
{ |
96 |
7 |
if (!skipDocument()) { |
97 |
7 |
super.endSection(docLevel, headerLevel, params); |
98 |
|
} |
99 |
|
} |
100 |
|
|
|
|
| 80% |
Uncovered Elements: 1 (5) |
Complexity: 2 |
Complexity Density: 0.67 |
|
101 |
7 |
@Override... |
102 |
|
public void endSectionContent( |
103 |
|
int docLevel, |
104 |
|
int headerLevel, |
105 |
|
WikiParameters params) |
106 |
|
{ |
107 |
7 |
pop(); |
108 |
7 |
if (!skipDocument()) { |
109 |
7 |
super.endSectionContent(docLevel, headerLevel, params); |
110 |
|
} |
111 |
|
} |
112 |
|
|
|
|
| 0% |
Uncovered Elements: 16 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
113 |
0 |
@Override... |
114 |
|
public void onMacroBlock( |
115 |
|
String macroName, |
116 |
|
WikiParameters params, |
117 |
|
String content) |
118 |
|
{ |
119 |
0 |
String type = null; |
120 |
0 |
if ("note".equals(macroName)) { |
121 |
0 |
type = "N"; |
122 |
0 |
} else if ("tip".equals(macroName)) { |
123 |
0 |
type = "T"; |
124 |
|
} |
125 |
0 |
if (type != null) { |
126 |
0 |
beginInfoBlock(type, params); |
127 |
0 |
parseContent(content); |
128 |
0 |
endInfoBlock(type, params); |
129 |
|
} else { |
130 |
0 |
super.onMacroBlock(macroName, params, content); |
131 |
|
} |
132 |
|
} |
133 |
|
|
134 |
|
|
135 |
|
@param |
136 |
|
@throws |
137 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.29 |
|
138 |
0 |
private void parseContent(String content)... |
139 |
|
{ |
140 |
0 |
try { |
141 |
0 |
push(true); |
142 |
0 |
StringReader reader = new StringReader(content); |
143 |
0 |
ConfluenceWikiParser parser = new ConfluenceWikiParser(); |
144 |
0 |
parser.parse(reader, this); |
145 |
0 |
pop(); |
146 |
|
} catch (WikiParserException e) { |
147 |
0 |
throw new RuntimeException(e); |
148 |
|
} |
149 |
|
} |
150 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
151 |
7 |
private void pop()... |
152 |
|
{ |
153 |
7 |
fSkipDocument.pop(); |
154 |
|
} |
155 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
156 |
7 |
private void push(boolean b)... |
157 |
|
{ |
158 |
7 |
fSkipDocument.push(b); |
159 |
|
} |
160 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 2 |
Complexity Density: 0.5 |
|
161 |
38 |
private boolean skipDocument()... |
162 |
|
{ |
163 |
38 |
if (fSkipDocument.isEmpty()) { |
164 |
30 |
return false; |
165 |
|
} |
166 |
8 |
Boolean peek = fSkipDocument.peek(); |
167 |
8 |
return peek; |
168 |
|
} |
169 |
|
} |
170 |
|
|
171 |
|
|
172 |
|
|
173 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
174 |
5 |
public ConfluenceExtendedWikiParser()... |
175 |
|
{ |
176 |
5 |
super(); |
177 |
|
} |
178 |
|
|
179 |
|
|
180 |
|
@see |
181 |
|
|
182 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
183 |
5 |
@Override... |
184 |
|
public void parse(Reader reader, IWemListener listener) |
185 |
|
throws WikiParserException |
186 |
|
{ |
187 |
5 |
IWemListener composite = new EnhancedListener(listener); |
188 |
5 |
super.parse(reader, composite); |
189 |
|
} |
190 |
|
} |