Skip to content
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
05edfc3
Merge remote-tracking branch 'upstream/features/semantic-snippets' in…
akhera99 Mar 16, 2022
4ee5f98
start work on if snippet
akhera99 Mar 16, 2022
f7ff1ad
wip
akhera99 Mar 16, 2022
bf3685c
wip
akhera99 Mar 17, 2022
74f5583
wip
akhera99 Mar 17, 2022
fa96642
wip
akhera99 Mar 22, 2022
3fbf4c7
wip
akhera99 Mar 23, 2022
977529d
tests
akhera99 Mar 28, 2022
14de21f
Merge remote-tracking branch 'upstream/features/semantic-snippets' in…
akhera99 Apr 5, 2022
2c1ed38
wip
akhera99 Apr 6, 2022
c705fd8
wip
akhera99 Apr 6, 2022
d84a6c5
Merge remote-tracking branch 'upstream/features/semantic-snippets' in…
akhera99 Apr 6, 2022
85c12cc
lsp service now works
akhera99 Apr 12, 2022
293e2b5
lots of changes
akhera99 Apr 14, 2022
b8593eb
wip
akhera99 Apr 19, 2022
105e658
Merge branch 'main' into features/snippets_2
akhera99 Apr 19, 2022
e137363
remove added changes
akhera99 Apr 19, 2022
e78d2d4
fixes
akhera99 Apr 19, 2022
9220332
cleanup
akhera99 Apr 19, 2022
5e4aefe
comments
akhera99 Apr 19, 2022
334331b
remove unused file
akhera99 Apr 19, 2022
ddd0aab
revert change made
akhera99 Apr 20, 2022
f4f0aea
update
akhera99 Apr 20, 2022
3230e0a
fix random file change
akhera99 Apr 20, 2022
ddfedf3
simplify
akhera99 Apr 20, 2022
29c41a6
cleanup/comments
akhera99 Apr 20, 2022
61ffd0e
remove unused attribute
akhera99 Apr 20, 2022
fae94b9
Merge remote-tracking branch 'upstream/features/semantic-snippets' in…
akhera99 Apr 20, 2022
35ba79b
pr feedback
akhera99 Apr 21, 2022
6588ac4
pr feedback, need to fix tests
akhera99 Apr 25, 2022
b09573d
fix tests
akhera99 Apr 26, 2022
76c70e1
fix/add comments
akhera99 Apr 26, 2022
29e3e17
more fixes
akhera99 Apr 26, 2022
51e7377
more pr feedback
akhera99 Apr 26, 2022
05e839f
lots of fixes
akhera99 Apr 26, 2022
631d80d
pr feedback
akhera99 Apr 26, 2022
f257f52
naming
akhera99 Apr 26, 2022
7f7c087
lots of changes + added new tests
akhera99 May 2, 2022
6ef9f5d
comments
akhera99 May 2, 2022
c281d2a
more fixes
akhera99 May 2, 2022
7002563
bug
akhera99 May 2, 2022
1940bb2
fix
akhera99 May 2, 2022
02a1a15
merge main
akhera99 May 2, 2022
e6254ed
options changed
akhera99 May 2, 2022
a4e669f
tests wrong and I did stupid stuff as a result
akhera99 May 2, 2022
93c8e9a
remove unnecessary code
akhera99 May 2, 2022
75970d1
comments
akhera99 May 2, 2022
d26a3a4
cleanup, need to add more tests
akhera99 May 2, 2022
fae4cff
tests
akhera99 May 2, 2022
08c22d6
every iteration
akhera99 May 2, 2022
973b95b
regions for easier viewing
akhera99 May 2, 2022
ed94922
no changes
akhera99 May 3, 2022
1a87816
feedback
akhera99 May 3, 2022
6baf3b3
pr feedback
akhera99 May 3, 2022
5021c4e
remove unused method
akhera99 May 4, 2022
2c2be6b
fix bug
akhera99 May 4, 2022
c244e00
feedback
akhera99 May 6, 2022
74111f9
way more tests
akhera99 May 6, 2022
af2aada
handle same positions better
akhera99 May 6, 2022
f36a262
comments
akhera99 May 6, 2022
c8f674f
tests
akhera99 May 9, 2022
6e33b9d
pr feedback
akhera99 May 9, 2022
2498eff
removed unnecessary check
akhera99 May 9, 2022
d02e1c2
fix
akhera99 May 10, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

#nullable disable

using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.CodeAnalysis.Completion;
using Microsoft.CodeAnalysis.Editor.CSharp.UnitTests.Completion.CompletionProviders;
using Roslyn.Test.Utilities;
using Xunit;

namespace Microsoft.CodeAnalysis.Test.Utilities.Snippets
{
public abstract class AbstractCSharpLSPSnippetTests : AbstractCSharpCompletionProviderTests
{
protected override async Task VerifyCustomCommitProviderWorkerAsync(string codeBeforeCommit, int position, string itemToCommit, string expectedLSPSnippet, SourceCodeKind sourceCodeKind, char? commitChar = null)
{
using var workspaceFixture = GetOrCreateWorkspaceFixture();
var workspace = workspaceFixture.Target.GetWorkspace();

// Set options that are not CompletionOptions
workspace.SetOptions(WithChangedNonCompletionOptions(workspace.Options));

var document1 = workspaceFixture.Target.UpdateDocument(codeBeforeCommit, sourceCodeKind);
await VerifyCustomCommitProviderLSPSnippetAsync(document1, position, itemToCommit, expectedLSPSnippet, commitChar);

if (await CanUseSpeculativeSemanticModelAsync(document1, position))
{
var document2 = workspaceFixture.Target.UpdateDocument(codeBeforeCommit, sourceCodeKind, cleanBeforeUpdate: false);
await VerifyCustomCommitProviderLSPSnippetAsync(document2, position, itemToCommit, expectedLSPSnippet, commitChar);
}
}

private async Task VerifyCustomCommitProviderLSPSnippetAsync(Document document, int position, string itemToCommit, string expectedLSPSnippet, char? commitChar = null)
{
var service = GetCompletionService(document.Project);
var completionList = await GetCompletionListAsync(service, document, position, CompletionTrigger.Invoke);
var items = completionList.Items;

Assert.Contains(itemToCommit, items.Select(x => x.DisplayText), GetStringComparer());
var completionItem = items.First(i => CompareItems(i.DisplayText, itemToCommit));
var commit = await service.GetChangeAsync(document, completionItem, commitChar, CancellationToken.None);
var generatedLSPSnippet = commit.LSPSnippet;
AssertEx.EqualOrDiff(expectedLSPSnippet, generatedLSPSnippet);
}
}
}
Loading