Skip to content

Commit

Permalink
view subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
daimor committed Feb 2, 2019
1 parent 8aa05a1 commit f7d5c98
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
27 changes: 22 additions & 5 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export class AtelierAPI {
type?: string;
filter?: string;
}): Promise<any> {
return this.request('GET', `v2/${this.ns}/docnames/${category}/${type}`, {
return this.request('GET', `v3/${this.ns}/docnames/${category}/${type}`, {
filter,
generated
});
Expand All @@ -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<any> {
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<any> {
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<any> {
return this.request('GET', `v3/${this.ns}/action/search`, params, {});
}

actionQuery(query: string, parameters: string[]): Promise<any> {
return this.request(
'POST',
`v3/${this.ns}/action/query`,
{},
{},
{
query,
parameters
}
);
}

actionCompile(docs: string[], flags?: string, source = false): Promise<any> {
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<any> {
Expand Down
38 changes: 38 additions & 0 deletions commands/subclass.ts
Original file line number Diff line number Diff line change
@@ -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<void> {
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));
}
2 changes: 1 addition & 1 deletion commands/viewOthers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import { currentFile } from '../utils';
import { DocumentContentProvider } from '../providers/DocumentContentProvider';

export async function viewOthers(): Promise<void> {
const api = new AtelierAPI();
const file = currentFile();
if (!file) {
return;
Expand All @@ -22,6 +21,7 @@ export async function viewOthers(): Promise<void> {
const getOthers = info => {
return info.result.content[0].others;
};
const api = new AtelierAPI();
return api
.actionIndex([file.name])
.then(info => {
Expand Down
2 changes: 2 additions & 0 deletions extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -128,6 +129,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<void>
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),
Expand Down
9 changes: 9 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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": "➾¹₀⁰₁¹₀"
Expand Down

0 comments on commit f7d5c98

Please sign in to comment.