@theia/console 1.53.0-next.55 → 1.53.0-next.64

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,32 +1,32 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 { ContainerModule } from '@theia/core/shared/inversify';
18
- import { CommandContribution, MenuContribution } from '@theia/core';
19
- import { FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser';
20
- import { ConsoleContribution } from './console-contribution';
21
- import { ConsoleManager } from './console-manager';
22
-
23
- import '../../src/browser/style/index.css';
24
-
25
- export default new ContainerModule(bind => {
26
- bind(ConsoleManager).toSelf().inSingletonScope();
27
- bind(ConsoleContribution).toSelf().inSingletonScope();
28
- bind(FrontendApplicationContribution).toService(ConsoleContribution);
29
- bind(CommandContribution).toService(ConsoleContribution);
30
- bind(KeybindingContribution).toService(ConsoleContribution);
31
- bind(MenuContribution).toService(ConsoleContribution);
32
- });
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 { ContainerModule } from '@theia/core/shared/inversify';
18
+ import { CommandContribution, MenuContribution } from '@theia/core';
19
+ import { FrontendApplicationContribution, KeybindingContribution } from '@theia/core/lib/browser';
20
+ import { ConsoleContribution } from './console-contribution';
21
+ import { ConsoleManager } from './console-manager';
22
+
23
+ import '../../src/browser/style/index.css';
24
+
25
+ export default new ContainerModule(bind => {
26
+ bind(ConsoleManager).toSelf().inSingletonScope();
27
+ bind(ConsoleContribution).toSelf().inSingletonScope();
28
+ bind(FrontendApplicationContribution).toService(ConsoleContribution);
29
+ bind(CommandContribution).toService(ConsoleContribution);
30
+ bind(KeybindingContribution).toService(ConsoleContribution);
31
+ bind(MenuContribution).toService(ConsoleContribution);
32
+ });
@@ -1,76 +1,76 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 } from '@theia/core/shared/inversify';
18
-
19
- @injectable()
20
- export class ConsoleHistory {
21
-
22
- static limit = 50;
23
-
24
- protected values: string[] = [];
25
- protected index = -1;
26
-
27
- push(value: string): void {
28
- this.delete(value);
29
- this.values.push(value);
30
- this.trim();
31
- this.index = this.values.length;
32
- }
33
- protected delete(value: string): void {
34
- const index = this.values.indexOf(value);
35
- if (index !== -1) {
36
- this.values.splice(index, 1);
37
- }
38
- }
39
- protected trim(): void {
40
- const index = this.values.length - ConsoleHistory.limit;
41
- if (index > 0) {
42
- this.values = this.values.slice(index);
43
- }
44
- }
45
-
46
- get current(): string | undefined {
47
- return this.values[this.index];
48
- }
49
-
50
- get previous(): string | undefined {
51
- this.index = Math.max(this.index - 1, -1);
52
- return this.current;
53
- }
54
-
55
- get next(): string | undefined {
56
- this.index = Math.min(this.index + 1, this.values.length);
57
- return this.current;
58
- }
59
-
60
- store(): ConsoleHistory.Data {
61
- const { values, index } = this;
62
- return { values, index };
63
- }
64
-
65
- restore(object: ConsoleHistory): void {
66
- this.values = object.values;
67
- this.index = object.index;
68
- }
69
-
70
- }
71
- export namespace ConsoleHistory {
72
- export interface Data {
73
- values: string[],
74
- index: number
75
- }
76
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 } from '@theia/core/shared/inversify';
18
+
19
+ @injectable()
20
+ export class ConsoleHistory {
21
+
22
+ static limit = 50;
23
+
24
+ protected values: string[] = [];
25
+ protected index = -1;
26
+
27
+ push(value: string): void {
28
+ this.delete(value);
29
+ this.values.push(value);
30
+ this.trim();
31
+ this.index = this.values.length;
32
+ }
33
+ protected delete(value: string): void {
34
+ const index = this.values.indexOf(value);
35
+ if (index !== -1) {
36
+ this.values.splice(index, 1);
37
+ }
38
+ }
39
+ protected trim(): void {
40
+ const index = this.values.length - ConsoleHistory.limit;
41
+ if (index > 0) {
42
+ this.values = this.values.slice(index);
43
+ }
44
+ }
45
+
46
+ get current(): string | undefined {
47
+ return this.values[this.index];
48
+ }
49
+
50
+ get previous(): string | undefined {
51
+ this.index = Math.max(this.index - 1, -1);
52
+ return this.current;
53
+ }
54
+
55
+ get next(): string | undefined {
56
+ this.index = Math.min(this.index + 1, this.values.length);
57
+ return this.current;
58
+ }
59
+
60
+ store(): ConsoleHistory.Data {
61
+ const { values, index } = this;
62
+ return { values, index };
63
+ }
64
+
65
+ restore(object: ConsoleHistory): void {
66
+ this.values = object.values;
67
+ this.index = object.index;
68
+ }
69
+
70
+ }
71
+ export namespace ConsoleHistory {
72
+ export interface Data {
73
+ values: string[],
74
+ index: number
75
+ }
76
+ }
@@ -1,37 +1,37 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 { ApplicationShell } from '@theia/core/lib/browser';
19
- import { ConsoleWidget } from './console-widget';
20
-
21
- @injectable()
22
- export class ConsoleManager {
23
-
24
- @inject(ApplicationShell)
25
- protected readonly shell: ApplicationShell;
26
-
27
- get activeConsole(): ConsoleWidget | undefined {
28
- const widget = this.shell.activeWidget;
29
- return widget instanceof ConsoleWidget ? widget : undefined;
30
- }
31
-
32
- get currentConsole(): ConsoleWidget | undefined {
33
- const widget = this.shell.currentWidget;
34
- return widget instanceof ConsoleWidget ? widget : undefined;
35
- }
36
-
37
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 { ApplicationShell } from '@theia/core/lib/browser';
19
+ import { ConsoleWidget } from './console-widget';
20
+
21
+ @injectable()
22
+ export class ConsoleManager {
23
+
24
+ @inject(ApplicationShell)
25
+ protected readonly shell: ApplicationShell;
26
+
27
+ get activeConsole(): ConsoleWidget | undefined {
28
+ const widget = this.shell.activeWidget;
29
+ return widget instanceof ConsoleWidget ? widget : undefined;
30
+ }
31
+
32
+ get currentConsole(): ConsoleWidget | undefined {
33
+ const widget = this.shell.currentWidget;
34
+ return widget instanceof ConsoleWidget ? widget : undefined;
35
+ }
36
+
37
+ }
@@ -1,121 +1,121 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2021 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 } from '@theia/core/shared/inversify';
18
- import { Emitter, Event, Disposable, DisposableCollection } from '@theia/core';
19
- import { ConsoleSession } from './console-session';
20
- import { Severity } from '@theia/core/lib/common/severity';
21
-
22
- @injectable()
23
- export class ConsoleSessionManager implements Disposable {
24
-
25
- protected readonly sessions = new Map<string, ConsoleSession>();
26
- protected _selectedSession: ConsoleSession | undefined;
27
- protected _severity: Severity | undefined;
28
-
29
- protected readonly sessionAddedEmitter = new Emitter<ConsoleSession>();
30
- protected readonly sessionDeletedEmitter = new Emitter<ConsoleSession>();
31
- protected readonly sessionWasShownEmitter = new Emitter<ConsoleSession>();
32
- protected readonly sessionWasHiddenEmitter = new Emitter<ConsoleSession>();
33
- protected readonly selectedSessionChangedEmitter = new Emitter<ConsoleSession | undefined>();
34
- protected readonly severityChangedEmitter = new Emitter<void>();
35
-
36
- get onDidAddSession(): Event<ConsoleSession> {
37
- return this.sessionAddedEmitter.event;
38
- }
39
- get onDidDeleteSession(): Event<ConsoleSession> {
40
- return this.sessionDeletedEmitter.event;
41
- }
42
- get onDidShowSession(): Event<ConsoleSession> {
43
- return this.sessionWasShownEmitter.event;
44
- }
45
- get onDidHideSession(): Event<ConsoleSession> {
46
- return this.sessionWasHiddenEmitter.event;
47
- }
48
- get onDidChangeSelectedSession(): Event<ConsoleSession | undefined> {
49
- return this.selectedSessionChangedEmitter.event;
50
- }
51
- get onDidChangeSeverity(): Event<void> {
52
- return this.severityChangedEmitter.event;
53
- }
54
-
55
- protected readonly toDispose = new DisposableCollection();
56
- protected readonly toDisposeOnSessionDeletion = new Map<string, Disposable>();
57
-
58
- dispose(): void {
59
- this.toDispose.dispose();
60
- }
61
-
62
- get severity(): Severity | undefined {
63
- return this._severity;
64
- }
65
-
66
- set severity(value: Severity | undefined) {
67
- value = value || Severity.Ignore;
68
- this._severity = value;
69
- for (const session of this.sessions.values()) {
70
- session.severity = value;
71
- }
72
- this.severityChangedEmitter.fire(undefined);
73
- }
74
-
75
- get all(): ConsoleSession[] {
76
- return Array.from(this.sessions.values());
77
- }
78
-
79
- get selectedSession(): ConsoleSession | undefined {
80
- return this._selectedSession;
81
- }
82
-
83
- set selectedSession(session: ConsoleSession | undefined) {
84
- const oldSession = this.selectedSession;
85
- this._selectedSession = session;
86
- this.selectedSessionChangedEmitter.fire(session);
87
- if (oldSession !== session) {
88
- if (oldSession) {
89
- this.sessionWasHiddenEmitter.fire(oldSession);
90
- }
91
- if (session) {
92
- this.sessionWasShownEmitter.fire(session);
93
- }
94
- }
95
- }
96
-
97
- get(id: string): ConsoleSession | undefined {
98
- return this.sessions.get(id);
99
- }
100
-
101
- add(session: ConsoleSession): void {
102
- this.sessions.set(session.id, session);
103
- this.sessionAddedEmitter.fire(session);
104
- if (this.sessions.size === 1) {
105
- this.selectedSession = session;
106
- }
107
- }
108
-
109
- delete(id: string): void {
110
- const session = this.sessions.get(id);
111
- if (this.sessions.delete(id) && session) {
112
- if (this.selectedSession === session) {
113
- // select a new sessions or undefined if none are left
114
- this.selectedSession = this.sessions.values().next().value;
115
- }
116
- session.dispose();
117
- this.sessionDeletedEmitter.fire(session);
118
- }
119
- }
120
-
121
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2021 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 } from '@theia/core/shared/inversify';
18
+ import { Emitter, Event, Disposable, DisposableCollection } from '@theia/core';
19
+ import { ConsoleSession } from './console-session';
20
+ import { Severity } from '@theia/core/lib/common/severity';
21
+
22
+ @injectable()
23
+ export class ConsoleSessionManager implements Disposable {
24
+
25
+ protected readonly sessions = new Map<string, ConsoleSession>();
26
+ protected _selectedSession: ConsoleSession | undefined;
27
+ protected _severity: Severity | undefined;
28
+
29
+ protected readonly sessionAddedEmitter = new Emitter<ConsoleSession>();
30
+ protected readonly sessionDeletedEmitter = new Emitter<ConsoleSession>();
31
+ protected readonly sessionWasShownEmitter = new Emitter<ConsoleSession>();
32
+ protected readonly sessionWasHiddenEmitter = new Emitter<ConsoleSession>();
33
+ protected readonly selectedSessionChangedEmitter = new Emitter<ConsoleSession | undefined>();
34
+ protected readonly severityChangedEmitter = new Emitter<void>();
35
+
36
+ get onDidAddSession(): Event<ConsoleSession> {
37
+ return this.sessionAddedEmitter.event;
38
+ }
39
+ get onDidDeleteSession(): Event<ConsoleSession> {
40
+ return this.sessionDeletedEmitter.event;
41
+ }
42
+ get onDidShowSession(): Event<ConsoleSession> {
43
+ return this.sessionWasShownEmitter.event;
44
+ }
45
+ get onDidHideSession(): Event<ConsoleSession> {
46
+ return this.sessionWasHiddenEmitter.event;
47
+ }
48
+ get onDidChangeSelectedSession(): Event<ConsoleSession | undefined> {
49
+ return this.selectedSessionChangedEmitter.event;
50
+ }
51
+ get onDidChangeSeverity(): Event<void> {
52
+ return this.severityChangedEmitter.event;
53
+ }
54
+
55
+ protected readonly toDispose = new DisposableCollection();
56
+ protected readonly toDisposeOnSessionDeletion = new Map<string, Disposable>();
57
+
58
+ dispose(): void {
59
+ this.toDispose.dispose();
60
+ }
61
+
62
+ get severity(): Severity | undefined {
63
+ return this._severity;
64
+ }
65
+
66
+ set severity(value: Severity | undefined) {
67
+ value = value || Severity.Ignore;
68
+ this._severity = value;
69
+ for (const session of this.sessions.values()) {
70
+ session.severity = value;
71
+ }
72
+ this.severityChangedEmitter.fire(undefined);
73
+ }
74
+
75
+ get all(): ConsoleSession[] {
76
+ return Array.from(this.sessions.values());
77
+ }
78
+
79
+ get selectedSession(): ConsoleSession | undefined {
80
+ return this._selectedSession;
81
+ }
82
+
83
+ set selectedSession(session: ConsoleSession | undefined) {
84
+ const oldSession = this.selectedSession;
85
+ this._selectedSession = session;
86
+ this.selectedSessionChangedEmitter.fire(session);
87
+ if (oldSession !== session) {
88
+ if (oldSession) {
89
+ this.sessionWasHiddenEmitter.fire(oldSession);
90
+ }
91
+ if (session) {
92
+ this.sessionWasShownEmitter.fire(session);
93
+ }
94
+ }
95
+ }
96
+
97
+ get(id: string): ConsoleSession | undefined {
98
+ return this.sessions.get(id);
99
+ }
100
+
101
+ add(session: ConsoleSession): void {
102
+ this.sessions.set(session.id, session);
103
+ this.sessionAddedEmitter.fire(session);
104
+ if (this.sessions.size === 1) {
105
+ this.selectedSession = session;
106
+ }
107
+ }
108
+
109
+ delete(id: string): void {
110
+ const session = this.sessions.get(id);
111
+ if (this.sessions.delete(id) && session) {
112
+ if (this.selectedSession === session) {
113
+ // select a new sessions or undefined if none are left
114
+ this.selectedSession = this.sessions.values().next().value;
115
+ }
116
+ session.dispose();
117
+ this.sessionDeletedEmitter.fire(session);
118
+ }
119
+ }
120
+
121
+ }
@@ -1,61 +1,61 @@
1
- // *****************************************************************************
2
- // Copyright (C) 2018 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 } from '@theia/core/shared/inversify';
18
- import { MaybePromise } from '@theia/core/lib/common/types';
19
- import { TreeSource, TreeElement, CompositeTreeElement } from '@theia/core/lib/browser/source-tree';
20
- import { Emitter } from '@theia/core/lib/common/event';
21
- import { Severity } from '@theia/core/lib/common/severity';
22
-
23
- export interface ConsoleItem extends TreeElement {
24
- readonly severity?: Severity;
25
- }
26
- export namespace ConsoleItem {
27
- export const errorClassName = 'theia-console-error';
28
- export const warningClassName = 'theia-console-warning';
29
- export const infoClassName = 'theia-console-info';
30
- export const logClassName = 'theia-console-log';
31
- }
32
-
33
- export interface CompositeConsoleItem extends ConsoleItem, CompositeTreeElement {
34
- getElements(): MaybePromise<IterableIterator<ConsoleItem>>
35
- }
36
-
37
- @injectable()
38
- export abstract class ConsoleSession extends TreeSource {
39
- protected selectedSeverity?: Severity;
40
- protected readonly selectionEmitter: Emitter<void> = new Emitter<void>();
41
- readonly onSelectionChange = this.selectionEmitter.event;
42
- override id: string;
43
-
44
- get severity(): Severity | undefined {
45
- return this.selectedSeverity;
46
- }
47
-
48
- set severity(severity: Severity | undefined) {
49
- if (severity === this.selectedSeverity) {
50
- return;
51
- }
52
-
53
- this.selectedSeverity = severity;
54
- this.selectionEmitter.fire(undefined);
55
- this.fireDidChange();
56
- }
57
-
58
- abstract override getElements(): MaybePromise<IterableIterator<ConsoleItem>>;
59
- abstract execute(value: string): MaybePromise<void>;
60
- abstract clear(): MaybePromise<void>;
61
- }
1
+ // *****************************************************************************
2
+ // Copyright (C) 2018 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 } from '@theia/core/shared/inversify';
18
+ import { MaybePromise } from '@theia/core/lib/common/types';
19
+ import { TreeSource, TreeElement, CompositeTreeElement } from '@theia/core/lib/browser/source-tree';
20
+ import { Emitter } from '@theia/core/lib/common/event';
21
+ import { Severity } from '@theia/core/lib/common/severity';
22
+
23
+ export interface ConsoleItem extends TreeElement {
24
+ readonly severity?: Severity;
25
+ }
26
+ export namespace ConsoleItem {
27
+ export const errorClassName = 'theia-console-error';
28
+ export const warningClassName = 'theia-console-warning';
29
+ export const infoClassName = 'theia-console-info';
30
+ export const logClassName = 'theia-console-log';
31
+ }
32
+
33
+ export interface CompositeConsoleItem extends ConsoleItem, CompositeTreeElement {
34
+ getElements(): MaybePromise<IterableIterator<ConsoleItem>>
35
+ }
36
+
37
+ @injectable()
38
+ export abstract class ConsoleSession extends TreeSource {
39
+ protected selectedSeverity?: Severity;
40
+ protected readonly selectionEmitter: Emitter<void> = new Emitter<void>();
41
+ readonly onSelectionChange = this.selectionEmitter.event;
42
+ override id: string;
43
+
44
+ get severity(): Severity | undefined {
45
+ return this.selectedSeverity;
46
+ }
47
+
48
+ set severity(severity: Severity | undefined) {
49
+ if (severity === this.selectedSeverity) {
50
+ return;
51
+ }
52
+
53
+ this.selectedSeverity = severity;
54
+ this.selectionEmitter.fire(undefined);
55
+ this.fireDidChange();
56
+ }
57
+
58
+ abstract override getElements(): MaybePromise<IterableIterator<ConsoleItem>>;
59
+ abstract execute(value: string): MaybePromise<void>;
60
+ abstract clear(): MaybePromise<void>;
61
+ }