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