@theia/outline-view 1.53.0-next.5 → 1.53.0-next.55

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,91 +1,91 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2017 TypeFox and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable, inject } from '@theia/core/shared/inversify';
18
- import { Event, Emitter, DisposableCollection } from '@theia/core';
19
- import { WidgetFactory } from '@theia/core/lib/browser';
20
- import { OutlineViewWidget, OutlineViewWidgetFactory, OutlineSymbolInformationNode } from './outline-view-widget';
21
- import { Widget } from '@theia/core/shared/@phosphor/widgets';
22
-
23
- @injectable()
24
- export class OutlineViewService implements WidgetFactory {
25
-
26
- id = 'outline-view';
27
-
28
- protected widget?: OutlineViewWidget;
29
- protected readonly onDidChangeOutlineEmitter = new Emitter<OutlineSymbolInformationNode[]>();
30
- protected readonly onDidChangeOpenStateEmitter = new Emitter<boolean>();
31
- protected readonly onDidSelectEmitter = new Emitter<OutlineSymbolInformationNode>();
32
- protected readonly onDidOpenEmitter = new Emitter<OutlineSymbolInformationNode>();
33
- protected readonly onDidTapNodeEmitter = new Emitter<OutlineSymbolInformationNode>();
34
-
35
- constructor(@inject(OutlineViewWidgetFactory) protected factory: OutlineViewWidgetFactory) { }
36
-
37
- get onDidSelect(): Event<OutlineSymbolInformationNode> {
38
- return this.onDidSelectEmitter.event;
39
- }
40
-
41
- get onDidOpen(): Event<OutlineSymbolInformationNode> {
42
- return this.onDidOpenEmitter.event;
43
- }
44
-
45
- get onDidChangeOutline(): Event<OutlineSymbolInformationNode[]> {
46
- return this.onDidChangeOutlineEmitter.event;
47
- }
48
-
49
- get onDidChangeOpenState(): Event<boolean> {
50
- return this.onDidChangeOpenStateEmitter.event;
51
- }
52
-
53
- get onDidTapNode(): Event<OutlineSymbolInformationNode> {
54
- return this.onDidTapNodeEmitter.event;
55
- }
56
-
57
- get open(): boolean {
58
- return this.widget !== undefined && this.widget.isVisible;
59
- }
60
-
61
- didTapNode(node: OutlineSymbolInformationNode): void {
62
- this.onDidTapNodeEmitter.fire(node);
63
- }
64
-
65
- /**
66
- * Publish the collection of outline view symbols.
67
- * - Publishing includes setting the `OutlineViewWidget` tree with symbol information.
68
- * @param roots the list of outline symbol information nodes.
69
- */
70
- publish(roots: OutlineSymbolInformationNode[]): void {
71
- if (this.widget) {
72
- this.widget.setOutlineTree(roots);
73
- }
74
- // onDidChangeOutline needs to be fired even when the outline view widget is closed
75
- // in order to update breadcrumbs.
76
- this.onDidChangeOutlineEmitter.fire(roots);
77
- }
78
-
79
- createWidget(): Promise<Widget> {
80
- this.widget = this.factory();
81
- const disposables = new DisposableCollection();
82
- disposables.push(this.widget.onDidChangeOpenStateEmitter.event(open => this.onDidChangeOpenStateEmitter.fire(open)));
83
- disposables.push(this.widget.model.onOpenNode(node => this.onDidOpenEmitter.fire(node as OutlineSymbolInformationNode)));
84
- disposables.push(this.widget.model.onSelectionChanged(selection => this.onDidSelectEmitter.fire(selection[0] as OutlineSymbolInformationNode)));
85
- this.widget.disposed.connect(() => {
86
- this.widget = undefined;
87
- disposables.dispose();
88
- });
89
- return Promise.resolve(this.widget);
90
- }
91
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2017 TypeFox and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable, inject } from '@theia/core/shared/inversify';
18
+ import { Event, Emitter, DisposableCollection } from '@theia/core';
19
+ import { WidgetFactory } from '@theia/core/lib/browser';
20
+ import { OutlineViewWidget, OutlineViewWidgetFactory, OutlineSymbolInformationNode } from './outline-view-widget';
21
+ import { Widget } from '@theia/core/shared/@phosphor/widgets';
22
+
23
+ @injectable()
24
+ export class OutlineViewService implements WidgetFactory {
25
+
26
+ id = 'outline-view';
27
+
28
+ protected widget?: OutlineViewWidget;
29
+ protected readonly onDidChangeOutlineEmitter = new Emitter<OutlineSymbolInformationNode[]>();
30
+ protected readonly onDidChangeOpenStateEmitter = new Emitter<boolean>();
31
+ protected readonly onDidSelectEmitter = new Emitter<OutlineSymbolInformationNode>();
32
+ protected readonly onDidOpenEmitter = new Emitter<OutlineSymbolInformationNode>();
33
+ protected readonly onDidTapNodeEmitter = new Emitter<OutlineSymbolInformationNode>();
34
+
35
+ constructor(@inject(OutlineViewWidgetFactory) protected factory: OutlineViewWidgetFactory) { }
36
+
37
+ get onDidSelect(): Event<OutlineSymbolInformationNode> {
38
+ return this.onDidSelectEmitter.event;
39
+ }
40
+
41
+ get onDidOpen(): Event<OutlineSymbolInformationNode> {
42
+ return this.onDidOpenEmitter.event;
43
+ }
44
+
45
+ get onDidChangeOutline(): Event<OutlineSymbolInformationNode[]> {
46
+ return this.onDidChangeOutlineEmitter.event;
47
+ }
48
+
49
+ get onDidChangeOpenState(): Event<boolean> {
50
+ return this.onDidChangeOpenStateEmitter.event;
51
+ }
52
+
53
+ get onDidTapNode(): Event<OutlineSymbolInformationNode> {
54
+ return this.onDidTapNodeEmitter.event;
55
+ }
56
+
57
+ get open(): boolean {
58
+ return this.widget !== undefined && this.widget.isVisible;
59
+ }
60
+
61
+ didTapNode(node: OutlineSymbolInformationNode): void {
62
+ this.onDidTapNodeEmitter.fire(node);
63
+ }
64
+
65
+ /**
66
+ * Publish the collection of outline view symbols.
67
+ * - Publishing includes setting the `OutlineViewWidget` tree with symbol information.
68
+ * @param roots the list of outline symbol information nodes.
69
+ */
70
+ publish(roots: OutlineSymbolInformationNode[]): void {
71
+ if (this.widget) {
72
+ this.widget.setOutlineTree(roots);
73
+ }
74
+ // onDidChangeOutline needs to be fired even when the outline view widget is closed
75
+ // in order to update breadcrumbs.
76
+ this.onDidChangeOutlineEmitter.fire(roots);
77
+ }
78
+
79
+ createWidget(): Promise<Widget> {
80
+ this.widget = this.factory();
81
+ const disposables = new DisposableCollection();
82
+ disposables.push(this.widget.onDidChangeOpenStateEmitter.event(open => this.onDidChangeOpenStateEmitter.fire(open)));
83
+ disposables.push(this.widget.model.onOpenNode(node => this.onDidOpenEmitter.fire(node as OutlineSymbolInformationNode)));
84
+ disposables.push(this.widget.model.onSelectionChanged(selection => this.onDidSelectEmitter.fire(selection[0] as OutlineSymbolInformationNode)));
85
+ this.widget.disposed.connect(() => {
86
+ this.widget = undefined;
87
+ disposables.dispose();
88
+ });
89
+ return Promise.resolve(this.widget);
90
+ }
91
+ }
@@ -1,77 +1,77 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2019 Ericsson and others.
3
- //
4
- // This program and the accompanying materials are made available under the
5
- // terms of the Eclipse Public License v. 2.0 which is available at
6
- // http://www.eclipse.org/legal/epl-2.0.
7
- //
8
- // This Source Code may also be made available under the following Secondary
9
- // Licenses when the conditions for such availability set forth in the Eclipse
10
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
- // with the GNU Classpath Exception which is available at
12
- // https://www.gnu.org/software/classpath/license.html.
13
- //
14
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
- // *****************************************************************************
16
-
17
- import { injectable } from '@theia/core/shared/inversify';
18
- import { CompositeTreeNode, TreeModelImpl, ExpandableTreeNode, TreeNode } from '@theia/core/lib/browser';
19
-
20
- @injectable()
21
- export class OutlineViewTreeModel extends TreeModelImpl {
22
-
23
- /**
24
- * Handle the expansion of the tree node.
25
- * - The method is a no-op in order to preserve focus on the editor
26
- * after attempting to perform a `collapse-all`.
27
- * @param node the expandable tree node.
28
- */
29
- protected override handleExpansion(node: Readonly<ExpandableTreeNode>): void {
30
- // no-op
31
- }
32
-
33
- override async collapseAll(raw?: Readonly<CompositeTreeNode>): Promise<boolean> {
34
- const node = raw || this.getFocusedNode();
35
- if (CompositeTreeNode.is(node)) {
36
- return this.expansionService.collapseAll(node);
37
- }
38
- return false;
39
- }
40
-
41
- /**
42
- * The default behavior of `openNode` calls `doOpenNode` which by default
43
- * toggles the expansion of the node. Overriding to prevent expansion, but
44
- * allow for the `onOpenNode` event to still fire on a double-click event.
45
- */
46
- override openNode(raw?: TreeNode | undefined): void {
47
- const node = raw || this.getFocusedNode();
48
- if (node) {
49
- this.onOpenNodeEmitter.fire(node);
50
- }
51
- }
52
-
53
- expandAll(raw?: TreeNode): void {
54
- if (CompositeTreeNode.is(raw)) {
55
- for (const child of raw.children) {
56
- if (ExpandableTreeNode.is(child)) {
57
- this.expandAll(child);
58
- }
59
- }
60
- }
61
- if (ExpandableTreeNode.is(raw)) {
62
- this.expandNode(raw);
63
- }
64
- }
65
-
66
- areNodesCollapsed(): boolean {
67
- if (CompositeTreeNode.is(this.root)) {
68
- for (const child of this.root.children) {
69
- if (!ExpandableTreeNode.isCollapsed(child)) {
70
- return false;
71
- }
72
- }
73
- }
74
- return true;
75
- }
76
-
77
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2019 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ import { injectable } from '@theia/core/shared/inversify';
18
+ import { CompositeTreeNode, TreeModelImpl, ExpandableTreeNode, TreeNode } from '@theia/core/lib/browser';
19
+
20
+ @injectable()
21
+ export class OutlineViewTreeModel extends TreeModelImpl {
22
+
23
+ /**
24
+ * Handle the expansion of the tree node.
25
+ * - The method is a no-op in order to preserve focus on the editor
26
+ * after attempting to perform a `collapse-all`.
27
+ * @param node the expandable tree node.
28
+ */
29
+ protected override handleExpansion(node: Readonly<ExpandableTreeNode>): void {
30
+ // no-op
31
+ }
32
+
33
+ override async collapseAll(raw?: Readonly<CompositeTreeNode>): Promise<boolean> {
34
+ const node = raw || this.getFocusedNode();
35
+ if (CompositeTreeNode.is(node)) {
36
+ return this.expansionService.collapseAll(node);
37
+ }
38
+ return false;
39
+ }
40
+
41
+ /**
42
+ * The default behavior of `openNode` calls `doOpenNode` which by default
43
+ * toggles the expansion of the node. Overriding to prevent expansion, but
44
+ * allow for the `onOpenNode` event to still fire on a double-click event.
45
+ */
46
+ override openNode(raw?: TreeNode | undefined): void {
47
+ const node = raw || this.getFocusedNode();
48
+ if (node) {
49
+ this.onOpenNodeEmitter.fire(node);
50
+ }
51
+ }
52
+
53
+ expandAll(raw?: TreeNode): void {
54
+ if (CompositeTreeNode.is(raw)) {
55
+ for (const child of raw.children) {
56
+ if (ExpandableTreeNode.is(child)) {
57
+ this.expandAll(child);
58
+ }
59
+ }
60
+ }
61
+ if (ExpandableTreeNode.is(raw)) {
62
+ this.expandNode(raw);
63
+ }
64
+ }
65
+
66
+ areNodesCollapsed(): boolean {
67
+ if (CompositeTreeNode.is(this.root)) {
68
+ for (const child of this.root.children) {
69
+ if (!ExpandableTreeNode.isCollapsed(child)) {
70
+ return false;
71
+ }
72
+ }
73
+ }
74
+ return true;
75
+ }
76
+
77
+ }