-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed configuration issue where data was being cleared of previous se…
…ctions (#317) * Fixed configuration issue where data was being cleared of previous sections * Updated scoped configuration to better handler on reload
- Loading branch information
1 parent
1497f35
commit 5571121
Showing
14 changed files
with
396 additions
and
121 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
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 |
---|---|---|
@@ -1,10 +1,38 @@ | ||
using System; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Serialization; | ||
|
||
namespace OmniSharp.Extensions.LanguageServer.Protocol.Models | ||
{ | ||
public class ConfigurationItem | ||
public class ConfigurationItem : IEquatable<ConfigurationItem> | ||
{ | ||
[Optional] public DocumentUri ScopeUri { get; set; } | ||
[Optional] public string Section { get; set; } | ||
|
||
public bool Equals(ConfigurationItem other) | ||
{ | ||
if (ReferenceEquals(null, other)) return false; | ||
if (ReferenceEquals(this, other)) return true; | ||
return Equals(ScopeUri, other.ScopeUri) && Section == other.Section; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
if (ReferenceEquals(null, obj)) return false; | ||
if (ReferenceEquals(this, obj)) return true; | ||
if (obj.GetType() != this.GetType()) return false; | ||
return Equals((ConfigurationItem) obj); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
unchecked | ||
{ | ||
return ( ( ScopeUri != null ? ScopeUri.GetHashCode() : 0 ) * 397 ) ^ ( Section != null ? Section.GetHashCode() : 0 ); | ||
} | ||
} | ||
|
||
public static bool operator ==(ConfigurationItem left, ConfigurationItem right) => Equals(left, right); | ||
|
||
public static bool operator !=(ConfigurationItem left, ConfigurationItem right) => !Equals(left, right); | ||
} | ||
} |
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
79 changes: 79 additions & 0 deletions
79
src/Protocol/Server/LanguageServerConfigurationExtensions.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,79 @@ | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using OmniSharp.Extensions.LanguageServer.Protocol.Models; | ||
|
||
namespace OmniSharp.Extensions.LanguageServer.Protocol.Server | ||
{ | ||
public static class LanguageServerConfigurationExtensions | ||
{ | ||
/// <summary> | ||
/// Adds a set of configuration items to be tracked by the server | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <param name="configurationItem"></param> | ||
/// <param name="configurationItems"></param> | ||
/// <returns></returns> | ||
public static ILanguageServerConfiguration AddConfigurationItem(this ILanguageServerConfiguration configuration, ConfigurationItem configurationItem, params ConfigurationItem[] configurationItems) | ||
{ | ||
return configuration.AddConfigurationItems(new[] { configurationItem }.Concat(configurationItems)); | ||
} | ||
|
||
/// <summary> | ||
/// Stops tracking a given set of configuration items | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <param name="configurationItem"></param> | ||
/// <param name="configurationItems"></param> | ||
/// <returns></returns> | ||
public static ILanguageServerConfiguration RemoveConfigurationItem(this ILanguageServerConfiguration configuration, ConfigurationItem configurationItem, params ConfigurationItem[] configurationItems) | ||
{ | ||
return configuration.RemoveConfigurationItems(new[] { configurationItem }.Concat(configurationItems)); | ||
} | ||
|
||
/// <summary> | ||
/// Adds a set of configuration items to be tracked by the server | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <param name="section"></param> | ||
/// <param name="sections"></param> | ||
/// <returns></returns> | ||
public static ILanguageServerConfiguration AddSection(this ILanguageServerConfiguration configuration, string section, params string[] sections) | ||
{ | ||
return configuration.AddConfigurationItems(new[] { section }.Concat(sections).Select(z => new ConfigurationItem() { Section = z})); | ||
} | ||
|
||
/// <summary> | ||
/// Stops tracking a given set of configuration items | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <param name="section"></param> | ||
/// <param name="sections"></param> | ||
/// <returns></returns> | ||
public static ILanguageServerConfiguration RemoveSection(this ILanguageServerConfiguration configuration, string section, params string[] sections) | ||
{ | ||
return configuration.RemoveConfigurationItems(new[] { section }.Concat(sections).Select(z => new ConfigurationItem() { Section = z})); | ||
} | ||
|
||
/// <summary> | ||
/// Adds a set of configuration items to be tracked by the server | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <param name="sections"></param> | ||
/// <returns></returns> | ||
public static ILanguageServerConfiguration AddSections(this ILanguageServerConfiguration configuration, IEnumerable<string> sections) | ||
{ | ||
return configuration.AddConfigurationItems(sections.Select(z => new ConfigurationItem() { Section = z})); | ||
} | ||
|
||
/// <summary> | ||
/// Stops tracking a given set of configuration items | ||
/// </summary> | ||
/// <param name="configuration"></param> | ||
/// <param name="sections"></param> | ||
/// <returns></returns> | ||
public static ILanguageServerConfiguration RemoveSections(this ILanguageServerConfiguration configuration, IEnumerable<string> sections) | ||
{ | ||
return configuration.RemoveConfigurationItems(sections.Select(z => new ConfigurationItem() { Section = z})); | ||
} | ||
} | ||
} |
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
Oops, something went wrong.