@@ -73,6 +73,7 @@ public class NewCUProposal extends ChangeCorrectionProposalCore {
7373 public static final int K_INTERFACE = 2 ;
7474 public static final int K_ENUM = 3 ;
7575 public static final int K_ANNOTATION = 4 ;
76+ public static final int K_RECORD = 5 ;
7677
7778 private Name fNode ;
7879 private ICompilationUnit fCompilationUnit ;
@@ -125,43 +126,51 @@ private void setDisplayName() {
125126 boolean isInnerType = fTypeContainer instanceof IType ;
126127 switch (fTypeKind ) {
127128 case K_CLASS :
128- if (fNode != null ) {
129- if (isInnerType ) {
130- if (containerName .length () == 0 ) {
131- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerclass_description , typeLabel ));
132- } else {
133- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerclass_intype_description , new String [] { typeLabel , containerLabel }));
134- }
129+ if (fNode != null ) {
130+ if (isInnerType ) {
131+ if (containerName .length () == 0 ) {
132+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerclass_description , typeLabel ));
135133 } else {
136- if (containerName .length () == 0 ) {
137- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createclass_description , typeLabel ));
138- } else {
139- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createclass_inpackage_description , new String [] { typeLabel , containerLabel }));
140- }
134+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerclass_intype_description , new String [] { typeLabel , containerLabel }));
141135 }
136+ } else {
137+ if (containerName .length () == 0 ) {
138+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createclass_description , typeLabel ));
139+ } else {
140+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createclass_inpackage_description , new String [] { typeLabel , containerLabel }));
141+ }
142+ }
143+ } else {
144+ if (isInnerType ) {
145+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewinnerclass_description , containerLabel ));
142146 } else {
143147 setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewclass_inpackage_description , containerLabel ));
144148 }
145- break ;
149+ }
150+ break ;
146151 case K_INTERFACE :
147- if (fNode != null ) {
148- if (isInnerType ) {
149- if (containerName .length () == 0 ) {
150- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerinterface_description , typeLabel ));
151- } else {
152- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerinterface_intype_description , new String [] { typeLabel , containerLabel }));
153- }
152+ if (fNode != null ) {
153+ if (isInnerType ) {
154+ if (containerName .length () == 0 ) {
155+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerinterface_description , typeLabel ));
154156 } else {
155- if (containerName .length () == 0 ) {
156- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinterface_description , typeLabel ));
157- } else {
158- setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinterface_inpackage_description , new String [] { typeLabel , containerLabel }));
159- }
157+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerinterface_intype_description , new String [] { typeLabel , containerLabel }));
158+ }
159+ } else {
160+ if (containerName .length () == 0 ) {
161+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinterface_description , typeLabel ));
162+ } else {
163+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinterface_inpackage_description , new String [] { typeLabel , containerLabel }));
160164 }
165+ }
166+ } else {
167+ if (isInnerType ) {
168+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewinnerinterface_description , containerLabel ));
161169 } else {
162170 setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewinterface_inpackage_description , containerLabel ));
163171 }
164- break ;
172+ }
173+ break ;
165174 case K_ENUM :
166175 if (fNode != null ) {
167176 if (isInnerType ) {
@@ -200,6 +209,29 @@ private void setDisplayName() {
200209 setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewannotation_inpackage_description , containerLabel ));
201210 }
202211 break ;
212+ case K_RECORD :
213+ if (fNode != null ) {
214+ if (isInnerType ) {
215+ if (containerName .length () == 0 ) {
216+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerrecord_description , typeLabel ));
217+ } else {
218+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createinnerrecord_intype_description , new String [] { typeLabel , containerLabel }));
219+ }
220+ } else {
221+ if (containerName .length () == 0 ) {
222+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createrecord_description , typeLabel ));
223+ } else {
224+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createrecord_inpackage_description , new String [] { typeLabel , containerLabel }));
225+ }
226+ }
227+ } else {
228+ if (isInnerType ) {
229+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewinnerrecord_description , containerLabel ));
230+ } else {
231+ setDisplayName (Messages .format (CorrectionMessages .NewCUCompletionUsingWizardProposal_createnewrecord_inpackage_description , containerLabel ));
232+ }
233+ }
234+ break ;
203235 default :
204236 throw new IllegalArgumentException ("Unknown type kind" ); //$NON-NLS-1$
205237 }
@@ -305,6 +337,9 @@ private TextEdit constructEnclosingTypeEdit(ICompilationUnit icu) throws CoreExc
305337 case K_ANNOTATION :
306338 newDeclaration = ast .newAnnotationTypeDeclaration ();
307339 break ;
340+ case K_RECORD :
341+ newDeclaration = ast .newRecordDeclaration ();
342+ break ;
308343 default :
309344 return null ;
310345 }
@@ -428,13 +463,19 @@ private String constructTypeStub(ICompilationUnit parentCU, String name, int mod
428463 type = "@interface " ; //$NON-NLS-1$
429464 templateID = CodeGeneration .ANNOTATION_BODY_TEMPLATE_ID ;
430465 break ;
466+ case K_RECORD :
467+ type = "record " ; //$NON-NLS-1$
468+ templateID = CodeGeneration .RECORD_BODY_TEMPLATE_ID ;
469+ break ;
431470 }
432471 buf .append (type );
433472 buf .append (name );
434473 if (isPermitted ) {
435474 buf .append (' ' );
436475 buf .append (superType );
437476 buf .append (cuType .getElementName ());
477+ } else if (fTypeKind == K_RECORD ) {
478+ buf .append ("() " );
438479 }
439480
440481 buf .append (" {" ).append (lineDelimiter ); //$NON-NLS-1$
0 commit comments