UNPKG

2.95 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-only WITH Classpath-exception-2.0
16// *****************************************************************************
17Object.defineProperty(exports, "__esModule", { value: true });
18exports.PreferenceScope = void 0;
19var PreferenceScope;
20(function (PreferenceScope) {
21 PreferenceScope[PreferenceScope["Default"] = 0] = "Default";
22 PreferenceScope[PreferenceScope["User"] = 1] = "User";
23 PreferenceScope[PreferenceScope["Workspace"] = 2] = "Workspace";
24 PreferenceScope[PreferenceScope["Folder"] = 3] = "Folder";
25})(PreferenceScope = exports.PreferenceScope || (exports.PreferenceScope = {}));
26(function (PreferenceScope) {
27 function is(scope) {
28 return typeof scope === 'number' && getScopes().includes(scope);
29 }
30 PreferenceScope.is = is;
31 /**
32 * @returns preference scopes from broadest to narrowest: Default -> Folder.
33 */
34 function getScopes() {
35 return Object.values(PreferenceScope).filter(nameOrIndex => !isNaN(Number(nameOrIndex)));
36 }
37 PreferenceScope.getScopes = getScopes;
38 /**
39 * @returns preference scopes from narrowest to broadest. Folder -> Default.
40 */
41 function getReversedScopes() {
42 return getScopes().reverse();
43 }
44 PreferenceScope.getReversedScopes = getReversedScopes;
45 function getScopeNames(scope) {
46 const names = [];
47 const scopes = getScopes();
48 if (scope) {
49 for (const scopeIndex of scopes) {
50 if (scopeIndex <= scope) {
51 names.push(PreferenceScope[scopeIndex]);
52 }
53 }
54 }
55 return names;
56 }
57 PreferenceScope.getScopeNames = getScopeNames;
58 function fromString(strScope) {
59 switch (strScope) {
60 case 'application':
61 return PreferenceScope.User;
62 case 'window':
63 return PreferenceScope.Folder;
64 case 'resource':
65 return PreferenceScope.Folder;
66 case 'language-overridable':
67 return PreferenceScope.Folder;
68 }
69 }
70 PreferenceScope.fromString = fromString;
71})(PreferenceScope = exports.PreferenceScope || (exports.PreferenceScope = {}));
72//# sourceMappingURL=preference-scope.js.map
\No newline at end of file