@theia/typehierarchy 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.
- package/README.md +30 -30
- package/package.json +4 -4
- package/src/browser/index.ts +20 -20
- package/src/browser/style/index.css +28 -28
- package/src/browser/tree/typehierarchy-tree-container.ts +35 -35
- package/src/browser/tree/typehierarchy-tree-model.ts +83 -83
- package/src/browser/tree/typehierarchy-tree-widget.tsx +108 -108
- package/src/browser/tree/typehierarchy-tree.ts +190 -190
- package/src/browser/typehierarchy-contribution.ts +175 -175
- package/src/browser/typehierarchy-frontend-module.ts +38 -38
- package/src/browser/typehierarchy-provider.ts +163 -163
- package/src/browser/typehierarchy-service.ts +89 -89
- package/src/browser/typehierarchy.ts +31 -31
- package/src/package.spec.ts +29 -29
package/README.md
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
<div align='center'>
|
|
2
|
-
|
|
3
|
-
<br />
|
|
4
|
-
|
|
5
|
-
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
-
|
|
7
|
-
<h2>ECLIPSE THEIA - TYPEHIERARCHY EXTENSION</h2>
|
|
8
|
-
|
|
9
|
-
<hr />
|
|
10
|
-
|
|
11
|
-
</div>
|
|
12
|
-
|
|
13
|
-
## Description
|
|
14
|
-
|
|
15
|
-
The `@theia/typehierarchy` extension includes support for `super` and `subtype` information for document symbols.
|
|
16
|
-
|
|
17
|
-
## Additional Information
|
|
18
|
-
|
|
19
|
-
- [API documentation for `@theia/typehierarchy`](https://eclipse-theia.github.io/theia/docs/next/modules/typehierarchy.html)
|
|
20
|
-
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
21
|
-
- [Theia - Website](https://theia-ide.org/)
|
|
22
|
-
|
|
23
|
-
## License
|
|
24
|
-
|
|
25
|
-
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
26
|
-
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
27
|
-
|
|
28
|
-
## Trademark
|
|
29
|
-
"Theia" is a trademark of the Eclipse Foundation
|
|
30
|
-
https://www.eclipse.org/theia
|
|
1
|
+
<div align='center'>
|
|
2
|
+
|
|
3
|
+
<br />
|
|
4
|
+
|
|
5
|
+
<img src='https://raw.githubusercontent.com/eclipse-theia/theia/master/logo/theia.svg?sanitize=true' alt='theia-ext-logo' width='100px' />
|
|
6
|
+
|
|
7
|
+
<h2>ECLIPSE THEIA - TYPEHIERARCHY EXTENSION</h2>
|
|
8
|
+
|
|
9
|
+
<hr />
|
|
10
|
+
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
## Description
|
|
14
|
+
|
|
15
|
+
The `@theia/typehierarchy` extension includes support for `super` and `subtype` information for document symbols.
|
|
16
|
+
|
|
17
|
+
## Additional Information
|
|
18
|
+
|
|
19
|
+
- [API documentation for `@theia/typehierarchy`](https://eclipse-theia.github.io/theia/docs/next/modules/typehierarchy.html)
|
|
20
|
+
- [Theia - GitHub](https://github.com/eclipse-theia/theia)
|
|
21
|
+
- [Theia - Website](https://theia-ide.org/)
|
|
22
|
+
|
|
23
|
+
## License
|
|
24
|
+
|
|
25
|
+
- [Eclipse Public License 2.0](http://www.eclipse.org/legal/epl-2.0/)
|
|
26
|
+
- [一 (Secondary) GNU General Public License, version 2 with the GNU Classpath Exception](https://projects.eclipse.org/license/secondary-gpl-2.0-cp)
|
|
27
|
+
|
|
28
|
+
## Trademark
|
|
29
|
+
"Theia" is a trademark of the Eclipse Foundation
|
|
30
|
+
https://www.eclipse.org/theia
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theia/typehierarchy",
|
|
3
|
-
"version": "1.53.0-next.
|
|
3
|
+
"version": "1.53.0-next.64+23b351d26",
|
|
4
4
|
"description": "Theia - Type Hierarchy Extension",
|
|
5
5
|
"dependencies": {
|
|
6
|
-
"@theia/core": "1.53.0-next.
|
|
7
|
-
"@theia/editor": "1.53.0-next.
|
|
6
|
+
"@theia/core": "1.53.0-next.64+23b351d26",
|
|
7
|
+
"@theia/editor": "1.53.0-next.64+23b351d26",
|
|
8
8
|
"tslib": "^2.6.2"
|
|
9
9
|
},
|
|
10
10
|
"publishConfig": {
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"nyc": {
|
|
46
46
|
"extends": "../../configs/nyc.json"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "23b351d26346a2b5d6aca3ee81fba59c056132f7"
|
|
49
49
|
}
|
package/src/browser/index.ts
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2022 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
|
-
export * from './typehierarchy';
|
|
18
|
-
export * from './typehierarchy-contribution';
|
|
19
|
-
export * from './typehierarchy-frontend-module';
|
|
20
|
-
export * from './typehierarchy-service';
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2022 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
|
+
export * from './typehierarchy';
|
|
18
|
+
export * from './typehierarchy-contribution';
|
|
19
|
+
export * from './typehierarchy-frontend-module';
|
|
20
|
+
export * from './typehierarchy-service';
|
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/********************************************************************************
|
|
2
|
-
* Copyright (C) 2019 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
|
-
.theia-type-hierarchy-tree {
|
|
18
|
-
font-size: var(--theia-ui-font-size0);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.theia-type-hierarchy-tree .theia-caption-suffix {
|
|
22
|
-
padding-left: 10px !important;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.theia-type-hierarchy-tree .theia-caption-prefix {
|
|
26
|
-
padding-right: 5px !important;
|
|
27
|
-
padding-left: 1px !important;
|
|
28
|
-
}
|
|
1
|
+
/********************************************************************************
|
|
2
|
+
* Copyright (C) 2019 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
|
+
.theia-type-hierarchy-tree {
|
|
18
|
+
font-size: var(--theia-ui-font-size0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.theia-type-hierarchy-tree .theia-caption-suffix {
|
|
22
|
+
padding-left: 10px !important;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.theia-type-hierarchy-tree .theia-caption-prefix {
|
|
26
|
+
padding-right: 5px !important;
|
|
27
|
+
padding-left: 1px !important;
|
|
28
|
+
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 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 { interfaces, Container } from '@theia/core/shared/inversify';
|
|
18
|
-
import { createTreeContainer, } from '@theia/core/lib/browser/tree';
|
|
19
|
-
import { TypeHierarchyTree } from './typehierarchy-tree';
|
|
20
|
-
import { TypeHierarchyTreeModel } from './typehierarchy-tree-model';
|
|
21
|
-
import { TypeHierarchyTreeWidget } from './typehierarchy-tree-widget';
|
|
22
|
-
|
|
23
|
-
function createHierarchyTreeContainer(parent: interfaces.Container): Container {
|
|
24
|
-
const child = createTreeContainer(parent, {
|
|
25
|
-
tree: TypeHierarchyTree,
|
|
26
|
-
model: TypeHierarchyTreeModel,
|
|
27
|
-
widget: TypeHierarchyTreeWidget
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
return child;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function createHierarchyTreeWidget(parent: interfaces.Container): TypeHierarchyTreeWidget {
|
|
34
|
-
return createHierarchyTreeContainer(parent).get(TypeHierarchyTreeWidget);
|
|
35
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 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 { interfaces, Container } from '@theia/core/shared/inversify';
|
|
18
|
+
import { createTreeContainer, } from '@theia/core/lib/browser/tree';
|
|
19
|
+
import { TypeHierarchyTree } from './typehierarchy-tree';
|
|
20
|
+
import { TypeHierarchyTreeModel } from './typehierarchy-tree-model';
|
|
21
|
+
import { TypeHierarchyTreeWidget } from './typehierarchy-tree-widget';
|
|
22
|
+
|
|
23
|
+
function createHierarchyTreeContainer(parent: interfaces.Container): Container {
|
|
24
|
+
const child = createTreeContainer(parent, {
|
|
25
|
+
tree: TypeHierarchyTree,
|
|
26
|
+
model: TypeHierarchyTreeModel,
|
|
27
|
+
widget: TypeHierarchyTreeWidget
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
return child;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function createHierarchyTreeWidget(parent: interfaces.Container): TypeHierarchyTreeWidget {
|
|
34
|
+
return createHierarchyTreeContainer(parent).get(TypeHierarchyTreeWidget);
|
|
35
|
+
}
|
|
@@ -1,83 +1,83 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 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 { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
-
import { TreeNode } from '@theia/core/lib/browser/tree/tree';
|
|
19
|
-
import { TreeModelImpl } from '@theia/core/lib/browser/tree/tree-model';
|
|
20
|
-
import { TypeHierarchyRegistry, TypeHierarchyDirection, TypeHierarchyParams } from '../typehierarchy-provider';
|
|
21
|
-
import { TypeHierarchyTree } from './typehierarchy-tree';
|
|
22
|
-
|
|
23
|
-
@injectable()
|
|
24
|
-
export class TypeHierarchyTreeModel extends TreeModelImpl {
|
|
25
|
-
|
|
26
|
-
@inject(TypeHierarchyRegistry)
|
|
27
|
-
protected readonly registry: TypeHierarchyRegistry;
|
|
28
|
-
|
|
29
|
-
protected override doOpenNode(node: TreeNode): void {
|
|
30
|
-
// do nothing (in particular do not expand the node)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* Initializes the tree by calculating and setting a new tree root node.
|
|
35
|
-
*/
|
|
36
|
-
async initialize(options: TypeHierarchyTree.InitOptions): Promise<void> {
|
|
37
|
-
this.tree.root = undefined;
|
|
38
|
-
(this.tree as TypeHierarchyTree).provider = undefined;
|
|
39
|
-
const { location, languageId, direction } = options;
|
|
40
|
-
if (languageId && location) {
|
|
41
|
-
const provider = await this.registry.get(languageId);
|
|
42
|
-
if (provider) {
|
|
43
|
-
const params: TypeHierarchyParams = {
|
|
44
|
-
textDocument: {
|
|
45
|
-
uri: location.uri
|
|
46
|
-
},
|
|
47
|
-
position: location.range.start,
|
|
48
|
-
direction,
|
|
49
|
-
resolve: 1
|
|
50
|
-
};
|
|
51
|
-
const symbol = await provider.get(params);
|
|
52
|
-
if (symbol) {
|
|
53
|
-
const root = TypeHierarchyTree.RootNode.create(symbol, direction);
|
|
54
|
-
root.expanded = true;
|
|
55
|
-
this.tree.root = root;
|
|
56
|
-
(this.tree as TypeHierarchyTree).provider = provider;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
/**
|
|
63
|
-
* If the tree root is set, it resets it with the inverse type hierarchy direction.
|
|
64
|
-
*/
|
|
65
|
-
async flipDirection(): Promise<void> {
|
|
66
|
-
const { root } = this.tree;
|
|
67
|
-
const service = (this.tree as TypeHierarchyTree).provider;
|
|
68
|
-
if (TypeHierarchyTree.RootNode.is(root) && !!service) {
|
|
69
|
-
const { direction, item } = root;
|
|
70
|
-
const { uri, selectionRange } = item;
|
|
71
|
-
const location = {
|
|
72
|
-
uri,
|
|
73
|
-
range: selectionRange
|
|
74
|
-
};
|
|
75
|
-
this.initialize({
|
|
76
|
-
direction: direction === TypeHierarchyDirection.Children ? TypeHierarchyDirection.Parents : TypeHierarchyDirection.Children,
|
|
77
|
-
location,
|
|
78
|
-
languageId: service.languageId
|
|
79
|
-
});
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 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 { inject, injectable } from '@theia/core/shared/inversify';
|
|
18
|
+
import { TreeNode } from '@theia/core/lib/browser/tree/tree';
|
|
19
|
+
import { TreeModelImpl } from '@theia/core/lib/browser/tree/tree-model';
|
|
20
|
+
import { TypeHierarchyRegistry, TypeHierarchyDirection, TypeHierarchyParams } from '../typehierarchy-provider';
|
|
21
|
+
import { TypeHierarchyTree } from './typehierarchy-tree';
|
|
22
|
+
|
|
23
|
+
@injectable()
|
|
24
|
+
export class TypeHierarchyTreeModel extends TreeModelImpl {
|
|
25
|
+
|
|
26
|
+
@inject(TypeHierarchyRegistry)
|
|
27
|
+
protected readonly registry: TypeHierarchyRegistry;
|
|
28
|
+
|
|
29
|
+
protected override doOpenNode(node: TreeNode): void {
|
|
30
|
+
// do nothing (in particular do not expand the node)
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Initializes the tree by calculating and setting a new tree root node.
|
|
35
|
+
*/
|
|
36
|
+
async initialize(options: TypeHierarchyTree.InitOptions): Promise<void> {
|
|
37
|
+
this.tree.root = undefined;
|
|
38
|
+
(this.tree as TypeHierarchyTree).provider = undefined;
|
|
39
|
+
const { location, languageId, direction } = options;
|
|
40
|
+
if (languageId && location) {
|
|
41
|
+
const provider = await this.registry.get(languageId);
|
|
42
|
+
if (provider) {
|
|
43
|
+
const params: TypeHierarchyParams = {
|
|
44
|
+
textDocument: {
|
|
45
|
+
uri: location.uri
|
|
46
|
+
},
|
|
47
|
+
position: location.range.start,
|
|
48
|
+
direction,
|
|
49
|
+
resolve: 1
|
|
50
|
+
};
|
|
51
|
+
const symbol = await provider.get(params);
|
|
52
|
+
if (symbol) {
|
|
53
|
+
const root = TypeHierarchyTree.RootNode.create(symbol, direction);
|
|
54
|
+
root.expanded = true;
|
|
55
|
+
this.tree.root = root;
|
|
56
|
+
(this.tree as TypeHierarchyTree).provider = provider;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* If the tree root is set, it resets it with the inverse type hierarchy direction.
|
|
64
|
+
*/
|
|
65
|
+
async flipDirection(): Promise<void> {
|
|
66
|
+
const { root } = this.tree;
|
|
67
|
+
const service = (this.tree as TypeHierarchyTree).provider;
|
|
68
|
+
if (TypeHierarchyTree.RootNode.is(root) && !!service) {
|
|
69
|
+
const { direction, item } = root;
|
|
70
|
+
const { uri, selectionRange } = item;
|
|
71
|
+
const location = {
|
|
72
|
+
uri,
|
|
73
|
+
range: selectionRange
|
|
74
|
+
};
|
|
75
|
+
this.initialize({
|
|
76
|
+
direction: direction === TypeHierarchyDirection.Children ? TypeHierarchyDirection.Parents : TypeHierarchyDirection.Children,
|
|
77
|
+
location,
|
|
78
|
+
languageId: service.languageId
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
}
|
|
@@ -1,108 +1,108 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2019 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 * as React from '@theia/core/shared/react';
|
|
18
|
-
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
|
-
import { DockPanel } from '@theia/core/shared/@phosphor/widgets';
|
|
20
|
-
import URI from '@theia/core/lib/common/uri';
|
|
21
|
-
import { SymbolKind, Range } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
22
|
-
import { TreeNode } from '@theia/core/lib/browser/tree/tree';
|
|
23
|
-
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
24
|
-
import { ContextMenuRenderer } from '@theia/core/lib/browser/context-menu-renderer';
|
|
25
|
-
import { TreeWidget, TreeProps } from '@theia/core/lib/browser/tree/tree-widget';
|
|
26
|
-
import { TypeHierarchyTreeModel } from './typehierarchy-tree-model';
|
|
27
|
-
import { TypeHierarchyTree } from './typehierarchy-tree';
|
|
28
|
-
import { codicon } from '@theia/core/lib/browser';
|
|
29
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
30
|
-
|
|
31
|
-
@injectable()
|
|
32
|
-
export class TypeHierarchyTreeWidget extends TreeWidget {
|
|
33
|
-
|
|
34
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
-
protected readonly icons = new Map(Array.from(Object.keys(SymbolKind)).map(key => [(SymbolKind as any)[key], key.toLocaleLowerCase()] as [number, string]));
|
|
36
|
-
|
|
37
|
-
@inject(EditorManager) readonly editorManager: EditorManager;
|
|
38
|
-
|
|
39
|
-
constructor(
|
|
40
|
-
@inject(TreeProps) props: TreeProps,
|
|
41
|
-
@inject(TypeHierarchyTreeModel) override readonly model: TypeHierarchyTreeModel,
|
|
42
|
-
@inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer
|
|
43
|
-
) {
|
|
44
|
-
super(props, model, contextMenuRenderer);
|
|
45
|
-
this.id = TypeHierarchyTreeWidget.WIDGET_ID;
|
|
46
|
-
this.title.label = TypeHierarchyTreeWidget.WIDGET_LABEL;
|
|
47
|
-
this.title.caption = TypeHierarchyTreeWidget.WIDGET_LABEL;
|
|
48
|
-
this.addClass(TypeHierarchyTreeWidget.Styles.TYPE_HIERARCHY_TREE_CLASS);
|
|
49
|
-
this.title.closable = true;
|
|
50
|
-
this.title.iconClass = codicon('type-hierarchy');
|
|
51
|
-
this.toDispose.push(this.model.onSelectionChanged(selection => {
|
|
52
|
-
const node = selection[0];
|
|
53
|
-
if (node) {
|
|
54
|
-
this.openEditor(node, true);
|
|
55
|
-
}
|
|
56
|
-
}));
|
|
57
|
-
this.toDispose.push(this.model.onOpenNode(node => this.openEditor(node)));
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Initializes the widget with the new input.
|
|
62
|
-
*/
|
|
63
|
-
async initialize(options: TypeHierarchyTree.InitOptions): Promise<void> {
|
|
64
|
-
await this.model.initialize(options);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* See: `TreeWidget#renderIcon`.
|
|
69
|
-
*/
|
|
70
|
-
protected override renderIcon(node: TreeNode): React.ReactNode {
|
|
71
|
-
if (TypeHierarchyTree.Node.is(node)) {
|
|
72
|
-
return <div className={'symbol-icon-center codicon codicon-symbol-' + this.icons.get(node.item.kind) || 'unknown'}></div>;
|
|
73
|
-
}
|
|
74
|
-
return undefined;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Opens up the node in the editor. On demand (`keepFocus`) it reveals the location in the editor.
|
|
79
|
-
*/
|
|
80
|
-
protected async openEditor(node: TreeNode, keepFocus: boolean = false): Promise<void> {
|
|
81
|
-
if (TypeHierarchyTree.Node.is(node)) {
|
|
82
|
-
const { selectionRange, uri } = node.item;
|
|
83
|
-
const editorWidget = await this.editorManager.open(new URI(uri), {
|
|
84
|
-
mode: keepFocus ? 'reveal' : 'activate',
|
|
85
|
-
selection: Range.create(selectionRange.start, selectionRange.end)
|
|
86
|
-
});
|
|
87
|
-
if (editorWidget.parent instanceof DockPanel) {
|
|
88
|
-
editorWidget.parent.selectWidget(editorWidget);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
export namespace TypeHierarchyTreeWidget {
|
|
96
|
-
|
|
97
|
-
export const WIDGET_ID = 'theia-typehierarchy';
|
|
98
|
-
export const WIDGET_LABEL = nls.localizeByDefault('Type Hierarchy');
|
|
99
|
-
|
|
100
|
-
/**
|
|
101
|
-
* CSS styles for the `Type Hierarchy` widget.
|
|
102
|
-
*/
|
|
103
|
-
export namespace Styles {
|
|
104
|
-
|
|
105
|
-
export const TYPE_HIERARCHY_TREE_CLASS = 'theia-type-hierarchy-tree';
|
|
106
|
-
|
|
107
|
-
}
|
|
108
|
-
}
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2019 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 * as React from '@theia/core/shared/react';
|
|
18
|
+
import { inject, injectable } from '@theia/core/shared/inversify';
|
|
19
|
+
import { DockPanel } from '@theia/core/shared/@phosphor/widgets';
|
|
20
|
+
import URI from '@theia/core/lib/common/uri';
|
|
21
|
+
import { SymbolKind, Range } from '@theia/core/shared/vscode-languageserver-protocol';
|
|
22
|
+
import { TreeNode } from '@theia/core/lib/browser/tree/tree';
|
|
23
|
+
import { EditorManager } from '@theia/editor/lib/browser/editor-manager';
|
|
24
|
+
import { ContextMenuRenderer } from '@theia/core/lib/browser/context-menu-renderer';
|
|
25
|
+
import { TreeWidget, TreeProps } from '@theia/core/lib/browser/tree/tree-widget';
|
|
26
|
+
import { TypeHierarchyTreeModel } from './typehierarchy-tree-model';
|
|
27
|
+
import { TypeHierarchyTree } from './typehierarchy-tree';
|
|
28
|
+
import { codicon } from '@theia/core/lib/browser';
|
|
29
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
30
|
+
|
|
31
|
+
@injectable()
|
|
32
|
+
export class TypeHierarchyTreeWidget extends TreeWidget {
|
|
33
|
+
|
|
34
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
35
|
+
protected readonly icons = new Map(Array.from(Object.keys(SymbolKind)).map(key => [(SymbolKind as any)[key], key.toLocaleLowerCase()] as [number, string]));
|
|
36
|
+
|
|
37
|
+
@inject(EditorManager) readonly editorManager: EditorManager;
|
|
38
|
+
|
|
39
|
+
constructor(
|
|
40
|
+
@inject(TreeProps) props: TreeProps,
|
|
41
|
+
@inject(TypeHierarchyTreeModel) override readonly model: TypeHierarchyTreeModel,
|
|
42
|
+
@inject(ContextMenuRenderer) contextMenuRenderer: ContextMenuRenderer
|
|
43
|
+
) {
|
|
44
|
+
super(props, model, contextMenuRenderer);
|
|
45
|
+
this.id = TypeHierarchyTreeWidget.WIDGET_ID;
|
|
46
|
+
this.title.label = TypeHierarchyTreeWidget.WIDGET_LABEL;
|
|
47
|
+
this.title.caption = TypeHierarchyTreeWidget.WIDGET_LABEL;
|
|
48
|
+
this.addClass(TypeHierarchyTreeWidget.Styles.TYPE_HIERARCHY_TREE_CLASS);
|
|
49
|
+
this.title.closable = true;
|
|
50
|
+
this.title.iconClass = codicon('type-hierarchy');
|
|
51
|
+
this.toDispose.push(this.model.onSelectionChanged(selection => {
|
|
52
|
+
const node = selection[0];
|
|
53
|
+
if (node) {
|
|
54
|
+
this.openEditor(node, true);
|
|
55
|
+
}
|
|
56
|
+
}));
|
|
57
|
+
this.toDispose.push(this.model.onOpenNode(node => this.openEditor(node)));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Initializes the widget with the new input.
|
|
62
|
+
*/
|
|
63
|
+
async initialize(options: TypeHierarchyTree.InitOptions): Promise<void> {
|
|
64
|
+
await this.model.initialize(options);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* See: `TreeWidget#renderIcon`.
|
|
69
|
+
*/
|
|
70
|
+
protected override renderIcon(node: TreeNode): React.ReactNode {
|
|
71
|
+
if (TypeHierarchyTree.Node.is(node)) {
|
|
72
|
+
return <div className={'symbol-icon-center codicon codicon-symbol-' + this.icons.get(node.item.kind) || 'unknown'}></div>;
|
|
73
|
+
}
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Opens up the node in the editor. On demand (`keepFocus`) it reveals the location in the editor.
|
|
79
|
+
*/
|
|
80
|
+
protected async openEditor(node: TreeNode, keepFocus: boolean = false): Promise<void> {
|
|
81
|
+
if (TypeHierarchyTree.Node.is(node)) {
|
|
82
|
+
const { selectionRange, uri } = node.item;
|
|
83
|
+
const editorWidget = await this.editorManager.open(new URI(uri), {
|
|
84
|
+
mode: keepFocus ? 'reveal' : 'activate',
|
|
85
|
+
selection: Range.create(selectionRange.start, selectionRange.end)
|
|
86
|
+
});
|
|
87
|
+
if (editorWidget.parent instanceof DockPanel) {
|
|
88
|
+
editorWidget.parent.selectWidget(editorWidget);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export namespace TypeHierarchyTreeWidget {
|
|
96
|
+
|
|
97
|
+
export const WIDGET_ID = 'theia-typehierarchy';
|
|
98
|
+
export const WIDGET_LABEL = nls.localizeByDefault('Type Hierarchy');
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* CSS styles for the `Type Hierarchy` widget.
|
|
102
|
+
*/
|
|
103
|
+
export namespace Styles {
|
|
104
|
+
|
|
105
|
+
export const TYPE_HIERARCHY_TREE_CLASS = 'theia-type-hierarchy-tree';
|
|
106
|
+
|
|
107
|
+
}
|
|
108
|
+
}
|