aboutsummaryrefslogtreecommitdiffstats
path: root/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend
diff options
context:
space:
mode:
Diffstat (limited to 'Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend')
-rw-r--r--Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend96
1 files changed, 96 insertions, 0 deletions
diff --git a/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend
new file mode 100644
index 00000000..28797bc4
--- /dev/null
+++ b/Solvers/Alloy-Solver/hu.bme.mit.inf.dslreasoner.alloy.language/src/hu/bme/mit/inf/dslreasoner/formatting/AlloyLanguageFormatter.xtend
@@ -0,0 +1,96 @@
1/*
2 * generated by Xtext
3 */
4package hu.bme.mit.inf.dslreasoner.formatting
5
6import com.google.inject.Inject
7import hu.bme.mit.inf.dslreasoner.services.AlloyLanguageGrammarAccess
8import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
9import org.eclipse.xtext.formatting.impl.FormattingConfig
10
11/**
12 * This class contains custom formatting description.
13 *
14 * see : http://www.eclipse.org/Xtext/documentation.html#formatting
15 * on how and when to use it
16 *
17 * Also see {@link org.eclipse.xtext.xtext.XtextFormattingTokenSerializer} as an example
18 */
19class AlloyLanguageFormatter extends AbstractDeclarativeFormatter {
20
21 @Inject extension AlloyLanguageGrammarAccess
22
23 override protected void configureFormatting(FormattingConfig c) {
24 // It's usually a good idea to activate the following three statements.
25 // They will add and preserve newlines around comments
26 c.setLinewrap(0, 1, 2).before(SL_COMMENTRule)
27 c.setLinewrap(0, 1, 2).before(ML_COMMENTRule)
28 c.setLinewrap(0, 1, 1).after(ML_COMMENTRule)
29
30 c.setAutoLinewrap(100000);
31
32 //Signatures
33 c.setIndentationIncrement.after(ALSSignatureBodyAccess.leftCurlyBracketKeyword_5);
34 c.setLinewrap.after(ALSSignatureBodyAccess.leftCurlyBracketKeyword_5)
35 c.setIndentationDecrement.before(ALSSignatureBodyAccess.rightCurlyBracketKeyword_7);
36 c.setLinewrap.after(ALSSignatureBodyAccess.rightCurlyBracketKeyword_7)
37 c.setLinewrap.before(ALSSignatureBodyAccess.rightCurlyBracketKeyword_7)
38 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_3_0)
39 c.setLinewrap.after(ALSSignatureBodyAccess.commaKeyword_3_0)
40 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_3_0)
41 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_6_1_0)
42 c.setLinewrap.after(ALSSignatureBodyAccess.commaKeyword_6_1_0)
43 c.setNoSpace.before(ALSSignatureBodyAccess.commaKeyword_6_1_0)
44 //c.setLinewrap(0,1,2).between(ALSSignatureDeclarationRule,ALSSignatureDeclarationRule)
45
46 //Enums
47 c.setIndentationIncrement.after(ALSEnumDeclarationAccess.leftCurlyBracketKeyword_2)
48 c.setLinewrap.after(ALSEnumDeclarationAccess.leftCurlyBracketKeyword_2)
49 c.setIndentationDecrement.before(ALSEnumDeclarationAccess.rightCurlyBracketKeyword_5)
50 c.setLinewrap.before(ALSEnumDeclarationAccess.rightCurlyBracketKeyword_5)
51 c.setLinewrap.after(ALSEnumDeclarationAccess.rightCurlyBracketKeyword_5)
52 c.setNoSpace.before(ALSEnumDeclarationAccess.commaKeyword_4_0)
53
54
55 //facts
56 c.setIndentationIncrement.after(ALSFactDeclarationAccess.leftCurlyBracketKeyword_3)
57 c.setLinewrap.after(ALSFactDeclarationAccess.leftCurlyBracketKeyword_3)
58 c.setIndentationDecrement.before(ALSFactDeclarationAccess.rightCurlyBracketKeyword_5)
59 c.setLinewrap.before(ALSFactDeclarationAccess.rightCurlyBracketKeyword_5)
60 c.setLinewrap.after(ALSFactDeclarationAccess.rightCurlyBracketKeyword_5)
61
62 //predicates
63 c.setIndentationIncrement.after(ALSRelationDefinitionAccess.leftCurlyBracketKeyword_6)
64 c.setLinewrap.after(ALSRelationDefinitionAccess.leftCurlyBracketKeyword_6)
65 c.setIndentationDecrement.before(ALSRelationDefinitionAccess.rightCurlyBracketKeyword_8)
66 c.setLinewrap.before(ALSRelationDefinitionAccess.rightCurlyBracketKeyword_8)
67 c.setLinewrap.after(ALSRelationDefinitionAccess.rightCurlyBracketKeyword_8)
68 c.setNoSpace.after(ALSRelationDefinitionAccess.leftSquareBracketKeyword_2)
69 c.setNoSpace.before(ALSRelationDefinitionAccess.rightSquareBracketKeyword_5)
70 c.setNoSpace.before(ALSRelationDefinitionAccess.commaKeyword_4_0)
71
72 // terms
73 //c.setNoSpace.before(ALSJoinAccess.rightSquareBracketKeyword_1_2_1_3)
74 c.setNoSpace.before(ALSJoinAccess.fullStopKeyword_1_1)
75 c.setNoSpace.after(ALSJoinAccess.fullStopKeyword_1_1)
76
77 c.setNoSpace.before(ALSDirectProductAccess.hyphenMinusGreaterThanSignKeyword_1_2)
78 c.setNoSpace.after(ALSDirectProductAccess.hyphenMinusGreaterThanSignKeyword_1_2)
79
80 c.setNoSpace.before(ALSVariableDeclarationAccess.colonKeyword_1)
81// c.setNoSpace.before(ALSPreficedAccess.commaKeyword_5_3_0)
82// c.setNoSpace.before(ALSPreficedAccess.commaKeyword_6_4_0)
83//
84// c.setIndentationIncrement.after(ALSPreficedAccess.leftCurlyBracketKeyword_5_4)
85// c.setLinewrap.after(ALSPreficedAccess.leftCurlyBracketKeyword_5_4)
86// c.setLinewrap.before(ALSPreficedAccess.rightCurlyBracketKeyword_5_6)
87// c.setIndentationDecrement.before(ALSPreficedAccess.rightCurlyBracketKeyword_5_6)
88
89 c.setNoSpace.after(ALSBasicRelationTermAccess.leftParenthesisKeyword_6_0)
90 c.setNoSpace.before(ALSBasicRelationTermAccess.rightParenthesisKeyword_6_2)
91
92 // Quantified expression
93 c.setNoSpace.before(ALSQuantifiedAccess.commaKeyword_0_4_0)
94
95 }
96}