Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2008 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2012 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 34-41
Link Here
|
34 |
*/ |
34 |
*/ |
35 |
public class JavaPairMatcherTest extends AbstractPairMatcherTest { |
35 |
public class JavaPairMatcherTest extends AbstractPairMatcherTest { |
36 |
|
36 |
|
37 |
private static boolean BEFORE_MATCHES_DISABLED= true; |
|
|
38 |
|
39 |
protected IDocument fDocument; |
37 |
protected IDocument fDocument; |
40 |
protected JavaPairMatcher fPairMatcher; |
38 |
protected JavaPairMatcher fPairMatcher; |
41 |
|
39 |
|
Lines 49-54
Link Here
|
49 |
} |
47 |
} |
50 |
|
48 |
|
51 |
protected ICharacterPairMatcher createMatcher(String chars) { |
49 |
protected ICharacterPairMatcher createMatcher(String chars) { |
|
|
50 |
setCaretInsideMatchedPair(true); |
51 |
setChars(chars); |
52 |
return new JavaPairMatcher(chars.toCharArray()); |
52 |
return new JavaPairMatcher(chars.toCharArray()); |
53 |
} |
53 |
} |
54 |
|
54 |
|
Lines 81-100
Link Here
|
81 |
|
81 |
|
82 |
public void testBeforeOpeningMatch() { |
82 |
public void testBeforeOpeningMatch() { |
83 |
IRegion match= fPairMatcher.match(fDocument, 2); |
83 |
IRegion match= fPairMatcher.match(fDocument, 2); |
84 |
if (BEFORE_MATCHES_DISABLED) { |
84 |
assertNull(match); |
85 |
assertNull(match); |
|
|
86 |
} else { |
87 |
assertNotNull(match); |
88 |
assertTrue(match.getOffset() == 2 && match.getLength() == 10); |
89 |
} |
90 |
|
85 |
|
91 |
match= fPairMatcher.match(fDocument, 5); |
86 |
match= fPairMatcher.match(fDocument, 5); |
92 |
if (BEFORE_MATCHES_DISABLED) { |
87 |
assertNull(match); |
93 |
assertNull(match); |
|
|
94 |
} else { |
95 |
assertNotNull(match); |
96 |
assertTrue(match.getOffset() == 5 && match.getLength() == 4); |
97 |
} |
98 |
} |
88 |
} |
99 |
|
89 |
|
100 |
public void testAfterOpeningMatch() { |
90 |
public void testAfterOpeningMatch() { |
Lines 109-174
Link Here
|
109 |
|
99 |
|
110 |
public void testBeforeClosingMatch() { |
100 |
public void testBeforeClosingMatch() { |
111 |
IRegion match= fPairMatcher.match(fDocument, 11); |
101 |
IRegion match= fPairMatcher.match(fDocument, 11); |
112 |
if (BEFORE_MATCHES_DISABLED) { |
102 |
assertNotNull(match); |
113 |
assertNull(match); |
103 |
assertTrue(match.getOffset() == 2 && match.getLength() == 10); |
114 |
} else { |
|
|
115 |
assertNotNull(match); |
116 |
assertTrue(match.getOffset() == 2 && match.getLength() == 10); |
117 |
} |
118 |
|
104 |
|
119 |
match= fPairMatcher.match(fDocument, 8); |
105 |
match= fPairMatcher.match(fDocument, 8); |
120 |
if (BEFORE_MATCHES_DISABLED) { |
106 |
assertNotNull(match); |
121 |
assertNull(match); |
107 |
assertTrue(match.getOffset() == 5 && match.getLength() == 4); |
122 |
} else { |
108 |
|
123 |
assertNotNull(match); |
|
|
124 |
assertTrue(match.getOffset() == 5 && match.getLength() == 4); |
125 |
} |
126 |
} |
109 |
} |
127 |
|
110 |
|
128 |
public void testAfterClosingMatch() { |
111 |
public void testAfterClosingMatch() { |
129 |
IRegion match= fPairMatcher.match(fDocument, 12); |
112 |
IRegion match= fPairMatcher.match(fDocument, 12); |
130 |
assertNotNull(match); |
113 |
assertNull(match); |
131 |
assertTrue(match.getOffset() == 2 && match.getLength() == 10); |
|
|
132 |
|
114 |
|
133 |
match= fPairMatcher.match(fDocument, 9); |
115 |
match= fPairMatcher.match(fDocument, 9); |
134 |
assertNotNull(match); |
116 |
assertNull(match); |
135 |
assertTrue(match.getOffset() == 5 && match.getLength() == 4); |
|
|
136 |
} |
117 |
} |
137 |
|
118 |
|
138 |
public void testBeforeClosingMatchWithNL() { |
119 |
public void testBeforeClosingMatchWithNL() { |
139 |
fDocument.set("x(y\ny)x"); |
120 |
fDocument.set("x(y\ny)x"); |
140 |
IRegion match= fPairMatcher.match(fDocument, 5); |
121 |
IRegion match= fPairMatcher.match(fDocument, 5); |
141 |
if (BEFORE_MATCHES_DISABLED) { |
122 |
assertNotNull(match); |
142 |
assertNull(match); |
123 |
assertTrue(match.getOffset() == 1 && match.getLength() == 5); |
143 |
} else { |
|
|
144 |
assertNotNull(match); |
145 |
assertTrue(match.getOffset() == 1 && match.getLength() == 5); |
146 |
} |
147 |
} |
124 |
} |
148 |
|
125 |
|
149 |
public void testAfterClosingMatchWithNL() { |
126 |
public void testAfterClosingMatchWithNL() { |
150 |
fDocument.set("x(y\ny)x"); |
127 |
fDocument.set("x(y\ny)x"); |
151 |
IRegion match= fPairMatcher.match(fDocument, 6); |
128 |
IRegion match= fPairMatcher.match(fDocument, 6); |
152 |
assertNotNull(match); |
129 |
assertNull(match); |
153 |
assertTrue(match.getOffset() == 1 && match.getLength() == 5); |
|
|
154 |
} |
130 |
} |
155 |
|
131 |
|
156 |
public void testBeforeClosingMatchWithNLAndSingleLineComment() { |
132 |
public void testBeforeClosingMatchWithNLAndSingleLineComment() { |
157 |
fDocument.set("x\nx(y\nx //(x\ny)x"); |
133 |
fDocument.set("x\nx(y\nx //(x\ny)x"); |
158 |
IRegion match= fPairMatcher.match(fDocument, 14); |
134 |
IRegion match= fPairMatcher.match(fDocument, 14); |
159 |
if (BEFORE_MATCHES_DISABLED) { |
135 |
assertNotNull(match); |
160 |
assertNull(match); |
136 |
assertTrue(match.getOffset() == 3 && match.getLength() == 12); |
161 |
} else { |
|
|
162 |
assertNotNull(match); |
163 |
assertTrue(match.getOffset() == 3 && match.getLength() == 12); |
164 |
} |
165 |
} |
137 |
} |
166 |
|
138 |
|
167 |
public void testAfterClosingMatchWithNLAndSingleLineComment() { |
139 |
public void testAfterClosingMatchWithNLAndSingleLineComment() { |
168 |
fDocument.set("x\nx(y\nx //(x\ny)x"); |
140 |
fDocument.set("x\nx(y\nx //(x\ny)x"); |
169 |
IRegion match= fPairMatcher.match(fDocument, 15); |
141 |
IRegion match= fPairMatcher.match(fDocument, 15); |
170 |
assertNotNull(match); |
142 |
assertNull(match); |
171 |
assertTrue(match.getOffset() == 3 && match.getLength() == 12); |
|
|
172 |
} |
143 |
} |
173 |
|
144 |
|
174 |
public void testAngleBrackets1_4() { |
145 |
public void testAngleBrackets1_4() { |
Lines 189-195
Link Here
|
189 |
public void testAngleBrackets1_5() { |
160 |
public void testAngleBrackets1_5() { |
190 |
final JavaPairMatcher matcher= (JavaPairMatcher) createMatcher("(){}[]<>"); |
161 |
final JavaPairMatcher matcher= (JavaPairMatcher) createMatcher("(){}[]<>"); |
191 |
matcher.setSourceVersion(JavaCore.VERSION_1_5); |
162 |
matcher.setSourceVersion(JavaCore.VERSION_1_5); |
192 |
performMatch(matcher, " #<>% "); |
163 |
performMatch(matcher, " #< %> "); |
193 |
performMatch(matcher, " <%># "); |
164 |
performMatch(matcher, " <%># "); |
194 |
performMatch(matcher, " 2 < 3 || 4 >% 5 "); |
165 |
performMatch(matcher, " 2 < 3 || 4 >% 5 "); |
195 |
performMatch(matcher, " 2 <% 3 || 4 > 5 "); |
166 |
performMatch(matcher, " 2 <% 3 || 4 > 5 "); |
Lines 203-209
Link Here
|
203 |
|
174 |
|
204 |
public void testBug209505() { |
175 |
public void testBug209505() { |
205 |
fDocument.set("(xny)/* */"); |
176 |
fDocument.set("(xny)/* */"); |
206 |
IRegion match= fPairMatcher.match(fDocument, 5); |
177 |
IRegion match= fPairMatcher.match(fDocument, 4); |
207 |
assertNotNull(match); |
178 |
assertNotNull(match); |
208 |
assertTrue(match.getOffset() == 0 && match.getLength() == 5); |
179 |
assertTrue(match.getOffset() == 0 && match.getLength() == 5); |
209 |
} |
180 |
} |