Skip to content

Commit f7d5c98

Browse files
committed
view subclasses
1 parent 8aa05a1 commit f7d5c98

File tree

6 files changed

+73
-6
lines changed

6 files changed

+73
-6
lines changed

Diff for: CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- Go to definition now goes to real file if such presented, or opens from the server
1313
- Basic syntax highlighting for CSP files, only as HTML
1414
- Added some snippets for class
15+
- View subclasses for current class
1516

1617
## [0.7.7]
1718

Diff for: api/index.ts

+22-5
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class AtelierAPI {
146146
type?: string;
147147
filter?: string;
148148
}): Promise<any> {
149-
return this.request('GET', `v2/${this.ns}/docnames/${category}/${type}`, {
149+
return this.request('GET', `v3/${this.ns}/docnames/${category}/${type}`, {
150150
filter,
151151
generated
152152
});
@@ -159,20 +159,37 @@ export class AtelierAPI {
159159
format
160160
};
161161
}
162-
return this.request('GET', `v2/${this.ns}/doc/${name}`, params);
162+
return this.request('GET', `v3/${this.ns}/doc/${name}`, params);
163163
}
164164

165165
putDoc(name: string, data: { enc: boolean; content: string[] }, ignoreConflict?: boolean): Promise<any> {
166166
let params = { ignoreConflict };
167-
return this.request('PUT', `v2/${this.ns}/doc/${name}`, params, {}, data);
167+
return this.request('PUT', `v3/${this.ns}/doc/${name}`, params, {}, data);
168168
}
169169

170170
actionIndex(docs: string[]): Promise<any> {
171-
return this.request('POST', `v2/${this.ns}/action/index`, {}, {}, docs);
171+
return this.request('POST', `v3/${this.ns}/action/index`, {}, {}, docs);
172+
}
173+
174+
actionSearch(params: { query: string; files?: string; sys?: boolean; gen?: boolean; max?: number }): Promise<any> {
175+
return this.request('GET', `v3/${this.ns}/action/search`, params, {});
176+
}
177+
178+
actionQuery(query: string, parameters: string[]): Promise<any> {
179+
return this.request(
180+
'POST',
181+
`v3/${this.ns}/action/query`,
182+
{},
183+
{},
184+
{
185+
query,
186+
parameters
187+
}
188+
);
172189
}
173190

174191
actionCompile(docs: string[], flags?: string, source = false): Promise<any> {
175-
return this.request('POST', `v2/${this.ns}/action/compile`, { flags, source }, {}, docs);
192+
return this.request('POST', `v3/${this.ns}/action/compile`, { flags, source }, {}, docs);
176193
}
177194

178195
cvtXmlUdl(source: string): Promise<any> {

Diff for: commands/subclass.ts

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import * as vscode from 'vscode';
2+
import { config } from '../extension';
3+
import { AtelierAPI } from '../api';
4+
import { currentFile } from '../utils';
5+
import { DocumentContentProvider } from '../providers/DocumentContentProvider';
6+
7+
export async function subclass(): Promise<void> {
8+
const file = currentFile();
9+
if (!file || !file.name.toLowerCase().endsWith('.cls')) {
10+
return;
11+
}
12+
let className = file.name
13+
.split('.')
14+
.slice(0, -1)
15+
.join('.');
16+
if (!config('conn').active) {
17+
return;
18+
}
19+
20+
const open = item => {
21+
let uri = DocumentContentProvider.getUri(item + '.cls');
22+
vscode.window.showTextDocument(uri);
23+
};
24+
25+
const api = new AtelierAPI();
26+
return api
27+
.actionQuery('CALL %Dictionary.ClassDefinitionQuery_SubclassOf(?)', [className])
28+
.then(data => {
29+
const list = data.result.content || [];
30+
if (!list.length) {
31+
return;
32+
}
33+
vscode.window.showQuickPick(list.map(el => el.Name)).then(item => {
34+
open(item);
35+
});
36+
})
37+
.catch(err => console.error(err));
38+
}

Diff for: commands/viewOthers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { currentFile } from '../utils';
55
import { DocumentContentProvider } from '../providers/DocumentContentProvider';
66

77
export async function viewOthers(): Promise<void> {
8-
const api = new AtelierAPI();
98
const file = currentFile();
109
if (!file) {
1110
return;
@@ -22,6 +21,7 @@ export async function viewOthers(): Promise<void> {
2221
const getOthers = info => {
2322
return info.result.content[0].others;
2423
};
24+
const api = new AtelierAPI();
2525
return api
2626
.actionIndex([file.name])
2727
.then(info => {

Diff for: extension.ts

+2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { viewOthers } from './commands/viewOthers';
77
import { importAndCompile } from './commands/compile';
88
import { exportAll, exportExplorerItem } from './commands/export';
99
import { xml2doc } from './commands/xml2doc';
10+
import { subclass } from './commands/subclass';
1011

1112
import { ObjectScriptClassSymbolProvider } from './providers/ObjectScriptClassSymbolProvider';
1213
import { ObjectScriptRoutineSymbolProvider } from './providers/ObjectScriptRoutineSymbolProvider';
@@ -128,6 +129,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
128129
vscode.commands.registerCommand('vscode-objectscript.compileWithFlags', () => importAndCompile(true)),
129130
vscode.commands.registerCommand('vscode-objectscript.export', exportAll),
130131
vscode.commands.registerCommand('vscode-objectscript.viewOthers', viewOthers),
132+
vscode.commands.registerCommand('vscode-objectscript.subclass', subclass),
131133
vscode.commands.registerCommand('vscode-objectscript.touchBar.viewOthers', viewOthers),
132134
vscode.commands.registerCommand('vscode-objectscript.explorer.refresh', () => explorerProvider.refresh()),
133135
vscode.commands.registerCommand('vscode-objectscript.explorer.openClass', vscode.window.showTextDocument),

Diff for: package.json

+9
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@
8282
"command": "vscode-objectscript.viewOthers",
8383
"when": "vscode-objectscript.connectActive"
8484
},
85+
{
86+
"command": "vscode-objectscript.subclass",
87+
"when": "vscode-objectscript.connectActive"
88+
},
8589
{
8690
"command": "vscode-objectscript.previewXml",
8791
"when": "vscode-objectscript.connectActive"
@@ -278,6 +282,11 @@
278282
"command": "vscode-objectscript.viewOthers",
279283
"title": "View other"
280284
},
285+
{
286+
"category": "ObjectScript",
287+
"command": "vscode-objectscript.subclass",
288+
"title": "View subclasses"
289+
},
281290
{
282291
"command": "vscode-objectscript.touchBar.compile",
283292
"title": "➾¹₀⁰₁¹₀"

0 commit comments

Comments
 (0)