blob: 55c5545d4ff5c7ab94be0ae5229b7df16238950c [file] [log] [blame]
/*
* generated by Xtext
*/
package org.eclipse.vorto.fbeditor.formatting
import javax.inject.Inject
import org.eclipse.xtext.formatting.impl.AbstractDeclarativeFormatter
import org.eclipse.xtext.formatting.impl.FormattingConfig
import org.eclipse.vorto.fbeditor.services.FunctionblockGrammarAccess
class FunctionblockFormatter extends AbstractDeclarativeFormatter {
@Inject extension FunctionblockGrammarAccess f
override protected void configureFormatting(FormattingConfig c) {
// formatting for Comments
c.setLinewrap(1, 1, 2).before(SL_COMMENTRule)
c.setLinewrap(1, 1, 2).before(ML_COMMENTRule)
c.setLinewrap(1, 1, 1).after(ML_COMMENTRule)
c.setAutoLinewrap(120)
// Line wrap for all basic function block info, like displayname, description etc.
c.setLinewrap(1).after(f.functionBlockAccess.displaynameAssignment_1)
c.setLinewrap(1).after(f.functionBlockAccess.descriptionAssignment_2_1)
c.setLinewrap(1).after(f.functionBlockAccess.vendorAssignment_4)
c.setLinewrap(1).after(f.functionBlockAccess.categoryAssignment_6)
c.setLinewrap(2).after(f.functionBlockAccess.versionAssignment_8)
//Line wrap for every property entries in all function block constructs like configuration, status etc.
c.setLinewrap(1).after(f.FBFeatureAccess.propertiesAssignment)
c.setLinewrap(1).before(f.findKeywords("mandatory").get(0))
c.setLinewrap(1).before(f.findKeywords("optional").get(0))
// Line wrap and indentation between function block sub elements.
findKeywordPairs("{","}").forEach[
c.setLinewrap(1).after(first)
c.setLinewrap(1).before(second)
c.setLinewrap(2).after(second)
c.setIndentationIncrement().after(first)
c.setIndentationDecrement().before(second)
]
//Formatting for operation paranthesis
findKeywordPairs("(",")").forEach[
c.setNoSpace().before(first)
c.setNoSpace().after(first)
c.setNoSpace().before(second)
]
//Formatting for constraint block
findKeywordPairs("<",">").forEach[
c.setSpace(" ").before(first)
c.setNoSpace().after(first)
c.setNoSpace().before(second)
]
//Line wrap for each operation.
c.setLinewrap(1).after(f.operationAccess.group)
//Remove space between enum values. Make enum into separate line.
c.setNoSpace().before(f.enumAccess.commaKeyword_3_1_0)
c.setLinewrap(1).after(f.enumAccess.commaKeyword_3_1_0)
//Remove extra spaces between constraint parameters.
c.setNoSpace().before(f.primitivePropertyAccess.commaKeyword_5_2_0)
c.setNoSpace().after(f.primitivePropertyAccess.commaKeyword_5_2_0)
//Remove extra spaces between method parameters.
c.setNoSpace().before(f.operationAccess.commaKeyword_2_1_0)
c.setNoSpace().after(f.operationAccess.commaKeyword_2_1_0)
}
}