Skip to content

Commit 8d9a8cf

Browse files
committed
go to super class
1 parent c6087e8 commit 8d9a8cf

File tree

6 files changed

+65
-4
lines changed

6 files changed

+65
-4
lines changed

Diff for: CHANGELOG.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@
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, available in command palette
15+
- Go to Subclass for the current class, available in command palette
16+
- Go to Super class for the current class, available in command palette
1617
- Go To any class/method in the workspace including server (by Cmd+T/Ctrl+T)
1718
- some small fixes in the highlighting, and selecting words/variables
1819
- Intellisense. Show list of methods for ##class(SomeClass)
20+
- Go to macros definition
1921

2022
## [0.7.7]
2123

Diff for: commands/subclass.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export async function subclass(): Promise<void> {
2626
return api
2727
.actionQuery('CALL %Dictionary.ClassDefinitionQuery_SubclassOf(?)', [className])
2828
.then(data => {
29-
const list = data.result.content || [];
29+
const list = data.result.content.slice(0, 100) || [];
3030
if (!list.length) {
3131
return;
3232
}

Diff for: commands/superclass.ts

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import * as vscode from 'vscode';
2+
import { config } from '../extension';
3+
import { currentFile } from '../utils';
4+
import { DocumentContentProvider } from '../providers/DocumentContentProvider';
5+
import { ClassDefinition } from '../utils/classDefinition';
6+
7+
export async function superclass(): Promise<void> {
8+
if (!config('conn').active) {
9+
return;
10+
}
11+
const file = currentFile();
12+
if (!file || !file.name.toLowerCase().endsWith('.cls')) {
13+
return;
14+
}
15+
16+
const open = item => {
17+
let uri = DocumentContentProvider.getUri(item + '.cls');
18+
vscode.window.showTextDocument(uri);
19+
};
20+
21+
const classDefinition = new ClassDefinition(file.name);
22+
return classDefinition
23+
.super()
24+
.then(data => {
25+
const list = data || [];
26+
if (!list.length) {
27+
return;
28+
}
29+
vscode.window.showQuickPick(list).then(item => {
30+
open(item);
31+
});
32+
})
33+
.catch(err => console.error(err));
34+
}

Diff for: extension.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { importAndCompile } from './commands/compile';
88
import { exportAll, exportExplorerItem } from './commands/export';
99
import { xml2doc } from './commands/xml2doc';
1010
import { subclass } from './commands/subclass';
11+
import { superclass } from './commands/superclass';
1112

1213
import { ObjectScriptClassSymbolProvider } from './providers/ObjectScriptClassSymbolProvider';
1314
import { ObjectScriptRoutineSymbolProvider } from './providers/ObjectScriptRoutineSymbolProvider';
@@ -131,6 +132,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
131132
vscode.commands.registerCommand('vscode-objectscript.export', exportAll),
132133
vscode.commands.registerCommand('vscode-objectscript.viewOthers', viewOthers),
133134
vscode.commands.registerCommand('vscode-objectscript.subclass', subclass),
135+
vscode.commands.registerCommand('vscode-objectscript.superclass', superclass),
134136
vscode.commands.registerCommand('vscode-objectscript.touchBar.viewOthers', viewOthers),
135137
vscode.commands.registerCommand('vscode-objectscript.explorer.refresh', () => explorerProvider.refresh()),
136138
vscode.commands.registerCommand('vscode-objectscript.explorer.openClass', vscode.window.showTextDocument),

Diff for: package.json

+10-1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,10 @@
8686
"command": "vscode-objectscript.subclass",
8787
"when": "vscode-objectscript.connectActive"
8888
},
89+
{
90+
"command": "vscode-objectscript.superclass",
91+
"when": "vscode-objectscript.connectActive"
92+
},
8993
{
9094
"command": "vscode-objectscript.previewXml",
9195
"when": "vscode-objectscript.connectActive"
@@ -285,7 +289,12 @@
285289
{
286290
"category": "ObjectScript",
287291
"command": "vscode-objectscript.subclass",
288-
"title": "View subclasses"
292+
"title": "Go to Subclass..."
293+
},
294+
{
295+
"category": "ObjectScript",
296+
"command": "vscode-objectscript.superclass",
297+
"title": "Go to Super class..."
289298
},
290299
{
291300
"command": "vscode-objectscript.touchBar.compile",

Diff for: utils/classDefinition.ts

+15-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export class ClassDefinition {
1010
constructor(className: string) {
1111
if (className.endsWith('.cls')) {
1212
className = className.replace(/\.cls$/i, '');
13-
}
13+
}
1414
this._className = ClassDefinition.normalizeClassName(className, false);
1515
this._classFileName = ClassDefinition.normalizeClassName(className, true);
1616
}
@@ -33,6 +33,20 @@ export class ClassDefinition {
3333
return api.actionIndex([this._classFileName]).then(data => getMethods(data.result.content));
3434
}
3535

36+
async super(): Promise<string[]> {
37+
const api = new AtelierAPI();
38+
let sql = `SELECT PrimarySuper FROM %Dictionary.CompiledClass WHERE Name = ?`;
39+
return api
40+
.actionQuery(sql, [this._className])
41+
.then(data =>
42+
data.result.content.reduce(
43+
(list: string[], el: { PrimarySuper: string }) =>
44+
list.concat(el.PrimarySuper.split('~').filter(el => el.length)),
45+
[]
46+
)
47+
);
48+
}
49+
3650
async includeCode(): Promise<string[]> {
3751
const api = new AtelierAPI();
3852
let sql = `SELECT LIST(IncludeCode) List FROM %Dictionary.CompiledClass WHERE Name %INLIST (

0 commit comments

Comments
 (0)