forked from rubberduck-vba/Rubberduck3
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe7958b
commit 9edeb2d
Showing
11 changed files
with
137 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
Client/Rubberduck.UI/Shared/Settings/DiagnosticSeveritySettingViewModel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
using Rubberduck.InternalApi.Settings.Model; | ||
using Rubberduck.UI.Shared.Settings.Abstract; | ||
|
||
namespace Rubberduck.UI.Shared.Settings | ||
{ | ||
public class DiagnosticSeveritySettingViewModel : EnumValueSettingViewModel<DiagnosticSeverity> | ||
{ | ||
public DiagnosticSeveritySettingViewModel(TypedRubberduckSetting<DiagnosticSeverity> setting) : base(setting) | ||
{ | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
...d/Rubberduck.InternalApi/Settings/Model/LanguageServer/Diagnostics/DiagnosticsSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
using Rubberduck.InternalApi.Model; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace Rubberduck.InternalApi.Settings.Model.LanguageServer.Diagnostics; | ||
|
||
public record class DiagnosticsSettings : TypedSettingGroup //<RubberduckDiagnosticId> | ||
{ | ||
public static DiagnosticSetting[] DefaultSettings => | ||
Enum.GetValues<RubberduckDiagnosticId>().Except(Overrides.Keys) | ||
.Select(e => new DiagnosticSetting { Key = e.Code()}) | ||
.Concat(Overrides.Values) | ||
.ToArray(); | ||
|
||
public DiagnosticsSettings() | ||
{ | ||
DefaultValue = DefaultSettings; | ||
} | ||
|
||
private static Dictionary<RubberduckDiagnosticId, DiagnosticSetting> Overrides { get; } = new() | ||
{ | ||
[RubberduckDiagnosticId.UseMeaningfulIdentifierNames] = UseMeaningfulNamesDiagnosticSettings.Default, | ||
}; | ||
|
||
public static DiagnosticsSettings Default { get; } = new DiagnosticsSettings() { Value = DefaultSettings, DefaultValue = DefaultSettings }; | ||
} | ||
|
||
/// <summary> | ||
/// The base class for configuring an individual diagnostic. | ||
/// </summary> | ||
public record class DiagnosticSetting : TypedSettingGroup | ||
{ | ||
private static readonly RubberduckSetting[] DefaultSettings = | ||
[ | ||
new DiagnosticSeveritySetting(), | ||
]; | ||
|
||
public DiagnosticSetting() | ||
{ | ||
Value = DefaultValue = DefaultSettings; | ||
} | ||
|
||
[JsonIgnore] | ||
public DiagnosticSeverity Severity => GetSetting<DiagnosticSeveritySetting>()?.TypedValue ?? DiagnosticSeveritySetting.DefaultSettingValue; | ||
} | ||
|
||
public record class DiagnosticSeveritySetting : TypedRubberduckSetting<DiagnosticSeverity> | ||
{ | ||
public static DiagnosticSeverity DefaultSettingValue { get; } = DiagnosticSeverity.Warning; | ||
public DiagnosticSeveritySetting() | ||
{ | ||
SettingDataType = SettingDataType.EnumValueSetting; | ||
Value = DefaultValue = DefaultSettingValue; | ||
} | ||
} | ||
|
||
public record class UseMeaningfulNamesDiagnosticSettings : DiagnosticSetting | ||
{ | ||
private static readonly RubberduckSetting[] DefaultSettings = | ||
[ | ||
new DiagnosticSeveritySetting(), | ||
new IgnoredIdentifierPrefixesSetting(), | ||
]; | ||
|
||
public UseMeaningfulNamesDiagnosticSettings() | ||
{ | ||
Value = DefaultValue = DefaultSettings; | ||
} | ||
|
||
[JsonIgnore] | ||
public string[] IgnoredIdentifierPrefixes => GetSetting<IgnoredIdentifierPrefixesSetting>()?.TypedValue ?? IgnoredIdentifierPrefixesSetting.DefaultSettingValue; | ||
|
||
public static UseMeaningfulNamesDiagnosticSettings Default { get; } = new UseMeaningfulNamesDiagnosticSettings() { Value = DefaultSettings, DefaultValue = DefaultSettings }; | ||
} | ||
|
||
public record class IgnoredIdentifierPrefixesSetting : TypedRubberduckSetting<string[]> | ||
{ | ||
public static string[] DefaultSettingValue { get; } = []; | ||
|
||
public IgnoredIdentifierPrefixesSetting() | ||
{ | ||
SettingDataType = SettingDataType.ListSetting; | ||
Value = DefaultValue = DefaultSettingValue; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 2 additions & 1 deletion
3
Shared/Rubberduck.InternalApi/Settings/Model/TypedRubberduckSetting.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters