diff --git a/package.json b/package.json index dba3843c..8b632d59 100644 --- a/package.json +++ b/package.json @@ -19,430 +19,328 @@ "npm": ">=8.0.0", "vscode": "^1.54.0" }, - "categories": [ - "Programming Languages" - ], - "keywords": [ - "vRealize", - "vRO", - "vRA" - ], - "activationEvents": [ - "onLanguage:javascript", - "onLanguage:typescript", - "workspaceContains:.o11n/", - "onView:vrdev.views.explorer", - "onCommand:vrdev.new.project", - "onCommand:vrdev.change.profile", - "onCommand:vrdev.open.action", - "onCommand:vrdev.open.workflow", - "onCommand:vrdev.open.config", - "onCommand:vrdev.open.resource", - "onCommand:vrdev.run.action", - "onCommand:vrdev.toggle.typescript", - "onCommand:vrdev.vra.auth.configure", - "onCommand:vrdev.blueprint.create", - "onCommand:vrdev.blueprint.fetch", - "onCommand:vrdev.blueprint.upload", - "onCommand:vrdev.blueprint.deploy" - ], - "main": "./extension/out/extension", + "categories": ["Programming Languages"], + "keywords": ["vRealize", "vRO", "vRA"], + "activationEvents": ["onLanguage:javascript", "onLanguage:typescript", "workspaceContains:.o11n/", "onView:vrdev.views.explorer", "onCommand:vrdev.new.project", "onCommand:vrdev.change.profile", "onCommand:vrdev.open.action", "onCommand:vrdev.open.workflow", "onCommand:vrdev.open.config", "onCommand:vrdev.open.resource", "onCommand:vrdev.run.action", "onCommand:vrdev.toggle.typescript", "onCommand:vrdev.vra.auth.configure", "onCommand:vrdev.blueprint.create", "onCommand:vrdev.blueprint.fetch", "onCommand:vrdev.blueprint.upload", "onCommand:vrdev.blueprint.deploy"], + "main": "./extension/dist/extension", "icon": "assets/logo.png", "contributes": { "viewsContainers": { - "activitybar": [ - { - "id": "vro-explorer", - "title": "vRealize Developer Tools", - "icon": "assets/icons/explorer.svg" - } - ] + "activitybar": [{ + "id": "vro-explorer", + "title": "vRealize Developer Tools", + "icon": "assets/icons/explorer.svg" + }] }, "views": { - "vro-explorer": [ - { - "id": "vrdev.views.explorer", - "name": "Explorer" - }, - { - "id": "vrdev.views.properties", - "name": "Properties" - } - ] + "vro-explorer": [{ + "id": "vrdev.views.explorer", + "name": "Explorer" + }, { + "id": "vrdev.views.properties", + "name": "Properties" + }] }, - "viewsWelcome": [ - { - "view": "vrdev.views.explorer", - "contents": "Connect to vRealize Orchetsrator by selecting a maven profile.\n\n[Select Profile](command:vrdev.change.profile)" - }, - { - "view": "vrdev.views.properties", - "contents": "Select a node in the Explorer to view its properties." + "viewsWelcome": [{ + "view": "vrdev.views.explorer", + "contents": "Connect to vRealize Orchetsrator by selecting a maven profile.\n\n[Select Profile](command:vrdev.change.profile)" + }, { + "view": "vrdev.views.properties", + "contents": "Select a node in the Explorer to view its properties." + }], + "commands": [{ + "command": "vrdev.views.explorer.refresh", + "title": "Refresh", + "category": "vRealize", + "icon": { + "light": "assets/icons/light/refresh.svg", + "dark": "assets/icons/dark/refresh.svg" + } + }, { + "command": "vrdev.views.explorer.revealItem", + "title": "Reveal Item in Explorer", + "category": "vRealize" + }, { + "command": "vrdev.views.properties.show", + "title": "Show Properties", + "category": "vRealize" + }, { + "command": "vrdev.views.properties.copy", + "title": "Copy Value", + "category": "vRealize", + "icon": { + "light": "assets/icons/light/clipboard.svg", + "dark": "assets/icons/dark/clipboard.svg" + } + }, { + "command": "vrdev.views.properties.locateItem", + "title": "Locate Item in Explorer", + "category": "vRealize", + "icon": { + "light": "assets/icons/light/location.svg", + "dark": "assets/icons/dark/location.svg" + } + }, { + "command": "vrdev.fetchRemoteElement", + "title": "Fetch from Remote", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/link-external.svg", + "light": "assets/icons/light/link-external.svg" + } + }, { + "command": "vrdev.workflow.fetchSchema", + "title": "Open Workflow Schema", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/circuit-board.svg", + "light": "assets/icons/light/circuit-board.svg" + } + }, { + "command": "vrdev.package.delete", + "title": "Delete", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/trash.svg", + "light": "assets/icons/light/trash.svg" + } + }, { + "command": "vrdev.change.profile", + "title": "Change Active Profile", + "category": "vRealize" + }, { + "command": "vrdev.open.action", + "title": "Open vRO Action", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/search.svg", + "light": "assets/icons/light/search.svg" + } + }, { + "command": "vrdev.open.workflow", + "title": "Open vRO Workflow", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/search.svg", + "light": "assets/icons/light/search.svg" + } + }, { + "command": "vrdev.open.config", + "title": "Open vRO Configuration", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/search.svg", + "light": "assets/icons/light/search.svg" + } + }, { + "command": "vrdev.open.resource", + "title": "Open vRO Resource", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/search.svg", + "light": "assets/icons/light/search.svg" } - ], - "commands": [ - { + }, { + "command": "vrdev.new.project", + "title": "New Project", + "category": "vRealize" + }, { + "command": "vrdev.run.action", + "title": "Run vRO Action", + "category": "vRealize", + "icon": { + "light": "assets/icons/light/zap.svg", + "dark": "assets/icons/dark/zap.svg" + } + }, { + "command": "vrdev.toggle.typescript", + "title": "Toggle TypeScript Support (Experimental)", + "category": "vRealize" + }, { + "command": "vrdev.vra.auth.configure", + "title": "Configure vRA Authentication", + "category": "vRealize" + }, { + "command": "vrdev.blueprint.create", + "title": "Create vRA Blueprint", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/circuit-board.svg", + "light": "assets/icons/light/circuit-board.svg" + } + }, { + "command": "vrdev.blueprint.upload", + "title": "Upload vRA Blueprint", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/circuit-board.svg", + "light": "assets/icons/light/circuit-board.svg" + } + }, { + "command": "vrdev.blueprint.fetch", + "title": "Fetch vRA Blueprint", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/circuit-board.svg", + "light": "assets/icons/light/circuit-board.svg" + } + }, { + "command": "vrdev.blueprint.deploy", + "title": "Deploy vRA Blueprint", + "category": "vRealize", + "icon": { + "dark": "assets/icons/dark/circuit-board.svg", + "light": "assets/icons/light/circuit-board.svg" + } + }], + "menus": { + "view/title": [{ + "when": "view =~ /^vrdev\\.views\\.explorer/", "command": "vrdev.views.explorer.refresh", - "title": "Refresh", - "category": "vRealize", - "icon": { - "light": "assets/icons/light/refresh.svg", - "dark": "assets/icons/dark/refresh.svg" - } - }, - { - "command": "vrdev.views.explorer.revealItem", - "title": "Reveal Item in Explorer", - "category": "vRealize" - }, - { - "command": "vrdev.views.properties.show", - "title": "Show Properties", - "category": "vRealize" - }, - { - "command": "vrdev.views.properties.copy", - "title": "Copy Value", - "category": "vRealize", - "icon": { - "light": "assets/icons/light/clipboard.svg", - "dark": "assets/icons/dark/clipboard.svg" - } - }, - { + "group": "navigation@1" + }, { + "when": "!vrdev:properties:empty && view =~ /^vrdev\\.views\\.properties/", "command": "vrdev.views.properties.locateItem", - "title": "Locate Item in Explorer", - "category": "vRealize", - "icon": { - "light": "assets/icons/light/location.svg", - "dark": "assets/icons/dark/location.svg" - } - }, - { + "group": "navigation@1" + }], + "view/item/context": [{ "command": "vrdev.fetchRemoteElement", - "title": "Fetch from Remote", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/link-external.svg", - "light": "assets/icons/light/link-external.svg" - } - }, - { + "when": "viewItem =~ /vrdev:element:kind:(action|workflow|config|resource)\\b/", + "group": "inline@98" + }, { + "command": "vrdev.fetchRemoteElement", + "when": "viewItem =~ /vrdev:element:kind:(action|workflow|config|resource)\\b/", + "group": "1_vrdevs@1" + }, { "command": "vrdev.workflow.fetchSchema", - "title": "Open Workflow Schema", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/circuit-board.svg", - "light": "assets/icons/light/circuit-board.svg" - } - }, - { + "when": "viewItem =~ /vrdev:element:kind:workflow\\b/", + "group": "inline@95" + }, { + "command": "vrdev.workflow.fetchSchema", + "when": "viewItem =~ /vrdev:element:kind:workflow\\b/", + "group": "1_vrdevs@2" + }, { "command": "vrdev.package.delete", - "title": "Delete", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/trash.svg", - "light": "assets/icons/light/trash.svg" - } - }, - { - "command": "vrdev.change.profile", - "title": "Change Active Profile", - "category": "vRealize" - }, - { + "when": "viewItem =~ /vrdev:element:kind:package\\b/", + "group": "inline@95" + }, { + "command": "vrdev.package.delete", + "when": "viewItem =~ /vrdev:element:kind:package\\b/", + "group": "1_vrdevs@1" + }, { "command": "vrdev.open.action", - "title": "Open vRO Action", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/search.svg", - "light": "assets/icons/light/search.svg" - } - }, - { + "when": "viewItem =~ /vrdev:element:kind:actions\\b/", + "group": "inline@95" + }, { + "command": "vrdev.open.action", + "when": "viewItem =~ /vrdev:element:kind:actions\\b/", + "group": "1_vrdevs@1" + }, { "command": "vrdev.open.workflow", - "title": "Open vRO Workflow", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/search.svg", - "light": "assets/icons/light/search.svg" - } - }, - { + "when": "viewItem =~ /vrdev:element:kind:workflows\\b/", + "group": "inline@95" + }, { + "command": "vrdev.open.workflow", + "when": "viewItem =~ /vrdev:element:kind:workflows\\b/", + "group": "1_vrdevs@1" + }, { "command": "vrdev.open.config", - "title": "Open vRO Configuration", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/search.svg", - "light": "assets/icons/light/search.svg" - } - }, - { + "when": "viewItem =~ /vrdev:element:kind:configs\\b/", + "group": "inline@95" + }, { + "command": "vrdev.open.config", + "when": "viewItem =~ /vrdev:element:kind:configs\\b/", + "group": "1_vrdevs@1" + }, { "command": "vrdev.open.resource", - "title": "Open vRO Resource", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/search.svg", - "light": "assets/icons/light/search.svg" - } - }, - { - "command": "vrdev.new.project", - "title": "New Project", - "category": "vRealize" - }, - { - "command": "vrdev.run.action", - "title": "Run vRO Action", - "category": "vRealize", - "icon": { - "light": "assets/icons/light/zap.svg", - "dark": "assets/icons/dark/zap.svg" - } - }, - { - "command": "vrdev.toggle.typescript", - "title": "Toggle TypeScript Support (Experimental)", - "category": "vRealize" - }, - { - "command": "vrdev.vra.auth.configure", - "title": "Configure vRA Authentication", - "category": "vRealize" - }, - { + "when": "viewItem =~ /vrdev:element:kind:resources\\b/", + "group": "inline@95" + }, { + "command": "vrdev.open.resource", + "when": "viewItem =~ /vrdev:element:kind:resources\\b/", + "group": "1_vrdevs@1" + }, { + "command": "vrdev.views.properties.copy", + "when": "viewItem =~ /vrdev:element:kind:property\\b(?!.*?\\+multi\\b)\\b/", + "group": "inline@95" + }, { + "command": "vrdev.views.properties.copy", + "when": "viewItem =~ /vrdev:element:kind:property\\b(?!.*?\\+multi\\b)\\b/", + "group": "1_vrdevs@1" + }, { "command": "vrdev.blueprint.create", - "title": "Create vRA Blueprint", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/circuit-board.svg", - "light": "assets/icons/light/circuit-board.svg" - } - }, - { + "when": "viewItem =~ /vrdev:element:kind:blueprint\\b/", + "group": "inline@95" + }, { + "command": "vrdev.blueprint.create", + "when": "viewItem =~ /vrdev:element:kind:blueprint\\b/", + "group": "1_vrdevs@1" + }], + "editor/title": [{ + "when": "resourceLangId == javascript || resourceLangId == typescript", + "command": "vrdev.run.action", + "group": "navigation" + }, { + "when": "resourceLangId == yaml", "command": "vrdev.blueprint.upload", - "title": "Upload vRA Blueprint", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/circuit-board.svg", - "light": "assets/icons/light/circuit-board.svg" - } - }, - { - "command": "vrdev.blueprint.fetch", - "title": "Fetch vRA Blueprint", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/circuit-board.svg", - "light": "assets/icons/light/circuit-board.svg" - } - }, - { + "group": "navigation" + }, { + "when": "resourceLangId == yaml", "command": "vrdev.blueprint.deploy", - "title": "Deploy vRA Blueprint", - "category": "vRealize", - "icon": { - "dark": "assets/icons/dark/circuit-board.svg", - "light": "assets/icons/light/circuit-board.svg" - } - } - ], - "menus": { - "view/title": [ - { - "when": "view =~ /^vrdev\\.views\\.explorer/", - "command": "vrdev.views.explorer.refresh", - "group": "navigation@1" - }, - { - "when": "!vrdev:properties:empty && view =~ /^vrdev\\.views\\.properties/", - "command": "vrdev.views.properties.locateItem", - "group": "navigation@1" - } - ], - "view/item/context": [ - { - "command": "vrdev.fetchRemoteElement", - "when": "viewItem =~ /vrdev:element:kind:(action|workflow|config|resource)\\b/", - "group": "inline@98" - }, - { - "command": "vrdev.fetchRemoteElement", - "when": "viewItem =~ /vrdev:element:kind:(action|workflow|config|resource)\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.workflow.fetchSchema", - "when": "viewItem =~ /vrdev:element:kind:workflow\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.workflow.fetchSchema", - "when": "viewItem =~ /vrdev:element:kind:workflow\\b/", - "group": "1_vrdevs@2" - }, - { - "command": "vrdev.package.delete", - "when": "viewItem =~ /vrdev:element:kind:package\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.package.delete", - "when": "viewItem =~ /vrdev:element:kind:package\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.open.action", - "when": "viewItem =~ /vrdev:element:kind:actions\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.open.action", - "when": "viewItem =~ /vrdev:element:kind:actions\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.open.workflow", - "when": "viewItem =~ /vrdev:element:kind:workflows\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.open.workflow", - "when": "viewItem =~ /vrdev:element:kind:workflows\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.open.config", - "when": "viewItem =~ /vrdev:element:kind:configs\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.open.config", - "when": "viewItem =~ /vrdev:element:kind:configs\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.open.resource", - "when": "viewItem =~ /vrdev:element:kind:resources\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.open.resource", - "when": "viewItem =~ /vrdev:element:kind:resources\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.views.properties.copy", - "when": "viewItem =~ /vrdev:element:kind:property\\b(?!.*?\\+multi\\b)\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.views.properties.copy", - "when": "viewItem =~ /vrdev:element:kind:property\\b(?!.*?\\+multi\\b)\\b/", - "group": "1_vrdevs@1" - }, - { - "command": "vrdev.blueprint.create", - "when": "viewItem =~ /vrdev:element:kind:blueprint\\b/", - "group": "inline@95" - }, - { - "command": "vrdev.blueprint.create", - "when": "viewItem =~ /vrdev:element:kind:blueprint\\b/", - "group": "1_vrdevs@1" - } - ], - "editor/title": [ - { - "when": "resourceLangId == javascript || resourceLangId == typescript", - "command": "vrdev.run.action", - "group": "navigation" - }, - { - "when": "resourceLangId == yaml", - "command": "vrdev.blueprint.upload", - "group": "navigation" - }, - { - "when": "resourceLangId == yaml", - "command": "vrdev.blueprint.deploy", - "group": "navigation" - } - ], - "commandPalette": [ - { - "command": "vrdev.fetchRemoteElement", - "when": "false" - }, - { - "command": "vrdev.workflow.fetchSchema", - "when": "false" - }, - { - "command": "vrdev.package.delete", - "when": "false" - }, - { - "command": "vrdev.views.properties.show", - "when": "false" - }, - { - "command": "vrdev.views.properties.copy", - "when": "false" - }, - { - "command": "vrdev.views.properties.locateItem", - "when": "false" - }, - { - "command": "vrdev.views.explorer.revealItem", - "when": "false" - }, - { - "command": "vrdev.views.explorer.refresh", - "when": "false" - } - ] + "group": "navigation" + }], + "commandPalette": [{ + "command": "vrdev.fetchRemoteElement", + "when": "false" + }, { + "command": "vrdev.workflow.fetchSchema", + "when": "false" + }, { + "command": "vrdev.package.delete", + "when": "false" + }, { + "command": "vrdev.views.properties.show", + "when": "false" + }, { + "command": "vrdev.views.properties.copy", + "when": "false" + }, { + "command": "vrdev.views.properties.locateItem", + "when": "false" + }, { + "command": "vrdev.views.explorer.revealItem", + "when": "false" + }, { + "command": "vrdev.views.explorer.refresh", + "when": "false" + }] }, - "taskDefinitions": [ - { - "type": "vRealize", - "required": [ - "label", - "command" - ], - "properties": { - "label": { - "type": "string" - }, - "command": { - "type": "string", - "description": "The command to execute" - } + "taskDefinitions": [{ + "type": "vRealize", + "required": ["label", "command"], + "properties": { + "label": { + "type": "string" + }, + "command": { + "type": "string", + "description": "The command to execute" } } - ], + }], "configuration": { "type": "object", "title": "vRealize Developer Tools", "properties": { "vrdev.log": { "type": "string", - "enum": [ - "off", - "info", - "debug" - ], + "enum": ["off", "info", "debug"], "default": "info", "description": "Enables logging of the vRealize Developer Tools to the OUTPUT panel. This log can be used to diagnose vRealize Developer Tools issues. The log may contain file paths, source code, and other potentially sensitive information from your project." }, "vrdev.trace": { "type": "string", - "enum": [ - "off", - "messages", - "verbose" - ], + "enum": ["off", "messages", "verbose"], "default": "off", "description": "Enables tracing of messages exchanged between the vRealize Developer Tools extension and the vRO language server. This trace can be used to diagnose extension issues. The trace may contain file paths, source code, and other potentially sensitive information from your project." }, @@ -481,10 +379,7 @@ }, "vrdev.vra.auth.type": { "type": "string", - "enum": [ - "refresh_token", - "password" - ], + "enum": ["refresh_token", "password"], "description": "Method for authetication towards vRealize Automation 8", "scope": "window" }, @@ -509,16 +404,8 @@ "vrdev.views.explorer.actions.layout": { "type": "string", "default": "compact", - "enum": [ - "tree", - "compact", - "flat" - ], - "enumDescriptions": [ - "Displays action packages as a tree", - "Displays action packages as a tree, but flattens any folders that have no children", - "Displays action packages as a list" - ], + "enum": ["tree", "compact", "flat"], + "enumDescriptions": ["Displays action packages as a tree", "Displays action packages as a tree, but flattens any folders that have no children", "Displays action packages as a list"], "markdownDescription": "Specifies how the _Explorer_ view will display vRO action packages", "scope": "window" }, @@ -530,16 +417,13 @@ } } }, - "snippets": [ - { - "language": "javascript", - "path": "./extension/snippets/vro.json" - }, - { - "language": "yaml", - "path": "./extension/snippets/vra-blueprint.json" - } - ] + "snippets": [{ + "language": "javascript", + "path": "./extension/snippets/vro.json" + }, { + "language": "yaml", + "path": "./extension/snippets/vra-blueprint.json" + }] }, "devDependencies": { "@types/adm-zip": "^0.4.33", @@ -619,11 +503,9 @@ "glob-stream": "^7.0.0", "ansi-regex": "^5.0.1" }, - "workspaces": [ - "packages/node/*" - ], + "workspaces": ["packages/node/*"], "scripts": { "preinstall": "node build/preinstall.js", "vscode:prepublish": "webpack --mode production --config ./extension/webpack.config.js && webpack --mode production --config ./packages/node/vro-language-server/webpack.config.js" } -} +} \ No newline at end of file diff --git a/packages/node/vro-language-server/src/server/core/HintLookup.ts b/packages/node/vro-language-server/src/server/core/HintLookup.ts index 03865524..fb4794ed 100644 --- a/packages/node/vro-language-server/src/server/core/HintLookup.ts +++ b/packages/node/vro-language-server/src/server/core/HintLookup.ts @@ -5,9 +5,9 @@ import * as fs from "fs" +import { AutoWire, HintModule, Logger, WorkspaceFolder } from "@vmware/vrdt-common" import * as _ from "lodash" import { v4 as uuidv4 } from "uuid" -import { AutoWire, HintModule, Logger, WorkspaceFolder } from "@vmware/vrdt-common" import { Disposable, WorkspaceFoldersChangeEvent } from "vscode-languageserver" import { vmw } from "../../proto" @@ -100,8 +100,8 @@ export class HintLookup implements Disposable { const module = this.getActionModules(workspaceFolder).find(module => module.name === moduleName) this.logger.debug(`Module hint: ${JSON.stringify(module, null, 4)}`) - if (module && module.actions) { - return module.actions.filter(action => !!action) + if (module?.actions) { + return module.actions.filter((action: any) => !!action) } return [] @@ -122,7 +122,7 @@ export class HintLookup implements Disposable { getConfigElementsIn(categoryPath: string, workspaceFolder?: WorkspaceFolder): vmw.pscoe.hints.IConfig[] { const module = this.getConfigCategories(workspaceFolder).find(category => category.path === categoryPath) - if (module && module.configurations) { + if (module?.configurations) { return module.configurations.filter(config => !!config) } @@ -139,9 +139,7 @@ export class HintLookup implements Disposable { for (const api of this.scriptingApi.global) { for (const cls of api.classes) { const hasConstructors = !!cls.constructors && cls.constructors.length > 0 - if (filter.isInstantiable === undefined) { - result.push(cls) - } else if (hasConstructors === filter.isInstantiable) { + if (filter.isInstantiable === undefined || hasConstructors === filter.isInstantiable) { result.push(cls) } } diff --git a/packages/node/vro-language-server/src/server/request/collection/ServerCollection.ts b/packages/node/vro-language-server/src/server/request/collection/ServerCollection.ts index 21304fc5..18ecc321 100644 --- a/packages/node/vro-language-server/src/server/request/collection/ServerCollection.ts +++ b/packages/node/vro-language-server/src/server/request/collection/ServerCollection.ts @@ -3,14 +3,14 @@ * SPDX-License-Identifier: MIT */ -import { CancellationToken } from "vscode-languageserver" import { AutoWire, HintAction, HintModule, HintPlugin, Logger, sleep, VroRestClient } from "@vmware/vrdt-common" +import { CancellationToken } from "vscode-languageserver" +import { Timeout } from "../../../constants" +import { vmw } from "../../../proto" import { remote } from "../../../public" import { ConnectionLocator, Environment, HintLookup, Settings } from "../../core" import { WorkspaceCollection } from "./WorkspaceCollection" -import { vmw } from "../../../proto" -import { Timeout } from "../../../constants" @AutoWire export class CollectionStatus { @@ -141,6 +141,13 @@ export class ServerCollection { }) } + /** + * Collect all vRO Scripting API (Plugin) objects like VcPlugin, ActiveDirectory, etc. + * Function is asynchronous and usually takes approximately 10 mins since the full list of plugin details + * is huge (approximately 370 000 lines of JSON definitions) + * + * @returns vmw.pscoe.hints.IClass[] + */ async getVroObjects() { this.logger.info("Collecting vRO objects...") @@ -164,9 +171,15 @@ export class ServerCollection { } const parsedLink = link[0].substring(9).toString() // always retrieve and parse the first occurrence const pluginDetails = await this.restClient.getPluginDetails(parsedLink) + for (const pluginObject of pluginDetails["objects"]) { + // enrich the object with vRO plugin object properties const object: vmw.pscoe.hints.IClass = { - name: pluginObject["name"] + name: pluginObject["name"], + description: pluginObject["description"], + constructors: pluginObject["constructors"], + properties: pluginObject["attributes"], + methods: pluginObject["methods"] } allObjects.push(object) } diff --git a/packages/node/vro-language-server/src/server/request/collection/WorkspaceCollection.ts b/packages/node/vro-language-server/src/server/request/collection/WorkspaceCollection.ts index 64edabd6..dcb53828 100644 --- a/packages/node/vro-language-server/src/server/request/collection/WorkspaceCollection.ts +++ b/packages/node/vro-language-server/src/server/request/collection/WorkspaceCollection.ts @@ -3,14 +3,9 @@ * SPDX-License-Identifier: MIT */ -import * as path from "path" import * as os from "os" +import * as path from "path" -import { parse } from "comment-parser" -import * as protobuf from "protobufjs" -import { v4 as uuidv4 } from "uuid" -import * as fs from "fs-extra" -import * as _ from "lodash" import { ActionParameters, AutoWire, @@ -20,11 +15,16 @@ import { PomFile, WorkspaceFolder } from "@vmware/vrdt-common" +import { parse } from "comment-parser" +import * as fs from "fs-extra" +import * as _ from "lodash" +import * as protobuf from "protobufjs" +import { v4 as uuidv4 } from "uuid" import { FileChangeType } from "vscode-languageserver" +import { ActionsPackProto, Timeout } from "../../../constants" import { Environment, FileChangeEventParams, HintLookup, WorkspaceFilesWatcher } from "../../core" import { FileSavedEventParams, WorkspaceDocumentWatcher } from "../../core/WorkspaceDocumentWatcher" -import { ActionsPackProto, Timeout } from "../../../constants" @AutoWire export class WorkspaceCollection { @@ -89,7 +89,7 @@ export class WorkspaceCollection { const payload = this.collectLocalData(modulesPath) this.generateActionsPbFiles(payload, outputDir, workspaceFolder) } catch (error) { - this.logger.warn(`Error occurred: ${JSON.stringify(error)}`) + this.logger.warn(`Error occurred: ${error}`) } this.logger.info("Workspace hint collection has finished") } @@ -104,22 +104,23 @@ export class WorkspaceCollection { fs.writeFileSync(actionPackProtoFile, ActionsPackProto) protobuf.load(actionPackProtoFile, function (err, root) { - if (err) throw err - if (!root) throw new Error("Root namespace not loaded") - + if (err) { + throw err + } + if (!root) { + throw new Error("Root namespace not loaded") + } // Obtain a message type const ActionsPack = root.lookupType("vmw.pscoe.hints.ActionsPack") - // Verify the payload (i.e. incomplete or invalid) const errMsg = ActionsPack.verify(payload) - if (errMsg) throw Error(errMsg) - + if (errMsg) { + throw Error(errMsg) + } // Create a new message const message = ActionsPack.create(payload) - // Encode a message to a Buffer const buffer = ActionsPack.encode(message).finish() - fs.writeFileSync(outputFile, buffer) }) } @@ -145,17 +146,17 @@ export class WorkspaceCollection { .replace(/[\/\\]$/, "") // remove trailing slash or backslash .replace(/[\/\\]/g, ".") // replace remaining slashes or backslashes with dots - parsedActions[0].tags.forEach(tag => { + parsedActions[0]?.tags.forEach(tag => { if (tag.tag === "param") { const actionParams: ActionParameters = { name: tag.name, type: tag.type, - description: tag.description + description: tag?.description } parameters.push(actionParams) } if (tag.tag === "return") { - returnType = tag.type + returnType = tag?.type } }) @@ -164,7 +165,7 @@ export class WorkspaceCollection { name: actionName, moduleName: moduleName, returnType: returnType, - description: parsedActions[0].description, + description: parsedActions[0]?.description, parameters: parameters } actions.push(actionObj) @@ -182,7 +183,7 @@ export class WorkspaceCollection { modules.forEach(module => { actions.forEach(action => { - if (action.moduleName === module.name) { + if (action?.moduleName === module?.name) { module.actions.push(action) } }) diff --git a/wiki/Using-the-VS-Code-Extension.md b/wiki/Using-the-VS-Code-Extension.md index af4afb9e..fd85de07 100644 --- a/wiki/Using-the-VS-Code-Extension.md +++ b/wiki/Using-the-VS-Code-Extension.md @@ -96,3 +96,25 @@ The `vrdev.tasks.exclude` setting can be used to _exclude_ certain projects from "my.example.library:util" // Exclude util library (:) ] ``` + +#### Display Hints in Java Script Projects + +The VS Code plugin supports displaying action hints for modules and actions that are present in vRO along with the modules and actions that are part of the currently opened project. If you type: + +```javascript +System.getModule("com.module.path."). +``` + +or + +```javascript +Class.load("com.module.path."). +``` + +a list of hints with modules available on vRO and in locally opened projects would be presented as list, furthermore methods and parameters would be also present as hints, as shown in the example below: + +./images/js-code-hinting.png + +The hinting functionality also supports displaying hints for constructors, methods and attributes of all Scripting API (vRO plugin) objects available on the vRO server, as shown in the example below: + +./images/js-plugin-hinting.png diff --git a/wiki/images/js-code-hinting.png b/wiki/images/js-code-hinting.png new file mode 100644 index 00000000..bfeb5092 Binary files /dev/null and b/wiki/images/js-code-hinting.png differ diff --git a/wiki/images/js-plugin-hinting.png b/wiki/images/js-plugin-hinting.png new file mode 100644 index 00000000..c52765d7 Binary files /dev/null and b/wiki/images/js-plugin-hinting.png differ