提交 e33a19e9 编写于 作者: C CyrusNajmabadi

Hookup options.

上级 c51f4329
......@@ -75,7 +75,8 @@ protected sealed override ITaggerEventSource CreateEventSource(ITextView textVie
TaggerEventSources.OnOptionChanged(subjectBuffer, BlockStructureOptions.ShowBlockStructureGuidesForCommentsAndPreprocessorRegions, TaggerDelay.NearImmediate),
TaggerEventSources.OnOptionChanged(subjectBuffer, BlockStructureOptions.ShowOutliningForCodeLevelConstructs, TaggerDelay.NearImmediate),
TaggerEventSources.OnOptionChanged(subjectBuffer, BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, TaggerDelay.NearImmediate),
TaggerEventSources.OnOptionChanged(subjectBuffer, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, TaggerDelay.NearImmediate));
TaggerEventSources.OnOptionChanged(subjectBuffer, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, TaggerDelay.NearImmediate),
TaggerEventSources.OnOptionChanged(subjectBuffer, BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, TaggerDelay.NearImmediate));
}
/// <summary>
......
......@@ -10,6 +10,7 @@
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Projection;
using Microsoft.VisualStudio.Text.Tagging;
using Roslyn.Utilities;
namespace Microsoft.CodeAnalysis.Editor.Implementation.Structure
{
......@@ -55,13 +56,14 @@ internal class RoslynOutliningRegionTag : IOutliningRegionTag
public override bool Equals(object obj)
=> Equals(obj as RoslynOutliningRegionTag);
// This is only called if the spans for the tags were the same. In that case, we
// consider ourselves the same unless the CollapsedForm properties are different.
public bool Equals(RoslynOutliningRegionTag tag)
=> tag != null && Equals(this.CollapsedForm, tag.CollapsedForm);
=> tag != null &&
IsImplementation == tag.IsImplementation &&
Equals(this.CollapsedForm, tag.CollapsedForm);
public override int GetHashCode()
=> EqualityComparer<object>.Default.GetHashCode(this.CollapsedForm);
=> Hash.Combine(IsImplementation,
EqualityComparer<object>.Default.GetHashCode(this.CollapsedForm));
public object CollapsedHintForm =>
new ViewHostingControl(CreateElisionBufferView, CreateElisionBuffer);
......
......@@ -63,9 +63,9 @@ private class RoslynBlockTag : RoslynOutliningRegionTag, IBlockTag
ITextSnapshot snapshot,
BlockSpan blockSpan) :
base(textEditorFactoryService,
projectionBufferFactoryService,
editorOptionsFactoryService,
snapshot, blockSpan)
projectionBufferFactoryService,
editorOptionsFactoryService,
snapshot, blockSpan)
{
Parent = parent;
Level = parent == null ? 0 : parent.Level + 1;
......@@ -87,21 +87,20 @@ public override bool Equals(object obj)
/// </summary>
public bool Equals(RoslynBlockTag tag)
{
return tag != null &&
this.IsCollapsible == tag.IsCollapsible &&
this.Level == tag.Level &&
this.Type == tag.Type &&
EqualityComparer<object>.Default.Equals(this.CollapsedForm, tag.CollapsedForm) &&
this.StatementSpan == tag.StatementSpan &&
this.Span == tag.Span;
return base.Equals(tag) &&
IsCollapsible == tag.IsCollapsible &&
Level == tag.Level &&
Type == tag.Type &&
StatementSpan == tag.StatementSpan &&
Span == tag.Span;
}
public override int GetHashCode()
{
return Hash.Combine(this.IsCollapsible,
return Hash.Combine(base.GetHashCode(),
Hash.Combine(this.IsCollapsible,
Hash.Combine(this.Level,
Hash.Combine(this.Type,
Hash.Combine(this.CollapsedForm,
Hash.Combine(this.StatementSpan.GetHashCode(), this.Span.GetHashCode())))));
}
}
......
......@@ -47,6 +47,8 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_Show_outlining_for_code_level_constructs}" />
<CheckBox x:Name="Show_outlining_for_comments_and_preprocessor_regions"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Show_outlining_for_comments_and_preprocessor_regions}" />
<CheckBox x:Name="Collapse_regions_when_collapsing_to_definitions"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Collapse_regions_when_collapsing_to_definitions}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="BlockStructureGuidesGroupBox"
......
......@@ -29,6 +29,7 @@ public AdvancedOptionPageControl(IServiceProvider serviceProvider) : base(servic
BindToOption(Show_outlining_for_declaration_level_constructs, BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, LanguageNames.CSharp);
BindToOption(Show_outlining_for_code_level_constructs, BlockStructureOptions.ShowOutliningForCodeLevelConstructs, LanguageNames.CSharp);
BindToOption(Show_outlining_for_comments_and_preprocessor_regions, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, LanguageNames.CSharp);
BindToOption(Collapse_regions_when_collapsing_to_definitions, BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.CSharp);
BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.CSharp);
BindToOption(Show_guides_for_code_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.CSharp);
......
......@@ -99,6 +99,9 @@ public static string Option_Show_outlining_for_code_level_constructs
public static string Option_Show_outlining_for_comments_and_preprocessor_regions
=> ServicesVSResources.Show_outlining_for_comments_and_preprocessor_regions;
public static string Option_Collapse_regions_when_collapsing_to_definitions
=> ServicesVSResources.Collapse_regions_when_collapsing_to_definitions;
public static string Option_Block_Structure_Guides
=> ServicesVSResources.Block_Structure_Guides;
......
......@@ -370,6 +370,15 @@ internal class ServicesVSResources {
}
}
/// <summary>
/// Looks up a localized string similar to Collapse #regions when collapsing to definitions.
/// </summary>
internal static string Collapse_regions_when_collapsing_to_definitions {
get {
return ResourceManager.GetString("Collapse_regions_when_collapsing_to_definitions", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Computing remove suppressions fix....
/// </summary>
......
......@@ -807,4 +807,7 @@ Additional information: {1}</value>
<data name="Prefer_coalesce_expression" xml:space="preserve">
<value>Prefer coalesce expression</value>
</data>
<data name="Collapse_regions_when_collapsing_to_definitions" xml:space="preserve">
<value>Collapse #regions when collapsing to definitions</value>
</data>
</root>
\ No newline at end of file
......@@ -48,6 +48,8 @@
Content="{x:Static local:AdvancedOptionPageStrings.Option_Show_outlining_for_code_level_constructs}" />
<CheckBox x:Name="Show_outlining_for_comments_and_preprocessor_regions"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Show_outlining_for_comments_and_preprocessor_regions}" />
<CheckBox x:Name="Collapse_regions_when_collapsing_to_definitions"
Content="{x:Static local:AdvancedOptionPageStrings.Option_Collapse_regions_when_collapsing_to_definitions}" />
</StackPanel>
</GroupBox>
<GroupBox x:Uid="BlockStructureGuidesGroupBox"
......
......@@ -4,7 +4,6 @@ Imports Microsoft.CodeAnalysis
Imports Microsoft.CodeAnalysis.Editing
Imports Microsoft.CodeAnalysis.Editor.Shared.Options
Imports Microsoft.CodeAnalysis.ExtractMethod
Imports Microsoft.CodeAnalysis.Shared.Options
Imports Microsoft.CodeAnalysis.Structure
Imports Microsoft.CodeAnalysis.SymbolSearch
Imports Microsoft.VisualStudio.LanguageServices.Implementation
......@@ -24,6 +23,7 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
BindToOption(Show_outlining_for_declaration_level_constructs, BlockStructureOptions.ShowOutliningForDeclarationLevelConstructs, LanguageNames.VisualBasic)
BindToOption(Show_outlining_for_code_level_constructs, BlockStructureOptions.ShowOutliningForCodeLevelConstructs, LanguageNames.VisualBasic)
BindToOption(Show_outlining_for_comments_and_preprocessor_regions, BlockStructureOptions.ShowOutliningForCommentsAndPreprocessorRegions, LanguageNames.VisualBasic)
BindToOption(Collapse_regions_when_collapsing_to_definitions, BlockStructureOptions.CollapseRegionsWhenCollapsingToDefinitions, LanguageNames.VisualBasic)
BindToOption(Show_guides_for_declaration_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForDeclarationLevelConstructs, LanguageNames.VisualBasic)
BindToOption(Show_guides_for_code_level_constructs, BlockStructureOptions.ShowBlockStructureGuidesForCodeLevelConstructs, LanguageNames.VisualBasic)
......
......@@ -134,6 +134,9 @@ Namespace Microsoft.VisualStudio.LanguageServices.VisualBasic.Options
Public ReadOnly Property Option_Show_outlining_for_comments_and_preprocessor_regions As String =
ServicesVSResources.Show_outlining_for_comments_and_preprocessor_regions
Public ReadOnly Property Option_Collapse_regions_when_collapsing_to_definitions As String =
ServicesVSResources.Collapse_regions_when_collapsing_to_definitions
Public ReadOnly Property Option_Block_Structure_Guides As String =
ServicesVSResources.Block_Structure_Guides
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册