UNPKG

2.9 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.PreferenceDataProperty = exports.PreferenceSchemaProperties = exports.PreferenceSchema = void 0;
19const preference_scope_1 = require("./preference-scope");
20var PreferenceSchema;
21(function (PreferenceSchema) {
22 function is(obj) {
23 return !!obj && ('properties' in obj) && PreferenceSchemaProperties.is(obj['properties']);
24 }
25 PreferenceSchema.is = is;
26 function getDefaultScope(schema) {
27 let defaultScope = preference_scope_1.PreferenceScope.Workspace;
28 if (!preference_scope_1.PreferenceScope.is(schema.scope)) {
29 defaultScope = preference_scope_1.PreferenceScope.fromString(schema.scope) || preference_scope_1.PreferenceScope.Workspace;
30 }
31 else {
32 defaultScope = schema.scope;
33 }
34 return defaultScope;
35 }
36 PreferenceSchema.getDefaultScope = getDefaultScope;
37})(PreferenceSchema = exports.PreferenceSchema || (exports.PreferenceSchema = {}));
38var PreferenceSchemaProperties;
39(function (PreferenceSchemaProperties) {
40 function is(obj) {
41 return !!obj && typeof obj === 'object';
42 }
43 PreferenceSchemaProperties.is = is;
44})(PreferenceSchemaProperties = exports.PreferenceSchemaProperties || (exports.PreferenceSchemaProperties = {}));
45var PreferenceDataProperty;
46(function (PreferenceDataProperty) {
47 function fromPreferenceSchemaProperty(schemaProps, defaultScope = preference_scope_1.PreferenceScope.Workspace) {
48 if (!schemaProps.scope) {
49 schemaProps.scope = defaultScope;
50 }
51 else if (typeof schemaProps.scope === 'string') {
52 return Object.assign(schemaProps, { scope: preference_scope_1.PreferenceScope.fromString(schemaProps.scope) || defaultScope });
53 }
54 return schemaProps;
55 }
56 PreferenceDataProperty.fromPreferenceSchemaProperty = fromPreferenceSchemaProperty;
57})(PreferenceDataProperty = exports.PreferenceDataProperty || (exports.PreferenceDataProperty = {}));
58//# sourceMappingURL=preference-schema.js.map
\No newline at end of file