Skip to content
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

Add semicolon as a commit character for object creation and symbol completion #48851

Merged
merged 41 commits into from
Nov 14, 2020
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
108e3b1
Modify SymbolCompletionProvider and ObjectCreationProvider
Cosifne Sep 28, 2020
79a4626
Add unit tests
Cosifne Oct 22, 2020
7a93ef3
Renaming
Cosifne Oct 22, 2020
4a14daa
Merge branch 'master' into dev/shech/methodCompletion
Cosifne Oct 23, 2020
314cc29
Fix the LSP test
Cosifne Oct 23, 2020
9861e01
Improve perf
Cosifne Oct 26, 2020
559c7b3
Improve perf in ObjectCreationCompletionProvider
Cosifne Oct 27, 2020
c0bcee7
Add text change in AbstractExtensionMethodImportProvider
Cosifne Oct 27, 2020
137c759
Merge branch 'master' into dev/shech/perfTestForMethodCompletion
Cosifne Oct 27, 2020
6b88ad6
Change the code to let all AbstractImportCompletionProviders add prop…
Cosifne Oct 28, 2020
e98d5ab
Merge branch 'dev/shech/methodCompletion' of https://github.com/Cosif…
Cosifne Oct 28, 2020
b0b3bc0
Handle text change in abstract import completion provider
Cosifne Oct 29, 2020
6bfb71f
Add options & experiment flag
Cosifne Oct 29, 2020
f263f76
Add dot completion
Cosifne Oct 29, 2020
1e16635
Fix test
Cosifne Oct 29, 2020
12069c8
Change title
Cosifne Oct 29, 2020
8f5424a
Add test for import type provider
Cosifne Oct 29, 2020
c922156
deley the parenthesis location check when get change
Cosifne Oct 29, 2020
9f6fe83
Merge branch 'dev/shech/perfTestForMethodCompletion' into dev/shech/m…
Cosifne Oct 30, 2020
7ba79e0
Merge branch 'master' into dev/shech/methodCompletion
Cosifne Oct 30, 2020
eee6c7c
Fix format
Cosifne Oct 30, 2020
3fcedf3
Change the logic from one to all
Cosifne Oct 30, 2020
66c80c7
Fix the code in all the providers
Cosifne Nov 4, 2020
ed9161c
Reset all the option page and experiment
Cosifne Nov 4, 2020
21c6749
Change implementation
Cosifne Nov 5, 2020
85438b5
handle generics and add tests
Cosifne Nov 6, 2020
37967c9
Clean code
Cosifne Nov 6, 2020
f560353
Restore accidentally deleted files
Cosifne Nov 6, 2020
3389940
Fix and add tests for alias scenario
Cosifne Nov 6, 2020
0234843
Merge branch 'master' into dev/shech/methodCompletion
Cosifne Nov 6, 2020
0e95072
fix a format issue
Cosifne Nov 6, 2020
bccd2d8
delete addtional line
Cosifne Nov 6, 2020
5847b05
Don't change caret postion
Cosifne Nov 6, 2020
3c48830
Add test and few clean up
Cosifne Nov 7, 2020
f415456
A few more clean up
Cosifne Nov 7, 2020
61cbc12
Use symbol instead of Symbols[0]
Cosifne Nov 7, 2020
d7a3e8e
Address feedback
Cosifne Nov 11, 2020
1272b5b
remove one unnecessary test
Cosifne Nov 11, 2020
58116d2
Address nits, add tests
Cosifne Nov 13, 2020
9e49363
Code style fix
Cosifne Nov 13, 2020
fb3b530
Clean nits
Cosifne Nov 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1888,6 +1888,63 @@ await VerifyImportItemIsAbsentAsync(
}
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestCommitWithSemicolonForMethod()
{
var markup = @"
public class C
{
}
namespace AA
{
public static class Ext
{
public static int ToInt(this C c)
=> 1;
}
}

namespace BB
{
public class B
{
public void M()
{
var c = new C();
c.$$
}
}
}";

var expected = @"
using AA;

public class C
{
}
namespace AA
{
public static class Ext
{
public static int ToInt(this C c)
=> 1;
}
}

namespace BB
{
public class B
{
public void M()
{
var c = new C();
c.ToInt();
}
}
}";
await VerifyProviderCommitAsync(markup, "ToInt", expected, commitChar: ';', sourceCodeKind: SourceCodeKind.Regular);
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task TestTimeBox()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -677,5 +677,113 @@ void M()
";
await VerifyItemExistsAsync(markup, "List<object?>");
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CreateObjectAndCommitWithSemicolon()
{
var markup = @"
class Program
{
void Bar()
{
object o = new $$
}
}";
var expectedMark = @"
class Program
{
void Bar()
{
object o = new object();
}
}";
await VerifyProviderCommitAsync(markup, "object", expectedMark, commitChar: ';');
}

[WpfFact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CreateNullableObjectAndCommitWithSemicolon()
{
var markup = @"
class Program
{
void Bar()
{
object? o = new $$
}
}";
var expectedMark = @"
class Program
{
void Bar()
{
object? o = new object();
}
}";
await VerifyProviderCommitAsync(markup, "object", expectedMark, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CreateStringAsLocalAndCommitWithSemicolon()
{
var markup = @"
class Program
{
void Bar()
{
string o = new $$
}
}";
var expectedMark = @"
class Program
{
void Bar()
{
string o = new string();
}
}";
await VerifyProviderCommitAsync(markup, "string", expectedMark, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CreateGenericListAsLocalAndCommitWithSemicolon()
{
var markup = @"
using System.Collections.Generic;
class Program
{
void Bar()
{
List<int> o = new $$
}
}";
var expectedMark = @"
using System.Collections.Generic;
class Program
{
void Bar()
{
List<int> o = new List<int>();
}
}";
await VerifyProviderCommitAsync(markup, "List<int>", expectedMark, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CreateGenericListAsFieldAndCommitWithSemicolon()
{
var markup = @"
using System.Collections.Generic;
class Program
{
private List<int> o = new $$
}";
var expectedMark = @"
using System.Collections.Generic;
class Program
{
private List<int> o = new List<int>();
}";
await VerifyProviderCommitAsync(markup, "List<int>", expectedMark, commitChar: ';');
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10759,6 +10759,186 @@ await VerifyItemIsAbsentAsync(
matchingFilters: new List<CompletionFilter> { FilterSet.LocalAndParameterFilter });
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CompletionWithSemicolonForMethod()
{
var markup = @"
class Program
{
private void Bar()
{
F$$
}

private void Foo(int i)
{
}

private void Foo(int i, int c)
{
}
}";
var expected = @"
class Program
{
private void Bar()
{
Foo();
}

private void Foo(int i)
{
}

private void Foo(int i, int c)
{
}
}";
await VerifyProviderCommitAsync(markup, "Foo", expected, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CompletionWithSemicolonInNestedMethod()
{
var markup = @"
class Program
{
private void Bar()
{
Foo(F$$);
}

private int Foo(int i)
{
return 1;
}
}";
var expected = @"
class Program
{
private void Bar()
{
Foo(Foo(););
}

private int Foo(int i)
{
return 1;
}
}";
await VerifyProviderCommitAsync(markup, "Foo", expected, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CompletionWithSemicolonForDelegateInferredType()
{
var markup = @"
using System;
class Program
{
private void Bar()
{
Bar2(F$$);
}

private void Foo()
{
}

void Bar2(Action t) { }
}";
var expected = @"
using System;
class Program
{
private void Bar()
{
Bar2(Foo;);
}

private void Foo()
{
}

void Bar2(Action t) { }
}";
await VerifyProviderCommitAsync(markup, "Foo", expected, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CompletionWithSemicolonForConstructor()
{
var markup = @"
class Program
{
private static void Bar()
{
var o = new P$$
}
}";
var expected = @"
class Program
{
private static void Bar()
{
var o = new Program();
}
}";
await VerifyProviderCommitAsync(markup, "Program", expected, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CompletionWithSemicolonForTypeUnderNonObjectCreationContext()
{
var markup = @"
class Program
{
private static void Bar()
{
var o = P$$
}
}";
var expected = @"
class Program
{
private static void Bar()
{
var o = Program;
}
}";
await VerifyProviderCommitAsync(markup, "Program", expected, commitChar: ';');
}

[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task CompletionWithSemicolonForAliasConstructor()
{
var markup = @"
using String2 = System.String;
namespace Bar1
{
class Program
{
private static void Bar()
{
var o = new S$$
}
}
}";
var expected = @"
using String2 = System.String;
namespace Bar1
{
class Program
{
private static void Bar()
{
var o = new String2();
}
}
}";
await VerifyProviderCommitAsync(markup, "String2", expected, commitChar: ';');
}

[WorkItem(49072, "https://github.com/dotnet/roslyn/issues/49072")]
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async Task EnumMemberAfterPatternMatch()
Expand Down
Loading