Documentation
¶
Index ¶
- func FindFirstNonWhitespaceColumn(startPos int, endPos int, sourceFile *ast.SourceFile, ...) int
- func FormatDocument(ctx context.Context, sourceFile *ast.SourceFile) []core.TextChange
- func FormatNodeGivenIndentation(ctx context.Context, node *ast.Node, file *ast.SourceFile, ...) []core.TextChange
- func FormatOnClosingCurly(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
- func FormatOnEnter(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
- func FormatOnOpeningCurly(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
- func FormatOnSemicolon(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
- func FormatSelection(ctx context.Context, sourceFile *ast.SourceFile, start int, end int) []core.TextChange
- func FormatSpan(ctx context.Context, span core.TextRange, file *ast.SourceFile, ...) []core.TextChange
- func GetContainingList(node *ast.Node, sourceFile *ast.SourceFile) *ast.NodeList
- func GetIndentationForNode(n *ast.Node, ignoreActualIndentationRange *core.TextRange, ...) int
- func GetLineStartPositionForPosition(position int, sourceFile *ast.SourceFile) int
- func GetNewLineOrDefaultFromContext(ctx context.Context) string
- func NewFormattingContext(file *ast.SourceFile, kind FormatRequestKind, options *FormatCodeSettings) *formattingContext
- func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *ast.Node, ...) bool
- func ShouldIndentChildNode(settings *FormatCodeSettings, parent *ast.Node, child *ast.Node, ...) bool
- func WithFormatCodeSettings(ctx context.Context, options *FormatCodeSettings, newLine string) context.Context
- type EditorSettings
- type FormatCodeSettings
- type FormatRequestKind
- type IndentStyle
- type LineAction
- type RulesPosition
- type SemicolonPreference
- type TextRangeWithKind
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindFirstNonWhitespaceColumn ¶
func FindFirstNonWhitespaceColumn(startPos int, endPos int, sourceFile *ast.SourceFile, options *FormatCodeSettings) int
func FormatDocument ¶
func FormatDocument(ctx context.Context, sourceFile *ast.SourceFile) []core.TextChange
func FormatNodeGivenIndentation ¶
func FormatNodeGivenIndentation(ctx context.Context, node *ast.Node, file *ast.SourceFile, languageVariant core.LanguageVariant, initialIndentation int, delta int) []core.TextChange
func FormatOnClosingCurly ¶
func FormatOnClosingCurly(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
func FormatOnEnter ¶
func FormatOnEnter(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
func FormatOnOpeningCurly ¶
func FormatOnOpeningCurly(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
func FormatOnSemicolon ¶
func FormatOnSemicolon(ctx context.Context, sourceFile *ast.SourceFile, position int) []core.TextChange
func FormatSelection ¶
func FormatSelection(ctx context.Context, sourceFile *ast.SourceFile, start int, end int) []core.TextChange
func FormatSpan ¶
func FormatSpan(ctx context.Context, span core.TextRange, file *ast.SourceFile, kind FormatRequestKind) []core.TextChange
func GetContainingList ¶
func GetIndentationForNode ¶
func GetIndentationForNode(n *ast.Node, ignoreActualIndentationRange *core.TextRange, sourceFile *ast.SourceFile, options *FormatCodeSettings) int
func GetLineStartPositionForPosition ¶
func GetLineStartPositionForPosition(position int, sourceFile *ast.SourceFile) int
func NewFormattingContext ¶
func NewFormattingContext(file *ast.SourceFile, kind FormatRequestKind, options *FormatCodeSettings) *formattingContext
func NodeWillIndentChild ¶
func NodeWillIndentChild(settings *FormatCodeSettings, parent *ast.Node, child *ast.Node, sourceFile *ast.SourceFile, indentByDefault bool) bool
func ShouldIndentChildNode ¶
func ShouldIndentChildNode(settings *FormatCodeSettings, parent *ast.Node, child *ast.Node, sourceFile *ast.SourceFile, isNextChildArg ...bool) bool
* * True when the parent node should indent the given child by an explicit rule. * @param isNextChild If true, we are judging indent of a hypothetical child *after* this one, not the current child.
func WithFormatCodeSettings ¶
Types ¶
type EditorSettings ¶
type FormatCodeSettings ¶
type FormatCodeSettings struct {
EditorSettings
InsertSpaceAfterCommaDelimiter core.Tristate
InsertSpaceAfterSemicolonInForStatements core.Tristate
InsertSpaceBeforeAndAfterBinaryOperators core.Tristate
InsertSpaceAfterConstructor core.Tristate
InsertSpaceAfterKeywordsInControlFlowStatements core.Tristate
InsertSpaceAfterFunctionKeywordForAnonymousFunctions core.Tristate
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis core.Tristate
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets core.Tristate
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces core.Tristate
InsertSpaceAfterOpeningAndBeforeClosingEmptyBraces core.Tristate
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces core.Tristate
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces core.Tristate
InsertSpaceAfterTypeAssertion core.Tristate
InsertSpaceBeforeFunctionParenthesis core.Tristate
PlaceOpenBraceOnNewLineForFunctions core.Tristate
PlaceOpenBraceOnNewLineForControlBlocks core.Tristate
InsertSpaceBeforeTypeAnnotation core.Tristate
IndentMultiLineObjectLiteralBeginningOnBlankLine core.Tristate
Semicolons SemicolonPreference
IndentSwitchCase core.Tristate
}
func GetDefaultFormatCodeSettings ¶
func GetDefaultFormatCodeSettings(newLineCharacter string) *FormatCodeSettings
func GetFormatCodeSettingsFromContext ¶
func GetFormatCodeSettingsFromContext(ctx context.Context) *FormatCodeSettings
type FormatRequestKind ¶
type FormatRequestKind int
const ( FormatRequestKindFormatDocument FormatRequestKind = iota FormatRequestKindFormatSelection FormatRequestKindFormatOnEnter FormatRequestKindFormatOnSemicolon FormatRequestKindFormatOnOpeningCurlyBrace FormatRequestKindFormatOnClosingCurlyBrace )
type IndentStyle ¶
type IndentStyle int
const ( IndentStyleNone IndentStyle = iota IndentStyleBlock IndentStyleSmart )
type LineAction ¶
type LineAction int
const ( LineActionNone LineAction = iota LineActionLineAdded LineActionLineRemoved )
type RulesPosition ¶
type RulesPosition int
const ( RulesPositionStopRulesSpecific RulesPosition = 0 RulesPositionStopRulesAny RulesPosition = maskBitSize * 1 RulesPositionContextRulesSpecific RulesPosition = maskBitSize * 2 RulesPositionContextRulesAny RulesPosition = maskBitSize * 3 RulesPositionNoContextRulesSpecific RulesPosition = maskBitSize * 4 RulesPositionNoContextRulesAny RulesPosition = maskBitSize * 5 )
type SemicolonPreference ¶
type SemicolonPreference string
const ( SemicolonPreferenceIgnore SemicolonPreference = "ignore" SemicolonPreferenceInsert SemicolonPreference = "insert" SemicolonPreferenceRemove SemicolonPreference = "remove" )
type TextRangeWithKind ¶
func NewTextRangeWithKind ¶
func NewTextRangeWithKind(pos int, end int, kind ast.Kind) TextRangeWithKind
Click to show internal directories.
Click to hide internal directories.