Skip to content

Commit 7e7182b

Browse files
committed
Modifying VF tokenizer test content to keep up with the minor grammar change
Streamlined IDENTIFIED_DOTTED logic. Added a couple more negative tests
1 parent 5ea116f commit 7e7182b

File tree

3 files changed

+71
-39
lines changed

3 files changed

+71
-39
lines changed

pmd-visualforce/etc/grammar/VfParser.jjt

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ PARSER_END(VfParser)
6767
| <#ALPHANUM_CHAR: ( <ALPHA_CHAR> | <NUM_CHAR> ) >
6868
| <#IDENTIFIER_CHAR: ( <ALPHANUM_CHAR> | [ "_", "-", ":" ] ) >
6969
| <#IDENTIFIER: <ALPHA_CHAR> (<IDENTIFIER_CHAR>)* >
70-
| <#IDENTIFIER_DOTTED: <IDENTIFIER> (<DOT> <IDENTIFIER>)* >
70+
| <#IDENTIFIER_DOTTED: <IDENTIFIER> (<DOT> <IDENTIFIER>)+ >
7171
| <#XMLNAME: (<ALPHA_CHAR> | "_" | ":") (<IDENTIFIER_CHAR>)* >
7272
| <#QUOTED_STRING_NO_BREAKS: ( "'" ( ~["'", "\r", "\n"] )* "'" )
7373
| ( "\"" ( ~["\"", "\r", "\n"] )* "\"" ) >
@@ -217,7 +217,7 @@ PARSER_END(VfParser)
217217

218218
<InTagState> TOKEN :
219219
{
220-
<ATTR_NAME: <IDENTIFIER_DOTTED> >
220+
<ATTR_NAME: <IDENTIFIER> | <IDENTIFIER_DOTTED> >
221221
| <TAG_END: ">" > : AfterTagState
222222
| <DECL_END: ("?>" | "!>") > : AfterTagState
223223
| <TAG_SLASHEND: ("/>" | "/ >") > : AfterTagState

pmd-visualforce/src/test/java/net/sourceforge/pmd/lang/vf/ast/VfParserTest.java

+32
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
import org.junit.Test;
88

9+
import net.sourceforge.pmd.lang.ast.ParseException;
10+
911
/**
1012
* @author sergey.gorbaty
1113
*/
@@ -31,4 +33,34 @@ public void testAttributeNameWithDot() {
3133
vf.parse("<table-row keep-together.within-page=\"always\" >");
3234
}
3335

36+
@Test
37+
public void testAttributeNameWithUnderscore() {
38+
vf.parse("<table-row test_attribute=\"always\" >");
39+
}
40+
41+
@Test
42+
public void testAttributeNameWithColon() {
43+
vf.parse("<table-row test:attribute=\"always\" >");
44+
}
45+
46+
@Test(expected = ParseException.class)
47+
public void testAttributeNameWithInvalidSymbol() {
48+
vf.parse("<table-row test&attribute=\"always\" >");
49+
}
50+
51+
@Test(expected = ParseException.class)
52+
public void testAttributeNameWithInvalidDot() {
53+
vf.parse("<table-row .class=\"always\" >");
54+
}
55+
56+
@Test(expected = ParseException.class)
57+
public void testAttributeNameWithInvalidDotV2() {
58+
vf.parse("<table-row test..attribute=\"always\" >");
59+
}
60+
61+
@Test(expected = ParseException.class)
62+
public void testAttributeNameWithInvalidDotV3() {
63+
vf.parse("<table-row test.attribute.=\"always\" >");
64+
}
65+
3466
}
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
11
[Image] or [Truncated image[ Bcol Ecol
22
L1
3-
[24] 1 1
4-
[85] 2 10
5-
[88] 11 11
3+
[25] 1 1
4+
[86] 2 10
5+
[89] 11 11
66
L2
7-
[24] 2 2
8-
[85] 3 6
9-
[87] 8 10
10-
[91] 11 11
11-
[94] 12 12
12-
[105] 13 22
13-
[103] 23 23
14-
[87] 25 28
15-
[91] 29 29
16-
[94] 30 30
17-
[105] 31 38
18-
[103] 39 39
19-
[87] 41 44
20-
[91] 45 45
21-
[94] 46 46
22-
[104] 47 48
23-
[66] 49 57
24-
[41] 58 58
25-
[66] 59 67
26-
[73] 68 68
27-
[105] 69 69
28-
[104] 70 71
29-
[66] 72 81
30-
[73] 82 82
31-
[103] 83 83
32-
[87] 85 86
33-
[91] 87 87
34-
[94] 88 88
35-
[105] 89 99
36-
[103] 100 100
37-
[90] 101 102
7+
[25] 2 2
8+
[86] 3 6
9+
[88] 8 10
10+
[92] 11 11
11+
[95] 12 12
12+
[106] 13 22
13+
[104] 23 23
14+
[88] 25 28
15+
[92] 29 29
16+
[95] 30 30
17+
[106] 31 38
18+
[104] 39 39
19+
[88] 41 44
20+
[92] 45 45
21+
[95] 46 46
22+
[105] 47 48
23+
[67] 49 57
24+
[42] 58 58
25+
[67] 59 67
26+
[74] 68 68
27+
[106] 69 69
28+
[105] 70 71
29+
[67] 72 81
30+
[74] 82 82
31+
[104] 83 83
32+
[88] 85 86
33+
[92] 87 87
34+
[95] 88 88
35+
[106] 89 99
36+
[104] 100 100
37+
[91] 101 102
3838
L3
39-
[25] 1 2
40-
[85] 3 11
41-
[88] 12 12
39+
[26] 1 2
40+
[86] 3 11
41+
[89] 12 12
4242
EOF

0 commit comments

Comments
 (0)