Skip to content

Commit 1672305

Browse files
committed
clean code
1 parent 18b10be commit 1672305

25 files changed

+58
-269
lines changed

LanguageServer.Framework.Tests/Handlers/CallHierarchyHandlerTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private class TestCallHierarchyHandler : CallHierarchyHandlerBase
2020
{
2121
var items = new List<CallHierarchyItem>
2222
{
23-
new CallHierarchyItem
23+
new()
2424
{
2525
Name = "testFunction",
2626
Kind = SymbolKind.Function,
@@ -44,7 +44,7 @@ protected override Task<CallHierarchyIncomingCallsResponse> CallHierarchyIncomin
4444
{
4545
var calls = new List<CallHierarchyIncomingCall>
4646
{
47-
new CallHierarchyIncomingCall
47+
new()
4848
{
4949
From = new Location
5050
{
@@ -69,7 +69,7 @@ protected override Task<CallHierarchyOutgoingCallsResponse> CallHierarchyOutgoin
6969
{
7070
var calls = new List<CallHierarchyOutgoingCall>
7171
{
72-
new CallHierarchyOutgoingCall
72+
new()
7373
{
7474
To = new Location
7575
{

LanguageServer.Framework.Tests/Handlers/CodeActionHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ protected override Task<CodeActionResponse> Handle(CodeActionParams request, Can
1919
{
2020
var actions = new List<CodeAction>
2121
{
22-
new CodeAction
22+
new()
2323
{
2424
Title = "Fix spelling",
2525
Kind = CodeActionKind.QuickFix,
@@ -41,7 +41,7 @@ [new DocumentUri(new Uri("file:///test.txt"))] =
4141
}
4242
}
4343
},
44-
new CodeAction
44+
new()
4545
{
4646
Title = "Refactor method",
4747
Kind = CodeActionKind.Refactor

LanguageServer.Framework.Tests/Handlers/CodeLensHandlerTests.cs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ protected override Task<CodeLensResponse> Handle(CodeLensParams request, Cancell
1818
{
1919
var lenses = new List<CodeLens>
2020
{
21-
new CodeLens
21+
new()
2222
{
2323
Range = new DocumentRange(
24-
new Position { Line = 0, Character = 0 },
25-
new Position { Line = 0, Character = 10 }
26-
),
24+
new Position { Line = 0, Character = 0 },
25+
new Position { Line = 0, Character = 10 }
26+
),
2727
Command = new Command
2828
{
2929
Title = "5 references",
@@ -45,7 +45,8 @@ protected override Task<CodeLens> Resolve(CodeLens codeLens, CancellationToken t
4545
return Task.FromResult(codeLens);
4646
}
4747

48-
public override void RegisterCapability(ServerCapabilities serverCapabilities, ClientCapabilities clientCapabilities)
48+
public override void RegisterCapability(ServerCapabilities serverCapabilities,
49+
ClientCapabilities clientCapabilities)
4950
{
5051
serverCapabilities.CodeLensProvider = new Protocol.Capabilities.Server.Options.CodeLensOptions
5152
{
@@ -66,7 +67,6 @@ public async Task Handle_ShouldReturnCodeLenses()
6667

6768
// Act
6869
var method = handler.GetType()
69-
7070
.GetMethod("Handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!;
7171

7272
var task = method.Invoke(handler, [request, CancellationToken.None]);
@@ -95,7 +95,6 @@ public async Task Resolve_ShouldUpdateCodeLens()
9595

9696
// Act
9797
var method = handler.GetType()
98-
9998
.GetMethod("Resolve", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!;
10099

101100
var task = method.Invoke(handler, [lens, CancellationToken.None]);
@@ -123,4 +122,4 @@ public void RegisterCapability_ShouldSetCodeLensProvider()
123122
serverCapabilities.CodeLensProvider.Should().NotBeNull();
124123
serverCapabilities.CodeLensProvider!.ResolveProvider.Should().BeTrue();
125124
}
126-
}
125+
}

LanguageServer.Framework.Tests/Handlers/CompletionHandlerTests.cs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ private class TestCompletionHandler : CompletionHandlerBase
1919
{
2020
var items = new List<CompletionItem>
2121
{
22-
new CompletionItem
22+
new()
2323
{
2424
Label = "testMethod",
2525
Kind = CompletionItemKind.Method,
@@ -28,7 +28,7 @@ private class TestCompletionHandler : CompletionHandlerBase
2828
InsertText = "testMethod()",
2929
InsertTextFormat = InsertTextFormat.PlainText
3030
},
31-
new CompletionItem
31+
new()
3232
{
3333
Label = "testVariable",
3434
Kind = CompletionItemKind.Variable,
@@ -47,7 +47,8 @@ protected override Task<CompletionItem> Resolve(CompletionItem item, Cancellatio
4747
return Task.FromResult(item);
4848
}
4949

50-
public override void RegisterCapability(ServerCapabilities serverCapabilities, ClientCapabilities clientCapabilities)
50+
public override void RegisterCapability(ServerCapabilities serverCapabilities,
51+
ClientCapabilities clientCapabilities)
5152
{
5253
serverCapabilities.CompletionProvider = new Protocol.Capabilities.Server.Options.CompletionOptions
5354
{
@@ -72,7 +73,6 @@ public async Task Handle_ShouldReturnCompletionItems()
7273

7374
// Act
7475
var method = handler.GetType()
75-
7676
.GetMethod("Handle", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!;
7777

7878
var task = method.Invoke(handler, [request, CancellationToken.None]);
@@ -101,7 +101,6 @@ public async Task Resolve_ShouldAddDocumentation()
101101

102102
// Act
103103
var method = handler.GetType()
104-
105104
.GetMethod("Resolve", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance)!;
106105

107106
var task = method.Invoke(handler, [item, CancellationToken.None]);
@@ -130,4 +129,4 @@ public void RegisterCapability_ShouldSetCompletionProvider()
130129
serverCapabilities.CompletionProvider.TriggerCharacters.Should().Contain(".");
131130
serverCapabilities.CompletionProvider.TriggerCharacters.Should().Contain(":");
132131
}
133-
}
132+
}

LanguageServer.Framework.Tests/Handlers/DeclarationHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private class TestDeclarationHandler : DeclarationHandlerBase
1818
{
1919
var locations = new List<Location>
2020
{
21-
new Location
21+
new()
2222
{
2323
Uri = "file:///declarations.txt",
2424
Range = new DocumentRange(

LanguageServer.Framework.Tests/Handlers/DefinitionHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ private class TestDefinitionHandler : DefinitionHandlerBase
1818
{
1919
var locations = new List<Location>
2020
{
21-
new Location
21+
new()
2222
{
2323
Uri = "file:///source.txt",
2424
Range = new DocumentRange(

LanguageServer.Framework.Tests/Handlers/DocumentColorHandlerTests.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected override Task<DocumentColorResponse> Handle(DocumentColorParams reques
1818
{
1919
var colorInfos = new List<ColorInformation>
2020
{
21-
new ColorInformation
21+
new()
2222
{
2323
Range = new DocumentRange(
2424
new Position { Line = 5, Character = 10 },
@@ -36,11 +36,11 @@ protected override Task<ColorPresentationResponse> Resolve(ColorPresentationPara
3636
{
3737
var presentations = new List<ColorPresentation>
3838
{
39-
new ColorPresentation
39+
new()
4040
{
4141
Label = $"rgb({request.Color.Red * 255}, {request.Color.Green * 255}, {request.Color.Blue * 255})"
4242
},
43-
new ColorPresentation
43+
new()
4444
{
4545
Label = "#FF0000"
4646
}

LanguageServer.Framework.Tests/Handlers/DocumentFormattingHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ private class TestDocumentFormattingHandler : DocumentFormattingHandlerBase
2020
{
2121
var edits = new List<TextEdit>
2222
{
23-
new TextEdit
23+
new()
2424
{
2525
Range = new DocumentRange(
2626
new Position { Line = 0, Character = 0 },
@@ -50,7 +50,7 @@ private class TestDocumentFormattingHandler : DocumentFormattingHandlerBase
5050
{
5151
var edits = new List<TextEdit>
5252
{
53-
new TextEdit
53+
new()
5454
{
5555
Range = request.Range,
5656
NewText = "formatted range"

LanguageServer.Framework.Tests/Handlers/DocumentHighlightHandlerTests.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,15 @@ protected override Task<DocumentHighlightResponse> Handle(DocumentHighlightParam
1919
{
2020
var highlights = new List<DocumentHighlight>
2121
{
22-
new DocumentHighlight
22+
new()
2323
{
2424
Range = new DocumentRange(
2525
new Position { Line = 5, Character = 10 },
2626
new Position { Line = 5, Character = 20 }
2727
),
2828
Kind = DocumentHighlightKind.Write
2929
},
30-
new DocumentHighlight
30+
new()
3131
{
3232
Range = new DocumentRange(
3333
new Position { Line = 10, Character = 5 },

LanguageServer.Framework.Tests/Handlers/DocumentLinkHandlerTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ protected override Task<DocumentLinkResponse> Handle(DocumentLinkParams request,
1818
{
1919
var links = new List<DocumentLink>
2020
{
21-
new DocumentLink
21+
new()
2222
{
2323
Range = new DocumentRange(
2424
new Position { Line = 0, Character = 0 },

0 commit comments

Comments
 (0)