JetBrains/resharper-fsharp

Record autocomplete no longer handles type name dot in computation expression

Opened this issue · 1 comments

nojaf commented

Hi,

@safesparrow and I encountered a bug with the autocompletion of a new record instance:

    type Entry =
        {
            Idx: int
            FileName: string
            /// Own deps
            DependencyCount: int
            /// Being depended on
            DependentCount: int
            LineCount: int
        }

    let x =
        {
            Entry.{caret}
        }
IComputationExpr
  FSharpTokenType+LbraceTokenElement(type:LBRACE, text:{)
  NewLine(type:NEW_LINE, text:\n) spaces:"\n"
  Whitespace(type:WHITE_SPACE, text:            ) spaces:"            "
  IFromErrorExpr
    IReferenceExpr
      FSharpIdentifierToken(type:IDENTIFIER, text:Entry)
    FSharpTokenType+DotTokenElement(type:DOT, text:.)
  NewLine(type:NEW_LINE, text:\n) spaces:"\n"
  Whitespace(type:WHITE_SPACE, text:        ) spaces:"        "
  FSharpTokenType+RbraceTokenElement(type:RBRACE, text:})

let getRecordEntity (context: FSharpCodeCompletionContext) =
let getRecordFromExprType (expr: IFSharpExpression) =
if isNull expr then None else
let expr = expr.TryGetOriginalRecordExprThroughSandBox()
if isNull expr then None else
let fcsType = expr.TryGetFcsType()
if isNull fcsType || not fcsType.HasTypeDefinition then None else
let fcsEntity = fcsType.TypeDefinition
if not fcsEntity.IsFSharpRecord then None else
Some(fcsEntity, expr)

is not finding the fcsType for the IComputationExpr:

image

We believe this used to work in 2022.1.2. It no longer works for us in 2023.1.3 and 2023.2 EAP 5.

checkResults.GetTypeOfExpression(range) no longer seems to work as expected it seems.

Does this ring a bell? Anything we can do to help?

@nojaf Yes, it looks like a regression, and I can reproduce it. Most likely, it'll require a fix in FCS.