|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -import { ExtensionContext, window, workspace, commands, Uri, ProgressLocation, ViewColumn, EventEmitter, extensions, Location, languages, CodeActionKind, TextEditor, CancellationToken, ConfigurationTarget, Range, Position } from "vscode"; |
| 3 | +import { ExtensionContext, window, workspace, commands, Uri, ProgressLocation, ViewColumn, EventEmitter, extensions, Location, languages, CodeActionKind, TextEditor, CancellationToken, ConfigurationTarget, Range, Position, TypeHierarchyItem } from "vscode"; |
4 | 4 | import { Commands } from "./commands"; |
5 | 5 | import { serverStatus, ServerStatusKind } from "./serverStatus"; |
6 | 6 | import { prepareExecutable, awaitServerConnection } from "./javaServerStarter"; |
@@ -29,10 +29,11 @@ import * as fileEventHandler from './fileEventHandler'; |
29 | 29 | import { markdownPreviewProvider } from "./markdownPreviewProvider"; |
30 | 30 | import { RefactorDocumentProvider, javaRefactorKinds } from "./codeActionProvider"; |
31 | 31 | import { typeHierarchyTree } from "./typeHierarchy/typeHierarchyTree"; |
32 | | -import { TypeHierarchyDirection, TypeHierarchyItem } from "./typeHierarchy/protocol"; |
33 | 32 | import { buildFilePatterns } from './plugin'; |
34 | 33 | import { pomCodeActionMetadata, PomCodeActionProvider } from "./pom/pomCodeActionProvider"; |
35 | 34 | import { findRuntimes, IJavaRuntime } from "jdk-utils"; |
| 35 | +import { TypeHierarchyFeature } from "vscode-languageclient/lib/common/proposed.typeHierarchy"; |
| 36 | +import { TypeHierarchyDirection, TypeItem, TypesModel } from "./typeHierarchy/model.reference-view"; |
36 | 37 |
|
37 | 38 | const extensionName = 'Language Support for Java'; |
38 | 39 | const GRADLE_CHECKSUM = "gradle/checksum/prompt"; |
@@ -98,7 +99,7 @@ export class StandardLanguageClient { |
98 | 99 |
|
99 | 100 | // Create the language client and start the client. |
100 | 101 | this.languageClient = new LanguageClient('java', extensionName, serverOptions, clientOptions); |
101 | | - |
| 102 | + this.languageClient.registerFeature(new TypeHierarchyFeature(this.languageClient)); |
102 | 103 | this.languageClient.onReady().then(() => { |
103 | 104 | activationProgressNotification.showProgress(); |
104 | 105 | this.languageClient.onNotification(StatusNotification.type, (report) => { |
@@ -371,31 +372,27 @@ export class StandardLanguageClient { |
371 | 372 | } |
372 | 373 | })); |
373 | 374 |
|
374 | | - context.subscriptions.push(commands.registerCommand(Commands.SHOW_TYPE_HIERARCHY, (location: any) => { |
| 375 | + context.subscriptions.push(commands.registerCommand(Commands.SHOW_CLASS_HIERARCHY, (location: any) => { |
375 | 376 | if (location instanceof Uri) { |
376 | | - typeHierarchyTree.setTypeHierarchy(new Location(location, window.activeTextEditor.selection.active), TypeHierarchyDirection.Both); |
| 377 | + typeHierarchyTree.setTypeHierarchy(new Location(location, window.activeTextEditor.selection.active)); |
377 | 378 | } else { |
378 | 379 | if (window.activeTextEditor?.document?.languageId !== "java") { |
379 | 380 | return; |
380 | 381 | } |
381 | | - typeHierarchyTree.setTypeHierarchy(new Location(window.activeTextEditor.document.uri, window.activeTextEditor.selection.active), TypeHierarchyDirection.Both); |
| 382 | + typeHierarchyTree.setTypeHierarchy(new Location(window.activeTextEditor.document.uri, window.activeTextEditor.selection.active)); |
382 | 383 | } |
383 | 384 | })); |
384 | 385 |
|
385 | | - context.subscriptions.push(commands.registerCommand(Commands.SHOW_CLASS_HIERARCHY, () => { |
386 | | - typeHierarchyTree.changeDirection(TypeHierarchyDirection.Both); |
387 | | - })); |
388 | | - |
389 | 386 | context.subscriptions.push(commands.registerCommand(Commands.SHOW_SUPERTYPE_HIERARCHY, () => { |
390 | | - typeHierarchyTree.changeDirection(TypeHierarchyDirection.Parents); |
| 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); |
391 | 390 | })); |
392 | 391 |
|
393 | 392 | context.subscriptions.push(commands.registerCommand(Commands.SHOW_SUBTYPE_HIERARCHY, () => { |
394 | | - typeHierarchyTree.changeDirection(TypeHierarchyDirection.Children); |
395 | | - })); |
396 | | - |
397 | | - context.subscriptions.push(commands.registerCommand(Commands.CHANGE_BASE_TYPE, async (item: TypeHierarchyItem) => { |
398 | | - typeHierarchyTree.changeBaseItem(item); |
| 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); |
399 | 396 | })); |
400 | 397 |
|
401 | 398 | context.subscriptions.push(commands.registerCommand(Commands.COMPILE_WORKSPACE, (isFullCompile: boolean, token?: CancellationToken) => { |
|
0 commit comments