diff --git a/CHANGELOG.md b/CHANGELOG.md index 72adb0ff..ef48ee50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - Go to definition now goes to real file if such presented, or opens from the server - Basic syntax highlighting for CSP files, only as HTML - Added some snippets for class +- View subclasses for current class ## [0.7.7] diff --git a/api/index.ts b/api/index.ts index 52921d66..f6e23a06 100644 --- a/api/index.ts +++ b/api/index.ts @@ -146,7 +146,7 @@ export class AtelierAPI { type?: string; filter?: string; }): Promise { - return this.request('GET', `v2/${this.ns}/docnames/${category}/${type}`, { + return this.request('GET', `v3/${this.ns}/docnames/${category}/${type}`, { filter, generated }); @@ -159,20 +159,37 @@ export class AtelierAPI { format }; } - return this.request('GET', `v2/${this.ns}/doc/${name}`, params); + return this.request('GET', `v3/${this.ns}/doc/${name}`, params); } putDoc(name: string, data: { enc: boolean; content: string[] }, ignoreConflict?: boolean): Promise { let params = { ignoreConflict }; - return this.request('PUT', `v2/${this.ns}/doc/${name}`, params, {}, data); + return this.request('PUT', `v3/${this.ns}/doc/${name}`, params, {}, data); } actionIndex(docs: string[]): Promise { - return this.request('POST', `v2/${this.ns}/action/index`, {}, {}, docs); + return this.request('POST', `v3/${this.ns}/action/index`, {}, {}, docs); + } + + actionSearch(params: { query: string; files?: string; sys?: boolean; gen?: boolean; max?: number }): Promise { + return this.request('GET', `v3/${this.ns}/action/search`, params, {}); + } + + actionQuery(query: string, parameters: string[]): Promise { + return this.request( + 'POST', + `v3/${this.ns}/action/query`, + {}, + {}, + { + query, + parameters + } + ); } actionCompile(docs: string[], flags?: string, source = false): Promise { - return this.request('POST', `v2/${this.ns}/action/compile`, { flags, source }, {}, docs); + return this.request('POST', `v3/${this.ns}/action/compile`, { flags, source }, {}, docs); } cvtXmlUdl(source: string): Promise { diff --git a/commands/subclass.ts b/commands/subclass.ts new file mode 100644 index 00000000..4c8ebfdd --- /dev/null +++ b/commands/subclass.ts @@ -0,0 +1,38 @@ +import * as vscode from 'vscode'; +import { config } from '../extension'; +import { AtelierAPI } from '../api'; +import { currentFile } from '../utils'; +import { DocumentContentProvider } from '../providers/DocumentContentProvider'; + +export async function subclass(): Promise { + const file = currentFile(); + if (!file || !file.name.toLowerCase().endsWith('.cls')) { + return; + } + let className = file.name + .split('.') + .slice(0, -1) + .join('.'); + if (!config('conn').active) { + return; + } + + const open = item => { + let uri = DocumentContentProvider.getUri(item + '.cls'); + vscode.window.showTextDocument(uri); + }; + + const api = new AtelierAPI(); + return api + .actionQuery('CALL %Dictionary.ClassDefinitionQuery_SubclassOf(?)', [className]) + .then(data => { + const list = data.result.content || []; + if (!list.length) { + return; + } + vscode.window.showQuickPick(list.map(el => el.Name)).then(item => { + open(item); + }); + }) + .catch(err => console.error(err)); +} diff --git a/commands/viewOthers.ts b/commands/viewOthers.ts index 29b3d585..5c6cf580 100644 --- a/commands/viewOthers.ts +++ b/commands/viewOthers.ts @@ -5,7 +5,6 @@ import { currentFile } from '../utils'; import { DocumentContentProvider } from '../providers/DocumentContentProvider'; export async function viewOthers(): Promise { - const api = new AtelierAPI(); const file = currentFile(); if (!file) { return; @@ -22,6 +21,7 @@ export async function viewOthers(): Promise { const getOthers = info => { return info.result.content[0].others; }; + const api = new AtelierAPI(); return api .actionIndex([file.name]) .then(info => { diff --git a/extension.ts b/extension.ts index bd0e549f..4edded7c 100644 --- a/extension.ts +++ b/extension.ts @@ -7,6 +7,7 @@ import { viewOthers } from './commands/viewOthers'; import { importAndCompile } from './commands/compile'; import { exportAll, exportExplorerItem } from './commands/export'; import { xml2doc } from './commands/xml2doc'; +import { subclass } from './commands/subclass'; import { ObjectScriptClassSymbolProvider } from './providers/ObjectScriptClassSymbolProvider'; import { ObjectScriptRoutineSymbolProvider } from './providers/ObjectScriptRoutineSymbolProvider'; @@ -128,6 +129,7 @@ export async function activate(context: vscode.ExtensionContext): Promise vscode.commands.registerCommand('vscode-objectscript.compileWithFlags', () => importAndCompile(true)), vscode.commands.registerCommand('vscode-objectscript.export', exportAll), vscode.commands.registerCommand('vscode-objectscript.viewOthers', viewOthers), + vscode.commands.registerCommand('vscode-objectscript.subclass', subclass), vscode.commands.registerCommand('vscode-objectscript.touchBar.viewOthers', viewOthers), vscode.commands.registerCommand('vscode-objectscript.explorer.refresh', () => explorerProvider.refresh()), vscode.commands.registerCommand('vscode-objectscript.explorer.openClass', vscode.window.showTextDocument), diff --git a/package.json b/package.json index 692c2c1f..fcc89d08 100644 --- a/package.json +++ b/package.json @@ -82,6 +82,10 @@ "command": "vscode-objectscript.viewOthers", "when": "vscode-objectscript.connectActive" }, + { + "command": "vscode-objectscript.subclass", + "when": "vscode-objectscript.connectActive" + }, { "command": "vscode-objectscript.previewXml", "when": "vscode-objectscript.connectActive" @@ -278,6 +282,11 @@ "command": "vscode-objectscript.viewOthers", "title": "View other" }, + { + "category": "ObjectScript", + "command": "vscode-objectscript.subclass", + "title": "View subclasses" + }, { "command": "vscode-objectscript.touchBar.compile", "title": "➾¹₀⁰₁¹₀"