Logo FSharp.Formatting

CodeFormatter Module

Formats F# source code snippets into annotated token sequences by invoking the F# Compiler Service for tokenisation, type-checking, and semantic classification.

Functions and values

Function or value Description

ParseAndCheckSource (file, source, options, defines, onError)

Full Usage: ParseAndCheckSource (file, source, options, defines, onError)

Parameters:
    file : string
    source : string
    options : string option
    defines : string option
    onError : string -> unit

Returns: Snippet array * SourceError[]

Parse, check and annotate the source code specified by 'source', assuming that it is located in a specified 'file'. Optional arguments can be used to give compiler command line options and preprocessor definitions

file : string
source : string
options : string option
defines : string option
onError : string -> unit
Returns: Snippet array * SourceError[]

categoryToTokenKind _arg1

Full Usage: categoryToTokenKind _arg1

Parameters:
Returns: TokenKind option

Maps an FCS to our , or None for unrecognised categories.

_arg1 : SemanticClassificationType
Returns: TokenKind option

fsChecker

Full Usage: fsChecker

Returns: FSharpChecker

Shared instance used for all source-code processing.

Returns: FSharpChecker

processDoubleBackticks body

Full Usage: processDoubleBackticks body

Parameters:
    body : string

Returns: string

Converts a double-backtick identifier like ``my ident`` into the form ( my ident ) that the compiler uses for tooltip lookup.

body : string
Returns: string

processSnippet checkResults categorizedRanges lines snippet

Full Usage: processSnippet checkResults categorizedRanges lines snippet

Parameters:
Returns: Line list
Type parameters: 'a (requires :> FSharp.Compiler.EditorServices.SemanticClassificationItem Microsoft.FSharp.Collections.seq)

Processes all lines of a snippet using the FCS check results and semantic classification ranges, returning an annotated list of values.

checkResults : FSharpCheckFileResults
categorizedRanges : Map<int, 'a>
lines : string array
snippet : Snippet
Returns: Line list

processSnippetLine checkResults semanticRanges lines (line, lineTokens)

Full Usage: processSnippetLine checkResults semanticRanges lines (line, lineTokens)

Parameters:
Returns: Line

Processes a single source line: walks the token stream and enriches each token with semantic classification (colour kind and tooltip) from the FCS type-check results.

checkResults : FSharpCheckFileResults
semanticRanges : SemanticClassificationItem array
lines : string array
line : int
lineTokens : SnippetLine
Returns: Line

processSourceCode (filePath, source, options, defines, onError)

Full Usage: processSourceCode (filePath, source, options, defines, onError)

Parameters:
    filePath : string
    source : string
    options : string option
    defines : string option
    onError : string -> unit

Returns: Async<Snippet array * SourceError[]>

Asynchronously parses, type-checks, and annotates a single F# source file or script, returning an array of named, token-annotated snippets and any compilation diagnostics.

filePath : string
source : string
options : string option
defines : string option
onError : string -> unit
Returns: Async<Snippet array * SourceError[]>

Type something to start searching.