Skip to content

Commit cceffcf

Browse files
committed
feat: support creating multiple types at once in NewTypeWizardPage(#1251)
Adds support for creating multiple types with semicolon-separated values, with or without spaces. Only the first file is opened in the editor and duplicate names are ignored. How to test: - Open the dialog for creating a new class, enum, etc. - Enter multiple names separated by semicolons in the type name field. Closes #1251
1 parent 5f271d3 commit cceffcf

16 files changed

Lines changed: 421 additions & 105 deletions

File tree

org.eclipse.jdt.junit/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.junit
33
Bundle-ManifestVersion: 2
44
Bundle-Name: %pluginName
55
Bundle-SymbolicName: org.eclipse.jdt.junit;singleton:=true
6-
Bundle-Version: 3.17.200.qualifier
6+
Bundle-Version: 3.18.0.qualifier
77
Bundle-Activator: org.eclipse.jdt.internal.junit.ui.JUnitPlugin
88
Bundle-ActivationPolicy: lazy
99
Bundle-Vendor: %providerName

org.eclipse.jdt.junit/src/org/eclipse/jdt/junit/wizards/NewTestSuiteWizardPage.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -380,12 +380,12 @@ private String getUpdatableString() {
380380
}
381381

382382
@Override
383-
public void createType(IProgressMonitor monitor) throws CoreException, InterruptedException {
383+
public void createTypes(IProgressMonitor monitor) throws CoreException, InterruptedException {
384384
IPackageFragment pack= getPackageFragment();
385385
ICompilationUnit cu= pack.getCompilationUnit(getTypeName() + ".java"); //$NON-NLS-1$
386386

387387
if (!cu.exists()) {
388-
super.createType(monitor);
388+
super.createTypes(monitor);
389389
fUpdatedExistingClassButton= false;
390390
} else {
391391
updateExistingType(cu, monitor);

org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest.java

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public void testCreateClass1() throws Exception {
134134
wizardPage.enableCommentControl(true);
135135

136136
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
137-
wizardPage.createType(testMonitor);
137+
wizardPage.createTypes(testMonitor);
138138
testMonitor.assertUsedUp();
139139

140140
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -176,7 +176,7 @@ public void testCreateClass2() throws Exception {
176176
wizardPage.enableCommentControl(true);
177177

178178
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
179-
wizardPage.createType(testMonitor);
179+
wizardPage.createTypes(testMonitor);
180180
testMonitor.assertUsedUp();
181181

182182
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -230,7 +230,7 @@ public class A<T> {
230230
wizardPage.enableCommentControl(true);
231231

232232
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
233-
wizardPage.createType(testMonitor);
233+
wizardPage.createTypes(testMonitor);
234234
testMonitor.assertUsedUp();
235235

236236
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -292,7 +292,7 @@ public class A<T> {
292292
wizardPage.enableCommentControl(true);
293293

294294
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
295-
wizardPage.createType(testMonitor);
295+
wizardPage.createTypes(testMonitor);
296296
testMonitor.assertUsedUp();
297297

298298
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -362,7 +362,7 @@ public class A<T> {
362362
wizardPage.enableCommentControl(true);
363363

364364
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
365-
wizardPage.createType(testMonitor);
365+
wizardPage.createTypes(testMonitor);
366366
testMonitor.assertUsedUp();
367367

368368
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -412,7 +412,7 @@ public void testCreateClassExtraImports1() throws Exception {
412412
wizardPage.enableCommentControl(true);
413413

414414
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
415-
wizardPage.createType(testMonitor);
415+
wizardPage.createTypes(testMonitor);
416416
testMonitor.assertUsedUp();
417417

418418
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -475,7 +475,7 @@ public static class Inner {
475475
wizardPage.enableCommentControl(true);
476476

477477
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
478-
wizardPage.createType(testMonitor);
478+
wizardPage.createTypes(testMonitor);
479479
testMonitor.assertUsedUp();
480480

481481
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -550,7 +550,7 @@ public class B {
550550
wizardPage.enableCommentControl(true);
551551

552552
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
553-
wizardPage.createType(testMonitor);
553+
wizardPage.createTypes(testMonitor);
554554
testMonitor.assertUsedUp();
555555

556556
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -601,7 +601,7 @@ public void testCreateInterface() throws Exception {
601601
wizardPage.enableCommentControl(true);
602602

603603
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
604-
wizardPage.createType(testMonitor);
604+
wizardPage.createTypes(testMonitor);
605605
testMonitor.assertUsedUp();
606606

607607
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -641,7 +641,7 @@ public void testCreateEnum() throws Exception {
641641
wizardPage.enableCommentControl(true);
642642

643643
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
644-
wizardPage.createType(testMonitor);
644+
wizardPage.createTypes(testMonitor);
645645
testMonitor.assertUsedUp();
646646

647647
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -679,7 +679,7 @@ public void testCreateAnnotation() throws Exception {
679679
wizardPage.enableCommentControl(true);
680680

681681
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
682-
wizardPage.createType(testMonitor);
682+
wizardPage.createTypes(testMonitor);
683683
testMonitor.assertUsedUp();
684684

685685
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -723,7 +723,7 @@ public void typeBodyTest( NewTypeWizardPage wizardPage, String templateID, Strin
723723
wizardPage.enableCommentControl(true);
724724

725725
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
726-
wizardPage.createType(testMonitor);
726+
wizardPage.createTypes(testMonitor);
727727
testMonitor.assertUsedUp();
728728

729729
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
@@ -835,7 +835,7 @@ public class Foo3 {
835835
NewClassWizardPage wizardPage= new NewClassWizardPage();
836836
wizardPage.init(new StructuredSelection(cu));
837837
FussyProgressMonitor testMonitor= new FussyProgressMonitor();
838-
wizardPage.createType(testMonitor);
838+
wizardPage.createTypes(testMonitor);
839839
testMonitor.assertUsedUp();
840840

841841
// Foo3.java can still be unique in test1

org.eclipse.jdt.ui.tests/ui/org/eclipse/jdt/ui/tests/wizardapi/NewTypeWizardTest17.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@
1414

1515
package org.eclipse.jdt.ui.tests.wizardapi;
1616

17-
import static org.junit.Assert.assertNotNull;
1817
import static org.junit.Assert.assertEquals;
18+
import static org.junit.Assert.assertNotNull;
1919

2020
import java.util.ArrayList;
2121
import java.util.Hashtable;
@@ -362,7 +362,7 @@ public void testNonModularCreateClassSuccess1() throws Exception {
362362
assertNotNull(status);
363363
assertEquals(IStatus.OK, status.getSeverity());
364364

365-
wizardPage.createType(null);
365+
wizardPage.createTypes(null);
366366

367367
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
368368

@@ -426,7 +426,7 @@ public void testNonModularCreateClassSuccess2() throws Exception {
426426
assertNotNull(status);
427427
assertEquals(IStatus.OK, status.getSeverity());
428428

429-
wizardPage.createType(null);
429+
wizardPage.createTypes(null);
430430

431431
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
432432

@@ -491,7 +491,7 @@ public void testNonModularCreateClassSuccess3() throws Exception {
491491
assertNotNull(status);
492492
assertEquals(IStatus.OK, status.getSeverity());
493493

494-
wizardPage.createType(null);
494+
wizardPage.createTypes(null);
495495

496496
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
497497

@@ -555,7 +555,7 @@ public void testNonModularCreateClassSuccess4() throws Exception {
555555
assertNotNull(status);
556556
assertEquals(IStatus.OK, status.getSeverity());
557557

558-
wizardPage.createType(null);
558+
wizardPage.createTypes(null);
559559

560560
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
561561

@@ -618,7 +618,7 @@ public void testNonModularCreateInterfaceSuccess1() throws Exception {
618618
assertNotNull(status);
619619
assertEquals(IStatus.OK, status.getSeverity());
620620

621-
wizardPage.createType(null);
621+
wizardPage.createTypes(null);
622622

623623
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
624624

@@ -773,7 +773,7 @@ public void testModularCreateClassSuccess1() throws Exception {
773773
assertNotNull(status);
774774
assertEquals(IStatus.OK, status.getSeverity());
775775

776-
wizardPage.createType(null);
776+
wizardPage.createTypes(null);
777777

778778
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
779779

@@ -844,7 +844,7 @@ public void testModularCreateClassSuccess2() throws Exception {
844844
assertNotNull(status);
845845
assertEquals(IStatus.OK, status.getSeverity());
846846

847-
wizardPage.createType(null);
847+
wizardPage.createTypes(null);
848848

849849
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
850850

@@ -916,7 +916,7 @@ public void testModularCreateClassSuccess3() throws Exception {
916916
assertNotNull(status);
917917
assertEquals(IStatus.OK, status.getSeverity());
918918

919-
wizardPage.createType(null);
919+
wizardPage.createTypes(null);
920920

921921
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
922922

@@ -987,7 +987,7 @@ public void testModularCreateClassSuccess4() throws Exception {
987987
assertNotNull(status);
988988
assertEquals(IStatus.OK, status.getSeverity());
989989

990-
wizardPage.createType(null);
990+
wizardPage.createTypes(null);
991991

992992
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
993993

@@ -1057,7 +1057,7 @@ public void testModularCreateInterfaceSuccess1() throws Exception {
10571057
assertNotNull(status);
10581058
assertEquals(IStatus.OK, status.getSeverity());
10591059

1060-
wizardPage.createType(null);
1060+
wizardPage.createTypes(null);
10611061

10621062
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
10631063

@@ -1233,7 +1233,7 @@ public void testCreateRecordWithAbstractMethodStubs() throws Exception {
12331233
wizardPage.setAddComments(true, true);
12341234
wizardPage.enableCommentControl(true);
12351235

1236-
wizardPage.createType(null);
1236+
wizardPage.createTypes(null);
12371237

12381238
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
12391239

@@ -1297,7 +1297,7 @@ public void testCreateRecordWithOutAbstractMethodStubsAndMain() throws Exception
12971297
wizardPage.setAddComments(true, true);
12981298
wizardPage.enableCommentControl(true);
12991299

1300-
wizardPage.createType(null);
1300+
wizardPage.createTypes(null);
13011301

13021302
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
13031303

@@ -1337,7 +1337,7 @@ public void testCreateRecordWithMain() throws Exception {
13371337
wizardPage.setAddComments(true, true);
13381338
wizardPage.enableCommentControl(true);
13391339

1340-
wizardPage.createType(null);
1340+
wizardPage.createTypes(null);
13411341

13421342
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
13431343

@@ -1384,7 +1384,7 @@ public void testCreateRecordWithAbstractMethodStubsAndMain() throws Exception {
13841384
wizardPage.setAddComments(true, true);
13851385
wizardPage.enableCommentControl(true);
13861386

1387-
wizardPage.createType(null);
1387+
wizardPage.createTypes(null);
13881388

13891389
String actual= wizardPage.getCreatedType().getCompilationUnit().getSource();
13901390

org.eclipse.jdt.ui/.options

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ org.eclipse.jdt.ui/perf/search/participants=300
2929
org.eclipse.jdt.ui/perf/content_assist/extensions=1000
3030

3131
#Reports the time for a single completion proposal sorter
32-
org.eclipse.jdt.ui/perf/content_assist_sorters/extensions
32+
org.eclipse.jdt.ui/perf/content_assist_sorters/extensions

org.eclipse.jdt.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Automatic-Module-Name: org.eclipse.jdt.ui
33
Bundle-ManifestVersion: 2
44
Bundle-Name: %pluginName
55
Bundle-SymbolicName: org.eclipse.jdt.ui; singleton:=true
6-
Bundle-Version: 3.35.200.qualifier
6+
Bundle-Version: 3.36.0.qualifier
77
Bundle-Activator: org.eclipse.jdt.internal.ui.JavaPlugin
88
Bundle-ActivationPolicy: lazy
99
Bundle-Vendor: %providerName

org.eclipse.jdt.ui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
</parent>
1919
<groupId>org.eclipse.jdt</groupId>
2020
<artifactId>org.eclipse.jdt.ui</artifactId>
21-
<version>3.35.200-SNAPSHOT</version>
21+
<version>3.36.0-SNAPSHOT</version>
2222
<packaging>eclipse-plugin</packaging>
2323

2424
<build>

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/correction/proposals/NewCUUsingWizardProposal.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ public void apply(IDocument document) {
317317
wizard.addPages();
318318
try {
319319
NewTypeWizardPage page= getPage(wizard);
320-
page.createType(null);
320+
page.createTypes(null);
321321
createdType= page.getCreatedType();
322322
} catch (CoreException e) {
323323
JavaPlugin.log(e);

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewAnnotationCreationWizard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ protected boolean canRunForked() {
6767

6868
@Override
6969
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
70-
fPage.createType(monitor); // use the full progress monitor
70+
fPage.createTypes(monitor); // use the full progress monitor
7171
}
7272

7373
@Override

org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/wizards/NewClassCreationWizard.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ protected boolean canRunForked() {
6565

6666
@Override
6767
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException {
68-
fPage.createType(monitor); // use the full progress monitor
68+
fPage.createTypes(monitor); // use the full progress monitor
6969
}
7070

7171
@Override

0 commit comments

Comments
 (0)