27
27
import org .mockito .Mockito ;
28
28
29
29
import org .eclipse .swt .SWT ;
30
- import org .eclipse .swt .widgets .Display ;
31
30
import org .eclipse .swt .widgets .Shell ;
32
31
33
32
import org .eclipse .jface .text .Document ;
@@ -98,31 +97,30 @@ public void testPerformReplaceAllForwards() {
98
97
* operates
99
98
*/
100
99
private void performReplaceAllBaseTestcases (IFindReplaceLogic findReplaceLogic , TextViewer textViewer ) {
101
- Display display = parentShell .getDisplay ();
102
100
textViewer .setDocument (new Document ("aaaa" ));
103
101
104
- findReplaceLogic .performReplaceAll ("a" , "b" , display );
102
+ findReplaceLogic .performReplaceAll ("a" , "b" );
105
103
assertThat (textViewer .getDocument ().get (), equalTo ("bbbb" ));
106
104
expectStatusIsReplaceAllWithCount (findReplaceLogic , 4 );
107
105
108
- findReplaceLogic .performReplaceAll ("b" , "aa" , display );
106
+ findReplaceLogic .performReplaceAll ("b" , "aa" );
109
107
assertThat (textViewer .getDocument ().get (), equalTo ("aaaaaaaa" ));
110
108
expectStatusIsReplaceAllWithCount (findReplaceLogic , 4 );
111
109
112
- findReplaceLogic .performReplaceAll ("b" , "c" , display );
110
+ findReplaceLogic .performReplaceAll ("b" , "c" );
113
111
assertThat (textViewer .getDocument ().get (), equalTo ("aaaaaaaa" ));
114
112
expectStatusIsCode (findReplaceLogic , FindStatus .StatusCode .NO_MATCH );
115
113
116
- findReplaceLogic .performReplaceAll ("aaaaaaaa" , "d" , display ); // https://github.com/eclipse-platform/eclipse.platform.ui/issues/1203
114
+ findReplaceLogic .performReplaceAll ("aaaaaaaa" , "d" ); // https://github.com/eclipse-platform/eclipse.platform.ui/issues/1203
117
115
assertThat (textViewer .getDocument ().get (), equalTo ("d" ));
118
116
expectStatusIsReplaceAllWithCount (findReplaceLogic , 1 );
119
117
120
- findReplaceLogic .performReplaceAll ("d" , null , display );
118
+ findReplaceLogic .performReplaceAll ("d" , null );
121
119
assertThat (textViewer .getDocument ().get (), equalTo ("" ));
122
120
expectStatusIsReplaceAllWithCount (findReplaceLogic , 1 );
123
121
124
122
textViewer .getDocument ().set ("f" );
125
- findReplaceLogic .performReplaceAll ("f" , "" , display );
123
+ findReplaceLogic .performReplaceAll ("f" , "" );
126
124
assertThat (textViewer .getDocument ().get (), equalTo ("" ));
127
125
expectStatusIsReplaceAllWithCount (findReplaceLogic , 1 );
128
126
@@ -131,7 +129,7 @@ private void performReplaceAllBaseTestcases(IFindReplaceLogic findReplaceLogic,
131
129
Mockito .when (mockFindReplaceTarget .isEditable ()).thenReturn (false );
132
130
133
131
findReplaceLogic .updateTarget (mockFindReplaceTarget , false );
134
- findReplaceLogic .performReplaceAll ("a" , "b" , display );
132
+ findReplaceLogic .performReplaceAll ("a" , "b" );
135
133
expectStatusIsCode (findReplaceLogic , FindStatus .StatusCode .NO_MATCH );
136
134
}
137
135
@@ -142,15 +140,15 @@ public void testPerformReplaceAllForwardRegEx() {
142
140
findReplaceLogic .activate (SearchOptions .REGEX );
143
141
findReplaceLogic .activate (SearchOptions .FORWARD );
144
142
145
- findReplaceLogic .performReplaceAll (".+\\ @.+\\ .com" , "" , parentShell . getDisplay () );
143
+ findReplaceLogic .performReplaceAll (".+\\ @.+\\ .com" , "" );
146
144
assertThat (textViewer .getDocument ().get (), equalTo (" looks.almost@like_an_email" ));
147
145
expectStatusIsReplaceAllWithCount (findReplaceLogic , 1 );
148
146
149
- findReplaceLogic .performReplaceAll ("( looks.)|(like_)" , "" , parentShell . getDisplay () );
147
+ findReplaceLogic .performReplaceAll ("( looks.)|(like_)" , "" );
150
148
assertThat (textViewer .getDocument ().get (), equalTo ("almost@an_email" ));
151
149
expectStatusIsReplaceAllWithCount (findReplaceLogic , 2 );
152
150
153
- findReplaceLogic .performReplaceAll ("[" , "" , parentShell . getDisplay () );
151
+ findReplaceLogic .performReplaceAll ("[" , "" );
154
152
assertThat (textViewer .getDocument ().get (), equalTo ("almost@an_email" ));
155
153
expectStatusIsMessageWithString (findReplaceLogic , "Unclosed character class near index 0" + System .lineSeparator ()
156
154
+ "[" + System .lineSeparator ()
@@ -165,15 +163,15 @@ public void testPerformReplaceAllForward() {
165
163
findReplaceLogic .activate (SearchOptions .REGEX );
166
164
findReplaceLogic .activate (SearchOptions .FORWARD );
167
165
168
- findReplaceLogic .performReplaceAll (".+\\ @.+\\ .com" , "" , parentShell . getDisplay () );
166
+ findReplaceLogic .performReplaceAll (".+\\ @.+\\ .com" , "" );
169
167
assertThat (textViewer .getDocument ().get (), equalTo (" looks.almost@like_an_email" ));
170
168
expectStatusIsReplaceAllWithCount (findReplaceLogic , 1 );
171
169
172
- findReplaceLogic .performReplaceAll ("( looks.)|(like_)" , "" , parentShell . getDisplay () );
170
+ findReplaceLogic .performReplaceAll ("( looks.)|(like_)" , "" );
173
171
assertThat (textViewer .getDocument ().get (), equalTo ("almost@an_email" ));
174
172
expectStatusIsReplaceAllWithCount (findReplaceLogic , 2 );
175
173
176
- findReplaceLogic .performReplaceAll ("[" , "" , parentShell . getDisplay () );
174
+ findReplaceLogic .performReplaceAll ("[" , "" );
177
175
assertThat (textViewer .getDocument ().get (), equalTo ("almost@an_email" ));
178
176
expectStatusIsMessageWithString (findReplaceLogic , "Unclosed character class near index 0" + System .lineSeparator ()
179
177
+ "[" + System .lineSeparator ()
@@ -364,15 +362,15 @@ public void testPerformSelectAllForward() {
364
362
IFindReplaceLogic findReplaceLogic = setupFindReplaceLogicObject (textViewer );
365
363
findReplaceLogic .activate (SearchOptions .FORWARD );
366
364
367
- findReplaceLogic .performSelectAll ("c" , parentShell . getDisplay () );
365
+ findReplaceLogic .performSelectAll ("c" );
368
366
expectStatusIsCode (findReplaceLogic , FindStatus .StatusCode .NO_MATCH );
369
367
370
- findReplaceLogic .performSelectAll ("b" , parentShell . getDisplay () );
368
+ findReplaceLogic .performSelectAll ("b" );
371
369
expectStatusIsFindAllWithCount (findReplaceLogic , 4 );
372
370
// I don't have access to getAllSelectionPoints or similar (not yet implemented), so I cannot really test for correct behavior
373
371
// related to https://github.com/eclipse-platform/eclipse.platform.ui/issues/1047
374
372
375
- findReplaceLogic .performSelectAll ("AbAbAbAb" , parentShell . getDisplay () );
373
+ findReplaceLogic .performSelectAll ("AbAbAbAb" );
376
374
expectStatusIsFindAllWithCount (findReplaceLogic , 1 );
377
375
}
378
376
@@ -383,13 +381,13 @@ public void testPerformSelectAllRegEx() {
383
381
findReplaceLogic .activate (SearchOptions .FORWARD );
384
382
findReplaceLogic .activate (SearchOptions .REGEX );
385
383
386
- findReplaceLogic .performSelectAll ("c.*" , parentShell . getDisplay () );
384
+ findReplaceLogic .performSelectAll ("c.*" );
387
385
expectStatusIsCode (findReplaceLogic , FindStatus .StatusCode .NO_MATCH );
388
386
389
- findReplaceLogic .performSelectAll ("(Ab)*" , parentShell . getDisplay () );
387
+ findReplaceLogic .performSelectAll ("(Ab)*" );
390
388
expectStatusIsFindAllWithCount (findReplaceLogic , 1 );
391
389
392
- findReplaceLogic .performSelectAll ("Ab(Ab)+Ab(Ab)+(Ab)+" , parentShell . getDisplay () );
390
+ findReplaceLogic .performSelectAll ("Ab(Ab)+Ab(Ab)+(Ab)+" );
393
391
expectStatusIsCode (findReplaceLogic , FindStatus .StatusCode .NO_MATCH );
394
392
}
395
393
@@ -400,12 +398,12 @@ public void testPerformSelectAllBackward() {
400
398
IFindReplaceLogic findReplaceLogic = setupFindReplaceLogicObject (textViewer );
401
399
findReplaceLogic .deactivate (SearchOptions .FORWARD );
402
400
403
- findReplaceLogic .performSelectAll ("b" , parentShell . getDisplay () );
401
+ findReplaceLogic .performSelectAll ("b" );
404
402
expectStatusIsFindAllWithCount (findReplaceLogic , 4 );
405
403
// I don't have access to getAllSelectionPoints or similar (not yet implemented), so I cannot really test for correct behavior
406
404
// related to https://github.com/eclipse-platform/eclipse.platform.ui/issues/1047
407
405
408
- findReplaceLogic .performSelectAll ("AbAbAbAb" , parentShell . getDisplay () );
406
+ findReplaceLogic .performSelectAll ("AbAbAbAb" );
409
407
expectStatusIsFindAllWithCount (findReplaceLogic , 1 );
410
408
}
411
409
@@ -414,7 +412,7 @@ public void testPerformSelectAllOnReadonlyTarget() {
414
412
TextViewer textViewer = setupTextViewer ("Ab Ab" );
415
413
textViewer .setEditable (false );
416
414
IFindReplaceLogic findReplaceLogic = setupFindReplaceLogicObject (textViewer );
417
- findReplaceLogic .performSelectAll ("Ab" , Display . getCurrent () );
415
+ findReplaceLogic .performSelectAll ("Ab" );
418
416
expectStatusIsFindAllWithCount (findReplaceLogic , 2 );
419
417
}
420
418
@@ -437,14 +435,14 @@ public void testSelectInSearchScope() {
437
435
IFindReplaceLogic findReplaceLogic = setupFindReplaceLogicObject (textViewer );
438
436
textViewer .setSelection (new TextSelection (6 , 11 ));
439
437
findReplaceLogic .deactivate (SearchOptions .GLOBAL );
440
- findReplaceLogic .performReplaceAll ("l" , "" , Display . getCurrent () );
438
+ findReplaceLogic .performReplaceAll ("l" , "" );
441
439
expectStatusIsReplaceAllWithCount (findReplaceLogic , 2 );
442
440
443
441
findReplaceLogic .activate (SearchOptions .GLOBAL );
444
442
textViewer .setSelection (new TextSelection (0 , 5 ));
445
443
findReplaceLogic .deactivate (SearchOptions .GLOBAL );
446
444
447
- findReplaceLogic .performReplaceAll ("n" , "" , Display . getCurrent () );
445
+ findReplaceLogic .performReplaceAll ("n" , "" );
448
446
expectStatusIsReplaceAllWithCount (findReplaceLogic , 1 );
449
447
450
448
assertThat (textViewer .getTextWidget ().getText (), is ("lie1\n ine2\n ine3" ));
0 commit comments