Guest User

Untitled

a guest
Oct 21st, 2019
80
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. * generated by Xtext 2.18.0.M3
  3. */
  4. package requirements.formatting2
  5.  
  6. import com.google.inject.Inject
  7. import eDOM_Inc1.Model
  8. import eDOM_Inc1.RequirementsGroup
  9. import eDOM_Inc1.Requirement
  10. import eDOM_Inc1.Comment
  11. import org.eclipse.xtext.formatting2.AbstractFormatter2
  12. import org.eclipse.xtext.formatting2.IFormattableDocument
  13. import requirements.services.DSLGrammarAccess
  14.  
  15. class DSLFormatter extends AbstractFormatter2 {
  16.  
  17. @Inject extension DSLGrammarAccess
  18.  
  19. def dispatch void format(Model model, extension IFormattableDocument document) {
  20. // TODO: format HiddenRegions around keywords, attributes, cross references, etc.
  21.  
  22. val open1 = model.regionFor.keyword(modelAccess.getLeftCurlyBracketKeyword_1)
  23. val close1 = model.regionFor.keyword(modelAccess.getRightCurlyBracketKeyword_5)
  24. open1.append[newLine]
  25. close1.append[newLine]
  26. interior(open1, close1)[indent]
  27.  
  28. val open2 = model.regionFor.keyword(modelAccess.getLeftCurlyBracketKeyword_4_1)
  29. val close2 = model.regionFor.keyword(modelAccess.getRightCurlyBracketKeyword_4_4)
  30. open2.append[newLine]
  31. close2.append[newLine]
  32. interior(open2, close2)[indent]
  33.  
  34. model.regionFor.keyword(modelAccess.getGroupsKeyword_4_0).prepend[newLine]
  35. model.regionFor.keyword(modelAccess.getCommaKeyword_4_3_0).append[newLine]
  36.  
  37. for (RequirementsGroup requirementsGroup : model.getGroups()) {
  38. requirementsGroup.append[newLine]
  39. requirementsGroup.format
  40. }
  41. }
  42.  
  43. def dispatch void format(RequirementsGroup requirementsGroup, extension IFormattableDocument document) {
  44.  
  45. val open1 = requirementsGroup.regionFor.keyword(requirementsGroupAccess.getLeftCurlyBracketKeyword_2)
  46. val close1 = requirementsGroup.regionFor.keyword(requirementsGroupAccess.rightCurlyBracketKeyword_9)
  47. open1.append[newLine]
  48. close1.append[newLine]
  49. close1.prepend[newLine]
  50. interior(open1, close1)[indent]
  51.  
  52. val open2 = requirementsGroup.regionFor.keyword(requirementsGroupAccess.leftCurlyBracketKeyword_7_1)
  53. val close2 = requirementsGroup.regionFor.keyword(requirementsGroupAccess.getRightCurlyBracketKeyword_7_4)
  54. open2.append[newLine]
  55. close2.append[newLine]
  56. close2.prepend[newLine]
  57. interior(open2, close2)[indent]
  58.  
  59. val open3 = requirementsGroup.regionFor.keyword(requirementsGroupAccess.leftCurlyBracketKeyword_8_1)
  60. val close3 = requirementsGroup.regionFor.keyword(requirementsGroupAccess.getRightCurlyBracketKeyword_8_4)
  61. open3.append[newLine]
  62. close3.append[newLine]
  63. interior(open3, close3)[indent]
  64.  
  65. requirementsGroup.regionFor.keyword(requirementsGroupAccess.descriptionKeyword_3).prepend[newLine]
  66. requirementsGroup.regionFor.keyword(requirementsGroupAccess.idKeyword_5).prepend[newLine]
  67. requirementsGroup.regionFor.keyword(requirementsGroupAccess.childrenKeyword_7_0).prepend[newLine]
  68. requirementsGroup.regionFor.keyword(requirementsGroupAccess.getRequirementsKeyword_8_0).prepend[newLine]
  69. requirementsGroup.regionFor.keyword(requirementsGroupAccess.commaKeyword_7_3_0).append[newLine]
  70.  
  71. for (RequirementsGroup rgChild : requirementsGroup.getChildren()) {
  72. rgChild.append[newLine]
  73. rgChild.format
  74. }
  75.  
  76. for (Requirement requirement : requirementsGroup.getRequirements()) {
  77. requirement.append[newLine]
  78. requirement.format
  79. }
  80. }
  81.  
  82. def dispatch void format(Requirement requirement, extension IFormattableDocument document) {
  83.  
  84. val open1 = requirement.regionFor.keyword(requirementAccess.getLeftCurlyBracketKeyword_1)
  85. val close1 = requirement.regionFor.keyword(requirementAccess.rightCurlyBracketKeyword_25)
  86. open1.append[newLine]
  87. close1.append[newLine]
  88. close1.prepend[newLine]
  89. interior(open1, close1)[indent]
  90.  
  91. val open2 = requirement.regionFor.keyword(requirementAccess.leftCurlyBracketKeyword_23_1)
  92. val close2 = requirement.regionFor.keyword(requirementAccess.getRightCurlyBracketKeyword_23_4)
  93. open2.append[newLine]
  94. close2.append[newLine]
  95. interior(open2, close2)[indent]
  96.  
  97. val open3 = requirement.regionFor.keyword(requirementAccess.getLeftCurlyBracketKeyword_24_1)
  98. val close3 = requirement.regionFor.keyword(requirementAccess.getRightCurlyBracketKeyword_24_4)
  99. open3.append[newLine]
  100. close3.append[newLine]
  101. interior(open3, close3)[indent]
  102.  
  103. requirement.regionFor.keyword(requirementAccess.descriptionKeyword_4).prepend[newLine]
  104. requirement.regionFor.keyword(requirementAccess.typeKeyword_6).prepend[newLine]
  105. requirement.regionFor.keyword(requirementAccess.priorityKeyword_8).prepend[newLine]
  106. requirement.regionFor.keyword(requirementAccess.authorKeyword_10).prepend[newLine]
  107. requirement.regionFor.keyword(requirementAccess.createdKeyword_12).prepend[newLine]
  108. requirement.regionFor.keyword(requirementAccess.idKeyword_14).prepend[newLine]
  109. requirement.regionFor.keyword(requirementAccess.stateKeyword_16).prepend[newLine]
  110. requirement.regionFor.keyword(requirementAccess.resolutionKeyword_18).prepend[newLine]
  111. requirement.regionFor.keyword(requirementAccess.dependenciesKeyword_20_0).prepend[newLine]
  112. requirement.regionFor.keyword(requirementAccess.versionKeyword_21).prepend[newLine]
  113. requirement.regionFor.keyword(requirementAccess.childrenKeyword_23_0).prepend[newLine]
  114. requirement.regionFor.keyword(requirementAccess.commentsKeyword_24_0).prepend[newLine]
  115. requirement.regionFor.keyword(requirementAccess.commaKeyword_20_3_0).append[newLine]
  116. requirement.regionFor.keyword(requirementAccess.commaKeyword_23_3_0).append[newLine]
  117. requirement.regionFor.keyword(requirementAccess.commaKeyword_24_3_0).append[newLine]
  118.  
  119. for (Requirement reqChild : requirement.getChildren()) {
  120. reqChild.append[newLine]
  121. reqChild.format
  122. }
  123.  
  124. for (Comment comment : requirement.getComments()) {
  125. comment.format
  126. comment.append[newLine]
  127. }
  128. }
  129.  
  130. def dispatch void format(Comment comment, extension IFormattableDocument document) {
  131.  
  132. val open1 = comment.regionFor.keyword(commentAccess.getLeftCurlyBracketKeyword_1)
  133. val close1 = comment.regionFor.keyword(commentAccess.getRightCurlyBracketKeyword_11)
  134. open1.append[newLine]
  135. close1.append[newLine]
  136. close1.prepend[newLine]
  137. interior(open1, close1)[indent]
  138.  
  139. val open2 = comment.regionFor.keyword(commentAccess.getLeftCurlyBracketKeyword_10_1)
  140. val close2 = comment.regionFor.keyword(commentAccess.getRightCurlyBracketKeyword_10_4)
  141. open2.append[newLine]
  142. close2.append[newLine]
  143. interior(open2, close2)[indent]
  144.  
  145. comment.regionFor.keyword(commentAccess.getBodyKeyword_4).prepend[newLine]
  146. comment.regionFor.keyword(commentAccess.getAuthorKeyword_6).prepend[newLine]
  147. comment.regionFor.keyword(commentAccess.getCreatedKeyword_8).prepend[newLine]
  148. comment.regionFor.keyword(commentAccess.getChildrenKeyword_10_0).prepend[newLine]
  149. comment.regionFor.keyword(commentAccess.getCommaKeyword_10_3_0).append[newLine]
  150.  
  151. for (Comment c : comment.getChildren()) {
  152. c.format
  153. c.append[newLine]
  154. }
  155. }
  156. }
RAW Paste Data