Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3567144
Initial skeleton + dependencies updates
cartermp Oct 16, 2020
8b4b8cb
Initial proof of concept
cartermp Oct 21, 2020
6b36be5
Cleanup, tag interfaces correctly, surface area
cartermp Oct 21, 2020
b67ebdb
Basic, buggy support for parameter names
cartermp Oct 22, 2020
7f09a76
Preliminary support for not adding hints to already-annotated values
cartermp Oct 23, 2020
e129f58
don't show for typed value decls
cartermp Oct 23, 2020
fcc4be6
No sig files, handle more typed cases
cartermp Oct 23, 2020
626f7ff
Be precise about type annotations when looking for them in the syntax…
cartermp Oct 23, 2020
1c9afe6
More annotations fixity
cartermp Oct 23, 2020
57f8246
Hints show only the return type for functions
cartermp Oct 24, 2020
7dfc1b8
Cleanup and surface tests
cartermp Oct 24, 2020
47ed27a
Match names
cartermp Oct 24, 2020
51dcd6f
Basic tests for arg names
cartermp Oct 24, 2020
d2502db
Fix issues with nested functions + more tests
cartermp Oct 26, 2020
a964414
More testing and fix a bug with annotating return types for methods
cartermp Oct 27, 2020
3169656
Add failing test for infix exprs
cartermp Oct 27, 2020
b565539
Tests and fixes for exprs in infix operators
cartermp Oct 27, 2020
a8e289b
QuickInfo is scoped out + surface area
cartermp Oct 27, 2020
16c0b93
Add IsMethod and change parameter name hints to be more like names pa…
cartermp Oct 28, 2020
7e9eded
Only show type hints for lambdas + tests + surface
cartermp Oct 28, 2020
0ce8403
Preliminary support for labels for methods
cartermp Oct 29, 2020
50e7d9d
Cleanup, handle method params properly, constructors
cartermp Oct 30, 2020
258aa23
Feedback
cartermp Nov 2, 2020
86c25b9
Param names
cartermp Nov 4, 2020
2fef548
Update with latest
cartermp Nov 6, 2020
feaacf7
Update src/fsharp/symbols/Symbols.fsi
cartermp Nov 16, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
No sig files, handle more typed cases
  • Loading branch information
cartermp committed Nov 6, 2020
commit fcc4be6a3093bcc4226992197060a2702568007a
30 changes: 20 additions & 10 deletions src/fsharp/service/ServiceUntypedParse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,30 @@ type FSharpParseFileResults(errors: FSharpErrorInfo[], input: ParsedInput option
| Some parseTree ->
let res =
AstTraversal.Traverse(pos, parseTree, { new AstTraversal.AstVisitorBase<_>() with
member __.VisitExpr(_path, _traverseSynExpr, defaultTraverse, expr) =
member _.VisitExpr(_path, _traverseSynExpr, defaultTraverse, expr) =
match expr with
| SynExpr.Typed (_expr, _typeExpr, range) ->
rangeContainsPos range pos
|> Some
| _ -> defaultTraverse(expr)
| SynExpr.Typed (_expr, _typeExpr, range) when rangeContainsPos range pos ->
Some range
| _ -> defaultTraverse expr

override _.VisitSimplePats(pats) =
match pats with
| [] -> None
| _ ->
let exprFunc pat =
match pat with
| SynSimplePat.Typed (_pat, _targetExpr, range) when rangeContainsPos range pos ->
Some range
| _ ->
None

pats |> List.tryPick exprFunc

override _.VisitPat(defaultTraverse, pat) =
match pat with
| SynPat.Typed (_pat, _targetType, range) ->
rangeContainsPos range pos
|> Some
| _ ->
defaultTraverse pat })
| SynPat.Typed (_pat, _targetType, range) when rangeContainsPos range pos ->
Some range
| _ -> defaultTraverse pat })
res.IsSome
| None ->
false
Expand Down
20 changes: 12 additions & 8 deletions vsintegration/src/FSharp.Editor/InlineHints/InlineHints.fs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type internal FSharpInlineHintsService
interface IFSharpInlineHintsService with
member _.GetInlineHintsAsync(document: Document, textSpan: TextSpan, cancellationToken: CancellationToken) =
asyncMaybe {
do! Option.guard (not (isSignatureFile document.FilePath))

let! textVersion = document.GetTextVersionAsync(cancellationToken)
let! parsingOptions, projectOptions = projectInfoManager.TryGetOptionsForEditingDocumentOrProject(document, cancellationToken, userOpName)
let! sourceText = document.GetTextAsync(cancellationToken)
Expand All @@ -39,19 +41,21 @@ type internal FSharpInlineHintsService
let typeHints = ImmutableArray.CreateBuilder()
let parameterHints = ImmutableArray.CreateBuilder()

let isValidValue (value: FSharpMemberOrFunctionOrValue) (symbolUse: FSharpSymbolUse) =
value.IsValue &&
not value.IsMemberThisValue &&
not value.IsConstructorThisValue &&
let isValid (funcOrValue: FSharpMemberOrFunctionOrValue) (symbolUse: FSharpSymbolUse) =
not (parseFileResults.IsTypeAnnotationGiven symbolUse.RangeAlternate.Start) &&
symbolUse.IsFromDefinition &&
not (parseFileResults.IsTypeAnnotationGiven symbolUse.RangeAlternate.Start)
(funcOrValue.IsValue || funcOrValue.IsFunction) &&
not funcOrValue.IsMember &&
not funcOrValue.IsMemberThisValue &&
not funcOrValue.IsConstructorThisValue &&
not (PrettyNaming.IsOperatorName funcOrValue.DisplayName)

for symbolUse in symbolUses do
for symbolUse in symbolUses |> Array.distinctBy (fun su -> su.RangeAlternate) do
match symbolUse.Symbol with
| :? FSharpMemberOrFunctionOrValue as value when isValidValue value symbolUse ->
| :? FSharpMemberOrFunctionOrValue as funcOrValue when isValid funcOrValue symbolUse ->
let typeInfo = ResizeArray()

value.FormatLayout symbolUse.DisplayContext
funcOrValue.FormatLayout symbolUse.DisplayContext
|> Layout.renderL (Layout.taggedTextListR typeInfo.Add)
|> ignore

Expand Down