-
Notifications
You must be signed in to change notification settings - Fork 156
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RoslynSource Text #1123
Merged
Merged
RoslynSource Text #1123
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
aa619d5
sketch of adaptive sourcetext
TheAngryByrd 7bf476d
RoslyinSourceText impl
TheAngryByrd a6a0682
Try using path that can create LargeText source files
TheAngryByrd 00b98e4
refactor to sourcefactory
TheAngryByrd 591b5c4
Allow switching of sourcetextfactory
TheAngryByrd 787eb05
formatting
TheAngryByrd 6871bfe
Fix naming
TheAngryByrd 79ef7cc
Remove unused code
TheAngryByrd 0e06921
Merge branch 'main' into own-source-text-impl
TheAngryByrd ffe5bf5
Refactoring file open code
TheAngryByrd db33b90
update fantomas
TheAngryByrd 825b3b9
Merge remote-tracking branch 'upstream/main' into own-source-text-impl
TheAngryByrd File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,10 +27,10 @@ | |
] | ||
}, | ||
"fantomas": { | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"commands": [ | ||
"fantomas" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,3 +44,4 @@ coverage | |
test/FsAutoComplete.Tests.Lsp/TestResults/ | ||
|
||
.tool-versions | ||
BenchmarkDotNet.Artifacts/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
namespace Benchmarks | ||
open System | ||
open BenchmarkDotNet | ||
open BenchmarkDotNet.Attributes | ||
open BenchmarkDotNet.Running | ||
open System.Security.Cryptography | ||
|
||
|
||
|
||
|
||
module EntryPoint = | ||
|
||
[<EntryPoint>] | ||
let main argv = | ||
let summary = BenchmarkRunner.Run<SourceText_LineChanges_Benchmarks>(); | ||
0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
namespace Benchmarks | ||
|
||
open System | ||
open FSharp.Data.Adaptive | ||
open Microsoft.CodeAnalysis.Text | ||
type FileVersion = int | ||
|
||
|
||
module Helpers = | ||
open FsAutoComplete.LspHelpers | ||
open FSharp.UMX | ||
open System.Collections.Generic | ||
|
||
let fileContents = IO.File.ReadAllText(@"C:\Users\jimmy\Repositories\public\TheAngryByrd\span-playground\Romeo and Juliet by William Shakespeare.txt") | ||
|
||
let initNamedText () = | ||
FsAutoComplete.NamedText(UMX.tag "lol", fileContents) | ||
|
||
let initRoslynSourceText () = | ||
SourceText.From(fileContents) | ||
|
||
|
||
let convertToTextSpan (sourceText : SourceText, range : Ionide.LanguageServerProtocol.Types.Range) = | ||
let start = sourceText.Lines.[max 0 (range.Start.Line)].Start + range.Start.Character | ||
let endPosition = | ||
sourceText.Lines.[min (range.End.Line) (sourceText.Lines.Count - 1)].Start | ||
+ range.End.Character | ||
TextSpan(start, endPosition - start) | ||
|
||
let addToSourceText (sourceText : SourceText, range : Ionide.LanguageServerProtocol.Types.Range, text : string) = | ||
let textSpan = convertToTextSpan(sourceText, range) | ||
let newText = sourceText.WithChanges([| TextChange(textSpan, text) |]) | ||
newText | ||
|
||
let addToSourceTextMany (sourceText : SourceText, spans : IEnumerable<Ionide.LanguageServerProtocol.Types.Range * string>) = | ||
let textSpans = spans |> Seq.map (fun (range, text) -> TextChange(convertToTextSpan(sourceText, range), text)) |> Seq.toArray | ||
let newText = sourceText.WithChanges(textSpans) | ||
newText | ||
|
||
let addToNamedText (namedText : FsAutoComplete.NamedText, range : Ionide.LanguageServerProtocol.Types.Range, text : string) = | ||
let range = protocolRangeToRange (UMX.untag namedText.FileName) range | ||
match namedText.ModifyText(range, text) with | Ok x -> x | Error e -> failwith e | ||
|
||
open BenchmarkDotNet | ||
open BenchmarkDotNet.Attributes | ||
open Helpers | ||
open BenchmarkDotNet.Jobs | ||
[<MemoryDiagnoser>] | ||
[<SimpleJob(RuntimeMoniker.Net70)>] | ||
type SourceText_LineChanges_Benchmarks ()= | ||
|
||
[<Params(1, 15, 50, 100, 1000)>] | ||
member val public N = 0 with get, set | ||
|
||
[<Benchmark(Baseline = true)>] | ||
member this.Named_Text_changeText_everyUpdate () = | ||
let mutable file = initNamedText () | ||
file <- addToNamedText(file, { Start = { Line = 0; Character = 5 }; End = { Line = 0; Character = 5 } }, "World") | ||
for i in 1..this.N do | ||
file <- addToNamedText(file, { Start = { Line = 0; Character = 10 }; End = { Line = 0; Character = 10 } }, "\nLOL") | ||
file.Lines |> Seq.toArray |> ignore | ||
|
||
[<Benchmark>] | ||
member this.Roslyn_Text_changeText_everyUpdate () = | ||
let mutable file = initRoslynSourceText () | ||
file <- addToSourceText(file, { Start = { Line = 0; Character = 5 }; End = { Line = 0; Character = 5 } }, "World") | ||
for i in 1..this.N do | ||
file <- addToSourceText(file, { Start = { Line = 0; Character = 10 }; End = { Line = 0; Character = 10 } }, "\nLOL") | ||
file.Lines |> Seq.toArray |> ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFrameworks>net6.0;net7.0</TargetFrameworks> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Compile Include="SourceTextBenchmarks.fs" /> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\src\FsAutoComplete\FsAutoComplete.fsproj" /> | ||
</ItemGroup> | ||
<Import Project="..\.paket\Paket.Restore.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
FSharp.Core | ||
BenchmarkDotNet | ||
Microsoft.CodeAnalysis | ||
FSharp.Data.Adaptive |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using this a just a giant text file. Should I include it or leave as an exercise for the others?