-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added getDocumentSymbols call to extension API (#1151)
Signed-off-by: Ondřej Musil <[email protected]>
- Loading branch information
Showing
4 changed files
with
47 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
'use strict'; | ||
|
||
import { | ||
CancellationToken, | ||
DocumentSymbol, | ||
DocumentSymbolParams, | ||
DocumentSymbolRequest, | ||
LanguageClient, | ||
SymbolInformation | ||
} from "vscode-languageclient"; | ||
|
||
type DocumentSymbolsResponse = DocumentSymbol[] | SymbolInformation[] | null; | ||
|
||
export type getDocumentSymbolsCommand = (params: DocumentSymbolParams, token?: CancellationToken) => Promise<DocumentSymbolsResponse>; | ||
|
||
export function getDocumentSymbolsProvider(languageClient: LanguageClient): getDocumentSymbolsCommand { | ||
return async (params: DocumentSymbolParams, token?: CancellationToken): Promise<DocumentSymbolsResponse> => { | ||
if (token !== undefined) { | ||
return languageClient.sendRequest(DocumentSymbolRequest.type, params, token); | ||
} | ||
return languageClient.sendRequest(DocumentSymbolRequest.type, params); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,17 @@ | ||
import { getDocumentSymbolsCommand } from './documentSymbols'; | ||
import { RequirementsData } from './requirements'; | ||
import { TextDocumentPositionParams } from 'vscode-languageclient'; | ||
import { CancellationToken, Command, ProviderResult } from 'vscode'; | ||
|
||
export type provideHoverCommandFn = (params: TextDocumentPositionParams, token: CancellationToken) => ProviderResult<Command[] | undefined>; | ||
export type registerHoverCommand = (callback: provideHoverCommandFn) => void; | ||
|
||
export const ExtensionApiVersion = '0.3'; | ||
|
||
export interface ExtensionAPI { | ||
readonly apiVersion: string; | ||
readonly javaRequirement: RequirementsData; | ||
readonly status: "Started" | "Error"; | ||
readonly registerHoverCommand: registerHoverCommand; | ||
readonly getDocumentSymbols: getDocumentSymbolsCommand; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters