-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix record stub generation off-by-one #905
fix record stub generation off-by-one #905
Conversation
@@ -19,7 +19,7 @@ type CodeGenerationService(checker : FSharpCompilerServiceChecker, state : State | |||
option { | |||
let! text = state.TryGetFileSource fileName |> Option.ofResult | |||
try | |||
let! line = text.GetLine (Position.mkPos (i - 1) 0) | |||
let! line = text.GetLine (Position.mkPos i 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was the core issue - we don't need to do a -1 line position because this helper covers that already.
@@ -117,7 +117,10 @@ module CodeGenerationUtils = | |||
range | |||
|
|||
let lineIdxAndTokenSeq = seq { | |||
for lineIdx = range.StartLine to range.EndLine do | |||
let lines = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cover edge cases where the line range is on the same line
@@ -20,6 +20,7 @@ type RecordExpr = { | |||
Expr: SynExpr | |||
CopyExprOption: option<SynExpr * BlockSeparator> | |||
FieldExprList: SynExprRecordField list | |||
LastKnownGoodPosForSymbolLookup: Position |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in case we are at the end of a record declaration (e.g. the |
in { a = "";| }
), we need some kind of identifier to use to look up the symbol to find the record's type definition. this field allows us to grab that during the AST walk for later use.
new SyntaxVisitorBase<RecordExpr>() with | ||
member x.VisitExpr(path: SyntaxVisitorPath, traverseSynExpr: (SynExpr -> _ option), defaultTraverse: (SynExpr -> _ option), synExpr: SynExpr) = | ||
match synExpr with | ||
| SynExpr.Record (recordFields = recordFields; copyInfo = copyInfo) -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is a lot less code than the other version and expresses the majority of the same intent. any addition we want to make to this will be much easier in the standard walker.
3680abe
to
69dae0d
Compare
69dae0d
to
55aec5b
Compare
Fixes ionide/ionide-vscode-fsharp#1674 by