Skip to content

Commit a6de45d

Browse files
committed
remove supertype and subtype switch
Signed-off-by: Shi Chen <chenshi@microsoft.com>
1 parent 67c9794 commit a6de45d

10 files changed

+36
-278
lines changed

package.json

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -948,15 +948,8 @@
948948
"category": "Java"
949949
},
950950
{
951-
"command": "java.action.showSupertypeHierarchy",
952-
"title": "%java.action.showSupertypeHierarchy%",
953-
"icon": "$(type-hierarchy-super)",
954-
"category": "Java"
955-
},
956-
{
957-
"command": "java.action.showSubtypeHierarchy",
958-
"title": "%java.action.showSubtypeHierarchy%",
959-
"icon": "$(type-hierarchy-sub)",
951+
"command": "java.action.changeBaseType",
952+
"title": "%java.action.changeBaseType%",
960953
"category": "Java"
961954
}
962955
],
@@ -1043,11 +1036,7 @@
10431036
"when": "javaLSReady && editorIsOpen"
10441037
},
10451038
{
1046-
"command": "java.action.showSubtypeHierarchy",
1047-
"when": "false"
1048-
},
1049-
{
1050-
"command": "java.action.showSupertypeHierarchy",
1039+
"command": "java.action.changeBaseType",
10511040
"when": "false"
10521041
},
10531042
{
@@ -1071,21 +1060,11 @@
10711060
"when": "java:serverMode == LightWeight"
10721061
}
10731062
],
1074-
"view/title": [
1075-
{
1076-
"command": "java.action.showClassHierarchy",
1077-
"group": "navigation@-1",
1078-
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == typeHierarchy && typeHierarchySymbolKind != 10"
1079-
},
1080-
{
1081-
"command": "java.action.showSupertypeHierarchy",
1082-
"group": "navigation@0",
1083-
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == javaTypeHierarchy"
1084-
},
1063+
"view/item/context": [
10851064
{
1086-
"command": "java.action.showSubtypeHierarchy",
1087-
"group": "navigation@1",
1088-
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == javaTypeHierarchy"
1065+
"command": "java.action.changeBaseType",
1066+
"group": "1",
1067+
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == javaTypeHierarchy && viewItem != 'false'"
10891068
}
10901069
]
10911070
}

package.nls.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@
1515
"java.show.server.task.status": "Show Build Job Status",
1616
"java.action.navigateToSuperImplementation": "Go to Super Implementation",
1717
"java.action.showClassHierarchy": "Show Class Hierarchy",
18-
"java.action.showSupertypeHierarchy": "Show Supertype Hierarchy",
19-
"java.action.showSubtypeHierarchy": "Show Subtype Hierarchy",
2018
"java.action.changeBaseType": "Base on this Type"
2119
}

package.nls.zh.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,5 @@
1515
"java.show.server.task.status": "显示工作状态",
1616
"java.action.navigateToSuperImplementation": "转到父类实现",
1717
"java.action.showClassHierarchy": "显示类的继承关系",
18-
"java.action.showSupertypeHierarchy": "显示父类层次结构",
19-
"java.action.showSubtypeHierarchy": "显示子类层次结构",
2018
"java.action.changeBaseType": "基于此类型"
2119
}

src/commands.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -192,18 +192,14 @@ export namespace Commands {
192192
* Navigate To Super Method Command.
193193
*/
194194
export const NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND = 'java.action.navigateToSuperImplementation';
195-
/**
196-
* Show SuperType Hierarchy of given Selection.
197-
*/
198-
export const SHOW_SUPERTYPE_HIERARCHY = 'java.action.showSupertypeHierarchy';
199-
/**
200-
* Show SubType Hierarchy of given Selection.
201-
*/
202-
export const SHOW_SUBTYPE_HIERARCHY = 'java.action.showSubtypeHierarchy';
203195
/**
204196
* Show Class Hierarchy of given Selection.
205197
*/
206198
export const SHOW_CLASS_HIERARCHY = 'java.action.showClassHierarchy';
199+
/**
200+
* Change the base type of Type Hierarchy.
201+
*/
202+
export const CHANGE_BASE_TYPE = 'java.action.changeBaseType';
207203
/**
208204
* Show server task status
209205
*/

src/standardLanguageClient.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict';
22

3-
import { ExtensionContext, window, workspace, commands, Uri, ProgressLocation, ViewColumn, EventEmitter, extensions, Location, languages, CodeActionKind, TextEditor, CancellationToken, ConfigurationTarget, Range, Position, TypeHierarchyItem } from "vscode";
3+
import { ExtensionContext, window, workspace, commands, Uri, ProgressLocation, ViewColumn, EventEmitter, extensions, Location, languages, CodeActionKind, TextEditor, CancellationToken, ConfigurationTarget, Range, Position } from "vscode";
44
import { Commands } from "./commands";
55
import { serverStatus, ServerStatusKind } from "./serverStatus";
66
import { prepareExecutable, awaitServerConnection } from "./javaServerStarter";
@@ -33,7 +33,7 @@ import { buildFilePatterns } from './plugin';
3333
import { pomCodeActionMetadata, PomCodeActionProvider } from "./pom/pomCodeActionProvider";
3434
import { findRuntimes, IJavaRuntime } from "jdk-utils";
3535
import { TypeHierarchyFeature } from "vscode-languageclient/lib/common/proposed.typeHierarchy";
36-
import { TypeHierarchyDirection, TypeItem, TypesModel } from "./typeHierarchy/model.reference-view";
36+
import { CodeTypeHierarchyItem } from "./typeHierarchy/protocol";
3737

3838
const extensionName = 'Language Support for Java';
3939
const GRADLE_CHECKSUM = "gradle/checksum/prompt";
@@ -383,16 +383,8 @@ export class StandardLanguageClient {
383383
}
384384
}));
385385

386-
context.subscriptions.push(commands.registerCommand(Commands.SHOW_SUPERTYPE_HIERARCHY, () => {
387-
const typesModel: TypesModel = new TypesModel(TypeHierarchyDirection.Supertypes, [typeHierarchyTree.currentItem]);
388-
const typeItem: TypeItem = new TypeItem(typesModel, typeHierarchyTree.currentItem, undefined);
389-
commands.executeCommand("references-view.showSupertypes", typeItem);
390-
}));
391-
392-
context.subscriptions.push(commands.registerCommand(Commands.SHOW_SUBTYPE_HIERARCHY, () => {
393-
const typesModel: TypesModel = new TypesModel(TypeHierarchyDirection.Subtypes, [typeHierarchyTree.currentItem]);
394-
const typeItem: TypeItem = new TypeItem(typesModel, typeHierarchyTree.currentItem, undefined);
395-
commands.executeCommand("references-view.showSubtypes", typeItem);
386+
context.subscriptions.push(commands.registerCommand(Commands.CHANGE_BASE_TYPE, async (item: CodeTypeHierarchyItem) => {
387+
typeHierarchyTree.changeBaseItem(item);
396388
}));
397389

398390
context.subscriptions.push(commands.registerCommand(Commands.COMPILE_WORKSPACE, (isFullCompile: boolean, token?: CancellationToken) => {

src/typeHierarchy/model.reference-view.ts

Lines changed: 0 additions & 214 deletions
This file was deleted.

src/typeHierarchy/model.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ class TypeHierarchyTreeDataProvider implements vscode.TreeDataProvider<CodeTypeH
9292
return undefined;
9393
}
9494
const treeItem: vscode.TreeItem = (element === this.model.getBaseItem()) ? new vscode.TreeItem({ label: element.name, highlights: [[0, element.name.length]] }) : new vscode.TreeItem(element.name);
95-
treeItem.contextValue = (element === this.model.getBaseItem() || !element.uri) ? "false" : "true";
95+
treeItem.contextValue = (element === this.model.getBaseItem() || !element.uri || element.kind === vscode.SymbolKind.Interface) ? "false" : "true";
9696
treeItem.description = element.detail;
9797
treeItem.iconPath = TypeHierarchyTreeDataProvider.getThemeIcon(element.kind);
9898
treeItem.command = (element.uri) ? {
@@ -119,10 +119,8 @@ class TypeHierarchyTreeDataProvider implements vscode.TreeDataProvider<CodeTypeH
119119
if (element.children) {
120120
return element.children;
121121
}
122-
const lspItem = this.client.code2ProtocolConverter.asTypeHierarchyItem(element);
123-
lspItem.data = element.data;
124122
const params: Proposed.TypeHierarchySubtypesParams = {
125-
item: lspItem,
123+
item: this.client.code2ProtocolConverter.asTypeHierarchyItem(element),
126124
};
127125
const children = await this.client.sendRequest(Proposed.TypeHierarchySubtypesRequest.type, params, this.token);
128126
const childrenCodeItems = [];

0 commit comments

Comments
 (0)