| 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.util.Stack; |
| 23 |
|
|
| 24 |
|
import org.xwiki.rendering.wikimodel.IWemListener; |
| 25 |
|
import org.xwiki.rendering.wikimodel.WikiParameters; |
| 26 |
|
import org.xwiki.rendering.wikimodel.impl.InternalWikiScannerContext; |
| 27 |
|
import org.xwiki.rendering.wikimodel.util.IListListener; |
| 28 |
|
import org.xwiki.rendering.wikimodel.util.ListBuilder; |
| 29 |
|
import org.xwiki.rendering.wikimodel.util.SectionBuilder; |
| 30 |
|
|
| 31 |
|
|
| 32 |
|
@version |
| 33 |
|
@since |
| 34 |
|
|
|
|
|
| 75.2% |
Uncovered Elements: 28 (113) |
Complexity: 28 |
Complexity Density: 0.36 |
|
| 35 |
|
public class ConfluenceInternalWikiScannerContext extends |
| 36 |
|
InternalWikiScannerContext |
| 37 |
|
{ |
| 38 |
|
private int fPreBlockType = IBlockTypes.NONE; |
| 39 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 40 |
562
|
public ConfluenceInternalWikiScannerContext(... |
| 41 |
|
SectionBuilder<WikiParameters> sectionBuilder, IWemListener listener) |
| 42 |
|
{ |
| 43 |
562
|
super(sectionBuilder, listener); |
| 44 |
|
} |
| 45 |
|
|
| 46 |
|
|
| 47 |
|
@inheritDoc |
| 48 |
|
|
| 49 |
|
|
| 50 |
|
|
| 51 |
|
@see |
| 52 |
|
|
| 53 |
|
|
|
|
|
| 85.7% |
Uncovered Elements: 1 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 54 |
21
|
@Override... |
| 55 |
|
public void onTableCell(boolean head, WikiParameters params) |
| 56 |
|
{ |
| 57 |
21
|
checkStyleOpened(); |
| 58 |
21
|
checkListOpened(); |
| 59 |
21
|
endTableCell(); |
| 60 |
21
|
fTableHead = head; |
| 61 |
21
|
fTableCellParams = params != null ? params : WikiParameters.EMPTY; |
| 62 |
|
|
| 63 |
|
|
| 64 |
|
|
| 65 |
|
|
| 66 |
|
} |
| 67 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 4 |
Complexity Density: 0.4 |
|
| 68 |
48
|
@Override... |
| 69 |
|
public void beginList() |
| 70 |
|
{ |
| 71 |
48
|
if ((fBlockType & IBlockTypes.LIST) != IBlockTypes.LIST) { |
| 72 |
16
|
if (!isInTable()) { |
| 73 |
12
|
closeBlock(); |
| 74 |
|
} else { |
| 75 |
4
|
checkStyleOpened(); |
| 76 |
4
|
fPreBlockType = fBlockType; |
| 77 |
|
} |
| 78 |
16
|
if (fListParams == null) { |
| 79 |
14
|
fListParams = WikiParameters.EMPTY; |
| 80 |
|
} |
| 81 |
16
|
IListListener listener = new IListListener() |
| 82 |
|
{ |
| 83 |
|
private Stack<WikiParameters> fListParamsStack = new Stack<WikiParameters>(); |
| 84 |
|
|
|
|
|
| 53.8% |
Uncovered Elements: 6 (13) |
Complexity: 3 |
Complexity Density: 0.33 |
|
| 85 |
40
|
public void beginRow(char treeType, char rowType)... |
| 86 |
|
{ |
| 87 |
40
|
if (rowType == ':') { |
| 88 |
0
|
fBlockType = IBlockTypes.LIST_DL_DD; |
| 89 |
0
|
fListener.beginDefinitionDescription(); |
| 90 |
40
|
} else if (rowType == ';') { |
| 91 |
0
|
fBlockType = IBlockTypes.LIST_DL_DT; |
| 92 |
0
|
fListener.beginDefinitionTerm(); |
| 93 |
|
} else { |
| 94 |
40
|
fBlockType = IBlockTypes.LIST_LI; |
| 95 |
40
|
fListener.beginListItem(); |
| 96 |
|
} |
| 97 |
40
|
beginStyleContainer(); |
| 98 |
|
} |
| 99 |
|
|
|
|
|
| 75% |
Uncovered Elements: 4 (16) |
Complexity: 3 |
Complexity Density: 0.19 |
|
| 100 |
32
|
public void beginTree(char type)... |
| 101 |
|
{ |
| 102 |
32
|
fListParamsStack.push(fListParams); |
| 103 |
|
|
| 104 |
32
|
closeFormat(); |
| 105 |
32
|
switch (type) { |
| 106 |
8
|
case '#': |
| 107 |
8
|
fListener.beginList(fListParams, true); |
| 108 |
8
|
fBlockType = IBlockTypes.LIST; |
| 109 |
8
|
break; |
| 110 |
0
|
case 'd': |
| 111 |
0
|
fListener.beginDefinitionList(fListParams); |
| 112 |
0
|
fBlockType = IBlockTypes.LIST_DL; |
| 113 |
0
|
break; |
| 114 |
24
|
default: |
| 115 |
24
|
fListener.beginList(fListParams, false); |
| 116 |
24
|
fBlockType = IBlockTypes.LIST; |
| 117 |
24
|
break; |
| 118 |
|
} |
| 119 |
|
|
| 120 |
32
|
fListParams = WikiParameters.EMPTY; |
| 121 |
|
} |
| 122 |
|
|
|
|
|
| 44.4% |
Uncovered Elements: 10 (18) |
Complexity: 4 |
Complexity Density: 0.33 |
|
| 123 |
40
|
public void endRow(char treeType, char rowType)... |
| 124 |
|
{ |
| 125 |
40
|
closeFormat(); |
| 126 |
40
|
endStyleContainer(); |
| 127 |
40
|
if (rowType == ':') { |
| 128 |
0
|
fListener.endDefinitionDescription(); |
| 129 |
0
|
fBlockType = IBlockTypes.LIST_DL; |
| 130 |
40
|
} else if (rowType == ';') { |
| 131 |
0
|
if ((fBlockType & IBlockTypes.LIST_DL_DT) == IBlockTypes.LIST_DL_DT) { |
| 132 |
0
|
fListener.endDefinitionTerm(); |
| 133 |
|
} else { |
| 134 |
0
|
fListener.endDefinitionDescription(); |
| 135 |
|
} |
| 136 |
0
|
fBlockType = IBlockTypes.LIST_DL; |
| 137 |
|
} else { |
| 138 |
40
|
fListener.endListItem(); |
| 139 |
40
|
fBlockType = IBlockTypes.LIST; |
| 140 |
|
} |
| 141 |
|
} |
| 142 |
|
|
|
|
|
| 71.4% |
Uncovered Elements: 4 (14) |
Complexity: 3 |
Complexity Density: 0.21 |
|
| 143 |
32
|
public void endTree(char type)... |
| 144 |
|
{ |
| 145 |
32
|
switch (type) { |
| 146 |
8
|
case '#': |
| 147 |
8
|
fListener.endList(fListParamsStack.peek(), true); |
| 148 |
8
|
fBlockType = IBlockTypes.LIST; |
| 149 |
8
|
break; |
| 150 |
0
|
case 'd': |
| 151 |
0
|
fListener |
| 152 |
|
.endDefinitionList(fListParamsStack.peek()); |
| 153 |
0
|
fBlockType = IBlockTypes.LIST; |
| 154 |
0
|
break; |
| 155 |
24
|
default: |
| 156 |
24
|
fListener.endList(fListParamsStack.peek(), false); |
| 157 |
24
|
fBlockType = IBlockTypes.LIST; |
| 158 |
24
|
break; |
| 159 |
|
} |
| 160 |
|
|
| 161 |
32
|
fListParamsStack.pop(); |
| 162 |
|
} |
| 163 |
|
}; |
| 164 |
16
|
fListBuilder = new ListBuilder(listener) |
| 165 |
|
{ |
|
|
|
| 60% |
Uncovered Elements: 2 (5) |
Complexity: 3 |
Complexity Density: 1 |
|
| 166 |
54
|
@Override... |
| 167 |
|
protected char getTreeType(char rowType) |
| 168 |
|
{ |
| 169 |
54
|
if (rowType == ';' || rowType == ':') { |
| 170 |
0
|
return 'd'; |
| 171 |
|
} |
| 172 |
54
|
return rowType; |
| 173 |
|
} |
| 174 |
|
}; |
| 175 |
16
|
fBlockType = IBlockTypes.LIST; |
| 176 |
|
} |
| 177 |
|
} |
| 178 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 179 |
36
|
@Override... |
| 180 |
|
public void endList() |
| 181 |
|
{ |
| 182 |
36
|
if ((fBlockType & IBlockTypes.LIST) != 0) { |
| 183 |
16
|
fListBuilder.alignContext(""); |
| 184 |
16
|
fListBuilder = null; |
| 185 |
|
|
| 186 |
16
|
fBlockType = fPreBlockType; |
| 187 |
16
|
fPreBlockType = IBlockTypes.NONE; |
| 188 |
|
} |
| 189 |
|
} |
| 190 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 191 |
43
|
public boolean isExplicitInTable()... |
| 192 |
|
{ |
| 193 |
43
|
return super.isInTable() |
| 194 |
|
|| (((fPreBlockType & IBlockTypes.TABLE) == IBlockTypes.TABLE) && |
| 195 |
|
(fBlockType & IBlockTypes.LIST) == IBlockTypes.LIST); |
| 196 |
|
} |
| 197 |
|
|
|
|
|
| 75% |
Uncovered Elements: 1 (4) |
Complexity: 2 |
Complexity Density: 1 |
|
| 198 |
21
|
private void checkListOpened()... |
| 199 |
|
{ |
| 200 |
21
|
if (isExplicitInTable()) { |
| 201 |
21
|
endList(); |
| 202 |
|
} |
| 203 |
|
} |
| 204 |
|
} |