Package: EmfParsleyDslFormatter$34$4

EmfParsleyDslFormatter$34$4

nameinstructionbranchcomplexitylinemethod
apply(IHiddenRegionFormatter)
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
{...}
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%

Coverage

1: /**
2: * Copyright (c) 2015 RCP Vision (http://www.rcp-vision.com) and others.
3: * All rights reserved. This program and the accompanying materials
4: * are made available under the terms of the Eclipse Public License v1.0
5: * which accompanies this distribution, and is available at
6: * http://www.eclipse.org/legal/epl-v10.html
7: *
8: * Contributors:
9: * Lorenzo Bettini - initial API and implementation
10: */
11: package org.eclipse.emf.parsley.dsl.formatting2;
12:
13: import com.google.inject.Provider;
14: import java.util.List;
15: import org.eclipse.emf.common.util.EList;
16: import org.eclipse.emf.ecore.EObject;
17: import org.eclipse.emf.parsley.dsl.model.AbstractControlFactory;
18: import org.eclipse.emf.parsley.dsl.model.AbstractFeatureCaptionProviderWithLabel;
19: import org.eclipse.emf.parsley.dsl.model.AbstractFeatureProvider;
20: import org.eclipse.emf.parsley.dsl.model.Binding;
21: import org.eclipse.emf.parsley.dsl.model.BindingsSpecification;
22: import org.eclipse.emf.parsley.dsl.model.Configurator;
23: import org.eclipse.emf.parsley.dsl.model.ControlFactorySpecification;
24: import org.eclipse.emf.parsley.dsl.model.ExtendsClause;
25: import org.eclipse.emf.parsley.dsl.model.FeatureAssociatedExpression;
26: import org.eclipse.emf.parsley.dsl.model.FeatureCaptionProvider;
27: import org.eclipse.emf.parsley.dsl.model.FeatureSpecification;
28: import org.eclipse.emf.parsley.dsl.model.FieldSpecification;
29: import org.eclipse.emf.parsley.dsl.model.LabelProvider;
30: import org.eclipse.emf.parsley.dsl.model.MenuBuilder;
31: import org.eclipse.emf.parsley.dsl.model.Model;
32: import org.eclipse.emf.parsley.dsl.model.ModelPackage;
33: import org.eclipse.emf.parsley.dsl.model.PartSpecification;
34: import org.eclipse.emf.parsley.dsl.model.PartsSpecifications;
35: import org.eclipse.emf.parsley.dsl.model.PolymorphicSpecification;
36: import org.eclipse.emf.parsley.dsl.model.ProposalCreator;
37: import org.eclipse.emf.parsley.dsl.model.ProviderBinding;
38: import org.eclipse.emf.parsley.dsl.model.ResourceManager;
39: import org.eclipse.emf.parsley.dsl.model.SimpleMethodSpecification;
40: import org.eclipse.emf.parsley.dsl.model.TableLabelProvider;
41: import org.eclipse.emf.parsley.dsl.model.TableViewerContentProvider;
42: import org.eclipse.emf.parsley.dsl.model.TypeBinding;
43: import org.eclipse.emf.parsley.dsl.model.ValueBinding;
44: import org.eclipse.emf.parsley.dsl.model.ViewSpecification;
45: import org.eclipse.emf.parsley.dsl.model.ViewerContentProvider;
46: import org.eclipse.emf.parsley.dsl.model.WithExpressions;
47: import org.eclipse.emf.parsley.dsl.model.WithExtendsClause;
48: import org.eclipse.emf.parsley.dsl.model.WithFeatureAssociatedExpressions;
49: import org.eclipse.emf.parsley.dsl.model.WithFields;
50: import org.eclipse.xtext.common.types.JvmTypeReference;
51: import org.eclipse.xtext.formatting2.IFormattableDocument;
52: import org.eclipse.xtext.formatting2.IHiddenRegionFormatter;
53: import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion;
54: import org.eclipse.xtext.xbase.XExpression;
55: import org.eclipse.xtext.xbase.annotations.formatting2.XbaseWithAnnotationsFormatter;
56: import org.eclipse.xtext.xbase.annotations.xAnnotations.XAnnotation;
57: import org.eclipse.xtext.xbase.lib.Extension;
58: import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
59:
60: /**
61: * @author Lorenzo Bettini
62: */
63: @SuppressWarnings("all")
64: public class EmfParsleyDslFormatter extends XbaseWithAnnotationsFormatter {
65: @Override
66: public void format(final Object o, final IFormattableDocument document) {
67: if ((o instanceof AbstractControlFactory)) {
68: this._format(((AbstractControlFactory)o), document);
69: return;
70: } else {
71: if ((o instanceof AbstractFeatureCaptionProviderWithLabel)) {
72: this._format(((AbstractFeatureCaptionProviderWithLabel)o), document);
73: return;
74: } else {
75: if ((o instanceof AbstractFeatureProvider)) {
76: this._format(((AbstractFeatureProvider)o), document);
77: return;
78: } else {
79: if ((o instanceof Configurator)) {
80: this._format(((Configurator)o), document);
81: return;
82: } else {
83: if ((o instanceof FeatureCaptionProvider)) {
84: this._format(((FeatureCaptionProvider)o), document);
85: return;
86: } else {
87: if ((o instanceof LabelProvider)) {
88: this._format(((LabelProvider)o), document);
89: return;
90: } else {
91: if ((o instanceof MenuBuilder)) {
92: this._format(((MenuBuilder)o), document);
93: return;
94: } else {
95: if ((o instanceof ProposalCreator)) {
96: this._format(((ProposalCreator)o), document);
97: return;
98: } else {
99: if ((o instanceof ResourceManager)) {
100: this._format(((ResourceManager)o), document);
101: return;
102: } else {
103: if ((o instanceof TableLabelProvider)) {
104: this._format(((TableLabelProvider)o), document);
105: return;
106: } else {
107: if ((o instanceof TableViewerContentProvider)) {
108: this._format(((TableViewerContentProvider)o), document);
109: return;
110: } else {
111: if ((o instanceof ViewerContentProvider)) {
112: this._format(((ViewerContentProvider)o), document);
113: return;
114: } else {
115: if ((o instanceof ControlFactorySpecification)) {
116: this._format(((ControlFactorySpecification)o), document);
117: return;
118: } else {
119: if ((o instanceof FeatureAssociatedExpression)) {
120: this._format(((FeatureAssociatedExpression)o), document);
121: return;
122: } else {
123: if ((o instanceof FeatureSpecification)) {
124: this._format(((FeatureSpecification)o), document);
125: return;
126: } else {
127: if ((o instanceof org.eclipse.emf.parsley.dsl.model.Module)) {
128: this._format(((org.eclipse.emf.parsley.dsl.model.Module)o), document);
129: return;
130: } else {
131: if ((o instanceof ProviderBinding)) {
132: this._format(((ProviderBinding)o), document);
133: return;
134: } else {
135: if ((o instanceof TypeBinding)) {
136: this._format(((TypeBinding)o), document);
137: return;
138: } else {
139: if ((o instanceof ValueBinding)) {
140: this._format(((ValueBinding)o), document);
141: return;
142: } else {
143: if ((o instanceof ViewSpecification)) {
144: this._format(((ViewSpecification)o), document);
145: return;
146: } else {
147: if ((o instanceof BindingsSpecification)) {
148: this._format(((BindingsSpecification)o), document);
149: return;
150: } else {
151: if ((o instanceof ExtendsClause)) {
152: this._format(((ExtendsClause)o), document);
153: return;
154: } else {
155: if ((o instanceof FieldSpecification)) {
156: this._format(((FieldSpecification)o), document);
157: return;
158: } else {
159: if ((o instanceof PolymorphicSpecification)) {
160: this._format(((PolymorphicSpecification)o), document);
161: return;
162: } else {
163: if ((o instanceof Model)) {
164: this._format(((Model)o), document);
165: return;
166: } else {
167: if ((o instanceof PartsSpecifications)) {
168: this._format(((PartsSpecifications)o), document);
169: return;
170: } else {
171: if ((o instanceof SimpleMethodSpecification)) {
172: this._format(((SimpleMethodSpecification)o), document);
173: return;
174: } else {
175: super.format(o, document);
176: }
177: }
178: }
179: }
180: }
181: }
182: }
183: }
184: }
185: }
186: }
187: }
188: }
189: }
190: }
191: }
192: }
193: }
194: }
195: }
196: }
197: }
198: }
199: }
200: }
201: }
202: }
203: }
204:
205: public void _format(final Model model, @Extension final IFormattableDocument document) {
206: this.format(model.getImportSection(), document);
207: this.format(model.getModule(), document);
208: }
209:
210: public void _format(final org.eclipse.emf.parsley.dsl.model.Module module, @Extension final IFormattableDocument document) {
211: final Procedure1<org.eclipse.emf.parsley.dsl.model.Module> _function = new Procedure1<org.eclipse.emf.parsley.dsl.model.Module>() {
212: @Override
213: public void apply(final org.eclipse.emf.parsley.dsl.model.Module it) {
214: EmfParsleyDslFormatter.this.format(module.getExtendsClause(), document);
215: EmfParsleyDslFormatter.this.format(module.getBindingsSpecification(), document);
216: EmfParsleyDslFormatter.this.format(module.getLabelProvider(), document);
217: EmfParsleyDslFormatter.this.format(module.getTableLabelProvider(), document);
218: EmfParsleyDslFormatter.this.format(module.getFeatureCaptionProvider(), document);
219: EmfParsleyDslFormatter.this.format(module.getFormFeatureCaptionProvider(), document);
220: EmfParsleyDslFormatter.this.format(module.getDialogFeatureCaptionProvider(), document);
221: EmfParsleyDslFormatter.this.format(module.getFeaturesProvider(), document);
222: EmfParsleyDslFormatter.this.format(module.getTableFeaturesProvider(), document);
223: EmfParsleyDslFormatter.this.format(module.getFormControlFactory(), document);
224: EmfParsleyDslFormatter.this.format(module.getDialogControlFactory(), document);
225: EmfParsleyDslFormatter.this.format(module.getProposalCreator(), document);
226: EmfParsleyDslFormatter.this.format(module.getMenuBuilder(), document);
227: EmfParsleyDslFormatter.this.format(module.getConfigurator(), document);
228: EmfParsleyDslFormatter.this.format(module.getViewerContentProvider(), document);
229: EmfParsleyDslFormatter.this.format(module.getTableViewerContentProvider(), document);
230: EmfParsleyDslFormatter.this.format(module.getPartsSpecifications(), document);
231: EmfParsleyDslFormatter.this.format(module.getResourceManager(), document);
232: }
233: };
234: this.<org.eclipse.emf.parsley.dsl.model.Module>indentBlock(module, document, _function);
235: }
236:
237: public void _format(final ExtendsClause extendsclause, @Extension final IFormattableDocument document) {
238: this.format(extendsclause.getSuperType(), document);
239: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
240: @Override
241: public void apply(final IHiddenRegionFormatter it) {
242: it.oneSpace();
243: }
244: };
245: document.surround(this.textRegionExtensions.regionFor(extendsclause).keyword("extends"), _function);
246: }
247:
248: public void _format(final BindingsSpecification bindingsspecification, @Extension final IFormattableDocument document) {
249: final Procedure1<BindingsSpecification> _function = new Procedure1<BindingsSpecification>() {
250: @Override
251: public void apply(final BindingsSpecification it) {
252: EmfParsleyDslFormatter.this.<Binding>formatAndSeparateElementsWithNewlines(bindingsspecification.getBindings(), document);
253: }
254: };
255: this.<BindingsSpecification>indentBlock(bindingsspecification, document, _function);
256: }
257:
258: public void _format(final TypeBinding typebinding, @Extension final IFormattableDocument document) {
259: this.<TypeBinding>oneSpaceAfterKeyword(typebinding, "type", document);
260: this.format(typebinding.getTypeToBind(), document);
261: this.formatBinding(typebinding, document);
262: }
263:
264: public void _format(final ProviderBinding providerbinding, @Extension final IFormattableDocument document) {
265: this.<ProviderBinding>oneSpaceAfterKeyword(providerbinding, "provide", document);
266: this.format(providerbinding.getType(), document);
267: this.formatBinding(providerbinding, document);
268: }
269:
270: public void _format(final ValueBinding valuebinding, @Extension final IFormattableDocument document) {
271: this.<ValueBinding>oneSpaceAfterKeyword(valuebinding, "value", document);
272: this.format(valuebinding.getTypeDecl(), document);
273: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
274: @Override
275: public void apply(final IHiddenRegionFormatter it) {
276: it.oneSpace();
277: }
278: };
279: document.surround(this.textRegionExtensions.regionFor(valuebinding).feature(ModelPackage.Literals.VALUE_BINDING__ID), _function);
280: this.formatBinding(valuebinding, document);
281: }
282:
283: private void formatBinding(final Binding binding, @Extension final IFormattableDocument document) {
284: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
285: @Override
286: public void apply(final IHiddenRegionFormatter it) {
287: it.oneSpace();
288: }
289: };
290: document.surround(this.textRegionExtensions.regionFor(binding).keyword("->"), _function);
291: this.format(binding.getTo(), document);
292: }
293:
294: public void _format(final LabelProvider labelprovider, @Extension final IFormattableDocument document) {
295: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
296: @Override
297: public void apply(final WithFields it) {
298: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(labelprovider.getTexts(), document);
299: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(labelprovider.getImages(), document);
300: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(labelprovider.getFonts(), document);
301: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(labelprovider.getForegrounds(), document);
302: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(labelprovider.getBackgrounds(), document);
303: }
304: };
305: this.formatWithFields(labelprovider, document, _function);
306: }
307:
308: public void _format(final FieldSpecification expr, @Extension final IFormattableDocument document) {
309: EList<XAnnotation> _annotations = expr.getAnnotations();
310: for (final XAnnotation annotations : _annotations) {
311: this.format(annotations, document);
312: }
313: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
314: @Override
315: public void apply(final IHiddenRegionFormatter it) {
316: it.oneSpace();
317: }
318: };
319: document.append(this.textRegionExtensions.regionFor(expr).keyword("val"), _function);
320: final Procedure1<IHiddenRegionFormatter> _function_1 = new Procedure1<IHiddenRegionFormatter>() {
321: @Override
322: public void apply(final IHiddenRegionFormatter it) {
323: it.oneSpace();
324: }
325: };
326: document.append(this.textRegionExtensions.regionFor(expr).keyword("var"), _function_1);
327: final Procedure1<IHiddenRegionFormatter> _function_2 = new Procedure1<IHiddenRegionFormatter>() {
328: @Override
329: public void apply(final IHiddenRegionFormatter it) {
330: it.oneSpace();
331: }
332: };
333: document.append(this.textRegionExtensions.regionFor(expr).keyword("extension"), _function_2);
334: final Procedure1<IHiddenRegionFormatter> _function_3 = new Procedure1<IHiddenRegionFormatter>() {
335: @Override
336: public void apply(final IHiddenRegionFormatter it) {
337: it.oneSpace();
338: }
339: };
340: document.<JvmTypeReference>append(expr.getType(), _function_3);
341: final Procedure1<IHiddenRegionFormatter> _function_4 = new Procedure1<IHiddenRegionFormatter>() {
342: @Override
343: public void apply(final IHiddenRegionFormatter it) {
344: it.oneSpace();
345: }
346: };
347: document.surround(this.textRegionExtensions.regionFor(expr).keyword("="), _function_4);
348: this.format(expr.getType(), document);
349: this.format(expr.getRight(), document);
350: final Procedure1<IHiddenRegionFormatter> _function_5 = new Procedure1<IHiddenRegionFormatter>() {
351: @Override
352: public void apply(final IHiddenRegionFormatter it) {
353: it.noSpace();
354: }
355: };
356: document.prepend(this.textRegionExtensions.regionFor(expr).keyword(";"), _function_5);
357: }
358:
359: public void _format(final TableLabelProvider tablelabelprovider, @Extension final IFormattableDocument document) {
360: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
361: @Override
362: public void apply(final WithFields it) {
363: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(tablelabelprovider.getFeatureTexts(), document);
364: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(tablelabelprovider.getFeatureImages(), document);
365: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(tablelabelprovider.getFeatureFonts(), document);
366: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(tablelabelprovider.getFeatureForegrounds(), document);
367: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(tablelabelprovider.getFeatureBackgrounds(), document);
368: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(tablelabelprovider.getRowFonts(), document);
369: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(tablelabelprovider.getRowForegrounds(), document);
370: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(tablelabelprovider.getRowBackgrounds(), document);
371: }
372: };
373: this.formatWithFields(tablelabelprovider, document, _function);
374: }
375:
376: public void _format(final PolymorphicSpecification specification, @Extension final IFormattableDocument document) {
377: this.format(specification.getParameterType(), document);
378: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
379: @Override
380: public void apply(final IHiddenRegionFormatter it) {
381: it.oneSpace();
382: }
383: };
384: document.surround(this.textRegionExtensions.regionFor(specification).keyword("->"), _function);
385: this.format(specification.getExpression(), document);
386: }
387:
388: public void _format(final FeatureCaptionProvider featurecaptionprovider, @Extension final IFormattableDocument document) {
389: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
390: @Override
391: public void apply(final WithFields it) {
392: final Provider<List<? extends EObject>> _function = new Provider<List<? extends EObject>>() {
393: @Override
394: public List<? extends EObject> get() {
395: return featurecaptionprovider.getFeatureTexts().getSpecifications();
396: }
397: };
398: EmfParsleyDslFormatter.this.<EObject>indentBlockAndFormatAndSeparateElementsWithNewlines(featurecaptionprovider.getFeatureTexts(), document, _function);
399: }
400: };
401: this.formatWithFields(featurecaptionprovider, document, _function);
402: }
403:
404: public void _format(final AbstractFeatureCaptionProviderWithLabel featurecaptionprovider, @Extension final IFormattableDocument document) {
405: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
406: @Override
407: public void apply(final WithFields it) {
408: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(featurecaptionprovider.getFeatureTexts(), document);
409: EmfParsleyDslFormatter.this.<EObject>formatFeatureSpecifications(featurecaptionprovider.getFeatureLabels(), document);
410: }
411: };
412: this.formatWithFields(featurecaptionprovider, document, _function);
413: }
414:
415: public void _format(final FeatureAssociatedExpression featureassociatedexpression, @Extension final IFormattableDocument document) {
416: this.format(featureassociatedexpression.getParameterType(), document);
417: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
418: @Override
419: public void apply(final IHiddenRegionFormatter it) {
420: it.oneSpace();
421: }
422: };
423: document.surround(this.textRegionExtensions.regionFor(featureassociatedexpression).keyword(":"), _function);
424: final Procedure1<IHiddenRegionFormatter> _function_1 = new Procedure1<IHiddenRegionFormatter>() {
425: @Override
426: public void apply(final IHiddenRegionFormatter it) {
427: it.oneSpace();
428: }
429: };
430: document.surround(this.textRegionExtensions.regionFor(featureassociatedexpression).keyword("->"), _function_1);
431: this.format(featureassociatedexpression.getExpression(), document);
432: }
433:
434: public void _format(final AbstractFeatureProvider featuresprovider, @Extension final IFormattableDocument document) {
435: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
436: @Override
437: public void apply(final WithFields it) {
438: final Provider<List<? extends EObject>> _function = new Provider<List<? extends EObject>>() {
439: @Override
440: public List<? extends EObject> get() {
441: return featuresprovider.getFeatures().getFeatureSpecifications();
442: }
443: };
444: EmfParsleyDslFormatter.this.<EObject>indentBlockAndFormatAndSeparateElementsWithNewlines(featuresprovider.getFeatures(), document, _function);
445: }
446: };
447: this.formatWithFields(featuresprovider, document, _function);
448: }
449:
450: public void _format(final FeatureSpecification featurespecification, @Extension final IFormattableDocument document) {
451: this.format(featurespecification.getParameterType(), document);
452: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
453: @Override
454: public void apply(final IHiddenRegionFormatter it) {
455: it.oneSpace();
456: }
457: };
458: document.surround(this.textRegionExtensions.regionFor(featurespecification).keyword("->"), _function);
459: List<ISemanticRegion> _keywords = this.textRegionExtensions.regionFor(featurespecification).keywords(",");
460: for (final ISemanticRegion comma : _keywords) {
461: final Procedure1<IHiddenRegionFormatter> _function_1 = new Procedure1<IHiddenRegionFormatter>() {
462: @Override
463: public void apply(final IHiddenRegionFormatter it) {
464: it.noSpace();
465: }
466: };
467: final Procedure1<IHiddenRegionFormatter> _function_2 = new Procedure1<IHiddenRegionFormatter>() {
468: @Override
469: public void apply(final IHiddenRegionFormatter it) {
470: it.oneSpace();
471: }
472: };
473: document.append(document.prepend(comma, _function_1), _function_2);
474: }
475: }
476:
477: public void _format(final AbstractControlFactory controlfactory, @Extension final IFormattableDocument document) {
478: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
479: @Override
480: public void apply(final WithFields it) {
481: final Provider<List<? extends EObject>> _function = new Provider<List<? extends EObject>>() {
482: @Override
483: public List<? extends EObject> get() {
484: return controlfactory.getControls().getSpecifications();
485: }
486: };
487: EmfParsleyDslFormatter.this.<EObject>indentBlockAndFormatAndSeparateElementsWithNewlines(controlfactory.getControls(), document, _function);
488: }
489: };
490: this.formatWithFields(controlfactory, document, _function);
491: }
492:
493: public void _format(final ControlFactorySpecification controlfactoryspecification, @Extension final IFormattableDocument document) {
494: this.format(controlfactoryspecification.getParameterType(), document);
495: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
496: @Override
497: public void apply(final IHiddenRegionFormatter it) {
498: it.oneSpace();
499: }
500: };
501: document.surround(this.textRegionExtensions.regionFor(controlfactoryspecification).keyword(":"), _function);
502: final Procedure1<IHiddenRegionFormatter> _function_1 = new Procedure1<IHiddenRegionFormatter>() {
503: @Override
504: public void apply(final IHiddenRegionFormatter it) {
505: it.oneSpace();
506: }
507: };
508: document.surround(this.textRegionExtensions.regionFor(controlfactoryspecification).keyword("->"), _function_1);
509: this.format(controlfactoryspecification.getExpression(), document);
510: final Procedure1<IHiddenRegionFormatter> _function_2 = new Procedure1<IHiddenRegionFormatter>() {
511: @Override
512: public void apply(final IHiddenRegionFormatter it) {
513: it.oneSpace();
514: }
515: };
516: document.surround(this.textRegionExtensions.regionFor(controlfactoryspecification).keyword("target"), _function_2);
517: this.format(controlfactoryspecification.getTarget(), document);
518: }
519:
520: public void _format(final ProposalCreator proposalcreator, @Extension final IFormattableDocument document) {
521: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
522: @Override
523: public void apply(final WithFields it) {
524: EmfParsleyDslFormatter.this.<FeatureAssociatedExpression>formatAndSeparateElementsWithNewlines(proposalcreator.getProposalsSpecifications(), document);
525: }
526: };
527: this.formatWithFields(proposalcreator, document, _function);
528: }
529:
530: public void _format(final MenuBuilder menubuilder, @Extension final IFormattableDocument document) {
531: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
532: @Override
533: public void apply(final WithFields it) {
534: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(menubuilder.getMenus(), document);
535: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(menubuilder.getEmfMenus(), document);
536: }
537: };
538: this.formatWithFields(menubuilder, document, _function);
539: }
540:
541: public void _format(final Configurator configurator, @Extension final IFormattableDocument document) {
542: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
543: @Override
544: public void apply(final WithFields it) {
545: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(configurator.getResourceURI(), document);
546: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(configurator.getEClassSpec(), document);
547: }
548: };
549: this.formatWithFields(configurator, document, _function);
550: }
551:
552: public void _format(final ViewerContentProvider viewercontentprovider, @Extension final IFormattableDocument document) {
553: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
554: @Override
555: public void apply(final WithFields it) {
556: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(viewercontentprovider.getElements(), document);
557: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(viewercontentprovider.getChildren(), document);
558: }
559: };
560: this.formatWithFields(viewercontentprovider, document, _function);
561: }
562:
563: public void _format(final TableViewerContentProvider tableviewercontentprovider, @Extension final IFormattableDocument document) {
564: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
565: @Override
566: public void apply(final WithFields it) {
567: EmfParsleyDslFormatter.this.<EObject>formatSpecifications(tableviewercontentprovider.getElements(), document);
568: }
569: };
570: this.formatWithFields(tableviewercontentprovider, document, _function);
571: }
572:
573: public void _format(final ResourceManager resourcemanager, @Extension final IFormattableDocument document) {
574: final Procedure1<WithFields> _function = new Procedure1<WithFields>() {
575: @Override
576: public void apply(final WithFields it) {
577: EmfParsleyDslFormatter.this.format(resourcemanager.getInitializeBody(), document);
578: EmfParsleyDslFormatter.this.format(resourcemanager.getSaveBody(), document);
579: }
580: };
581: this.formatWithFields(resourcemanager, document, _function);
582: }
583:
584: public void _format(final SimpleMethodSpecification simplemethodspecification, @Extension final IFormattableDocument document) {
585: this.<XExpression>formatAndSeparateWithNewlines(simplemethodspecification.getBody(), document);
586: }
587:
588: public void _format(final PartsSpecifications partsspecifications, @Extension final IFormattableDocument document) {
589: final Procedure1<PartsSpecifications> _function = new Procedure1<PartsSpecifications>() {
590: @Override
591: public void apply(final PartsSpecifications it) {
592: EmfParsleyDslFormatter.this.<PartSpecification>formatAndSeparateElementsWithNewlines(partsspecifications.getParts(), document);
593: }
594: };
595: this.<PartsSpecifications>indentBlock(partsspecifications, document, _function);
596: }
597:
598: public void _format(final ViewSpecification viewspecification, @Extension final IFormattableDocument document) {
599: final Procedure1<ViewSpecification> _function = new Procedure1<ViewSpecification>() {
600: @Override
601: public void apply(final ViewSpecification it) {
602: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
603: @Override
604: public void apply(final IHiddenRegionFormatter it) {
605: it.oneSpace();
606: }
607: };
608: document.append(EmfParsleyDslFormatter.this.textRegionExtensions.regionFor(viewspecification).keyword("viewpart"), _function);
609: final Procedure1<IHiddenRegionFormatter> _function_1 = new Procedure1<IHiddenRegionFormatter>() {
610: @Override
611: public void apply(final IHiddenRegionFormatter it) {
612: it.oneSpace();
613: }
614: };
615: document.append(EmfParsleyDslFormatter.this.textRegionExtensions.regionFor(viewspecification).keyword("viewname"), _function_1);
616: final Procedure1<IHiddenRegionFormatter> _function_2 = new Procedure1<IHiddenRegionFormatter>() {
617: @Override
618: public void apply(final IHiddenRegionFormatter it) {
619: it.setNewLines(1, 1, 2);
620: }
621: };
622: document.append(EmfParsleyDslFormatter.this.textRegionExtensions.regionFor(viewspecification).feature(ModelPackage.Literals.VIEW_SPECIFICATION__VIEW_NAME), _function_2);
623: final Procedure1<IHiddenRegionFormatter> _function_3 = new Procedure1<IHiddenRegionFormatter>() {
624: @Override
625: public void apply(final IHiddenRegionFormatter it) {
626: it.oneSpace();
627: }
628: };
629: document.append(EmfParsleyDslFormatter.this.textRegionExtensions.regionFor(viewspecification).keyword("viewclass"), _function_3);
630: EmfParsleyDslFormatter.this.format(viewspecification.getType(), document);
631: final Procedure1<IHiddenRegionFormatter> _function_4 = new Procedure1<IHiddenRegionFormatter>() {
632: @Override
633: public void apply(final IHiddenRegionFormatter it) {
634: it.setNewLines(1, 1, 2);
635: }
636: };
637: document.<JvmTypeReference>append(viewspecification.getType(), _function_4);
638: String _category = viewspecification.getCategory();
639: boolean _tripleNotEquals = (_category != null);
640: if (_tripleNotEquals) {
641: final Procedure1<IHiddenRegionFormatter> _function_5 = new Procedure1<IHiddenRegionFormatter>() {
642: @Override
643: public void apply(final IHiddenRegionFormatter it) {
644: it.oneSpace();
645: }
646: };
647: document.append(EmfParsleyDslFormatter.this.textRegionExtensions.regionFor(viewspecification).keyword("viewcategory"), _function_5);
648: final Procedure1<IHiddenRegionFormatter> _function_6 = new Procedure1<IHiddenRegionFormatter>() {
649: @Override
650: public void apply(final IHiddenRegionFormatter it) {
651: it.setNewLines(1, 1, 2);
652: }
653: };
654: document.append(EmfParsleyDslFormatter.this.textRegionExtensions.regionFor(viewspecification).feature(ModelPackage.Literals.VIEW_SPECIFICATION__CATEGORY), _function_6);
655: }
656: }
657: };
658: this.<ViewSpecification>indentBlock(viewspecification, document, _function);
659: }
660:
661: private WithExtendsClause formatWithFields(final WithFields e, @Extension final IFormattableDocument document, final Procedure1<? super WithFields> elementsFormatter) {
662: final Procedure1<WithExtendsClause> _function = new Procedure1<WithExtendsClause>() {
663: @Override
664: public void apply(final WithExtendsClause it) {
665: EmfParsleyDslFormatter.this.formatFields(e, document);
666: elementsFormatter.apply(e);
667: }
668: };
669: return this.formatWithExtendsClause(e, document, _function);
670: }
671:
672: private WithExtendsClause formatWithExtendsClause(final WithExtendsClause e, @Extension final IFormattableDocument document, final Procedure1<? super WithExtendsClause> elementsFormatter) {
673: WithExtendsClause _xblockexpression = null;
674: {
675: this.format(e.getExtendsClause(), document);
676: final Procedure1<WithExtendsClause> _function = new Procedure1<WithExtendsClause>() {
677: @Override
678: public void apply(final WithExtendsClause it) {
679: elementsFormatter.apply(e);
680: }
681: };
682: this.<WithExtendsClause>indentBlock(e, document, _function);
683: _xblockexpression = this.<WithExtendsClause>separateElementsWithNewlines(e, document);
684: }
685: return _xblockexpression;
686: }
687:
688: private void formatFields(final WithFields withFields, @Extension final IFormattableDocument document) {
689: this.<FieldSpecification>formatAndSeparateElementsWithNewlines(withFields.getFields(), document);
690: }
691:
692: private <T extends EObject> EObject formatSpecifications(final WithExpressions e, @Extension final IFormattableDocument document) {
693: final Provider<List<? extends EObject>> _function = new Provider<List<? extends EObject>>() {
694: @Override
695: public List<? extends EObject> get() {
696: return e.getSpecifications();
697: }
698: };
699: return this.<EObject>indentBlockAndFormatAndSeparateElementsWithNewlines(e, document, _function);
700: }
701:
702: private <T extends EObject> EObject formatFeatureSpecifications(final WithFeatureAssociatedExpressions e, @Extension final IFormattableDocument document) {
703: final Provider<List<? extends EObject>> _function = new Provider<List<? extends EObject>>() {
704: @Override
705: public List<? extends EObject> get() {
706: return e.getSpecifications();
707: }
708: };
709: return this.<EObject>indentBlockAndFormatAndSeparateElementsWithNewlines(e, document, _function);
710: }
711:
712: /**
713: * The elementsProvider is invoked only if the passed parent is not null
714: */
715: private <T extends EObject> EObject indentBlockAndFormatAndSeparateElementsWithNewlines(final EObject parent, @Extension final IFormattableDocument document, final Provider<List<? extends T>> elementsProvider) {
716: EObject _xifexpression = null;
717: if ((parent != null)) {
718: EObject _xblockexpression = null;
719: {
720: final List<? extends T> list = elementsProvider.get();
721: final Procedure1<EObject> _function = new Procedure1<EObject>() {
722: @Override
723: public void apply(final EObject it) {
724: EmfParsleyDslFormatter.this.<T>formatAndSeparateElementsWithNewlines(list, document);
725: }
726: };
727: this.<EObject>indentBlock(parent, document, _function);
728: _xblockexpression = this.<EObject>separateElementsWithNewlines(parent, document);
729: }
730: _xifexpression = _xblockexpression;
731: }
732: return _xifexpression;
733: }
734:
735: private <T extends EObject> void formatAndSeparateElementsWithNewlines(final List<? extends T> elements, @Extension final IFormattableDocument document) {
736: for (final T e : elements) {
737: this.<T>formatAndSeparateWithNewlines(e, document);
738: }
739: }
740:
741: private <T extends EObject> T formatAndSeparateWithNewlines(final T e, final IFormattableDocument document) {
742: T _xblockexpression = null;
743: {
744: this.format(e, document);
745: _xblockexpression = this.<T>separateElementsWithNewlines(e, document);
746: }
747: return _xblockexpression;
748: }
749:
750: private <T extends EObject> ISemanticRegion oneSpaceAfterKeyword(final T element, final String k, @Extension final IFormattableDocument document) {
751: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
752: @Override
753: public void apply(final IHiddenRegionFormatter it) {
754: it.oneSpace();
755: }
756: };
757: return document.append(this.textRegionExtensions.regionFor(element).keyword(k), _function);
758: }
759:
760: private <T extends EObject> T separateElementsWithNewlines(final T element, @Extension final IFormattableDocument document) {
761: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
762: @Override
763: public void apply(final IHiddenRegionFormatter it) {
764: it.setNewLines(1, 1, 2);
765: }
766: };
767: return document.<T>append(element, _function);
768: }
769:
770: private <T extends EObject> void indentBlock(final T element, @Extension final IFormattableDocument document, final Procedure1<? super T> elementsFormatter) {
771: final ISemanticRegion open = this.textRegionExtensions.regionFor(element).keyword("{");
772: final ISemanticRegion close = this.textRegionExtensions.regionFor(element).keyword("}");
773: final Procedure1<IHiddenRegionFormatter> _function = new Procedure1<IHiddenRegionFormatter>() {
774: @Override
775: public void apply(final IHiddenRegionFormatter it) {
776: it.newLine();
777: }
778: };
779: document.append(open, _function);
780: final Procedure1<IHiddenRegionFormatter> _function_1 = new Procedure1<IHiddenRegionFormatter>() {
781: @Override
782: public void apply(final IHiddenRegionFormatter it) {
783: it.indent();
784: }
785: };
786: document.<ISemanticRegion, ISemanticRegion>interior(open, close, _function_1);
787: elementsFormatter.apply(element);
788: }
789: }