1010 *******************************************************************************/
1111package com .avaloq .tools .ddk .check .formatting2 ;
1212
13- import java .util .Arrays ;
14-
1513import org .eclipse .emf .ecore .EObject ;
1614import org .eclipse .xtext .Keyword ;
1715import org .eclipse .xtext .common .types .JvmFormalParameter ;
@@ -118,7 +116,7 @@ private void globalFormatting(final IEObjectRegion requestRoot, final IFormattab
118116 // autowrap everywhere. default to one-space between semantic regions.
119117 // low priority so that it can be overridden by other custom formatting rules.
120118 boolean firstRegion = true ;
121- for (ISemanticRegion region : requestRoot .getAllSemanticRegions ()) {
119+ for (final ISemanticRegion region : requestRoot .getAllSemanticRegions ()) {
122120 if (firstRegion ) {
123121 document .prepend (region , (IHiddenRegionFormatter it ) -> {
124122 it .lowPriority ();
@@ -164,16 +162,16 @@ protected void _format(final CheckCatalog checkcatalog, final IFormattableDocume
164162
165163 // Generated model traversal
166164 this .format (checkcatalog .getImports (), document );
167- for (Category categories : checkcatalog .getCategories ()) {
165+ for (final Category categories : checkcatalog .getCategories ()) {
168166 this .format (categories , document );
169167 }
170- for (Implementation implementations : checkcatalog .getImplementations ()) {
168+ for (final Implementation implementations : checkcatalog .getImplementations ()) {
171169 this .format (implementations , document );
172170 }
173- for (Check checks : checkcatalog .getChecks ()) {
171+ for (final Check checks : checkcatalog .getChecks ()) {
174172 this .format (checks , document );
175173 }
176- for (Member members : checkcatalog .getMembers ()) {
174+ for (final Member members : checkcatalog .getMembers ()) {
177175 this .format (members , document );
178176 }
179177
@@ -187,7 +185,7 @@ protected void _format(final CheckCatalog checkcatalog, final IFormattableDocume
187185 @ Override
188186 protected void _format (final XImportSection ximportsection , final IFormattableDocument document ) {
189187 // Generated model traversal
190- for (XImportDeclaration importDeclarations : ximportsection .getImportDeclarations ()) {
188+ for (final XImportDeclaration importDeclarations : ximportsection .getImportDeclarations ()) {
191189 // ADDED: formatting added before each import
192190 document .prepend (importDeclarations , (IHiddenRegionFormatter it ) -> {
193191 it .setNewLines (1 , 1 , 2 );
@@ -204,7 +202,7 @@ protected void _format(final Category category, final IFormattableDocument docum
204202 formatCurlyBracket (category , document );
205203
206204 // Generated model traversal
207- for (Check checks : category .getChecks ()) {
205+ for (final Check checks : category .getChecks ()) {
208206 this .format (checks , document );
209207 }
210208 }
@@ -227,7 +225,7 @@ protected void _format(final Check check, final IFormattableDocument document) {
227225
228226 // Generated model traversal
229227 this .format (check .getSeverityRange (), document );
230- for (FormalParameter formalParameters : check .getFormalParameters ()) {
228+ for (final FormalParameter formalParameters : check .getFormalParameters ()) {
231229 // ADDED: formatting added around comma.
232230 // High priority to override formatting from adjacent regions and parent formatter.
233231 final ISemanticRegion comma = immediatelyFollowing (formalParameters ).keyword ("," );
@@ -242,7 +240,7 @@ protected void _format(final Check check, final IFormattableDocument document) {
242240
243241 this .format (formalParameters , document );
244242 }
245- for (Context contexts : check .getContexts ()) {
243+ for (final Context contexts : check .getContexts ()) {
246244 this .format (contexts , document );
247245 }
248246 }
@@ -267,7 +265,7 @@ protected void _format(final SeverityRange severityrange, final IFormattableDocu
267265
268266 protected void _format (final Member member , final IFormattableDocument document ) {
269267 // Generated model traversal
270- for (XAnnotation annotations : member .getAnnotations ()) {
268+ for (final XAnnotation annotations : member .getAnnotations ()) {
271269 this .format (annotations , document );
272270 }
273271 this .format (member .getType (), document );
@@ -296,7 +294,7 @@ protected void _format(final XUnaryOperation xunaryoperation, final IFormattable
296294
297295 protected void _format (final XListLiteral xlistliteral , final IFormattableDocument document ) {
298296 // Generated model traversal
299- for (XExpression elements : xlistliteral .getElements ()) {
297+ for (final XExpression elements : xlistliteral .getElements ()) {
300298 this .format (elements , document );
301299 }
302300 }
@@ -367,7 +365,7 @@ protected void _format(final XIssueExpression xissueexpression, final IFormattab
367365 this .format (xissueexpression .getMarkerObject (), document );
368366 this .format (xissueexpression .getMarkerIndex (), document );
369367 this .format (xissueexpression .getMessage (), document );
370- for (XExpression messageParameters : xissueexpression .getMessageParameters ()) {
368+ for (final XExpression messageParameters : xissueexpression .getMessageParameters ()) {
371369 // ADDED: formatting added around comma
372370 final ISemanticRegion comma = immediatelyFollowing (messageParameters ).keyword ("," );
373371 document .prepend (comma , (IHiddenRegionFormatter it ) -> {
@@ -381,7 +379,7 @@ protected void _format(final XIssueExpression xissueexpression, final IFormattab
381379
382380 this .format (messageParameters , document );
383381 }
384- for (XExpression issueData : xissueexpression .getIssueData ()) {
382+ for (final XExpression issueData : xissueexpression .getIssueData ()) {
385383 // ADDED: formatting added around comma
386384 final ISemanticRegion comma = immediatelyFollowing (issueData ).keyword ("," );
387385 document .prepend (comma , (IHiddenRegionFormatter it ) -> {
@@ -466,112 +464,109 @@ protected void _format(final XMemberFeatureCall xfeaturecall, final IFormattable
466464
467465 @ Override
468466 @ XbaseGenerated
469- public void format (final Object xlistliteral , final IFormattableDocument document ) {
470- if (xlistliteral instanceof JvmTypeParameter ) {
471- _format (( JvmTypeParameter ) xlistliteral , document );
472- } else if (xlistliteral instanceof JvmFormalParameter ) {
473- _format (( JvmFormalParameter ) xlistliteral , document );
474- } else if (xlistliteral instanceof XtextResource ) {
475- _format (( XtextResource ) xlistliteral , document );
476- } else if (xlistliteral instanceof XAssignment ) {
477- _format (( XAssignment ) xlistliteral , document );
478- } else if (xlistliteral instanceof XBinaryOperation ) {
479- _format (( XBinaryOperation ) xlistliteral , document );
480- } else if (xlistliteral instanceof XDoWhileExpression ) {
481- _format (( XDoWhileExpression ) xlistliteral , document );
482- } else if (xlistliteral instanceof XFeatureCall ) {
483- _format (( XFeatureCall ) xlistliteral , document );
484- } else if (xlistliteral instanceof XListLiteral ) {
485- _format (( XListLiteral ) xlistliteral , document );
486- } else if (xlistliteral instanceof XMemberFeatureCall ) {
487- _format (( XMemberFeatureCall ) xlistliteral , document );
488- } else if (xlistliteral instanceof XPostfixOperation ) {
489- _format (( XPostfixOperation ) xlistliteral , document );
490- } else if (xlistliteral instanceof XUnaryOperation ) {
491- _format (( XUnaryOperation ) xlistliteral , document );
492- } else if (xlistliteral instanceof XWhileExpression ) {
493- _format (( XWhileExpression ) xlistliteral , document );
494- } else if (xlistliteral instanceof XFunctionTypeRef ) {
495- _format (( XFunctionTypeRef ) xlistliteral , document );
496- } else if (xlistliteral instanceof Category ) {
497- _format (( Category ) xlistliteral , document );
498- } else if (xlistliteral instanceof Check ) {
499- _format (( Check ) xlistliteral , document );
500- } else if (xlistliteral instanceof CheckCatalog ) {
501- _format (( CheckCatalog ) xlistliteral , document );
502- } else if (xlistliteral instanceof Context ) {
503- _format (( Context ) xlistliteral , document );
504- } else if (xlistliteral instanceof Implementation ) {
505- _format (( Implementation ) xlistliteral , document );
506- } else if (xlistliteral instanceof Member ) {
507- _format (( Member ) xlistliteral , document );
508- } else if (xlistliteral instanceof XGuardExpression ) {
509- _format (( XGuardExpression ) xlistliteral , document );
510- } else if (xlistliteral instanceof XIssueExpression ) {
511- _format (( XIssueExpression ) xlistliteral , document );
512- } else if (xlistliteral instanceof JvmGenericArrayTypeReference ) {
513- _format (( JvmGenericArrayTypeReference ) xlistliteral , document );
514- } else if (xlistliteral instanceof JvmParameterizedTypeReference ) {
515- _format (( JvmParameterizedTypeReference ) xlistliteral , document );
516- } else if (xlistliteral instanceof JvmWildcardTypeReference ) {
517- _format (( JvmWildcardTypeReference ) xlistliteral , document );
518- } else if (xlistliteral instanceof XBasicForLoopExpression ) {
519- _format (( XBasicForLoopExpression ) xlistliteral , document );
520- } else if (xlistliteral instanceof XBlockExpression ) {
521- _format (( XBlockExpression ) xlistliteral , document );
522- } else if (xlistliteral instanceof XCastedExpression ) {
523- _format (( XCastedExpression ) xlistliteral , document );
524- } else if (xlistliteral instanceof XClosure ) {
525- _format (( XClosure ) xlistliteral , document );
526- } else if (xlistliteral instanceof XCollectionLiteral ) {
527- _format (( XCollectionLiteral ) xlistliteral , document );
528- } else if (xlistliteral instanceof XConstructorCall ) {
529- _format (( XConstructorCall ) xlistliteral , document );
530- } else if (xlistliteral instanceof XForLoopExpression ) {
531- _format (( XForLoopExpression ) xlistliteral , document );
532- } else if (xlistliteral instanceof XIfExpression ) {
533- _format (( XIfExpression ) xlistliteral , document );
534- } else if (xlistliteral instanceof XInstanceOfExpression ) {
535- _format (( XInstanceOfExpression ) xlistliteral , document );
536- } else if (xlistliteral instanceof XReturnExpression ) {
537- _format (( XReturnExpression ) xlistliteral , document );
538- } else if (xlistliteral instanceof XSwitchExpression ) {
539- _format (( XSwitchExpression ) xlistliteral , document );
540- } else if (xlistliteral instanceof XSynchronizedExpression ) {
541- _format (( XSynchronizedExpression ) xlistliteral , document );
542- } else if (xlistliteral instanceof XThrowExpression ) {
543- _format (( XThrowExpression ) xlistliteral , document );
544- } else if (xlistliteral instanceof XTryCatchFinallyExpression ) {
545- _format (( XTryCatchFinallyExpression ) xlistliteral , document );
546- } else if (xlistliteral instanceof XTypeLiteral ) {
547- _format (( XTypeLiteral ) xlistliteral , document );
548- } else if (xlistliteral instanceof XVariableDeclaration ) {
549- _format (( XVariableDeclaration ) xlistliteral , document );
550- } else if (xlistliteral instanceof XAnnotation ) {
551- _format (( XAnnotation ) xlistliteral , document );
552- } else if (xlistliteral instanceof ContextVariable ) {
553- _format (( ContextVariable ) xlistliteral , document );
554- } else if (xlistliteral instanceof FormalParameter ) {
555- _format (( FormalParameter ) xlistliteral , document );
556- } else if (xlistliteral instanceof SeverityRange ) {
557- _format (( SeverityRange ) xlistliteral , document );
558- } else if (xlistliteral instanceof JvmTypeConstraint ) {
559- _format (( JvmTypeConstraint ) xlistliteral , document );
560- } else if (xlistliteral instanceof XExpression ) {
561- _format (( XExpression ) xlistliteral , document );
562- } else if (xlistliteral instanceof XImportDeclaration ) {
563- _format (( XImportDeclaration ) xlistliteral , document );
564- } else if (xlistliteral instanceof XImportSection ) {
565- _format (( XImportSection ) xlistliteral , document );
566- } else if (xlistliteral instanceof EObject ) {
567- _format (( EObject ) xlistliteral , document );
568- } else if (xlistliteral == null ) {
467+ public void format (final Object element , final IFormattableDocument document ) {
468+ if (element instanceof JvmTypeParameter jvmTypeParameter ) {
469+ _format (jvmTypeParameter , document );
470+ } else if (element instanceof JvmFormalParameter jvmFormalParameter ) {
471+ _format (jvmFormalParameter , document );
472+ } else if (element instanceof XtextResource xtextResource ) {
473+ _format (xtextResource , document );
474+ } else if (element instanceof XAssignment xAssignment ) {
475+ _format (xAssignment , document );
476+ } else if (element instanceof XBinaryOperation xBinaryOperation ) {
477+ _format (xBinaryOperation , document );
478+ } else if (element instanceof XDoWhileExpression xDoWhileExpression ) {
479+ _format (xDoWhileExpression , document );
480+ } else if (element instanceof XFeatureCall xFeatureCall ) {
481+ _format (xFeatureCall , document );
482+ } else if (element instanceof XListLiteral xListLiteral ) {
483+ _format (xListLiteral , document );
484+ } else if (element instanceof XMemberFeatureCall xMemberFeatureCall ) {
485+ _format (xMemberFeatureCall , document );
486+ } else if (element instanceof XPostfixOperation xPostfixOperation ) {
487+ _format (xPostfixOperation , document );
488+ } else if (element instanceof XUnaryOperation xUnaryOperation ) {
489+ _format (xUnaryOperation , document );
490+ } else if (element instanceof XWhileExpression xWhileExpression ) {
491+ _format (xWhileExpression , document );
492+ } else if (element instanceof XFunctionTypeRef xFunctionTypeRef ) {
493+ _format (xFunctionTypeRef , document );
494+ } else if (element instanceof Category category ) {
495+ _format (category , document );
496+ } else if (element instanceof Check check ) {
497+ _format (check , document );
498+ } else if (element instanceof CheckCatalog checkCatalog ) {
499+ _format (checkCatalog , document );
500+ } else if (element instanceof Context context ) {
501+ _format (context , document );
502+ } else if (element instanceof Implementation implementation ) {
503+ _format (implementation , document );
504+ } else if (element instanceof Member member ) {
505+ _format (member , document );
506+ } else if (element instanceof XGuardExpression xGuardExpression ) {
507+ _format (xGuardExpression , document );
508+ } else if (element instanceof XIssueExpression xIssueExpression ) {
509+ _format (xIssueExpression , document );
510+ } else if (element instanceof JvmGenericArrayTypeReference jvmGenericArrayTypeReference ) {
511+ _format (jvmGenericArrayTypeReference , document );
512+ } else if (element instanceof JvmParameterizedTypeReference jvmParameterizedTypeReference ) {
513+ _format (jvmParameterizedTypeReference , document );
514+ } else if (element instanceof JvmWildcardTypeReference jvmWildcardTypeReference ) {
515+ _format (jvmWildcardTypeReference , document );
516+ } else if (element instanceof XBasicForLoopExpression xBasicForLoopExpression ) {
517+ _format (xBasicForLoopExpression , document );
518+ } else if (element instanceof XBlockExpression xBlockExpression ) {
519+ _format (xBlockExpression , document );
520+ } else if (element instanceof XCastedExpression xCastedExpression ) {
521+ _format (xCastedExpression , document );
522+ } else if (element instanceof XClosure xClosure ) {
523+ _format (xClosure , document );
524+ } else if (element instanceof XCollectionLiteral xCollectionLiteral ) {
525+ _format (xCollectionLiteral , document );
526+ } else if (element instanceof XConstructorCall xConstructorCall ) {
527+ _format (xConstructorCall , document );
528+ } else if (element instanceof XForLoopExpression xForLoopExpression ) {
529+ _format (xForLoopExpression , document );
530+ } else if (element instanceof XIfExpression xIfExpression ) {
531+ _format (xIfExpression , document );
532+ } else if (element instanceof XInstanceOfExpression xInstanceOfExpression ) {
533+ _format (xInstanceOfExpression , document );
534+ } else if (element instanceof XReturnExpression xReturnExpression ) {
535+ _format (xReturnExpression , document );
536+ } else if (element instanceof XSwitchExpression xSwitchExpression ) {
537+ _format (xSwitchExpression , document );
538+ } else if (element instanceof XSynchronizedExpression xSynchronizedExpression ) {
539+ _format (xSynchronizedExpression , document );
540+ } else if (element instanceof XThrowExpression xThrowExpression ) {
541+ _format (xThrowExpression , document );
542+ } else if (element instanceof XTryCatchFinallyExpression xTryCatchFinallyExpression ) {
543+ _format (xTryCatchFinallyExpression , document );
544+ } else if (element instanceof XTypeLiteral xTypeLiteral ) {
545+ _format (xTypeLiteral , document );
546+ } else if (element instanceof XVariableDeclaration xVariableDeclaration ) {
547+ _format (xVariableDeclaration , document );
548+ } else if (element instanceof XAnnotation xAnnotation ) {
549+ _format (xAnnotation , document );
550+ } else if (element instanceof ContextVariable contextVariable ) {
551+ _format (contextVariable , document );
552+ } else if (element instanceof FormalParameter formalParameter ) {
553+ _format (formalParameter , document );
554+ } else if (element instanceof SeverityRange severityRange ) {
555+ _format (severityRange , document );
556+ } else if (element instanceof JvmTypeConstraint jvmTypeConstraint ) {
557+ _format (jvmTypeConstraint , document );
558+ } else if (element instanceof XExpression xExpression ) {
559+ _format (xExpression , document );
560+ } else if (element instanceof XImportDeclaration xImportDeclaration ) {
561+ _format (xImportDeclaration , document );
562+ } else if (element instanceof XImportSection xImportSection ) {
563+ _format (xImportSection , document );
564+ } else if (element instanceof EObject eObject ) {
565+ _format (eObject , document );
566+ } else if (element == null ) {
569567 _format ((Void ) null , document );
570- } else if (xlistliteral != null ) {
571- _format (xlistliteral , document );
572568 } else {
573- throw new IllegalArgumentException ("Unhandled parameter types: "
574- + Arrays .<Object >asList (xlistliteral , document ).toString ());
569+ _format (element , document );
575570 }
576571 }
577572}
0 commit comments