UNPKG

2.79 kBJavaScriptView Raw
1"use strict";
2// *****************************************************************************
3// Copyright (C) 2021 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.NavigatableWidgetOptions = exports.NavigatableWidget = exports.Navigatable = void 0;
19const common_1 = require("../common");
20const widgets_1 = require("./widgets");
21var Navigatable;
22(function (Navigatable) {
23 function is(arg) {
24 return (0, common_1.isObject)(arg) && 'getResourceUri' in arg && 'createMoveToUri' in arg;
25 }
26 Navigatable.is = is;
27})(Navigatable = exports.Navigatable || (exports.Navigatable = {}));
28var NavigatableWidget;
29(function (NavigatableWidget) {
30 function is(arg) {
31 return arg instanceof widgets_1.BaseWidget && Navigatable.is(arg);
32 }
33 NavigatableWidget.is = is;
34 function* getAffected(widgets, context) {
35 const uris = Array.isArray(context) ? context : [context];
36 return get(widgets, resourceUri => uris.some(uri => uri.isEqualOrParent(resourceUri)));
37 }
38 NavigatableWidget.getAffected = getAffected;
39 function* get(widgets, filter = () => true) {
40 for (const widget of widgets) {
41 if (NavigatableWidget.is(widget)) {
42 const resourceUri = widget.getResourceUri();
43 if (resourceUri && filter(resourceUri)) {
44 yield [resourceUri, widget];
45 }
46 }
47 }
48 }
49 NavigatableWidget.get = get;
50 function getUri(widget) {
51 if (is(widget)) {
52 return widget.getResourceUri();
53 }
54 }
55 NavigatableWidget.getUri = getUri;
56})(NavigatableWidget = exports.NavigatableWidget || (exports.NavigatableWidget = {}));
57var NavigatableWidgetOptions;
58(function (NavigatableWidgetOptions) {
59 function is(arg) {
60 return (0, common_1.isObject)(arg) && arg.kind === 'navigatable';
61 }
62 NavigatableWidgetOptions.is = is;
63})(NavigatableWidgetOptions = exports.NavigatableWidgetOptions || (exports.NavigatableWidgetOptions = {}));
64//# sourceMappingURL=navigatable-types.js.map
\No newline at end of file