1111package com .avaloq .tools .ddk .check .formatting2 ;
1212
1313import org .eclipse .emf .ecore .EObject ;
14- import org .eclipse .xtext .Keyword ;
1514import org .eclipse .xtext .common .types .JvmFormalParameter ;
1615import org .eclipse .xtext .common .types .JvmGenericArrayTypeReference ;
1716import org .eclipse .xtext .common .types .JvmParameterizedTypeReference ;
1817import org .eclipse .xtext .common .types .JvmTypeConstraint ;
1918import org .eclipse .xtext .common .types .JvmTypeParameter ;
2019import org .eclipse .xtext .common .types .JvmWildcardTypeReference ;
2120import org .eclipse .xtext .formatting2 .IFormattableDocument ;
22- import org .eclipse .xtext .formatting2 .IHiddenRegionFormatter ;
2321import org .eclipse .xtext .formatting2 .regionaccess .IEObjectRegion ;
2422import org .eclipse .xtext .formatting2 .regionaccess .ISemanticRegion ;
2523import org .eclipse .xtext .resource .XtextResource ;
@@ -88,15 +86,15 @@ private void formatCurlyBracket(final EObject semanticElement, final IFormattabl
8886 // low priority so that it can be overridden by other custom formatting rules.
8987 final ISemanticRegion open = regionFor (semanticElement ).keyword ("{" );
9088 final ISemanticRegion close = regionFor (semanticElement ).keyword ("}" );
91- document .interior (open , close , ( IHiddenRegionFormatter it ) -> {
89+ document .interior (open , close , it -> {
9290 it .lowPriority ();
9391 it .indent ();
9492 });
95- document .append (open , ( IHiddenRegionFormatter it ) -> {
93+ document .append (open , it -> {
9694 it .lowPriority ();
9795 it .newLine ();
9896 });
99- document .prepend (close , ( IHiddenRegionFormatter it ) -> {
97+ document .prepend (close , it -> {
10098 it .lowPriority ();
10199 it .newLine ();
102100 });
@@ -117,13 +115,13 @@ private void globalFormatting(final IEObjectRegion requestRoot, final IFormattab
117115 boolean firstRegion = true ;
118116 for (final ISemanticRegion region : requestRoot .getAllSemanticRegions ()) {
119117 if (firstRegion ) {
120- document .prepend (region , ( IHiddenRegionFormatter it ) -> {
118+ document .prepend (region , it -> {
121119 it .lowPriority ();
122120 it .autowrap (132 );
123121 });
124122 firstRegion = false ;
125123 } else {
126- document .prepend (region , ( IHiddenRegionFormatter it ) -> {
124+ document .prepend (region , it -> {
127125 it .lowPriority ();
128126 it .oneSpace ();
129127 it .autowrap (132 );
@@ -134,27 +132,27 @@ private void globalFormatting(final IEObjectRegion requestRoot, final IFormattab
134132 // CHECKSTYLE:CHECK-ON MagicNumber
135133
136134 protected void _format (final CheckCatalog checkcatalog , final IFormattableDocument document ) {
137- document .prepend (checkcatalog , ( IHiddenRegionFormatter it ) -> {
135+ document .prepend (checkcatalog , it -> {
138136 it .noSpace ();
139137 it .setNewLines (0 );
140138 });
141- document .append (checkcatalog , ( IHiddenRegionFormatter it ) -> {
139+ document .append (checkcatalog , it -> {
142140 it .noSpace ();
143141 it .setNewLines (0 , 0 , 1 );
144142 });
145143 final ISemanticRegion finalKw = regionFor (checkcatalog ).keyword ("final" );
146144 final ISemanticRegion catalog = regionFor (checkcatalog ).keyword ("catalog" );
147145 if (finalKw != null ) {
148- document .prepend (finalKw , ( IHiddenRegionFormatter it ) -> {
146+ document .prepend (finalKw , it -> {
149147 it .setNewLines (1 , 2 , 2 );
150148 });
151149 } else {
152- document .prepend (catalog , ( IHiddenRegionFormatter it ) -> {
150+ document .prepend (catalog , it -> {
153151 it .setNewLines (1 , 1 , 2 );
154152 });
155153 }
156154 final ISemanticRegion forKw = regionFor (checkcatalog ).keyword ("for" );
157- document .prepend (forKw , ( IHiddenRegionFormatter it ) -> {
155+ document .prepend (forKw , it -> {
158156 it .setNewLines (1 , 1 , 2 );
159157 });
160158 formatCurlyBracket (checkcatalog , document );
@@ -186,7 +184,7 @@ protected void _format(final XImportSection ximportsection, final IFormattableDo
186184 // Generated model traversal
187185 for (final XImportDeclaration importDeclarations : ximportsection .getImportDeclarations ()) {
188186 // ADDED: formatting added before each import
189- document .prepend (importDeclarations , ( IHiddenRegionFormatter it ) -> {
187+ document .prepend (importDeclarations , it -> {
190188 it .setNewLines (1 , 1 , 2 );
191189 });
192190
@@ -195,7 +193,7 @@ protected void _format(final XImportSection ximportsection, final IFormattableDo
195193 }
196194
197195 protected void _format (final Category category , final IFormattableDocument document ) {
198- document .prepend (category , ( IHiddenRegionFormatter it ) -> {
196+ document .prepend (category , it -> {
199197 it .setNewLines (1 , 2 , 2 );
200198 });
201199 formatCurlyBracket (category , document );
@@ -207,17 +205,17 @@ protected void _format(final Category category, final IFormattableDocument docum
207205 }
208206
209207 protected void _format (final Check check , final IFormattableDocument document ) {
210- document .prepend (check , ( IHiddenRegionFormatter it ) -> {
208+ document .prepend (check , it -> {
211209 it .setNewLines (1 , 2 , 2 );
212210 });
213211 final ISemanticRegion open = regionFor (check ).keyword ("(" );
214212 final ISemanticRegion close = regionFor (check ).keyword (")" );
215- document .interior (open , close , ( IHiddenRegionFormatter it ) -> {
213+ document .interior (open , close , it -> {
216214 it .highPriority ();
217215 it .noSpace ();
218216 }); // High priority to override formatting from adjacent regions and parent formatter.
219217 final ISemanticRegion message = regionFor (check ).keyword ("message" );
220- document .prepend (message , ( IHiddenRegionFormatter it ) -> {
218+ document .prepend (message , it -> {
221219 it .setNewLines (1 , 1 , 2 );
222220 });
223221 formatCurlyBracket (check , document );
@@ -228,11 +226,11 @@ protected void _format(final Check check, final IFormattableDocument document) {
228226 // ADDED: formatting added around comma.
229227 // High priority to override formatting from adjacent regions and parent formatter.
230228 final ISemanticRegion comma = immediatelyFollowing (formalParameters ).keyword ("," );
231- document .prepend (comma , ( IHiddenRegionFormatter it ) -> {
229+ document .prepend (comma , it -> {
232230 it .highPriority ();
233231 it .noSpace ();
234232 });
235- document .append (comma , ( IHiddenRegionFormatter it ) -> {
233+ document .append (comma , it -> {
236234 it .highPriority ();
237235 it .setNewLines (0 , 0 , 1 );
238236 });
@@ -246,18 +244,18 @@ protected void _format(final Check check, final IFormattableDocument document) {
246244
247245 protected void _format (final SeverityRange severityrange , final IFormattableDocument document ) {
248246 final ISemanticRegion range = regionFor (severityrange ).keyword ("SeverityRange" );
249- document .surround (range , ( IHiddenRegionFormatter it ) -> {
247+ document .surround (range , it -> {
250248 it .noSpace ();
251249 });
252250 final ISemanticRegion open = regionFor (severityrange ).keyword ("(" );
253- document .append (open , ( IHiddenRegionFormatter it ) -> {
251+ document .append (open , it -> {
254252 it .noSpace ();
255253 });
256254 final ISemanticRegion close = regionFor (severityrange ).keyword (")" );
257- document .prepend (close , ( IHiddenRegionFormatter it ) -> {
255+ document .prepend (close , it -> {
258256 it .noSpace ();
259257 });
260- document .append (close , ( IHiddenRegionFormatter it ) -> {
258+ document .append (close , it -> {
261259 it .newLine ();
262260 });
263261 }
@@ -272,7 +270,7 @@ protected void _format(final Member member, final IFormattableDocument document)
272270 }
273271
274272 protected void _format (final Implementation implementation , final IFormattableDocument document ) {
275- document .prepend (implementation , ( IHiddenRegionFormatter it ) -> {
273+ document .prepend (implementation , it -> {
276274 it .setNewLines (1 , 2 , 2 );
277275 });
278276
@@ -299,7 +297,7 @@ protected void _format(final XListLiteral xlistliteral, final IFormattableDocume
299297 }
300298
301299 protected void _format (final Context context , final IFormattableDocument document ) {
302- document .surround (context , ( IHiddenRegionFormatter it ) -> {
300+ document .surround (context , it -> {
303301 it .setNewLines (1 , 2 , 2 );
304302 });
305303
@@ -314,7 +312,7 @@ protected void _format(final ContextVariable contextvariable, final IFormattable
314312 }
315313
316314 protected void _format (final XGuardExpression xguardexpression , final IFormattableDocument document ) {
317- document .prepend (xguardexpression , ( IHiddenRegionFormatter it ) -> {
315+ document .prepend (xguardexpression , it -> {
318316 it .setNewLines (1 , 2 , 2 );
319317 });
320318
@@ -324,37 +322,37 @@ protected void _format(final XGuardExpression xguardexpression, final IFormattab
324322
325323 protected void _format (final XIssueExpression xissueexpression , final IFormattableDocument document ) {
326324 // High priority to override formatting from adjacent regions and parent formatter.
327- document .prepend (xissueexpression , ( IHiddenRegionFormatter it ) -> {
325+ document .prepend (xissueexpression , it -> {
328326 it .highPriority ();
329327 it .setNewLines (1 , 2 , 2 );
330328 });
331- checkGrammarAccess .getXIssueExpressionAccess ().findKeywords ("#" ).forEach (( Keyword kw ) -> {
329+ checkGrammarAccess .getXIssueExpressionAccess ().findKeywords ("#" ).forEach (kw -> {
332330 final ISemanticRegion hash = regionFor (xissueexpression ).keyword (kw );
333- document .surround (hash , ( IHiddenRegionFormatter it ) -> {
331+ document .surround (hash , it -> {
334332 it .highPriority ();
335333 it .noSpace ();
336334 });
337335 });
338336 final ISemanticRegion openSquare = regionFor (xissueexpression ).keyword ("[" );
339- document .surround (openSquare , ( IHiddenRegionFormatter it ) -> {
337+ document .surround (openSquare , it -> {
340338 it .highPriority ();
341339 it .noSpace ();
342340 });
343341 final ISemanticRegion closeSquare = regionFor (xissueexpression ).keyword ("]" );
344- document .prepend (closeSquare , ( IHiddenRegionFormatter it ) -> {
342+ document .prepend (closeSquare , it -> {
345343 it .highPriority ();
346344 it .noSpace ();
347345 });
348- checkGrammarAccess .getXIssueExpressionAccess ().findKeywords ("(" ).forEach (( Keyword kw ) -> {
346+ checkGrammarAccess .getXIssueExpressionAccess ().findKeywords ("(" ).forEach (kw -> {
349347 final ISemanticRegion open = regionFor (xissueexpression ).keyword (kw );
350- document .append (open , ( IHiddenRegionFormatter it ) -> {
348+ document .append (open , it -> {
351349 it .highPriority ();
352350 it .noSpace ();
353351 });
354352 });
355- checkGrammarAccess .getXIssueExpressionAccess ().findKeywords (")" ).forEach (( Keyword kw ) -> {
353+ checkGrammarAccess .getXIssueExpressionAccess ().findKeywords (")" ).forEach (kw -> {
356354 final ISemanticRegion close = regionFor (xissueexpression ).keyword (kw );
357- document .prepend (close , ( IHiddenRegionFormatter it ) -> {
355+ document .prepend (close , it -> {
358356 it .highPriority ();
359357 it .noSpace ();
360358 });
@@ -367,11 +365,11 @@ protected void _format(final XIssueExpression xissueexpression, final IFormattab
367365 for (final XExpression messageParameters : xissueexpression .getMessageParameters ()) {
368366 // ADDED: formatting added around comma
369367 final ISemanticRegion comma = immediatelyFollowing (messageParameters ).keyword ("," );
370- document .prepend (comma , ( IHiddenRegionFormatter it ) -> {
368+ document .prepend (comma , it -> {
371369 it .highPriority ();
372370 it .noSpace ();
373371 });
374- document .append (comma , ( IHiddenRegionFormatter it ) -> {
372+ document .append (comma , it -> {
375373 it .highPriority ();
376374 it .oneSpace ();
377375 });
@@ -381,11 +379,11 @@ protected void _format(final XIssueExpression xissueexpression, final IFormattab
381379 for (final XExpression issueData : xissueexpression .getIssueData ()) {
382380 // ADDED: formatting added around comma
383381 final ISemanticRegion comma = immediatelyFollowing (issueData ).keyword ("," );
384- document .prepend (comma , ( IHiddenRegionFormatter it ) -> {
382+ document .prepend (comma , it -> {
385383 it .highPriority ();
386384 it .noSpace ();
387385 });
388- document .append (comma , ( IHiddenRegionFormatter it ) -> {
386+ document .append (comma , it -> {
389387 it .highPriority ();
390388 it .oneSpace ();
391389 });
@@ -397,31 +395,31 @@ protected void _format(final XIssueExpression xissueexpression, final IFormattab
397395 @ Override
398396 protected void _format (final XIfExpression xifexpression , final IFormattableDocument document ) {
399397 // High priority to override formatting from adjacent regions and parent formatter.
400- document .prepend (xifexpression , ( IHiddenRegionFormatter it ) -> {
398+ document .prepend (xifexpression , it -> {
401399 it .highPriority ();
402400 it .setNewLines (1 , 1 , 2 );
403401 });
404402 final ISemanticRegion open = regionFor (xifexpression ).keyword ("(" );
405403 final ISemanticRegion close = regionFor (xifexpression ).keyword (")" );
406- document .prepend (open , ( IHiddenRegionFormatter it ) -> {
404+ document .prepend (open , it -> {
407405 it .highPriority ();
408406 it .oneSpace ();
409407 });
410- document .append (open , ( IHiddenRegionFormatter it ) -> {
408+ document .append (open , it -> {
411409 it .highPriority ();
412410 it .noSpace ();
413411 });
414- document .prepend (close , ( IHiddenRegionFormatter it ) -> {
412+ document .prepend (close , it -> {
415413 it .highPriority ();
416414 it .noSpace ();
417415 });
418- document .append (close , ( IHiddenRegionFormatter it ) -> {
416+ document .append (close , it -> {
419417 it .highPriority ();
420418 it .setNewLines (0 );
421419 it .oneSpace ();
422420 });
423421 final ISemanticRegion elseKw = regionFor (xifexpression ).keyword ("else" );
424- document .surround (elseKw , ( IHiddenRegionFormatter it ) -> {
422+ document .surround (elseKw , it -> {
425423 it .highPriority ();
426424 it .setNewLines (0 );
427425 it .oneSpace ();
@@ -435,23 +433,23 @@ protected void _format(final XIfExpression xifexpression, final IFormattableDocu
435433 protected void _format (final XMemberFeatureCall xfeaturecall , final IFormattableDocument document ) {
436434 // set no space after '::' in CheckUtil::hasQualifiedName(..., and also not after plain "." or "?."
437435 // High priority to override formatting from adjacent regions and parent formatter.
438- checkGrammarAccess .getXMemberFeatureCallAccess ().findKeywords ("." ).forEach (( Keyword kw ) -> {
436+ checkGrammarAccess .getXMemberFeatureCallAccess ().findKeywords ("." ).forEach (kw -> {
439437 final ISemanticRegion dot = regionFor (xfeaturecall ).keyword (kw );
440- document .append (dot , ( IHiddenRegionFormatter it ) -> {
438+ document .append (dot , it -> {
441439 it .highPriority ();
442440 it .noSpace ();
443441 });
444442 });
445- checkGrammarAccess .getXMemberFeatureCallAccess ().findKeywords ("?." ).forEach (( Keyword kw ) -> {
443+ checkGrammarAccess .getXMemberFeatureCallAccess ().findKeywords ("?." ).forEach (kw -> {
446444 final ISemanticRegion queryDot = regionFor (xfeaturecall ).keyword (kw );
447- document .append (queryDot , ( IHiddenRegionFormatter it ) -> {
445+ document .append (queryDot , it -> {
448446 it .highPriority ();
449447 it .noSpace ();
450448 });
451449 });
452- checkGrammarAccess .getXMemberFeatureCallAccess ().findKeywords ("::" ).forEach (( Keyword kw ) -> {
450+ checkGrammarAccess .getXMemberFeatureCallAccess ().findKeywords ("::" ).forEach (kw -> {
453451 final ISemanticRegion colonColon = regionFor (xfeaturecall ).keyword (kw );
454- document .append (colonColon , ( IHiddenRegionFormatter it ) -> {
452+ document .append (colonColon , it -> {
455453 it .highPriority ();
456454 it .noSpace ();
457455 });
0 commit comments