UNPKG

3.13 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2019 Ericsson and others.
4//
5// This program and the accompanying materials are made available under the
6// terms of the Eclipse Public License v. 2.0 which is available at
7// http://www.eclipse.org/legal/epl-2.0.
8//
9// This Source Code may also be made available under the following Secondary
10// Licenses when the conditions for such availability set forth in the Eclipse
11// Public License v. 2.0 are satisfied: GNU General Public License, version 2
12// with the GNU Classpath Exception which is available at
13// https://www.gnu.org/software/classpath/license.html.
14//
15// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.PreferenceScope = void 0;
19/* eslint-disable @typescript-eslint/no-explicit-any */
20var PreferenceScope;
21(function (PreferenceScope) {
22 PreferenceScope[PreferenceScope["Default"] = 0] = "Default";
23 PreferenceScope[PreferenceScope["User"] = 1] = "User";
24 PreferenceScope[PreferenceScope["Workspace"] = 2] = "Workspace";
25 PreferenceScope[PreferenceScope["Folder"] = 3] = "Folder";
26})(PreferenceScope = exports.PreferenceScope || (exports.PreferenceScope = {}));
27(function (PreferenceScope) {
28 function is(scope) {
29 return typeof scope === 'number' && getScopes().findIndex(s => s === scope) >= 0;
30 }
31 PreferenceScope.is = is;
32 /**
33 * @returns preference scopes from broadest to narrowest: Default -> Folder.
34 */
35 function getScopes() {
36 return Object.keys(PreferenceScope)
37 .filter(k => typeof PreferenceScope[k] === 'string')
38 .map(v => Number(v));
39 }
40 PreferenceScope.getScopes = getScopes;
41 /**
42 * @returns preference scopes from narrowest to broadest. Folder -> Default.
43 */
44 function getReversedScopes() {
45 return getScopes().reverse();
46 }
47 PreferenceScope.getReversedScopes = getReversedScopes;
48 function getScopeNames(scope) {
49 const names = [];
50 const allNames = Object.keys(PreferenceScope)
51 .filter(k => typeof PreferenceScope[k] === 'number');
52 if (scope) {
53 for (const name of allNames) {
54 if (PreferenceScope[name] <= scope) {
55 names.push(name);
56 }
57 }
58 }
59 return names;
60 }
61 PreferenceScope.getScopeNames = getScopeNames;
62 function fromString(strScope) {
63 switch (strScope) {
64 case 'application':
65 return PreferenceScope.User;
66 case 'window':
67 return PreferenceScope.Folder;
68 case 'resource':
69 return PreferenceScope.Folder;
70 case 'language-overridable':
71 return PreferenceScope.Folder;
72 }
73 }
74 PreferenceScope.fromString = fromString;
75})(PreferenceScope = exports.PreferenceScope || (exports.PreferenceScope = {}));
76//# sourceMappingURL=preference-scope.js.map
\No newline at end of file