提交 59e47d37 编写于 作者: R Ravi Chande

Add an option to disable name suggestions

上级 790aeaca
......@@ -207,9 +207,9 @@ public class C
void Goo(StringBuilder $$) {}
}
";
await VerifyItemExistsAsync(markup, "stringBuilder", glyph: (int) Glyph.Parameter);
await VerifyItemExistsAsync(markup, "@string", glyph: (int) Glyph.Parameter);
await VerifyItemExistsAsync(markup, "builder", glyph: (int) Glyph.Parameter);
await VerifyItemExistsAsync(markup, "stringBuilder", glyph: (int)Glyph.Parameter);
await VerifyItemExistsAsync(markup, "@string", glyph: (int)Glyph.Parameter);
await VerifyItemExistsAsync(markup, "builder", glyph: (int)Glyph.Parameter);
}
[WorkItem(19260, "https://github.com/dotnet/roslyn/issues/19260")]
......@@ -223,7 +223,7 @@ public class C
void Goo(For $$) {}
}
";
await VerifyItemExistsAsync(markup, "@for", glyph: (int) Glyph.Parameter);
await VerifyItemExistsAsync(markup, "@for", glyph: (int)Glyph.Parameter);
}
[WorkItem(19260, "https://github.com/dotnet/roslyn/issues/19260")]
......@@ -626,5 +626,30 @@ void Do<T>(out T goo)
";
await VerifyItemExistsAsync(markup, "test");
}
[Fact, Trait(Traits.Feature, Traits.Features.Completion)]
public async void DisabledByOption()
{
var workspace = WorkspaceFixture.GetWorkspace();
var originalOptions = WorkspaceFixture.GetWorkspace().Options;
try
{
workspace.Options = originalOptions.
WithChangedOption(CompletionOptions.ShowNameSuggestions, LanguageNames.CSharp, false);
var markup = @"
class Test
{
Test $$
}
";
await VerifyNoItemsExistAsync(markup);
}
finally
{
workspace.Options = originalOptions;
}
}
}
}
......@@ -32,6 +32,11 @@ public override async Task ProvideCompletionsAsync(CompletionContext completionC
var cancellationToken = completionContext.CancellationToken;
var semanticModel = await document.GetSemanticModelForSpanAsync(new Text.TextSpan(position, 0), cancellationToken).ConfigureAwait(false);
if (!completionContext.Options.GetOption(CompletionOptions.ShowNameSuggestions, LanguageNames.CSharp))
{
return;
}
var context = CSharpSyntaxContext.CreateContext(document.Project.Solution.Workspace, semanticModel, position, cancellationToken);
if (context.IsInNonUserCode)
{
......
......@@ -37,6 +37,10 @@ internal static class CompletionOptions
nameof(CompletionOptions), nameof(BlockForCompletionItems), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation($"TextEditor.%LANGUAGE%.Specific.{BlockForCompletionItems}"));
public static readonly PerLanguageOption<bool> ShowNameSuggestions =
new PerLanguageOption<bool>(nameof(CompletionOptions), nameof(ShowNameSuggestions), defaultValue: true,
storageLocations: new RoamingProfileStorageLocation("TextEditor.%LANGUAGE%.Specific.ShowNameSuggestions"));
public static IEnumerable<PerLanguageOption<bool>> GetDev15CompletionOptions()
{
yield return ShowCompletionItemFilters;
......
......@@ -1149,6 +1149,15 @@ internal class CSharpVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Show name s_uggestions.
/// </summary>
internal static string Show_name_suggestions {
get {
return ResourceManager.GetString("Show_name_suggestions", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Show preview for rename _tracking.
/// </summary>
......
......@@ -528,4 +528,7 @@
<data name="Separate_using_directive_groups" xml:space="preserve">
<value>Separate using directive groups</value>
</data>
<data name="Show_name_suggestions" xml:space="preserve">
<value>Show name s_uggestions</value>
</data>
</root>
\ No newline at end of file
......@@ -60,6 +60,10 @@
x:Name="Always_add_new_line_on_enter"
Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Always_add_new_line_on_enter}"/>
</StackPanel>
<CheckBox x:Uid="Show_name_suggestions"
x:Name="Show_name_suggestions"
Content="{x:Static local:IntelliSenseOptionPageStrings.Option_Show_name_suggestions}" />
</StackPanel>
</GroupBox>
</StackPanel>
......
......@@ -29,6 +29,8 @@ public IntelliSenseOptionPageControl(IServiceProvider serviceProvider) : base(se
BindToOption(Never_add_new_line_on_enter, CompletionOptions.EnterKeyBehavior, EnterKeyRule.Never, LanguageNames.CSharp);
BindToOption(Only_add_new_line_on_enter_with_whole_word, CompletionOptions.EnterKeyBehavior, EnterKeyRule.AfterFullyTypedWord, LanguageNames.CSharp);
BindToOption(Always_add_new_line_on_enter, CompletionOptions.EnterKeyBehavior, EnterKeyRule.Always, LanguageNames.CSharp);
BindToOption(Show_name_suggestions, CompletionOptions.ShowNameSuggestions, LanguageNames.CSharp);
}
private void Show_completion_list_after_a_character_is_typed_Checked(object sender, RoutedEventArgs e)
......
......@@ -59,5 +59,8 @@ public static string Option_ShowSnippets
public static string Option_Include_snippets_when_question_Tab_is_typed_after_an_identifier =>
CSharpVSResources.Include_snippets_when_Tab_is_typed_after_an_identifier;
public static string Option_Show_name_suggestions =>
CSharpVSResources.Show_name_suggestions;
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册