diff options
author | nosami <jasonimison@gmail.com> | 2019-05-03 12:27:53 +0300 |
---|---|---|
committer | nosami <jasonimison@gmail.com> | 2019-05-08 12:07:24 +0300 |
commit | 9690b1240bdbb427a6776250bb660799ed8945c6 (patch) | |
tree | 035764ef713a2c16512fb528affce97f44e4a65c /main/external/fsharpbinding | |
parent | b3e30152db46e70acbfce985847cfc4dde8bf62e (diff) |
Update FSharp.Compiler.Service
Fixes VSTS #889046
Diffstat (limited to 'main/external/fsharpbinding')
51 files changed, 1135 insertions, 1134 deletions
diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Completions.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Completions.fs index fc4962873f..e6561f227d 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Completions.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Completions.fs @@ -1,9 +1,8 @@ namespace MonoDevelop.FSharp.Shared -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.Interactive.Shell -open System +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.Interactive.Shell open System.IO type CompletionData = { diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Extensions.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Extensions.fs index 0924a97a9b..62f48cdbea 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Extensions.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Extensions.fs @@ -4,7 +4,7 @@ open System.Collections open System.Text open System.Threading.Tasks open System.IO -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open ExtCore module Seq = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/FSharpSymbolHelper.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/FSharpSymbolHelper.fs index a1c451a42a..b78c8be5a1 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/FSharpSymbolHelper.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/FSharpSymbolHelper.fs @@ -2,8 +2,8 @@ open System open System.Collections.Generic open System.Text -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices module Symbols = let getLocationFromSymbolUse (s: FSharpSymbolUse) = @@ -647,7 +647,10 @@ module SymbolTooltips = sprintf "%s%s<small>Namespace:\t%s</small>%s<small>Assembly:\t%s</small>" fullName Environment.NewLine ns Environment.NewLine c.Assembly.SimpleName | Field f -> - let parent = f.DeclaringEntity.UnAnnotate().DisplayName + let parent = + match f.DeclaringEntity with + | Some ent -> ent.DisplayName + | None -> "No declaring entity" sprintf "<small>From type:\t%s</small>%s<small>Assembly:\t%s</small>" parent Environment.NewLine f.Assembly.SimpleName | ActivePatternCase ap -> diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Lexer.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Lexer.fs index 6b9478609c..d25d4f643f 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Lexer.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/Lexer.fs @@ -1,7 +1,7 @@ namespace MonoDevelop.FSharp.Shared open System.Diagnostics -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices type SymbolKind = | Ident @@ -48,7 +48,7 @@ module Lexer = let sourceTokenizer = FSharpSourceTokenizer(defines, None) let lines = String.getLines source - let mutable lexState = 0L + let mutable lexState = FSharpTokenizerLexState.Initial for line in lines do yield lexState let lineTokenizer = sourceTokenizer.CreateLineTokenizer line @@ -75,7 +75,7 @@ module Lexer = Debug.Assert(line >= 0 && line < Array.length lexStates, "Should have lex states for every line.") lexStates.[line] - let singleLineQueryLexState _ _ _ = 0L + let singleLineQueryLexState _ _ _ = FSharpTokenizerLexState.Initial /// Return all tokens of current line let tokenizeLine source (args: string[]) line lineStr queryLexState = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj index 9053bf663b..3b00e27807 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/MonoDevelop.FSharp.Shared.fsproj @@ -51,7 +51,7 @@ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'"> <ItemGroup> <Reference Include="FSharp.Compiler.Service"> - <HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath> + <HintPath>..\packages\FSharp.Compiler.Service\lib\net461\FSharp.Compiler.Service.dll</HintPath> <Private>True</Private> <Paket>True</Paket> </Reference> diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/ParameterHinting.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/ParameterHinting.fs index 3767475adc..80f15291cc 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/ParameterHinting.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Shared/ParameterHinting.fs @@ -1,5 +1,5 @@ namespace MonoDevelop.FSharp.Shared -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices module ParameterHinting = let getTooltipInformation (symbol: FSharpSymbolUse) = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/GlobalSearch.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/GlobalSearch.fs index e1a936acff..006ad65939 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/GlobalSearch.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/GlobalSearch.fs @@ -1,6 +1,6 @@ namespace MonoDevelopTests open System.Collections.Generic -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open NUnit.Framework open FsUnit open MonoDevelop.FSharp diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj index 7475932843..e3d2f9e02a 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/MonoDevelop.FSharp.Tests.fsproj @@ -21,8 +21,6 @@ <StartArguments>run-md-tests $(MSBuildProjectDirectory)\..\..\..\build\tests\MonoDevelop.FSharp.Tests.dll</StartArguments> <EnablePrivateAssetsLocalCopyWorkaround>false</EnablePrivateAssetsLocalCopyWorkaround> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> <ItemGroup> <Reference Include="System" /> <Reference Include="System.Xml" /> @@ -175,6 +173,17 @@ </Properties> </MonoDevelop> </ProjectExtensions> + <ItemGroup> + <IncludeCopyLocal Include="System.Reactive.dll" /> + <IncludeCopyLocal Include="Newtonsoft.Json.dll" /> + <IncludeCopyLocal Include="ExtCore.dll" /> + <IncludeCopyLocal Include="Fantomas.dll" /> + <IncludeCopyLocal Include="FSharp.Compiler.CodeDom.dll" /> + <IncludeCopyLocal Include="FSharp.Compiler.Service.dll" /> + <IncludeCopyLocal Include="FSharp.Core.dll" /> + <IncludeCopyLocal Include="MonoDevelop.FSharp.Shared.dll" /> + <IncludeCopyLocal Include="FSharp.Compiler.Interactive.Settings.dll" /> + </ItemGroup> <Choose> <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'"> <ItemGroup> @@ -189,17 +198,8 @@ <Choose> <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'"> <ItemGroup> - <Reference Include="ISymWrapper, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"> - <Paket>True</Paket> - </Reference> - <Reference Include="System.IO"> - <Paket>True</Paket> - </Reference> - <Reference Include="System.Runtime"> - <Paket>True</Paket> - </Reference> <Reference Include="FSharp.Compiler.Service"> - <HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath> + <HintPath>..\packages\FSharp.Compiler.Service\lib\net461\FSharp.Compiler.Service.dll</HintPath> <Private>True</Private> <Paket>True</Paket> </Reference> @@ -287,16 +287,5 @@ </ItemGroup> </When> </Choose> - <ItemGroup> - <IncludeCopyLocal Include="System.Reactive.dll" /> - <IncludeCopyLocal Include="Newtonsoft.Json.dll" /> - <IncludeCopyLocal Include="ExtCore.dll" /> - <IncludeCopyLocal Include="Fantomas.dll" /> - <IncludeCopyLocal Include="FSharp.Compiler.CodeDom.dll" /> - <IncludeCopyLocal Include="FSharp.Compiler.Service.dll" /> - <IncludeCopyLocal Include="FSharp.Core.dll" /> - <IncludeCopyLocal Include="MonoDevelop.FSharp.Shared.dll" /> - <IncludeCopyLocal Include="FSharp.Compiler.Interactive.Settings.dll" /> - </ItemGroup> <Import Project="..\packages\StrongNamer\build\StrongNamer.targets" Condition="Exists('..\packages\StrongNamer\build\StrongNamer.targets')" Label="Paket" /> </Project>
\ No newline at end of file diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs index 02b78fe646..5d842cb345 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TemplateTests.fs @@ -5,7 +5,7 @@ open System.Reflection open System.Runtime.CompilerServices open System.Threading.Tasks open FsUnit -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop.Core open MonoDevelop.FSharp open MonoDevelop.Ide diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TestHelpers.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TestHelpers.fs index a88abc4957..e0600fdb50 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TestHelpers.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TestHelpers.fs @@ -1,6 +1,6 @@ namespace MonoDevelopTests open System -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop.FSharp open MonoDevelop.Ide.Editor open MonoDevelop.Ide.TypeSystem diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs index 3e45607631..0f101c2c30 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/TypeSignatureHelp.fs @@ -1,6 +1,6 @@ namespace MonoDevelopTests open NUnit.Framework -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop.FSharp open MonoDevelop.FSharp.MonoDevelop open FsUnit diff --git a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/UnusedOpens.fs b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/UnusedOpens.fs index 391b9a87f3..6eb8d846c4 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/UnusedOpens.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharp.Tests/UnusedOpens.fs @@ -4,7 +4,7 @@ open NUnit.Framework open MonoDevelop.FSharp open MonoDevelop.Ide.Editor -open Microsoft.FSharp.Compiler +open FSharp.Compiler open System.Threading.Tasks open System.Runtime.CompilerServices diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/CodeFix/AddOpenCodeFixProvider.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/CodeFix/AddOpenCodeFixProvider.fs index 0ebc969b5d..fc8066e284 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/CodeFix/AddOpenCodeFixProvider.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/CodeFix/AddOpenCodeFixProvider.fs @@ -2,9 +2,10 @@ namespace MonoDevelop.FSharp open System -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.Range +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices.Extensions open MonoDevelop.FSharp open MonoDevelop open MonoDevelop.Ide.Editor @@ -102,7 +103,7 @@ module internal FSharpAddOpenCodeFixProvider = xs |> Seq.map (fun (_, name, ctx) -> name, ctx) |> Seq.distinctBy (fun (name, _) -> name) - |> Seq.sort + |> Seq.sortBy(fun (name, _) -> name) |> Seq.toArray) |> Seq.map (fun (ns, names) -> let multipleNames = names |> Array.length > 1 @@ -126,6 +127,12 @@ module internal FSharpAddOpenCodeFixProvider = let isAttribute = UntypedParseImpl.GetEntityKind(unresolvedIdentRange.Start, parsedInput) = Some EntityKind.Attribute + let replace index value (array: _ []) = + if index >= array.Length then raise (IndexOutOfRangeException "index") + let res = Array.copy array + res.[index] <- value + res + let entities = assemblyContentProvider.GetAllEntitiesInProjectAndReferencedAssemblies checkResults |> List.collect (fun e -> @@ -138,9 +145,9 @@ module internal FSharpAddOpenCodeFixProvider = e.AutoOpenParent, e.Namespace, e.CleanedIdents - |> Array.replace (e.CleanedIdents.Length - 1) (lastIdent.Substring(0, lastIdent.Length - 9)) ]) + |> replace (e.CleanedIdents.Length - 1) (lastIdent.Substring(0, lastIdent.Length - 9)) ]) - let longIdent = ParsedInput.getLongIdentAt parsedInput unresolvedIdentRange.End + let longIdent = FSharp.Compiler.SourceCodeServices.ParsedInput.getLongIdentAt parsedInput unresolvedIdentRange.End let! maybeUnresolvedIdents = longIdent @@ -150,7 +157,8 @@ module internal FSharpAddOpenCodeFixProvider = { Ident = ident.idText Resolved = false }) |> List.toArray) - let createEntity = ParsedInput.tryFindInsertionContext unresolvedIdentRange.StartLine parsedInput maybeUnresolvedIdents + + let createEntity = ParsedInput.tryFindInsertionContext unresolvedIdentRange.StartLine parsedInput maybeUnresolvedIdents OpenStatementInsertionPoint.TopLevel let candidates = entities |> Seq.map createEntity |> Seq.concat |> Seq.toList return getSuggestions editor monitor candidates |> Seq.toList } diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpBraceMatcher.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpBraceMatcher.fs index e87085a1d7..1595b0a0bc 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpBraceMatcher.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpBraceMatcher.fs @@ -4,7 +4,7 @@ open System open System.Threading.Tasks open MonoDevelop.Core.Text open MonoDevelop.Ide.Editor -open Microsoft.FSharp.Compiler +open FSharp.Compiler module braceMatcher = let noMatch = Nullable() diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpDebuggerExpressionResolver.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpDebuggerExpressionResolver.fs index 8c69e79dca..80c8abda4e 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpDebuggerExpressionResolver.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpDebuggerExpressionResolver.fs @@ -1,6 +1,6 @@ namespace MonoDevelop.FSharp -open Microsoft.FSharp.Compiler +open FSharp.Compiler open MonoDevelop open MonoDevelop.Ide.Editor.Extension open MonoDevelop.Debugger diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs index 91d630c76f..fe193328f5 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpFormatter.fs @@ -8,8 +8,9 @@ open MonoDevelop.Projects.Policies open MonoDevelop.Ide.CodeFormatting open Fantomas open Fantomas.FormatConfig -open Microsoft.FSharp.Compiler -open ExtCore.Control +open FSharp.Compiler +open FSharp.Compiler.Range +//open ExtCore.Control open MonoDevelop.Core.Text type FormattingOption = @@ -22,10 +23,10 @@ type FSharpFormatter() = let offsetToPos (positions : _ []) offset = let rec searchPos start finish = if start >= finish then None - elif start + 1 = finish then Some(Range.mkPos (start + 1) (offset - positions.[start])) + elif start + 1 = finish then Some(mkPos (start + 1) (offset - positions.[start])) else let mid = (start + finish) / 2 - if offset = positions.[mid] then Some(Range.mkPos (mid + 1) 0) + if offset = positions.[mid] then Some(mkPos (mid + 1) 0) elif offset > positions.[mid] then searchPos mid finish else searchPos start mid searchPos 0 (positions.Length - 1) @@ -76,8 +77,7 @@ type FSharpFormatter() = | Document, Some projectOptions -> let output = try - let checker = SourceCodeServices.FSharpChecker.Create() - let parsingOptions, _errors = checker.GetParsingOptionsFromProjectOptions(projectOptions) + let parsingOptions, _errors = languageService.Checker.GetParsingOptionsFromProjectOptions(projectOptions) let formatted = CodeFormatter.FormatDocumentAsync(filename, input, config, parsingOptions, languageService.Checker) |> Async.RunSynchronously @@ -108,7 +108,7 @@ type FSharpFormatter() = maybe { let! startPos = offsetToPos positions (max 0 fromOffset) let! endPos = offsetToPos positions (min input.Length toOffset+1) - let range = Range.mkRange "/tmp.fsx" startPos endPos + let range = FSharp.Compiler.Range.mkRange "/tmp.fsx" startPos endPos LoggingService.LogDebug("**Fantomas**: Try to format range {0}.", range) let! result = try @@ -135,6 +135,7 @@ type FSharpFormatter() = | None -> StringTextSource.Empty formatted :> _ | _, None -> StringTextSource input :> _ + let formatText (editor : Editor.TextEditor option) (policyParent : PolicyContainer) (mimeType:string) input formattingOption = let textStylePolicy = policyParent.Get<TextStylePolicy>(mimeType) let formattingPolicy = policyParent.Get<FSharpFormattingPolicy>(mimeType) diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs index 16a0ab8088..3cac905401 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpHighlightUsagesExtension.fs @@ -7,7 +7,7 @@ open MonoDevelop.Core open MonoDevelop.Ide open MonoDevelop.Ide.Editor.Extension open MonoDevelop.Ide.FindInFiles -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices /// MD/XS extension for highlighting the usages of a symbol within the current buffer. type HighlightUsagesExtension() = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpNavigationTextEditorExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpNavigationTextEditorExtension.fs index 6298b71192..d58af32bb4 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpNavigationTextEditorExtension.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpNavigationTextEditorExtension.fs @@ -3,8 +3,8 @@ open MonoDevelop open MonoDevelop.Ide.Editor open MonoDevelop.Ide.Editor.Extension -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices type FSharpNavigationTextEditorExtension() = inherit AbstractNavigationExtension() diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpOutlineTextEditorExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpOutlineTextEditorExtension.fs index 957c180354..a701e77c91 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpOutlineTextEditorExtension.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpOutlineTextEditorExtension.fs @@ -10,7 +10,7 @@ open MonoDevelop.Ide.Editor.Extension open MonoDevelop.Ide.Gui.Components open MonoDevelop.Ide open MonoDevelop.Projects -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices type FSharpOutlineTextEditorExtension() as x = inherit TextEditorExtension() diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParsedDocument.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParsedDocument.fs index b3c7751bd7..94cf7d0c21 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParsedDocument.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParsedDocument.fs @@ -1,7 +1,7 @@ namespace MonoDevelop.FSharp -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open MonoDevelop open MonoDevelop.Core open MonoDevelop.Ide diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParser.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParser.fs index 5b2b0c5db6..9260f137fb 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParser.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpParser.fs @@ -1,7 +1,7 @@ namespace MonoDevelop.FSharp -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open MonoDevelop.Core open MonoDevelop.Ide open MonoDevelop.Ide.Editor diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpPathExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpPathExtension.fs index aa819db252..28923641d2 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpPathExtension.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpPathExtension.fs @@ -10,7 +10,7 @@ open MonoDevelop.Ide open MonoDevelop.Ide.Editor.Extension open MonoDevelop.Ide.Gui open MonoDevelop.Ide.Gui.Content -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open ExtCore.Control type FSharpPathExtension() as x = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpResolverProvider.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpResolverProvider.fs index 2332fd3ce5..5e51ecb79e 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpResolverProvider.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpResolverProvider.fs @@ -11,7 +11,7 @@ open MonoDevelop.Ide open MonoDevelop.Ide.Gui open MonoDevelop.Ide.Editor open MonoDevelop.Ide.Gui.Content -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open ExtCore.Control /// Resolves locations to NRefactory symbols and ResolveResult objects. diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSelection.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSelection.fs index b42771de94..3ee64dbc79 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSelection.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSelection.fs @@ -7,12 +7,11 @@ open MonoDevelop.Core open MonoDevelop.Ide open MonoDevelop.Ide.Editor open Mono.TextEditor -open ExtCore.Control -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range -open Microsoft.FSharp.Compiler.Ast -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.SourceCodeServices.AstTraversal +//open ExtCore.Control +open FSharp.Compiler +open FSharp.Compiler.Ast +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices.AstTraversal module ExpandSelection = type ExpandSelectionAnnotation(editor:TextEditor) = @@ -37,7 +36,7 @@ module ExpandSelection = let symbolStart, _symbolEnd = symbolRange symbolStart >= selection.Offset - let getExpandRange (editor:TextEditor, tree:ParsedInput) = + let getExpandRange (editor:TextEditor, tree:FSharp.Compiler.Ast.ParsedInput) = if not editor.IsSomethingSelected then let line = editor.GetLine editor.CaretLine if editor.CaretColumn = line.LengthIncludingDelimiter || editor.CaretOffset = line.Offset then @@ -46,7 +45,7 @@ module ExpandSelection = let data = editor.GetContent<ITextEditorDataProvider>().GetTextEditorData() Some (data.FindCurrentWordStart(editor.CaretOffset), data.FindCurrentWordEnd(editor.CaretOffset)) else - let rangeAsOffsets(range:Range.range) = + let rangeAsOffsets(range:FSharp.Compiler.Range.range) = let startPos = editor.LocationToOffset(range.StartLine, range.StartColumn + 1) let endPos = editor.LocationToOffset(range.EndLine, range.EndColumn + 1) (startPos, endPos) @@ -74,7 +73,7 @@ module ExpandSelection = else defaultTraverse(expr) } - let traversePath = AstTraversal.Traverse(mkPos editor.CaretLine (editor.CaretColumn), tree, walker) + let traversePath = AstTraversal.Traverse(FSharp.Compiler.Range.mkPos editor.CaretLine (editor.CaretColumn), tree, walker) let rangesFromTraverse = function | TraverseStep.Binding binding -> [binding.RangeOfHeadPat; binding.RangeOfBindingAndRhs; binding.RangeOfBindingSansRhs] diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSymbolHelper.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSymbolHelper.fs index bed368cf7f..ba4a1577ce 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSymbolHelper.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSymbolHelper.fs @@ -4,9 +4,8 @@ open System.Collections.Generic open System.IO open System.Text open System.Threading -open MonoDevelop.FSharp.Shared -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open Mono.TextEditor open Mono.TextEditor.Highlighting open MonoDevelop.Core @@ -31,7 +30,7 @@ module Symbols = ///Given a column and line string returns the identifier portion of the string let lastIdent column lineString = - match Parsing.findIdents column lineString SymbolLookupKind.ByLongIdent with + match MonoDevelop.FSharp.Shared.Parsing.findIdents column lineString MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent with | Some (_col, identIsland) -> Seq.last identIsland | None -> "" @@ -396,17 +395,17 @@ module SymbolTooltips = | true, false -> b | false, false -> a + " " + b - let formatSummary (summary:XmlDoc) = + let formatSummary (summary:MonoDevelop.FSharp.Shared.XmlDoc) = match summary with - | Full(summary) -> + | MonoDevelop.FSharp.Shared.Full(summary) -> TooltipsXml.getTooltipSummary Styles.simpleMarkup summary - | Lookup(key, potentialFilename) -> + | MonoDevelop.FSharp.Shared.Lookup(key, potentialFilename) -> maybe { let! filename = potentialFilename let! markup = TooltipXmlDoc.findDocForEntity(filename, key) let summary = TooltipsXml.getTooltipSummary Styles.simpleMarkup markup return summary } |> Option.fill "" - | EmptyDoc -> "" + | MonoDevelop.FSharp.Shared.EmptyDoc -> "" let getTooltipInformationFromTip tip = async { @@ -416,9 +415,10 @@ module SymbolTooltips = let toolTipInfo = new TooltipInformation(SignatureMarkup = signature, FooterMarkup=footer) let result = match xmldoc with - | Full(summary) -> toolTipInfo.SummaryMarkup <- summary - toolTipInfo - | Lookup(key, potentialFilename) -> + | MonoDevelop.FSharp.Shared.Full(summary) -> + toolTipInfo.SummaryMarkup <- summary + toolTipInfo + | MonoDevelop.FSharp.Shared.Lookup(key, potentialFilename) -> let summary = maybe { let! filename = potentialFilename let! markup = TooltipXmlDoc.findDocForEntity(filename, key) @@ -426,7 +426,7 @@ module SymbolTooltips = return summary } summary |> Option.iter (fun summary -> toolTipInfo.SummaryMarkup <- summary) toolTipInfo - | EmptyDoc -> toolTipInfo + | MonoDevelop.FSharp.Shared.EmptyDoc -> toolTipInfo return result with ex -> LoggingService.LogError ("F# Tooltip error", ex) @@ -443,13 +443,13 @@ module SymbolTooltips = let getTooltipInformationFromSignature summary signature parameterName = let summary, parameterInfo = match summary with - | Full(summary) -> + | MonoDevelop.FSharp.Shared.Full(summary) -> let parameterMarkup = match TooltipsXml.getParameterTip Styles.simpleMarkup summary parameterName with | Some p -> parameterName ++ ":" ++ p | None -> "" summary, parameterMarkup - | Lookup(key, filename) -> + | MonoDevelop.FSharp.Shared.Lookup(key, filename) -> let summaryAndparameterInfo = maybe { let! filename = filename let! markup = TooltipXmlDoc.findDocForEntity(filename, key) @@ -461,7 +461,7 @@ module SymbolTooltips = return (summary, parameterMarkup) } summaryAndparameterInfo |> Option.getOrElse (fun () -> "", "") - | EmptyDoc -> "", "" + | MonoDevelop.FSharp.Shared.EmptyDoc -> "", "" let toolTipInfo = TooltipInformation(SignatureMarkup = signature, SummaryMarkup=summary) if not (String.isNullOrEmpty parameterInfo) then toolTipInfo.AddCategory("Parameter", parameterInfo) diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSyntaxMode.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSyntaxMode.fs index 688ad63a5c..d3e311e3ce 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSyntaxMode.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpSyntaxMode.fs @@ -9,8 +9,8 @@ open MonoDevelop.Ide.Editor open MonoDevelop.Ide.Editor.Highlighting open MonoDevelop.Core open Mono.TextEditor.Highlighting -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open ExtCore.Control open MonoDevelop open Gtk @@ -351,8 +351,8 @@ module Patterns = | Some (tokens:_ list, symbols, colours, _formatters) when tokens.Length >= lineNumber -> let tokens, _lineText = tokens.[lineNumber-1] tokens - |> Lexer.fixTokens txt - |> List.choose (fun draft -> makeChunk symbols lineNumber lineOffset colours {draft.Token with RightColumn = draft.RightColumn} ) + |> MonoDevelop.FSharp.Shared.Lexer.fixTokens txt + |> List.choose (fun (draft:MonoDevelop.FSharp.Shared.DraftToken) -> makeChunk symbols lineNumber lineOffset colours {draft.Token with RightColumn = draft.RightColumn} ) |> List.toSeq | _ -> Seq.empty diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs index a04a5ac1ce..625bdaa875 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTextEditorCompletion.fs @@ -9,7 +9,7 @@ open System.Collections.Generic open System.Text.RegularExpressions open System.Threading.Tasks open Microsoft.CodeAnalysis.Text -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop open MonoDevelop.Core open MonoDevelop.FSharp.Shared @@ -472,7 +472,7 @@ module Completion = |> Seq.cast<CompletionData> result.AddRange completions - let _longName,residue = Parsing.findLongIdentsAndResidue(column, lineToCaret) + let _longName,residue = MonoDevelop.FSharp.Shared.Parsing.findLongIdentsAndResidue(column, lineToCaret) if completionChar <> '.' && result.Count > 0 then LoggingService.logDebug "Completion: residue %s" residue @@ -532,11 +532,11 @@ module Completion = let result = CompletionDataList() let addIdentCompletions() = - let (idents, residue) = Parsing.findLongIdentsAndResidue(column, lineToCaret) + let (idents, residue) = MonoDevelop.FSharp.Shared.Parsing.findLongIdentsAndResidue(column, lineToCaret) if idents.IsEmpty then let lineWithoutResidue = lineToCaret.[0..column-residue.Length-1] if not (lineWithoutResidue.EndsWith ".") then - let tokens = Lexer.tokenizeLine lineWithoutResidue [||] 0 lineWithoutResidue Lexer.singleLineQueryLexState + let tokens = MonoDevelop.FSharp.Shared.Lexer.tokenizeLine lineWithoutResidue [||] 0 lineWithoutResidue Lexer.singleLineQueryLexState let tokenToCompletion (token:FSharpTokenInfo) = let displayText = lineToCaret.[token.LeftColumn..token.RightColumn] CompletionData(displayText, IconId "md-fs-field", displayText, displayText) @@ -572,7 +572,7 @@ module Completion = // can be empty when it comes after an application // such as DateTime.Now.ToString().Subs <- // Here, we do a simple lookup for `Subs` in the above example. - Parsing.findResidue lineToCaret + MonoDevelop.FSharp.Shared.Parsing.findResidue lineToCaret else residue @@ -620,7 +620,7 @@ module Completion = ctrlSpace = ctrlSpace } = context - let (_, residue) = Parsing.findLongIdentsAndResidue(column, lineToCaret) + let (_, residue) = MonoDevelop.FSharp.Shared.Parsing.findLongIdentsAndResidue(column, lineToCaret) let result = CompletionDataList() result.DefaultCompletionString <- residue result.TriggerWordLength <- residue.Length diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTokens.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTokens.fs index 1085155699..ae30dd34e9 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTokens.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTokens.fs @@ -1,5 +1,5 @@ namespace MonoDevelop.FSharp -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop open MonoDevelop.Core open MonoDevelop.FSharp.Shared @@ -10,17 +10,17 @@ open System.IO module Tokens = let getTokenAtPoint (editor:TextEditor) offset = let line, col, txt = editor.GetLineInfoFromOffset offset - Lexer.tokenizeLine txt [||] line txt Lexer.singleLineQueryLexState - |> Lexer.findTokenAt col + MonoDevelop.FSharp.Shared.Lexer.tokenizeLine txt [||] line txt Lexer.singleLineQueryLexState + |> MonoDevelop.FSharp.Shared.Lexer.findTokenAt col let isInvalidTipTokenAtPoint (editor:TextEditor) offset = match getTokenAtPoint editor offset with - | Some token -> Lexer.isNonTipToken token + | Some token -> MonoDevelop.FSharp.Shared.Lexer.isNonTipToken token | None -> true let isInvalidCompletionToken (token:FSharpTokenInfo option) = match token with - | Some token -> Lexer.isNonTipToken token + | Some token -> MonoDevelop.FSharp.Shared.Lexer.isNonTipToken token | None -> false let tryGetTokens source defines fileName = @@ -28,7 +28,7 @@ module Tokens = LoggingService.logDebug "FSharpParser: Processing tokens for %s" (Path.GetFileName fileName) let readOnlyDoc = TextEditorFactory.CreateNewReadonlyDocument (source, fileName) let lines = readOnlyDoc.GetLines() |> Seq.map readOnlyDoc.GetLineText - let tokens = Lexer.getTokensWithInitialState 0L lines (Some fileName) defines + let tokens = MonoDevelop.FSharp.Shared.Lexer.getTokensWithInitialState FSharpTokenizerLexState.Initial lines (Some fileName) defines Some(tokens) with ex -> LoggingService.LogWarning ("FSharpParser: Couldn't update token information for {0}", Path.GetFileName fileName, ex) diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTooltipProvider.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTooltipProvider.fs index 49e47aaa10..a394d12a44 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTooltipProvider.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpTooltipProvider.fs @@ -13,13 +13,13 @@ open MonoDevelop.FSharp.Shared open MonoDevelop.Ide open MonoDevelop.Ide.CodeCompletion open MonoDevelop.Ide.Editor -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open ExtCore.Control module TooltipImpl = let extraKeywords = ["let!";"do!";"return!";"use!";"yield!";"->";"<-";"<@";"@>";"<@@";"@@>";":>";":?>"] let tryKeyword col lineStr = - maybe {let! (_col, keyword) = Parsing.findIdents col lineStr SymbolLookupKind.Simple + maybe {let! (_col, keyword) = MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.Simple let! keyword = keyword |> List.tryHead if PrettyNaming.KeywordNames |> List.contains keyword || extraKeywords |> List.contains keyword then return keyword @@ -30,7 +30,7 @@ module MDTooltip = let startOffset = editor.LocationToOffset(line, col - keyword.Length+1) let endOffset = startOffset + keyword.Length let segment = Text.TextSegment.FromBounds(startOffset, endOffset) - let tip = SymbolTooltips.getKeywordTooltip keyword + let tip = MonoDevelop.FSharp.Shared.SymbolTooltips.getKeywordTooltip keyword TooltipItem( tip, segment :> Text.ISegment) /// Resolves locations to tooltip items, and orchestrates their display. @@ -68,7 +68,7 @@ type FSharpTooltipProvider() = | Some ast -> let! symbol = ast.GetSymbolAtLocation(line, col, lineStr) |> AsyncChoice.ofOptionWith "TooltipProvider: ParseAndCheckResults not found" let! signature, xmldoc, footer = - SymbolTooltips.getTooltipFromSymbolUse symbol + MonoDevelop.FSharp.Shared.SymbolTooltips.getTooltipFromSymbolUse symbol |> Choice.ofOptionWith (sprintf "TooltipProvider: TootipText not returned\n %s\n %s" lineStr (String.replicate col "-" + "^")) let highlightedTip = syntaxHighlight signature, xmldoc, footer diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpUnitTestTextEditorExtension.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpUnitTestTextEditorExtension.fs index 71097e2d33..afe1eff6bb 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpUnitTestTextEditorExtension.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/FSharpUnitTestTextEditorExtension.fs @@ -7,7 +7,7 @@ open MonoDevelop.Core open MonoDevelop.Ide.Editor open MonoDevelop.UnitTesting open MonoDevelop.Projects -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices module unitTestGatherer = let hasAttributeNamed (att:FSharpAttribute) (unitTestMarkers: IUnitTestMarkers[]) (filter: string -> IUnitTestMarkers -> bool) = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/HighlightUnusedCode.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/HighlightUnusedCode.fs index 4abe8453a6..9c15e15a5d 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/HighlightUnusedCode.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/HighlightUnusedCode.fs @@ -4,8 +4,8 @@ open MonoDevelop open MonoDevelop.Core open MonoDevelop.Ide.Editor open MonoDevelop.Ide.Editor.Extension -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler module highlightUnusedCode = let getOffset (editor:TextEditor) (pos:Range.pos) = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj index 6e36304812..d332874952 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/MonoDevelop.FSharp.fsproj @@ -22,8 +22,6 @@ <StartProgram>$(MSBuildProjectDirectory)\..\..\..\build\bin\MonoDevelop.exe</StartProgram> <StartWorkingDirectory>$(MSBuildProjectDirectory)\..\..\..\build\bin</StartWorkingDirectory> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> <Target Name="Clean"> <RemoveDir Directories="..\bin\" /> </Target> @@ -238,7 +236,7 @@ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'"> <ItemGroup> <Reference Include="FSharp.Compiler.Service"> - <HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath> + <HintPath>..\packages\FSharp.Compiler.Service\lib\net461\FSharp.Compiler.Service.dll</HintPath> <Private>True</Private> <Paket>True</Paket> </Reference> @@ -380,4 +378,4 @@ </When> </Choose> <Import Project="..\packages\StrongNamer\build\StrongNamer.targets" Condition="Exists('..\packages\StrongNamer\build\StrongNamer.targets')" Label="Paket" /> -</Project> +</Project>
\ No newline at end of file diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ProjectSearchCategory.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ProjectSearchCategory.fs index d210024e1d..59bd0d9bf3 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ProjectSearchCategory.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ProjectSearchCategory.fs @@ -7,7 +7,7 @@ open MonoDevelop.Components.MainToolbar open MonoDevelop.Ide open MonoDevelop.Ide.Gui open MonoDevelop.Projects -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open Symbols [<AutoOpen>] diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/RefactoringOperationsHandler.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/RefactoringOperationsHandler.fs index afe30c6712..c96910f53b 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/RefactoringOperationsHandler.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/RefactoringOperationsHandler.fs @@ -11,8 +11,8 @@ open MonoDevelop.Ide open MonoDevelop.Ide.Editor open MonoDevelop.Projects open MonoDevelop.Refactoring -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open MonoDevelop.Ide.FindInFiles open ExtCore.Control @@ -697,7 +697,7 @@ open Microsoft.CodeAnalysis open Mono.Addins open Microsoft.CodeAnalysis.CodeFixes open MonoDevelop.FSharp.Editor -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.Range open MonoDevelop.FSharp.Shared type QuickFixMenuHandler() = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ScriptDebugging.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ScriptDebugging.fs index ad46402774..2ce7d806e1 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ScriptDebugging.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/ScriptDebugging.fs @@ -3,7 +3,7 @@ open System open System.IO open System.Threading open System.Threading.Tasks -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop.Components.Commands open MonoDevelop.Core open MonoDevelop.Core.Assemblies diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs index 622d327844..94ba6163c1 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/CompilerArguments.fs @@ -15,7 +15,7 @@ open MonoDevelop.Core.Assemblies open MonoDevelop.Core open ExtCore open ExtCore.Control -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices // -------------------------------------------------------------------------------------- // Common utilities for working with files & extracting information from diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/Extensions.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/Extensions.fs index f3b110a7da..d8fbddd3f7 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/Extensions.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/Extensions.fs @@ -4,7 +4,7 @@ open System.Text open System.IO open System.Threading open System.Threading.Tasks -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices open MonoDevelop.Core open System.Reactive.Linq diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/FileService.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/FileService.fs index 9e4ee5c926..ec6db23f23 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/FileService.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/FileService.fs @@ -1,5 +1,5 @@ namespace MonoDevelop.FSharp -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.AbstractIL.Internal.Library open System.IO open MonoDevelop.Ide open MonoDevelop.Ide.Gui diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs index e5b6188375..ecb23511cc 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/LanguageService.fs @@ -3,8 +3,8 @@ open System open System.Collections.Generic open System.IO open System.Diagnostics -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices open ExtCore.Control open ExtCore.Control.Collections open MonoDevelop.Core @@ -66,7 +66,7 @@ type ParseAndCheckResults (infoOpt : FSharpCheckFileResults option, parseResults async { match infoOpt with | Some checkResults -> - match Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent with + match MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent with | None -> return None | Some(col,identIsland) -> let! res = checkResults.GetToolTipText(line, col, lineStr, identIsland, FSharpTokenTag.Identifier) @@ -77,7 +77,7 @@ type ParseAndCheckResults (infoOpt : FSharpCheckFileResults option, parseResults async { match infoOpt with | Some checkResults -> - match Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent with + match MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent with | None -> return FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "No idents found") | Some(col,identIsland) -> return! checkResults.GetDeclarationLocation(line, col, lineStr, identIsland, false) | None -> return FSharpFindDeclResult.DeclNotFound (FSharpFindDeclFailureReason.Unknown "No check results")} @@ -86,8 +86,8 @@ type ParseAndCheckResults (infoOpt : FSharpCheckFileResults option, parseResults async { match infoOpt with | Some (checkResults) -> - match Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent - |> Option.orTry (fun () -> Parsing.findIdents col lineStr SymbolLookupKind.Fuzzy) with + match MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent + |> Option.orTry (fun () -> MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.Fuzzy) with | None -> return None | Some(colu, identIsland) -> try @@ -106,7 +106,7 @@ type ParseAndCheckResults (infoOpt : FSharpCheckFileResults option, parseResults let column = lineToCaret |> Seq.tryFindIndexBack (fun c -> c <> '(' && c <> ' ') match column with | Some col -> - match Parsing.findIdents (col-1) lineToCaret SymbolLookupKind.ByLongIdent with + match MonoDevelop.FSharp.Shared.Parsing.findIdents (col-1) lineToCaret MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent with | None -> return None | Some(colu, identIsland) -> return! checkResults.GetMethodsAsSymbols(line, colu, lineToCaret, identIsland) @@ -503,7 +503,7 @@ type LanguageService(dirtyNotify, _extraProjectInfo) as x = member x.GetUsesOfSymbolAtLocationInFile(projectFilename, fileName, version, source, line:int, col, lineStr) = asyncMaybe { LoggingService.logDebug "LanguageService: GetUsesOfSymbolAtLocationInFile: file:%s, line:%i, col:%i" (Path.GetFileName(fileName)) line col - let! _colu, identIsland = Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent |> async.Return + let! _colu, identIsland = MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent |> async.Return let! results = x.GetTypedParseResultWithTimeout(projectFilename, fileName, version, source, AllowStaleResults.MatchingSource) let! symbolUse = results.GetSymbolAtLocation(line, col, lineStr) let lastIdent = Seq.last identIsland @@ -513,7 +513,7 @@ type LanguageService(dirtyNotify, _extraProjectInfo) as x = member x.GetSymbolAtLocationInFile(projectFilename, fileName, version, source, line:int, col, lineStr) = asyncMaybe { LoggingService.logDebug "LanguageService: GetUsesOfSymbolAtLocationInFile: file:%s, line:%i, col:%i" (Path.GetFileName(fileName)) line col - let! _colu, identIsland = Parsing.findIdents col lineStr SymbolLookupKind.ByLongIdent |> async.Return + let! _colu, identIsland = MonoDevelop.FSharp.Shared.Parsing.findIdents col lineStr MonoDevelop.FSharp.Shared.SymbolLookupKind.ByLongIdent |> async.Return let! results = x.GetTypedParseResultWithTimeout(projectFilename, fileName, version, source, AllowStaleResults.MatchingSource) let! symbolUse = results.GetSymbolAtLocation(line, col, lineStr) let lastIdent = Seq.last identIsland diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/MDLanguageService.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/MDLanguageService.fs index b7c2e22bc5..020984818f 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/MDLanguageService.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/MDLanguageService.fs @@ -20,8 +20,8 @@ open MonoDevelop.Ide open MonoDevelop.Ide.Editor open MonoDevelop.Core open MonoDevelop.Projects -open Microsoft.FSharp.Compiler.SourceCodeServices -open Microsoft.FSharp.Compiler.AbstractIL.Internal.Library +open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.Internal.Library open MonoDevelop.Ide.TypeSystem module MonoDevelop = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/RoslynHelpers.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/RoslynHelpers.fs index 24d2c3c190..7df93b10ee 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/RoslynHelpers.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/RoslynHelpers.fs @@ -2,7 +2,7 @@ namespace MonoDevelop.FSharp open System open System.Collections.Immutable -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices module RoslynHelpers = ///Barebones symbol diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/TooltipHelpers.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/TooltipHelpers.fs index 5562cbaee5..9d7f294191 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/TooltipHelpers.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/Services/TooltipHelpers.fs @@ -10,6 +10,7 @@ open System.Xml open System.Xml.Linq open MonoDevelop.Core open ExtCore.Control +open FSharp.Compiler.SourceCodeServices [<RequireQualifiedAccess>] type Style = @@ -273,7 +274,7 @@ module TooltipXmlDoc = /// Formatting of TooltipElement information displayed in tooltips and autocompletion module TooltipFormatting = - open Microsoft.FSharp.Compiler.SourceCodeServices + open FSharp.Compiler.SourceCodeServices /// Format some of the data returned by the F# compiler let private buildFormatComment cmt = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs index f559a7ea82..735a954fd2 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/TypeSignatureHelp.fs @@ -10,8 +10,8 @@ open MonoDevelop.Components.Commands open MonoDevelop.Core open MonoDevelop.Ide.Editor open MonoDevelop.Ide.Editor.Extension -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler +open FSharp.Compiler.SourceCodeServices type SignatureHelpMarker(document, text, font, line, isFromFSharpType) = inherit TextLineMarker() diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/AssemblyContentProvider.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/AssemblyContentProvider.fs index 1b95a839af..808ac3834d 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/AssemblyContentProvider.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/AssemblyContentProvider.fs @@ -5,7 +5,7 @@ namespace MonoDevelop.FSharp open System open System.ComponentModel.Composition -open Microsoft.FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.SourceCodeServices [<Export(typeof<AssemblyContentProvider>); Composition.Shared>] type internal AssemblyContentProvider () = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/CommonRoslynHelpers.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/CommonRoslynHelpers.fs index 1bb65431ae..ecfdd85b93 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/CommonRoslynHelpers.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/CommonRoslynHelpers.fs @@ -4,7 +4,7 @@ namespace MonoDevelop.FSharp.Editor open System.Threading.Tasks open Microsoft.CodeAnalysis.Text -open Microsoft.FSharp.Compiler.Range +open FSharp.Compiler.Range module CommonRoslynHelpers = diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/ServiceAssemblyContent.fs b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/ServiceAssemblyContent.fs index 340c029281..49e3ffd987 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/ServiceAssemblyContent.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpBinding/VS/ServiceAssemblyContent.fs @@ -1,23 +1,23 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. +//// Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. -//---------------------------------------------------------------------------- -// Open up the compiler as an incremental service for parsing, -// type checking and intellisense-like environment-reporting. -//-------------------------------------------------------------------------- +////---------------------------------------------------------------------------- +//// Open up the compiler as an incremental service for parsing, +//// type checking and intellisense-like environment-reporting. +////-------------------------------------------------------------------------- -namespace Microsoft.FSharp.Compiler.SourceCodeServices +namespace FSharp.Compiler.SourceCodeServices open System -open Microsoft.FSharp.Compiler.Ast -open System.Collections.Generic -open Microsoft.FSharp.Compiler -open Microsoft.FSharp.Compiler.Range +//open FSharp.Compiler.Ast +//open System.Collections.Generic +//open FSharp.Compiler +//open FSharp.Compiler.Range -type internal ShortIdent = string -type Idents = ShortIdent[] -type MaybeUnresolvedIdent = { Ident: ShortIdent; Resolved: bool } -type MaybeUnresolvedIdents = MaybeUnresolvedIdent[] -type IsAutoOpen = bool +//type internal ShortIdent = string +//type Idents = ShortIdent[] +//type MaybeUnresolvedIdent = { Ident: ShortIdent; Resolved: bool } +//type MaybeUnresolvedIdents = MaybeUnresolvedIdent[] +//type IsAutoOpen = bool [<AutoOpen>] module internal Extensions = @@ -37,988 +37,991 @@ module internal Extensions = res.[index] <- value res - /// Optimized arrays equality. ~100x faster than `array1 = array2` on strings. - /// ~2x faster for floats - /// ~0.8x slower for ints - let inline areEqual (xs: 'T []) (ys: 'T []) = - match xs, ys with - | null, null -> true - | [||], [||] -> true - | null, _ | _, null -> false - | _ when xs.Length <> ys.Length -> false - | _ -> - let mutable break' = false - let mutable i = 0 - let mutable result = true - while i < xs.Length && not break' do - if xs.[i] <> ys.[i] then - break' <- true - result <- false - i <- i + 1 - result - - /// Returns all heads of a given array. - /// For [|1;2;3|] it returns [|[|1; 2; 3|]; [|1; 2|]; [|1|]|] - let heads (array: 'T []) = - let res = Array.zeroCreate<'T[]> array.Length - for i = array.Length - 1 downto 0 do - res.[i] <- array.[0..i] - res - - /// check if subArray is found in the wholeArray starting - /// at the provided index - let inline isSubArray (subArray: 'T []) (wholeArray:'T []) index = - if isNull subArray || isNull wholeArray then false - elif subArray.Length = 0 then true - elif subArray.Length > wholeArray.Length then false - elif subArray.Length = wholeArray.Length then areEqual subArray wholeArray else - let rec loop subidx idx = - if subidx = subArray.Length then true - elif subArray.[subidx] = wholeArray.[idx] then loop (subidx+1) (idx+1) - else false - loop 0 index - - /// Returns true if one array has another as its subset from index 0. - let startsWith (prefix: _ []) (whole: _ []) = - isSubArray prefix whole 0 - - /// Returns true if one array has trailing elements equal to another's. - let endsWith (suffix: _ []) (whole: _ []) = - isSubArray suffix whole (whole.Length-suffix.Length) - - type FSharpEntity with - member x.TryGetFullName() = - try x.TryFullName - with _ -> - try Some(String.Join(".", x.AccessPath, x.DisplayName)) - with _ -> None - - member x.TryGetFullDisplayName() = - let fullName = x.TryGetFullName() |> Option.map (fun fullName -> fullName.Split '.') - let res = - match fullName with - | Some fullName -> - match Option.attempt (fun _ -> x.DisplayName) with - | Some shortDisplayName when not (shortDisplayName.Contains ".") -> - Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName) - | _ -> Some fullName - | None -> None - |> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName)) - //debug "GetFullDisplayName: FullName = %A, Result = %A" fullName res - res - - member x.TryGetFullCompiledName() = - let fullName = x.TryGetFullName() |> Option.map (fun fullName -> fullName.Split '.') - let res = - match fullName with - | Some fullName -> - match Option.attempt (fun _ -> x.CompiledName) with - | Some shortCompiledName when not (shortCompiledName.Contains ".") -> - Some (fullName |> Array.replace (fullName.Length - 1) shortCompiledName) - | _ -> Some fullName - | None -> None - |> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName)) - //debug "GetFullCompiledName: FullName = %A, Result = %A" fullName res - res - - member x.PublicNestedEntities = - x.NestedEntities |> Seq.filter (fun entity -> entity.Accessibility.IsPublic) - - member x.TryGetMembersFunctionsAndValues = - try x.MembersFunctionsAndValues with _ -> [||] :> _ - - let isOperator (name: string) = - name.StartsWith "( " && name.EndsWith " )" && name.Length > 4 - && name.Substring (2, name.Length - 4) - |> String.forall (fun c -> c <> ' ' && not (Char.IsLetter c)) - - type FSharpMemberOrFunctionOrValue with - // FullType may raise exceptions (see https://github.com/fsharp/fsharp/issues/307). - member x.FullTypeSafe = Option.attempt (fun _ -> x.FullType) - - member x.TryGetFullDisplayName() = - let fullName = Option.attempt (fun _ -> x.FullName.Split '.') - match fullName with - | Some fullName -> - match Option.attempt (fun _ -> x.DisplayName) with - | Some shortDisplayName when not (shortDisplayName.Contains ".") -> - Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName) - | _ -> Some fullName - | None -> None - |> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName)) - - //member x.TryGetFullCompiledOperatorNameIdents() : Idents option = - //// For operator ++ displayName is ( ++ ) compiledName is op_PlusPlus - //if isOperator x.DisplayName && x.DisplayName <> x.CompiledName then - // Option.attempt (fun _ -> x.EnclosingEntity) - // |> Option.bind (fun e -> e.TryGetFullName()) - // |> Option.map (fun enclosingEntityFullName -> - // Array.append (enclosingEntityFullName.Split '.') [| x.CompiledName |]) - //else None - - type FSharpAssemblySignature with - member x.TryGetEntities() = try x.Entities :> _ seq with _ -> Seq.empty - -[<AutoOpen>] -module internal Utils = - let isAttribute<'T> (attribute: FSharpAttribute) = - // CompiledName throws exception on DataContractAttribute generated by SQLProvider - match (try Some attribute.AttributeType.CompiledName with _ -> None) with - | Some name when name = typeof<'T>.Name -> true - | _ -> false - - let hasAttribute<'T> (attributes: seq<FSharpAttribute>) = - attributes |> Seq.exists isAttribute<'T> - - let tryGetAttribute<'T> (attributes: seq<FSharpAttribute>) = - attributes |> Seq.tryFind isAttribute<'T> - - let hasModuleSuffixAttribute (entity: FSharpEntity) = - entity.Attributes - |> tryGetAttribute<CompilationRepresentationAttribute> - |> Option.bind (fun a -> - try Some a.ConstructorArguments with _ -> None - |> Option.bind (fun args -> args |> Seq.tryPick (fun (_, arg) -> - let res = - match arg with - | :? int32 as arg when arg = int CompilationRepresentationFlags.ModuleSuffix -> - Some() - | :? CompilationRepresentationFlags as arg when arg = CompilationRepresentationFlags.ModuleSuffix -> - Some() - | _ -> - None - res))) - |> Option.isSome - -[<RequireQualifiedAccess>] -type internal LookupType = - | Fuzzy - | Precise - -[<NoComparison; NoEquality>] -type internal RawEntity = - { /// Full entity name as it's seen in compiled code (raw FSharpEntity.FullName, FSharpValueOrFunction.FullName). - FullName: string - /// Entity name parts with removed module suffixes (Ns.M1Module.M2Module.M3.entity -> Ns.M1.M2.M3.entity) - /// and replaced compiled names with display names (FSharpEntity.DisplayName, FSharpValueOrFucntion.DisplayName). - /// Note: *all* parts are cleaned, not the last one. - CleanedIdents: Idents - Namespace: Idents option - IsPublic: bool - TopRequireQualifiedAccessParent: Idents option - AutoOpenParent: Idents option - Kind: LookupType -> EntityKind } - override x.ToString() = sprintf "%A" x - -type AssemblyPath = string -type AssemblyContentType = Public | Full - -type internal Parent = - { Namespace: Idents option - RequiresQualifiedAccess: Idents option - AutoOpen: Idents option - WithModuleSuffix: Idents option } - static member Empty = - { Namespace = None - RequiresQualifiedAccess = None - AutoOpen = None - WithModuleSuffix = None } - static member RewriteParentIdents (parentIdents: Idents option) (idents: Idents) = - match parentIdents with - | Some p when p.Length <= idents.Length -> - for i in 0..p.Length - 1 do - idents.[i] <- p.[i] - | _ -> () - idents - member x.FixParentModuleSuffix (idents: Idents) = - Parent.RewriteParentIdents x.WithModuleSuffix idents - - member __.FormatEntityFullName (entity: FSharpEntity) = - // remove number of arguments from generic types - // e.g. System.Collections.Generic.Dictionary`2 -> System.Collections.Generic.Dictionary - // and System.Data.Listeners`1.Func -> System.Data.Listeners.Func - let removeGenericParamsCount (idents: Idents) = - idents - |> Array.map (fun ident -> - if ident.Length > 0 && Char.IsDigit ident.[ident.Length - 1] then - let lastBacktickIndex = ident.LastIndexOf '`' - if lastBacktickIndex <> -1 then - ident.Substring(0, lastBacktickIndex) - else ident - else ident) - - let removeModuleSuffix (idents: Idents) = - if entity.IsFSharpModule && idents.Length > 0 && hasModuleSuffixAttribute entity then - let lastIdent = idents.[idents.Length - 1] - if lastIdent.EndsWith "Module" then - idents |> Array.replace (idents.Length - 1) (lastIdent.Substring(0, lastIdent.Length - 6)) - else idents - else idents - - entity.TryGetFullName() - |> Option.bind (fun fullName -> - entity.TryGetFullDisplayName() - |> Option.map (fun fullDisplayName -> - fullName, - fullDisplayName.Split '.' - |> removeGenericParamsCount - |> removeModuleSuffix)) - -module internal TypedAstPatterns = - let (|TypeWithDefinition|_|) (ty: FSharpType) = - if ty.HasTypeDefinition then Some ty.TypeDefinition - else None - - let (|Attribute|_|) (entity: FSharpEntity) = - let isAttribute (entity: FSharpEntity) = - try entity.IsAttributeType with _ -> false - if isAttribute entity then Some() else None - - let (|FSharpModule|_|) (entity: FSharpEntity) = if entity.IsFSharpModule then Some() else None - -type internal AssemblyContentCacheEntry = - { FileWriteTime: DateTime - ContentType: AssemblyContentType - Entities: RawEntity list } - -[<NoComparison; NoEquality>] -type internal IAssemblyContentCache = - abstract TryGet: AssemblyPath -> AssemblyContentCacheEntry option - abstract Set: AssemblyPath -> AssemblyContentCacheEntry -> unit - -module internal AssemblyContentProvider = - open System.IO - - let private createEntity ns (parent: Parent) (entity: FSharpEntity) = - parent.FormatEntityFullName entity - |> Option.map (fun (fullName, cleanIdents) -> - { FullName = fullName - CleanedIdents = cleanIdents - Namespace = ns - IsPublic = entity.Accessibility.IsPublic - TopRequireQualifiedAccessParent = parent.RequiresQualifiedAccess |> Option.map parent.FixParentModuleSuffix - AutoOpenParent = parent.AutoOpen |> Option.map parent.FixParentModuleSuffix - Kind = fun lookupType -> - match entity, lookupType with - | TypedAstPatterns.FSharpModule, _ -> - EntityKind.Module - { IsAutoOpen = hasAttribute<AutoOpenAttribute> entity.Attributes - HasModuleSuffix = hasModuleSuffixAttribute entity } - | _, LookupType.Fuzzy -> - EntityKind.Type - | _, LookupType.Precise -> - match entity with - | TypedAstPatterns.Attribute -> EntityKind.Attribute - | _ -> EntityKind.Type - }) - - let private traverseMemberFunctionAndValues ns (parent: Parent) (membersFunctionsAndValues: seq<FSharpMemberOrFunctionOrValue>) = - membersFunctionsAndValues - |> Seq.collect (fun func -> - let processIdents fullName idents = - { FullName = fullName - CleanedIdents = parent.FixParentModuleSuffix idents - Namespace = ns - IsPublic = func.Accessibility.IsPublic - TopRequireQualifiedAccessParent = - parent.RequiresQualifiedAccess |> Option.map parent.FixParentModuleSuffix - AutoOpenParent = parent.AutoOpen |> Option.map parent.FixParentModuleSuffix - Kind = fun _ -> EntityKind.FunctionOrValue func.IsActivePattern } - - [ yield! func.TryGetFullDisplayName() - |> Option.map (fun fullDisplayName -> processIdents func.FullName (fullDisplayName.Split '.')) - |> Option.toList - (* for - [<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>] - module M = - let (++) x y = () - open M - let _ = 1 ++ 2 - we should return additional RawEntity { FullName = MModule.op_PlusPlus; CleanedIdents = [|"M"; "op_PlusPlus"|] ... } - *) - yield! func.TryGetFullCompiledOperatorNameIdents() - |> Option.map (fun fullCompiledIdents -> - processIdents (fullCompiledIdents |> String.concat ".") fullCompiledIdents) - |> Option.toList ]) - - let rec private traverseEntity contentType (parent: Parent) (entity: FSharpEntity) = - - seq { if not entity.IsProvided then - match contentType, entity.Accessibility.IsPublic with - | Full, _ | Public, true -> - let ns = entity.Namespace |> Option.map (fun x -> x.Split '.') |> Option.orElse parent.Namespace - let currentEntity = createEntity ns parent entity - - match currentEntity with - | Some x -> yield x - | None -> () - - let currentParent = - { RequiresQualifiedAccess = - parent.RequiresQualifiedAccess - |> Option.orElse ( - if entity.IsFSharp && hasAttribute<RequireQualifiedAccessAttribute> entity.Attributes then - parent.FormatEntityFullName entity |> Option.map snd - else None) - AutoOpen = - let isAutoOpen = entity.IsFSharpModule && hasAttribute<AutoOpenAttribute> entity.Attributes - match isAutoOpen, parent.AutoOpen with - // if parent is also AutoOpen, then keep the parent - | true, Some parent -> Some parent - // if parent is not AutoOpen, but current entity is, peek the latter as a new AutoOpen module - | true, None -> parent.FormatEntityFullName entity |> Option.map snd - // if current entity is not AutoOpen, we discard whatever parent was - | false, _ -> None - - WithModuleSuffix = - if entity.IsFSharpModule && hasModuleSuffixAttribute entity then - currentEntity |> Option.map (fun e -> e.CleanedIdents) - else parent.WithModuleSuffix - Namespace = ns } - - if entity.IsFSharpModule then - match entity.TryGetMembersFunctionsAndValues with - | xs when xs.Count > 0 -> - yield! traverseMemberFunctionAndValues ns currentParent xs - | _ -> () - - for e in (try entity.NestedEntities :> _ seq with _ -> Seq.empty) do - yield! traverseEntity contentType currentParent e - | _ -> () } - - let getAssemblySignatureContent contentType (signature: FSharpAssemblySignature) = - signature.TryGetEntities() - |> Seq.collect (traverseEntity contentType Parent.Empty) - |> Seq.distinctBy (fun {FullName = fullName; CleanedIdents = cleanIdents} -> (fullName, cleanIdents)) - - let private getAssemblySignaturesContent contentType (assemblies: FSharpAssembly list) = - assemblies - |> Seq.collect (fun asm -> getAssemblySignatureContent contentType asm.Contents) - |> Seq.toList - - let getAssemblyContent (withCache: (IAssemblyContentCache -> _) -> _) - contentType (fileName: string option) (assemblies: FSharpAssembly list) = - match assemblies |> List.filter (fun x -> not x.IsProviderGenerated), fileName with - | [], _ -> [] - | assemblies, Some fileName -> - let fileWriteTime = FileInfo(fileName).LastWriteTime - withCache <| fun cache -> - match contentType, cache.TryGet fileName with - | _, Some entry - | Public, Some entry when entry.FileWriteTime = fileWriteTime -> entry.Entities - | _ -> - let entities = getAssemblySignaturesContent contentType assemblies - cache.Set fileName { FileWriteTime = fileWriteTime; ContentType = contentType; Entities = entities } - entities - | assemblies, None -> - getAssemblySignaturesContent contentType assemblies - |> List.filter (fun entity -> - match contentType, entity.IsPublic with - | Full, _ | Public, true -> true - | _ -> false) - -type internal EntityCache() = - let dic = Dictionary<AssemblyPath, AssemblyContentCacheEntry>() - interface IAssemblyContentCache with - member __.TryGet assembly = - match dic.TryGetValue assembly with - | true, entry -> Some entry - | _ -> None - member __.Set assembly entry = dic.[assembly] <- entry - - member __.Clear() = dic.Clear() - member x.Locking f = lock dic <| fun _ -> f (x :> IAssemblyContentCache) - -type internal LongIdent = string - -type internal Entity = - { FullRelativeName: LongIdent - Qualifier: LongIdent - Namespace: LongIdent option - Name: LongIdent } - override x.ToString() = sprintf "%A" x - -[<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>] -module internal Entity = - let getRelativeNamespace (targetNs: Idents) (sourceNs: Idents) = - let rec loop index = - if index > targetNs.Length - 1 then sourceNs.[index..] - // target namespace is not a full parent of source namespace, keep the source ns as is - elif index > sourceNs.Length - 1 then sourceNs - elif targetNs.[index] = sourceNs.[index] then loop (index + 1) - else sourceNs.[index..] - if sourceNs.Length = 0 || targetNs.Length = 0 then sourceNs - else loop 0 - - let cutAutoOpenModules (autoOpenParent: Idents option) (candidateNs: Idents) = - let nsCount = - match autoOpenParent with - | Some parent when parent.Length > 0 -> - min (parent.Length - 1) candidateNs.Length - | _ -> candidateNs.Length - candidateNs.[0..nsCount - 1] - - let tryCreate (targetNamespace: Idents option, targetScope: Idents, partiallyQualifiedName: MaybeUnresolvedIdents, - requiresQualifiedAccessParent: Idents option, autoOpenParent: Idents option, candidateNamespace: Idents option, candidate: Idents) = - match candidate with - | [||] -> [||] - | _ -> - partiallyQualifiedName - |> Array.heads - // long ident must contain an unresolved part, otherwise we show false positive suggestions like - // "open System" for `let _ = System.DateTime.Naaaw`. Here only "Naaw" is unresolved. - |> Array.filter (fun x -> x |> Array.exists (fun x -> not x.Resolved)) - |> Array.choose (fun parts -> - let parts = parts |> Array.map (fun x -> x.Ident) - if not (candidate |> Array.endsWith parts) then None - else - let identCount = parts.Length - let fullOpenableNs, restIdents = - let openableNsCount = - match requiresQualifiedAccessParent with - | Some parent -> min parent.Length candidate.Length - | None -> candidate.Length - candidate.[0..openableNsCount - 2], candidate.[openableNsCount - 1..] +// /// Optimized arrays equality. ~100x faster than `array1 = array2` on strings. +// /// ~2x faster for floats +// /// ~0.8x slower for ints +// let inline areEqual (xs: 'T []) (ys: 'T []) = +// match xs, ys with +// | null, null -> true +// | [||], [||] -> true +// | null, _ | _, null -> false +// | _ when xs.Length <> ys.Length -> false +// | _ -> +// let mutable break' = false +// let mutable i = 0 +// let mutable result = true +// while i < xs.Length && not break' do +// if xs.[i] <> ys.[i] then +// break' <- true +// result <- false +// i <- i + 1 +// result + +// /// Returns all heads of a given array. +// /// For [|1;2;3|] it returns [|[|1; 2; 3|]; [|1; 2|]; [|1|]|] +// let heads (array: 'T []) = +// let res = Array.zeroCreate<'T[]> array.Length +// for i = array.Length - 1 downto 0 do +// res.[i] <- array.[0..i] +// res + +// /// check if subArray is found in the wholeArray starting +// /// at the provided index +// let inline isSubArray (subArray: 'T []) (wholeArray:'T []) index = +// if isNull subArray || isNull wholeArray then false +// elif subArray.Length = 0 then true +// elif subArray.Length > wholeArray.Length then false +// elif subArray.Length = wholeArray.Length then areEqual subArray wholeArray else +// let rec loop subidx idx = +// if subidx = subArray.Length then true +// elif subArray.[subidx] = wholeArray.[idx] then loop (subidx+1) (idx+1) +// else false +// loop 0 index + +// /// Returns true if one array has another as its subset from index 0. +// let startsWith (prefix: _ []) (whole: _ []) = +// isSubArray prefix whole 0 + +// /// Returns true if one array has trailing elements equal to another's. +// let endsWith (suffix: _ []) (whole: _ []) = +// isSubArray suffix whole (whole.Length-suffix.Length) + +// type FSharpEntity with +// member x.TryGetFullName() = +// try x.TryFullName +// with _ -> +// try Some(String.Join(".", x.AccessPath, x.DisplayName)) +// with _ -> None + +// member x.TryGetFullDisplayName() = +// let fullName = x.TryGetFullName() |> Option.map (fun fullName -> fullName.Split '.') +// let res = +// match fullName with +// | Some fullName -> +// match Option.attempt (fun _ -> x.DisplayName) with +// | Some shortDisplayName when not (shortDisplayName.Contains ".") -> +// Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName) +// | _ -> Some fullName +// | None -> None +// |> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName)) +// //debug "GetFullDisplayName: FullName = %A, Result = %A" fullName res +// res + +// member x.TryGetFullCompiledName() = +// let fullName = x.TryGetFullName() |> Option.map (fun fullName -> fullName.Split '.') +// let res = +// match fullName with +// | Some fullName -> +// match Option.attempt (fun _ -> x.CompiledName) with +// | Some shortCompiledName when not (shortCompiledName.Contains ".") -> +// Some (fullName |> Array.replace (fullName.Length - 1) shortCompiledName) +// | _ -> Some fullName +// | None -> None +// |> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName)) +// //debug "GetFullCompiledName: FullName = %A, Result = %A" fullName res +// res + +// member x.PublicNestedEntities = +// x.NestedEntities |> Seq.filter (fun entity -> entity.Accessibility.IsPublic) + +// member x.TryGetMembersFunctionsAndValues = +// try x.MembersFunctionsAndValues with _ -> [||] :> _ + +// let isOperator (name: string) = +// name.StartsWith "( " && name.EndsWith " )" && name.Length > 4 +// && name.Substring (2, name.Length - 4) +// |> String.forall (fun c -> c <> ' ' && not (Char.IsLetter c)) + +// type FSharpMemberOrFunctionOrValue with +// // FullType may raise exceptions (see https://github.com/fsharp/fsharp/issues/307). +// member x.FullTypeSafe = Option.attempt (fun _ -> x.FullType) + +// member x.TryGetFullDisplayName() = +// let fullName = Option.attempt (fun _ -> x.FullName.Split '.') +// match fullName with +// | Some fullName -> +// match Option.attempt (fun _ -> x.DisplayName) with +// | Some shortDisplayName when not (shortDisplayName.Contains ".") -> +// Some (fullName |> Array.replace (fullName.Length - 1) shortDisplayName) +// | _ -> Some fullName +// | None -> None +// |> Option.map (fun fullDisplayName -> String.Join (".", fullDisplayName)) + +// //member x.TryGetFullCompiledOperatorNameIdents() : Idents option = +// //// For operator ++ displayName is ( ++ ) compiledName is op_PlusPlus +// //if isOperator x.DisplayName && x.DisplayName <> x.CompiledName then +// // Option.attempt (fun _ -> x.EnclosingEntity) +// // |> Option.bind (fun e -> e.TryGetFullName()) +// // |> Option.map (fun enclosingEntityFullName -> +// // Array.append (enclosingEntityFullName.Split '.') [| x.CompiledName |]) +// //else None + +// type FSharpAssemblySignature with +// member x.TryGetEntities() = try x.Entities :> _ seq with _ -> Seq.empty + +//[<AutoOpen>] +//module internal Utils = +// let isAttribute<'T> (attribute: FSharpAttribute) = +// // CompiledName throws exception on DataContractAttribute generated by SQLProvider +// match (try Some attribute.AttributeType.CompiledName with _ -> None) with +// | Some name when name = typeof<'T>.Name -> true +// | _ -> false + +// let hasAttribute<'T> (attributes: seq<FSharpAttribute>) = +// attributes |> Seq.exists isAttribute<'T> + +// let tryGetAttribute<'T> (attributes: seq<FSharpAttribute>) = +// attributes |> Seq.tryFind isAttribute<'T> + +// let hasModuleSuffixAttribute (entity: FSharpEntity) = +// entity.Attributes +// |> tryGetAttribute<CompilationRepresentationAttribute> +// |> Option.bind (fun a -> +// try Some a.ConstructorArguments with _ -> None +// |> Option.bind (fun args -> args |> Seq.tryPick (fun (_, arg) -> +// let res = +// match arg with +// | :? int32 as arg when arg = int CompilationRepresentationFlags.ModuleSuffix -> +// Some() +// | :? CompilationRepresentationFlags as arg when arg = CompilationRepresentationFlags.ModuleSuffix -> +// Some() +// | _ -> +// None +// res))) +// |> Option.isSome + +//[<RequireQualifiedAccess>] +//type internal LookupType = +// | Fuzzy +// | Precise + +//[<NoComparison; NoEquality>] +//type internal RawEntity = +// { /// Full entity name as it's seen in compiled code (raw FSharpEntity.FullName, FSharpValueOrFunction.FullName). +// FullName: string +// /// Entity name parts with removed module suffixes (Ns.M1Module.M2Module.M3.entity -> Ns.M1.M2.M3.entity) +// /// and replaced compiled names with display names (FSharpEntity.DisplayName, FSharpValueOrFucntion.DisplayName). +// /// Note: *all* parts are cleaned, not the last one. +// CleanedIdents: Idents +// Namespace: Idents option +// IsPublic: bool +// TopRequireQualifiedAccessParent: Idents option +// AutoOpenParent: Idents option +// Kind: LookupType -> EntityKind } +// override x.ToString() = sprintf "%A" x + +//type AssemblyPath = string +//type AssemblyContentType = Public | Full + +//type internal Parent = +// { Namespace: Idents option +// RequiresQualifiedAccess: Idents option +// AutoOpen: Idents option +// WithModuleSuffix: Idents option } +// static member Empty = +// { Namespace = None +// RequiresQualifiedAccess = None +// AutoOpen = None +// WithModuleSuffix = None } +// static member RewriteParentIdents (parentIdents: Idents option) (idents: Idents) = +// match parentIdents with +// | Some p when p.Length <= idents.Length -> +// for i in 0..p.Length - 1 do +// idents.[i] <- p.[i] +// | _ -> () +// idents +// member x.FixParentModuleSuffix (idents: Idents) = +// Parent.RewriteParentIdents x.WithModuleSuffix idents + +// member __.FormatEntityFullName (entity: FSharpEntity) = +// // remove number of arguments from generic types +// // e.g. System.Collections.Generic.Dictionary`2 -> System.Collections.Generic.Dictionary +// // and System.Data.Listeners`1.Func -> System.Data.Listeners.Func +// let removeGenericParamsCount (idents: Idents) = +// idents +// |> Array.map (fun ident -> +// if ident.Length > 0 && Char.IsDigit ident.[ident.Length - 1] then +// let lastBacktickIndex = ident.LastIndexOf '`' +// if lastBacktickIndex <> -1 then +// ident.Substring(0, lastBacktickIndex) +// else ident +// else ident) + +// let removeModuleSuffix (idents: Idents) = +// if entity.IsFSharpModule && idents.Length > 0 && hasModuleSuffixAttribute entity then +// let lastIdent = idents.[idents.Length - 1] +// if lastIdent.EndsWith "Module" then +// idents |> Array.replace (idents.Length - 1) (lastIdent.Substring(0, lastIdent.Length - 6)) +// else idents +// else idents + +// entity.TryGetFullName() +// |> Option.bind (fun fullName -> +// entity.TryGetFullDisplayName() +// |> Option.map (fun fullDisplayName -> +// fullName, +// fullDisplayName.Split '.' +// |> removeGenericParamsCount +// |> removeModuleSuffix)) + +//module internal TypedAstPatterns = +// let (|TypeWithDefinition|_|) (ty: FSharpType) = +// if ty.HasTypeDefinition then Some ty.TypeDefinition +// else None + +// let (|Attribute|_|) (entity: FSharpEntity) = +// let isAttribute (entity: FSharpEntity) = +// try entity.IsAttributeType with _ -> false +// if isAttribute entity then Some() else None + +// let (|FSharpModule|_|) (entity: FSharpEntity) = if entity.IsFSharpModule then Some() else None + +//type internal AssemblyContentCacheEntry = +// { FileWriteTime: DateTime +// ContentType: AssemblyContentType +// Entities: RawEntity list } + +//[<NoComparison; NoEquality>] +//type internal IAssemblyContentCache = +// abstract TryGet: AssemblyPath -> AssemblyContentCacheEntry option +// abstract Set: AssemblyPath -> AssemblyContentCacheEntry -> unit + +//module internal AssemblyContentProvider = +// open System.IO + +// let private createEntity ns (parent: Parent) (entity: FSharpEntity) = +// parent.FormatEntityFullName entity +// |> Option.map (fun (fullName, cleanIdents) -> +// { FullName = fullName +// CleanedIdents = cleanIdents +// Namespace = ns +// IsPublic = entity.Accessibility.IsPublic +// TopRequireQualifiedAccessParent = parent.RequiresQualifiedAccess |> Option.map parent.FixParentModuleSuffix +// AutoOpenParent = parent.AutoOpen |> Option.map parent.FixParentModuleSuffix +// Kind = fun lookupType -> +// match entity, lookupType with +// | TypedAstPatterns.FSharpModule, _ -> +// EntityKind.Module +// { IsAutoOpen = hasAttribute<AutoOpenAttribute> entity.Attributes +// HasModuleSuffix = hasModuleSuffixAttribute entity } +// | _, LookupType.Fuzzy -> +// EntityKind.Type +// | _, LookupType.Precise -> +// match entity with +// | TypedAstPatterns.Attribute -> EntityKind.Attribute +// | _ -> EntityKind.Type +// }) + +// let private traverseMemberFunctionAndValues ns (parent: Parent) (membersFunctionsAndValues: seq<FSharpMemberOrFunctionOrValue>) = +// membersFunctionsAndValues +// |> Seq.collect (fun func -> +// let processIdents fullName idents = +// { FullName = fullName +// CleanedIdents = parent.FixParentModuleSuffix idents +// Namespace = ns +// IsPublic = func.Accessibility.IsPublic +// TopRequireQualifiedAccessParent = +// parent.RequiresQualifiedAccess |> Option.map parent.FixParentModuleSuffix +// AutoOpenParent = parent.AutoOpen |> Option.map parent.FixParentModuleSuffix +// Kind = fun _ -> EntityKind.FunctionOrValue func.IsActivePattern } + +// [ yield! func.TryGetFullDisplayName() +// |> Option.map (fun fullDisplayName -> processIdents func.FullName (fullDisplayName.Split '.')) +// |> Option.toList +// (* for +// [<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>] +// module M = +// let (++) x y = () +// open M +// let _ = 1 ++ 2 +// we should return additional RawEntity { FullName = MModule.op_PlusPlus; CleanedIdents = [|"M"; "op_PlusPlus"|] ... } +// *) +// yield! func.TryGetFullCompiledOperatorNameIdents() +// |> Option.map (fun fullCompiledIdents -> +// processIdents (fullCompiledIdents |> String.concat ".") fullCompiledIdents) +// |> Option.toList ]) + +// let rec private traverseEntity contentType (parent: Parent) (entity: FSharpEntity) = + +// seq { if not entity.IsProvided then +// match contentType, entity.Accessibility.IsPublic with +// | Full, _ | Public, true -> +// let ns = entity.Namespace |> Option.map (fun x -> x.Split '.') |> Option.orElse parent.Namespace +// let currentEntity = createEntity ns parent entity + +// match currentEntity with +// | Some x -> yield x +// | None -> () + +// let currentParent = +// { RequiresQualifiedAccess = +// parent.RequiresQualifiedAccess +// |> Option.orElse ( +// if entity.IsFSharp && hasAttribute<RequireQualifiedAccessAttribute> entity.Attributes then +// parent.FormatEntityFullName entity |> Option.map snd +// else None) +// AutoOpen = +// let isAutoOpen = entity.IsFSharpModule && hasAttribute<AutoOpenAttribute> entity.Attributes +// match isAutoOpen, parent.AutoOpen with +// // if parent is also AutoOpen, then keep the parent +// | true, Some parent -> Some parent +// // if parent is not AutoOpen, but current entity is, peek the latter as a new AutoOpen module +// | true, None -> parent.FormatEntityFullName entity |> Option.map snd +// // if current entity is not AutoOpen, we discard whatever parent was +// | false, _ -> None + +// WithModuleSuffix = +// if entity.IsFSharpModule && hasModuleSuffixAttribute entity then +// currentEntity |> Option.map (fun e -> e.CleanedIdents) +// else parent.WithModuleSuffix +// Namespace = ns } + +// if entity.IsFSharpModule then +// match entity.TryGetMembersFunctionsAndValues with +// | xs when xs.Count > 0 -> +// yield! traverseMemberFunctionAndValues ns currentParent xs +// | _ -> () + +// for e in (try entity.NestedEntities :> _ seq with _ -> Seq.empty) do +// yield! traverseEntity contentType currentParent e +// | _ -> () } + +// let getAssemblySignatureContent contentType (signature: FSharpAssemblySignature) = +// signature.TryGetEntities() +// |> Seq.collect (traverseEntity contentType Parent.Empty) +// |> Seq.distinctBy (fun {FullName = fullName; CleanedIdents = cleanIdents} -> (fullName, cleanIdents)) + +// let private getAssemblySignaturesContent contentType (assemblies: FSharpAssembly list) = +// assemblies +// |> Seq.collect (fun asm -> getAssemblySignatureContent contentType asm.Contents) +// |> Seq.toList + +// let getAssemblyContent (withCache: (IAssemblyContentCache -> _) -> _) +// contentType (fileName: string option) (assemblies: FSharpAssembly list) = +// match assemblies |> List.filter (fun x -> not x.IsProviderGenerated), fileName with +// | [], _ -> [] +// | assemblies, Some fileName -> +// let fileWriteTime = FileInfo(fileName).LastWriteTime +// withCache <| fun cache -> +// match contentType, cache.TryGet fileName with +// | _, Some entry +// | Public, Some entry when entry.FileWriteTime = fileWriteTime -> entry.Entities +// | _ -> +// let entities = getAssemblySignaturesContent contentType assemblies +// cache.Set fileName { FileWriteTime = fileWriteTime; ContentType = contentType; Entities = entities } +// entities +// | assemblies, None -> +// getAssemblySignaturesContent contentType assemblies +// |> List.filter (fun entity -> +// match contentType, entity.IsPublic with +// | Full, _ | Public, true -> true +// | _ -> false) + +//type internal EntityCache() = +// let dic = Dictionary<AssemblyPath, AssemblyContentCacheEntry>() +// interface IAssemblyContentCache with +// member __.TryGet assembly = +// match dic.TryGetValue assembly with +// | true, entry -> Some entry +// | _ -> None +// member __.Set assembly entry = dic.[assembly] <- entry + +// member __.Clear() = dic.Clear() +// member x.Locking f = lock dic <| fun _ -> f (x :> IAssemblyContentCache) + +//type internal LongIdent = string + +//type internal Entity = +// { FullRelativeName: LongIdent +// Qualifier: LongIdent +// Namespace: LongIdent option +// Name: LongIdent } +// override x.ToString() = sprintf "%A" x + +//[<CompilationRepresentation (CompilationRepresentationFlags.ModuleSuffix)>] +//module internal Entity = +// let getRelativeNamespace (targetNs: Idents) (sourceNs: Idents) = +// let rec loop index = +// if index > targetNs.Length - 1 then sourceNs.[index..] +// // target namespace is not a full parent of source namespace, keep the source ns as is +// elif index > sourceNs.Length - 1 then sourceNs +// elif targetNs.[index] = sourceNs.[index] then loop (index + 1) +// else sourceNs.[index..] +// if sourceNs.Length = 0 || targetNs.Length = 0 then sourceNs +// else loop 0 + +// let cutAutoOpenModules (autoOpenParent: Idents option) (candidateNs: Idents) = +// let nsCount = +// match autoOpenParent with +// | Some parent when parent.Length > 0 -> +// min (parent.Length - 1) candidateNs.Length +// | _ -> candidateNs.Length +// candidateNs.[0..nsCount - 1] + +// let tryCreate (targetNamespace: Idents option, targetScope: Idents, partiallyQualifiedName: MaybeUnresolvedIdents, +// requiresQualifiedAccessParent: Idents option, autoOpenParent: Idents option, candidateNamespace: Idents option, candidate: Idents) = +// match candidate with +// | [||] -> [||] +// | _ -> +// partiallyQualifiedName +// |> Array.heads +// // long ident must contain an unresolved part, otherwise we show false positive suggestions like +// // "open System" for `let _ = System.DateTime.Naaaw`. Here only "Naaw" is unresolved. +// |> Array.filter (fun x -> x |> Array.exists (fun x -> not x.Resolved)) +// |> Array.choose (fun parts -> +// let parts = parts |> Array.map (fun x -> x.Ident) +// if not (candidate |> Array.endsWith parts) then None +// else +// let identCount = parts.Length +// let fullOpenableNs, restIdents = +// let openableNsCount = +// match requiresQualifiedAccessParent with +// | Some parent -> min parent.Length candidate.Length +// | None -> candidate.Length +// candidate.[0..openableNsCount - 2], candidate.[openableNsCount - 1..] - let openableNs = cutAutoOpenModules autoOpenParent fullOpenableNs +// let openableNs = cutAutoOpenModules autoOpenParent fullOpenableNs - let getRelativeNs ns = - match targetNamespace, candidateNamespace with - | Some targetNs, Some candidateNs when candidateNs = targetNs -> - getRelativeNamespace targetScope ns - | None, _ -> getRelativeNamespace targetScope ns - | _ -> ns - - let relativeNs = getRelativeNs openableNs - - match relativeNs, restIdents with - | [||], [||] -> None - | [||], [|_|] -> None - | _ -> - let fullRelativeName = Array.append (getRelativeNs fullOpenableNs) restIdents - let ns = - match relativeNs with - | [||] -> None - | _ when identCount > 1 && relativeNs.Length >= identCount -> - Some (relativeNs.[0..relativeNs.Length - identCount] |> String.concat ".") - | _ -> Some (relativeNs |> String.concat ".") - let qualifier = - if fullRelativeName.Length > 1 && fullRelativeName.Length >= identCount then - fullRelativeName.[0..fullRelativeName.Length - identCount] - else fullRelativeName - Some - { FullRelativeName = String.concat "." fullRelativeName //.[0..fullRelativeName.Length - identCount - 1] - Qualifier = String.concat "." qualifier - Namespace = ns - Name = match restIdents with [|_|] -> "" | _ -> String.concat "." restIdents }) - -type internal ScopeKind = - | Namespace - | TopModule - | NestedModule - | OpenDeclaration - | HashDirective - override x.ToString() = sprintf "%A" x - -[<Measure>] type internal FCS - -type internal Point<[<Measure>]'t> = { Line : int; Column : int } - -[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] -module internal Point = - let make line column : Point<'t> = { Line = line; Column = column } - -type internal InsertContext = - { ScopeKind: ScopeKind - Pos: Point<FCS> } - -module internal ParsedInput = - open Microsoft.FSharp.Compiler - open Microsoft.FSharp.Compiler.Ast - - type private EndLine = int - - /// An recursive pattern that collect all sequential expressions to avoid StackOverflowException - let rec (|Sequentials|_|) = function - | SynExpr.Sequential(_, _, e, Sequentials es, _) -> - Some(e::es) - | SynExpr.Sequential(_, _, e1, e2, _) -> - Some [e1; e2] - | _ -> None - - let (|ConstructorPats|) = function - | SynConstructorArgs.Pats ps -> ps - | SynConstructorArgs.NamePatPairs(xs, _) -> List.map snd xs - - /// Returns all `Ident`s and `LongIdent`s found in an untyped AST. - let internal getLongIdents (input: ParsedInput option) : IDictionary<Range.pos, LongIdent> = - let identsByEndPos = Dictionary<Range.pos, LongIdent>() - - let addLongIdent (longIdent: LongIdent) = - for ident in longIdent do - identsByEndPos.[ident.idRange.End] <- longIdent - - let addLongIdentWithDots (LongIdentWithDots (longIdent, lids) as value) = - match longIdent with - | [] -> () - | [_] as idents -> identsByEndPos.[value.Range.End] <- idents - | idents -> - for dotRange in lids do - identsByEndPos.[Range.mkPos dotRange.EndLine (dotRange.EndColumn - 1)] <- idents - identsByEndPos.[value.Range.End] <- idents +// let getRelativeNs ns = +// match targetNamespace, candidateNamespace with +// | Some targetNs, Some candidateNs when candidateNs = targetNs -> +// getRelativeNamespace targetScope ns +// | None, _ -> getRelativeNamespace targetScope ns +// | _ -> ns + +// let relativeNs = getRelativeNs openableNs + +// match relativeNs, restIdents with +// | [||], [||] -> None +// | [||], [|_|] -> None +// | _ -> +// let fullRelativeName = Array.append (getRelativeNs fullOpenableNs) restIdents +// let ns = +// match relativeNs with +// | [||] -> None +// | _ when identCount > 1 && relativeNs.Length >= identCount -> +// Some (relativeNs.[0..relativeNs.Length - identCount] |> String.concat ".") +// | _ -> Some (relativeNs |> String.concat ".") +// let qualifier = +// if fullRelativeName.Length > 1 && fullRelativeName.Length >= identCount then +// fullRelativeName.[0..fullRelativeName.Length - identCount] +// else fullRelativeName +// Some +// { FullRelativeName = String.concat "." fullRelativeName //.[0..fullRelativeName.Length - identCount - 1] +// Qualifier = String.concat "." qualifier +// Namespace = ns +// Name = match restIdents with [|_|] -> "" | _ -> String.concat "." restIdents }) + +//type internal ScopeKind = +// | Namespace +// | TopModule +// | NestedModule +// | OpenDeclaration +// | HashDirective +// override x.ToString() = sprintf "%A" x + +//[<Measure>] type internal FCS + +//type internal Point<[<Measure>]'t> = { Line : int; Column : int } + +//[<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>] +//module internal Point = +// let make line column : Point<'t> = { Line = line; Column = column } + +//type internal InsertContext = +// { ScopeKind: ScopeKind +// Pos: Point<FCS> } + +//module internal ParsedInput = + //open FSharp.Compiler + //open FSharp.Compiler.Ast + + //type private EndLine = int + + ///// An recursive pattern that collect all sequential expressions to avoid StackOverflowException + //let rec (|Sequentials|_|) = function + // | SynExpr.Sequential(_, _, e, Sequentials es, _) -> + // Some(e::es) + // | SynExpr.Sequential(_, _, e1, e2, _) -> + // Some [e1; e2] + // | _ -> None + + //let (|ConstructorPats|) = function + // | SynConstructorArgs.Pats ps -> ps + // | SynConstructorArgs.NamePatPairs(xs, _) -> List.map snd xs + + ///// Returns all `Ident`s and `LongIdent`s found in an untyped AST. + //let internal getLongIdents (input: ParsedInput option) : IDictionary<Range.pos, LongIdent> = + // let identsByEndPos = Dictionary<Range.pos, LongIdent>() + + // let addLongIdent (longIdent: LongIdent) = + // for ident in longIdent do + // identsByEndPos.[ident.idRange.End] <- longIdent + + // let addLongIdentWithDots (LongIdentWithDots (longIdent, lids) as value) = + // match longIdent with + // | [] -> () + // | [_] as idents -> identsByEndPos.[value.Range.End] <- idents + // | idents -> + // for dotRange in lids do + // identsByEndPos.[Range.mkPos dotRange.EndLine (dotRange.EndColumn - 1)] <- idents + // identsByEndPos.[value.Range.End] <- idents - let addIdent (ident: Ident) = - identsByEndPos.[ident.idRange.End] <- [ident] + // let addIdent (ident: Ident) = + // identsByEndPos.[ident.idRange.End] <- [ident] - let rec walkImplFileInput (ParsedImplFileInput(_, _, _, _, _, moduleOrNamespaceList, _)) = - List.iter walkSynModuleOrNamespace moduleOrNamespaceList + // let rec walkImplFileInput (ParsedImplFileInput(_, _, _, _, _, moduleOrNamespaceList, _)) = + // List.iter walkSynModuleOrNamespace moduleOrNamespaceList - and walkSynModuleOrNamespace (SynModuleOrNamespace(_, _, _, decls, _, attrs, _, _)) = - List.iter walkAttribute attrs - List.iter walkSynModuleDecl decls + // and walkSynModuleOrNamespace (SynModuleOrNamespace(_, _, _, decls, _, attrs, _, _)) = + // List.iter walkAttribute attrs + // List.iter walkSynModuleDecl decls - and walkAttribute (attr: SynAttribute) = - addLongIdentWithDots attr.TypeName - walkExpr attr.ArgExpr + // and walkAttribute (attr: SynAttribute) = + // addLongIdentWithDots attr.TypeName + // walkExpr attr.ArgExpr - and walkTyparDecl (SynTyparDecl.TyparDecl (attrs, typar)) = - List.iter walkAttribute attrs - walkTypar typar + // and walkTyparDecl (SynTyparDecl.TyparDecl (attrs, typar)) = + // List.iter walkAttribute attrs + // walkTypar typar - and walkTypeConstraint = function - | SynTypeConstraint.WhereTyparIsValueType (t, _) - | SynTypeConstraint.WhereTyparIsReferenceType (t, _) - | SynTypeConstraint.WhereTyparIsUnmanaged (t, _) - | SynTypeConstraint.WhereTyparSupportsNull (t, _) - | SynTypeConstraint.WhereTyparIsComparable (t, _) - | SynTypeConstraint.WhereTyparIsEquatable (t, _) -> walkTypar t - | SynTypeConstraint.WhereTyparDefaultsToType (t, ty, _) - | SynTypeConstraint.WhereTyparSubtypeOfType (t, ty, _) -> walkTypar t; walkType ty - | SynTypeConstraint.WhereTyparIsEnum (t, ts, _) - | SynTypeConstraint.WhereTyparIsDelegate (t, ts, _) -> walkTypar t; List.iter walkType ts - | SynTypeConstraint.WhereTyparSupportsMember (ts, sign, _) -> List.iter walkType ts; walkMemberSig sign + // and walkTypeConstraint = function + // | SynTypeConstraint.WhereTyparIsValueType (t, _) + // | SynTypeConstraint.WhereTyparIsReferenceType (t, _) + // | SynTypeConstraint.WhereTyparIsUnmanaged (t, _) + // | SynTypeConstraint.WhereTyparSupportsNull (t, _) + // | SynTypeConstraint.WhereTyparIsComparable (t, _) + // | SynTypeConstraint.WhereTyparIsEquatable (t, _) -> walkTypar t + // | SynTypeConstraint.WhereTyparDefaultsToType (t, ty, _) + // | SynTypeConstraint.WhereTyparSubtypeOfType (t, ty, _) -> walkTypar t; walkType ty + // | SynTypeConstraint.WhereTyparIsEnum (t, ts, _) + // | SynTypeConstraint.WhereTyparIsDelegate (t, ts, _) -> walkTypar t; List.iter walkType ts + // | SynTypeConstraint.WhereTyparSupportsMember (ts, sign, _) -> List.iter walkType ts; walkMemberSig sign - and walkPat = function - | SynPat.Tuple (pats, _) - | SynPat.ArrayOrList (_, pats, _) - | SynPat.Ands (pats, _) -> List.iter walkPat pats - | SynPat.Named (pat, ident, _, _, _) -> - walkPat pat - addIdent ident - | SynPat.Typed (pat, t, _) -> - walkPat pat - walkType t - | SynPat.Attrib (pat, attrs, _) -> - walkPat pat - List.iter walkAttribute attrs - | SynPat.Or (pat1, pat2, _) -> List.iter walkPat [pat1; pat2] - | SynPat.LongIdent (ident, _, typars, ConstructorPats pats, _, _) -> - addLongIdentWithDots ident - typars - |> Option.iter (fun (SynValTyparDecls (typars, _, constraints)) -> - List.iter walkTyparDecl typars - List.iter walkTypeConstraint constraints) - List.iter walkPat pats - | SynPat.Paren (pat, _) -> walkPat pat - | SynPat.IsInst (t, _) -> walkType t - | SynPat.QuoteExpr(e, _) -> walkExpr e - | _ -> () + // and walkPat = function + // | SynPat.Tuple (_, pats, _) + // | SynPat.ArrayOrList (_, pats, _) + // | SynPat.Ands (pats, _) -> List.iter walkPat pats + // | SynPat.Named (pat, ident, _, _, _) -> + // walkPat pat + // addIdent ident + // | SynPat.Typed (pat, t, _) -> + // walkPat pat + // walkType t + // | SynPat.Attrib (pat, attrs, _) -> + // walkPat pat + // List.iter walkAttribute attrs + // | SynPat.Or (pat1, pat2, _) -> List.iter walkPat [pat1; pat2] + // | SynPat.LongIdent (ident, _, typars, ConstructorPats pats, _, _) -> + // addLongIdentWithDots ident + // typars + // |> Option.iter (fun (SynValTyparDecls (typars, _, constraints)) -> + // List.iter walkTyparDecl typars + // List.iter walkTypeConstraint constraints) + // List.iter walkPat pats + // | SynPat.Paren (pat, _) -> walkPat pat + // | SynPat.IsInst (t, _) -> walkType t + // | SynPat.QuoteExpr(e, _) -> walkExpr e + // | _ -> () - and walkTypar (Typar (_, _, _)) = () + // and walkTypar (Typar (_, _, _)) = () - and walkBinding (SynBinding.Binding (_, _, _, _, attrs, _, _, pat, returnInfo, e, _, _)) = - List.iter walkAttribute attrs - walkPat pat - walkExpr e - returnInfo |> Option.iter (fun (SynBindingReturnInfo (t, _, _)) -> walkType t) + // and walkBinding (SynBinding.Binding (_, _, _, _, attrs, _, _, pat, returnInfo, e, _, _)) = + // List.iter walkAttribute attrs + // walkPat pat + // walkExpr e + // returnInfo |> Option.iter (fun (SynBindingReturnInfo (t, _, _)) -> walkType t) - and walkInterfaceImpl (InterfaceImpl(_, bindings, _)) = List.iter walkBinding bindings + // and walkInterfaceImpl (InterfaceImpl(_, bindings, _)) = List.iter walkBinding bindings - and walkIndexerArg = function - | SynIndexerArg.One e -> walkExpr e - | SynIndexerArg.Two (e1, e2) -> List.iter walkExpr [e1; e2] + // and walkIndexerArg = function + // | SynIndexerArg.One e -> walkExpr e + // | SynIndexerArg.Two (e1, e2) -> List.iter walkExpr [e1; e2] - and walkType = function - | SynType.Array (_, t, _) - | SynType.HashConstraint (t, _) - | SynType.MeasurePower (t, _, _) -> walkType t - | SynType.Fun (t1, t2, _) - | SynType.MeasureDivide (t1, t2, _) -> walkType t1; walkType t2 - | SynType.LongIdent ident -> addLongIdentWithDots ident - | SynType.App (ty, _, types, _, _, _, _) -> walkType ty; List.iter walkType types - | SynType.LongIdentApp (_, _, _, types, _, _, _) -> List.iter walkType types - | SynType.Tuple (ts, _) -> ts |> List.iter (fun (_, t) -> walkType t) - | SynType.WithGlobalConstraints (t, typeConstraints, _) -> - walkType t; List.iter walkTypeConstraint typeConstraints - | _ -> () + // and walkType = function + // | SynType.Array (_, t, _) + // | SynType.HashConstraint (t, _) + // | SynType.MeasurePower (t, _, _) -> walkType t + // | SynType.Fun (t1, t2, _) + // | SynType.MeasureDivide (t1, t2, _) -> walkType t1; walkType t2 + // | SynType.LongIdent ident -> addLongIdentWithDots ident + // | SynType.App (ty, _, types, _, _, _, _) -> walkType ty; List.iter walkType types + // | SynType.LongIdentApp (_, _, _, types, _, _, _) -> List.iter walkType types + // | SynType.Tuple (_, ts, _) -> ts |> List.iter (fun (_, t) -> walkType t) + // | SynType.WithGlobalConstraints (t, typeConstraints, _) -> + // walkType t; List.iter walkTypeConstraint typeConstraints + // | _ -> () - and walkClause (Clause (pat, e1, e2, _, _)) = - walkPat pat - walkExpr e2 - e1 |> Option.iter walkExpr + // and walkClause (Clause (pat, e1, e2, _, _)) = + // walkPat pat + // walkExpr e2 + // e1 |> Option.iter walkExpr - and walkSimplePats = function - | SynSimplePats.SimplePats (pats, _) -> List.iter walkSimplePat pats - | SynSimplePats.Typed (pats, ty, _) -> - walkSimplePats pats - walkType ty + // and walkSimplePats = function + // | SynSimplePats.SimplePats (pats, _) -> List.iter walkSimplePat pats + // | SynSimplePats.Typed (pats, ty, _) -> + // walkSimplePats pats + // walkType ty - and walkExpr = function - | SynExpr.Paren (e, _, _, _) - | SynExpr.Quote (_, _, e, _, _) - | SynExpr.Typed (e, _, _) - | SynExpr.InferredUpcast (e, _) - | SynExpr.InferredDowncast (e, _) - | SynExpr.AddressOf (_, e, _, _) - | SynExpr.DoBang (e, _) - | SynExpr.YieldOrReturn (_, e, _) - | SynExpr.ArrayOrListOfSeqExpr (_, e, _) - | SynExpr.CompExpr (_, _, e, _) - | SynExpr.Do (e, _) - | SynExpr.Assert (e, _) - | SynExpr.Lazy (e, _) - | SynExpr.YieldOrReturnFrom (_, e, _) -> walkExpr e - | SynExpr.Lambda (_, _, pats, e, _) -> - walkSimplePats pats - walkExpr e - | SynExpr.New (_, t, e, _) - | SynExpr.TypeTest (e, t, _) - | SynExpr.Upcast (e, t, _) - | SynExpr.Downcast (e, t, _) -> walkExpr e; walkType t - | SynExpr.Tuple (es, _, _) - | Sequentials es - | SynExpr.ArrayOrList (_, es, _) -> List.iter walkExpr es - | SynExpr.App (_, _, e1, e2, _) - | SynExpr.TryFinally (e1, e2, _, _, _) - | SynExpr.While (_, e1, e2, _) -> List.iter walkExpr [e1; e2] - | SynExpr.Record (_, _, fields, _) -> - fields |> List.iter (fun ((ident, _), e, _) -> - addLongIdentWithDots ident - e |> Option.iter walkExpr) - | SynExpr.Ident ident -> addIdent ident - | SynExpr.ObjExpr(ty, argOpt, bindings, ifaces, _, _) -> - argOpt |> Option.iter (fun (e, ident) -> - walkExpr e - ident |> Option.iter addIdent) - walkType ty - List.iter walkBinding bindings - List.iter walkInterfaceImpl ifaces - | SynExpr.LongIdent (_, ident, _, _) -> addLongIdentWithDots ident - | SynExpr.For (_, ident, e1, _, e2, e3, _) -> - addIdent ident - List.iter walkExpr [e1; e2; e3] - | SynExpr.ForEach (_, _, _, pat, e1, e2, _) -> - walkPat pat - List.iter walkExpr [e1; e2] - | SynExpr.MatchLambda (_, _, synMatchClauseList, _, _) -> - List.iter walkClause synMatchClauseList - | SynExpr.Match (_, e, synMatchClauseList, _, _) -> - walkExpr e - List.iter walkClause synMatchClauseList - | SynExpr.TypeApp (e, _, tys, _, _, _, _) -> - List.iter walkType tys; walkExpr e - | SynExpr.LetOrUse (_, _, bindings, e, _) -> - List.iter walkBinding bindings; walkExpr e - | SynExpr.TryWith (e, _, clauses, _, _, _, _) -> - List.iter walkClause clauses; walkExpr e - | SynExpr.IfThenElse (e1, e2, e3, _, _, _, _) -> - List.iter walkExpr [e1; e2] - e3 |> Option.iter walkExpr - | SynExpr.LongIdentSet (ident, e, _) - | SynExpr.DotGet (e, _, ident, _) -> - addLongIdentWithDots ident - walkExpr e - | SynExpr.DotSet (e1, idents, e2, _) -> - walkExpr e1 - addLongIdentWithDots idents - walkExpr e2 - | SynExpr.DotIndexedGet (e, args, _, _) -> - walkExpr e - List.iter walkIndexerArg args - | SynExpr.DotIndexedSet (e1, args, e2, _, _, _) -> - walkExpr e1 - List.iter walkIndexerArg args - walkExpr e2 - | SynExpr.NamedIndexedPropertySet (ident, e1, e2, _) -> - addLongIdentWithDots ident - List.iter walkExpr [e1; e2] - | SynExpr.DotNamedIndexedPropertySet (e1, ident, e2, e3, _) -> - addLongIdentWithDots ident - List.iter walkExpr [e1; e2; e3] - | SynExpr.JoinIn (e1, _, e2, _) -> List.iter walkExpr [e1; e2] - | SynExpr.LetOrUseBang (_, _, _, pat, e1, e2, _) -> - walkPat pat - List.iter walkExpr [e1; e2] - | SynExpr.TraitCall (ts, sign, e, _) -> - List.iter walkTypar ts - walkMemberSig sign - walkExpr e - | SynExpr.Const (SynConst.Measure(_, m), _) -> walkMeasure m - | _ -> () + // and walkExpr = function + // | SynExpr.Paren (e, _, _, _) + // | SynExpr.Quote (_, _, e, _, _) + // | SynExpr.Typed (e, _, _) + // | SynExpr.InferredUpcast (e, _) + // | SynExpr.InferredDowncast (e, _) + // | SynExpr.AddressOf (_, e, _, _) + // | SynExpr.DoBang (e, _) + // | SynExpr.YieldOrReturn (_, e, _) + // | SynExpr.ArrayOrListOfSeqExpr (_, e, _) + // | SynExpr.CompExpr (_, _, e, _) + // | SynExpr.Do (e, _) + // | SynExpr.Assert (e, _) + // | SynExpr.Lazy (e, _) + // | SynExpr.YieldOrReturnFrom (_, e, _) -> walkExpr e + // | SynExpr.Lambda (_, _, pats, e, _) -> + // walkSimplePats pats + // walkExpr e + // | SynExpr.New (_, t, e, _) + // | SynExpr.TypeTest (e, t, _) + // | SynExpr.Upcast (e, t, _) + // | SynExpr.Downcast (e, t, _) -> walkExpr e; walkType t + // | SynExpr.Tuple (_, es, _, _) + // | Sequentials es + // | SynExpr.ArrayOrList (_, es, _) -> List.iter walkExpr es + // | SynExpr.App (_, _, e1, e2, _) + // | SynExpr.TryFinally (e1, e2, _, _, _) + // | SynExpr.While (_, e1, e2, _) -> List.iter walkExpr [e1; e2] + // | SynExpr.Record (_, _, fields, _) -> + // fields |> List.iter (fun ((ident, _), e, _) -> + // addLongIdentWithDots ident + // e |> Option.iter walkExpr) + // | SynExpr.Ident ident -> addIdent ident + // | SynExpr.ObjExpr(ty, argOpt, bindings, ifaces, _, _) -> + // argOpt |> Option.iter (fun (e, ident) -> + // walkExpr e + // ident |> Option.iter addIdent) + // walkType ty + // List.iter walkBinding bindings + // List.iter walkInterfaceImpl ifaces + // | SynExpr.LongIdent (_, ident, _, _) -> addLongIdentWithDots ident + // | SynExpr.For (_, ident, e1, _, e2, e3, _) -> + // addIdent ident + // List.iter walkExpr [e1; e2; e3] + // | SynExpr.ForEach (_, _, _, pat, e1, e2, _) -> + // walkPat pat + // List.iter walkExpr [e1; e2] + // | SynExpr.MatchLambda (_, _, synMatchClauseList, _, _) -> + // List.iter walkClause synMatchClauseList + // | SynExpr.Match (_, e, synMatchClauseList, _) -> + // walkExpr e + // List.iter walkClause synMatchClauseList + // | SynExpr.TypeApp (e, _, tys, _, _, _, _) -> + // List.iter walkType tys; walkExpr e + // | SynExpr.LetOrUse (_, _, bindings, e, _) -> + // List.iter walkBinding bindings; walkExpr e + // | SynExpr.TryWith (e, _, clauses, _, _, _, _) -> + // List.iter walkClause clauses; walkExpr e + // | SynExpr.IfThenElse (e1, e2, e3, _, _, _, _) -> + // List.iter walkExpr [e1; e2] + // e3 |> Option.iter walkExpr + // | SynExpr.LongIdentSet (ident, e, _) + // | SynExpr.DotGet (e, _, ident, _) -> + // addLongIdentWithDots ident + // walkExpr e + // | SynExpr.DotSet (e1, idents, e2, _) -> + // walkExpr e1 + // addLongIdentWithDots idents + // walkExpr e2 + // | SynExpr.DotIndexedGet (e, args, _, _) -> + // walkExpr e + // List.iter walkIndexerArg args + // | SynExpr.DotIndexedSet (e1, args, e2, _, _, _) -> + // walkExpr e1 + // List.iter walkIndexerArg args + // walkExpr e2 + // | SynExpr.NamedIndexedPropertySet (ident, e1, e2, _) -> + // addLongIdentWithDots ident + // List.iter walkExpr [e1; e2] + // | SynExpr.DotNamedIndexedPropertySet (e1, ident, e2, e3, _) -> + // addLongIdentWithDots ident + // List.iter walkExpr [e1; e2; e3] + // | SynExpr.JoinIn (e1, _, e2, _) -> List.iter walkExpr [e1; e2] + // | SynExpr.LetOrUseBang (_, _, _, pat, e1, e2, _) -> + // walkPat pat + // List.iter walkExpr [e1; e2] + // | SynExpr.TraitCall (ts, sign, e, _) -> + // List.iter walkTypar ts + // walkMemberSig sign + // walkExpr e + // | SynExpr.Const (SynConst.Measure(_, m), _) -> walkMeasure m + // | _ -> () - and walkMeasure = function - | SynMeasure.Product (m1, m2, _) - | SynMeasure.Divide (m1, m2, _) -> walkMeasure m1; walkMeasure m2 - | SynMeasure.Named (longIdent, _) -> addLongIdent longIdent - | SynMeasure.Seq (ms, _) -> List.iter walkMeasure ms - | SynMeasure.Power (m, _, _) -> walkMeasure m - | SynMeasure.Var (ty, _) -> walkTypar ty - | SynMeasure.One - | SynMeasure.Anon _ -> () + // and walkMeasure = function + // | SynMeasure.Product (m1, m2, _) + // | SynMeasure.Divide (m1, m2, _) -> walkMeasure m1; walkMeasure m2 + // | SynMeasure.Named (longIdent, _) -> addLongIdent longIdent + // | SynMeasure.Seq (ms, _) -> List.iter walkMeasure ms + // | SynMeasure.Power (m, _, _) -> walkMeasure m + // | SynMeasure.Var (ty, _) -> walkTypar ty + // | SynMeasure.One + // | SynMeasure.Anon _ -> () - and walkSimplePat = function - | SynSimplePat.Attrib (pat, attrs, _) -> - walkSimplePat pat - List.iter walkAttribute attrs - | SynSimplePat.Typed(pat, t, _) -> - walkSimplePat pat - walkType t - | _ -> () + // and walkSimplePat = function + // | SynSimplePat.Attrib (pat, attrs, _) -> + // walkSimplePat pat + // List.iter walkAttribute attrs + // | SynSimplePat.Typed(pat, t, _) -> + // walkSimplePat pat + // walkType t + // | _ -> () - and walkField (SynField.Field(attrs, _, _, t, _, _, _, _)) = - List.iter walkAttribute attrs - walkType t + // and walkField (SynField.Field(attrs, _, _, t, _, _, _, _)) = + // List.iter walkAttribute attrs + // walkType t - and walkValSig (SynValSig.ValSpfn(attrs, _, _, t, SynValInfo(argInfos, argInfo), _, _, _, _, _, _)) = - List.iter walkAttribute attrs - walkType t - argInfo :: (argInfos |> List.concat) - |> List.map (fun (SynArgInfo(attrs, _, _)) -> attrs) - |> List.concat - |> List.iter walkAttribute + // and walkValSig (SynValSig.ValSpfn(attrs, _, _, t, SynValInfo(argInfos, argInfo), _, _, _, _, _, _)) = + // List.iter walkAttribute attrs + // walkType t + // argInfo :: (argInfos |> List.concat) + // |> List.map (fun (SynArgInfo(attrs, _, _)) -> attrs) + // |> List.concat + // |> List.iter walkAttribute - and walkMemberSig = function - | SynMemberSig.Inherit (t, _) - | SynMemberSig.Interface(t, _) -> walkType t - | SynMemberSig.Member(vs, _, _) -> walkValSig vs - | SynMemberSig.ValField(f, _) -> walkField f - | SynMemberSig.NestedType(SynTypeDefnSig.TypeDefnSig (info, repr, memberSigs, _), _) -> - let isTypeExtensionOrAlias = - match repr with - | SynTypeDefnSigRepr.Simple(SynTypeDefnSimpleRepr.TypeAbbrev _, _) - | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.TyconAbbrev, _, _) - | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.TyconAugmentation, _, _) -> true - | _ -> false - walkComponentInfo isTypeExtensionOrAlias info - walkTypeDefnSigRepr repr - List.iter walkMemberSig memberSigs - - and walkMember = function - | SynMemberDefn.AbstractSlot (valSig, _, _) -> walkValSig valSig - | SynMemberDefn.Member (binding, _) -> walkBinding binding - | SynMemberDefn.ImplicitCtor (_, attrs, pats, _, _) -> - List.iter walkAttribute attrs - List.iter walkSimplePat pats - | SynMemberDefn.ImplicitInherit (t, e, _, _) -> walkType t; walkExpr e - | SynMemberDefn.LetBindings (bindings, _, _, _) -> List.iter walkBinding bindings - | SynMemberDefn.Interface (t, members, _) -> - walkType t - members |> Option.iter (List.iter walkMember) - | SynMemberDefn.Inherit (t, _, _) -> walkType t - | SynMemberDefn.ValField (field, _) -> walkField field - | SynMemberDefn.NestedType (tdef, _, _) -> walkTypeDefn tdef - | SynMemberDefn.AutoProperty (attrs, _, _, t, _, _, _, _, e, _, _) -> - List.iter walkAttribute attrs - Option.iter walkType t - walkExpr e - | _ -> () + // and walkMemberSig = function + // | SynMemberSig.Inherit (t, _) + // | SynMemberSig.Interface(t, _) -> walkType t + // | SynMemberSig.Member(vs, _, _) -> walkValSig vs + // | SynMemberSig.ValField(f, _) -> walkField f + // | SynMemberSig.NestedType(SynTypeDefnSig.TypeDefnSig (info, repr, memberSigs, _), _) -> + // let isTypeExtensionOrAlias = + // match repr with + // | SynTypeDefnSigRepr.Simple(SynTypeDefnSimpleRepr.TypeAbbrev _, _) + // | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.TyconAbbrev, _, _) + // | SynTypeDefnSigRepr.ObjectModel(SynTypeDefnKind.TyconAugmentation, _, _) -> true + // | _ -> false + // walkComponentInfo isTypeExtensionOrAlias info + // walkTypeDefnSigRepr repr + // List.iter walkMemberSig memberSigs + + // and walkMember = function + // | SynMemberDefn.AbstractSlot (valSig, _, _) -> walkValSig valSig + // | SynMemberDefn.Member (binding, _) -> walkBinding binding + // | SynMemberDefn.ImplicitCtor (_, attrs, pats, _, _) -> + // List.iter walkAttribute attrs + // List.iter walkSimplePat pats + // | SynMemberDefn.ImplicitInherit (t, e, _, _) -> walkType t; walkExpr e + // | SynMemberDefn.LetBindings (bindings, _, _, _) -> List.iter walkBinding bindings + // | SynMemberDefn.Interface (t, members, _) -> + // walkType t + // members |> Option.iter (List.iter walkMember) + // | SynMemberDefn.Inherit (t, _, _) -> walkType t + // | SynMemberDefn.ValField (field, _) -> walkField field + // | SynMemberDefn.NestedType (tdef, _, _) -> walkTypeDefn tdef + // | SynMemberDefn.AutoProperty (attrs, _, _, t, _, _, _, _, e, _, _) -> + // List.iter walkAttribute attrs + // Option.iter walkType t + // walkExpr e + // | _ -> () - and walkEnumCase (EnumCase(attrs, _, _, _, _)) = List.iter walkAttribute attrs + // and walkEnumCase (EnumCase(attrs, _, _, _, _)) = List.iter walkAttribute attrs - and walkUnionCaseType = function - | SynUnionCaseType.UnionCaseFields fields -> List.iter walkField fields - | SynUnionCaseType.UnionCaseFullType (t, _) -> walkType t - - and walkUnionCase (SynUnionCase.UnionCase (attrs, _, t, _, _, _)) = - List.iter walkAttribute attrs - walkUnionCaseType t - - and walkTypeDefnSimple = function - | SynTypeDefnSimpleRepr.Enum (cases, _) -> List.iter walkEnumCase cases - | SynTypeDefnSimpleRepr.Union (_, cases, _) -> List.iter walkUnionCase cases - | SynTypeDefnSimpleRepr.Record (_, fields, _) -> List.iter walkField fields - | SynTypeDefnSimpleRepr.TypeAbbrev (_, t, _) -> walkType t - | _ -> () - - and walkComponentInfo isTypeExtensionOrAlias (ComponentInfo(attrs, typars, constraints, longIdent, _, _, _, _)) = - List.iter walkAttribute attrs - List.iter walkTyparDecl typars - List.iter walkTypeConstraint constraints - if isTypeExtensionOrAlias then - addLongIdent longIdent - - and walkTypeDefnRepr = function - | SynTypeDefnRepr.ObjectModel (_, defns, _) -> List.iter walkMember defns - | SynTypeDefnRepr.Simple(defn, _) -> walkTypeDefnSimple defn - | SynTypeDefnRepr.Exception _ -> () - - and walkTypeDefnSigRepr = function - | SynTypeDefnSigRepr.ObjectModel (_, defns, _) -> List.iter walkMemberSig defns - | SynTypeDefnSigRepr.Simple(defn, _) -> walkTypeDefnSimple defn - | SynTypeDefnSigRepr.Exception _ -> () - - and walkTypeDefn (TypeDefn (info, repr, members, _)) = - let isTypeExtensionOrAlias = - match repr with - | SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.TyconAugmentation, _, _) - | SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.TyconAbbrev, _, _) - | SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.TypeAbbrev _, _) -> true - | _ -> false - walkComponentInfo isTypeExtensionOrAlias info - walkTypeDefnRepr repr - List.iter walkMember members + // and walkUnionCaseType = function + // | SynUnionCaseType.UnionCaseFields fields -> List.iter walkField fields + // | SynUnionCaseType.UnionCaseFullType (t, _) -> walkType t + + // and walkUnionCase (SynUnionCase.UnionCase (attrs, _, t, _, _, _)) = + // List.iter walkAttribute attrs + // walkUnionCaseType t + + // and walkTypeDefnSimple = function + // | SynTypeDefnSimpleRepr.Enum (cases, _) -> List.iter walkEnumCase cases + // | SynTypeDefnSimpleRepr.Union (_, cases, _) -> List.iter walkUnionCase cases + // | SynTypeDefnSimpleRepr.Record (_, fields, _) -> List.iter walkField fields + // | SynTypeDefnSimpleRepr.TypeAbbrev (_, t, _) -> walkType t + // | _ -> () + + // and walkComponentInfo isTypeExtensionOrAlias (ComponentInfo(attrs, typars, constraints, longIdent, _, _, _, _)) = + // List.iter walkAttribute attrs + // List.iter walkTyparDecl typars + // List.iter walkTypeConstraint constraints + // if isTypeExtensionOrAlias then + // addLongIdent longIdent + + // and walkTypeDefnRepr = function + // | SynTypeDefnRepr.ObjectModel (_, defns, _) -> List.iter walkMember defns + // | SynTypeDefnRepr.Simple(defn, _) -> walkTypeDefnSimple defn + // | SynTypeDefnRepr.Exception _ -> () + + // and walkTypeDefnSigRepr = function + // | SynTypeDefnSigRepr.ObjectModel (_, defns, _) -> List.iter walkMemberSig defns + // | SynTypeDefnSigRepr.Simple(defn, _) -> walkTypeDefnSimple defn + // | SynTypeDefnSigRepr.Exception _ -> () + + // and walkTypeDefn (TypeDefn (info, repr, members, _)) = + // let isTypeExtensionOrAlias = + // match repr with + // | SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.TyconAugmentation, _, _) + // | SynTypeDefnRepr.ObjectModel (SynTypeDefnKind.TyconAbbrev, _, _) + // | SynTypeDefnRepr.Simple (SynTypeDefnSimpleRepr.TypeAbbrev _, _) -> true + // | _ -> false + // walkComponentInfo isTypeExtensionOrAlias info + // walkTypeDefnRepr repr + // List.iter walkMember members - and walkSynModuleDecl (decl: SynModuleDecl) = - match decl with - | SynModuleDecl.NamespaceFragment fragment -> walkSynModuleOrNamespace fragment - | SynModuleDecl.NestedModule (info, _, modules, _, _) -> - walkComponentInfo false info - List.iter walkSynModuleDecl modules - | SynModuleDecl.Let (_, bindings, _) -> List.iter walkBinding bindings - | SynModuleDecl.DoExpr (_, expr, _) -> walkExpr expr - | SynModuleDecl.Types (types, _) -> List.iter walkTypeDefn types - | SynModuleDecl.Attributes (attrs, _) -> List.iter walkAttribute attrs - | _ -> () + // and walkSynModuleDecl (decl: SynModuleDecl) = + // match decl with + // | SynModuleDecl.NamespaceFragment fragment -> walkSynModuleOrNamespace fragment + // | SynModuleDecl.NestedModule (info, _, modules, _, _) -> + // walkComponentInfo false info + // List.iter walkSynModuleDecl modules + // | SynModuleDecl.Let (_, bindings, _) -> List.iter walkBinding bindings + // | SynModuleDecl.DoExpr (_, expr, _) -> walkExpr expr + // | SynModuleDecl.Types (types, _) -> List.iter walkTypeDefn types + // | SynModuleDecl.Attributes (attrs, _) -> List.iter walkAttribute attrs + // | _ -> () - match input with - | Some (ParsedInput.ImplFile input) -> - walkImplFileInput input - | _ -> () - //debug "%A" idents - upcast identsByEndPos + // match input with + // | Some (ParsedInput.ImplFile input) -> + // walkImplFileInput input + // | _ -> () + // //debug "%A" idents + // upcast identsByEndPos - let getLongIdentAt ast pos = - let idents = getLongIdents (Some ast) - - match idents.TryGetValue pos with - | true, idents -> Some idents - | _ -> None - - type Col = int - - type Scope = - { Idents: Idents - Kind: ScopeKind } - - let tryFindInsertionContext (currentLine: int) (ast: ParsedInput) = - let result: (Scope * Point<FCS>) option ref = ref None - let ns: string[] option ref = ref None - let modules = ResizeArray<Idents * EndLine * Col>() - - let inline longIdentToIdents ident = ident |> Seq.map (fun x -> string x) |> Seq.toArray - - let addModule (longIdent: LongIdent) endLine col = - modules.Add(longIdent |> List.map string |> List.toArray, endLine, col) - - let doRange kind (scope: LongIdent) line col = - if line <= currentLine then - match !result with - | None -> - result := Some ({ Idents = longIdentToIdents scope; Kind = kind }, Point.make line col) - | Some (oldScope, oldPos) -> - match kind, oldScope.Kind with - | (Namespace | NestedModule | TopModule), OpenDeclaration - | _ when oldPos.Line <= line -> - result := - Some ({ Idents = - match scope with - | [] -> oldScope.Idents - | _ -> longIdentToIdents scope - Kind = kind }, - Point.make line col) - | _ -> () - - let getMinColumn (decls: SynModuleDecls) = - match decls with - | [] -> None - | firstDecl :: _ -> - match firstDecl with - | SynModuleDecl.NestedModule (_, _, _, _, r) - | SynModuleDecl.Let (_, _, r) - | SynModuleDecl.DoExpr (_, _, r) - | SynModuleDecl.Types (_, r) - | SynModuleDecl.Exception (_, r) - | SynModuleDecl.Open (_, r) - | SynModuleDecl.HashDirective (_, r) -> Some r - | _ -> None - |> Option.map (fun r -> r.StartColumn) - - - let rec walkImplFileInput (ParsedImplFileInput(_, _, _, _, _, moduleOrNamespaceList, _)) = - List.iter (walkSynModuleOrNamespace []) moduleOrNamespaceList - - and walkSynModuleOrNamespace (parent: LongIdent) (SynModuleOrNamespace(ident, _, isModule, decls, _, _, _, range)) = - if range.EndLine >= currentLine then - match isModule, parent, ident with - | false, _, _ -> ns := Some (longIdentToIdents ident) - // top level module with "inlined" namespace like Ns1.Ns2.TopModule - | true, [], _f :: _s :: _ -> - let ident = longIdentToIdents ident - ns := Some (ident.[0..ident.Length - 2]) - | _ -> () + //let getLongIdentAt ast pos = + // let idents = getLongIdents (Some ast) + + // match idents.TryGetValue pos with + // | true, idents -> Some idents + // | _ -> None + + //type Col = int + + //type Scope = + // { Idents: Idents + // Kind: ScopeKind } + + //let tryFindInsertionContext (currentLine: int) (ast: ParsedInput) = + //let result: (Scope * Point<FCS>) option ref = ref None + //let ns: string[] option ref = ref None + //let modules = ResizeArray<Module> + + //let inline longIdentToIdents ident = ident |> Seq.map (fun x -> string x) |> Seq.toArray + + //let addModule (longIdent: LongIdent, range: range) = + // modules.Add + // { Idents = longIdent |> List.map string |> List.toArray + // Range = range } + + //let doRange kind (scope: LongIdent) line col = + // if line <= currentLine then + // match !result with + // | None -> + // result := Some ({ Idents = longIdentToIdents scope; Kind = kind }, Point.make line col) + // | Some (oldScope, oldPos) -> + // match kind, oldScope.Kind with + // | (Namespace | NestedModule | TopModule), OpenDeclaration + // | _ when oldPos.Line <= line -> + // result := + // Some ({ Idents = + // match scope with + // | [] -> oldScope.Idents + // | _ -> longIdentToIdents scope + // Kind = kind }, + // Point.make line col) + // | _ -> () + + //let getMinColumn (decls: SynModuleDecls) = + // match decls with + // | [] -> None + // | firstDecl :: _ -> + // match firstDecl with + // | SynModuleDecl.NestedModule (_, _, _, _, r) + // | SynModuleDecl.Let (_, _, r) + // | SynModuleDecl.DoExpr (_, _, r) + // | SynModuleDecl.Types (_, r) + // | SynModuleDecl.Exception (_, r) + // | SynModuleDecl.Open (_, r) + // | SynModuleDecl.HashDirective (_, r) -> Some r + // | _ -> None + // |> Option.map (fun r -> r.StartColumn) + + + //let rec walkImplFileInput (ParsedImplFileInput(_, _, _, _, _, moduleOrNamespaceList, _)) = + // List.iter (walkSynModuleOrNamespace []) moduleOrNamespaceList + + //and walkSynModuleOrNamespace (parent: LongIdent) (SynModuleOrNamespace(ident, _, kind, decls, _, _, _, range)) = + // if range.EndLine >= currentLine then + // let isModule = kind.IsModule + // match isModule, parent, ident with + // | false, _, _ -> ns := Some (longIdentToIdents ident) + // // top level module with "inlined" namespace like Ns1.Ns2.TopModule + // | true, [], _f :: _s :: _ -> + // let ident = longIdentToIdents ident + // ns := Some (ident.[0..ident.Length - 2]) + // | _ -> () - let fullIdent = parent @ ident - - let startLine = - if isModule then range.StartLine - else range.StartLine - 1 - - let scopeKind = - match isModule, parent with - | true, [] -> TopModule - | true, _ -> NestedModule - | _ -> Namespace - - doRange scopeKind fullIdent startLine range.StartColumn - addModule fullIdent range.EndLine range.StartColumn - List.iter (walkSynModuleDecl fullIdent) decls - - and walkSynModuleDecl (parent: LongIdent) (decl: SynModuleDecl) = - match decl with - | SynModuleDecl.NamespaceFragment fragment -> walkSynModuleOrNamespace parent fragment - | SynModuleDecl.NestedModule(ComponentInfo(_, _, _, ident, _, _, _, _), _, decls, _, range) -> - let fullIdent = parent @ ident - addModule fullIdent range.EndLine range.StartColumn - if range.EndLine >= currentLine then - let moduleBodyIdentation = getMinColumn decls |> Option.defaultValue (range.StartColumn + 4) - doRange NestedModule fullIdent range.StartLine moduleBodyIdentation - List.iter (walkSynModuleDecl fullIdent) decls - | SynModuleDecl.Open (_, range) -> doRange OpenDeclaration [] range.EndLine (range.StartColumn - 5) - | SynModuleDecl.HashDirective (_, range) -> doRange HashDirective [] range.EndLine range.StartColumn - | _ -> () - - match ast with - | ParsedInput.SigFile _ -> () - | ParsedInput.ImplFile input -> walkImplFileInput input - - let res = - !result - |> Option.map (fun (scope, pos) -> - let ns = !ns |> Option.map longIdentToIdents - scope, ns, { pos with Line = pos.Line + 1 }) + // let fullIdent = parent @ ident + + // let startLine = + // if isModule then range.StartLine + // else range.StartLine - 1 + + // let scopeKind = + // match isModule, parent with + // | true, [] -> TopModule + // | true, _ -> NestedModule + // | _ -> Namespace + + // doRange scopeKind fullIdent startLine range.StartColumn + // addModule (fullIdent, range) + // List.iter (walkSynModuleDecl fullIdent) decls + + //and walkSynModuleDecl (parent: LongIdent) (decl: SynModuleDecl) = + // match decl with + // | SynModuleDecl.NamespaceFragment fragment -> walkSynModuleOrNamespace parent fragment + // | SynModuleDecl.NestedModule(ComponentInfo(_, _, _, ident, _, _, _, _), _, decls, _, range) -> + // let fullIdent = parent @ ident + // addModule fullIdent range.EndLine range.StartColumn + // if range.EndLine >= currentLine then + // let moduleBodyIdentation = getMinColumn decls |> Option.defaultValue (range.StartColumn + 4) + // doRange NestedModule fullIdent range.StartLine moduleBodyIdentation + // List.iter (walkSynModuleDecl fullIdent) decls + // | SynModuleDecl.Open (_, range) -> doRange OpenDeclaration [] range.EndLine (range.StartColumn - 5) + // | SynModuleDecl.HashDirective (_, range) -> doRange HashDirective [] range.EndLine range.StartColumn + // | _ -> () + + //match ast with + //| ParsedInput.SigFile _ -> () + //| ParsedInput.ImplFile input -> walkImplFileInput input + + //let res = + // !result + // |> Option.map (fun (scope, pos) -> + // let ns = !ns |> Option.map longIdentToIdents + // scope, ns, { pos with Line = pos.Line + 1 }) - let modules = - modules - |> Seq.filter (fun (_, endLine, _) -> endLine < currentLine) - |> Seq.sortBy (fun (m, _, _) -> -m.Length) - |> Seq.toList - - fun (partiallyQualifiedName: MaybeUnresolvedIdents) - (requiresQualifiedAccessParent: Idents option, autoOpenParent: Idents option, entityNamespace: Idents option, entity: Idents) -> - match res with - | None -> [||] - | Some (scope, ns, pos) -> - let results = - Entity.tryCreate(ns, scope.Idents, partiallyQualifiedName, requiresQualifiedAccessParent, autoOpenParent, entityNamespace, entity) - |> Array.map (fun e -> - e, - match modules |> List.filter (fun (m, _, _) -> entity |> Array.startsWith m ) with - | [] -> { ScopeKind = scope.Kind; Pos = pos } - | (_, endLine, startCol) :: _ -> - //printfn "All modules: %A, Win module: %A" modules m - let scopeKind = - match scope.Kind with - | TopModule -> NestedModule - | x -> x - { ScopeKind = scopeKind; Pos = Point.make (endLine + 1) startCol }) - results
\ No newline at end of file + //let modules = + // modules + // |> Seq.filter (fun (_, endLine, _) -> endLine < currentLine) + // |> Seq.sortBy (fun (m, _, _) -> -m.Length) + // |> Seq.toList + + //fun (partiallyQualifiedName: MaybeUnresolvedIdents) + //(requiresQualifiedAccessParent: Idents option, autoOpenParent: Idents option, entityNamespace: Idents option, entity: Idents) -> + //match res with + //| None -> [||] + //| Some (scope, ns, pos) -> + //let results = + // Entity.tryCreate(ns, scope.Idents, partiallyQualifiedName, requiresQualifiedAccessParent, autoOpenParent, entityNamespace, entity) + // |> Array.map (fun e -> + // e, + // match modules |> List.filter (fun (m, _, _) -> entity |> Array.startsWith m ) with + // | [] -> { ScopeKind = scope.Kind; Pos = pos } + // | (_, endLine, startCol) :: _ -> + // //printfn "All modules: %A, Win module: %A" modules m + // let scopeKind = + // match scope.Kind with + // | TopModule -> NestedModule + // | x -> x + // { ScopeKind = scopeKind; Pos = Point.make (endLine + 1) startCol }) + //results
\ No newline at end of file diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj index 6462718a65..c3710a5e90 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj +++ b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/MonoDevelop.FSharpInteractive.Service.fsproj @@ -14,8 +14,6 @@ <GenerateTailCalls>true</GenerateTailCalls> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> </PropertyGroup> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' " /> - <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' " /> <ItemGroup> <Reference Include="mscorlib" /> <Reference Include="System" /> @@ -69,7 +67,7 @@ <When Condition="$(TargetFrameworkIdentifier) == '.NETFramework' And $(TargetFrameworkVersion) == 'v4.7.2'"> <ItemGroup> <Reference Include="FSharp.Compiler.Service"> - <HintPath>..\packages\FSharp.Compiler.Service\lib\net45\FSharp.Compiler.Service.dll</HintPath> + <HintPath>..\packages\FSharp.Compiler.Service\lib\net461\FSharp.Compiler.Service.dll</HintPath> <Private>True</Private> <Paket>True</Paket> </Reference> diff --git a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs index a00e1f97bf..a34a7c1dea 100644 --- a/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs +++ b/main/external/fsharpbinding/MonoDevelop.FSharpi.Service/Program.fs @@ -5,7 +5,7 @@ open System.Drawing open System.IO open System.Reflection open Newtonsoft.Json -open Microsoft.FSharp.Compiler.Interactive.Shell +open FSharp.Compiler.Interactive.Shell open MonoDevelop.FSharp.Shared /// Wrapper for fsi with support for returning completions module CompletionServer = diff --git a/main/external/fsharpbinding/build.fsx b/main/external/fsharpbinding/build.fsx index e89981a9d3..4ad2b37254 100755 --- a/main/external/fsharpbinding/build.fsx +++ b/main/external/fsharpbinding/build.fsx @@ -58,7 +58,7 @@ Target "GenerateFastBuildProjects" (fun _ -> let (/) a b = Path.Combine(a, b) let nsuri = "http://schemas.microsoft.com/developer/msbuild/2003" - let absoluteFromRelative projectPath relPath = + let absoluteFromRelative (projectPath: string) relPath = let projectFolder = Path.GetDirectoryName projectPath let full = projectFolder / relPath Uri(full).LocalPath |> Path.GetFullPath diff --git a/main/external/fsharpbinding/paket.dependencies b/main/external/fsharpbinding/paket.dependencies index 01c0a0bd61..85bc2e254d 100644 --- a/main/external/fsharpbinding/paket.dependencies +++ b/main/external/fsharpbinding/paket.dependencies @@ -1,12 +1,13 @@ version 5.201.1 framework: net472 source https://nuget.org/api/v2/ +source https://www.myget.org/F/fantomas/api/v3/index.json nuget ExtCore framework: >= net40 nuget FSharp.Compiler.Service nuget FSharp.Core nuget System.ValueTuple -nuget Fantomas framework: >= net45 +nuget Fantomas 2.9.2-latest nuget FSharp.Compiler.CodeDom 0.9.2 framework: >= net40 nuget Mono.Cecil 0.10.0-beta6 framework: >= net40 nuget FAKE diff --git a/main/external/fsharpbinding/paket.lock b/main/external/fsharpbinding/paket.lock index 95a4b7060b..8f2934fc93 100644 --- a/main/external/fsharpbinding/paket.lock +++ b/main/external/fsharpbinding/paket.lock @@ -3,28 +3,29 @@ NUGET remote: https://www.nuget.org/api/v2 ExtCore (0.8.46) FAKE (5.8.4) - Fantomas (2.9.0) - FSharp.Compiler.Service (>= 25.0.1) FSharp.Compiler.CodeDom (0.9.2) - FSharp.Compiler.Service (25.0.1) - FSharp.Core (>= 4.1.18) + FSharp.Compiler.Service (28.0) + FSharp.Core (>= 4.6.2) System.Collections.Immutable (>= 1.5) System.Reflection.Metadata (>= 1.6) System.ValueTuple (>= 4.4) - FSharp.Core (4.5.4) + FSharp.Core (4.6.2) Mono.Cecil (0.10.0-beta6) - Newtonsoft.Json (12.0.1) + Newtonsoft.Json (12.0.2) StrongNamer (0.0.8) System.Collections.Immutable (1.5) - System.Reactive (4.1.2) - System.Threading.Tasks.Extensions (>= 4.5.1) - System.ValueTuple (>= 4.4) - System.Reactive.Linq (4.1.2) - System.Reactive (>= 4.1.2) - System.Threading.Tasks.Extensions (>= 4.5.1) + System.Reactive (4.1.5) + System.Threading.Tasks.Extensions (>= 4.5.2) + System.ValueTuple (>= 4.5) + System.Reactive.Linq (4.1.5) + System.Reactive (>= 4.1.5) + System.Threading.Tasks.Extensions (>= 4.5.2) System.Reflection.Metadata (1.6) System.Collections.Immutable (>= 1.5) System.Runtime.CompilerServices.Unsafe (4.5.2) - System.Threading.Tasks.Extensions (4.5.1) - System.Runtime.CompilerServices.Unsafe (>= 4.5) + System.Threading.Tasks.Extensions (4.5.2) + System.Runtime.CompilerServices.Unsafe (>= 4.5.2) System.ValueTuple (4.5) + remote: https://www.myget.org/F/fantomas/api/v3/index.json + Fantomas (2.9.2-latest) + FSharp.Compiler.Service (>= 27.0.1) |