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
Cleanup, handle method params properly, constructors
  • Loading branch information
cartermp committed Nov 6, 2020
commit 50e7d9d0cc86e00f987ffb1cbc83f6d03b795ce9
44 changes: 27 additions & 17 deletions src/fsharp/service/ServiceParamInfoLocations.fs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,19 @@ open FSharp.Compiler.SyntaxTree
open FSharp.Compiler.SyntaxTreeOps
open FSharp.Compiler.Range

type TupledArgumentLocation = { IsNamedArgument: bool; ArgumentRange: range }

[<Sealed>]
type FSharpNoteworthyParamInfoLocations
(
longId: string list,
longIdRange: range,
openParenLocation: pos,
argRanges: {| IsNamedArgument: bool; ArgumentRange: range |} list,
argRanges: TupledArgumentLocation list,
tupleEndLocations: pos list,
isThereACloseParen: bool,
namedParamNames: string option list) =
namedParamNames: string option list
) =

let tupleEndLocations = Array.ofList tupleEndLocations
let namedParamNames = Array.ofList namedParamNames
Expand Down Expand Up @@ -59,7 +62,7 @@ module internal NoteworthyParamInfoLocationsImpl =
| _ -> None

type FindResult =
| Found of openParen: pos * argRanges: {| IsNamedArgument: bool; ArgumentRange: range |} list * commasAndCloseParen: (pos * string option) list * hasClosedParen: bool
| Found of openParen: pos * argRanges: TupledArgumentLocation list * commasAndCloseParen: (pos * string option) list * hasClosedParen: bool
| NotFound

let digOutIdentFromStaticArg (StripParenTypes synType) =
Expand Down Expand Up @@ -95,7 +98,7 @@ module internal NoteworthyParamInfoLocationsImpl =
match inner with
| None ->
if AstTraversal.rangeContainsPosLeftEdgeExclusiveAndRightEdgeInclusive parenRange pos then
let argRanges = [{| IsNamedArgument = (getNamedParamName synExpr).IsSome; ArgumentRange = synExpr.Range |}]
let argRanges = [{ IsNamedArgument = (getNamedParamName synExpr).IsSome; ArgumentRange = synExpr.Range }]
Found (parenRange.Start, argRanges, [(parenRange.End, getNamedParamName synExpr)], rpRangeOpt.IsSome), None
else
NotFound, None
Expand All @@ -116,7 +119,7 @@ module internal NoteworthyParamInfoLocationsImpl =
// argRange, isNamed
let argRanges =
synExprList
|> List.map (fun e -> {| IsNamedArgument = (getNamedParamName e).IsSome; ArgumentRange = e.Range |})
|> List.map (fun e -> { IsNamedArgument = (getNamedParamName e).IsSome; ArgumentRange = e.Range })
let commasAndCloseParen = ((synExprList, commaRanges@[parenRange]) ||> List.map2 (fun e c -> c.End, getNamedParamName e))
let r = Found (parenRange.Start, argRanges, commasAndCloseParen, rpRangeOpt.IsSome)
r, None
Expand Down Expand Up @@ -167,7 +170,7 @@ module internal NoteworthyParamInfoLocationsImpl =
let betweenTheBrackets = mkRange wholem.FileName openm.Start wholem.End
if AstTraversal.rangeContainsPosEdgesExclusive betweenTheBrackets pos && args |> List.forall isStaticArg then
let commasAndCloseParen = [ for c in commas -> c.End ] @ [ wholem.End ]
Some (FSharpNoteworthyParamInfoLocations(pathOfLid lid, lidm, openm.Start, [](* TODO - figure out if need to do anything here *), commasAndCloseParen, closemOpt.IsSome, args |> List.map digOutIdentFromStaticArg))
Some (FSharpNoteworthyParamInfoLocations(pathOfLid lid, lidm, openm.Start, [], commasAndCloseParen, closemOpt.IsSome, args |> List.map digOutIdentFromStaticArg))
else
None
| _ ->
Expand Down Expand Up @@ -204,7 +207,7 @@ module internal NoteworthyParamInfoLocationsImpl =
if AstTraversal.rangeContainsPosEdgesExclusive typeArgsm pos then
// We found it, dig out ident
match digOutIdentFromFuncExpr synExpr with
| Some(lid, lidRange) -> Some (FSharpNoteworthyParamInfoLocations(lid, lidRange, op.idRange.Start, [] (* TODO - figure out if need to do anything here *), [ wholem.End ], false, []))
| Some(lid, lidRange) -> Some (FSharpNoteworthyParamInfoLocations(lid, lidRange, op.idRange.Start, [], [ wholem.End ], false, []))
| None -> None
else
None
Expand Down Expand Up @@ -242,7 +245,7 @@ module internal NoteworthyParamInfoLocationsImpl =
let typeArgsm = mkRange openm.FileName openm.Start wholem.End
if AstTraversal.rangeContainsPosEdgesExclusive typeArgsm pos && tyArgs |> List.forall isStaticArg then
let commasAndCloseParen = [ for c in commas -> c.End ] @ [ wholem.End ]
let argRanges = tyArgs |> List.map (fun tyarg -> {| IsNamedArgument = false; ArgumentRange = tyarg.Range |})
let argRanges = tyArgs |> List.map (fun tyarg -> { IsNamedArgument = false; ArgumentRange = tyarg.Range })
let r = FSharpNoteworthyParamInfoLocations(["dummy"], synExpr.Range, openm.Start, argRanges, commasAndCloseParen, closemOpt.IsSome, tyArgs |> List.map digOutIdentFromStaticArg)
Some r
else
Expand Down Expand Up @@ -288,17 +291,25 @@ type FSharpNoteworthyParamInfoLocations with
| _ -> None

module internal FunctionApplicationArgumentLocationsImpl =
let rec private searchSynArgExpr traverseSynExpr _pos expr ranges =
let rec private searchSynArgExpr traverseSynExpr expr ranges =
match expr with
| SynExprParen(SynExprParen(_, _, _, _), _, _, parenRange) ->
Some(parenRange :: ranges), None

| SynExpr.ArbitraryAfterError (_debugStr, range) -> // single argument when e.g. after open paren you hit EOF
Some(range :: ranges), None

| SynExpr.Const(SynConst.Unit, _) ->
None, None

| SynExprParen(SynExpr.Tuple (_, exprs, _commas, _tupRange), _, _, _parenRange) ->
let rec loop (exprs: SynExpr list) ranges =
match exprs with
| [] -> ranges
| h::t ->
loop t (h.Range :: ranges)

let res = loop exprs ranges
Some (res), None

| SynExprParen(SynExprParen(_, _, _, _) as synExpr, _, _, _parenRange) ->
let r, _cacheOpt = searchSynArgExpr traverseSynExpr synExpr ranges
r, None

| SynExprParen(SynExpr.App (_, _isInfix, _, _, _range), _, _, parenRange) ->
Some (parenRange :: ranges), None

Expand All @@ -322,13 +333,12 @@ module internal FunctionApplicationArgumentLocationsImpl =
if isInfixFuncExpr then
traverseSynExpr funcExpr
else

let workingRanges =
match traverseSynExpr funcExpr with
| Some ranges -> ranges
| None -> []

let xResult, cacheOpt = searchSynArgExpr traverseSynExpr pos argExpr workingRanges
let xResult, cacheOpt = searchSynArgExpr traverseSynExpr argExpr workingRanges
match xResult, cacheOpt with
| Some ranges, _ -> Some ranges
| None, Some cache -> cache
Expand Down
5 changes: 4 additions & 1 deletion src/fsharp/service/ServiceParamInfoLocations.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ namespace FSharp.Compiler.SourceCodeServices
open FSharp.Compiler.Range
open FSharp.Compiler.SyntaxTree

/// Represents the location of a tupled argument, which can optionally be a named argument.
type TupledArgumentLocation = { IsNamedArgument: bool; ArgumentRange: range }

/// Represents the locations relevant to activating parameter info in an IDE
[<Sealed>]
type public FSharpNoteworthyParamInfoLocations =
Expand All @@ -36,7 +39,7 @@ type public FSharpNoteworthyParamInfoLocations =
member NamedParamNames : string option []

/// Array of locations for each argument, and a flag if that argument is named
member ArgLocations: {| IsNamedArgument: bool; ArgumentRange: range |} []
member ArgLocations: TupledArgumentLocation []

/// Find the information about parameter info locations at a particular source location
static member Find : pos * ParsedInput -> FSharpNoteworthyParamInfoLocations option
Expand Down
2 changes: 1 addition & 1 deletion src/fsharp/service/ServiceUntypedParse.fs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ type FSharpParseFileResults(errors: FSharpErrorInfo[], input: ParsedInput option
| Some input -> FSharpNoteworthyParamInfoLocations.Find(pos, input)
| _ -> None

member scope.GetAllArgumentsForFunctionApplication pos =
member scope.GetAllArgumentsForFunctionApplicationAtPostion pos =
match input with
| Some input -> FunctionApplicationArgumentLocationsImpl.findFSharpFunctionArgInfos pos input
| None -> None
Expand Down
8 changes: 4 additions & 4 deletions src/fsharp/service/ServiceUntypedParse.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ type public FSharpParseFileResults =
/// Notable parse info for ParameterInfo at a given location
member FindNoteworthyParamInfoLocations : pos:pos -> FSharpNoteworthyParamInfoLocations option

// doot doot yeet yeet
member GetAllArgumentsForFunctionApplication: pos: pos -> range list option
/// Gets the ranges of all arguments, if they can be found, for a function application at the given position.
member GetAllArgumentsForFunctionApplicationAtPostion: pos: pos -> range list option

// Determines if the expression or pattern at the given position has a type annotation
/// Determines if the expression or pattern at the given position has a type annotation
member IsTypeAnnotationGiven: pos -> bool

// Determines if the binding at a given position is a lambda expression
/// Determines if the binding at a given position is a lambda expression
member IsBindingALambda: pos -> bool

/// Name of the file for which this information were created
Expand Down
17 changes: 0 additions & 17 deletions src/fsharp/symbols/Symbols.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1932,23 +1932,6 @@ type FSharpMemberOrFunctionOrValue(cenv, d:FSharpMemberOrValData, item) =
|> makeReadOnlyCollection ]
|> makeReadOnlyCollection

member x.PossibleArgumentList =
checkIsResolved()
match d with
| P _ | E _ | M _ | C _ -> None
| V v ->
match v.ValReprInfo with
| None ->
// the "pass a single function to a function case"?
let _, tau = v.TypeScheme
if isFunTy cenv.g tau then
Some [v.DisplayName]
else
None
| Some info ->
info.ArgNames


member x.ReturnParameter =
checkIsResolved()
match d with
Expand Down
18 changes: 7 additions & 11 deletions src/fsharp/symbols/Symbols.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -861,10 +861,14 @@ type FSharpMemberOrFunctionOrValue =
/// Get the name as presented in F# error messages and documentation
member DisplayName: string

<<<<<<< HEAD
member CurriedParameterGroups: IList<IList<FSharpParameter>>

/// doop doop yeet yeet
member PossibleArgumentList : string list option
=======
/// List of list of parameters. Typically, there is only one nested list.
/// However, code such as 'f (a, b) (c, d)' contains two groups, each with two parameters.
/// In that example, there is a list made up of two lists, each with a parameter.
member CurriedParameterGroups : IList<IList<FSharpParameter>>
>>>>>>> 8dc6b59f9... Cleanup, handle method params properly, constructors

/// Gets the overloads for the current method
/// matchParameterNumber indicates whether to filter the overloads to match the number of parameters in the current symbol
Expand Down Expand Up @@ -914,7 +918,6 @@ type FSharpMemberOrFunctionOrValue =
member IsConstructor: bool

/// Format the type using the rules of the given display context
<<<<<<< HEAD
member FormatLayout: context: FSharpDisplayContext -> Layout

/// Format the type using the rules of the given display context
Expand All @@ -923,13 +926,6 @@ type FSharpMemberOrFunctionOrValue =
/// Check if this method has an entrpoint that accepts witness arguments and if so return
/// the name of that entrypoint and information about the additional witness arguments
member GetWitnessPassingInfo: unit -> (string * IList<FSharpParameter>) option
=======
member FormatLayout : displayContext: FSharpDisplayContext -> Layout

/// Format the type using the rules of the given display context
member GetReturnTypeLayout : displayContext: FSharpDisplayContext -> Layout option

>>>>>>> ac5c7ef5f... Match names

/// A subtype of FSharpSymbol that represents a parameter
[<Class>]
Expand Down
19 changes: 15 additions & 4 deletions tests/FSharp.Compiler.Service.Tests/SurfaceArea.netstandard.fs
Original file line number Diff line number Diff line change
Expand Up @@ -22504,7 +22504,6 @@ FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: FSharp.Compile
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Int32 GetEffectivelySameAsHash()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Int32 GetHashCode()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Internal.Utilities.StructuredFormat.Layout FormatLayout(FSharp.Compiler.SourceCodeServices.FSharpDisplayContext)
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[Internal.Utilities.StructuredFormat.Layout]
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[Internal.Utilities.StructuredFormat.Layout] GetReturnTypeLayout(FSharp.Compiler.SourceCodeServices.FSharpDisplayContext)
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Range+range] DeclarationLocation
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Range+range] ImplementationLocation
Expand All @@ -22527,8 +22526,6 @@ FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collect
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collections.Generic.IList`1[FSharp.Compiler.SourceCodeServices.FSharpGenericParameter] get_GenericParameters()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[FSharp.Compiler.SourceCodeServices.FSharpParameter]] CurriedParameterGroups
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collections.Generic.IList`1[System.Collections.Generic.IList`1[FSharp.Compiler.SourceCodeServices.FSharpParameter]] get_CurriedParameterGroups()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]] PossibleArgumentList
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[System.String]] get_PossibleArgumentList()
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collections.Generic.IList`1[System.String] ElaboratedXmlDoc
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collections.Generic.IList`1[System.String] XmlDoc
FSharp.Compiler.SourceCodeServices.FSharpMemberOrFunctionOrValue: System.Collections.Generic.IList`1[System.String] get_ElaboratedXmlDoc()
Expand Down Expand Up @@ -22680,6 +22677,19 @@ FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations: pos get_L
FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations: pos get_OpenParenLocation()
FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations: pos[] TupleEndLocations
FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations: pos[] get_TupleEndLocations()
FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations: FSharp.Compiler.SourceCodeServices.TupledArgumentLocation[] ArgLocations
FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations: FSharp.Compiler.SourceCodeServices.TupledArgumentLocation[] get_ArgLocations()
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Boolean Equals(FSharp.Compiler.SourceCodeServices.TupledArgumentLocation)
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Boolean Equals(System.Object)
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Boolean Equals(System.Object, System.Collections.IEqualityComparer)
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Boolean IsNamedArgument
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Boolean get_IsNamedArgument()
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Int32 GetHashCode()
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Int32 GetHashCode(System.Collections.IEqualityComparer)
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: System.String ToString()
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: Void .ctor(Boolean, range)
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: range ArgumentRange
FSharp.Compiler.SourceCodeServices.TupledArgumentLocation: range get_ArgumentRange()
FSharp.Compiler.SourceCodeServices.FSharpObjectExprOverride: FSharp.Compiler.SourceCodeServices.FSharpAbstractSignature Signature
FSharp.Compiler.SourceCodeServices.FSharpObjectExprOverride: FSharp.Compiler.SourceCodeServices.FSharpAbstractSignature get_Signature()
FSharp.Compiler.SourceCodeServices.FSharpObjectExprOverride: FSharp.Compiler.SourceCodeServices.FSharpExpr Body
Expand Down Expand Up @@ -22746,7 +22756,8 @@ FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: FSharp.Compiler.Sourc
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.Range+range] ValidateBreakpointLocation(pos)
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SourceCodeServices.FSharpNoteworthyParamInfoLocations] FindNoteworthyParamInfoLocations(pos)
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Boolean IsTypeAnnotationGiven(pos)
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Range+range]] GetAllArgumentsForFunctionApplication(pos)
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Boolean IsBindingALambda(pos)
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[Microsoft.FSharp.Collections.FSharpList`1[FSharp.Compiler.Range+range]] GetAllArgumentsForFunctionApplicationAtPostion(pos)
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTree+ParsedInput] ParseTree
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: Microsoft.FSharp.Core.FSharpOption`1[FSharp.Compiler.SyntaxTree+ParsedInput] get_ParseTree()
FSharp.Compiler.SourceCodeServices.FSharpParseFileResults: System.String FileName
Expand Down
Loading