Header menu logo F# Compiler Guide

QuickParse Module

 Methods for cheaply and inaccurately parsing F#.

 These methods are very old and are mostly to do with extracting "long identifier islands"
     A.B.C
 from F# source code, an approach taken from pre-F# VS samples for implementing intelliense.

 This code should really no longer be needed since the language service has access to
 parsed F# source code ASTs.  However, the long identifiers are still passed back to GetDeclarations and friends in the
 F# Compiler Service and it's annoyingly hard to remove their use completely.

 In general it is unlikely much progress will be made by fixing this code - it will be better to
 extract more information from the F# ASTs.

 It's also surprising how hard even the job of getting long identifier islands can be. For example the code
 below is inaccurate for long identifier chains involving ``...`` identifiers.  And there are special cases
 for active pattern names and so on.

Functions and values

Function or value Description

CorrectIdentifierToken tokenText tokenTag

Full Usage: CorrectIdentifierToken tokenText tokenTag

Parameters:
    tokenText : string
    tokenTag : int

Returns: int
tokenText : string
tokenTag : int
Returns: int

GetCompleteIdentifierIsland tolerateJustAfter lineStr index

Full Usage: GetCompleteIdentifierIsland tolerateJustAfter lineStr index

Parameters:
    tolerateJustAfter : bool
    lineStr : string MaybeNull
    index : int

Returns: (string * int * bool) option
 Given a string and a position in that string, find an identifier as
 expected by `GotoDefinition`. This will work when the cursor is
 immediately before the identifier, within the identifier, or immediately
 after the identifier.

 'tolerateJustAfter' indicates that we tolerate being one character after the identifier, used
 for goto-definition

 In general, only identifiers composed from upper/lower letters and '.' are supported, but there
 are a couple of explicitly handled exceptions to allow some common scenarios:
 - When the name contains only letters and '|' symbol, it may be an active pattern, so we
   treat it as a valid identifier - e.g. let ( |Identity| ) a = a
   (but other identifiers that include '|' are not allowed - e.g. '||' operator)
 - It searches for double tick (``) to see if the identifier could be something like ``a b``

 REVIEW: Also support, e.g., operators, performing the necessary mangling.
 (i.e., I would like that the name returned here can be passed as-is
 (post `.`-chopping) to `GetDeclarationLocation.)

 In addition, return the position where a `.` would go if we were making
 a call to `DeclItemsForNamesAtPosition` for intellisense. This will
 allow us to use find the correct qualified items rather than resorting
 to the more expensive and less accurate environment lookup.
tolerateJustAfter : bool
lineStr : string MaybeNull
index : int
Returns: (string * int * bool) option

GetPartialLongName (lineStr, index)

Full Usage: GetPartialLongName (lineStr, index)

Parameters:
Returns: string list * string

Get the partial long name of the identifier to the left of index.

lineStr : string MaybeNull
index : int
Returns: string list * string

GetPartialLongNameEx (lineStr, index)

Full Usage: GetPartialLongNameEx (lineStr, index)

Parameters:
Returns: PartialLongName

Get the partial long name of the identifier to the left of index. For example, for `System.DateTime.Now` it returns PartialLongName ([|"System"; "DateTime"|], "Now", Some 32), where "32" pos of the last dot.

lineStr : string MaybeNull
index : int
Returns: PartialLongName

MagicalAdjustmentConstant

Full Usage: MagicalAdjustmentConstant

Returns: int

Puts us after the last character.

Returns: int

TestMemberOrOverrideDeclaration tokens

Full Usage: TestMemberOrOverrideDeclaration tokens

Parameters:
Returns: bool

Tests whether the user is typing something like "member x." or "override (*comment*) x."

tokens : FSharpTokenInfo[]
Returns: bool

Type something to start searching.