feat: Add new IDE service endpoints
- Implement getDiagnosticsInRange for code diagnostics - Create getCollapsedCode for code collapsing functionality - Add getExtensionToolsPath to retrieve tools directory - Update services.ts with new endpoint handlers
This commit is contained in:
parent
a308d09dc8
commit
2b5412b0bc
12
src/ide_services/endpoints/documentRangeDiagnostics.ts
Normal file
12
src/ide_services/endpoints/documentRangeDiagnostics.ts
Normal file
@ -0,0 +1,12 @@
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export async function getDiagnosticsInRange(fileName: string, startLine: number, endLine: number): Promise<string[]> {
|
||||
const document = await vscode.workspace.openTextDocument(fileName);
|
||||
const startPosition = new vscode.Position(startLine, 0);
|
||||
const endPosition = new vscode.Position(endLine, Number.MAX_VALUE);
|
||||
const range = new vscode.Range(startPosition, endPosition);
|
||||
const diagnosticsAll = vscode.languages.getDiagnostics(document.uri);
|
||||
|
||||
const diagnostics = diagnosticsAll.filter(diag => range.contains(diag.range));
|
||||
return diagnostics.map(diag => { return `${diag.message} <<${diag.source??""}:${diag.code??""}>>`; });
|
||||
}
|
11
src/ide_services/endpoints/getCollapsedCode.ts
Normal file
11
src/ide_services/endpoints/getCollapsedCode.ts
Normal file
@ -0,0 +1,11 @@
|
||||
import { collapseFileExculdeSelectRange } from '../../contributes/codecomplete/ast/collapseBlock';
|
||||
import * as vscode from 'vscode';
|
||||
|
||||
export async function getCollapsedCode(fileName: string, startLine: number, endLine: number): Promise<string> {
|
||||
const document = await vscode.workspace.openTextDocument(fileName);
|
||||
const startPosition = new vscode.Position(startLine, 0);
|
||||
const endPosition = new vscode.Position(endLine, Number.MAX_VALUE);
|
||||
const range = new vscode.Range(startPosition, endPosition);
|
||||
const code = await collapseFileExculdeSelectRange(document.uri.fsPath, document.getText(), range.start.line, range.end.line);
|
||||
return code;
|
||||
}
|
6
src/ide_services/endpoints/getToolsPath.ts
Normal file
6
src/ide_services/endpoints/getToolsPath.ts
Normal file
@ -0,0 +1,6 @@
|
||||
import { UiUtilWrapper } from "../../util/uiUtil";
|
||||
|
||||
|
||||
export async function getExtensionToolsPath(): Promise<string> {
|
||||
return await UiUtilWrapper.extensionPath() + "/tools/";
|
||||
}
|
@ -14,6 +14,9 @@ import { getDocumentSymbols } from "./endpoints/getDocumentSymbols";
|
||||
import { findTypeDefinitionLocations } from "./endpoints/findTypeDefs";
|
||||
import { findDefinitionLocations } from "./endpoints/findDefs";
|
||||
import { getCurrentFileInfo } from "./endpoints/getCurrentFileInfo";
|
||||
import { getDiagnosticsInRange } from "./endpoints/documentRangeDiagnostics";
|
||||
import { getExtensionToolsPath } from "./endpoints/getToolsPath";
|
||||
import { getCollapsedCode } from "./endpoints/getCollapsedCode";
|
||||
|
||||
const functionRegistry: any = {
|
||||
/**
|
||||
@ -89,6 +92,18 @@ const functionRegistry: any = {
|
||||
"/current_file_info": {
|
||||
keys: [],
|
||||
handler: getCurrentFileInfo,
|
||||
},
|
||||
"/get_diagnostics_in_range": {
|
||||
keys: ["fileName", "startLine", "endLine"],
|
||||
handler: getDiagnosticsInRange,
|
||||
},
|
||||
"/get_extension_tools_path": {
|
||||
keys: [],
|
||||
handler: getExtensionToolsPath,
|
||||
},
|
||||
"/get_collapsed_code": {
|
||||
keys: ["fileName", "startLine", "endLine"],
|
||||
handler: getCollapsedCode,
|
||||
}
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user