Skip to content

Commit

Permalink
Introduce legend concept tree (finos#71)
Browse files Browse the repository at this point in the history
* Introduce legend concept tree

* Move commands to constants

* Introduce constant for legend language id

* Fix licence check
  • Loading branch information
rafaelbey authored Jun 3, 2024
1 parent 9604940 commit ccbdae6
Show file tree
Hide file tree
Showing 8 changed files with 559 additions and 11 deletions.
5 changes: 5 additions & 0 deletions icons/legend.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion license-check-and-add-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"ignore": ["*.json", ".vscode-test", "lib", ".github", "*.vsix", "server", "*"],
"ignore": ["*.json", "icons/*.svg", "build", ".vscode-test", "lib", ".github", "*.vsix", "server", "*"],
"license": "./scripts/copyright/COPYRIGHT_HEADER.txt",
"licenseFormats": {
"ts": {
Expand Down
100 changes: 94 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,22 @@
"title": "Results",
"icon": ""
}
],
"activitybar": [
{
"id": "legend-activity-bar-menu",
"title": "Legend",
"icon": "./icons/legend.svg"
}
]
},
"views": {
"legend-activity-bar-menu": [
{
"id": "legendConceptTree",
"name": "Concept Tree"
}
],
"resultsViewContainer": [
{
"id": "executionView",
Expand All @@ -43,7 +56,11 @@
"view": "executionView",
"contents": "Execution in progress...",
"when": "isExecutionHappening"
}
},
{
"view": "legendConceptTree",
"contents": "[Load](command:legend.conceptTree.refresh) Legend concpets."
}
],
"commands": [
{
Expand All @@ -53,14 +70,34 @@
},
{
"command": "legend.extension.output",
"title": "Show Legend Extension Output",
"title": "Show Extension Output",
"category": "Legend"
},
{
"command": "legend.reload",
"title": "Reload Legend Extension",
"title": "Reload Extension",
"category": "Legend"
}
},
{
"command": "legend.conceptTree.show",
"title": "Show In Concept Tree",
"category": "Legend"
},
{
"command": "legend.conceptTree.navigate",
"title": "GoTo",
"icon": "$(go-to-file)"
},
{
"command": "legend.conceptTree.focusOnElement",
"title": "Focus Current Concept",
"icon": "$(target)"
},
{
"command": "legend.conceptTree.refresh",
"title": "Refresh",
"icon": "$(refresh)"
}
],
"configuration": {
"type": "object",
Expand Down Expand Up @@ -113,7 +150,11 @@
"id": "legend",
"extensions": [
".pure"
]
],
"icon": {
"dark": "./icons/legend.svg",
"light": "./icons/legend.svg"
}
}
],
"grammars": [
Expand All @@ -130,7 +171,54 @@
"title": "Legend REPL (Beta)"
}
]
}
},
"menus": {
"view/item/context": [
{
"command": "legend.conceptTree.navigate",
"when": "view == legendConceptTree && viewItem != package",
"group": "inline"
}
],
"view/title": [
{
"command": "legend.conceptTree.focusOnElement",
"when": "view == legendConceptTree",
"group": "navigation"
},
{
"command": "legend.conceptTree.refresh",
"when": "view == legendConceptTree",
"group": "navigation"
}
],
"editor/context": [
{
"group": "Legend",
"submenu": "legend.editor.context",
"when": "editorTextFocus && editorLangId == legend"
}
],
"legend.editor.context": [
{
"group": "Legend",
"command": "legend.conceptTree.show"
}
]
},
"submenus": [
{
"id": "legend.editor.context",
"label": "Legend"
}
],
"keybindings":[
{
"command": "legend.conceptTree.show",
"key": "ctrl+shift+l",
"mac": "shift+cmd+l"
}
]
},
"scripts": {
"test": "npm run build && node ./lib/tests/runTest.js",
Expand Down
39 changes: 38 additions & 1 deletion src/LegendLanguageClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,25 @@ import {
TEST_CASES_REQUEST_ID,
EXECUTE_TESTS_REQUEST_ID,
VIRTUAL_FILE_SYSTEM_FILE_REQUEST_ID,
ENTITIES_REQUEST_ID,
} from './utils/Const';
import type { PlainObject } from './utils/SerializationUtils';
import { LanguageClient } from 'vscode-languageclient/node';
import {
LanguageClient,
type TextDocumentIdentifier,
} from 'vscode-languageclient/node';
import type { LegendTest } from './model/LegendTest';
import type { ExecuteTestRequest } from './model/ExecuteTestRequest';
import type { LegendTestExecutionResult } from './model/LegendTestExecutionResult';
import { LegendEntity } from './model/LegendEntity';

export class LegendEntitiesRequest {
private textDocuments!: TextDocumentIdentifier[];

constructor(textDocuments: TextDocumentIdentifier[]) {
this.textDocuments = textDocuments;
}
}

export class LegendLanguageClient extends LanguageClient {
async sendTDSRequest(
Expand Down Expand Up @@ -80,4 +93,28 @@ export class LegendLanguageClient extends LanguageClient {
return this.sendRequest(EXECUTE_TESTS_REQUEST_ID, uri.toString());
}
}

async entities(
request: LegendEntitiesRequest,
token?: CancellationToken,
): Promise<LegendEntity[]> {
let promise: Promise<PlainObject<LegendTestExecutionResult>[]>;

if (token) {
promise = this.sendRequest<PlainObject<LegendTestExecutionResult>[]>(
ENTITIES_REQUEST_ID,
request,
token,
);
} else {
promise = this.sendRequest<PlainObject<LegendTestExecutionResult>[]>(
ENTITIES_REQUEST_ID,
request,
);
}

return promise.then((res) =>
res.map((x) => LegendEntity.serialization.fromJson(x)),
);
}
}
Loading

0 comments on commit ccbdae6

Please sign in to comment.