Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJuergen Haug2018-01-17 18:57:40 +0000
committerJuergen Haug2018-01-17 19:11:34 +0000
commit1f97945b88564aa8f0f33259ee5a1bc08cab294a (patch)
tree999032a1d96b1da1a2b95b4e17aca9688419c2be /plugins/org.eclipse.etrice.core.fsm
parentcc19bc99d802135bfff2ce55dbedf8e3812fec85 (diff)
downloadorg.eclipse.etrice-1f97945b88564aa8f0f33259ee5a1bc08cab294a.tar.gz
org.eclipse.etrice-1f97945b88564aa8f0f33259ee5a1bc08cab294a.tar.xz
org.eclipse.etrice-1f97945b88564aa8f0f33259ee5a1bc08cab294a.zip
[core] fixed and improved formatter
Diffstat (limited to 'plugins/org.eclipse.etrice.core.fsm')
-rw-r--r--plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/formatting2/FSMFormatter.xtend22
1 files changed, 13 insertions, 9 deletions
diff --git a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/formatting2/FSMFormatter.xtend b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/formatting2/FSMFormatter.xtend
index ccf6ccd9a..9066c5a65 100644
--- a/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/formatting2/FSMFormatter.xtend
+++ b/plugins/org.eclipse.etrice.core.fsm/src/org/eclipse/etrice/core/fsm/formatting2/FSMFormatter.xtend
@@ -27,6 +27,8 @@ import org.eclipse.etrice.core.fsm.fSM.TriggeredTransition
import org.eclipse.etrice.core.fsm.services.FSMGrammarAccess
import org.eclipse.xtext.formatting2.IFormattableDocument
import org.eclipse.xtext.formatting2.regionaccess.ISemanticRegion
+import org.eclipse.etrice.core.fsm.fSM.RefinedTransition
+import org.eclipse.etrice.core.fsm.fSM.TransitionBase
class FSMFormatter extends BaseFormatter {
@@ -48,29 +50,31 @@ class FSMFormatter extends BaseFormatter {
def dispatch void format(StateGraph it, extension IFormattableDocument document) {
eContents.forEach[prependDefaultNewLines(document)]
+ eContents.forEach[format] // format children
}
def dispatch void format(State it, extension IFormattableDocument document) {
regionFor.keywords('entry', 'exit', 'do', 'subgraph').forEach[prependDefaultNewLines(document) append[oneSpace]]
+ eContents.forEach[format] // format children
}
- def dispatch void format(Transition it, extension IFormattableDocument document) {
- regionFor.keywords('action', 'guard', 'cond').forEach[prependDefaultNewLines(document) append[oneSpace]]
- }
-
- def dispatch void format(TriggeredTransition it, extension IFormattableDocument document) {
- regionFor.keywords('action', 'guard', 'cond', 'triggers').forEach[prependDefaultNewLines(document) append[oneSpace]]
-
- triggers.head.prepend[newLine]
- triggers.tail.forEach[prepend[oneSpace]]
+ def dispatch void format(TransitionBase it, extension IFormattableDocument document) {
+ regionFor.keywords('action', 'guard', 'cond', 'triggers').forEach[prependDefaultNewLines(document) append[oneSpace]]
+ if(it instanceof TriggeredTransition) {
+ triggers.head.prepend[newLine]
+ triggers.tail.forEach[prepend[oneSpace]]
+ }
+ eContents.forEach[format] // format children
}
def dispatch void format(Trigger it, extension IFormattableDocument document) {
regionFor.keywordPairs('<', '>').forEach[interior[noSpace]]
+ eContents.forEach[format] // format children
}
def dispatch void format(ProtocolSemantics it, extension IFormattableDocument document) {
rules.forEach[prependDefaultNewLines(document)]
+ eContents.forEach[format] // format children
}
@Inject

Back to the top