Skip to content

Commit

Permalink
remove supertype and subtype switch
Browse files Browse the repository at this point in the history
Signed-off-by: Shi Chen <[email protected]>
  • Loading branch information
CsCherrYY committed Mar 25, 2022
1 parent 67c9794 commit a6de45d
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 278 deletions.
35 changes: 7 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -948,15 +948,8 @@
"category": "Java"
},
{
"command": "java.action.showSupertypeHierarchy",
"title": "%java.action.showSupertypeHierarchy%",
"icon": "$(type-hierarchy-super)",
"category": "Java"
},
{
"command": "java.action.showSubtypeHierarchy",
"title": "%java.action.showSubtypeHierarchy%",
"icon": "$(type-hierarchy-sub)",
"command": "java.action.changeBaseType",
"title": "%java.action.changeBaseType%",
"category": "Java"
}
],
Expand Down Expand Up @@ -1043,11 +1036,7 @@
"when": "javaLSReady && editorIsOpen"
},
{
"command": "java.action.showSubtypeHierarchy",
"when": "false"
},
{
"command": "java.action.showSupertypeHierarchy",
"command": "java.action.changeBaseType",
"when": "false"
},
{
Expand All @@ -1071,21 +1060,11 @@
"when": "java:serverMode == LightWeight"
}
],
"view/title": [
{
"command": "java.action.showClassHierarchy",
"group": "navigation@-1",
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == typeHierarchy && typeHierarchySymbolKind != 10"
},
{
"command": "java.action.showSupertypeHierarchy",
"group": "navigation@0",
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == javaTypeHierarchy"
},
"view/item/context": [
{
"command": "java.action.showSubtypeHierarchy",
"group": "navigation@1",
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == javaTypeHierarchy"
"command": "java.action.changeBaseType",
"group": "1",
"when": "view == references-view.tree && reference-list.hasResult && reference-list.source == javaTypeHierarchy && viewItem != 'false'"
}
]
}
Expand Down
2 changes: 0 additions & 2 deletions package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@
"java.show.server.task.status": "Show Build Job Status",
"java.action.navigateToSuperImplementation": "Go to Super Implementation",
"java.action.showClassHierarchy": "Show Class Hierarchy",
"java.action.showSupertypeHierarchy": "Show Supertype Hierarchy",
"java.action.showSubtypeHierarchy": "Show Subtype Hierarchy",
"java.action.changeBaseType": "Base on this Type"
}
2 changes: 0 additions & 2 deletions package.nls.zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,5 @@
"java.show.server.task.status": "显示工作状态",
"java.action.navigateToSuperImplementation": "转到父类实现",
"java.action.showClassHierarchy": "显示类的继承关系",
"java.action.showSupertypeHierarchy": "显示父类层次结构",
"java.action.showSubtypeHierarchy": "显示子类层次结构",
"java.action.changeBaseType": "基于此类型"
}
12 changes: 4 additions & 8 deletions src/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -192,18 +192,14 @@ export namespace Commands {
* Navigate To Super Method Command.
*/
export const NAVIGATE_TO_SUPER_IMPLEMENTATION_COMMAND = 'java.action.navigateToSuperImplementation';
/**
* Show SuperType Hierarchy of given Selection.
*/
export const SHOW_SUPERTYPE_HIERARCHY = 'java.action.showSupertypeHierarchy';
/**
* Show SubType Hierarchy of given Selection.
*/
export const SHOW_SUBTYPE_HIERARCHY = 'java.action.showSubtypeHierarchy';
/**
* Show Class Hierarchy of given Selection.
*/
export const SHOW_CLASS_HIERARCHY = 'java.action.showClassHierarchy';
/**
* Change the base type of Type Hierarchy.
*/
export const CHANGE_BASE_TYPE = 'java.action.changeBaseType';
/**
* Show server task status
*/
Expand Down
16 changes: 4 additions & 12 deletions src/standardLanguageClient.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use strict';

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

const extensionName = 'Language Support for Java';
const GRADLE_CHECKSUM = "gradle/checksum/prompt";
Expand Down Expand Up @@ -383,16 +383,8 @@ export class StandardLanguageClient {
}
}));

context.subscriptions.push(commands.registerCommand(Commands.SHOW_SUPERTYPE_HIERARCHY, () => {
const typesModel: TypesModel = new TypesModel(TypeHierarchyDirection.Supertypes, [typeHierarchyTree.currentItem]);
const typeItem: TypeItem = new TypeItem(typesModel, typeHierarchyTree.currentItem, undefined);
commands.executeCommand("references-view.showSupertypes", typeItem);
}));

context.subscriptions.push(commands.registerCommand(Commands.SHOW_SUBTYPE_HIERARCHY, () => {
const typesModel: TypesModel = new TypesModel(TypeHierarchyDirection.Subtypes, [typeHierarchyTree.currentItem]);
const typeItem: TypeItem = new TypeItem(typesModel, typeHierarchyTree.currentItem, undefined);
commands.executeCommand("references-view.showSubtypes", typeItem);
context.subscriptions.push(commands.registerCommand(Commands.CHANGE_BASE_TYPE, async (item: CodeTypeHierarchyItem) => {
typeHierarchyTree.changeBaseItem(item);
}));

context.subscriptions.push(commands.registerCommand(Commands.COMPILE_WORKSPACE, (isFullCompile: boolean, token?: CancellationToken) => {
Expand Down
214 changes: 0 additions & 214 deletions src/typeHierarchy/model.reference-view.ts

This file was deleted.

6 changes: 2 additions & 4 deletions src/typeHierarchy/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class TypeHierarchyTreeDataProvider implements vscode.TreeDataProvider<CodeTypeH
return undefined;
}
const treeItem: vscode.TreeItem = (element === this.model.getBaseItem()) ? new vscode.TreeItem({ label: element.name, highlights: [[0, element.name.length]] }) : new vscode.TreeItem(element.name);
treeItem.contextValue = (element === this.model.getBaseItem() || !element.uri) ? "false" : "true";
treeItem.contextValue = (element === this.model.getBaseItem() || !element.uri || element.kind === vscode.SymbolKind.Interface) ? "false" : "true";
treeItem.description = element.detail;
treeItem.iconPath = TypeHierarchyTreeDataProvider.getThemeIcon(element.kind);
treeItem.command = (element.uri) ? {
Expand All @@ -119,10 +119,8 @@ class TypeHierarchyTreeDataProvider implements vscode.TreeDataProvider<CodeTypeH
if (element.children) {
return element.children;
}
const lspItem = this.client.code2ProtocolConverter.asTypeHierarchyItem(element);
lspItem.data = element.data;
const params: Proposed.TypeHierarchySubtypesParams = {
item: lspItem,
item: this.client.code2ProtocolConverter.asTypeHierarchyItem(element),
};
const children = await this.client.sendRequest(Proposed.TypeHierarchySubtypesRequest.type, params, this.token);
const childrenCodeItems = [];
Expand Down
Loading

0 comments on commit a6de45d

Please sign in to comment.