protected void _format ( SarlBehaviorUnit behaviorUnit , IFormattableDocument document ) { formatAnnotations ( behaviorUnit , document , XbaseFormatterPreferenceKeys . newLineAfterMethodAnnotations ) ; final ISemanticRegionsFinder regionFor = this . textRegionExtensions . regionFor ( behaviorUnit ) ; document . append ( regionFor . keyword ( this . keywords . getOnKeyword ( ) ) , ONE_SPACE ) ; if ( behaviorUnit . getGuard ( ) != null ) { ISemanticRegion keyword = this . textRegionExtensions . immediatelyPreceding ( behaviorUnit . getGuard ( ) ) . keyword ( this . keywords . getLeftSquareBracketKeyword ( ) ) ; document . prepend ( keyword , ONE_SPACE ) ; document . append ( keyword , NO_SPACE ) ; keyword = this . textRegionExtensions . immediatelyFollowing ( behaviorUnit . getGuard ( ) ) . keyword ( this . keywords . getRightSquareBracketKeyword ( ) ) ; document . prepend ( keyword , NO_SPACE ) ; } document . format ( behaviorUnit . getName ( ) ) ; document . format ( behaviorUnit . getGuard ( ) ) ; final XExpression expression = behaviorUnit . getExpression ( ) ; if ( expression != null ) { final ISemanticRegionFinder finder = this . textRegionExtensions . regionFor ( expression ) ; final ISemanticRegion brace = finder . keyword ( this . keywords . getLeftCurlyBracketKeyword ( ) ) ; document . prepend ( brace , XbaseFormatterPreferenceKeys . bracesInNewLine ) ; document . format ( expression ) ; } }
Format a behavior unit .