Options
All
  • Public
  • Public/Protected
  • All
Menu

Class PreferenceProvider

The PreferenceProvider is used to store and retrieve preference values. A PreferenceProvider does not operate in a global scope but is configured for one or more PreferenceScopes. The (default implementation for the) PreferenceService aggregates all PreferenceProviders and serves as a common facade for manipulating preference values.

Hierarchy

Implements

  • Disposable

Index

Constructors

constructor

  • Returns PreferenceProvider

Properties

Protected _pendingChanges

_pendingChanges: Promise<boolean>

Protected Readonly _ready

_ready: Deferred<void>

Protected deferredChanges

deferredChanges: undefined | PreferenceProviderDataChanges

Protected fireDidPreferencesChanged

fireDidPreferencesChanged: () => Promise<boolean>

Type declaration

    • (): Promise<boolean>
    • Returns Promise<boolean>

Readonly onDidPreferencesChanged

onDidPreferencesChanged: Event<PreferenceProviderDataChanges>

Protected Readonly onDidPreferencesChangedEmitter

onDidPreferencesChangedEmitter: Emitter<PreferenceProviderDataChanges>

Protected Readonly preferenceOverrideService

preferenceOverrideService: PreferenceLanguageOverrideService

Protected Readonly toDispose

toDispose: DisposableCollection

Accessors

pendingChanges

  • get pendingChanges(): Promise<boolean>
  • Returns Promise<boolean>

ready

  • get ready(): Promise<void>
  • Resolved when the preference provider is ready to provide preferences It should be resolved by subclasses.

    Returns Promise<void>

Methods

dispose

  • dispose(): void
  • Returns void

Protected emitPreferencesChangedEvent

  • Informs the listeners that one or more preferences of this provider are changed. The listeners are able to find what was changed from the emitted event.

    Parameters

    Returns Promise<boolean>

get

  • get<T>(preferenceName: string, resourceUri?: string): undefined | T
  • Retrieve the stored value for the given preference and resource URI.

    Type parameters

    • T

    Parameters

    • preferenceName: string

      the preference identifier.

    • Optional resourceUri: string

      the uri of the resource for which the preference is stored. This is used to retrieve a potentially different value for the same preference for different resources, for example files.encoding.

    Returns undefined | T

    the value stored for the given preference and resourceUri if it exists, otherwise undefined.

getConfigUri

  • getConfigUri(resourceUri?: string, sectionName?: string): undefined | default
  • Retrieve the configuration URI for the given resource URI.

    Parameters

    • Optional resourceUri: string

      the uri of the resource or undefined.

    • Optional sectionName: string

      the section to return the URI for, e.g. tasks or launch. Defaults to settings.

    Returns undefined | default

    the corresponding resource URI or undefined if there is no valid URI.

Optional getContainingConfigUri

  • getContainingConfigUri(resourceUri?: string, sectionName?: string): undefined | default
  • Retrieves the first valid configuration URI contained by the given resource.

    Parameters

    • Optional resourceUri: string

      the uri of the container resource or undefined.

    • Optional sectionName: string

    Returns undefined | default

    the first valid configuration URI contained by the given resource undefined if there is no valid configuration URI at all.

getDomain

  • getDomain(): undefined | string[]
  • Retrieve the domain for this provider.

    Returns undefined | string[]

    the domain or undefined if this provider is suitable for all domains.

Protected getParsedContent

  • getParsedContent(jsonData: any): {}
  • Parameters

    • jsonData: any

    Returns {}

    • [key: string]: any

Abstract getPreferences

  • getPreferences(resourceUri?: string): {}
  • Parameters

    • Optional resourceUri: string

    Returns {}

    • [p: string]: any

Protected mergePreferenceProviderDataChange

resolve

  • Resolve the value for the given preference and resource URI.

    Type parameters

    • T

    Parameters

    • preferenceName: string

      the preference identifier.

    • Optional resourceUri: string

      the URI of the resource for which this provider should resolve the preference. This is used to retrieve a potentially different value for the same preference for different resources, for example files.encoding.

    Returns PreferenceResolveResult<T>

    an object containing the value stored for the given preference and resourceUri if it exists, otherwise undefined.

Abstract setPreference

  • setPreference(key: string, value: any, resourceUri?: string): Promise<boolean>
  • Stores a new value for the given preference key in the provider.

    Parameters

    • key: string

      the preference key (typically the name).

    • value: any

      the new preference value.

    • Optional resourceUri: string

      the URI of the resource for which the preference is stored.

    Returns Promise<boolean>

    a promise that only resolves if all changes were delivered. If changes were made then implementation must either await on this.emitPreferencesChangedEvent(...) or this.pendingChanges if changes are fired indirectly.

Static deepEqual

  • deepEqual(a: undefined | null | string | number | boolean | JSONObject | JSONArray, b: undefined | null | string | number | boolean | JSONObject | JSONArray): boolean
  • Handles deep equality with the possibility of undefined

    Parameters

    • a: undefined | null | string | number | boolean | JSONObject | JSONArray
    • b: undefined | null | string | number | boolean | JSONObject | JSONArray

    Returns boolean

Static merge

  • merge(source: undefined | null | string | number | boolean | JSONObject | JSONArray, target: JSONValue): JSONValue
  • Parameters

    • source: undefined | null | string | number | boolean | JSONObject | JSONArray
    • target: JSONValue

    Returns JSONValue