diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 00000000..94e02963 --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,17 @@ +comment: + layout: "header, diff, files" + behavior: default + require_changes: no + +coverage: + range: 80..100 + round: down + precision: 2 + + status: + project: + default: + target: 90% + threshold: 2% + patch: yes + changes: no diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 00000000..9b452b41 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,30 @@ +language: node_js + +node_js: +- "node" +- "lts/*" + +branches: + # only master, dev, and tagged commits + only: + - master + - dev + - /^v\d+\.\d+(\.\d+)?(-\S*)?$/ + +cache: + directories: + - "node_modules" + - "server/node_modules" + +install: +- npm install --devDependencies + +before_script: +- npm run compile + +script: +- npm run lint +- npm run test:coverage + +after_success: +- bash <(curl -s https://codecov.io/bash) diff --git a/.vscode/settings.json b/.vscode/settings.json index 2987b827..49e05f55 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -19,7 +19,7 @@ ], "editor.tabSize": 4 }, - "mocha.files.glob": "test/**/*.ts", + "mocha.files.glob": "test/**/*.test.ts", "mocha.options": { "recursive": true }, diff --git a/CHANGELOG.md b/CHANGELOG.md index e2912b5c..77719d6b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). ## [Unreleased] +### Changed +- How completions and signatures are generated behind the scenes, resulting in a lower memory footprint. +### Fixed +- Fixed document unregistration in `tspManager` if it lacked a shebang. +- Corrected the completion label for `status.condition`. +- Removed unnecessary asterisk escapes. +- Added missing `smu.interlock` and `trigger.model` 2450 commands. -## [0.4.0] - 2018-09-07 +## 0.4.0 - 2018-09-07 ### Added - Model 2450 support. - Lua 5.0.3 support. diff --git a/README.md b/README.md index 505c07bd..6389fc80 100644 --- a/README.md +++ b/README.md @@ -14,15 +14,9 @@ After installation, if you have not restarted VSCode, you may have to manually s ## Supported Instruments -Release builds are available as VSIX files in the [Releases](https://github.com/tektronixofficial/vscode-tsplang/releases) section and currently support these instrument models: +Release builds are available as VSIX files in the [Releases](https://github.com/tektronixofficial/vscode-tsplang/releases) section. Currently supported instrument models include: * 2450 -Developer builds include all instruments supported in Release builds in addition to these instrument models: -* 2460 -* 2461 -* 2461-SYS -* 6500 - ## Contribute See a typo? Know how to fix an issue? Implement a requested feature? diff --git a/package-lock.json b/package-lock.json index e8dda278..ec40a426 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "tsplang", - "version": "0.3.0", + "version": "0.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index a46cf4b8..4311f07d 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "tsplang", "displayName": "TSPLang", "description": "Keithley Instruments TSP® language extension for Visual Studio Code", - "version": "0.4.0", + "version": "0.4.1", "preview": true, "publisher": "Keithley", "license": "Apache-2.0", @@ -76,6 +76,8 @@ "watch:server": "cd server && npm run install-server && cd .. && tsc -w -p server/tsconfig.json" }, "nyc": { + "all": true, + "clean": true, "extension": [ ".ts", ".tsx" @@ -89,13 +91,15 @@ "./coverage/**", "./out/**", "./client/**", - "./src/extension.ts" + "./src/extension.ts", + "./server/src/instrument/2460/*", + "./server/src/instrument/2461/*", + "./server/src/instrument/6500/*", + "./server/src/instrument/raw-tsb-help/*" ], "reporter": [ - "html", - "text", - "mocha" - ], - "all": true + "mocha", + "text" + ] } } diff --git a/server/package-lock.json b/server/package-lock.json index 19058433..8d353de4 100644 --- a/server/package-lock.json +++ b/server/package-lock.json @@ -1,6 +1,6 @@ { "name": "tsplang", - "version": "0.3.0", + "version": "0.4.1", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/server/package.json b/server/package.json index 60ab154f..c88dfb66 100644 --- a/server/package.json +++ b/server/package.json @@ -2,7 +2,7 @@ "name": "tsplang", "displayName": "TSPLang", "description": "Keithley Instruments TSP® language extension for Visual Studio Code", - "version": "0.4.0", + "version": "0.4.1", "publisher": "Keithley", "license": "Apache-2.0", "engines": { diff --git a/server/src/contentParser.ts b/server/src/contentParser.ts new file mode 100644 index 00000000..0cfa2d7e --- /dev/null +++ b/server/src/contentParser.ts @@ -0,0 +1,272 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, Position, SignatureHelp, SignatureInformation, TextDocuments } from 'vscode-languageserver' + +import { resolveCompletionNamespace } from './instrument/provider' +import { TspItem } from './tspManager' + +export class ContentParser { + lastCompletionUri?: string + + private readonly documents: TextDocuments + private namespaceRegexp: RegExp = new RegExp(/^[a-zA-Z0-9\[\].]*/) + private tableIndexRegexp: RegExp = new RegExp(/\[[0-9]\]/g) + + constructor(documents: TextDocuments) { + this.documents = documents + } + + getCompletionDoc = (item: CompletionItem, tspItem: TspItem): CompletionItem => { + const result: CompletionItem = item + + // We cannot provide completion documentation if none exist + if (tspItem.commandSet.completionDocs.size === 0) { + return result + } + + // Only service those CompletionItems whose "documentation" property is undefined + if (result.documentation === undefined) { + const commandDoc = tspItem.commandSet.completionDocs.get(resolveCompletionNamespace(result)) + + if (commandDoc === undefined) { + return result + } + + result.documentation = { + kind: commandDoc.kind, + value: commandDoc.toString(tspItem.commandSet.specification) + } + } + + return result + } + + getCompletions(uri: string, position: Position, tspItem: TspItem): Array | undefined { + // Save the last uri that asked us for a list of completions + this.lastCompletionUri = uri + + // We cannot provide completions if none exist + if (tspItem.commandSet.completions.length === 0) { + return + } + + const content = this.documents.get(this.lastCompletionUri) + + if (content === undefined) { + return + } + + const contentText = content.getText() + + // Convert the current Position to a zero-based offset + const offset: number = content.offsetAt(position) + + // Get all text before the cursor offset, reverse it, and match against it. + // Reversing allows for a simpler regular expression since the match + // will start at the beginning of the string. + const reverseMatches = this.reverse(contentText.slice(0, offset)).match(this.namespaceRegexp) + + if (reverseMatches === null) { + return + } + + const results: Array = new Array() + + let firstMatch = reverseMatches.shift() + + // Show root namespace completions if we did not match against a namespace + if (firstMatch === undefined || firstMatch === '') { + for (const completion of tspItem.commandSet.completions) { + // Root namespaces have an undefined "data" property + if (completion.data === undefined) { + results.push(completion) + } + } + + return results + } + + let endingQualifier = false + + // Remove any trailing namespace qualifiers ("."). + // Since the string is reversed, this is index 0. + if (firstMatch.indexOf('.') === 0) { + firstMatch = firstMatch.slice(1) + endingQualifier = true + + // Return if we just deleted the entire string + if (firstMatch.length === 0) { + return + } + } + + // Un-reverse the string and remove any table indexers + const unreversed = this.reverse(firstMatch.replace(this.tableIndexRegexp, '')) + // Split the unreversed string on namespace qualifiers and reverse the resulting array + const reverseNamespaceArray: Array = unreversed.split('.').reverse() + + for (const completion of tspItem.commandSet.completions) { + // Use the "data" property if it exists... + if (completion.data !== undefined) { + if (completion.data.join('.') === reverseNamespaceArray.join('.')) { + results.push(completion) + } + } + // ...otherwise this completion should be treated as a root namespace. + else { + // Do not include a root namespace in our results if the last character + // of the user's current namespace is a namespace qualifier. + // Suggest the foo module on a "foo" match but not on a "foo." match. + if (endingQualifier) { + continue + } + + // Partial match against the "label" property + const partialMatches = completion.label.match(reverseNamespaceArray.join('.')) + + if (partialMatches === null) { + continue + } + + const partial = partialMatches.shift() + if (partial !== undefined && partial.length !== 0) { + results.push(completion) + } + } + } + + return results + } + + getSignatures(uri: string, position: Position, tspItem: TspItem): SignatureHelp | undefined { + // We cannot provide signatures if none exist + if (tspItem.commandSet.signatures.length === 0) { + return + } + + const content = this.documents.get(uri) + + if (content === undefined) { + return + } + + const contentText = content.getText() + + // Convert the current Position to a zero-based offset + const offset: number = content.offsetAt(position) + // Get the document offset of the nearest open-parenthesis to the left of the cursor offset + const openParenOffset = contentText.lastIndexOf('(', offset) + // Get the document offset of the nearest close-parenthesis to the right of the cursor offset + const closeParenOffset = contentText.indexOf(')', offset) + + // Do not provide signature help if we cannot find a closing parenthesis + if (closeParenOffset === -1) { + return + } + + // Do not provide signature help if the cursor moves outside of a parenthesis-pair + if (offset <= openParenOffset || offset > closeParenOffset) { + return + } + + // Get all text before the open-parenthesis offset, reverse it, and remove leading horizontal spaces + const reverse = this.reverse(contentText.slice(0, openParenOffset)).replace(/^\s*/, '') + // Match against the reversed string. + const reverseMatches = reverse.match(this.namespaceRegexp) + + if (reverseMatches === null) { + return + } + + const firstMatch = reverseMatches.shift() + + if (firstMatch === undefined) { + return + } + + // Un-reverse the string and remove digits inside of table indexers + const unreversed = this.reverse(firstMatch).replace(this.tableIndexRegexp, '[]') + + const results: Array = new Array() + + for (const fullSignature of tspItem.commandSet.signatures) { + // Get the namespace of the signature before the first open-parenthesis + const signature: string = fullSignature.label.slice(0, fullSignature.label.indexOf('(')) + + // Only add signatures if they are an exact match + if (signature.localeCompare(unreversed) === 0) { + results.push(fullSignature) + } + } + + const commaIndices: Array = new Array() + + // Get the index of each comma between our parentheses offsets. + // Starting i is the character following the open parenthesis. + // Breaks when the i reaches the closing parenthesis. + for (let i = openParenOffset + 1; i < closeParenOffset;) { + // Find the index of the nearest comma to the right of i + const commaIndex = contentText.indexOf(',', i) + + // Break if no more commas can be found or if the next index lies outside our parentheses + if (commaIndex === -1 || commaIndex > closeParenOffset) { + break + } + + // If this comma is located to the right of i + if (commaIndex >= i) { + commaIndices.push(commaIndex) + // Next time, start searching one after the index of this comma to prevent + // indexOf from matching it again. + i = commaIndex + 1 + } + } + + // The zero-based index of the parameter to highlight and show documentation for + let active = 0 + + // For each comma index, increment the active parameter until the current offset + // is greater than the current comma index. + commaIndices.forEach((index: number) => { + if (offset > index) { + active++ + } + else { + return + } + }) + + return { + activeParameter: active, + activeSignature: 0, + signatures: results + } + } + + /** + * Reverse the given string. + * @param value - The string to reverse. + * @returns The given string in reverse order. + */ + private reverse = (value: string): string => { + // Convert the string to an array of characters, + // Reverse the array of characters + // Convert the array to a string + return value.split('').reverse().join('') + } +} diff --git a/server/src/instrument/2450/beeper.ts b/server/src/instrument/2450/beeper.ts deleted file mode 100644 index e4135d2f..00000000 --- a/server/src/instrument/2450/beeper.ts +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const beeperCompletions: Array = [ - { - kind: CompletionItemKind.Module, - label: 'beeper' - }, - { - data: ['beeper'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction beep(duration, frequency)\n```\n\nbeeper.beep(duration, frequency)\n\ -\n\ -You can use the beeper of the instrument to provide an audible signal at a specific frequency and time duration.\n\ -\n\ -Using this function from a remote interface does not affect audible errors or key click settings that were made from \ -the front panel.' - }, - kind: CompletionItemKind.Function, - label: 'beep' - }, -] - -const beeperSignatures: Array = [ - SignatureInformation.create( - 'beeper.beep(duration, frequency)', - undefined, - ParameterInformation.create( - 'duration', - 'The amount of time to play the tone (0.001 to 100s).' - ), - ParameterInformation.create( - 'frequency', - 'The frequency of the beep (20 to 8000 Hz).' - ), - ), -] - -export async function getBeeperCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(beeperCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getBeeperSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(beeperSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/buffer-write.ts b/server/src/instrument/2450/buffer-write.ts deleted file mode 100644 index e2cff1d9..00000000 --- a/server/src/instrument/2450/buffer-write.ts +++ /dev/null @@ -1,194 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -/* TODO: buffer.write.reading parameter 'status' is not helpful */ - -const bufferWriteCompletions: Array = [ - { - data: ['buffer'], - kind: CompletionItemKind.Module, - label: 'write' - }, - { - data: ['write', 'buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction format(bufferVar, units, displayDigits, extraUnits, extraDigits)\n```\n\ -\n\ -buffer.write.format(bufferVar, buffer.UNIT_\\*, buffer.DIGITS_\\*[, extraUnits][, extraDigits])\n\ -\n\ -Set the units and number of digits of readings written to the specified WRITABLE or WRITABLE_FULL buffer.\n\ -\n\ -Defines the units and the number of digits that are reported for the data. This function affects how the data is \ -shown in the reading buffer and what is shown on the front‑panel Home, Histogram, Reading Table, and Graph screens.' - }, - kind: CompletionItemKind.Function, - label: 'format' - }, - { - data: ['write', 'buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction reading(bufferVar, readingValue, seconds, fractionalSeconds, status)\n```\n\ -\n\ -buffer.write.reading(bufferVar, readingValue[, seconds][, fractionalSeconds][, status])\n\ -\n\ -Write readings into the specified WRITABLE or WRITABLE_FULL buffer.\n\ -\n\ -Data must be added in chronological order. If the time is not specified for a reading, it is set to one integer \ -second after the last reading. As you write the data, the front‑panel Home screen updates and displays the reading \ -you entered.' - }, - kind: CompletionItemKind.Function, - label: 'reading' - }, -] - -const bufferWriteSignatures: Array = [ - SignatureInformation.create( - 'buffer.write.format(bufferVar, units, displayDigits[, extraUnits][, extraDigits])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the buffer.' - ), - ParameterInformation.create( - 'units', - 'One of:\n\ -buffer.UNIT_AMP\n\ -buffer.UNIT_AMP_AC\n\ -buffer.UNIT_CELSIUS\n\ -buffer.UNIT_DECIBEL\n\ -buffer.UNIT_FAHRENHEIT\n\ -buffer.UNIT_FARAD\n\ -buffer.UNIT_HERTZ\n\ -buffer.UNIT_KELVIN\n\ -buffer.UNIT_NONE\n\ -buffer.UNIT_OHM\n\ -buffer.UNIT_PERCENT\n\ -buffer.UNIT_RATIO\n\ -buffer.UNIT_RECIPROCAL\n\ -buffer.UNIT_SECOND\n\ -buffer.UNIT_VOLT\n\ -buffer.UNIT_VOLT_AC\n\ -buffer.UNIT_WATT\n\ -buffer.UNIT_X.' - ), - ParameterInformation.create( - 'displayDigits', - 'The number of digits to use for the first measurement. One of:\n\ -buffer.DIGITS_3_5\n\ -buffer.DIGITS_4_5\n\ -buffer.DIGITS_5_5\n\ -buffer.DIGITS_6_5\n\ -buffer.DIGITS_7_5\n\ -buffer.DIGITS_8_5' - ), - ParameterInformation.create( - 'extraUnits', - 'The units for the second measurement in the buffer index; the selections are the same as units (only \ -valid for buffer style WRITABLE_FULL); if not specified, will use the value for units.' - ), - ParameterInformation.create( - 'extraDigits', - 'The number of digits to use for the second measurement; the selections are the same as displayDigits \ -(only valid for buffer style WRITABLE_FULL); if not specified, will use the value for displayDigits.' - ), - ), - SignatureInformation.create( - 'buffer.write.reading(bufferVar, readingValue[, seconds][, fractionalSeconds][, status])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the buffer.' - ), - ParameterInformation.create( - 'readingValue', - 'The first value that is recorded in the buffer index.' - ), - ParameterInformation.create( - 'seconds', - 'An integer that repesents the seconds.' - ), - ParameterInformation.create( - 'fractionalSeconds', - 'The portion of the time that represents the fractional seconds.' - ), - ParameterInformation.create( - 'status', - 'The reading that is the start of a group of readings: buffer.STAT_START_GROUP; set to 256 to graph a \ -family of curves (default is 0).' - ), - ), - SignatureInformation.create( - 'buffer.write.reading(bufferVar, readingValue[, extraValue][, seconds][, fractionalSeconds][, status])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the buffer.' - ), - ParameterInformation.create( - 'readingValue', - 'The first value that is recorded in the buffer index.' - ), - ParameterInformation.create( - 'extraValue', - 'A second value that is recorded in the buffer index (only valid for buffer style WRITABLE_FULL).' - ), - ParameterInformation.create( - 'seconds', - 'An integer that repesents the seconds.' - ), - ParameterInformation.create( - 'fractionalSeconds', - 'The portion of the time that represents the fractional seconds.' - ), - ParameterInformation.create( - 'status', - 'The reading that is the start of a group of readings: buffer.STAT_START_GROUP; set to 256 to graph a \ -family of curves (default is 0).' - ), - ), -] - -export async function getBufferWriteCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(bufferWriteCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getBufferWriteSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(bufferWriteSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/buffer.ts b/server/src/instrument/2450/buffer.ts deleted file mode 100644 index a939cfba..00000000 --- a/server/src/instrument/2450/buffer.ts +++ /dev/null @@ -1,266 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const bufferCompletions: Array = [ - { - kind: CompletionItemKind.Module, - label: 'buffer' - }, - { - data: ['buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction clearstats(bufferVar)\n```\n\nbuffer.clearstats([bufferVar])\n\ -\n\ -Clear the statistical information associated with the specified buffer without clearing the readings.' - }, - kind: CompletionItemKind.Function, - label: 'clearstats' - }, - { - data: ['buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction delete(bufferName)\n```\n\nbuffer.delete(bufferName)\n\ -\n\ -Delete the specified, user-defined reading buffer.\n\ -\n\ -You cannot delete the default reading buffers, defbuffer1 and defbuffer2.' - }, - kind: CompletionItemKind.Function, - label: 'delete' - }, - { - data: ['buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction getstats(bufferVar)\n```\n\ -\n\ -buffer.getstats([bufferVar]) -> {max, mean, min, n, stddev}\n\ -\n\ -Returns a statistics table from the specified reading buffer.\n\ -\n\ -The stats table always has the entry "n" (number of data points).\n\ -\n\ -If n is greater than 0, then the stats table has the entries \ -"mean" (average reading), \ -"max" (subtable containing max value data), and \ -"min" (subtable containing min value data).\n\ -\n\ -The max and min subtables contain the entries "reading", "timestamp", "seconds", and "fractionalseconds".\n\ -\n\ -If n is greater than 1, then the stats table has the entry "stddev" (standard deviation).\n\ -\n\ -When the reading buffer is configured to fill continuously and overwrite older data with new data, the buffer \ -statistics include the data that was overwritten.' - }, - kind: CompletionItemKind.Function, - label: 'getstats' - }, - { - data: ['buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction make(bufferSize, style)\n```\n\ -\n\ -buffer.make(bufferSize[, buffer.STYLE_\\*]) -> bufferVar\n\ -\n\ -Create a user-defined reading buffer and set it as the active buffer.\n\ -\n\ -Newly created user-defined buffers have a default fill mode of FILL_ONCE.\n\ -\n\ -If you create a reading buffer that has the same name as an existing user-defined buffer, the existing buffer is \ -overwritten by the new buffer. Any data in the existing buffer is lost.\n\ -\n\ -You cannot assign user-defined reading buffers the name defbuffer1 and defbuffer2.' - }, - kind: CompletionItemKind.Function, - label: 'make' - }, - { - data: ['buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction save(bufferVar, fileName, timeFormat, start, end)\n```\n\ -\n\ -buffer.save(bufferVar, fileName[, buffer.SAVE_\\*][, start, end])\n\ -\n\ -Save data from the specified reading buffer to a USB flash drive.\n\ -\n\ -The filename must specify the full path (including /usb1/). If included, the file extension must be set to .csv (if \ -no file extension is specified, .csv is added).\n\ -\n\ -Verify that you are using a unique name to avoid overwriting any existing .csv files on the flash drive.' - }, - kind: CompletionItemKind.Function, - label: 'save' - }, - { - data: ['buffer'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction saveappend(bufferVar, fileName, timeFormat, start, end)\n```\n\ -\n\ -buffer.saveappend(bufferVar, fileName[, buffer.SAVE_\\*][, start, end])\n\ -\n\ -Append data from the specified reading buffer to a file on the USB flash drive or create the file if it does not \ -exist.\n\ -\n\ -The index column entry in the .csv file starts at 1 for each append operation.' - }, - kind: CompletionItemKind.Function, - label: 'saveappend' - }, -] - -const bufferSignatures: Array = [ - SignatureInformation.create( - 'buffer.clearstats([bufferVar])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1 if not specified.' - ), - ), - SignatureInformation.create( - 'buffer.delete(bufferName)', - undefined, - ParameterInformation.create( - 'bufferName', - 'The name of a user‑defined reading buffer.' - ), - ), - SignatureInformation.create( - 'buffer.getstats([bufferVar])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1 if not specified.' - ), - ), - SignatureInformation.create( - 'buffer.make(bufferSize[, style])', - undefined, - ParameterInformation.create( - 'bufferSize', - 'The maximum number of readings that can be stored in bufferVar; minimum is 10.' - ), - ParameterInformation.create( - 'style', - 'The type of reading buffer to create. One of:\n\ -buffer.STYLE_STANDARD (default)\n\ -buffer.STYLE_COMPACT\n\ -buffer.STYLE_FULL\n\ -buffer.STYLE_WRITABLE\n\ -buffer.STYLE_WRITABLE_FULL\n\ -\n\ -Once the first reading is stored in a COMPACT buffer, its range, display digits, and units cannot be changed.\n\ -\n\ -WRITABLE buffers are used to import external data and cannot be used to collect readings from the instrument.' - ), - ), - SignatureInformation.create( - 'buffer.save(bufferVar, fileName[, timeFormat][, start, end])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer.' - ), - ParameterInformation.create( - 'fileName', - 'A string that indicates the name of the file on the USB flash drive in which to save the reading buffer.' - ), - ParameterInformation.create( - 'timeFormat', - 'Defines how date and time information from the buffer is saved in the file on the USB flash drive; \ -one of:\n\ -buffer.SAVE_FORMAT_TIME (dates, times, and fractional seconds)\n\ -buffer.SAVE_RAW_TIME (seconds and fractional seconds)\n\ -buffer.SAVE_RELATIVE_TIME (relative timestamps)\n\ -buffer.SAVE_TIMESTAMP_TIME (timestamps).' - ), - ParameterInformation.create( - 'start', - 'Defines the starting point in the buffer to start saving data.' - ), - ParameterInformation.create( - 'end', - 'Defines the ending point in the buffer to stop saving data.' - ), - ), - SignatureInformation.create( - 'buffer.saveappend(bufferVar, fileName[, timeFormat][, start, end])', - undefined, - ParameterInformation.create( - 'bufferVar', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer.' - ), - ParameterInformation.create( - 'fileName', - 'A string that indicates the name of the file on the USB flash drive in which to save the reading buffer.' - ), - ParameterInformation.create( - 'timeFormat', - 'Defines how date and time information from the buffer is saved in the file on the USB flash drive; \ -one of:\n\ -buffer.SAVE_FORMAT_TIME (dates, times, and fractional seconds)\n\ -buffer.SAVE_RAW_TIME (seconds and fractional seconds)\n\ -buffer.SAVE_RELATIVE_TIME (relative timestamps)\n\ -buffer.SAVE_TIMESTAMP_TIME (timestamps).' - ), - ParameterInformation.create( - 'start', - 'Defines the starting point in the buffer to start saving data.' - ), - ParameterInformation.create( - 'end', - 'Defines the ending point in the buffer to stop saving data.' - ), - ), -] - -export async function getBufferCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(bufferCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getBufferSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(bufferSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/createconfigscript.ts b/server/src/instrument/2450/createconfigscript.ts deleted file mode 100644 index c7bda53f..00000000 --- a/server/src/instrument/2450/createconfigscript.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const createconfigscriptCompletions: Array = [ - { - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction createconfigscript(scriptName)\n```\n\ncreateconfigscript(scriptName)\n\ -\n\ -Create a setup file that captures most of the present settings of the instrument.\n\ -\n\ -If scriptName is set to the name of an existing script, an eventlog message is returned.\n\ -\n\ -Once created, the script that contains the settings can be run and edited like any other script.' - }, - kind: CompletionItemKind.Function, - label: 'createconfigscript', - }, -] - -const createconfigscriptSignatures: Array = [ - SignatureInformation.create( - 'createconfigscript(scriptName)', - undefined, - ParameterInformation.create( - 'scriptName', - 'A string that represents the name of the script that will be created.' - ), - ), -] - -export async function getCreateconfigscriptCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void): void => { - try { - resolve(createconfigscriptCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - - }) -} - -export async function getCreateconfigscriptSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(createconfigscriptSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/delay.ts b/server/src/instrument/2450/delay.ts deleted file mode 100644 index 4120065a..00000000 --- a/server/src/instrument/2450/delay.ts +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const delayCompletions: Array = [ - { - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction delay(seconds)\n```\n\ndelay([seconds])\n\ -\n\ -Delay execution for at least the specified number of seconds and fractional seconds.\n\ -\n\ -However, the processing time may cause the instrument to delay 5μs to 10μs more than the requested delay.' - }, - kind: CompletionItemKind.Function, - label: 'delay', - }, -] - -const delaySignatures: Array = [ - SignatureInformation.create( - 'delay([seconds])', - undefined, - ParameterInformation.create( - 'seconds', - 'The number of seconds to delay (0 to 100 ks).' - ), - ), -] - -export async function getDelayCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(delayCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getDelaySignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(delaySignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/display-input.ts b/server/src/instrument/2450/display-input.ts deleted file mode 100644 index 6cfb460a..00000000 --- a/server/src/instrument/2450/display-input.ts +++ /dev/null @@ -1,244 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const displayInputCompletions: Array = [ - { - data: ['display'], - kind: CompletionItemKind.Module, - label: 'input' - }, - { - data: ['input', 'display'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction number(dialogTitle, numberFormat, defaultValue, minimumValue, maximumValue)\n\ -```\n\ -\n\ -display.input.number(dialogTitle[, display.NFORMAT_\\*][, defaultValue][, minimumValue][, maximumValue]) -> \ -number | nil\n\ -\n\ -Display a number prompt and return the number entered from the front-panel; nil if Cancel is pressed.\n\ -\n\ -The prompt is displayed until it has been responded to.' - }, - kind: CompletionItemKind.Function, - label: 'number', - }, - { - data: ['input', 'display'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\n\ -function option(dialogTitle, buttonTitle1, buttonTitle2, buttonTitle3, buttonTitle4, buttonTitle5, buttonTitle6, \ -buttonTitle7, buttonTitle8, buttonTitle9, buttonTitle10)\n\ -```\n\ -\n\ -display.input.option(dialogTitle, buttonTitle1, buttonTitle2[, buttonTitle3][, buttonTitle4][, buttonTitle5][, \ -buttonTitle6][, buttonTitle7][, buttonTitle8][, buttonTitle9][, buttonTitle10]) -> display.BUTTON_OPTION | nil\n\ -\n\ -Display a custom multi-selection prompt and return display.BUTTON_OPTION where is the one-indexed button that \ -was selected from the front-panel display; nil if Cancel is pressed.\n\ -\n\ -Buttons are created and numbered () from top to bottom, left to right. If you have more than five buttons, they \ -are placed into two columns.\n\ -\n\ -The prompt is displayed until it has been responded to.' - }, - kind: CompletionItemKind.Function, - label: 'option', - }, - { - data: ['input', 'display'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction prompt(buttonSet, dialogTitle)\n```\n\ -\n\ -display.input.prompt(display.BUTTONS_\\*, dialogTitle) -> display.BUTTON_CANCEL | BUTTON_NO | BUTTON_OK | BUTTON_YES\n\ -\n\ -Display a simple multi-selection prompt and return the button selected from the front-panel. For a non-blocking \ -prompt, see display.prompt().\n\ -\n\ -The prompt is displayed until it has been responded to by the user.' - }, - kind: CompletionItemKind.Function, - label: 'prompt', - }, - { - data: ['input', 'display'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction string(dialogTitle, textFormat)\n```\n\ -\n\ -display.input.string(dialogTitle[, display.SFORMAT_\\*]) -> string | nil\n\ -\n\ -Display a string prompt and return the text entered from the front-panel; nil if Cancel is pressed.\n\ -\n\ -The prompt is displayed until it has been responded to.' - }, - kind: CompletionItemKind.Function, - label: 'string', - }, -] - -const displayInputSignatures: Array = [ - SignatureInformation.create( - 'display.input.number(dialogTitle[, numberFormat][, defaultValue][, minimumValue][, maximumValue])', - undefined, - ParameterInformation.create( - 'dialogTitle', - 'A string that contains the text to be displayed as the title of the dialog box on the front-panel \ -display; can be up to 32 characters.' - ), - ParameterInformation.create( - 'numberFormat', - 'One of:\n\ -display.NFORMAT_INTEGER (default)\n\ -display.NFORMAT_DECIMAL\n\ -display.NFORMAT_EXPONENT\n\ -display.NFORMAT_PREFIX' - ), - ParameterInformation.create( - 'defaultValue', - 'Value that is initially displayed in the displayed keypad.' - ), - ParameterInformation.create( - 'minimumValue', - 'The lowest value that can be entered.' - ), - ParameterInformation.create( - 'maximumValue', - 'The highest value that can be entered.' - ), - ), - SignatureInformation.create( - 'display.input.option(dialogTitle, buttonTitle1, buttonTitle2[, buttonTitle3][, buttonTitle4][, \ -buttonTitle5][, buttonTitle6][, buttonTitle7][, buttonTitle8][, buttonTitle9][, buttonTitle10])', - undefined, - ParameterInformation.create( - 'dialogTitle', - 'A string that contains the text to be displayed as the title of the dialog box on the front-panel \ -display; can be up to 32 characters.' - ), - ParameterInformation.create( - 'buttonTitle1', - 'A string that contains the name of the first button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle2', - 'A string that contains the name of the second button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle2', - 'A string that contains the name of the second button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle3', - 'A string that contains the name of the third button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle4', - 'A string that contains the name of the fourth button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle5', - 'A string that contains the name of the fifth button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle6', - 'A string that contains the name of the sixth button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle7', - 'A string that contains the name of the seventh button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle8', - 'A string that contains the name of the eighth button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle9', - 'A string that contains the name of the ninth button; up to 15 characters.' - ), - ParameterInformation.create( - 'buttonTitle10', - 'A string that contains the name of the tenth button; up to 15 characters.' - ), - ), - SignatureInformation.create( - 'display.input.prompt(buttonSet[, dialogTitle])', - undefined, - ParameterInformation.create( - 'buttonSet', - 'One of:\n\ -display.BUTTONS_OK\n\ -display.BUTTONS_CANCEL\n\ -display.BUTTONS_OKCANCEL\n\ -display.BUTTONS_YESNO\n\ -display.BUTTONS_YESNOCANCEL' - ), - ParameterInformation.create( - 'dialogTitle', - 'A string that contains the text to be displayed as the title of the dialog box on the front-panel \ -display; can be up to 127 characters.' - ), - ), - SignatureInformation.create( - 'display.input.string(dialogTitle[, textFormat])', - undefined, - ParameterInformation.create( - 'dialogTitle', - 'A string that contains the text to be displayed as the title of the dialog box on the front-panel \ -display; can be up to 32 characters.' - ), - ParameterInformation.create( - 'textFormat', - 'One of:\n\ -display.SFORMAT_ANY (default)\n\ -display.SFORMAT_UPPER_LOWER\n\ -display.SFORMAT_UPPER\n\ -display.SFORMAT_BUFFER_NAME' - ), - ), -] - -export async function getDisplayInputCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(displayInputCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getDisplayInputSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(displayInputSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/index.ts b/server/src/instrument/2450/index.ts index 45f7ff00..c2ea3d50 100644 --- a/server/src/instrument/2450/index.ts +++ b/server/src/instrument/2450/index.ts @@ -13,205 +13,1071 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { CompletionItem, SignatureInformation } from 'vscode-languageserver' - -import { getBeeperCompletions, getBeeperSignatures } from './beeper' -import { getBufferCompletions, getBufferSignatures } from './buffer' -import { getBufferEnumCompletions } from './buffer-enums' -import { getBufferWriteCompletions, getBufferWriteSignatures } from './buffer-write' -import { getBufferVarCompletions } from './bufferVar' -import { getCreateconfigscriptCompletions, getCreateconfigscriptSignatures } from './createconfigscript' -import { getDataqueueCompletions, getDataqueueSignatures } from './dataqueue' -import { getDelayCompletions, getDelaySignatures } from './delay' -import { getDigioCompletions, getDigioSignatures } from './digio' -import { getDigioEnumCompletions } from './digio-enums' -import { getDigioLineCompletions } from './digio-line' -import { getDisplayCompletions, getDisplaySignatures } from './display' -import { getEventlogCompletions, getEventlogSignatures } from './eventlog' -import { getEventlogEnumCompletions } from './eventlog-enums' -import { getExitCompletions } from './exit' -import { getFileCompletions } from './file' -import { getFileEnumCompletions } from './file-enums' -import { getFormatCompletions } from './format' -import { getFormatEnumCompletions } from './format-enums' -import { getGpibCompletions } from './gpib' -import { getLanCompletions, getLanSignatures } from './lan' -import { getLanEnumCompletions } from './lan-enums' -import { getLocalnodeCompletions, getLocalnodeSignatures } from './localnode' -import { getLocalnodeEnumCompletions } from './localnode-enums' -import { getNodeCompletions, getNodeSignatures } from './node' -import { getOpcCompletions } from './opc' -import { getPrintbufferCompletions, getPrintbufferSignatures } from './printbuffer' -import { getPrintnumberCompletions, getPrintnumberSignatures } from './printnumber' -import { getResetCompletions, getResetSignatures } from './reset' -import { getScriptCompletions, getScriptSignatures } from './script' -import { getScriptVarCompletions, getScriptVarSignatures } from './scriptVar' -import { getSmuCompletions } from './smu' -import { getSmuEnumCompletions } from './smu-enums' -import { getSmuInterlockCompletions } from './smu-interlock' -import { getSmuMeasureCompletions, getSmuMeasureSignatures } from './smu-measure' -import { getSmuMeasureAutozeroCompletions } from './smu-measure-autozero' -import { getSmuMeasureConfiglistCompletions, getSmuMeasureConfiglistSignatures } from './smu-measure-configlist' -import { getSmuMeasureFilterCompletions } from './smu-measure-filter' -import { getSmuMeasureLimitCompletions } from './smu-measure-limit' -import { getSmuMeasureLimitHighCompletions } from './smu-measure-limit-high' -import { getSmuMeasureLimitLowCompletions } from './smu-measure-limit-low' -import { getSmuMeasureMathCompletions } from './smu-measure-math' -import { getSmuMeasureMathMxbCompletions } from './smu-measure-math-mxb' -import { getSmuMeasureRelCompletions } from './smu-measure-rel' -import { getSmuSourceCompletions, getSmuSourceSignatures } from './smu-source' -import { getSmuSourceConfiglistCompletions, getSmuSourceConfiglistSignatures } from './smu-source-configlist' -import { getSmuSourceIlimitCompletions } from './smu-source-ilimit' -import { getSmuSourceProtectCompletions } from './smu-source-protect' -import { getSmuSourceVlimitCompletions } from './smu-source-vlimit' -import { getStatusCompletions } from './status' -import { getStatusEnumCompletions } from './status-enums' -import { getStatusOperationCompletions, getStatusOperationSignatures } from './status-operation' -import { getStatusQuestionableCompletions, getStatusQuestionableSignatures } from './status-questionable' -import { getStatusStandardCompletions } from './status-standard' -import { getStatusStandardEnumCompletions } from './status-standard-enums' -import { getTimerCompletions } from './timer' -import { getTriggerCompletions, getTriggerSignatures } from './trigger' -import { getTriggerBlenderCompletions, getTriggerBlenderSignatures } from './trigger-blender' -import { getTriggerDiginCompletions, getTriggerDiginSignatures } from './trigger-digin' -import { getTriggerDigoutCompletions } from './trigger-digout' -import { getTriggerEnumCompletions } from './trigger-enums' -import { getTriggerLaninCompletions, getTriggerLaninSignatures } from './trigger-lanin' -import { getTriggerLanoutCompletions } from './trigger-lanout' -import { getTriggerModelCompletions, getTriggerModelSignatures } from './trigger-model' -import { getTriggerTimerCompletions, getTriggerTimerSignatures } from './trigger-timer' -import { getTriggerTimerStartCompletions } from './trigger-timer-start' -import { getTriggerTsplinkinCompletions, getTriggerTsplinkinSignatures } from './trigger-tsplinkin' -import { getTriggerTsplinkoutCompletions } from './trigger-tsplinkout' -import { getTsplinkCompletions, getTsplinkSignatures } from './tsplink' -import { getTsplinkEnumCompletions } from './tsplink-enums' -import { getTsplinkLineCompletions } from './tsplink-line' -import { getTspnetCompletions, getTspnetSignatures } from './tspnet' -import { getTspnetEnumCompletions } from './tspnet-enums' -import { getTspnetTspCompletions, getTspnetTspSignatures } from './tspnet-tsp' -import { getUpgradeCompletions } from './upgrade' -import { getUserstringCompletions, getUserstringSignatures } from './userstring' -import { getWaitcompleteCompletions, getWaitcompleteSignatures } from './waitcomplete' - -const completions2450: Array = new Array() -const signatures2450: Array = new Array() - -export async function get2450Completions(): Promise> { - return completions2450 - .concat(await getBeeperCompletions()) - .concat(await getBufferCompletions()) - .concat(await getBufferEnumCompletions()) - .concat(await getBufferWriteCompletions()) - .concat(await getBufferVarCompletions()) - .concat(await getCreateconfigscriptCompletions()) - .concat(await getDataqueueCompletions()) - .concat(await getDelayCompletions()) - .concat(await getDigioCompletions()) - .concat(await getDigioEnumCompletions()) - .concat(await getDigioLineCompletions()) - .concat(await getDisplayCompletions()) - .concat(await getEventlogCompletions()) - .concat(await getEventlogEnumCompletions()) - .concat(await getExitCompletions()) - .concat(await getFileCompletions()) - .concat(await getFileEnumCompletions()) - .concat(await getFormatCompletions()) - .concat(await getFormatEnumCompletions()) - .concat(await getGpibCompletions()) - .concat(await getLanCompletions()) - .concat(await getLanEnumCompletions()) - .concat(await getLocalnodeCompletions()) - .concat(await getLocalnodeEnumCompletions()) - .concat(await getNodeCompletions()) - .concat(await getOpcCompletions()) - .concat(await getPrintbufferCompletions()) - .concat(await getPrintnumberCompletions()) - .concat(await getResetCompletions()) - .concat(await getScriptCompletions()) - .concat(await getScriptVarCompletions()) - .concat(await getSmuCompletions()) - .concat(await getSmuEnumCompletions()) - .concat(await getSmuInterlockCompletions()) - .concat(await getSmuMeasureAutozeroCompletions()) - .concat(await getSmuMeasureCompletions()) - .concat(await getSmuMeasureConfiglistCompletions()) - .concat(await getSmuMeasureFilterCompletions()) - .concat(await getSmuMeasureLimitCompletions()) - .concat(await getSmuMeasureLimitHighCompletions()) - .concat(await getSmuMeasureLimitLowCompletions()) - .concat(await getSmuMeasureMathCompletions()) - .concat(await getSmuMeasureMathMxbCompletions()) - .concat(await getSmuMeasureRelCompletions()) - .concat(await getSmuSourceCompletions()) - .concat(await getSmuSourceConfiglistCompletions()) - .concat(await getSmuSourceIlimitCompletions()) - .concat(await getSmuSourceProtectCompletions()) - .concat(await getSmuSourceVlimitCompletions()) - .concat(await getStatusCompletions()) - .concat(await getStatusEnumCompletions()) - .concat(await getStatusOperationCompletions()) - .concat(await getStatusQuestionableCompletions()) - .concat(await getStatusStandardCompletions()) - .concat(await getStatusStandardEnumCompletions()) - .concat(await getTimerCompletions()) - .concat(await getTriggerCompletions()) - .concat(await getTriggerBlenderCompletions()) - .concat(await getTriggerDiginCompletions()) - .concat(await getTriggerDigoutCompletions()) - .concat(await getTriggerEnumCompletions()) - .concat(await getTriggerLaninCompletions()) - .concat(await getTriggerLanoutCompletions()) - .concat(await getTriggerModelCompletions()) - .concat(await getTriggerTimerCompletions()) - .concat(await getTriggerTimerStartCompletions()) - .concat(await getTriggerTsplinkinCompletions()) - .concat(await getTriggerTsplinkoutCompletions()) - .concat(await getTsplinkCompletions()) - .concat(await getTsplinkEnumCompletions()) - .concat(await getTsplinkLineCompletions()) - .concat(await getTspnetCompletions()) - .concat(await getTspnetEnumCompletions()) - .concat(await getTspnetTspCompletions()) - .concat(await getUpgradeCompletions()) - .concat(await getUserstringCompletions()) - .concat(await getWaitcompleteCompletions()) -} - -export async function get2450Signatures(): Promise> { - return signatures2450 - .concat(await getBeeperSignatures()) - .concat(await getBufferSignatures()) - .concat(await getBufferWriteSignatures()) - .concat(await getCreateconfigscriptSignatures()) - .concat(await getDataqueueSignatures()) - .concat(await getDelaySignatures()) - .concat(await getDigioSignatures()) - .concat(await getDisplaySignatures()) - .concat(await getEventlogSignatures()) - .concat(await getLanSignatures()) - .concat(await getLocalnodeSignatures()) - .concat(await getNodeSignatures()) - .concat(await getPrintbufferSignatures()) - .concat(await getPrintnumberSignatures()) - .concat(await getResetSignatures()) - .concat(await getScriptSignatures()) - .concat(await getScriptVarSignatures()) - .concat(await getSmuMeasureSignatures()) - .concat(await getSmuMeasureConfiglistSignatures()) - .concat(await getSmuSourceSignatures()) - .concat(await getSmuSourceConfiglistSignatures()) - .concat(await getStatusOperationSignatures()) - .concat(await getStatusQuestionableSignatures()) - .concat(await getTriggerSignatures()) - .concat(await getTriggerBlenderSignatures()) - .concat(await getTriggerDiginSignatures()) - .concat(await getTriggerLaninSignatures()) - .concat(await getTriggerModelSignatures()) - .concat(await getTriggerTimerSignatures()) - .concat(await getTriggerTsplinkinSignatures()) - .concat(await getTsplinkSignatures()) - .concat(await getTspnetSignatures()) - .concat(await getTspnetTspSignatures()) - .concat(await getUserstringSignatures()) - .concat(await getWaitcompleteSignatures()) +'use strict' + +import { ApiSpec, InstrumentSpec } from '..' +import { getLuaApiSpec } from '../lua' + +const beeper: ApiSpec = { + children: [ + { label: 'beeper.beep' }, + ], + label: 'beeper' +} + +const bufferWrite: ApiSpec = { + children: [ + { label: 'buffer.write.format' }, + { label: 'buffer.write.reading' }, + ], + label: 'buffer.write' +} + +const buffer: ApiSpec = { + children: [ + { label: 'buffer.clearstats' }, + { label: 'buffer.delete' }, + { label: 'buffer.getstats' }, + { label: 'buffer.make' }, + { label: 'buffer.save' }, + { label: 'buffer.saveappend' }, + ], + enums: [ + { label: 'buffer.DIGITS_3_5' }, + { label: 'buffer.DIGITS_4_5' }, + { label: 'buffer.DIGITS_5_5' }, + { label: 'buffer.DIGITS_6_5' }, + { label: 'buffer.DIGITS_7_5' }, + { label: 'buffer.DIGITS_3_5' }, + { label: 'buffer.FILL_CONTINUOUS' }, + { label: 'buffer.FILL_ONCE' }, + { label: 'buffer.OFF' }, + { label: 'buffer.ON' }, + { label: 'buffer.SAVE_FORMAT_TIME' }, + { label: 'buffer.SAVE_RAW_TIME' }, + { label: 'buffer.SAVE_RELATIVE_TIME' }, + { label: 'buffer.SAVE_TIMESTAMP_TIME' }, + { label: 'buffer.STAT_LIMIT' }, + { label: 'buffer.STAT_LIMIT1_HIGH' }, + { label: 'buffer.STAT_LIMIT1_LOW' }, + { label: 'buffer.STAT_LIMIT2_HIGH' }, + { label: 'buffer.STAT_LIMIT2_LOW' }, + { label: 'buffer.STAT_ORIGIN' }, + { label: 'buffer.STAT_OUTPUT' }, + { label: 'buffer.STAT_OVER_TEMP' }, + { label: 'buffer.STAT_PROTECTION' }, + { label: 'buffer.STAT_QUESTIONABLE' }, + { label: 'buffer.STAT_READBACK' }, + { label: 'buffer.STAT_SENSE' }, + { label: 'buffer.STAT_START_GROUP' }, + { label: 'buffer.STAT_TERMINAL' }, + { label: 'buffer.STYLE_COMPACT' }, + { label: 'buffer.STYLE_FULL' }, + { label: 'buffer.STYLE_STANDARD' }, + { label: 'buffer.STYLE_WRITABLE' }, + { label: 'buffer.STYLE_WRITABLE_FULL' }, + { label: 'buffer.UNIT_AMP' }, + { label: 'buffer.UNIT_AMP_AC' }, + { label: 'buffer.UNIT_CELSIUS' }, + { label: 'buffer.UNIT_DECIBEL' }, + { label: 'buffer.UNIT_FAHRENHEIT' }, + { label: 'buffer.UNIT_FARAD' }, + { label: 'buffer.UNIT_HERTZ' }, + { label: 'buffer.UNIT_KELVIN' }, + { label: 'buffer.UNIT_NONE' }, + { label: 'buffer.UNIT_OHM' }, + { label: 'buffer.UNIT_PERCENT' }, + { label: 'buffer.UNIT_RATIO' }, + { label: 'buffer.UNIT_RECIPROCAL' }, + { label: 'buffer.UNIT_SECOND' }, + { label: 'buffer.UNIT_VOLT' }, + { label: 'buffer.UNIT_VOLT_AC' }, + { label: 'buffer.UNIT_WATT' }, + { label: 'buffer.UNIT_X' }, + ], + label: 'buffer' +} + +const createconfigscript: ApiSpec = { label: 'createconfigscript' } + +const dataqueue: ApiSpec = { + children: [ + { label: 'dataqueue.add' }, + { label: 'dataqueue.CAPACITY' }, + { label: 'dataqueue.clear' }, + { label: 'dataqueue.count' }, + { label: 'dataqueue.next' }, + ], + label: 'dataqueue' +} + +const delay: ApiSpec = { label: 'delay' } + +const digioLine: ApiSpec = { + children: [ + { label: 'digio.line.mode' }, + { label: 'digio.line.reset' }, + { label: 'digio.line.state' }, + ], + label: 'digio.line' +} + +const digio: ApiSpec = { + children: [ + { label: 'digio.readport' }, + { label: 'digio.writeport' }, + ], + enums: [ + { label: 'digio.MODE_DIGITAL_IN' }, + { label: 'digio.MODE_DIGITAL_OPEN_DRAIN' }, + { label: 'digio.MODE_DIGITAL_OUT' }, + { label: 'digio.MODE_TRIGGER_IN' }, + { label: 'digio.MODE_TRIGGER_OPEN_DRAIN' }, + { label: 'digio.MODE_TRIGGER_OUT' }, + { label: 'digio.MODE_SYNCHRONOUS_ACCEPTOR' }, + { label: 'digio.MODE_SYNCHRONOUS_MASTER' }, + { label: 'digio.STATE_HIGH' }, + { label: 'digio.STATE_LOW' }, + ], + label: 'digio' +} + +const displayInput: ApiSpec = { + children: [ + { label: 'display.input.number' }, + { label: 'display.input.option' }, + { label: 'display.input.prompt' }, + { label: 'display.input.string' }, + ], + label: 'display.input' +} + +const display: ApiSpec = { + children: [ + { label: 'display.changescreen' }, + { label: 'display.clear' }, + { label: 'display.delete' }, + { label: 'display.lightstate' }, + { label: 'display.prompt' }, + { label: 'display.readingformat' }, + { label: 'display.settext' }, + { label: 'display.waitevent' }, + ], + enums: [ + { label: 'display.BUTTON_CANCEL' }, + { label: 'display.BUTTON_NO' }, + { label: 'display.BUTTON_OK' }, + { label: 'display.BUTTON_YES' }, + { label: 'display.BUTTON_OPTION1' }, + { label: 'display.BUTTON_OPTION2' }, + { label: 'display.BUTTON_OPTION3' }, + { label: 'display.BUTTON_OPTION4' }, + { label: 'display.BUTTON_OPTION5' }, + { label: 'display.BUTTON_OPTION6' }, + { label: 'display.BUTTON_OPTION7' }, + { label: 'display.BUTTON_OPTION8' }, + { label: 'display.BUTTON_OPTION9' }, + { label: 'display.BUTTON_OPTION10' }, + { label: 'display.BUTTONS_NONE' }, + { label: 'display.BUTTONS_OK' }, + { label: 'display.BUTTONS_CANCEL' }, + { label: 'display.BUTTONS_OKCANCEL' }, + { label: 'display.BUTTONS_YESNO' }, + { label: 'display.BUTTONS_YESNOCANCEL' }, + { label: 'display.FORMAT_EXPONENT' }, + { label: 'display.FORMAT_PREFIX' }, + { label: 'display.NFORMAT_DECIMAL' }, + { label: 'display.NFORMAT_EXPONENT' }, + { label: 'display.NFORMAT_INTEGER' }, + { label: 'display.NFORMAT_PREFIX' }, + { label: 'display.SCREEN_DATASHEET' }, + { label: 'display.SCREEN_GRAPH' }, + { label: 'display.SCREEN_GRAPH_SWIPE' }, + { label: 'display.SCREEN_HISTOGRAM' }, + { label: 'display.SCREEN_HOME' }, + { label: 'display.SCREEN_HOME_LARGE_READING' }, + { label: 'display.SCREEN_READING_TABLE' }, + { label: 'display.SCREEN_PLOT_SWIPE' }, + { label: 'display.SCREEN_SETTINGS_SWIPE' }, + { label: 'display.SCREEN_SOURCE_SWIPE' }, + { label: 'display.SCREEN_STATS_SWIPE' }, + { label: 'display.SCREEN_USER_SWIPE' }, + { label: 'display.SFORMAT_ANY' }, + { label: 'display.SFORMAT_UPPER' }, + { label: 'display.SFORMAT_UPPER_LOWER' }, + { label: 'display.STATE_LCD_100' }, + { label: 'display.STATE_LCD_75' }, + { label: 'display.STATE_LCD_50' }, + { label: 'display.STATE_LCD_25' }, + { label: 'display.STATE_LCD_OFF' }, + { label: 'display.STATE_BLACKOUT' }, + { label: 'display.TEXT1' }, + { label: 'display.TEXT2' }, + ], + label: 'display' +} + +const eventlog: ApiSpec = { + children: [ + { label: 'eventlog.clear' }, + { label: 'eventlog.getcount' }, + { label: 'eventlog.next' }, + { label: 'eventlog.post' }, + { label: 'eventlog.save' }, + ], + enums: [ + { label: 'eventlog.SEV_ALL' }, + { label: 'eventlog.SEV_ERROR' }, + { label: 'eventlog.SEV_INFO' }, + { label: 'eventlog.SEV_WARN' }, + ], + label: 'eventlog' +} + +const exit: ApiSpec = { label: 'exit' } + +const file: ApiSpec = { + children: [ + { label: 'file.close' }, + { label: 'file.flush' }, + { label: 'file.mkdir' }, + { label: 'file.open' }, + { label: 'file.read' }, + { label: 'file.usbdriveexists' }, + { label: 'file.write' }, + ], + enums: [ + { label: 'file.MODE_APPEND' }, + { label: 'file.MODE_READ' }, + { label: 'file.MODE_WRITE' }, + { label: 'file.READ_ALL' }, + { label: 'file.READ_LINE' }, + { label: 'file.READ_NUMBER' }, + ], + label: 'file' +} + +const format: ApiSpec = { + children: [ + { label: 'format.asciiprecision' }, + { label: 'format.byteorder' }, + { label: 'format.data' }, + ], + enums: [ + { label: 'format.ASCII' }, + { label: 'format.BIGENDIAN' }, + { label: 'format.LITTLEENDIAN' }, + { label: 'format.REAL32' }, + { label: 'format.REAL64' }, + ], + label: 'format' +} + +const gpib: ApiSpec = { label: 'gpib' } + +const lan: ApiSpec = { + children: [ + { label: 'lan.ipconfig' }, + { label: 'lan.lxidomain' }, + { label: 'lan.macaddress' }, + ], + enums: [ + { label: 'lan.MODE_AUTO' }, + { label: 'lan.MODE_MANUAL' }, + ], + label: 'lan' +} + +const localnode: ApiSpec = { + children: [ + { label: 'localnode.access' }, + { label: 'localnode.gettime' }, + { label: 'localnode.linefreq' }, + { label: 'localnode.model' }, + { label: 'localnode.password' }, + { label: 'localnode.prompts' }, + { label: 'localnode.prompts4882' }, + { label: 'localnode.serialno' }, + { label: 'localnode.settime' }, + { label: 'localnode.showevents' }, + { label: 'localnode.version' }, + ], + enums: [ + { label: 'localnode.ACCESS_EXCLUSIVE' }, + { label: 'localnode.ACCESS_FULL' }, + { label: 'localnode.ACCESS_LOCKOUT' }, + { label: 'localnode.ACCESS_PROTECTED' }, + { label: 'localnode.DISABLE' }, + { label: 'localnode.ENABLE' }, + ], + label: 'localnode' +} + +const node: ApiSpec = { + children: [ + { label: 'node.execute' }, + { label: 'node.getglobal' }, + { label: 'node.setglobal' }, + ], + label: 'node' +} + +const opc: ApiSpec = { label: 'opc' } + +const printbuffer: ApiSpec = { label: 'printbuffer' } + +const printnumber: ApiSpec = { label: 'printnumber' } + +const reset: ApiSpec = { label: 'reset' } + +const script: ApiSpec = { + children: [ + { label: 'script.delete' }, + { label: 'script.load' }, + ], + label: 'script' +} + +const smuInterlock: ApiSpec = { + children: [ + { label: 'smu.interlock.tripped' }, + ], + label: 'smu.interlock' +} + +const smuMeasureAutozero: ApiSpec = { + children: [ + { label: 'smu.measure.autozero.enable' }, + { label: 'smu.measure.autozero.once' }, + ], + label: 'smu.measure.autozero' +} + +const smuMeasureConfiglist: ApiSpec = { + children: [ + { label: 'smu.measure.configlist.catalog' }, + { label: 'smu.measure.configlist.create' }, + { label: 'smu.measure.configlist.delete' }, + { label: 'smu.measure.configlist.query' }, + { label: 'smu.measure.configlist.recall' }, + { label: 'smu.measure.configlist.size' }, + { label: 'smu.measure.configlist.store' }, + ], + label: 'smu.measure.configlist' +} + +const smuMeasureFilter: ApiSpec = { + children: [ + { label: 'smu.measure.filter.count' }, + { label: 'smu.measure.filter.enable' }, + { label: 'smu.measure.filter.type' }, + ], + label: 'smu.measure.filter' +} + +const smuMeasureLimitHigh: ApiSpec = { + children: [ + { label: 'smu.measure.limit.high.value' }, + ], + label: 'smu.measure.limit.high' +} + +const smuMeasureLimitLow: ApiSpec = { + children: [ + { label: 'smu.measure.limit.low.value' }, + ], + label: 'smu.measure.limit.low' +} + +const smuMeasureLimit: ApiSpec = { + children: [ + { label: 'smu.measure.limit.audible' }, + { label: 'smu.measure.limit.autoclear' }, + { label: 'smu.measure.limit.clear' }, + { label: 'smu.measure.limit.enable' }, + { label: 'smu.measure.limit.fail' }, + ], + label: 'smu.measure.limit' +} + +const smuMeasureMathMxb: ApiSpec = { + children: [ + { label: 'smu.measure.math.mxb.bfactor' }, + { label: 'smu.measure.math.mxb.mfactor' }, + ], + label: 'smu.measure.math.mxb' +} + +const smuMeasureMath: ApiSpec = { + children: [ + { label: 'smu.measure.math.enable' }, + { label: 'smu.measure.math.format' }, + { label: 'smu.measure.math.percent' }, + ], + label: 'smu.measure.math' +} + +const smuMeasureRel: ApiSpec = { + children: [ + { label: 'smu.measure.rel.acquire' }, + { label: 'smu.measure.rel.enable' }, + { label: 'smu.measure.rel.level' }, + ], + label: 'smu.measure.rel' +} + +const smuMeasure: ApiSpec = { + children: [ + { label: 'smu.measure.autorange' }, + { label: 'smu.measure.autorangehigh' }, + { label: 'smu.measure.autorangelow' }, + { label: 'smu.measure.count' }, + { label: 'smu.measure.displaydigits' }, + { label: 'smu.measure.func' }, + { label: 'smu.measure.nplc' }, + { label: 'smu.measure.offsetcompensation' }, + { label: 'smu.measure.range' }, + { label: 'smu.measure.read' }, + { label: 'smu.measure.readwithtime' }, + { label: 'smu.measure.sense' }, + { label: 'smu.measure.terminals' }, + { label: 'smu.measure.unit' }, + { label: 'smu.measure.userdelay' }, + ], + label: 'smu.measure' +} + +const smuSourceConfiglist: ApiSpec = { + children: [ + { label: 'smu.source.configlist.catalog' }, + { label: 'smu.source.configlist.create' }, + { label: 'smu.source.configlist.delete' }, + { label: 'smu.source.configlist.query' }, + { label: 'smu.source.configlist.recall' }, + { label: 'smu.source.configlist.size' }, + { label: 'smu.source.configlist.store' }, + ], + label: 'smu.source.configlist' +} + +const smuSourceIlimit: ApiSpec = { + children: [ + { label: 'smu.source.ilimit.level' }, + { label: 'smu.source.ilimit.tripped' }, + ], + label: 'smu.source.ilimit' +} + +const smuSourceProtect: ApiSpec = { + children: [ + { label: 'smu.source.protect.level' }, + { label: 'smu.source.protect.tripped' }, + ], + label: 'smu.source.protect' +} + +const smuSourceVlimit: ApiSpec = { + children: [ + { label: 'smu.source.vlimit.level' }, + { label: 'smu.source.vlimit.tripped' }, + ], + label: 'smu.source.vlimit' +} + +const smuSource: ApiSpec = { + children: [ + { label: 'smu.source.autodelay' }, + { label: 'smu.source.autorange' }, + { label: 'smu.source.delay' }, + { label: 'smu.source.func' }, + { label: 'smu.source.highc' }, + { label: 'smu.source.level' }, + { label: 'smu.source.offmode' }, + { label: 'smu.source.output' }, + { label: 'smu.source.range' }, + { label: 'smu.source.readback' }, + { label: 'smu.source.sweeplinear' }, + { label: 'smu.source.sweeplinearstep' }, + { label: 'smu.source.sweeplist' }, + { label: 'smu.source.sweeplog' }, + { label: 'smu.source.userdelay' }, + ], + label: 'smu.source' +} + +const smu: ApiSpec = { + children: [ + { label: 'smu.reset' }, + ], + enums: [ + { label: 'smu.AUDIBLE_FAIL' }, + { label: 'smu.AUDIBLE_NONE' }, + { label: 'smu.AUDIBLE_PASS' }, + { label: 'smu.DELAY_AUTO' }, + { label: 'smu.DIGITS_3_5' }, + { label: 'smu.DIGITS_4_5' }, + { label: 'smu.DIGITS_5_5' }, + { label: 'smu.DIGITS_6_5' }, + { label: 'smu.FAIL_BOTH' }, + { label: 'smu.FAIL_HIGH' }, + { label: 'smu.FAIL_LOW' }, + { label: 'smu.FAIL_NONE' }, + { label: 'smu.FILTER_MOVING_AVG' }, + { label: 'smu.FILTER_REPEAT_AVG' }, + { label: 'smu.FUNC_DC_CURRENT' }, + { label: 'smu.FUNC_DC_VOLTAGE' }, + { label: 'smu.FUNC_RESISTANCE' }, + { label: 'smu.INFINITE' }, + { label: 'smu.MATH_MXB' }, + { label: 'smu.MATH_PERCENT' }, + { label: 'smu.MATH_RECIPROCAL' }, + { label: 'smu.OFF' }, + { label: 'smu.OFFMODE_GUARD' }, + { label: 'smu.OFFMODE_HIGHZ' }, + { label: 'smu.OFFMODE_NORMAL' }, + { label: 'smu.OFFMODE_ZERO' }, + { label: 'smu.ON' }, + { label: 'smu.PROTECT_2V' }, + { label: 'smu.PROTECT_5V' }, + { label: 'smu.PROTECT_10V' }, + { label: 'smu.PROTECT_20V' }, + { label: 'smu.PROTECT_40V' }, + { label: 'smu.PROTECT_60V' }, + { label: 'smu.PROTECT_80V' }, + { label: 'smu.PROTECT_100V' }, + { label: 'smu.PROTECT_120V' }, + { label: 'smu.PROTECT_140V' }, + { label: 'smu.PROTECT_160V' }, + { label: 'smu.PROTECT_180V' }, + { label: 'smu.PROTECT_NONE' }, + { label: 'smu.RANGE_AUTO' }, + { label: 'smu.RANGE_BEST' }, + { label: 'smu.RANGE_FIXED' }, + { label: 'smu.SENSE_2WIRE' }, + { label: 'smu.SENSE_4WIRE' }, + { label: 'smu.TERMINALS_FRONT' }, + { label: 'smu.TERMINALS_REAR' }, + { label: 'smu.UNIT_AMP' }, + { label: 'smu.UNIT_OHM' }, + { label: 'smu.UNIT_VOLT' }, + { label: 'smu.UNIT_WATT' }, + ], + label: 'smu' +} + +const statusOperation: ApiSpec = { + children: [ + { label: 'status.operation.condition' }, + { label: 'status.operation.enable' }, + { label: 'status.operation.event' }, + { label: 'status.operation.getmap' }, + { label: 'status.operation.setmap' }, + ], + label: 'status.operation' +} + +const statusQuestionable: ApiSpec = { + children: [ + { label: 'status.questionable.condition' }, + { label: 'status.questionable.enable' }, + { label: 'status.questionable.event' }, + { label: 'status.questionable.getmap' }, + { label: 'status.questionable.setmap' }, + ], + label: 'status.questionable' +} + +const statusStandard: ApiSpec = { + children: [ + { label: 'status.standard.enable' }, + { label: 'status.standard.event' }, + ], + enums: [ + { label: 'status.standard.OPC' }, + { label: 'status.standard.QYE' }, + { label: 'status.standard.PON' }, + ], + label: 'status.standard' +} + +const status: ApiSpec = { + children: [ + { label: 'status.clear' }, + { label: 'status.condition' }, + { label: 'status.preset' }, + { label: 'status.request_enable' }, + ], + enums: [ + { label: 'status.MSB' }, + { label: 'status.EAV' }, + { label: 'status.QSB' }, + { label: 'status.MAV' }, + { label: 'status.ESB' }, + { label: 'status.MSS' }, + { label: 'status.OSB' }, + ], + label: 'status' +} + +const timer: ApiSpec = { + children: [ + { label: 'timer.cleartime' }, + { label: 'timer.gettime' }, + ], + label: 'timer' +} + +const triggerBlender: ApiSpec = { + children: [ + { label: 'trigger.blender.clear' }, + { label: 'trigger.blender.orenable' }, + { label: 'trigger.blender.overrun' }, + { label: 'trigger.blender.reset' }, + { label: 'trigger.blender.stimulus' }, + { label: 'trigger.blender.wait' }, + ], + label: 'trigger.blender' +} + +const triggerDigin: ApiSpec = { + children: [ + { label: 'trigger.digin.clear' }, + { label: 'trigger.digin.edge' }, + { label: 'trigger.digin.overrun' }, + { label: 'trigger.digin.wait' }, + ], + label: 'trigger.digin' +} + +const triggerDigout: ApiSpec = { + children: [ + { label: 'trigger.digout.assert' }, + { label: 'trigger.digout.logic' }, + { label: 'trigger.digout.pulsewidth' }, + { label: 'trigger.digout.release' }, + { label: 'trigger.digout.stimulus' }, + ], + label: 'trigger.digout' +} + +const triggerLanin: ApiSpec = { + children: [ + { label: 'trigger.lanin.clear' }, + { label: 'trigger.lanin.edge' }, + { label: 'trigger.lanin.overrun' }, + { label: 'trigger.lanin.wait' }, + ], + label: 'trigger.lanin' +} + +const triggerLanout: ApiSpec = { + children: [ + { label: 'trigger.lanout.assert' }, + { label: 'trigger.lanout.connect' }, + { label: 'trigger.lanout.connected' }, + { label: 'trigger.lanout.disconnect' }, + { label: 'trigger.lanout.ipaddress' }, + { label: 'trigger.lanout.logic' }, + { label: 'trigger.lanout.protocol' }, + { label: 'trigger.lanout.stimulus' }, + ], + label: 'trigger.lanout' +} + +const triggerModel: ApiSpec = { + children: [ + { label: 'trigger.model.abort' }, + { label: 'trigger.model.getblocklist' }, + { label: 'trigger.model.getbranchcount' }, + { label: 'trigger.model.initiate' }, + { label: 'trigger.model.load' }, + { label: 'trigger.model.setblock' }, + { label: 'trigger.model.state' }, + ], + label: 'trigger.model' +} + +const triggerTimerStart: ApiSpec = { + children: [ + { label: 'trigger.timer.start.fractionalseconds' }, + { label: 'trigger.timer.start.generate' }, + { label: 'trigger.timer.start.overrun' }, + { label: 'trigger.timer.start.seconds' }, + { label: 'trigger.timer.start.stimulus' }, + ], + label: 'trigger.timer.start' +} + +const triggerTimer: ApiSpec = { + children: [ + { label: 'trigger.timer.clear' }, + { label: 'trigger.timer.count' }, + { label: 'trigger.timer.delay' }, + { label: 'trigger.timer.delaylist' }, + { label: 'trigger.timer.enable' }, + { label: 'trigger.timer.reset' }, + { label: 'trigger.timer.wait' }, + ], + label: 'trigger.timer' +} + +const triggerTsplinkin: ApiSpec = { + children: [ + { label: 'trigger.tsplinkin.clear' }, + { label: 'trigger.tsplinkin.edge' }, + { label: 'trigger.tsplinkin.overrun' }, + { label: 'trigger.tsplinkin.wait' }, + ], + label: 'trigger.tsplinkin' +} + +const triggerTsplinkout: ApiSpec = { + children: [ + { label: 'trigger.tsplinkout.assert' }, + { label: 'trigger.tsplinkout.logic' }, + { label: 'trigger.tsplinkout.pulsewidth' }, + { label: 'trigger.tsplinkout.release' }, + { label: 'trigger.tsplinkout.stimulus' }, + ], + label: 'trigger.tsplinkout' +} + +const trigger: ApiSpec = { + children: [ + { label: 'trigger.clear' }, + { label: 'trigger.wait' }, + ], + enums: [ + { label: 'trigger.BLOCK_BRANCH_ALWAYS' }, + { label: 'trigger.BLOCK_BRANCH_COUNTER' }, + { label: 'trigger.BLOCK_BRANCH_DELTA' }, + { label: 'trigger.BLOCK_BRANCH_LIMIT_CONSTANT' }, + { label: 'trigger.BLOCK_BRANCH_LIMIT_DYNAMIC' }, + { label: 'trigger.BLOCK_BRANCH_ON_EVENT' }, + { label: 'trigger.BLOCK_BRANCH_ONCE' }, + { label: 'trigger.BLOCK_BRANCH_ONCE_EXCLUDED' }, + { label: 'trigger.BLOCK_BUFFER_CLEAR' }, + { label: 'trigger.BLOCK_CONFIG_NEXT' }, + { label: 'trigger.BLOCK_CONFIG_PREV' }, + { label: 'trigger.BLOCK_CONFIG_RECALL' }, + { label: 'trigger.BLOCK_DELAY_CONSTANT' }, + { label: 'trigger.BLOCK_DELAY_DYNAMIC' }, + { label: 'trigger.BLOCK_DIGITAL_IO' }, + { label: 'trigger.BLOCK_LOG_EVENT' }, + { label: 'trigger.BLOCK_MEASURE' }, + { label: 'trigger.BLOCK_NOP' }, + { label: 'trigger.BLOCK_NOTIFY' }, + { label: 'trigger.BLOCK_RESET_BRANCH_COUNT' }, + { label: 'trigger.BLOCK_SOURCE_OUTPUT' }, + { label: 'trigger.BLOCK_WAIT' }, + { label: 'trigger.CLEAR_ENTER' }, + { label: 'trigger.CLEAR_NEVER' }, + { label: 'trigger.COUNT_INFINITE' }, + { label: 'trigger.COUNT_STOP' }, + { label: 'trigger.EDGE_EITHER' }, + { label: 'trigger.EDGE_FALLING' }, + { label: 'trigger.EDGE_RISING' }, + { label: 'trigger.EVENT_BLENDER1' }, + { label: 'trigger.EVENT_BLENDER2' }, + { label: 'trigger.EVENT_COMMAND' }, + { label: 'trigger.EVENT_DIGIO1' }, + { label: 'trigger.EVENT_DIGIO2' }, + { label: 'trigger.EVENT_DIGIO3' }, + { label: 'trigger.EVENT_DIGIO4' }, + { label: 'trigger.EVENT_DIGIO5' }, + { label: 'trigger.EVENT_DIGIO6' }, + { label: 'trigger.EVENT_DISPLAY' }, + { label: 'trigger.EVENT_LAN1' }, + { label: 'trigger.EVENT_LAN2' }, + { label: 'trigger.EVENT_LAN3' }, + { label: 'trigger.EVENT_LAN4' }, + { label: 'trigger.EVENT_LAN5' }, + { label: 'trigger.EVENT_LAN6' }, + { label: 'trigger.EVENT_LAN7' }, + { label: 'trigger.EVENT_LAN8' }, + { label: 'trigger.EVENT_NONE' }, + { label: 'trigger.EVENT_NOTIFY1' }, + { label: 'trigger.EVENT_NOTIFY2' }, + { label: 'trigger.EVENT_NOTIFY3' }, + { label: 'trigger.EVENT_NOTIFY4' }, + { label: 'trigger.EVENT_NOTIFY5' }, + { label: 'trigger.EVENT_NOTIFY6' }, + { label: 'trigger.EVENT_NOTIFY7' }, + { label: 'trigger.EVENT_NOTIFY8' }, + { label: 'trigger.EVENT_SOURCE_LIMIT' }, + { label: 'trigger.EVENT_TIMER1' }, + { label: 'trigger.EVENT_TIMER2' }, + { label: 'trigger.EVENT_TIMER3' }, + { label: 'trigger.EVENT_TIMER4' }, + { label: 'trigger.EVENT_TSPLINK1' }, + { label: 'trigger.EVENT_TSPLINK2' }, + { label: 'trigger.EVENT_TSPLINK3' }, + { label: 'trigger.LIMIT_ABOVE' }, + { label: 'trigger.LIMIT_BELOW' }, + { label: 'trigger.LIMIT_INSIDE' }, + { label: 'trigger.LIMIT_OUTSIDE' }, + { label: 'trigger.LOG_INFO1' }, + { label: 'trigger.LOG_INFO2' }, + { label: 'trigger.LOG_INFO3' }, + { label: 'trigger.LOG_INFO4' }, + { label: 'trigger.LOG_WARN_ABORT' }, + { label: 'trigger.LOG_WARN1' }, + { label: 'trigger.LOG_WARN2' }, + { label: 'trigger.LOG_WARN3' }, + { label: 'trigger.LOG_WARN4' }, + { label: 'trigger.LOG_ERROR1' }, + { label: 'trigger.LOG_ERROR2' }, + { label: 'trigger.LOG_ERROR3' }, + { label: 'trigger.LOG_ERROR4' }, + { label: 'trigger.LOGIC_NEGATIVE' }, + { label: 'trigger.LOGIC_POSITIVE' }, + { label: 'trigger.OFF' }, + { label: 'trigger.ON' }, + { label: 'trigger.STATE_ABORTED' }, + { label: 'trigger.STATE_ABORTING' }, + { label: 'trigger.STATE_BUILDING' }, + { label: 'trigger.STATE_EMPTY' }, + { label: 'trigger.STATE_FAILED' }, + { label: 'trigger.STATE_IDLE' }, + { label: 'trigger.STATE_RUNNING' }, + { label: 'trigger.STATE_WAITING' }, + { label: 'trigger.USER_DELAY_M1' }, + { label: 'trigger.USER_DELAY_M2' }, + { label: 'trigger.USER_DELAY_M3' }, + { label: 'trigger.USER_DELAY_M4' }, + { label: 'trigger.USER_DELAY_M5' }, + { label: 'trigger.USER_DELAY_S1' }, + { label: 'trigger.USER_DELAY_S2' }, + { label: 'trigger.USER_DELAY_S3' }, + { label: 'trigger.USER_DELAY_S4' }, + { label: 'trigger.USER_DELAY_S5' }, + { label: 'trigger.WAIT_AND' }, + { label: 'trigger.WAIT_OR' }, + ], + label: 'trigger' +} + +const tsplink: ApiSpec = { + children: [ + { label: 'tsplink.MODE_DIGITAL_OPEN_DRAIN' }, + { label: 'tsplink.MODE_TRIGGER_OPEN_DRAIN' }, + { label: 'tsplink.MODE_SYNCHRONOUS_ACCEPTOR' }, + { label: 'tsplink.MODE_SYNCHRONOUS_MASTER' }, + { label: 'tsplink.STATE_HIGH' }, + { label: 'tsplink.STATE_LOW' }, + ], + enums: [ + { label: 'tsplink.group' }, + { label: 'tsplink.initialize' }, + { label: 'tsplink.master' }, + { label: 'tsplink.node' }, + { label: 'tsplink.readport' }, + { label: 'tsplink.reset' }, + { label: 'tsplink.state' }, + { label: 'tsplink.writeport' }, + ], + label: 'tsplink' +} + +const tsplinkLine: ApiSpec = { + children: [ + { label: 'tsplink.line.mode' }, + { label: 'tsplink.line.reset' }, + { label: 'tsplink.line.state' }, + ], + label: 'tsplink.line' +} + +const tspnet: ApiSpec = { + children: [ + { label: 'tspnet.clear' }, + { label: 'tspnet.connect' }, + { label: 'tspnet.disconnect' }, + { label: 'tspnet.execute' }, + { label: 'tspnet.idn' }, + { label: 'tspnet.read' }, + { label: 'tspnet.readavailable' }, + { label: 'tspnet.reset' }, + { label: 'tspnet.termination' }, + { label: 'tspnet.timeout' }, + { label: 'tspnet.write' }, + ], + enums: [ + { label: 'tspnet.TERM_CR' }, + { label: 'tspnet.TERM_CRLF' }, + { label: 'tspnet.TERM_LF' }, + { label: 'tspnet.TERM_LFCR' }, + ], + label: 'tspnet' +} + +const tspnetTsp: ApiSpec = { + children: [ + { label: 'tspnet.tsp.abort' }, + { label: 'tspnet.tsp.abortonconnect' }, + { label: 'tspnet.tsp.rbtablecopy' }, + { label: 'tspnet.tsp.runscript' }, + ], + label: 'tspnet.tsp' +} + +const upgrade: ApiSpec = { + children: [ + { label: 'upgrade.previous' }, + { label: 'upgrade.unit' }, + ], + label: 'upgrade' +} + +const userstring: ApiSpec = { + children: [ + { label: 'userstring.add' }, + { label: 'userstring.catalog' }, + { label: 'userstring.delete' }, + { label: 'userstring.get' }, + ], + label: 'userstring' +} + +const waitcomplete: ApiSpec = { label: 'waitcomplete' } + +export function get2450ApiSpec(): Array { + return getLuaApiSpec().concat([ + beeper, + bufferWrite, + buffer, + createconfigscript, + dataqueue, + delay, + digioLine, + digio, + displayInput, + display, + eventlog, + exit, + file, + format, + gpib, + lan, + localnode, + node, + opc, + printbuffer, + printnumber, + reset, + script, + smuInterlock, + smuMeasureAutozero, + smuMeasureConfiglist, + smuMeasureFilter, + smuMeasureLimitHigh, + smuMeasureLimitLow, + smuMeasureLimit, + smuMeasureMath, + smuMeasureMathMxb, + smuMeasureRel, + smuMeasure, + smuSourceConfiglist, + smuSourceIlimit, + smuSourceProtect, + smuSourceVlimit, + smuSource, + smu, + statusOperation, + statusQuestionable, + statusStandard, + status, + timer, + triggerBlender, + triggerDigin, + triggerDigout, + triggerLanin, + triggerLanout, + triggerModel, + triggerTimerStart, + triggerTimer, + triggerTsplinkin, + triggerTsplinkout, + trigger, + tsplinkLine, + tsplink, + tspnetTsp, + tspnet, + upgrade, + userstring, + waitcomplete + ]) +} + +export function get2450InstrumentSpec(): InstrumentSpec { + return { + beeper: { + maxHertz: 8000, + maxSeconds: 100, + minHertz: 20, + minSeconds: 0.001 + }, + current: { + measure: { + level: { + high: 1.05, + low: -1.05 + }, + range: { + default: 1e-4, + high: 1, + low: 1e-9 + } + }, + source: { + rangeDefault: 1e-8, + // tslint:disable-next-line:no-magic-numbers + ranges: [10e-9, 100e-9, 1e-6, 10e-6, 100e-6, 1e-3, 10e-3, 100e-3, 1] + } + }, + overflow: 9.9e37, + resistance: { + level: { + high: 2.1e6, + low: -2.1e6 + }, + range: { + default: 200000, + high: 200e6, + low: 20 + } + }, + smuInterlock: { + maxNominalVoltageTripped: 42, + maxSourceVoltageTripped: 21 + }, + smuMeasureAutorange: { + currentLowDefault: 10e-9, + resistanceHighDefault: 200e6, + resistanceLowDefault: 20, + voltageLowDefault: 20 + }, + smuSourceSweepLog: { + currentLevelLow: 1e-12, + voltageLevelLow: 1e-12 + }, + voltage: { + measure: { + level: { + high: 210, + low: -210 + }, + range: { + default: 0.02, + high: 200, + low: 0.02 + } + }, + source: { + rangeDefault: 2e-2, + // tslint:disable-next-line:no-magic-numbers + ranges: [20e-3, 200e-3, 2, 20, 200] + } + } + } } diff --git a/server/src/instrument/2450/printbuffer.ts b/server/src/instrument/2450/printbuffer.ts deleted file mode 100644 index 586b06fa..00000000 --- a/server/src/instrument/2450/printbuffer.ts +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const printbufferCompletions: Array = [ - { - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction printbuffer(startIndex, endIndex, ...)\n```\n\ -\n\ -Generate a single response message containing data from the specified tables or reading buffer subtables. \ -Passing a reading buffer will cause its default subtable to be printed.\n\ -\n\ -The format.data attribute controls the output format of the response message.\n\ -\n\ -If the given startIndex is less than 1 or endIndex greater than the size of the table, 9.910000e+37 is returned for \ -each value outside the table indices and an event is generated.\n\ -\n\ -If overlapped commands use the specified reading buffers and the commands are not complete (at least to the \ -specified index), data will be printed as it becomes available.' - }, - kind: CompletionItemKind.Function, - label: 'printbuffer', - }, -] - -const printbufferSignatures: Array = [ - SignatureInformation.create( - 'printbuffer(startIndex, endIndex, ...)', - undefined, - ParameterInformation.create( - 'startIndex', - 'Beginning index of the buffer to print; must be greater than or equal to one and less than endIndex.' - ), - ParameterInformation.create( - 'endIndex', - 'Ending index of the buffer to print; \ -must be greater than startIndex and less than or equal to the last table index.' - ), - ParameterInformation.create( - '...', - 'One or more tables or reading buffer subtables separated with commas.' - ), - ), -] - -export async function getPrintbufferCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(printbufferCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getPrintbufferSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(printbufferSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/printnumber.ts b/server/src/instrument/2450/printnumber.ts deleted file mode 100644 index e6c56384..00000000 --- a/server/src/instrument/2450/printnumber.ts +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const printnumberCompletions: Array = [ - { - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction printnumber(...)\n```\n\ -\n\ -Generate a single response message containing the specified numbers using the data format specified by \ -format.data and format.asciiprecision.' - }, - kind: CompletionItemKind.Function, - label: 'printnumber', - }, -] - -const printnumberSignatures: Array = [ - SignatureInformation.create( - 'printnumber(...)', - undefined, - ParameterInformation.create( - '...', - 'One or more values separated with commas. Values are printed in the currently configured format.' - ), - ), -] - -export async function getPrintnumberCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(printnumberCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getPrintnumberSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(printnumberSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-source.ts b/server/src/instrument/2450/smu-source.ts deleted file mode 100644 index 2575a60e..00000000 --- a/server/src/instrument/2450/smu-source.ts +++ /dev/null @@ -1,491 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const smuSourceCompletions: Array = [ - { - data: ['smu'], - kind: CompletionItemKind.Module, - label: 'source' - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.autodelay\n```\n\ -\n\ -Get or set the automatic delay that occurs when the source is turned on to smu.OFF or ON. Defaults to smu.ON.\n\ -\n\ -This attribute is automatically set to smu.OFF on manual source delay configuration.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, - kind: CompletionItemKind.Property, - label: 'autodelay', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.autorange\n```\n\ -\n\ -Get or set the present autorange setting to smu.OFF or ON. Defaults to smu.ON. Only available for the Current and \ -Voltage functions.\n\ -\n\ -When set to smu.ON, the instrument automatically sets the most appropriate sourcing range.\n\ -\n\ -When set to smu.OFF, the instrument range must be configured manually. If the range is not configured, the instrument \ -will remain at the range last used by autorange. This attribute is automatically set to smu.OFF on manual range \ -configuration.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, - kind: CompletionItemKind.Property, - label: 'autorange', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.delay\n```\n\ -\n\ -Get or set a source delay for the active source function to a number from 0 to 10 000 seconds.\n\ -\n\ -Setting this attribute automatically sets the source autodelay to smu.OFF. This attribute is overwritten if autodelay \ -is re-enabled.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, - kind: CompletionItemKind.Property, - label: 'delay', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.func\n```\n\ -\n\ -Get or set the active source function to smu.FUNC_DC_CURRENT or FUNC_DC_VOLTAGE. Defaults to smu.FUNC_DC_CURRENT.\n\ -\n\ -When the active source function is changed, settings that are retained on a per-function basis are also changed.' - }, - kind: CompletionItemKind.Property, - label: 'func', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.highc\n```\n\ -\n\ -Get or set the present high-capacitance mode setting to smu.ON or OFF. Defaults to smu.OFF.\n\ -\n\ -When measuring a current in the 1 µA range or above and driving a capacitive load, enable this attribute to prevent \ -any overshoot, ringing, or instability.' - }, - kind: CompletionItemKind.Property, - label: 'highc', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.level\n```\n\ -\n\ -Get or set the output level of the active source function as a number. Defaults to 0 for all source functions.\n\ -\n\ -When the source function is set to Current, the valid range of this attribute is -1.05 to +1.05.\n\ -\n\ -When the source function is set to Voltage, the valid range of this attribute is -210 to +210.\n\ -\n\ -If manual source ranging is enabled, then this attribute cannot exceed the present source range setting.' - }, - kind: CompletionItemKind.Property, - label: 'level', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.offmode\n```\n\ -\n\ -Get or set the instrument state when output is turned off to smu.OFFMODE_\\*. Defaults to smu.OFFMODE_NORMAL.' - }, - kind: CompletionItemKind.Property, - label: 'offmode', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.output\n```\n\ -\n\ -Get or set the present source output state to smu.ON or OFF. Defaults to smu.OFF.' - }, - kind: CompletionItemKind.Property, - label: 'output', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.range\n```\n\ -\n\ -Get or set the source range of the active source function by passing the expected source level as a number.\n\ -\n\ -When the source function is set to Current, the valid range of this attribute is -1.0 to +1.0 and defaults to +1e-8.\n\ -\n\ -When the source function is set to Voltage, this range is -200.0 to +200.0 and defaults to +2e-2.\n\ -\n\ -While this attribute accepts any number in the applicable range, the instrument is set to the closest effective range \ -less than supplied source level.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, - kind: CompletionItemKind.Property, - label: 'range', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.readback\n```\n\ -\n\ -Get or set the present source readback setting to smu.OFF or ON. Defaults to smu.ON.\n\ -\n\ -When source readback is set to smu.OFF, the front-panel displays the present value of the source level attribute in \ -addition to recording it in the buffer alongside each measurement.\n\ -\n\ -When source readback is set to smu.ON, the actual source level is measured, displayed on the front-panel, and \ -recorded in the buffer alongside each measurement.' - }, - kind: CompletionItemKind.Property, - label: 'readback', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction sweeplinear(configListName, start, stop, points, delay, count, rangeType, \ -failAbort, dual, bufferName)\n```\n\ -\n\ -smu.source.sweeplinear(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort][, dual]\ -[, bufferName])\n\ -\n\ -Configure a linear sweep for a fixed number of measurement points.\n\ -\n\ -Clears any existing trigger models, creates a source configuration list, and populates the trigger model. Initiate \ -the trigger model to start the sweep.' - }, - kind: CompletionItemKind.Function, - label: 'sweeplinear', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction sweeplinearstep(configListName, start, stop, step, delay, count, rangeType, \ -failAbort, dual, bufferName)\n```\n\ -\n\ -smu.source.sweeplinearstep(configListName, start, stop, step[, delay][, count][, rangeType][, failAbort][, dual]\ -[, bufferName])\n\ -\n\ -Configure a stepped linear sweep for a fixed number of measurement points.\n\ -\n\ -Clears any existing trigger models, creates a source configuration list, and populates the trigger model to perform a \ -uniform series of ascending or descending output steps. Initiate the trigger model to start the sweep.' - }, - kind: CompletionItemKind.Function, - label: 'sweeplinearstep', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction sweeplist(configListName, index, delay, count, failAbort, bufferName)\n```\n\ -\n\ -smu.source.sweeplist(configListName[, index][, delay][, count][, failAbort][, bufferName])\n\ -\n\ -Configure a custom sweep using the given configListName to specify each source level.\n\ -\n\ -Clears any existing trigger models, loads from the specified source configuration list, and populates the trigger \ -model. Initiate the trigger model to start the sweep.' - }, - kind: CompletionItemKind.Function, - label: 'sweeplist', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction sweeplog(configListName, start, stop, points, delay, count, rangeType, \ -failAbort, dual, bufferName, asymptote)\n```\n\ -\n\ -smu.source.sweeplog(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort][, dual]\ -[, bufferName][, asymptote])\n\ -\n\ -Configure a logarithmic sweep for a fixed number of measurement points.\n\ -\n\ -Clears any existing trigger models, creates a source configuration list, and populates the trigger model. Initiate \ -the trigger model to start the sweep.' - }, - kind: CompletionItemKind.Function, - label: 'sweeplog', - }, - { - data: ['source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.measure.userdelay[N]\n```\n\ -\n\ -An array of available user delays for use by the Dynamic Delay block of the trigger model. Indexed from 1 to 5. Get \ -or set the index to a number from 0 to +10e+3 seconds.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, - kind: CompletionItemKind.Property, - label: 'userdelay', - }, -] - -const smuSourceSignatures: Array = [ - SignatureInformation.create( - 'smu.source.sweeplinear(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort]\ -[, dual][, bufferName])', - undefined, - ParameterInformation.create( - 'configListName', - 'The name of the source configuration list to create as a string.' - ), - ParameterInformation.create( - 'start', - 'The source level at which to start sweeping as a number.\n\ -Current range: -1.05 to +1.05\n\ -Voltage range: -210 to +210.' - ), - ParameterInformation.create( - 'stop', - 'The source level at which to stop sweeping as a number.\n\ -Current range: -1.05 to +1.05\n\ -Voltage range: -210 to +210.' - ), - ParameterInformation.create( - 'points', - 'The number of source-measure points between the start and stop values of the sweep as a number from +2.0 \ -to +1e+6.' - ), - ParameterInformation.create( - 'delay', - 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds, 0 for no delay, or \ -smu.DELAY_AUTO. Defaults to smu.DELAY_AUTO.' - ), - ParameterInformation.create( - 'count', - 'The number of times to run the sweep as a number from 1 to 268 435 455 or smu.INFINITE. Defaults to 1.' - ), - ParameterInformation.create( - 'rangeType', - 'Some smu.RANGE_*. Defaults to smu.RANGE_BEST.' - ), - ParameterInformation.create( - 'failAbort', - 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if exceeded. Defaults \ -to smu.ON.' - ), - ParameterInformation.create( - 'dual', - 'smu.OFF to sweep from start to stop only or smu.ON to sweep from start to stop, then back to start. \ -Defaults to smu.OFF.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the name of a \ -user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'smu.source.sweeplinearstep(configListName, start, stop, step[, delay][, count][, rangeType][, failAbort]\ -[, dual][, bufferName])', - undefined, - ParameterInformation.create( - 'configListName', - 'The name of the source configuration list to create as a string.' - ), - ParameterInformation.create( - 'start', - 'The source level at which to start sweeping as a number.\n\ -Current range: -1.05 to +1.05\n\ -Voltage range: -210 to +210.' - ), - ParameterInformation.create( - 'stop', - 'The source level at which to stop sweeping as a number.\n\ -Current range: -1.05 to +1.05\n\ -Voltage range: -210 to +210.' - ), - ParameterInformation.create( - 'step', - 'The magnitude by which the output level will change for each step as a number greater than 0.' - ), - ParameterInformation.create( - 'delay', - 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds, 0 for no delay, or \ -smu.DELAY_AUTO. Defaults to smu.DELAY_AUTO.' - ), - ParameterInformation.create( - 'count', - 'The number of times to run the sweep as a number from 1 to 268 435 455 or smu.INFINITE. Defaults to 1.' - ), - ParameterInformation.create( - 'rangeType', - 'Some smu.RANGE_*. Defaults to smu.RANGE_BEST.' - ), - ParameterInformation.create( - 'failAbort', - 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if exceeded. Defaults \ -to smu.ON.' - ), - ParameterInformation.create( - 'dual', - 'smu.OFF to sweep from start to stop only or smu.ON to sweep from start to stop, then back to start. \ -Defaults to smu.OFF.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the name of a \ -user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'smu.source.sweeplist(configListName[, index][, delay][, count][, failAbort][, bufferName])', - undefined, - ParameterInformation.create( - 'configListName', - 'The name of the source configuration list to load as a string.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Defaults to the first configuration index.' - ), - ParameterInformation.create( - 'delay', - 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds or 0 for no delay.' - ), - ParameterInformation.create( - 'count', - 'The number of times to run the sweep as a number from 1 to 268 435 455 or smu.INFINITE. Defaults to 1.' - ), - ParameterInformation.create( - 'failAbort', - 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if exceeded. Defaults \ -to smu.ON.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the name of a \ -user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'smu.source.sweeplog(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort][, dual]\ -[, bufferName][, asymptote])', - undefined, - ParameterInformation.create( - 'configListName', - 'The name of the source configuration list to create as a string.' - ), - ParameterInformation.create( - 'start', - 'The source level at which to start sweeping as a number.\n\ -Current range: +1e-12 to +1.05\n\ -Voltage range: +1e-12 to +210.' - ), - ParameterInformation.create( - 'stop', - 'The source level at which to stop sweeping as a number.\n\ -Current range: +1e-12 to +1.05\n\ -Voltage range: +1e-12 to +210.' - ), - ParameterInformation.create( - 'points', - 'The number of source-measure points between the start and stop values of the sweep as a number from +2.0 \ -to +1e+6.' - ), - ParameterInformation.create( - 'delay', - 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds, 0 for no delay, or \ -smu.DELAY_AUTO. Defaults to smu.DELAY_AUTO.' - ), - ParameterInformation.create( - 'count', - 'The number of times to run the sweep as a number from 1 to 268 435 455 or smu.INFINITE. Defaults to 1.' - ), - ParameterInformation.create( - 'rangeType', - 'Some smu.RANGE_*. Defaults to smu.RANGE_BEST.' - ), - ParameterInformation.create( - 'failAbort', - 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if exceeded. Defaults \ -to smu.ON.' - ), - ParameterInformation.create( - 'dual', - 'smu.OFF to sweep from start to stop only or smu.ON to sweep from start to stop, then back to start. \ -Defaults to smu.OFF.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the name of a \ -user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.' - ), - ParameterInformation.create( - 'asymptote', - 'The value of the asymtotic curve at either positive or negative infinity, depending on the direction of \ -the sweep. Defaults to 0.\n\ -Asymtotic value cannot be less than or equal to the sweep bounds.' - ), - ), -] - -export async function getSmuSourceCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getSmuSourceSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-model.ts b/server/src/instrument/2450/trigger-model.ts deleted file mode 100644 index 0d38c414..00000000 --- a/server/src/instrument/2450/trigger-model.ts +++ /dev/null @@ -1,921 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const triggerModelCompletions: Array = [ - { - data: ['trigger'], - kind: CompletionItemKind.Module, - label: 'model' - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction abort()\n```\n\ -\n\ -Stop all trigger model commands.' - }, - kind: CompletionItemKind.Function, - label: 'abort', - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction getblocklist()\n```\n\ntrigger.model.getblocklist() -> string\n\ -\n\ -Returns the present blocks in the trigger model as a string.' - }, - kind: CompletionItemKind.Function, - label: 'getblocklist', - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction getbranchcount(blockNumber)\n```\n\ -\n\ -trigger.model.getbranchcount(blockNumber) -> number\n\ -\n\ -Returns the counter value of the specified BRANCH_COUNTER block as a number. If execution has not yet reached the \ -block, then a 0 is returned.' - }, - kind: CompletionItemKind.Function, - label: 'getbranchcount', - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction initiate()\n```\n\ -\n\ -Start the trigger model.' - }, - kind: CompletionItemKind.Function, - label: 'initiate', - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction load(typeString, typeParam, ...)\n```\n\ -\n\ -Load a predefined trigger model configuration.' - }, - kind: CompletionItemKind.Function, - label: 'load', - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction setblock(blockNumber, trigger.BLOCK_\\*, blockParams, ...)\n```\n\ -\n\ -Add a block to the trigger model.' - }, - kind: CompletionItemKind.Function, - label: 'setblock', - }, - { - data: ['model', 'trigger'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction state()\n```\n\ -\n\ -trigger.model.state() -> trigger.STATE_\\*, trigger.STATE_\\*, number\n\ -\n\ -Returns `overallStatus, engineStatus, blockNumber` where \ -*overallStatus* is the overall trigger model status, \ -*engineStatus* is the present status of the trigger engine, \ -and *blockNumber* is the last executed block number.\n\ -\n\ -Trigger state is updated every 100 ms.' - }, - kind: CompletionItemKind.Function, - label: 'state', - }, -] - -const triggerModelSignatures: Array = [ - SignatureInformation.create( - 'trigger.model.getbranchcount(blockNumber)', - undefined, - ParameterInformation.create( - 'blockNumber', - 'The sequence of the BRANCH_COUNTER block in the trigger model.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("ConfigList", measureConfigList, sourceConfigList[, delay][, bufferName])', - 'Load trigger model from Source and Measure config lists.', - ParameterInformation.create( - '"ConfigList"', - 'The string "ConfigList".' - ), - ParameterInformation.create( - 'measureConfigList', - 'A string that contains the name of the measurement configuration list to use.' - ), - ParameterInformation.create( - 'sourceConfigList', - 'A string that contains the name of the source configuration list to use.' - ), - ParameterInformation.create( - 'delay', - 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("DurationLoop", duration[, delay][, bufferName])', - 'Load a basic duration loop trigger model.', - ParameterInformation.create( - '"DurationLoop"', - 'The string "DurationLoop".' - ), - ParameterInformation.create( - 'duration', - 'The amount of time for which to make measurements (167 ns to 100 ks).' - ), - ParameterInformation.create( - 'delay', - 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("Empty")', - 'Clear the trigger model.', - ParameterInformation.create( - '"Empty"', - 'The string "Empty".' - ), - ), - SignatureInformation.create( - 'trigger.model.load("GradeBinning", components, startInLine, startDelay, endDelay, \ -limit1High, limit1Low[, limit1Pattern]\ -[, limit2High][, limit2Low][, limit2Pattern]\ -[, limit3High][, limit3Low][, limit3Pattern]\ -[, limit4High][, limit4Low][, limit4Pattern]\ -[, allPattern][, bufferName])', - 'Load a basic grade binning trigger model.', - ParameterInformation.create( - '"GradeBinning"', - 'The string "GradeBinning".' - ), - ParameterInformation.create( - 'components', - 'The number of components to measure (1 to 268,435,455).' - ), - ParameterInformation.create( - 'startInLine', - 'The digital input line that starts the test (5 or 6)' - ), - ParameterInformation.create( - 'startDelay', - 'The delay time before each measurement (167 ns to 10 ks); 0 for no delay.' - ), - ParameterInformation.create( - 'endDelay', - 'The delay time after each measurement (167 ns to 10 ks); 0 for no delay.' - ), - ParameterInformation.create( - 'limit1High', - 'The first upper limit that the measurement is compared against. \ -To mark this limit as unused, set this value lower than limit1Low.' - ), - ParameterInformation.create( - 'limit1Low', - 'The first lower limit that the measurement is compared against. \ -To mark this limit as unused, set this value higher than limit1High.' - ), - ParameterInformation.create( - 'limit1Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 1; defaults to 1. \ -Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.' - ), - ParameterInformation.create( - 'limit2High', - 'The second upper limit that the measurement is compared against. \ -To mark this limit as unused, set this value lower than limit2Low.' - ), - ParameterInformation.create( - 'limit2Low', - 'The second lower limit that the measurement is compared against. \ -To mark this limit as unused, set this value higher than limit2High.' - ), - ParameterInformation.create( - 'limit2Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 2; defaults to 2. \ -Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.' - ), - ParameterInformation.create( - 'limit3High', - 'The third upper limit that the measurement is compared against. \ -To mark this limit as unused, set this value lower than limit3Low.' - ), - ParameterInformation.create( - 'limit3Low', - 'The third lower limit that the measurement is compared against. \ -To mark this limit as unused, set this value higher than limit3High.' - ), - ParameterInformation.create( - 'limit3Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 3; defaults to 4. \ -Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.' - ), - ParameterInformation.create( - 'limit4High', - 'The fourth upper limit that the measurement is compared against. \ -To mark this limit as unused, set this value lower than limit4Low.' - ), - ParameterInformation.create( - 'limit4Low', - 'The fourth lower limit that the measurement is compared against. \ -To mark this limit as unused, set this value higher than limit4High.' - ), - ParameterInformation.create( - 'limit4Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 4; defaults to 8. \ -Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.' - ), - ParameterInformation.create( - 'allPattern', - 'The bit pattern (1 to 15) that is sent when all limits have passed; defaults to 15. \ -Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("LogicTrigger", digInLine, digOutLine, count, clear[, delay][, bufferName])', - 'Load a basic logic trigger model.', - ParameterInformation.create( - '"LogicTrigger"', - 'The string "LogicTrigger".' - ), - ParameterInformation.create( - 'digInLine', - 'The digital input line (1 to 6); also the event that the trigger model will wait on in block 1.' - ), - ParameterInformation.create( - 'digOutLine', - 'The digital output line (1 to 6).' - ), - ParameterInformation.create( - 'count', - 'The number of measurements the instrument will make.' - ), - ParameterInformation.create( - 'clear', - 'Use trigger.CLEAR_NEVER to immediately act on any previously detected triggers and not clear them \ -(default) or trigger.CLEAR_ENTER to clear previously detected trigger events when entering the wait block.' - ), - ParameterInformation.create( - 'delay', - 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("LoopUntilEvent", triggerEvent, position, clear[, delay][, bufferName])', - 'Load a basic event loop trigger model.', - ParameterInformation.create( - '"LoopUntilEvent"', - 'The string "LoopUntilEvent".' - ), - ParameterInformation.create( - 'triggerEvent', - 'The event that ends infinite triggering or readings set to occur before the trigger; value is some \ -trigger.EVENT_* enumeration besides trigger.EVENT_NONE.' - ), - ParameterInformation.create( - 'position', - 'The number of readings to make in relation to the size of the reading buffer; enter as percentage out of \ -100.' - ), - ParameterInformation.create( - 'clear', - 'Use trigger.CLEAR_NEVER to immediately act on any previously detected triggers and not clear them \ -(default) or trigger.CLEAR_ENTER to clear previously detected trigger events when entering the wait block.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("SimpleLoop", count[, delay][, bufferName])', - 'Load a basic looping trigger model.', - ParameterInformation.create( - '"SimpleLoop"', - 'The string "SimpleLoop".' - ), - ParameterInformation.create( - 'count', - 'The number of measurements the instrument will make.' - ), - ParameterInformation.create( - 'delay', - 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.load("SortBinning", components, startInLine, startDelay, endDelay, \ -limit1High, limit1Low[, limit1Pattern]\ -[, limit2High][, limit2Low][, limit2Pattern]\ -[, limit3High][, limit3Low][, limit3Pattern]\ -[, limit4High][, limit4Low][, limit4Pattern]\ -[, allPattern][, bufferName])', - 'Load a basic sort binning trigger model.', - ParameterInformation.create( - '"SortBinning"', - 'The string "SortBinning".' - ), - ParameterInformation.create( - 'components', - 'The number of components to measure (1 to 268,435,455).' - ), - ParameterInformation.create( - 'startInLine', - 'The digital input line that starts the test (5 or 6)' - ), - ParameterInformation.create( - 'startDelay', - 'The delay time before each measurement (167 ns to 10 ks); 0 for no delay.' - ), - ParameterInformation.create( - 'endDelay', - 'The delay time after each measurement (167 ns to 10 ks); 0 for no delay.' - ), - ParameterInformation.create( - 'limit1High', - 'The first upper limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit1Low', - 'The first lower limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit1Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 1; defaults to 1' - ), - ParameterInformation.create( - 'limit2High', - 'The second upper limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit2Low', - 'The second lower limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit2Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 2; defaults to 2' - ), - ParameterInformation.create( - 'limit3High', - 'The third upper limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit3Low', - 'The third lower limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit3Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 3; defaults to 4' - ), - ParameterInformation.create( - 'limit4High', - 'The fourth upper limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit4Low', - 'The fourth lower limit that the measurement is compared against.' - ), - ParameterInformation.create( - 'limit4Pattern', - 'The bit pattern (1 to 15) that is sent when the measurement fails limit 4; defaults to 8' - ), - ParameterInformation.create( - 'allPattern', - 'The bit pattern (1 to 15) that is sent when all limits have passed; defaults to 15.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ALWAYS, branchToBlock)', - 'Transfer execution to the specified block number.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_ALWAYS', - 'The "trigger.BLOCK_BRANCH_ALWAYS" enumeration.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the trigger model reaches this block.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_COUNTER, targetCount, branchToBlock)', - 'Transfer execution if the total number of branches is less than the specified counter; otherwise continue.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_COUNTER', - 'The "trigger.BLOCK_BRANCH_COUNTER" enumeration.' - ), - ParameterInformation.create( - 'targetCount', - 'The number of times to repeat.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the counter is less than the targetCount value.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_DELTA, targetDifference, branchToBlock\ -[, measureBlock])', - 'Transfer execution if the delta between the last two measurements (ultimate - penultimate) is less than the \ -specified value; otherwise continue.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_DELTA', - 'The "trigger.BLOCK_BRANCH_DELTA" enumeration.' - ), - ParameterInformation.create( - 'targetDifference', - 'The value against which the block compares the difference between the measurements.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the difference between the measurements is less than or equal to the \ -targetDifference.' - ), - ParameterInformation.create( - 'measureBlock', - 'The block number that makes the measurements to be compared; if this is 0 or undefined, the trigger \ -model uses a previous measure block.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_LIMIT_CONSTANT, limitType, limitA, limitB, \ -branchToBlock[, measureBlock])', - 'Transfer execution if a measurement meets the specified criteria.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_LIMIT_CONSTANT', - 'The "trigger.BLOCK_BRANCH_LIMIT_CONSTANT" enumeration.' - ), - ParameterInformation.create( - 'limitType', - 'The type of limit, which can be some trigger.LIMIT_*.' - ), - ParameterInformation.create( - 'limitA', - 'The lower limit that the measurement is tested against as a number. Limit is ignored if limitType is set \ -to trigger.LIMIT_ABOVE. If limitType is set to trigger.LIMIT_INSIDE or LIMIT_OUTSIDE, then this is the low limit that \ -the measurement is compared against. If limitType is set to trigger.LIMIT_BELOW, then the measurement must be below \ -this value.' - ), - ParameterInformation.create( - 'limitB', - 'The upper limit that the measurement is tested against as a number. Limit is ignored if limitType is set \ -to trigger.LIMIT_BELOW. If limitType is set to trigger.LIMIT_INSIDE or LIMIT_OUTSIDE, then this is the low limit that \ -the measurement is compared against. If limitType is set to trigger.LIMIT_ABOVE, then the measurement must be above \ -this value.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the measurement meets the defined criteria.' - ), - ParameterInformation.create( - 'measureBlock', - 'The block number that makes the measurements to be compared; if this is 0 or undefined, the trigger \ -model uses the previous measure block.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_LIMIT_DYNAMIC, limitType, limitNumber, branchToBlock\ -[, measureBlock])', - 'Transfer execution if a measurement meets the criteria specified by a loaded measurement configuration list.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_LIMIT_DYNAMIC', - 'The "trigger.BLOCK_BRANCH_LIMIT_DYNAMIC" enumeration.' - ), - ParameterInformation.create( - 'limitType', - 'The type of limit, which can be some trigger.LIMIT_*.' - ), - ParameterInformation.create( - 'limitNumber', - 'The limit number (1 or 2).' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the measurement meets the criteria set in the configuration list.' - ), - ParameterInformation.create( - 'measureBlock', - 'The block number that makes the measurements to be compared; if this is 0 or undefined, the trigger \ -model uses the previous measure block.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ONCE, branchToBlock)', - 'Transfer execution if this block has not been executed; otherwise continue.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_ONCE', - 'The "trigger.BLOCK_BRANCH_ONCE" enumeration.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the trigger model first encounters this block.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ONCE_EXCLUDED, branchToBlock)', - 'Transfer execution if this block has been executed; otherwise continue.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_ONCE_EXCLUDED', - 'The "trigger.BLOCK_BRANCH_ONCE_EXCLUDED" enumeration.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the trigger model encounters this block after the first encounter.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ON_EVENT, event, branchToBlock)', - 'Transfer execution if the specified event has occurred; otherwise continue.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BRANCH_ON_EVENT', - 'The "trigger.BLOCK_BRANCH_ON_EVENT" enumeration.' - ), - ParameterInformation.create( - 'event', - 'Some trigger.EVENT_* that must occur before the trigger model branches to the specified block.' - ), - ParameterInformation.create( - 'branchToBlock', - 'The block number to execute when the specified event occurs.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_BUFFER_CLEAR[, bufferName])', - 'Clear the specified reading buffer.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_BUFFER_CLEAR', - 'The "trigger.BLOCK_BUFFER_CLEAR" enumeration.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of an existing buffer; if no buffer is defined, defbuffer1 is used.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_CONFIG_NEXT, configurationList)', - 'Recall the settings at the next index of the specified source/measurement configuration list.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_CONFIG_NEXT', - 'The "trigger.BLOCK_CONFIG_NEXT" enumeration.' - ), - ParameterInformation.create( - 'configurationList', - 'A string that defines the source or measure configuration list to recall.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_CONFIG_PREV, configurationList)', - 'Recall the settings at the previous index of the specified source/measurement configuration list.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_CONFIG_PREV', - 'The "trigger.BLOCK_CONFIG_PREV" enumeration.' - ), - ParameterInformation.create( - 'configurationList', - 'A string that defines the source or measure configuration list to recall.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_CONFIG_RECALL, configurationList[, index])', - 'Recall the settings stored in the specified source/measurement configuration list.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_CONFIG_RECALL', - 'The "trigger.BLOCK_CONFIG_RECALL" enumeration.' - ), - ParameterInformation.create( - 'configurationList', - 'A string that defines the source or measure configuration list to recall.' - ), - ParameterInformation.create( - 'index', - 'The index in the configuration list to recall; default is 1.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_DELAY_CONSTANT, time)', - 'Halt measurement and trigger model execution for the specified amount of time. Background measurements will \ -continue, as will any infinite measurements set by a previous block.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_DELAY_CONSTANT', - 'The "trigger.BLOCK_DELAY_CONSTANT" enumeration.' - ), - ParameterInformation.create( - 'time', - 'The amount of time to delay in seconds (+167e-9 to 10 000, or 0 for no delay).' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_DELAY_DYNAMIC, trigger.USER_DELAY_*)', - 'Halt measurement and trigger model execution for a remotely programmable amount of time. Background \ -measurements will continue, as will any infinite measurements set by a previous block.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_DELAY_DYNAMIC', - 'The "trigger.BLOCK_DELAY_DYNAMIC" enumeration.' - ), - ParameterInformation.create( - 'trigger.USER_DELAY_*', - 'Either USER_DELAY_M or USER_DELAY_S depending on whether you want to use the measure or source \ -user delays, respectively. Where is the index of the userdelay array attribute to use.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_DIGITAL_IO, bitPattern, bitMask)', - 'Send a given bit pattern (0 to 63) on the specified digital I/O line. The least significant bit maps to \ -digital I/O line 1 and the most significant bit to line 6.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_DIGITAL_IO', - 'The "trigger.BLOCK_DIGITAL_IO" enumeration.' - ), - ParameterInformation.create( - 'bitPattern', - 'Sets the value that specifies the output line bit pattern (0 to 63).' - ), - ParameterInformation.create( - 'bitMask', - 'Specifies the bit mask; if omitted, all lines are driven (0 to 63).' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_LOG_EVENT, eventNumber, message)', - 'Post the specified event to the event log. Using this block too often in a trigger model could overflow the \ -event log. It may also take away from the time needed to process more critical trigger model blocks.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_LOG_EVENT', - 'The "trigger.BLOCK_LOG_EVENT" enumeration.' - ), - ParameterInformation.create( - 'eventNumber', - 'Some trigger.LOG_*. You can also set trigger.LOG_WARN_ABORT, which aborts the trigger model immediately \ -and posts a warning message to the event log.' - ), - ParameterInformation.create( - 'message', - 'A string up to 31 characters.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_MEASURE[, bufferName][, count])', - 'Take the specified number of measurements. If an infinite measure count is given, then execution continues \ -until the next MEASURE block.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_MEASURE', - 'The "trigger.BLOCK_MEASURE" enumeration.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of an existing buffer; if no buffer is defined, defbuffer1 is used.' - ), - ParameterInformation.create( - 'count', - 'The number of readings to make before moving to the next block in the trigger model; set to a specific \ -number or trigger.COUNT_INFINITE or trigger.COUNT_STOP to stop infinite measurements.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_NOP)', - 'Placeholder block to prevent trigger model renumbering.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_NOP', - 'The "trigger.BLOCK_NOP" enumeration.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_NOTIFY, trigger.EVENT_NOTIFY*)', - 'Generate the specified trigger event and continue.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_NOTIFY', - 'The "trigger.BLOCK_NOTIFY" enumeration.' - ), - ParameterInformation.create( - 'trigger.EVENT_NOTIFY*', - 'Some trigger.EVENT_NOTIFY*.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_RESET_BRANCH_COUNT, counter)', - 'Resets the total branch count of the specified COUNTER block.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_RESET_BRANCH_COUNT', - 'The "trigger.BLOCK_RESET_BRANCH_COUNT" enumeration.' - ), - ParameterInformation.create( - 'counter', - 'The block number of the counter to be reset.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_SOURCE_OUTPUT, state)', - 'Sets the source to the specified output state.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_SOURCE_OUTPUT', - 'The "trigger.BLOCK_SOURCE_OUTPUT" enumeration.' - ), - ParameterInformation.create( - 'state', - 'Either smu.OFF to turn off the output source or smu.ON to turn it on.' - ), - ), - SignatureInformation.create( - 'trigger.model.setblock(blockNumber, trigger.BLOCK_WAIT, event[, clear][, logic][, event][, event])', - 'Halts execution until the specified event occurs.', - ParameterInformation.create( - 'blockNumber', - 'The sequence of the block in the trigger model.' - ), - ParameterInformation.create( - 'trigger.BLOCK_WAIT', - 'The "trigger.BLOCK_WAIT" enumeration.' - ), - ParameterInformation.create( - 'event', - 'Some trigger.EVENT_* that must occur before the trigger block allows trigger execution to continue.' - ), - ParameterInformation.create( - 'clear', - 'To clear previously detected trigger events when entering the wait block use trigger.CLEAR_ENTER. To \ -immediately act on any previously detected triggers and not clear them use trigger.CLEAR_NEVER. Defaults to \ -trigger.CLEAR_NEVER.' - ), - ParameterInformation.create( - 'logic', - 'To force each event to occur before the trigger model continues use trigger.WAIT_AND. To continue \ -trigger model execution if at least one event occurs use trigger.WAIT_OR.' - ), - ParameterInformation.create( - 'event', - 'Some trigger.EVENT_* that must occur before the trigger block allows trigger execution to continue.' - ), - ParameterInformation.create( - 'event', - 'Some trigger.EVENT_* that must occur before the trigger block allows trigger execution to continue.' - ), - ), -] - -export async function getTriggerModelCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerModelCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerModelSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerModelSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/waitcomplete.ts b/server/src/instrument/2450/waitcomplete.ts deleted file mode 100644 index 0fbbf620..00000000 --- a/server/src/instrument/2450/waitcomplete.ts +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const waitcompleteCompletions: Array = [ - { - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction waitcomplete(group)\n```\n\nwaitcomplete([group])\n\ -\n\ -Wait for all overlapped commands to complete.\n\ -\n\ -If no group is specified, the local group is used. \ -If 0, this function waits for all nodes in the system. \ -A group number may only be specified when this node is the master node.' - }, - kind: CompletionItemKind.Function, - label: 'waitcomplete', - }, -] - -const waitcompleteSignatures: Array = [ - SignatureInformation.create( - 'waitcomplete([group])', - undefined, - ParameterInformation.create( - 'group', - 'Specifies which TSP-Link group on which to wait or 0 for all nodes.' - ), - ), -] - -export async function getWaitcompleteCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(waitcompleteCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getWaitcompleteSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(waitcompleteSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/commandSet.ts b/server/src/instrument/commandSet.ts new file mode 100644 index 00000000..082c42f3 --- /dev/null +++ b/server/src/instrument/commandSet.ts @@ -0,0 +1,60 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CompletionItem, SignatureInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '.' +import { CommandDocumentation, FormattableSignatureInformation } from './provider' + +export interface CommandSetInterface { + completionDocs?: Map + completions: Array + signatures?: Array +} + +export class CommandSet implements CommandSetInterface { + readonly completionDocs: Map + readonly completions: Array + readonly signatures: Array + readonly specification: InstrumentSpec + + constructor(spec: InstrumentSpec) { + this.completionDocs = new Map() + this.completions = new Array() + this.signatures = new Array() + this.specification = spec + } + + add(set: CommandSetInterface): void { + // merge completion documentation + if (set.completionDocs !== undefined) { + set.completionDocs.forEach((value: CommandDocumentation, key: string) => { + this.completionDocs.set(key, value) + }) + } + + // merge completion items + set.completions.forEach((value: CompletionItem) => { + this.completions.push(value) + }) + + // merge signatures + if (set.signatures !== undefined) { + set.signatures.forEach((value: SignatureInformation) => { + this.signatures.push(value) + }) + } + } +} diff --git a/server/src/instrument/index.ts b/server/src/instrument/index.ts new file mode 100644 index 00000000..10a84ee1 --- /dev/null +++ b/server/src/instrument/index.ts @@ -0,0 +1,185 @@ +/* +* Copyright 2018 Tektronix Inc. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* https://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +'use strict' + +export { CommandSet, CommandSetInterface } from './commandSet' + +export interface BaseApiSpec { + label: string +} + +export interface ApiSpec extends BaseApiSpec { + children?: Array + enums?: Array +} + +export interface BeeperSpec { + /** + * 2450: 8000 + */ + maxHertz: number + /** + * 2450: 100 + */ + maxSeconds: number + /** + * 2450: 20 + */ + minHertz: number + /** + * 2450: 0.001 + */ + minSeconds: number +} + +export interface MeasureCurrentSpec { + /** + * 2450: -1.05 to 1.05; default 0 + * 2460: -7.35 to 7.35; default 0 + */ + level: RangeSpec + /** + * 2450: 1e-9 to 1; default 1e-4 + * 2460: 1e-6 to 7; default 1e-6 + */ + range: RangeSpec +} + +export interface MeasureResistanceSpec { + /** + * 2450: -2.1e6 to 2.1e6; default 0 + * 2460: -210e6 to 210e6; default 0 + */ + level: RangeSpec + /** + * 2450: 20 to 200e6; default 200,000 + * 2460: 2 to 200e6; default 200e6 + */ + range: RangeSpec +} + +export interface MeasureVoltageSpec { + /** + * 2450: -210 to 210; default 0 + * 2460: -105 to 105; default 0 + */ + level: RangeSpec + /** + * 2450: 0.02 to 200; default 0.02 + * 2460: 0.2 to 100; default 2 + */ + range: RangeSpec +} + +export interface SourceCurrentSpec { + /** + * 2450: 1e-8 + * 2460: 1e-6 + */ + rangeDefault: number + /** + * 2450: [10e-9, 100e-9, 1e-6, 10e-6, 100e-6, 1e-3, 10e-3, 100e-3, 1] + * 2460: [1e-6, 10e-6, 100e-6, 1e-3, 10e-3, 100e-3, 1, 4, 5, 7] + */ + ranges: Array +} + +export interface SourceVoltageSpec { + /** + * 2450: 2e-2 + * 2460: 200e-3 + */ + rangeDefault: number + /** + * 2450: [20e-3, 200e-3, 2, 20, 200] + * 2460: [200e-3, 2, 7, 10, 20, 100] + */ + ranges: Array +} + +export interface RangeSpec { + default?: number + high: number + low: number +} + +export interface SmuInterlockSpec { + /** + * 2450: 42 + * 2360: 42 + */ + maxNominalVoltageTripped: number + /** + * 2450: 21 + * 2460: 21 + */ + maxSourceVoltageTripped: number +} + +export interface SmuMeasureAutorangeSpec { + currentHighDefault?: number + /** + * 2450: 10e-9 + * 2460: 1e-6 + */ + currentLowDefault: number + /** + * 2450: 200e6 + * 2460: 200e6 + */ + resistanceHighDefault: number + /** + * 2450: 20 + * 2460: 2 + */ + resistanceLowDefault: number + voltageHighDefault?: number + /** + * 2450: 20 + * 2460: 200e-3 + */ + voltageLowDefault: number +} + +export interface SmuSourceSweepLog { + /** + * 2450: 1e-12 + * 2460: 1e-6 + */ + currentLevelLow: number + /** + * 2450: 1e-12 + * 2460: 200e-3 + */ + voltageLevelLow: number +} + +export interface InstrumentSpec { + beeper: BeeperSpec + current: { + measure: MeasureCurrentSpec; + source: SourceCurrentSpec; + } + overflow: number + resistance: MeasureResistanceSpec + smuInterlock: SmuInterlockSpec + smuMeasureAutorange: SmuMeasureAutorangeSpec + smuSourceSweepLog: SmuSourceSweepLog + voltage: { + measure: MeasureVoltageSpec; + source: SourceVoltageSpec; + } +} diff --git a/server/src/instrument/lua/index.ts b/server/src/instrument/lua/index.ts new file mode 100644 index 00000000..29760223 --- /dev/null +++ b/server/src/instrument/lua/index.ts @@ -0,0 +1,187 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { ApiSpec, InstrumentSpec } from '..' + +const coroutine: ApiSpec = { + children: [ + { label: 'coroutine.create' }, + { label: 'coroutine.resume' }, + { label: 'coroutine.status' }, + { label: 'coroutine.wrap' }, + { label: 'coroutine.yield' }, + ], + label: 'coroutine' +} + +const functions: ApiSpec = { + children: [ + { label: 'assert' }, + { label: 'collectgarbage' }, + { label: 'dofile' }, + { label: 'error' }, + { label: 'gcinfo' }, + { label: 'getfenv' }, + { label: 'getmetatable' }, + { label: 'ipairs' }, + { label: 'loadfile' }, + { label: 'loadstring' }, + { label: 'next' }, + { label: 'pairs' }, + { label: 'pcall' }, + { label: 'print' }, + { label: 'rawequal' }, + { label: 'rawget' }, + { label: 'rawset' }, + { label: 'require' }, + { label: 'setfenv' }, + { label: 'setmetatable' }, + { label: 'tonumber' }, + { label: 'tostring' }, + { label: 'type' }, + { label: 'unpack' }, + { label: 'xpcall' }, + ], + label: 'functions' +} + +const keywords: ApiSpec = { + children: [ + { label: 'break' }, + { label: 'do' }, + { label: 'else' }, + { label: 'elseif' }, + { label: 'end' }, + { label: 'for' }, + { label: 'function' }, + { label: 'if' }, + { label: 'in' }, + { label: 'local' }, + { label: 'repeat' }, + { label: 'return' }, + { label: 'then' }, + { label: 'until' }, + { label: 'while' }, + ], + label: 'keywords' +} + +const math: ApiSpec = { + children: [ + { label: 'math.abs' }, + { label: 'math.acos' }, + { label: 'math.asin' }, + { label: 'math.atan' }, + { label: 'math.atan2' }, + { label: 'math.ceil' }, + { label: 'math.cos' }, + { label: 'math.deg' }, + { label: 'math.exp' }, + { label: 'math.floor' }, + { label: 'math.frexp' }, + { label: 'math.ldexp' }, + { label: 'math.log' }, + { label: 'math.log10' }, + { label: 'math.max' }, + { label: 'math.min' }, + { label: 'math.pow' }, + { label: 'math.rad' }, + { label: 'math.random' }, + { label: 'math.randomseed' }, + { label: 'math.sin' }, + { label: 'math.sqrt' }, + { label: 'math.tan' }, + ], + enums: [ + { label: 'math.pi' }, + ], + label: 'math' +} + +const os: ApiSpec = { + children: [ + { label: 'os.clock' }, + { label: 'os.date' }, + { label: 'os.difftime' }, + { label: 'os.rename' }, + { label: 'os.time' }, + ], + label: 'os' +} + +const _string: ApiSpec = { + children: [ + { label: 'string.byte' }, + { label: 'string.char' }, + { label: 'string.dump' }, + { label: 'string.find' }, + { label: 'string.format' }, + { label: 'string.gsub' }, + { label: 'string.len' }, + { label: 'string.lower' }, + { label: 'string.rep' }, + { label: 'string.sub' }, + { label: 'string.upper' }, + ], + label: 'string' +} + +const table: ApiSpec = { + children: [ + { label: 'table.concat' }, + { label: 'table.insert' }, + { label: 'table.remove' }, + { label: 'table.sort' }, + ], + label: 'table' +} + +export function getLuaApiSpec(): Array { + return [ + coroutine, + functions, + keywords, + math, + os, + _string, + table + ] +} + +export function getLuaInstrumentSpec(): InstrumentSpec { + return { + beeper: { maxHertz: NaN, maxSeconds: NaN, minHertz: NaN, minSeconds: NaN }, + current: { + measure: { level: { high: NaN, low: NaN }, range: { default: NaN, high: NaN, low: NaN } }, + source: { rangeDefault: NaN, ranges: [ NaN ] } + }, + overflow: NaN, + resistance: { level: { high: NaN, low: NaN }, range: { default: NaN, high: NaN, low: NaN } }, + smuInterlock: { maxNominalVoltageTripped: NaN, maxSourceVoltageTripped: NaN }, + smuMeasureAutorange: { + currentLowDefault: NaN, + resistanceHighDefault: NaN, + resistanceLowDefault: NaN, + voltageLowDefault: NaN + }, + smuSourceSweepLog: { currentLevelLow: NaN, voltageLevelLow: NaN }, + voltage: { + measure: { level: { high: NaN, low: NaN }, range: { default: NaN, high: NaN, low: NaN } }, + source: { rangeDefault: NaN, ranges: [ NaN ] } + } + } +} diff --git a/server/src/instrument/provider/beeper.ts b/server/src/instrument/provider/beeper.ts new file mode 100644 index 00000000..9b1f58e0 --- /dev/null +++ b/server/src/instrument/provider/beeper.ts @@ -0,0 +1,66 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + kind: CompletionItemKind.Module, + label: 'beeper' + }, + { + data: ['beeper'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction beep(duration, frequency)\n```\n\nbeeper.beep(duration, frequency)\n\ +\n\ +You can use the beeper of the instrument to provide an audible signal at a specific frequency and time duration.\n\ +\n\ +Using this function from a remote interface does not affect audible errors or key click settings that were made from \ +the front panel.' + }, + kind: CompletionItemKind.Function, + label: 'beep' + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => { + return [ + { + documentation: 'The amount of time to play the tone (%{0} to %{1} seconds).' + .replace('%{0}', spec.beeper.minSeconds.toString()) + .replace('%{1}', spec.beeper.maxSeconds.toString()), + label: 'duration' + }, + { + documentation: 'The frequency of the beep (%{0} to %{1} Hz).' + .replace('%{0}', spec.beeper.minHertz.toString()) + .replace('%{1}', spec.beeper.maxHertz.toString()), + label: 'frequency' + }, + ] + }, + label: 'beeper.beep(duration, frequency)', + }, +] diff --git a/server/src/instrument/2450/buffer-enums.ts b/server/src/instrument/provider/buffer-enums.ts similarity index 91% rename from server/src/instrument/2450/buffer-enums.ts rename to server/src/instrument/provider/buffer-enums.ts index cee36264..11fb0c8f 100644 --- a/server/src/instrument/2450/buffer-enums.ts +++ b/server/src/instrument/provider/buffer-enums.ts @@ -15,9 +15,9 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const bufferEnumCompletions: Array = [ +export const completions: Array = [ { data: ['buffer'], kind: CompletionItemKind.EnumMember, @@ -74,21 +74,37 @@ const bufferEnumCompletions: Array = [ }, { data: ['buffer'], + documentation: { + kind: MarkupKind.PlainText, + value: 'Save date, time, and fractional seconds.' + }, kind: CompletionItemKind.EnumMember, label: 'SAVE_FORMAT_TIME' }, { data: ['buffer'], + documentation: { + kind: MarkupKind.PlainText, + value: 'Save seconds and fractional seconds.' + }, kind: CompletionItemKind.EnumMember, label: 'SAVE_RAW_TIME' }, { data: ['buffer'], + documentation: { + kind: MarkupKind.PlainText, + value: 'Save relative timestamps.' + }, kind: CompletionItemKind.EnumMember, label: 'SAVE_RELATIVE_TIME' }, { data: ['buffer'], + documentation: { + kind: MarkupKind.PlainText, + value: 'Save timestamps.' + }, kind: CompletionItemKind.EnumMember, label: 'SAVE_TIMESTAMP_TIME' }, @@ -292,16 +308,3 @@ const bufferEnumCompletions: Array = [ label: 'UNIT_X' } ] - -export async function getBufferEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(bufferEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/buffer-write.ts b/server/src/instrument/provider/buffer-write.ts new file mode 100644 index 00000000..2cc88937 --- /dev/null +++ b/server/src/instrument/provider/buffer-write.ts @@ -0,0 +1,158 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +/* TODO: buffer.write.reading parameter 'status' is not helpful */ + +export const completions: Array = [ + { + data: ['buffer'], + kind: CompletionItemKind.Module, + label: 'write' + }, + { + data: ['write', 'buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction format(bufferVar, units, displayDigits, extraUnits, extraDigits)\n```\n\ +\n\ +buffer.write.format(bufferVar, buffer.UNIT_\\*, buffer.DIGITS_\\*[, extraUnits][, extraDigits])\n\ +\n\ +Set the units and number of digits of readings written to the specified WRITABLE or WRITABLE_FULL buffer.\n\ +\n\ +Defines the units and the number of digits that are reported for the data. This function affects how the data is \ +shown in the reading buffer and what is shown on the front‑panel Home, Histogram, Reading Table, and Graph screens.' + }, + kind: CompletionItemKind.Function, + label: 'format' + }, + { + data: ['write', 'buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction reading(bufferVar, readingValue, seconds, fractionalSeconds, status)\n```\n\ +\n\ +buffer.write.reading(bufferVar, readingValue[, seconds][, fractionalSeconds][, status])\n\ +\n\ +Write readings into the specified WRITABLE or WRITABLE_FULL buffer.\n\ +\n\ +Data must be added in chronological order. If the time is not specified for a reading, it is set to one integer \ +second after the last reading. As you write the data, the front‑panel Home screen updates and displays the reading \ +you entered.' + }, + kind: CompletionItemKind.Function, + label: 'reading' + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.write.format(bufferVar, units, displayDigits[, extraUnits][, extraDigits])', + parameters: [ + { + documentation: 'The name of the buffer.', + label: 'bufferVar', + }, + { + documentation: 'Some buffer.UNIT_*.', + label: 'units', + }, + { + documentation: 'The number of digits to use for the first measurement. Some buffer.DIGITS_*.', + label: 'displayDigits', + }, + { + documentation: 'The units for the second measurement in the buffer index; the selections are the same \ +as units (only valid for buffer style WRITABLE_FULL); if not specified, will use the value for units.', + label: 'extraUnits', + }, + { + documentation: 'The number of digits to use for the second measurement; the selections are the same \ +as displayDigits (only valid for buffer style WRITABLE_FULL); if not specified, will use the value for displayDigits.', + label: 'extraDigits', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.write.reading(bufferVar, readingValue[, seconds][, fractionalSeconds][, status])', + parameters: [ + { + documentation: 'The name of the buffer.', + label: 'bufferVar', + }, + { + documentation: 'The first value that is recorded in the buffer index.', + label: 'readingValue', + }, + { + documentation: 'An integer that repesents the seconds.', + label: 'seconds', + }, + { + documentation: 'The portion of the time that represents the fractional seconds.', + label: 'fractionalSeconds', + }, + { + documentation: 'The reading that is the start of a group of readings: buffer.STAT_START_GROUP; set to \ +256 to graph a family of curves (default is 0).', + label: 'status', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.write.reading(bufferVar, readingValue[, extraValue][, seconds][, fractionalSeconds][, status])', + parameters: [ + { + documentation: 'The name of the buffer.', + label: 'bufferVar', + }, + { + documentation: 'The first value that is recorded in the buffer index.', + label: 'readingValue', + }, + { + documentation: 'A second value that is recorded in the buffer index (only valid for buffer style \ +WRITABLE_FULL).', + label: 'extraValue', + }, + { + documentation: 'An integer that repesents the seconds.', + label: 'seconds', + }, + { + documentation: 'The portion of the time that represents the fractional seconds.', + label: 'fractionalSeconds', + }, + { + documentation: 'The reading that is the start of a group of readings: buffer.STAT_START_GROUP; set to \ +256 to graph a family of curves (default is 0).', + label: 'status', + }, + ], + }, +] diff --git a/server/src/instrument/provider/buffer.ts b/server/src/instrument/provider/buffer.ts new file mode 100644 index 00000000..1f586c31 --- /dev/null +++ b/server/src/instrument/provider/buffer.ts @@ -0,0 +1,250 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + kind: CompletionItemKind.Module, + label: 'buffer' + }, + { + data: ['buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction clearstats(bufferVar)\n```\n\nbuffer.clearstats([bufferVar])\n\ +\n\ +Clear the statistical information associated with the specified buffer without clearing the readings.' + }, + kind: CompletionItemKind.Function, + label: 'clearstats' + }, + { + data: ['buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction delete(bufferName)\n```\n\nbuffer.delete(bufferName)\n\ +\n\ +Delete the specified, user-defined reading buffer.\n\ +\n\ +You cannot delete the default reading buffers, defbuffer1 and defbuffer2.' + }, + kind: CompletionItemKind.Function, + label: 'delete' + }, + { + data: ['buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction getstats(bufferVar)\n```\n\ +\n\ +buffer.getstats([bufferVar]) -> {max, mean, min, n, stddev}\n\ +\n\ +Returns a statistics table from the specified reading buffer.\n\ +\n\ +The stats table always has the entry "n" (number of data points).\n\ +\n\ +If n is greater than 0, then the stats table has the entries \ +"mean" (average reading), \ +"max" (subtable containing max value data), and \ +"min" (subtable containing min value data).\n\ +\n\ +The max and min subtables contain the entries "reading", "timestamp", "seconds", and "fractionalseconds".\n\ +\n\ +If n is greater than 1, then the stats table has the entry "stddev" (standard deviation).\n\ +\n\ +When the reading buffer is configured to fill continuously and overwrite older data with new data, the buffer \ +statistics include the data that was overwritten.' + }, + kind: CompletionItemKind.Function, + label: 'getstats' + }, + { + data: ['buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction make(bufferSize, style)\n```\n\ +\n\ +buffer.make(bufferSize[, buffer.STYLE_\\*]) -> bufferVar\n\ +\n\ +Create a user-defined reading buffer and set it as the active buffer.\n\ +\n\ +Newly created user-defined buffers have a default fill mode of FILL_ONCE.\n\ +\n\ +If you create a reading buffer that has the same name as an existing user-defined buffer, the existing buffer is \ +overwritten by the new buffer. Any data in the existing buffer is lost.\n\ +\n\ +You cannot assign user-defined reading buffers the name defbuffer1 and defbuffer2.' + }, + kind: CompletionItemKind.Function, + label: 'make' + }, + { + data: ['buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction save(bufferVar, fileName, timeFormat, start, end)\n```\n\ +\n\ +buffer.save(bufferVar, fileName[, buffer.SAVE_\\*][, start, end])\n\ +\n\ +Save data from the specified reading buffer to a USB flash drive.\n\ +\n\ +The filename must specify the full path (including "/usb1/"). If included, the file extension must be set to .csv (if \ +no file extension is specified, .csv is added).\n\ +\n\ +Verify that you are using a unique name to avoid overwriting any existing .csv files on the flash drive.' + }, + kind: CompletionItemKind.Function, + label: 'save' + }, + { + data: ['buffer'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction saveappend(bufferVar, fileName, timeFormat, start, end)\n```\n\ +\n\ +buffer.saveappend(bufferVar, fileName[, buffer.SAVE_\\*][, start, end])\n\ +\n\ +Append data from the specified reading buffer to a file on the USB flash drive or create the file if it does not \ +exist.\n\ +\n\ +The index column entry in the .csv file starts at 1 for each append operation.' + }, + kind: CompletionItemKind.Function, + label: 'saveappend' + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.clearstats([bufferVar])', + parameters: [ + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1 if not specified.', + label: 'bufferVar', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.delete(bufferName)', + parameters: [ + { + documentation: 'The name of a user‑defined reading buffer.', + label: 'bufferName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.getstats([bufferVar])', + parameters: [ + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1 if not specified.', + label: 'bufferVar', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.make(bufferSize[, style])', + parameters: [ + { + documentation: 'The maximum number of readings that can be stored in bufferVar; minimum is 10.', + label: 'bufferSize', + }, + { + documentation: 'The type of reading buffer to create as some buffer.STYLE_*. Defaults to \ +buffer.STYLE_STANDARD.\n\ +Once the first reading is stored in a COMPACT buffer, its range, display digits, and units cannot be changed.\n\ +WRITABLE buffers are used to import external data and cannot be used to collect readings from the instrument.', + label: 'style', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.save(bufferVar, fileName[, timeFormat][, start, end])', + parameters: [ + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer.', + label: 'bufferVar', + }, + { + documentation: 'A string that indicates the name of the file on the USB flash drive in which to save \ +the reading buffer.', + label: 'fileName', + }, + { + documentation: 'Define how date and time information from the buffer is saved in the file on the USB \ +flash drive; given as some buffer.SAVE_*.', + label: 'timeFormat', + }, + { + documentation: 'Defines the starting point in the buffer to start saving data.', + label: 'start', + }, + { + documentation: 'Defines the ending point in the buffer to stop saving data.', + label: 'end', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'buffer.saveappend(bufferVar, fileName[, timeFormat][, start, end])', + parameters: [ + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer.', + label: 'bufferVar', + }, + { + documentation: 'A string that indicates the name of the file on the USB flash drive in which to save \ +the reading buffer.', + label: 'fileName', + }, + { + documentation: 'Define how date and time information from the buffer is saved in the file on the USB \ +flash drive; given as some buffer.SAVE_*.', + label: 'timeFormat', + }, + { + documentation: 'Defines the starting point in the buffer to start saving data.', + label: 'start', + }, + { + documentation: 'Defines the ending point in the buffer to stop saving data.', + label: 'end', + }, + ], + }, +] diff --git a/server/src/instrument/2450/bufferVar.ts b/server/src/instrument/provider/bufferVar.ts similarity index 95% rename from server/src/instrument/2450/bufferVar.ts rename to server/src/instrument/provider/bufferVar.ts index 4b8ad23c..ac0679c6 100644 --- a/server/src/instrument/2450/bufferVar.ts +++ b/server/src/instrument/provider/bufferVar.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const bufferVarCompletions: Array = [ +export const completions: Array = [ // No bufferVar namespace { data: ['bufferVar'], @@ -288,16 +288,3 @@ Returns, as an array, a string indicating the unit of measure for each reading i label: 'units', }, ] - -export async function getBufferVarCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(bufferVarCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/lua/coroutine.ts b/server/src/instrument/provider/coroutine.ts similarity index 59% rename from server/src/lua/coroutine.ts rename to server/src/instrument/provider/coroutine.ts index 3398c48b..61d7bbef 100644 --- a/server/src/lua/coroutine.ts +++ b/server/src/instrument/provider/coroutine.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const coroutineCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'coroutine' @@ -91,75 +95,64 @@ Suspends execution of the current coroutine. Any arguments given are returned as }, ] -const coroutineSignatures: Array = [ - SignatureInformation.create( - 'coroutine.create(f)', - undefined, - ParameterInformation.create( - 'f', - 'A function to use as the coroutine body.' - ), - ), - SignatureInformation.create( - 'coroutine.resume(co, ...)', - undefined, - ParameterInformation.create( - 'co', - 'A coroutine object of type "thread".' - ), - ParameterInformation.create( - '...', - 'Zero or more arguments to pass to the coroutine.' - ), - ), - SignatureInformation.create( - 'coroutine.status(co)', - undefined, - ParameterInformation.create( - 'co', - 'A coroutine object of type "thread".' - ), - ), - SignatureInformation.create( - 'coroutine.wrap(f)', - undefined, - ParameterInformation.create( - 'f', - 'A function to use as the coroutine body.' - ), - ), - SignatureInformation.create( - 'coroutine.yield(...)', - undefined, - ParameterInformation.create( - '...', - 'Zero or more arguments to return as extra results to the resume function.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'coroutine.create(f)', + parameters: [ + { + documentation: 'A function to use as the coroutine body.', + label: 'f', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'coroutine.resume(co, ...)', + parameters: [ + { + documentation: 'A coroutine object of type "thread".', + label: 'co', + }, + { + documentation: 'Zero or more arguments to pass to the coroutine.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'coroutine.status(co)', + parameters: [ + { + documentation: 'A coroutine object of type "thread".', + label: 'co', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'coroutine.wrap(f)', + parameters: [ + { + documentation: 'A function to use as the coroutine body.', + label: 'f', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'coroutine.yield(...)', + parameters: [ + { + documentation: 'Zero or more arguments to return as extra results to the resume function.', + label: '...', + }, + ], + }, ] - -export async function getCoroutineCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(coroutineCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getCoroutineSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(coroutineSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/createconfigscript.ts b/server/src/instrument/provider/createconfigscript.ts new file mode 100644 index 00000000..0099dd08 --- /dev/null +++ b/server/src/instrument/provider/createconfigscript.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction createconfigscript(scriptName)\n```\n\ncreateconfigscript(scriptName)\n\ +\n\ +Create a setup file that captures most of the present settings of the instrument.\n\ +\n\ +If scriptName is set to the name of an existing script, an eventlog message is returned.\n\ +\n\ +Once created, the script that contains the settings can be run and edited like any other script.' + }, + kind: CompletionItemKind.Function, + label: 'createconfigscript', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'createconfigscript(scriptName)', + parameters: [ + { + documentation: 'A string that represents the name of the script that will be created.', + label: 'scriptName', + }, + ], + }, +] diff --git a/server/src/instrument/2450/dataqueue.ts b/server/src/instrument/provider/dataqueue.ts similarity index 67% rename from server/src/instrument/2450/dataqueue.ts rename to server/src/instrument/provider/dataqueue.ts index 10a8edc1..9e7954e5 100644 --- a/server/src/instrument/2450/dataqueue.ts +++ b/server/src/instrument/provider/dataqueue.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const dataqueueCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'dataqueue' @@ -94,51 +98,31 @@ Any returned tables and subtables are duplicates and contain no references to th }, ] -const dataqueueSignatures: Array = [ - SignatureInformation.create( - 'dataqueue.add(value[, timeout])', - undefined, - ParameterInformation.create( - 'value', - 'The data item to add; value can be of any type.' - ), - ParameterInformation.create( - 'timeout', - 'The maximum number of seconds to wait for space in the data queue.' - ), - ), - SignatureInformation.create( - 'dataqueue.next([timeout])', - undefined, - ParameterInformation.create( - 'timeout', - 'The number of seconds to wait for data in the queue.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'dataqueue.add(value[, timeout])', + parameters: [ + { + documentation: 'The data item to add; value can be of any type.', + label: 'value', + }, + { + documentation: 'The maximum number of seconds to wait for space in the data queue.', + label: 'timeout', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'dataqueue.next([timeout])', + parameters: [ + { + documentation: 'The number of seconds to wait for data in the queue.', + label: 'timeout', + }, + ], + }, ] - -export async function getDataqueueCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(dataqueueCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getDataqueueSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(dataqueueSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/delay.ts b/server/src/instrument/provider/delay.ts new file mode 100644 index 00000000..ec3038d3 --- /dev/null +++ b/server/src/instrument/provider/delay.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction delay(seconds)\n```\n\ndelay([seconds])\n\ +\n\ +Delay execution for at least the specified number of seconds and fractional seconds.\n\ +\n\ +However, the processing time may cause the instrument to delay 5μs to 10μs more than the requested delay.' + }, + kind: CompletionItemKind.Function, + label: 'delay', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'delay([seconds])', + parameters: [ + { + documentation: 'The number of seconds to delay (0 to 100 ks).', + label: 'seconds', + }, + ], + }, +] diff --git a/server/src/instrument/2450/digio-enums.ts b/server/src/instrument/provider/digio-enums.ts similarity index 89% rename from server/src/instrument/2450/digio-enums.ts rename to server/src/instrument/provider/digio-enums.ts index 3aa7d92a..37f24f83 100644 --- a/server/src/instrument/2450/digio-enums.ts +++ b/server/src/instrument/provider/digio-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const digioEnumCompletions: Array = [ +export const completions: Array = [ { data: ['digio'], documentation: { @@ -112,16 +112,3 @@ as output.' label: 'STATE_LOW' }, ] - -export async function getDigioEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(digioEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/digio-line.ts b/server/src/instrument/provider/digio-line.ts similarity index 83% rename from server/src/instrument/2450/digio-line.ts rename to server/src/instrument/provider/digio-line.ts index 77577e46..7f9c6beb 100644 --- a/server/src/instrument/2450/digio-line.ts +++ b/server/src/instrument/provider/digio-line.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const digioLineCompletions: Array = [ +export const completions: Array = [ { data: ['digio'], documentation: { @@ -72,16 +72,3 @@ May be set to high on reset, as digial inputs float high if nothing is connected label: 'state', }, ] - -export async function getDigioLineCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(digioLineCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/digio.ts b/server/src/instrument/provider/digio.ts similarity index 61% rename from server/src/instrument/2450/digio.ts rename to server/src/instrument/provider/digio.ts index 22d16aea..e6eabe9e 100644 --- a/server/src/instrument/2450/digio.ts +++ b/server/src/instrument/provider/digio.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const digioCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'digio' @@ -54,39 +58,16 @@ All six lines must be configured as digital control lines or an error will be lo }, ] -const digioSignatures: Array = [ - SignatureInformation.create( - 'digio.writeport(data)', - undefined, - ParameterInformation.create( - 'data', - 'The value to write to the port (0 to 63).' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'digio.writeport(data)', + parameters: [ + { + documentation: 'The value to write to the port (0 to 63).', + label: 'data', + }, + ], + }, ] - -export async function getDigioCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(digioCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getDigioSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(digioSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/display-enums.ts b/server/src/instrument/provider/display-enums.ts similarity index 93% rename from server/src/instrument/2450/display-enums.ts rename to server/src/instrument/provider/display-enums.ts index 622bb0c8..119c8a5b 100644 --- a/server/src/instrument/2450/display-enums.ts +++ b/server/src/instrument/provider/display-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const displayEnumCompletions: Array = [ +export const completions: Array = [ { data: ['display'], kind: CompletionItemKind.EnumMember, @@ -272,16 +272,3 @@ const displayEnumCompletions: Array = [ label: 'TEXT2' }, ] - -export async function getDisplayCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(displayEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/display-input.ts b/server/src/instrument/provider/display-input.ts new file mode 100644 index 00000000..40d1a932 --- /dev/null +++ b/server/src/instrument/provider/display-input.ts @@ -0,0 +1,234 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + data: ['display'], + kind: CompletionItemKind.Module, + label: 'input' + }, + { + data: ['input', 'display'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction number(dialogTitle, numberFormat, defaultValue, minimumValue, maximumValue)\n\ +```\n\ +\n\ +display.input.number(dialogTitle[, display.NFORMAT_\\*][, defaultValue][, minimumValue][, maximumValue]) -> \ +number | nil\n\ +\n\ +Display a number prompt and return the number entered from the front-panel; nil if Cancel is pressed.\n\ +\n\ +The prompt is displayed until it has been responded to.' + }, + kind: CompletionItemKind.Function, + label: 'number', + }, + { + data: ['input', 'display'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\n\ +function option(dialogTitle, buttonTitle1, buttonTitle2, buttonTitle3, buttonTitle4, buttonTitle5, buttonTitle6, \ +buttonTitle7, buttonTitle8, buttonTitle9, buttonTitle10)\n\ +```\n\ +\n\ +display.input.option(dialogTitle, buttonTitle1, buttonTitle2[, buttonTitle3][, buttonTitle4][, buttonTitle5][, \ +buttonTitle6][, buttonTitle7][, buttonTitle8][, buttonTitle9][, buttonTitle10]) -> display.BUTTON_OPTION | nil\n\ +\n\ +Display a custom multi-selection prompt and return display.BUTTON_OPTION where is the one-indexed button that \ +was selected from the front-panel display; nil if Cancel is pressed.\n\ +\n\ +Buttons are created and numbered () from top to bottom, left to right. If you have more than five buttons, they \ +are placed into two columns.\n\ +\n\ +The prompt is displayed until it has been responded to.' + }, + kind: CompletionItemKind.Function, + label: 'option', + }, + { + data: ['input', 'display'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction prompt(buttonSet, dialogTitle)\n```\n\ +\n\ +display.input.prompt(display.BUTTONS_\\*, dialogTitle) -> display.BUTTON_CANCEL | BUTTON_NO | BUTTON_OK | BUTTON_YES\n\ +\n\ +Display a simple multi-selection prompt and return the button selected from the front-panel. For a non-blocking \ +prompt, see display.prompt().\n\ +\n\ +The prompt is displayed until it has been responded to by the user.' + }, + kind: CompletionItemKind.Function, + label: 'prompt', + }, + { + data: ['input', 'display'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction string(dialogTitle, textFormat)\n```\n\ +\n\ +display.input.string(dialogTitle[, display.SFORMAT_\\*]) -> string | nil\n\ +\n\ +Display a string prompt and return the text entered from the front-panel; nil if Cancel is pressed.\n\ +\n\ +The prompt is displayed until it has been responded to.' + }, + kind: CompletionItemKind.Function, + label: 'string', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.input.number(dialogTitle[, numberFormat][, defaultValue][, minimumValue][, maximumValue])', + parameters: [ + { + documentation: 'A string that contains the text to be displayed as the title of the dialog box on the \ +front-panel display; can be up to 32 characters.', + label: 'dialogTitle', + }, + { + documentation: 'One of:\n\ +display.NFORMAT_INTEGER (default)\n\ +display.NFORMAT_DECIMAL\n\ +display.NFORMAT_EXPONENT\n\ +display.NFORMAT_PREFIX', + label: 'numberFormat', + }, + { + documentation: 'Value that is initially displayed in the displayed keypad.', + label: 'defaultValue', + }, + { + documentation: 'The lowest value that can be entered.', + label: 'minimumValue', + }, + { + documentation: 'The highest value that can be entered.', + label: 'maximumValue', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.input.option(dialogTitle, buttonTitle1, buttonTitle2[, buttonTitle3][, buttonTitle4][, \ +buttonTitle5][, buttonTitle6][, buttonTitle7][, buttonTitle8][, buttonTitle9][, buttonTitle10])', + parameters: [ + { + documentation: 'A string that contains the text to be displayed as the title of the dialog box on the \ +front-panel display; can be up to 32 characters.', + label: 'dialogTitle', + }, + { + documentation: 'A string that contains the name of the first button; up to 15 characters.', + label: 'buttonTitle1', + }, + { + documentation: 'A string that contains the name of the second button; up to 15 characters.', + label: 'buttonTitle2', + }, + { + documentation: 'A string that contains the name of the second button; up to 15 characters.', + label: 'buttonTitle2', + }, + { + documentation: 'A string that contains the name of the third button; up to 15 characters.', + label: 'buttonTitle3', + }, + { + documentation: 'A string that contains the name of the fourth button; up to 15 characters.', + label: 'buttonTitle4', + }, + { + documentation: 'A string that contains the name of the fifth button; up to 15 characters.', + label: 'buttonTitle5', + }, + { + documentation: 'A string that contains the name of the sixth button; up to 15 characters.', + label: 'buttonTitle6', + }, + { + documentation: 'A string that contains the name of the seventh button; up to 15 characters.', + label: 'buttonTitle7', + }, + { + documentation: 'A string that contains the name of the eighth button; up to 15 characters.', + label: 'buttonTitle8', + }, + { + documentation: 'A string that contains the name of the ninth button; up to 15 characters.', + label: 'buttonTitle9', + }, + { + documentation: 'A string that contains the name of the tenth button; up to 15 characters.', + label: 'buttonTitle10', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.input.prompt(buttonSet[, dialogTitle])', + parameters: [ + { + documentation: 'One of:\n\ +display.BUTTONS_OK\n\ +display.BUTTONS_CANCEL\n\ +display.BUTTONS_OKCANCEL\n\ +display.BUTTONS_YESNO\n\ +display.BUTTONS_YESNOCANCEL', + label: 'buttonSet', + }, + { + documentation: 'A string that contains the text to be displayed as the title of the dialog box on the \ +front-panel display; can be up to 127 characters.', + label: 'dialogTitle', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.input.string(dialogTitle[, textFormat])', + parameters: [ + { + documentation: 'A string that contains the text to be displayed as the title of the dialog box on the \ +front-panel display; can be up to 32 characters.', + label: 'dialogTitle', + }, + { + documentation: 'One of:\n\ +display.SFORMAT_ANY (default)\n\ +display.SFORMAT_UPPER_LOWER\n\ +display.SFORMAT_UPPER\n\ +display.SFORMAT_BUFFER_NAME', + label: 'textFormat', + }, + ], + }, +] diff --git a/server/src/instrument/2450/display.ts b/server/src/instrument/provider/display.ts similarity index 63% rename from server/src/instrument/2450/display.ts rename to server/src/instrument/provider/display.ts index 7bda0bf7..ad33536d 100644 --- a/server/src/instrument/2450/display.ts +++ b/server/src/instrument/provider/display.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const displayCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'display' @@ -138,13 +142,14 @@ This command waits until a user responds to a front‑panel prompt that was crea }, ] -const displaySignatures: Array = [ - SignatureInformation.create( - 'display.changescreen(screenName)', - undefined, - ParameterInformation.create( - 'screenName', - 'One of:\n\ +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.changescreen(screenName)', + parameters: [ + { + documentation: 'One of:\n\ display.SCREEN_HOME\n\ display.SCREEN_HOME_LARGE_READING\n\ display.SCREEN_READING_TABLE\n\ @@ -154,91 +159,76 @@ display.SCREEN_GRAPH_SWIPE\n\ display.SCREEN_SETTINGS_SWIPE\n\ display.SCREEN_SOURCE_SWIPE\n\ display.SCREEN_STATS_SWIPE\n\ -display.SCREEN_USER_SWIPE' - ), - ), - SignatureInformation.create( - 'display.delete(promptID)', - undefined, - ParameterInformation.create( - 'promptID', - 'An object reference returned by display.prompt().' - ), - ), - SignatureInformation.create( - 'display.prompt(buttonSet, promptText)', - undefined, - ParameterInformation.create( - 'buttonSet', - 'One of:\n\ +display.SCREEN_USER_SWIPE', + label: 'screenName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.delete(promptID)', + parameters: [ + { + documentation: 'An object reference returned by display.prompt().', + label: 'promptID', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.prompt(buttonSet, promptText)', + parameters: [ + { + documentation: 'One of:\n\ display.BUTTONS_NONE\n\ display.BUTTONS_OK\n\ display.BUTTONS_CANCEL\n\ display.BUTTONS_OKCANCEL\n\ display.BUTTONS_YESNO\n\ -display.BUTTONS_YESNOCANCEL' - ), - ParameterInformation.create( - 'promptText', - 'A string that contains the text that is displayed above the prompts.' - ), - ), - SignatureInformation.create( - 'display.settext(position, userDisplayText)', - undefined, - ParameterInformation.create( - 'position', - 'One of:\n\ -display.TEXT1 (top line)\n\ -display.TEXT2 (bottom line)' - ), - ParameterInformation.create( - 'userDisplayText', - 'String that contains the message for the USER swipe screen.\n\ -If position is display.TEXT1, then up to 20 characters can be displayed. \ -If position is display.TEXT2, then up to 32 characters are available.' - ), - ), - SignatureInformation.create( - 'display.waitevent([timeout])', - undefined, - ParameterInformation.create( - 'timeout', - 'The amount of time to wait before timing out; time is 0 to 300 s, where 0 (default) waits indefinitely.' - ), - ParameterInformation.create( - 'subID', - 'The returned value after a button is pressed on the front panel. One of:\n\ -display.BUTTON_YES\n\ -display.BUTTON_NO\n\ -display.BUTTON_OK\n\ -display.BUTTON_CANCEL.' - ), - ), +display.BUTTONS_YESNOCANCEL', + label: 'buttonSet', + }, + { + documentation: 'A string that contains the text that is displayed above the prompts.', + label: 'promptText', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.settext(position, userDisplayText)', + parameters: [ + { + documentation: 'Some display.TEXT*.\n\ +TEXT1 places the text on the top line and TEXT2 on the bottom line.', + label: 'position', + }, + { + documentation: 'String that contains the message for the USER swipe screen.\n\ +If position is display.TEXT1, then up to 20 characters can be displayed. If position is display.TEXT2, then up to 32 \ +characters are available.', + label: 'userDisplayText', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'display.waitevent([timeout])', + parameters: [ + { + documentation: 'The amount of time to wait before timing out; time is 0 to 300 s, where 0 (default) \ +waits indefinitely.', + label: 'timeout', + }, + { + documentation: 'The returned value after a button is pressed on the front panel. One of \ +display.BUTTON_YES, BUTTON_NO, BUTTON_OK, or BUTTON_CANCEL.', + label: 'subID', + }, + ], + }, ] - -export async function getDisplayCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(displayCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getDisplaySignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(displaySignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/eventlog-enums.ts b/server/src/instrument/provider/eventlog-enums.ts similarity index 76% rename from server/src/instrument/2450/eventlog-enums.ts rename to server/src/instrument/provider/eventlog-enums.ts index c5981f19..be289f68 100644 --- a/server/src/instrument/2450/eventlog-enums.ts +++ b/server/src/instrument/provider/eventlog-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const eventlogEnumCompletions: Array = [ +export const completions: Array = [ { data: ['eventlog'], detail: 'eventlog.SEV_ERROR: 1', @@ -47,16 +47,3 @@ const eventlogEnumCompletions: Array = [ label: 'SEV_ALL' }, ] - -export async function getEventlogEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(eventlogEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/eventlog.ts b/server/src/instrument/provider/eventlog.ts similarity index 57% rename from server/src/instrument/2450/eventlog.ts rename to server/src/instrument/provider/eventlog.ts index 65341e42..e8d3099b 100644 --- a/server/src/instrument/2450/eventlog.ts +++ b/server/src/instrument/provider/eventlog.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const eventlogCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'eventlog' @@ -97,86 +101,60 @@ The .csv extension is automatically added to the file name.' }, ] -const eventlogSignatures: Array = [ - SignatureInformation.create( - 'eventlog.getcount([eventType])', - undefined, - ParameterInformation.create( - 'eventType', - 'Limit the return to specific event log types as defined by:\n\ -eventlog.SEV_ERROR (1)\n\ -eventlog.SEV_WARN (2)\n\ -eventlog.SEV_INFO (4)\n\ -eventlog.SEV_ALL (7)\n\ -Combinations via bitwise OR are supported.' - ), - ), - SignatureInformation.create( - 'eventlog.next([eventType])', - undefined, - ParameterInformation.create( - 'eventType', - 'Limit the return to specific event log types as defined by:\n\ -eventlog.SEV_ERROR (1)\n\ -eventlog.SEV_WARN (2)\n\ -eventlog.SEV_INFO (4)\n\ -eventlog.SEV_ALL (7)\n\ -Combinations via bitwise OR are supported.' - ), - ), - SignatureInformation.create( - 'eventlog.post(message[, eventType])', - undefined, - ParameterInformation.create( - 'message', - 'String that contains the message.' - ), - ParameterInformation.create( - 'eventType', - 'One of:\n`eventlog.SEV_ERROR` (1)\n`eventlog.SEV_WARN` (2)\n`eventlog.SEV_INFO` (4, default)' - ), - ), - SignatureInformation.create( - 'eventlog.save(filename, eventType)', - undefined, - ParameterInformation.create( - 'filename', - 'A string that represents the name of the file to be saved.' - ), - ParameterInformation.create( - 'eventType', - 'Limit the return to specific event log types as defined by:\n\ -eventlog.SEV_ERROR (1)\n\ -eventlog.SEV_WARN (2)\n\ -eventlog.SEV_INFO (4)\n\ -eventlog.SEV_ALL (7)\n\ -Combinations via bitwise OR are supported.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'eventlog.getcount([eventType])', + parameters: [ + { + documentation: 'Limit the return to specific event log types as defined by eventlog.SEV_*.\n\ +Combinations via bitwise OR are supported.', + label: 'eventType', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'eventlog.next([eventType])', + parameters: [ + { + documentation: 'Limit the return to specific event log types as defined by eventlog.SEV_*.\n\ +Combinations via bitwise OR are supported.', + label: 'eventType', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'eventlog.post(message[, eventType])', + parameters: [ + { + documentation: 'String that contains the message.', + label: 'message', + }, + { + documentation: 'The type of event to post as some eventlog.SEV_*. Defaults to eventlog.SEV_INFO.', + label: 'eventType', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'eventlog.save(filename, eventType)', + parameters: [ + { + documentation: 'A string that represents the name of the file to be saved.', + label: 'filename', + }, + { + documentation: 'Limit the return to specific event log types as defined by eventlog.SEV_*.\n\ +Combinations via bitwise OR are supported.', + label: 'eventType', + }, + ], + }, ] - -export async function getEventlogCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(eventlogCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getEventlogSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(eventlogSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/exit.ts b/server/src/instrument/provider/exit.ts similarity index 73% rename from server/src/instrument/2450/exit.ts rename to server/src/instrument/provider/exit.ts index f8a30fce..b0c52f2c 100644 --- a/server/src/instrument/2450/exit.ts +++ b/server/src/instrument/provider/exit.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const exitCompletions: Array = [ +export const completions: Array = [ { detail: 'This function stops a script that is presently running.', documentation: { @@ -33,16 +33,3 @@ If overlapped commands are required to finish, call waitcomplete() before callin label: 'exit', }, ] - -export async function getExitCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(exitCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/file-enums.ts b/server/src/instrument/provider/file-enums.ts similarity index 75% rename from server/src/instrument/2450/file-enums.ts rename to server/src/instrument/provider/file-enums.ts index e0d8cc17..ce90ef87 100644 --- a/server/src/instrument/2450/file-enums.ts +++ b/server/src/instrument/provider/file-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const fileEnumCompletions: Array = [ +export const completions: Array = [ { data: ['file'], kind: CompletionItemKind.EnumMember, @@ -49,16 +49,3 @@ const fileEnumCompletions: Array = [ label: 'READ_NUMBER' }, ] - -export async function getFileEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(fileEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/file.ts b/server/src/instrument/provider/file.ts similarity index 59% rename from server/src/instrument/2450/file.ts rename to server/src/instrument/provider/file.ts index 76943368..a3e55eb7 100644 --- a/server/src/instrument/2450/file.ts +++ b/server/src/instrument/provider/file.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const fileCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'file' @@ -122,97 +126,83 @@ Files should be closed before script exit via file.close().' }, ] -const fileSignatures: Array = [ - SignatureInformation.create( - 'file.close(fileNumber)', - undefined, - ParameterInformation.create( - 'fileNumber', - 'A file reference returned from the file.open() function.' - ), - ), - SignatureInformation.create( - 'file.flush(fileNumber)', - undefined, - ParameterInformation.create( - 'fileNumber', - 'A file reference returned from the file.open() function.' - ), - ), - SignatureInformation.create( - 'file.mkdir(path)', - undefined, - ParameterInformation.create( - 'path', - "Directory path. May begin with '/usb1/'." - ), - ), - SignatureInformation.create( - 'file.open(fileName, accessType)', - undefined, - ParameterInformation.create( - 'fileName', - 'Absolute filepath to the target file.' - ), - ParameterInformation.create( - 'accessType', - 'One of:\n\ -file.MODE_APPEND\n\ -file.MODE_READ\n\ -file.MODE_WRITE' - ), - ), - SignatureInformation.create( - 'file.read(fileNumber, readAction)', - undefined, - ParameterInformation.create( - 'fileNumber', - 'A file reference returned from the file.open() function.' - ), - ParameterInformation.create( - 'readAction', - 'One of:\n\ -file.READ_LINE\n\ -file.READ_NUMBER\n\ -file.READ_ALL' - ), - ), - SignatureInformation.create( - 'file.write(fileNumber, data)', - undefined, - ParameterInformation.create( - 'fileNumber', - 'A file reference returned from the file.open() function.' - ), - ParameterInformation.create( - 'data', - 'The string to write to the file.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'file.close(fileNumber)', + parameters: [ + { + documentation: 'A file reference returned from the file.open() function.', + label: 'fileNumber', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'file.flush(fileNumber)', + parameters: [ + { + documentation: 'A file reference returned from the file.open() function.', + label: 'fileNumber', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'file.mkdir(path)', + parameters: [ + { + documentation: 'Directory path. May begin with "/usb1/".', + label: 'path', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'file.open(fileName, accessType)', + parameters: [ + { + documentation: 'Absolute filepath to the target file.', + label: 'fileName', + }, + { + documentation: 'Some: file.MODE_*', + label: 'accessType', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'file.read(fileNumber, readAction)', + parameters: [ + { + documentation: 'A file reference returned from the file.open() function.', + label: 'fileNumber', + }, + { + documentation: 'Some file.READ_*', + label: 'readAction', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'file.write(fileNumber, data)', + parameters: [ + { + documentation: 'A file reference returned from the file.open() function.', + label: 'fileNumber', + }, + { + documentation: 'The string to write to the file.', + label: 'data', + }, + ], + }, ] - -export async function getFileCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(fileCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getFileSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(fileSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/format-enums.ts b/server/src/instrument/provider/format-enums.ts similarity index 77% rename from server/src/instrument/2450/format-enums.ts rename to server/src/instrument/provider/format-enums.ts index f85f503f..1c933efe 100644 --- a/server/src/instrument/2450/format-enums.ts +++ b/server/src/instrument/provider/format-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const formatEnumCompletions: Array = [ +export const completions: Array = [ { data: ['format'], kind: CompletionItemKind.EnumMember, @@ -48,16 +48,3 @@ const formatEnumCompletions: Array = [ label: 'REAL64' }, ] - -export async function getFormatEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(formatEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/format.ts b/server/src/instrument/provider/format.ts similarity index 83% rename from server/src/instrument/2450/format.ts rename to server/src/instrument/provider/format.ts index f3ce8862..7841e45f 100644 --- a/server/src/instrument/2450/format.ts +++ b/server/src/instrument/provider/format.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const formatCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'format' @@ -64,16 +64,3 @@ When in ASCII format, multiple elements are separated with a comma and space.' label: 'data', }, ] - -export async function getFormatCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(formatCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/lua/functions.ts b/server/src/instrument/provider/functions.ts similarity index 54% rename from server/src/lua/functions.ts rename to server/src/instrument/provider/functions.ts index 4d96361a..0b521397 100644 --- a/server/src/lua/functions.ts +++ b/server/src/instrument/provider/functions.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const functionCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { documentation: { kind: MarkupKind.Markdown, @@ -346,275 +350,322 @@ otherwise the following values are those returned by function f.' }, ] -const functionSignatures: Array = [ - SignatureInformation.create( - 'assert(condition[, message])', - undefined, - ParameterInformation.create( - 'condition', - 'A boolean condition to evaluate.' - ), - ParameterInformation.create( - 'message', - 'Optional failure message string. Defaults to "assertion failed!"' - ), - ), - SignatureInformation.create( - 'collectgarbage([limit])', - undefined, - ParameterInformation.create( - 'limit', - 'A number representing the garbage-collection threshold in kilobytes.' - ), - ), - SignatureInformation.create( - 'dofile(filename)', - undefined, - ParameterInformation.create( - 'filename', - 'A string representing the path of the file to execute.' - ), - ), - SignatureInformation.create( - 'error(message[, level])', - undefined, - ParameterInformation.create( - 'message', - 'An error message string.' - ), - ParameterInformation.create( - 'level', - 'Stack level of the error location starting at 1. Defaults to 1 (here).' - ), - ), - SignatureInformation.create( - 'getfenv([f])', - undefined, - ParameterInformation.create( - 'f', - 'A function name or a stack level starting at 0 (global environment). Defaults to 1 (here).' - ), - ), - SignatureInformation.create( - 'getmetatable(object)', - undefined, - ParameterInformation.create( - 'object', - 'The target object of the function call.' - ), - ), - SignatureInformation.create( - 'ipairs(t)', - undefined, - ParameterInformation.create( - 't', - 'The table to iterate over.' - ), - ), - SignatureInformation.create( - 'loadfile(filename)', - undefined, - ParameterInformation.create( - 'filename', - 'A string representing the path of the file to load.' - ), - ), - SignatureInformation.create( - 'loadstring(chunkString[, chunkName])', - undefined, - ParameterInformation.create( - 'chunkString', - 'The string to load as a chunk.' - ), - ParameterInformation.create( - 'chunkName', - 'A string representing the name of the loaded chunk.' - ), - ), - SignatureInformation.create( - 'next(t[, i])', - undefined, - ParameterInformation.create( - 't', - 'The table to iterate over.' - ), - ParameterInformation.create( - 'i', - 'The previously returned index or nil to return the first index.' - ), - ), - SignatureInformation.create( - 'pairs(t)', - undefined, - ParameterInformation.create( - 't', - 'The table to iterate over.' - ), - ), - SignatureInformation.create( - 'pcall(f[, ...])', - undefined, - ParameterInformation.create( - 'f', - 'The function to call in protected mode.' - ), - ParameterInformation.create( - '...', - 'Zero or more arguments that will be passed to function f.' - ), - ), - SignatureInformation.create( - 'print(...)', - undefined, - ParameterInformation.create( - '...', - 'One or more values separated with commas.' - ), - ), - SignatureInformation.create( - 'rawequal(x, y)', - undefined, - ParameterInformation.create( - 'x', - 'An object whose equality will be compared against object y.' - ), - ParameterInformation.create( - 'y', - 'An object whose equality will be compared against object x.' - ), - ), - SignatureInformation.create( - 'rawget(t, i)', - undefined, - ParameterInformation.create( - 't', - 'The table to access.' - ), - ParameterInformation.create( - 'i', - 'The index of table t to access.' - ), - ), - SignatureInformation.create( - 'rawset(t, i, v)', - undefined, - ParameterInformation.create( - 't', - 'The table to access.' - ), - ParameterInformation.create( - 'i', - 'The index of table t to set.' - ), - ParameterInformation.create( - 'v', - 'The value of the table t at index i.' - ), - ), - SignatureInformation.create( - 'require(packagename)', - undefined, - ParameterInformation.create( - 'packagename', - 'A string or path string representing the package to load.' - ), - ), - SignatureInformation.create( - 'setfenv(f, t)', - undefined, - ParameterInformation.create( - 'f', - 'A function name or a stack level starting at 0 (current execution context).' - ), - ParameterInformation.create( - 't', - 'The new environment table.' - ), - ), - SignatureInformation.create( - 'setmetatable(t, m)', - undefined, - ParameterInformation.create( - 't', - 'The table whose metatable will be altered.' - ), - ParameterInformation.create( - 'm', - 'The new metatable or nil.' - ), - ), - SignatureInformation.create( - 'tonumber(v[, base])', - undefined, - ParameterInformation.create( - 'v', - 'Some value to convert.' - ), - ParameterInformation.create( - 'base', - 'Desired numeric base.' - ), - ), - SignatureInformation.create( - 'tostring(v)', - undefined, - ParameterInformation.create( - 'v', - 'Some value to convert.' - ), - ), - SignatureInformation.create( - 'type(v)', - undefined, - ParameterInformation.create( - 'v', - 'Some value to query.' - ), - ), - SignatureInformation.create( - 'unpack(list)', - undefined, - ParameterInformation.create( - 'list', - 'The list whose values will be returned.' - ), - ), - SignatureInformation.create( - 'xpcall(f, errHandler)', - undefined, - ParameterInformation.create( - 'f', - 'The function to call in protected mode.' - ), - ParameterInformation.create( - 'errHandler', - 'The function to call if an error occurs.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'assert(condition[, message])', + parameters: [ + { + documentation: 'A boolean condition to evaluate.', + label: 'condition', + }, + { + documentation: 'Optional failure message string. Defaults to "assertion failed!"', + label: 'message', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'collectgarbage([limit])', + parameters: [ + { + documentation: 'A number representing the garbage-collection threshold in kilobytes.', + label: 'limit', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'dofile(filename)', + parameters: [ + { + documentation: 'A string representing the path of the file to execute.', + label: 'filename', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'error(message[, level])', + parameters: [ + { + documentation: 'An error message string.', + label: 'message', + }, + { + documentation: 'Stack level of the error location starting at 1. Defaults to 1 (here).', + label: 'level', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'getfenv([f])', + parameters: [ + { + documentation: 'A function name or a stack level starting at 0 (global environment). Defaults to 1 \ +(here).', + label: 'f', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'getmetatable(object)', + parameters: [ + { + documentation: 'The target object of the function call.', + label: 'object', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'ipairs(t)', + parameters: [ + { + documentation: 'The table to iterate over.', + label: 't', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'loadfile(filename)', + parameters: [ + { + documentation: 'A string representing the path of the file to load.', + label: 'filename', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'loadstring(chunkString[, chunkName])', + parameters: [ + { + documentation: 'The string to load as a chunk.', + label: 'chunkString', + }, + { + documentation: 'A string representing the name of the loaded chunk.', + label: 'chunkName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'next(t[, i])', + parameters: [ + { + documentation: 'The table to iterate over.', + label: 't', + }, + { + documentation: 'The previously returned index or nil to return the first index.', + label: 'i', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'pairs(t)', + parameters: [ + { + documentation: 'The table to iterate over.', + label: 't', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'pcall(f[, ...])', + parameters: [ + { + documentation: 'The function to call in protected mode.', + label: 'f', + }, + { + documentation: 'Zero or more arguments that will be passed to function f.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'print(...)', + parameters: [ + { + documentation: 'One or more values separated with commas.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'rawequal(x, y)', + parameters: [ + { + documentation: 'An object whose equality will be compared against object y.', + label: 'x', + }, + { + documentation: 'An object whose equality will be compared against object x.', + label: 'y', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'rawget(t, i)', + parameters: [ + { + documentation: 'The table to access.', + label: 't', + }, + { + documentation: 'The index of table t to access.', + label: 'i', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'rawset(t, i, v)', + parameters: [ + { + documentation: 'The table to access.', + label: 't', + }, + { + documentation: 'The index of table t to set.', + label: 'i', + }, + { + documentation: 'The value of the table t at index i.', + label: 'v', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'require(packagename)', + parameters: [ + { + documentation: 'A string or path string representing the package to load.', + label: 'packagename', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'setfenv(f, t)', + parameters: [ + { + documentation: 'A function name or a stack level starting at 0 (current execution context).', + label: 'f', + }, + { + documentation: 'The new environment table.', + label: 't', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'setmetatable(t, m)', + parameters: [ + { + documentation: 'The table whose metatable will be altered.', + label: 't', + }, + { + documentation: 'The new metatable or nil.', + label: 'm', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tonumber(v[, base])', + parameters: [ + { + documentation: 'Some value to convert.', + label: 'v', + }, + { + documentation: 'Desired numeric base.', + label: 'base', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tostring(v)', + parameters: [ + { + documentation: 'Some value to convert.', + label: 'v', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'type(v)', + parameters: [ + { + documentation: 'Some value to query.', + label: 'v', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'unpack(list)', + parameters: [ + { + documentation: 'The list whose values will be returned.', + label: 'list', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'xpcall(f, errHandler)', + parameters: [ + { + documentation: 'The function to call in protected mode.', + label: 'f', + }, + { + documentation: 'The function to call if an error occurs.', + label: 'errHandler', + }, + ], + }, ] - -export async function getFunctionCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(functionCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getFunctionSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(functionSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/gpib.ts b/server/src/instrument/provider/gpib.ts similarity index 80% rename from server/src/instrument/2450/gpib.ts rename to server/src/instrument/provider/gpib.ts index 9998715a..4b4ce757 100644 --- a/server/src/instrument/2450/gpib.ts +++ b/server/src/instrument/provider/gpib.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const gpibCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'gpib' @@ -45,16 +45,3 @@ The reset() function does not affect a GPIB address set remotely.' label: 'address', }, ] - -export async function getGpibCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(gpibCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/index.ts b/server/src/instrument/provider/index.ts new file mode 100644 index 00000000..bae3505d --- /dev/null +++ b/server/src/instrument/provider/index.ts @@ -0,0 +1,172 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import { CompletionItem, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' + +import { ApiSpec, BaseApiSpec, CommandSet, CommandSetInterface, InstrumentSpec } from '..' + +export interface CommandDocumentation { + kind: MarkupKind + toString(spec: InstrumentSpec): string +} + +export interface FormattableSignatureInformation extends SignatureInformation { + getFormattedParameters(spec: InstrumentSpec): Array +} + +/** + * Convert a root namespace label to the module name which stores it. For example, *buffer.write* becomes + * *./buffer-write* + * + * @param label A root namespace. + * @param getEnums true to load the enums file associated with the given label. Defaults to false. + */ +function labelToModuleName(label: string, getEnums: boolean = false): string { + const result = './'.concat(label.replace(new RegExp(/\./, 'g'), '-')) + + return (getEnums) ? result.concat('-enums') : result +} + +export function resolveCompletionNamespace(item: CompletionItem): string { + if (item.data === undefined) { + return item.label + } + + return [item.label].concat(item.data).reverse().join('.') +} + +export function resolveSignatureNamespace(item: SignatureInformation): string | undefined { + const openParamIndex: number = item.label.indexOf('(') + + if (openParamIndex === -1) { + return + } + + return item.label.slice(0, openParamIndex).replace(new RegExp(/\[\]/, 'g'), '') +} + +function filter(cmd: ApiSpec, spec: InstrumentSpec, isEnum: boolean, set: CommandSetInterface): CommandSetInterface { + const cmds: Array = new Array() + + if (! isEnum + && cmd.label.localeCompare('keywords') !== 0 + && cmd.label.localeCompare('functions') !== 0) { + // add the root namespace to the list of cmds we want + cmds.push({ label: cmd.label }) + } + + if (! isEnum) { + if (cmd.children !== undefined) { + cmd.children.forEach((child: BaseApiSpec) => { cmds.push(child) }) + } + } + else { + if (cmd.enums !== undefined) { + cmd.enums.forEach((enumItem: BaseApiSpec) => { cmds.push(enumItem) }) + } + } + + const resultCompletionDocs: Map = new Map() + let resultCompletions: Array = new Array() + let unformattedSignatures: Array = new Array() + + cmds.forEach((cmdItem: ApiSpec) => { + // filter completion documentation + if (set.completionDocs !== undefined) { + set.completionDocs.forEach((value: CommandDocumentation, key: string) => { + // if this completion document is listed in the given API + if (cmdItem.label.localeCompare(key) === 0) { + resultCompletionDocs.set(key, value) + } + }) + } + + // filter completion items + resultCompletions = resultCompletions.concat(set.completions.filter( + (value: CompletionItem) => { + return cmdItem.label.localeCompare(resolveCompletionNamespace(value)) === 0 + }) + ) + + // filter signatures + if (set.signatures !== undefined) { + unformattedSignatures = unformattedSignatures.concat(set.signatures.filter( + (value: FormattableSignatureInformation) => { + const signaNamespace = resolveSignatureNamespace(value) + + if (signaNamespace === undefined) { + throw new Error('Unable to resolve signature namespace for ' + cmd.label) + } + + return cmdItem.label.localeCompare(signaNamespace) === 0 + }) + ) + } + }) + + // format signatures + const resultSignatures: Array = new Array() + unformattedSignatures.forEach((value: FormattableSignatureInformation) => { + resultSignatures.push({ + documentation: value.documentation, + label: value.label, + parameters: (value.parameters === undefined) ? + value.getFormattedParameters(spec) : + value.parameters.concat(value.getFormattedParameters(spec)) + }) + }) + + return { + completionDocs: (resultCompletionDocs.size === 0) ? undefined : resultCompletionDocs, + completions: resultCompletions, + signatures: (resultSignatures.length === 0) ? undefined : resultSignatures + } +} + +export async function generateCommandSet(apiSpecs: Array, spec: InstrumentSpec): Promise { + return new Promise(( + resolve: (value?: CommandSet) => void, + reject: (reason?: Error) => void + ): void => { + try { + const result: CommandSet = new CommandSet(spec) + + apiSpecs.forEach((api: ApiSpec) => { + const cmdModule: CommandSetInterface = require(labelToModuleName(api.label)) + + result.add(filter(api, spec, false, { + completionDocs: cmdModule.completionDocs, + completions: cmdModule.completions, + signatures: cmdModule.signatures + })) + + // any enums must be loaded speparately due to the command storage scheme + if (api.enums !== undefined) { + const enumModule: CommandSetInterface = require(labelToModuleName(api.label, true)) + + result.add(filter(api, spec, true, { + completionDocs: enumModule.completionDocs, + completions: enumModule.completions, + signatures: enumModule.signatures + })) + } + }) + + resolve(result) + } catch (e) { + reject(new Error(e.toString())) + } + }) +} diff --git a/server/src/lua/keywords.ts b/server/src/instrument/provider/keywords.ts similarity index 81% rename from server/src/lua/keywords.ts rename to server/src/instrument/provider/keywords.ts index e64c83f1..b75ab99c 100644 --- a/server/src/lua/keywords.ts +++ b/server/src/instrument/provider/keywords.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const keywordCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Keyword, label: 'break' @@ -79,16 +79,3 @@ const keywordCompletions: Array = [ label: 'while' }, ] - -export async function getKeywordCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(keywordCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/lan-enums.ts b/server/src/instrument/provider/lan-enums.ts similarity index 67% rename from server/src/instrument/2450/lan-enums.ts rename to server/src/instrument/provider/lan-enums.ts index acec3390..bd37e48b 100644 --- a/server/src/instrument/2450/lan-enums.ts +++ b/server/src/instrument/provider/lan-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const lanEnumCompletions: Array = [ +export const completions: Array = [ { data: ['lan'], kind: CompletionItemKind.EnumMember, @@ -29,16 +29,3 @@ const lanEnumCompletions: Array = [ label: 'MODE_MANUAL' }, ] - -export async function getLanEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(lanEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/lan.ts b/server/src/instrument/provider/lan.ts similarity index 62% rename from server/src/instrument/2450/lan.ts rename to server/src/instrument/provider/lan.ts index 0ef7704a..560b444c 100644 --- a/server/src/instrument/2450/lan.ts +++ b/server/src/instrument/provider/lan.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const lanCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'lan' @@ -78,53 +82,28 @@ separated by a colon.' }, ] -const lanSignatures: Array = [ - SignatureInformation.create( - 'lan.ipconfig([method][, ipV4Address][, subnetMask][, gateway])', - undefined, - ParameterInformation.create( - 'method', - 'The method for configuring LAN settings; one of:\n\ -lan.MODE_AUTO\n\ -lan.MODE_MANUAL' - ), - ParameterInformation.create( - 'ipV4Address', - 'LAN IP address; must be a valid IPv4 address.' - ), - ParameterInformation.create( - 'subnetMask', - 'The LAN subnet mask; must be a valid IPv4 subnet mask.' - ), - ParameterInformation.create( - 'gateway', - 'The LAN default gateway; must be a valid IPv4 address.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'lan.ipconfig([method][, ipV4Address][, subnetMask][, gateway])', + parameters: [ + { + documentation: 'The method for configuring LAN settings; Some lan.MODE_*', + label: 'method', + }, + { + documentation: 'LAN IP address; must be a valid IPv4 address.', + label: 'ipV4Address', + }, + { + documentation: 'The LAN subnet mask; must be a valid IPv4 subnet mask.', + label: 'subnetMask', + }, + { + documentation: 'The LAN default gateway; must be a valid IPv4 address.', + label: 'gateway', + }, + ], + }, ] - -export async function getLanCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(lanCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getLanSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(lanSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/localnode-enums.ts b/server/src/instrument/provider/localnode-enums.ts similarity index 75% rename from server/src/instrument/2450/localnode-enums.ts rename to server/src/instrument/provider/localnode-enums.ts index 1028eb78..85e7dd47 100644 --- a/server/src/instrument/2450/localnode-enums.ts +++ b/server/src/instrument/provider/localnode-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const localnodeEnumCompletions: Array = [ +export const completions: Array = [ { data: ['localnode'], kind: CompletionItemKind.EnumMember, @@ -49,16 +49,3 @@ const localnodeEnumCompletions: Array = [ label: 'ENABLE' }, ] - -export async function getLocalnodeEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(localnodeEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/localnode.ts b/server/src/instrument/provider/localnode.ts similarity index 70% rename from server/src/instrument/2450/localnode.ts rename to server/src/instrument/provider/localnode.ts index f6dfeae6..b7397ae9 100644 --- a/server/src/instrument/2450/localnode.ts +++ b/server/src/instrument/provider/localnode.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const localnodeCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'localnode' @@ -183,95 +187,78 @@ Returns the firmware version of the instrument as a string.' }, ] -const localnodeSignatures: Array = [ - SignatureInformation.create( - 'localnode.settime(utcTime)', - undefined, - ParameterInformation.create( - 'utcTime', - 'UTC time string as formatted by os.time.' - ), - ), - SignatureInformation.create( - 'localnode.settime(hour, minute, second)', - undefined, - ParameterInformation.create( - 'year', - 'Year before 1970.' - ), - ParameterInformation.create( - 'month', - 'Month (1 to 12).' - ), - ParameterInformation.create( - 'day', - 'Day (1 to 31).' - ), - ParameterInformation.create( - 'hour', - 'Hour in 24‑hour time format (0 to 23).' - ), - ParameterInformation.create( - 'minute', - 'Minute (0 to 59).' - ), - ParameterInformation.create( - 'second', - 'Second (0 to 59).' - ), - ), - SignatureInformation.create( - 'localnode.settime(year, month, day, hour, minute, second)', - undefined, - ParameterInformation.create( - 'year', - 'Year before 1970.' - ), - ParameterInformation.create( - 'month', - 'Month (1 to 12).' - ), - ParameterInformation.create( - 'day', - 'Day (1 to 31).' - ), - ParameterInformation.create( - 'hour', - 'Hour in 24‑hour time format (0 to 23).' - ), - ParameterInformation.create( - 'minute', - 'Minute (0 to 59).' - ), - ParameterInformation.create( - 'second', - 'Second (0 to 59).' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'localnode.settime(utcTime)', + parameters: [ + { + documentation: 'UTC time string as formatted by os.time.', + label: 'utcTime', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'localnode.settime(hour, minute, second)', + parameters: [ + { + documentation: 'Year before 1970.', + label: 'year', + }, + { + documentation: 'Month (1 to 12).', + label: 'month', + }, + { + documentation: 'Day (1 to 31).', + label: 'day', + }, + { + documentation: 'Hour in 24‑hour time format (0 to 23).', + label: 'hour', + }, + { + documentation: 'Minute (0 to 59).', + label: 'minute', + }, + { + documentation: 'Second (0 to 59).', + label: 'second', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'localnode.settime(year, month, day, hour, minute, second)', + parameters: [ + { + documentation: 'Year before 1970.', + label: 'year', + }, + { + documentation: 'Month (1 to 12).', + label: 'month', + }, + { + documentation: 'Day (1 to 31).', + label: 'day', + }, + { + documentation: 'Hour in 24‑hour time format (0 to 23).', + label: 'hour', + }, + { + documentation: 'Minute (0 to 59).', + label: 'minute', + }, + { + documentation: 'Second (0 to 59).', + label: 'second', + }, + ], + }, ] - -export async function getLocalnodeCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(localnodeCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getLocalnodeSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(localnodeSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/math-enums.ts b/server/src/instrument/provider/math-enums.ts new file mode 100644 index 00000000..f2833afe --- /dev/null +++ b/server/src/instrument/provider/math-enums.ts @@ -0,0 +1,26 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' + +export const completions: Array = [ + { + data: ['math'], + kind: CompletionItemKind.Constant, + label: 'pi' + }, +] diff --git a/server/src/lua/math.ts b/server/src/instrument/provider/math.ts similarity index 50% rename from server/src/lua/math.ts rename to server/src/instrument/provider/math.ts index 6e6be5a8..15e1f068 100644 --- a/server/src/lua/math.ts +++ b/server/src/instrument/provider/math.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const mathCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'math' @@ -288,232 +292,278 @@ Returns the tangent of angle x in radians.' }, ] -const mathSignatures: Array = [ - SignatureInformation.create( - 'math.abs(x)', - undefined, - ParameterInformation.create( - 'x' - ), - ), - SignatureInformation.create( - 'math.acos(x)', - undefined, - ParameterInformation.create( - 'x', - 'A number on the interval [-1, +1].' - ), - ), - SignatureInformation.create( - 'math.asin(x)', - undefined, - ParameterInformation.create( - 'x', - 'A number on the interval [-1, +1].' - ), - ), - SignatureInformation.create( - 'math.atan(x)', - undefined, - ParameterInformation.create( - 'x' - ), - ), - SignatureInformation.create( - 'math.atan2(y, x)', - undefined, - ParameterInformation.create( - 'y', - 'A number representing the y-coordinate.' - ), - ParameterInformation.create( - 'x', - 'A number representing the x-coordinate.' - ), - ), - SignatureInformation.create( - 'math.ceil(x)', - undefined, - ParameterInformation.create( - 'x', - 'Number to round upward.' - ), - ), - SignatureInformation.create( - 'math.cos(x)', - undefined, - ParameterInformation.create( - 'x', - 'An angle in radians.' - ), - ), - SignatureInformation.create( - 'math.deg(x)', - undefined, - ParameterInformation.create( - 'x', - 'An angle in radians.' - ), - ), - SignatureInformation.create( - 'math.exp(x)', - undefined, - ParameterInformation.create( - 'x', - 'The exponent to raise e.' - ), - ), - SignatureInformation.create( - 'math.floor(x)', - undefined, - ParameterInformation.create( - 'x', - 'Number to round downward.' - ), - ), - SignatureInformation.create( - 'math.frexp(x)', - undefined, - ParameterInformation.create( - 'x', - 'Number to decompose into a significand and power of 2.' - ), - ), - SignatureInformation.create( - 'math.ldexp(x, exp)', - undefined, - ParameterInformation.create( - 'x', - 'Binary significand.' - ), - ParameterInformation.create( - 'exp', - 'Binary exponent.' - ), - ), - SignatureInformation.create( - 'math.log(x)', - undefined, - ParameterInformation.create( - 'x' - ), - ), - SignatureInformation.create( - 'math.log10(x)', - undefined, - ParameterInformation.create( - 'x' - ), - ), - SignatureInformation.create( - 'math.max(...)', - undefined, - ParameterInformation.create( - '...', - 'One or more numbers to compare.' - ), - ), - SignatureInformation.create( - 'math.min(...)', - undefined, - ParameterInformation.create( - '...', - 'One or more numbers to compare.' - ), - ), - SignatureInformation.create( - 'math.pow(base, exp)', - undefined, - ParameterInformation.create( - 'base' - ), - ParameterInformation.create( - 'exp' - ), - ), - SignatureInformation.create( - 'math.rad(x)', - undefined, - ParameterInformation.create( - 'x', - 'An angle in degrees.' - ), - ), - SignatureInformation.create( - 'math.random(x)', - undefined, - ParameterInformation.create( - 'x', - 'Upper bound of the inclusive interval [1, x].' - ), - ), - SignatureInformation.create( - 'math.random(x, y)', - undefined, - ParameterInformation.create( - 'x', - 'Lower bound of the inclusive interval [x, y].' - ), - ParameterInformation.create( - 'y', - 'Upper bound of the inclusive interval [x, y].' - ), - ), - SignatureInformation.create( - 'math.randomseed(x)', - undefined, - ParameterInformation.create( - 'x' - ), - ), - SignatureInformation.create( - 'math.sin(x)', - undefined, - ParameterInformation.create( - 'x', - 'An angle in degrees.' - ), - ), - SignatureInformation.create( - 'math.sqrt(x)', - undefined, - ParameterInformation.create( - 'x', - 'A non-negative number.' - ), - ), - SignatureInformation.create( - 'math.tan(x)', - undefined, - ParameterInformation.create( - 'x', - 'An angle in degrees.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.abs(x)', + parameters: [ + { + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.acos(x)', + parameters: [ + { + documentation: 'A number on the interval [-1, +1].', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.asin(x)', + parameters: [ + { + documentation: 'A number on the interval [-1, +1].', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.atan(x)', + parameters: [ + { + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.atan2(y, x)', + parameters: [ + { + documentation: 'A number representing the y-coordinate.', + label: 'y', + }, + { + documentation: 'A number representing the x-coordinate.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.ceil(x)', + parameters: [ + { + documentation: 'Number to round upward.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.cos(x)', + parameters: [ + { + documentation: 'An angle in radians.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.deg(x)', + parameters: [ + { + documentation: 'An angle in radians.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.exp(x)', + parameters: [ + { + documentation: 'The exponent to raise e.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.floor(x)', + parameters: [ + { + documentation: 'Number to round downward.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.frexp(x)', + parameters: [ + { + documentation: 'Number to decompose into a significand and power of 2.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.ldexp(x, exp)', + parameters: [ + { + documentation: 'Binary significand.', + label: 'x', + }, + { + documentation: 'Binary exponent.', + label: 'exp', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.log(x)', + parameters: [ + { + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.log10(x)', + parameters: [ + { + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.max(...)', + parameters: [ + { + documentation: 'One or more numbers to compare.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.min(...)', + parameters: [ + { + documentation: 'One or more numbers to compare.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.pow(base, exp)', + parameters: [ + { + label: 'base', + }, + { + label: 'exp', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.rad(x)', + parameters: [ + { + documentation: 'An angle in degrees.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.random(x)', + parameters: [ + { + documentation: 'Upper bound of the inclusive interval [1, x].', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.random(x, y)', + parameters: [ + { + documentation: 'Lower bound of the inclusive interval [x, y].', + label: 'x', + }, + { + documentation: 'Upper bound of the inclusive interval [x, y].', + label: 'y', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.randomseed(x)', + parameters: [ + { + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.sin(x)', + parameters: [ + { + documentation: 'An angle in degrees.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.sqrt(x)', + parameters: [ + { + documentation: 'A non-negative number.', + label: 'x', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'math.tan(x)', + parameters: [ + { + documentation: 'An angle in degrees.', + label: 'x', + }, + ], + }, ] - -export async function getMathCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(mathCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getMathSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(mathSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/node.ts b/server/src/instrument/provider/node.ts similarity index 56% rename from server/src/instrument/2450/node.ts rename to server/src/instrument/provider/node.ts index c941bf4f..15aaf1b7 100644 --- a/server/src/instrument/2450/node.ts +++ b/server/src/instrument/provider/node.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const nodeCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { documentation: { kind: MarkupKind.PlainText, @@ -66,59 +70,42 @@ Set the value of a global variable on a subordinate node from the TSP-Link maste }, ] -const nodeSignatures: Array = [ - SignatureInformation.create( - 'node[].execute(scriptCode)', - undefined, - ParameterInformation.create( - 'scriptCode', - 'A string containing the source code.' - ), - ), - SignatureInformation.create( - 'node[].getglobal(name)', - undefined, - ParameterInformation.create( - 'name', - 'The global variable name as a string.' - ), - ), - SignatureInformation.create( - 'node[].setglobal(name, value)', - undefined, - ParameterInformation.create( - 'name', - 'The global variable name as a string.' - ), - ParameterInformation.create( - 'value', - 'The value to assign to the global variable.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'node[].execute(scriptCode)', + parameters: [ + { + documentation: 'A string containing the source code.', + label: 'scriptCode', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'node[].getglobal(name)', + parameters: [ + { + documentation: 'The global variable name as a string.', + label: 'name', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'node[].setglobal(name, value)', + parameters: [ + { + documentation: 'The global variable name as a string.', + label: 'name', + }, + { + documentation: 'The value to assign to the global variable.', + label: 'value', + }, + ], + }, ] - -export async function getNodeCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(nodeCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getNodeSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(nodeSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/opc.ts b/server/src/instrument/provider/opc.ts similarity index 73% rename from server/src/instrument/2450/opc.ts rename to server/src/instrument/provider/opc.ts index dc4635d0..c338e456 100644 --- a/server/src/instrument/2450/opc.ts +++ b/server/src/instrument/provider/opc.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const opcCompletions: Array = [ +export const completions: Array = [ { documentation: { kind: MarkupKind.Markdown, @@ -32,16 +32,3 @@ Each node independently sets its operation complete bit in its own status model. label: 'opc', }, ] - -export async function getOpcCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(opcCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/lua/os.ts b/server/src/instrument/provider/os.ts similarity index 60% rename from server/src/lua/os.ts rename to server/src/instrument/provider/os.ts index 40f1e528..74255507 100644 --- a/server/src/lua/os.ts +++ b/server/src/instrument/provider/os.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const osCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'os' @@ -93,75 +97,61 @@ for a more accurate conversion.' }, ] -const osSignatures: Array = [ - SignatureInformation.create( - 'os.date([format[, time]])', - undefined, - ParameterInformation.create( - 'format', - 'A date format string. Optionally begins with "!" for UTC. "*t" returns a time table. All other format \ -specifiers follow the convention set by the C-language strftime function.' - ), - ParameterInformation.create( - 'time', - 'An optional number representing a time in seconds.' - ), - ), - SignatureInformation.create( - 'os.difftime(t1, t2)', - undefined, - ParameterInformation.create( - 't1' - ), - ParameterInformation.create( - 't2' - ), - ), - SignatureInformation.create( - 'os.rename(source, destination)', - undefined, - ParameterInformation.create( - 'source', - 'The filepath of the target file as a string.' - ), - ParameterInformation.create( - 'destination', - 'The new filepath of the source file.' - ), - ), - SignatureInformation.create( - 'os.time(t)', - undefined, - ParameterInformation.create( - 't', - 'A time table that contains a year, month, and day field. The hour, min, sec, and isdst fields are used \ -if available.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'os.date([format[, time]])', + parameters: [ + { + documentation: 'A date format string. Optionally begins with "!" for UTC. "*t" returns a time table. \ +All other format specifiers follow the convention set by the C-language strftime function.', + label: 'format', + }, + { + documentation: 'An optional number representing a time in seconds.', + label: 'time', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'os.difftime(t1, t2)', + parameters: [ + { + label: 't1', + }, + { + label: 't2', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'os.rename(source, destination)', + parameters: [ + { + documentation: 'The filepath of the target file as a string.', + label: 'source', + }, + { + documentation: 'The new filepath of the source file.', + label: 'destination', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'os.time(t)', + parameters: [ + { + documentation: 'A time table that contains a year, month, and day field. The hour, min, sec, and \ +isdst fields are used if available.', + label: 't', + }, + ], + }, ] - -export async function getOSCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(osCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getOSSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(osSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/printbuffer.ts b/server/src/instrument/provider/printbuffer.ts new file mode 100644 index 00000000..312301ca --- /dev/null +++ b/server/src/instrument/provider/printbuffer.ts @@ -0,0 +1,68 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction printbuffer(startIndex, endIndex, ...)\n```\n\ +\n\ +Generate a single response message containing data from the specified tables or reading buffer subtables. \ +Passing a reading buffer will cause its default subtable to be printed.\n\ +\n\ +The format.data attribute controls the output format of the response message.\n\ +\n\ +If the given startIndex is less than 1 or endIndex greater than the size of the table, 9.910000e+37 is returned for \ +each value outside the table indices and an event is generated.\n\ +\n\ +If overlapped commands use the specified reading buffers and the commands are not complete (at least to the \ +specified index), data will be printed as it becomes available.' + }, + kind: CompletionItemKind.Function, + label: 'printbuffer', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'printbuffer(startIndex, endIndex, ...)', + parameters: [ + { + documentation: 'Beginning index of the buffer to print; must be greater than or equal to one and less \ +than endIndex.', + label: 'startIndex', + }, + { + documentation: 'Ending index of the buffer to print; must be greater than startIndex and less than or \ +equal to the last table index.', + label: 'endIndex', + }, + { + documentation: 'One or more tables or reading buffer subtables separated with commas.', + label: '...', + }, + ], + }, +] diff --git a/server/src/instrument/provider/printnumber.ts b/server/src/instrument/provider/printnumber.ts new file mode 100644 index 00000000..5286a122 --- /dev/null +++ b/server/src/instrument/provider/printnumber.ts @@ -0,0 +1,51 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction printnumber(...)\n```\n\ +\n\ +Generate a single response message containing the specified numbers using the data format specified by \ +format.data and format.asciiprecision.' + }, + kind: CompletionItemKind.Function, + label: 'printnumber', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'printnumber(...)', + parameters: [ + { + documentation: 'One or more values separated with commas. Values are printed in the currently \ +configured format.', + label: '...', + }, + ], + }, +] diff --git a/server/src/instrument/2450/reset.ts b/server/src/instrument/provider/reset.ts similarity index 50% rename from server/src/instrument/2450/reset.ts rename to server/src/instrument/provider/reset.ts index cf8323bd..1c709660 100644 --- a/server/src/instrument/2450/reset.ts +++ b/server/src/instrument/provider/reset.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const resetCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { documentation: { kind: MarkupKind.Markdown, @@ -34,41 +38,17 @@ If system is true (default) and the local node is not the master, then an error }, ] -const resetSignatures: Array = [ - SignatureInformation.create( - 'reset([system])', - undefined, - ParameterInformation.create( - 'system', - 'true to reset all nodes (default) or false to reset the local node.\n\ -\n\ -If true and local node is not the master, then an error is logged.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'reset([system])', + parameters: [ + { + documentation: 'true to reset all nodes (default) or false to reset the local node.\n\ +If true and local node is not the master, then an error is logged.', + label: 'system', + }, + ], + }, ] - -export async function getResetCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(resetCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getResetSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(resetSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/script.ts b/server/src/instrument/provider/script.ts similarity index 55% rename from server/src/instrument/2450/script.ts rename to server/src/instrument/provider/script.ts index 9c1c86dc..b4473a84 100644 --- a/server/src/instrument/2450/script.ts +++ b/server/src/instrument/provider/script.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const scriptCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'script' @@ -51,48 +55,28 @@ For scripts residing on a USB flash drive, the given fileName should be absolute }, ] -const scriptSignatures: Array = [ - SignatureInformation.create( - 'script.delete(scriptName)', - undefined, - ParameterInformation.create( - 'scriptName', - 'A string that represents the name of the script.' - ), - ), - SignatureInformation.create( - 'script.load(fileName)', - undefined, - ParameterInformation.create( - 'fileName', - "The filepath of the script file to load.\n\ -Scripts residing on a USB flash drive should be absolute and begin with '/usb1/'." - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'script.delete(scriptName)', + parameters: [ + { + documentation: 'A string that represents the name of the script.', + label: 'scriptName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'script.load(fileName)', + parameters: [ + { + documentation: 'The filepath of the script file to load.\n\ +Scripts residing on a USB flash drive should be absolute and begin with "/usb1/".', + label: 'fileName', + }, + ], + }, ] - -export async function getScriptCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(scriptCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getScriptSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(scriptSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/scriptVar.ts b/server/src/instrument/provider/scriptVar.ts similarity index 61% rename from server/src/instrument/2450/scriptVar.ts rename to server/src/instrument/provider/scriptVar.ts index 17d29954..759dd5ca 100644 --- a/server/src/instrument/2450/scriptVar.ts +++ b/server/src/instrument/provider/scriptVar.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const scriptVarCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ // No scriptVar namespace { data: ['scriptVar'], @@ -57,39 +61,16 @@ Returns the script body as a string with lines separated by newline characters.' }, ] -const scriptVarSignatures: Array = [ - SignatureInformation.create( - 'scriptVar.save([fileName])', - undefined, - ParameterInformation.create( - 'fileName', - 'The file name to use when saving the script to a USB flash drive.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'scriptVar.save([fileName])', + parameters: [ + { + documentation: 'The file name to use when saving the script to a USB flash drive.', + label: 'fileName', + }, + ], + }, ] - -export async function getScriptVarCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(scriptVarCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getScriptVarSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(scriptVarSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-enums.ts b/server/src/instrument/provider/smu-enums.ts similarity index 95% rename from server/src/instrument/2450/smu-enums.ts rename to server/src/instrument/provider/smu-enums.ts index 5a0ea244..7f9a95c8 100644 --- a/server/src/instrument/2450/smu-enums.ts +++ b/server/src/instrument/provider/smu-enums.ts @@ -17,9 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -// starts on 25729.htm - -const smuEnumCompletions: Array = [ +export const completions: Array = [ { data: ['smu'], kind: CompletionItemKind.EnumMember, @@ -340,16 +338,3 @@ current range, whichever is greater; otherwise the current limit is not changed. label: 'UNIT_WATT' }, ] - -export async function getSmuEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-interlock.ts b/server/src/instrument/provider/smu-interlock.ts similarity index 52% rename from server/src/instrument/2450/smu-interlock.ts rename to server/src/instrument/provider/smu-interlock.ts index f546b8d7..cd480ff4 100644 --- a/server/src/instrument/2450/smu-interlock.ts +++ b/server/src/instrument/provider/smu-interlock.ts @@ -17,7 +17,31 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuInterlockCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { CommandDocumentation } from '.' + +export const completionDocs: Map = new Map([ + [ + 'smu.interlock.tripped', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.interlock.tripped\n```\n\nsmu.interlock.tripped -> smu.OFF | smu.ON\n\ +\n\ +Get the status of the interlock.\n\ +\n\ +If smu.OFF is returned the %{0} range is disabled, nominal output is limited to ±%{1}V, and attempting to source more \ +than ±%{2}V will generate an error message; otherwise all voltage ranges are available.' + .replace('%{1}', spec.voltage.measure.range.high.toString()) + .replace('%{1}', spec.smuInterlock.maxNominalVoltageTripped.toString()) + .replace('%{2}', spec.smuInterlock.maxSourceVoltageTripped.toString()) + }, + } + ], +]) + +export const completions: Array = [ { data: ['smu'], kind: CompletionItemKind.Module, @@ -25,29 +49,7 @@ const smuInterlockCompletions: Array = [ }, { data: ['interlock', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.interlock.tripped\n```\n\nsmu.interlock.tripped -> smu.OFF | smu.ON\n\ -\n\ -Get the status of the interlock.\n\ -\n\ -If smu.OFF is returned the 200V range is disabled, nominal output is limited to ±42V, and attempting to source more \ -than ±21V will generate an error message; otherwise all voltage ranges are available.' - }, kind: CompletionItemKind.Constant, label: 'tripped', }, ] - -export async function getSmuInterlockCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuInterlockCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-autozero.ts b/server/src/instrument/provider/smu-measure-autozero.ts similarity index 82% rename from server/src/instrument/2450/smu-measure-autozero.ts rename to server/src/instrument/provider/smu-measure-autozero.ts index ca524d08..d77f1735 100644 --- a/server/src/instrument/2450/smu-measure-autozero.ts +++ b/server/src/instrument/provider/smu-measure-autozero.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureAutozeroCompletions: Array = [ +export const completions: Array = [ { data: ['measure', 'smu'], kind: CompletionItemKind.Module, @@ -56,16 +56,3 @@ If the NPLC setting is less than 0.2 PLC, calling this function may result in a label: 'once', }, ] - -export async function getSmuMeasureAutozeroCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureAutozeroCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-configlist.ts b/server/src/instrument/provider/smu-measure-configlist.ts similarity index 58% rename from server/src/instrument/2450/smu-measure-configlist.ts rename to server/src/instrument/provider/smu-measure-configlist.ts index 471542f0..5fd4091d 100644 --- a/server/src/instrument/2450/smu-measure-configlist.ts +++ b/server/src/instrument/provider/smu-measure-configlist.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const smuMeasureConfiglistCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['measure', 'smu'], kind: CompletionItemKind.Module, @@ -129,98 +133,90 @@ between power cycles.' }, ] -const smuMeasureConfiglistSignatures: Array = [ - SignatureInformation.create( - 'smu.measure.configlist.create(listName)', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a measure configuration list.' - ), - ), - SignatureInformation.create( - 'smu.measure.configlist.delete(listName[, index])', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a measure configuration list.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Deletes the entire configuration list by default.' - ), - ), - SignatureInformation.create( - 'smu.measure.configlist.query(listName, index[, fieldSeparator])', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a measure configuration list.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Defaults to the first configuration index.' - ), - ParameterInformation.create( - 'fieldSeparator', - 'The string that will separate each setting.' - ), - ), - SignatureInformation.create( - 'smu.measure.configlist.recall(listName[, index])', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a measure configuration list.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Defaults to the first configuration index.' - ), - ), - SignatureInformation.create( - 'smu.measure.configlist.size(listName)', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a measure configuration list.' - ), - ), - SignatureInformation.create( - 'smu.measure.configlist.store(listName)', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a measure configuration list.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.configlist.create(listName)', + parameters: [ + { + documentation: 'A string that represents the name of a measure configuration list.', + label: 'listName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.configlist.delete(listName[, index])', + parameters: [ + { + documentation: 'A string that represents the name of a measure configuration list.', + label: 'listName', + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Deletes the entire configuration list by default.', + label: 'index', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.configlist.query(listName, index[, fieldSeparator])', + parameters: [ + { + documentation: 'A string that represents the name of a measure configuration list.', + label: 'listName', + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Defaults to the first configuration index.', + label: 'index', + }, + { + documentation: 'The string that will separate each setting.', + label: 'fieldSeparator', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.configlist.recall(listName[, index])', + parameters: [ + { + documentation: 'A string that represents the name of a measure configuration list.', + label: 'listName', + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Defaults to the first configuration index.', + label: 'index', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.configlist.size(listName)', + parameters: [ + { + documentation: 'A string that represents the name of a measure configuration list.', + label: 'listName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.configlist.store(listName)', + parameters: [ + { + documentation: 'A string that represents the name of a measure configuration list.', + label: 'listName', + }, + ], + }, ] - -export async function getSmuMeasureConfiglistCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureConfiglistCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getSmuMeasureConfiglistSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureConfiglistSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-filter.ts b/server/src/instrument/provider/smu-measure-filter.ts similarity index 87% rename from server/src/instrument/2450/smu-measure-filter.ts rename to server/src/instrument/provider/smu-measure-filter.ts index df3179a8..9a221b7c 100644 --- a/server/src/instrument/2450/smu-measure-filter.ts +++ b/server/src/instrument/provider/smu-measure-filter.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureFilterCompletions: Array = [ +export const completions: Array = [ { data: ['measure', 'smu'], kind: CompletionItemKind.Module, @@ -77,16 +77,3 @@ This attribute is saved with the active function and retained until the next ins label: 'type', }, ] - -export async function getSmuMeasureFilterCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureFilterCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-limit-high.ts b/server/src/instrument/provider/smu-measure-limit-high.ts similarity index 75% rename from server/src/instrument/2450/smu-measure-limit-high.ts rename to server/src/instrument/provider/smu-measure-limit-high.ts index 0a30bc74..bc2bf3c3 100644 --- a/server/src/instrument/2450/smu-measure-limit-high.ts +++ b/server/src/instrument/provider/smu-measure-limit-high.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureLimitHighCompletions: Array = [ +export const completions: Array = [ { data: ['limit', 'measure', 'smu'], kind: CompletionItemKind.Module, @@ -40,16 +40,3 @@ This attribute is saved with the active function and retained until the next ins label: 'value', }, ] - -export async function getSmuMeasureLimitHighCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureLimitHighCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-limit-low.ts b/server/src/instrument/provider/smu-measure-limit-low.ts similarity index 75% rename from server/src/instrument/2450/smu-measure-limit-low.ts rename to server/src/instrument/provider/smu-measure-limit-low.ts index c3acd50e..4b003558 100644 --- a/server/src/instrument/2450/smu-measure-limit-low.ts +++ b/server/src/instrument/provider/smu-measure-limit-low.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureLimitLowCompletions: Array = [ +export const completions: Array = [ { data: ['limit', 'measure', 'smu'], kind: CompletionItemKind.Module, @@ -39,16 +39,3 @@ This attribute is saved with the active function and retained until the next ins label: 'value', }, ] - -export async function getSmuMeasureLimitLowCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureLimitLowCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-limit.ts b/server/src/instrument/provider/smu-measure-limit.ts similarity index 89% rename from server/src/instrument/2450/smu-measure-limit.ts rename to server/src/instrument/provider/smu-measure-limit.ts index b1e82d0f..0f4c3087 100644 --- a/server/src/instrument/2450/smu-measure-limit.ts +++ b/server/src/instrument/provider/smu-measure-limit.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureLimitCompletions: Array = [ +export const completions: Array = [ { data: ['measure', 'smu'], documentation: { @@ -104,16 +104,3 @@ cleared after being accessed. This attribute is always cleared when changing mea label: 'fail', }, ] - -export async function getSmuMeasureLimitCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureLimitCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-math-mxb.ts b/server/src/instrument/provider/smu-measure-math-mxb.ts similarity index 83% rename from server/src/instrument/2450/smu-measure-math-mxb.ts rename to server/src/instrument/provider/smu-measure-math-mxb.ts index 507e2ebc..72bb5266 100644 --- a/server/src/instrument/2450/smu-measure-math-mxb.ts +++ b/server/src/instrument/provider/smu-measure-math-mxb.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureMathMxbCompletions: Array = [ +export const completions: Array = [ { data: ['math', 'measure', 'smu'], kind: CompletionItemKind.Module, @@ -62,16 +62,3 @@ This attribute is saved with the active function and retained until the next ins label: 'mfactor', }, ] - -export async function getSmuMeasureMathMxbCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureMathMxbCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-math.ts b/server/src/instrument/provider/smu-measure-math.ts similarity index 86% rename from server/src/instrument/2450/smu-measure-math.ts rename to server/src/instrument/provider/smu-measure-math.ts index c06884df..f6a4842a 100644 --- a/server/src/instrument/2450/smu-measure-math.ts +++ b/server/src/instrument/provider/smu-measure-math.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureMathCompletions: Array = [ +export const completions: Array = [ { data: ['measure', 'smu'], kind: CompletionItemKind.Module, @@ -75,16 +75,3 @@ This attribute is saved with the active function and retained until the next ins label: 'percent', }, ] - -export async function getSmuMeasureMathCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureMathCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure-rel.ts b/server/src/instrument/provider/smu-measure-rel.ts similarity index 72% rename from server/src/instrument/2450/smu-measure-rel.ts rename to server/src/instrument/provider/smu-measure-rel.ts index a57e562b..8932c9b7 100644 --- a/server/src/instrument/2450/smu-measure-rel.ts +++ b/server/src/instrument/provider/smu-measure-rel.ts @@ -17,7 +17,40 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuMeasureRelCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { CommandDocumentation } from '.' + +export const completionDocs: Map = new Map([ + [ + 'smu.measure.rel.level', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.measure.rel.level\n```\n\ +\n\ +Get or set the value used by the relative offset calculation to some number. Defaults to 0 for all measurement \ +functions.\n\ +\n\ +When the measurement function is set to Current, the valid range of this attribute is %{0} to %{1}.\n\ +\n\ +When the measurement function is set to Resistance, the valid range of this attribute is %{2} to %{3}.\n\ +\n\ +When the measurement function is set to Voltage, the valid range of this attribute is %{4} to %{5}.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + .replace('%{0}', spec.current.measure.level.low.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.resistance.level.low.toString()) + .replace('%{3}', spec.resistance.level.high.toString()) + .replace('%{4}', spec.voltage.measure.level.low.toString()) + .replace('%{5}', spec.voltage.measure.level.high.toString()) + } + } + ], +]) + +export const completions: Array = [ { data: ['measure', 'smu'], kind: CompletionItemKind.Module, @@ -58,34 +91,7 @@ This attribute is saved with the active function and retained until the next ins }, { data: ['rel', 'measure', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.measure.rel.level\n```\n\ -\n\ -Get or set the value used by the relative offset calculation to some number. Defaults to 0.\n\ -\n\ -When the measurement function is set to Current, the valid range of this attribute is -1.05 to +1.05.\n\ -\n\ -When the measurement function is set to Resistance, the valid range of this attribute is -2.10e+6 to +2.10e+6.\n\ -\n\ -When the measurement function is set to Voltage, the valid range of this attribute is -210 to +210.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, kind: CompletionItemKind.Property, label: 'level', }, ] - -export async function getSmuMeasureRelCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureRelCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-measure.ts b/server/src/instrument/provider/smu-measure.ts similarity index 68% rename from server/src/instrument/2450/smu-measure.ts rename to server/src/instrument/provider/smu-measure.ts index 7c190326..0c084bdc 100644 --- a/server/src/instrument/2450/smu-measure.ts +++ b/server/src/instrument/provider/smu-measure.ts @@ -15,9 +15,117 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const smuMeasureCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { CommandDocumentation, FormattableSignatureInformation } from '.' + +export const completionDocs: Map = new Map([ + [ + 'smu.measure.autorangehigh', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.measure.autorangehigh\n```\n\ +\n\ +Acts as a read-write attribute if and only if the present measurement function is set to Resistance; otherwise it \ +acts as a read-only attribute.\n\ +\n\ +For Resistance measurements, this attribute can be set to any number from %{0} to %{1} that is greater than or equal \ +to the measure autorangelow attribute. Defaults to %{2}. Any set value is saved with the resistance function and \ +retained until the next instrument reset or power cycle.' + .replace('%{0}', spec.resistance.range.low.toString()) + .replace('%{1}', spec.resistance.range.high.toString()) + .replace('%{1}', spec.smuMeasureAutorange.resistanceHighDefault.toString()) + } + } + ], + [ + 'smu.measure.autorangelow', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.measure.autorangelow\n```\n\ +\n\ +Get or set the lowest range available to the autorange setting to a number.\n\ +\n\ +When the measurement function is set to Current, the valid range of this attribute is %{0} to \ +%{1} and defaults to %{2}.\n\ +\n\ +When the measurement function is set to Voltage, the valid range is %{3} to %{4} and defaults to %{5}.\n\ +\n\ +When the measurement function is set to Resistance, the valid range is any number %{6} to %{7} that is less than \ +or equal to the measure autorangehigh attribute. Defaults to %{8}.\n\ +\n\ +While this attribute accepts any number in the applicable range, the instrument is set to the closest effective range \ +greater than or equal to the supplied value.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + .replace('%{0}', spec.current.measure.range.low.toString()) + .replace('%{1}', spec.current.measure.range.high.toString()) + .replace('%{2}', spec.smuMeasureAutorange.currentLowDefault.toString()) + .replace('%{3}', spec.voltage.measure.range.low.toString()) + .replace('%{4}', spec.voltage.measure.range.high.toString()) + .replace('%{5}', spec.smuMeasureAutorange.voltageLowDefault.toString()) + .replace('%{6}', spec.resistance.range.low.toString()) + .replace('%{7}', spec.resistance.range.high.toString()) + .replace('%{8}', spec.smuMeasureAutorange.resistanceLowDefault.toString()) + }, + } + ], + [ + 'smu.measure.range', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.measure.range\n```\n\ +\n\ +Get or set the measurement range of the active measure function as a number.\n\ +\n\ +When the measurement function is set to Current, the valid range of this attribute is %{0} to %{1} and defaults to \ +%{2}.\n\ +\n\ +When the measurement function is set to Voltage, this range is %{3} to %{4} and defaults to %{5}.\n\ +\n\ +When the measurement function is set to Resistance, this range is %{6} to %{7} and defaults to %{8}.\n\ +\n\ +While this attribute accepts any number in the applicable range, the instrument is set to the closest effective range \ +greater than or equal to the supplied value.\n\ +\n\ +Any signal greater than the set range is returned as %{9}.\n\ +\n\ +If sourcing and measuring the same function, the source range takes precendence.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + .replace('%{0}', spec.current.measure.range.low.toString()) + .replace('%{1}', spec.current.measure.range.high.toString()) + .replace( + '%{2}', + (spec.current.measure.range.default === undefined) ? + 'UNDEFINED' : spec.current.measure.range.default.toString() + ) + .replace('%{3}', spec.voltage.measure.range.low.toString()) + .replace('%{4}', spec.voltage.measure.range.high.toString()) + .replace( + '%{5}', + (spec.voltage.measure.range.default === undefined) ? + 'UNDEFINED' : spec.voltage.measure.range.default.toString() + ) + .replace('%{6}', spec.resistance.range.low.toString()) + .replace('%{7}', spec.resistance.range.high.toString()) + .replace( + '%{8}', + (spec.resistance.range.default === undefined) ? + 'UNDEFINED' : spec.resistance.range.default.toString() + ) + .replace('%{9}', spec.overflow.toString()) + } + } + ], +]) + +export const completions: Array = [ { data: ['smu'], kind: CompletionItemKind.Module, @@ -44,41 +152,11 @@ This attribute is saved with the active function and retained until the next ins }, { data: ['measure', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.measure.autorangehigh\n```\n\ -\n\ -Acts as a read-write attribute if and only if the present measurement function is set to Resistance; otherwise it \ -acts as a read-only attribute.\n\ -\n\ -For Resistance measurements, this attribute can be set to any number +2.0 to +200e+6 that is greater than or equal to \ -the measure autorangelow attribute. Defaults to +200e+6. Any set value is saved with the resistance function and \ -retained until the next instrument reset or power cycle.' - }, kind: CompletionItemKind.Property, label: 'autorangehigh', }, { data: ['measure', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.measure.autorangelow\n```\n\ -\n\ -Get or set the lowest range available to the autorange setting to a number.\n\ -\n\ -When the measurement function is set to Current, the valid range of this attribute is +1e-8 to +1.0 and defaults to \ -+10e-9.\n\ -\n\ -When the measurement function is set to Voltage, the valid range is +0.02 to +200.0 and defaults to +20.0.\n\ -\n\ -When the measurement function is set to Resistance, the valid range is any number +2.0 to +200e+6 that is less than \ -or equal to the measure autorangehigh attribute. Defaults to +20.0.\n\ -\n\ -While this attribute accepts any number in the applicable range, the instrument is set to the closest effective range \ -greater than or equal to the supplied value.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, kind: CompletionItemKind.Property, label: 'autorangelow', }, @@ -165,28 +243,6 @@ with the resistance function and retained until the next instrument reset or pow }, { data: ['measure', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.measure.range\n```\n\ -\n\ -Get or set the measurement range of the active measure function as a number.\n\ -\n\ -When the measurement function is set to Current, the valid range of this attribute is +1e-9 to +1.0 and defaults to \ -+1e-4.\n\ -\n\ -When the measurement function is set to Voltage, this range is +0.02 to +200.0 and defaults to +0.02.\n\ -\n\ -When the measurement function is set to Resistance, this range is +20.0 to +200e+6 and defaults to +200e+3.\n\ -\n\ -While this attribute accepts any number in the applicable range, the instrument is set to the closest effective range \ -greater than or equal to the supplied value.\n\ -\n\ -Any signal greater than the set range is returned as +9.9e+37.\n\ -\n\ -If sourcing and measuring the same function, the source range takes precendence.\n\ -\n\ -This attribute is saved with the active function and retained until the next instrument reset or power cycle.' - }, kind: CompletionItemKind.Property, label: 'range', }, @@ -291,53 +347,33 @@ This attribute is saved with the active function and retained until the next ins }, ] -const smuMeasureSignatures: Array = [ - SignatureInformation.create( - 'smu.measure.read([bufferName])', - undefined, - ParameterInformation.create( - 'reading', - 'The last reading of the measurement process.' - ), - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1 if not specified.' - ), - ), - SignatureInformation.create( - 'smu.measure.readwithtime([bufferName])', - undefined, - ParameterInformation.create( - 'bufferName', - 'The name of the reading buffer, which may be a default buffer (defbuffer1 or defbuffer2) or a \ -user‑defined buffer; defaults to defbuffer1 if not specified.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.read([bufferName])', + parameters: [ + { + documentation: 'The last reading of the measurement process.', + label: 'reading', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1 if not specified.', + label: 'bufferName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.measure.readwithtime([bufferName])', + parameters: [ + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1 if not specified.', + label: 'bufferName', + }, + ], + }, ] - -export async function getSmuMeasureCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getSmuMeasureSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuMeasureSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-source-configlist.ts b/server/src/instrument/provider/smu-source-configlist.ts similarity index 58% rename from server/src/instrument/2450/smu-source-configlist.ts rename to server/src/instrument/provider/smu-source-configlist.ts index 25b8ebc3..6dfdc82a 100644 --- a/server/src/instrument/2450/smu-source-configlist.ts +++ b/server/src/instrument/provider/smu-source-configlist.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const smuSourceConfiglistCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['source', 'smu'], kind: CompletionItemKind.Module, @@ -129,98 +133,90 @@ between power cycles.' }, ] -const smuSourceConfiglistSignatures: Array = [ - SignatureInformation.create( - 'smu.source.configlist.create(listName)', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a source configuration list.' - ), - ), - SignatureInformation.create( - 'smu.source.configlist.delete(listName[, index])', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a source configuration list.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Deletes the entire configuration list by default.' - ), - ), - SignatureInformation.create( - 'smu.source.configlist.query(listName, index[, fieldSeparator])', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a source configuration list.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Defaults to the first configuration index.' - ), - ParameterInformation.create( - 'fieldSeparator', - 'The string that will separate each setting.' - ), - ), - SignatureInformation.create( - 'smu.source.configlist.recall(listName[, index])', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a source configuration list.' - ), - ParameterInformation.create( - 'index', - 'A number that defines a specific configuration index in the configuration list. \ -Defaults to the first configuration index.' - ), - ), - SignatureInformation.create( - 'smu.source.configlist.size(listName)', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a source configuration list.' - ), - ), - SignatureInformation.create( - 'smu.source.configlist.store(listName)', - undefined, - ParameterInformation.create( - 'listName', - 'A string that represents the name of a source configuration list.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.configlist.create(listName)', + parameters: [ + { + documentation: 'A string that represents the name of a source configuration list.', + label: 'listName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.configlist.delete(listName[, index])', + parameters: [ + { + documentation: 'A string that represents the name of a source configuration list.', + label: 'listName', + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Deletes the entire configuration list by default.', + label: 'index', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.configlist.query(listName, index[, fieldSeparator])', + parameters: [ + { + documentation: 'A string that represents the name of a source configuration list.', + label: 'listName', + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Defaults to the first configuration index.', + label: 'index', + }, + { + documentation: 'The string that will separate each setting.', + label: 'fieldSeparator', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.configlist.recall(listName[, index])', + parameters: [ + { + documentation: 'A string that represents the name of a source configuration list.', + label: 'listName', + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Defaults to the first configuration index.', + label: 'index', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.configlist.size(listName)', + parameters: [ + { + documentation: 'A string that represents the name of a source configuration list.', + label: 'listName', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.configlist.store(listName)', + parameters: [ + { + documentation: 'A string that represents the name of a source configuration list.', + label: 'listName', + }, + ], + }, ] - -export async function getSmuSourceConfiglistCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceConfiglistCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getSmuSourceConfiglistSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceConfiglistSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-source-ilimit.ts b/server/src/instrument/provider/smu-source-ilimit.ts similarity index 66% rename from server/src/instrument/2450/smu-source-ilimit.ts rename to server/src/instrument/provider/smu-source-ilimit.ts index a5e5ef18..b609c0c2 100644 --- a/server/src/instrument/2450/smu-source-ilimit.ts +++ b/server/src/instrument/provider/smu-source-ilimit.ts @@ -17,7 +17,33 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuSourceIlimitCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { CommandDocumentation } from '.' + +export const completionDocs: Map = new Map([ + [ + 'smu.source.ilimit.level', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.source.ilimit.level\n```\n\ +\n\ +Get or set the source limit for current to a number from %{0} to %{1}. Changing the source function will reset this \ +attribute to its default value of %{2}.\n\ +\n\ +Specified values must be more than 0.1% of the measurement range unless the instrument is in autorange mode. If set \ +to an invalid level, the instrument will use the nearest valid level and log a warning.' + .replace('%{0}', spec.current.measure.range.low.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + // tslint:disable-next-line:no-magic-numbers + .replace('%{2}', (spec.current.measure.level.high * 0.0001).toString()) + } + } + ], +]) + +export const completions: Array = [ { data: ['source', 'smu'], kind: CompletionItemKind.Module, @@ -25,16 +51,6 @@ const smuSourceIlimitCompletions: Array = [ }, { data: ['ilimit', 'source', 'smu'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.ilimit.level\n```\n\ -\n\ -Get or set the source limit for current to a number from 1nA to 1.05A. Changing the source function will reset this \ -attribute to its default value of +1.05e-04.\n\ -\n\ -Specified values must be more than 0.1% of the measurement range unless the instrument is in autorange mode. If set \ -to an invalid level, the instrument will use the nearest valid level and log a warning.' - }, kind: CompletionItemKind.Property, label: 'level', }, @@ -53,16 +69,3 @@ When smu.ON is returned, the instrument has clamped the source to keep it within label: 'tripped', }, ] - -export async function getSmuSourceIlimitCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceIlimitCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-source-protect.ts b/server/src/instrument/provider/smu-source-protect.ts similarity index 80% rename from server/src/instrument/2450/smu-source-protect.ts rename to server/src/instrument/provider/smu-source-protect.ts index fd93e567..13e07f35 100644 --- a/server/src/instrument/2450/smu-source-protect.ts +++ b/server/src/instrument/provider/smu-source-protect.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuSourceProtectCompletions: Array = [ +export const completions: Array = [ { data: ['source', 'smu'], kind: CompletionItemKind.Module, @@ -52,16 +52,3 @@ When smu.ON is returned, the instrument has restricted the maximum voltage level label: 'tripped', }, ] - -export async function getSmuSourceProtectCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceProtectCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/smu-source-vlimit.ts b/server/src/instrument/provider/smu-source-vlimit.ts similarity index 68% rename from server/src/instrument/2450/smu-source-vlimit.ts rename to server/src/instrument/provider/smu-source-vlimit.ts index 26e23206..2df01339 100644 --- a/server/src/instrument/2450/smu-source-vlimit.ts +++ b/server/src/instrument/provider/smu-source-vlimit.ts @@ -17,17 +17,17 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuSourceVlimitCompletions: Array = [ - { - data: ['source', 'smu'], - kind: CompletionItemKind.Module, - label: 'vlimit' - }, - { - data: ['vlimit', 'source', 'smu'], - documentation: { +import { InstrumentSpec } from '..' + +import { CommandDocumentation } from '.' + +export const completionDocs: Map = new Map([ + [ + 'smu.source.ilimit.level', + { kind: MarkupKind.Markdown, - value: '```lua\nsmu.source.vlimit.level\n```\n\ + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.source.vlimit.level\n```\n\ \n\ Get or set the source limit for voltage to a number from 0.02V to 210V. Changing the source function will reset this \ attribute to its default value of +21.0.\n\ @@ -36,7 +36,27 @@ Specified values must be more than 0.1% of the measurement range unless the inst to an invalid level, the instrument will use the nearest valid level and log a warning.\n\ \n\ Values that can be set for this attribute are limited by the overvoltage protection limit.' - }, + .replace('%{0}', spec.voltage.measure.range.low.toString()) + .replace('%{1}', spec.voltage.measure.level.high.toString()) + /* TODO: + This default calculation is probably wrong for the 2460. + We may have to add this setting to the InstrumentSpec. + */ + // tslint:disable-next-line:no-magic-numbers + .replace('%{2}', (spec.voltage.measure.level.high * 0.1).toString()) + } + } + ], +]) + +export const completions: Array = [ + { + data: ['source', 'smu'], + kind: CompletionItemKind.Module, + label: 'vlimit' + }, + { + data: ['vlimit', 'source', 'smu'], kind: CompletionItemKind.Property, label: 'level', }, @@ -55,16 +75,3 @@ When smu.ON is returned, the instrument has clamped the source to keep it within label: 'tripped', }, ] - -export async function getSmuSourceVlimitCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuSourceVlimitCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/smu-source.ts b/server/src/instrument/provider/smu-source.ts new file mode 100644 index 00000000..60ba6ce8 --- /dev/null +++ b/server/src/instrument/provider/smu-source.ts @@ -0,0 +1,553 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { CommandDocumentation, FormattableSignatureInformation } from '.' + +export const completionDocs: Map = new Map([ + [ + 'smu.source.level', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.source.level\n```\n\ +\n\ +Get or set the output level of the active source function as a number. Defaults to 0 for all source functions.\n\ +\n\ +When the source function is set to Current, the valid range of this attribute is %{0} to %{1}.\n\ +\n\ +When the source function is set to Voltage, the valid range of this attribute is %{2} to %{3}.\n\ +\n\ +If manual source ranging is enabled, then this attribute cannot exceed the present source range setting.' + .replace('%{0}', (spec.current.measure.level.high * -1).toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', (spec.voltage.source.rangeDefault * -1).toString()) + .replace('%{3}', spec.voltage.source.rangeDefault.toString()) + } + } + ], + [ + 'smu.source.range', + { + kind: MarkupKind.Markdown, + toString: (spec: InstrumentSpec): string => { + return '```lua\nsmu.source.range\n```\n\ +\n\ +Get or set the source range of the active source function by passing the expected source level as a number.\n\ +\n\ +When the source function is set to Current, the valid range of this attribute is %{0} to %{1} and defaults to %{2}. \ +Fixed Current ranges include %{3}.\n\ +\n\ +When the source function is set to Voltage, this range is %{4} to %{5} and defaults to %{6}. Fixed Voltage ranges \ +include %{7}.\n\ +\n\ +While this attribute accepts any number in the applicable range, the instrument is set to the closest effective range \ +less than supplied source level.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + .replace( + '%{0}', + (spec.current.source.ranges[spec.current.source.ranges.length - 1] * -1).toString() + ) + .replace('%{1}', spec.current.source.ranges[spec.current.source.ranges.length - 1].toString()) + .replace('%{2}', spec.current.source.rangeDefault.toString()) + .replace('%{3}', spec.current.source.ranges.join(', ')) + .replace( + '%{4}', + (spec.voltage.source.ranges[spec.voltage.source.ranges.length - 1] * -1).toString() + ) + .replace('%{5}', spec.voltage.source.ranges[spec.voltage.source.ranges.length - 1].toString()) + .replace('%{6}', spec.voltage.source.rangeDefault.toString()) + .replace('%{7}', spec.voltage.source.ranges.join(', ')) + } + } + ], +]) + +export const completions: Array = [ + { + data: ['smu'], + kind: CompletionItemKind.Module, + label: 'source' + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.autodelay\n```\n\ +\n\ +Get or set the automatic delay that occurs when the source is turned on to smu.OFF or ON. Defaults to smu.ON.\n\ +\n\ +This attribute is automatically set to smu.OFF on manual source delay configuration.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + }, + kind: CompletionItemKind.Property, + label: 'autodelay', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.autorange\n```\n\ +\n\ +Get or set the present autorange setting to smu.OFF or ON. Defaults to smu.ON. Only available for the Current and \ +Voltage functions.\n\ +\n\ +When set to smu.ON, the instrument automatically sets the most appropriate sourcing range.\n\ +\n\ +When set to smu.OFF, the instrument range must be configured manually. If the range is not configured, the instrument \ +will remain at the range last used by autorange. This attribute is automatically set to smu.OFF on manual range \ +configuration.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + }, + kind: CompletionItemKind.Property, + label: 'autorange', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.delay\n```\n\ +\n\ +Get or set a source delay for the active source function to a number from 0 to 10 000 seconds.\n\ +\n\ +Setting this attribute automatically sets the source autodelay to smu.OFF. This attribute is overwritten if autodelay \ +is re-enabled.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + }, + kind: CompletionItemKind.Property, + label: 'delay', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.func\n```\n\ +\n\ +Get or set the active source function to smu.FUNC_DC_CURRENT or FUNC_DC_VOLTAGE. Defaults to smu.FUNC_DC_CURRENT.\n\ +\n\ +When the active source function is changed, settings that are retained on a per-function basis are also changed.' + }, + kind: CompletionItemKind.Property, + label: 'func', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.highc\n```\n\ +\n\ +Get or set the present high-capacitance mode setting to smu.ON or OFF. Defaults to smu.OFF.\n\ +\n\ +When measuring a current in the 1 µA range or above and driving a capacitive load, enable this attribute to prevent \ +any overshoot, ringing, or instability.' + }, + kind: CompletionItemKind.Property, + label: 'highc', + }, + { + data: ['source', 'smu'], + kind: CompletionItemKind.Property, + label: 'level', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.offmode\n```\n\ +\n\ +Get or set the instrument state when output is turned off to smu.OFFMODE_\\*. Defaults to smu.OFFMODE_NORMAL.' + }, + kind: CompletionItemKind.Property, + label: 'offmode', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.output\n```\n\ +\n\ +Get or set the present source output state to smu.ON or OFF. Defaults to smu.OFF.' + }, + kind: CompletionItemKind.Property, + label: 'output', + }, + { + data: ['source', 'smu'], + kind: CompletionItemKind.Property, + label: 'range', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.source.readback\n```\n\ +\n\ +Get or set the present source readback setting to smu.OFF or ON. Defaults to smu.ON.\n\ +\n\ +When source readback is set to smu.OFF, the front-panel displays the present value of the source level attribute in \ +addition to recording it in the buffer alongside each measurement.\n\ +\n\ +When source readback is set to smu.ON, the actual source level is measured, displayed on the front-panel, and \ +recorded in the buffer alongside each measurement.' + }, + kind: CompletionItemKind.Property, + label: 'readback', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction sweeplinear(configListName, start, stop, points, delay, count, rangeType, \ +failAbort, dual, bufferName)\n```\n\ +\n\ +smu.source.sweeplinear(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort][, dual]\ +[, bufferName])\n\ +\n\ +Configure a linear sweep for a fixed number of measurement points.\n\ +\n\ +Clears any existing trigger models, creates a source configuration list, and populates the trigger model. Initiate \ +the trigger model to start the sweep.' + }, + kind: CompletionItemKind.Function, + label: 'sweeplinear', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction sweeplinearstep(configListName, start, stop, step, delay, count, rangeType, \ +failAbort, dual, bufferName)\n```\n\ +\n\ +smu.source.sweeplinearstep(configListName, start, stop, step[, delay][, count][, rangeType][, failAbort][, dual]\ +[, bufferName])\n\ +\n\ +Configure a stepped linear sweep for a fixed number of measurement points.\n\ +\n\ +Clears any existing trigger models, creates a source configuration list, and populates the trigger model to perform a \ +uniform series of ascending or descending output steps. Initiate the trigger model to start the sweep.' + }, + kind: CompletionItemKind.Function, + label: 'sweeplinearstep', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction sweeplist(configListName, index, delay, count, failAbort, bufferName)\n```\n\ +\n\ +smu.source.sweeplist(configListName[, index][, delay][, count][, failAbort][, bufferName])\n\ +\n\ +Configure a custom sweep using the given configListName to specify each source level.\n\ +\n\ +Clears any existing trigger models, loads from the specified source configuration list, and populates the trigger \ +model. Initiate the trigger model to start the sweep.' + }, + kind: CompletionItemKind.Function, + label: 'sweeplist', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction sweeplog(configListName, start, stop, points, delay, count, rangeType, \ +failAbort, dual, bufferName, asymptote)\n```\n\ +\n\ +smu.source.sweeplog(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort][, dual]\ +[, bufferName][, asymptote])\n\ +\n\ +Configure a logarithmic sweep for a fixed number of measurement points.\n\ +\n\ +Clears any existing trigger models, creates a source configuration list, and populates the trigger model. Initiate \ +the trigger model to start the sweep.' + }, + kind: CompletionItemKind.Function, + label: 'sweeplog', + }, + { + data: ['source', 'smu'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nsmu.measure.userdelay[N]\n```\n\ +\n\ +An array of available user delays for use by the Dynamic Delay block of the trigger model. Indexed from 1 to 5. Get \ +or set the index to a number from 0 to +10e+3 seconds.\n\ +\n\ +This attribute is saved with the active function and retained until the next instrument reset or power cycle.' + }, + kind: CompletionItemKind.Property, + label: 'userdelay', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => { + return [ + { + documentation: 'The source level at which to start sweeping as a number.\n\ +Current range: %{0} to %{1}\n\ +Voltage range: %{2} to %{3}' + .replace('%{0}', spec.current.measure.level.low.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.voltage.measure.level.low.toString()) + .replace('%{3}', spec.voltage.measure.level.high.toString()), + label: 'start' + }, + { + documentation: 'The source level at which to stop sweeping as a number.\n\ +Current range: %{0} to %{1}\n\ +Voltage range: %{2} to %{3}' + .replace('%{0}', spec.current.measure.level.low.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.voltage.measure.level.low.toString()) + .replace('%{3}', spec.voltage.measure.level.high.toString()), + label: 'stop' + }, + ] + }, + label: 'smu.source.sweeplinear(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort]\ +[, dual][, bufferName])', + parameters: [ + { + documentation: 'The name of the source configuration list to create as a string.', + label: 'configListName' + }, + { + documentation: 'The number of source-measure points between the start and stop values of the sweep as \ +a number from +2.0 to +1e+6.', + label: 'points' + }, + { + documentation: 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds, 0 for \ +no delay, or smu.DELAY_AUTO. Defaults to smu.DELAY_AUTO.', + label: 'delay' + }, + { + documentation: 'The number of times to run the sweep as a number from 1 to 268 435 455 or \ +smu.INFINITE. Defaults to 1.', + label: 'count' + }, + { + documentation: 'Some smu.RANGE_*. Defaults to smu.RANGE_BEST.', + label: 'rangeType' + }, + { + documentation: 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if \ +exceeded. Defaults to smu.ON.', + label: 'failAbort' + }, + { + documentation: 'smu.OFF to sweep from start to stop only or smu.ON to sweep from start to stop, then \ +back to start. Defaults to smu.OFF.', + label: 'dual' + }, + { + documentation: 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the \ +name of a user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.', + label: 'bufferName' + }, + ] + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => { + return [ + { + documentation: 'The source level at which to start sweeping as a number.\n\ +Current range: %{0} to %{1}\n\ +Voltage range: %{2} to %{3}' + .replace('%{0}', spec.current.measure.level.low.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.voltage.measure.level.low.toString()) + .replace('%{3}', spec.voltage.measure.level.high.toString()), + label: 'start' + }, + { + documentation: 'The source level at which to stop sweeping as a number.\n\ +Current range: %{0} to %{1}\n\ +Voltage range: %{2} to %{3}' + .replace('%{0}', spec.current.measure.level.low.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.voltage.measure.level.low.toString()) + .replace('%{3}', spec.voltage.measure.level.high.toString()), + label: 'stop' + }, + ] + }, + label: 'smu.source.sweeplinearstep(configListName, start, stop, step[, delay][, count][, rangeType]\ +[, failAbort][, dual][, bufferName])', + parameters: [ + { + documentation: 'The name of the source configuration list to create as a string.', + label: 'configListName' + }, + { + documentation: 'The magnitude by which the output level will change for each step as a number greater \ +than 0.', + label: 'step' + }, + { + documentation: 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds, 0 for \ +no delay, or smu.DELAY_AUTO. Defaults to smu.DELAY_AUTO.', + label: 'delay' + }, + { + documentation: 'The number of times to run the sweep as a number from 1 to 268 435 455 or \ +smu.INFINITE. Defaults to 1.', + label: 'count' + }, + { + documentation: 'Some smu.RANGE_*. Defaults to smu.RANGE_BEST.', + label: 'rangeType' + }, + { + documentation: 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if \ +exceeded. Defaults to smu.ON.', + label: 'failAbort' + }, + { + documentation: 'smu.OFF to sweep from start to stop only or smu.ON to sweep from start to stop, then \ +back to start. Defaults to smu.OFF.', + label: 'dual' + }, + { + documentation: 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the \ +name of a user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.', + label: 'bufferName' + }, + ] + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'smu.source.sweeplist(configListName[, index][, delay][, count][, failAbort][, bufferName])', + parameters: [ + { + documentation: 'The name of the source configuration list to load as a string.', + label: 'configListName' + }, + { + documentation: 'A number that defines a specific configuration index in the configuration list. \ +Defaults to the first configuration index.', + label: 'index' + }, + { + documentation: 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds or 0 \ +for no delay.', + label: 'delay' + }, + { + documentation: 'The number of times to run the sweep as a number from 1 to 268 435 455 or \ +smu.INFINITE. Defaults to 1.', + label: 'count' + }, + { + documentation: 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if \ +exceeded. Defaults to smu.ON.', + label: 'failAbort' + }, + { + documentation: 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the \ +name of a user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.', + label: 'bufferName' + }, + ] + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => { + return [ + { + documentation: 'The source level at which to start sweeping as a number.\n\ +Current range: %{0} to %{1}\n\ +Voltage range: %{2} to %{3}' + .replace('%{0}', spec.smuSourceSweepLog.currentLevelLow.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.smuSourceSweepLog.voltageLevelLow.toString()) + .replace('%{3}', spec.voltage.measure.level.high.toString()), + label: 'start' + }, + { + documentation: 'The source level at which to stop sweeping as a number.\n\ +Current range: %{0} to %{1}\n\ +Voltage range: %{2} to %{3}' + .replace('%{0}', spec.smuSourceSweepLog.currentLevelLow.toString()) + .replace('%{1}', spec.current.measure.level.high.toString()) + .replace('%{2}', spec.smuSourceSweepLog.voltageLevelLow.toString()) + .replace('%{3}', spec.voltage.measure.level.high.toString()), + label: 'stop' + }, + ] + }, + label: 'smu.source.sweeplog(configListName, start, stop, points[, delay][, count][, rangeType][, failAbort]\ +[, dual][, bufferName][, asymptote])', + parameters: [ + { + documentation: 'The name of the source configuration list to create as a string.', + label: 'configListName' + }, + { + documentation: 'The number of source-measure points between the start and stop values of the sweep as \ +a number from +2.0 to +1e+6.', + label: 'points' + }, + { + documentation: 'The delay between measurement points as a number from +50e-6 to +10e+3 seconds, 0 for \ +no delay, or smu.DELAY_AUTO. Defaults to smu.DELAY_AUTO.', + label: 'delay' + }, + { + documentation: 'The number of times to run the sweep as a number from 1 to 268 435 455 or \ +smu.INFINITE. Defaults to 1.', + label: 'count' + }, + { + documentation: 'Some smu.RANGE_*. Defaults to smu.RANGE_BEST.', + label: 'rangeType' + }, + { + documentation: 'smu.ON to abort the sweep if the source limit is exceeded or smu.OFF to complete if \ +exceeded. Defaults to smu.ON.', + label: 'failAbort' + }, + { + documentation: 'smu.OFF to sweep from start to stop only or smu.ON to sweep from start to stop, then \ +back to start. Defaults to smu.OFF.', + label: 'dual' + }, + { + documentation: 'The name of a reading buffer; the default buffers (defbuffer1 or defbuffer2) or the \ +name of a user‑defined buffer; if no buffer is specified, this parameter defaults to defbuffer1.', + label: 'bufferName' + }, + { + documentation: 'The value of the asymtotic curve at either positive or negative infinity, depending \ +on the direction of the sweep. Defaults to 0.\n\ +Asymtotic value cannot be less than or equal to the sweep bounds.', + label: 'asymptote' + }, + ] + }, +] diff --git a/server/src/instrument/2450/smu.ts b/server/src/instrument/provider/smu.ts similarity index 72% rename from server/src/instrument/2450/smu.ts rename to server/src/instrument/provider/smu.ts index 8ea8a35d..91efbb60 100644 --- a/server/src/instrument/2450/smu.ts +++ b/server/src/instrument/provider/smu.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const smuCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'smu' @@ -34,16 +34,3 @@ Turn off instrument output and reset smu. commands to their default values.' label: 'reset', }, ] - -export async function getSmuCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(smuCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/status-enums.ts b/server/src/instrument/provider/status-enums.ts similarity index 78% rename from server/src/instrument/2450/status-enums.ts rename to server/src/instrument/provider/status-enums.ts index 4fc974ee..2ea46517 100644 --- a/server/src/instrument/2450/status-enums.ts +++ b/server/src/instrument/provider/status-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const statusEnumCompletions: Array = [ +export const completions: Array = [ { data: ['status'], detail: 'status.MSB: 1', @@ -61,16 +61,3 @@ const statusEnumCompletions: Array = [ label: 'OSB' }, ] - -export async function getStatusEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/status-operation.ts b/server/src/instrument/provider/status-operation.ts similarity index 66% rename from server/src/instrument/2450/status-operation.ts rename to server/src/instrument/provider/status-operation.ts index b44e7fdf..0d5a8f6a 100644 --- a/server/src/instrument/2450/status-operation.ts +++ b/server/src/instrument/provider/status-operation.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const statusOperationCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['status'], kind: CompletionItemKind.Module, @@ -98,55 +102,37 @@ set to 0 upon detection.' }, ] -const statusOperationSignatures: Array = [ - SignatureInformation.create( - 'status.operation.getmap(bitNumber)', - undefined, - ParameterInformation.create( - 'bitNumber', - 'The bit number to check.' - ), - ), - SignatureInformation.create( - 'status.operation.setmap(bitNumber, setEvent[, clearEvent])', - undefined, - ParameterInformation.create( - 'bitNumber', - 'The bit number that is mapped to an event (0 to 14).' - ), - ParameterInformation.create( - 'setEvent', - 'The number of the event that sets the bits in the condition and event registers; 0 if no mapping.' - ), - ParameterInformation.create( - 'clearEvent', - 'The number of the event that clears the bit in the condition register; 0 if no mapping.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'status.operation.getmap(bitNumber)', + parameters: [ + { + documentation: 'The bit number to check.', + label: 'bitNumber', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'status.operation.setmap(bitNumber, setEvent[, clearEvent])', + parameters: [ + { + documentation: 'The bit number that is mapped to an event (0 to 14).', + label: 'bitNumber', + }, + { + documentation: 'The number of the event that sets the bits in the condition and event registers; 0 if \ +no mapping is set.', + label: 'setEvent', + }, + { + documentation: 'The number of the event that clears the bit in the condition register; 0 if no \ +mapping is set.', + label: 'clearEvent', + }, + ], + }, ] - -export async function getStatusOperationCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusOperationCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getStatusOperationSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusOperationSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/status-questionable.ts b/server/src/instrument/provider/status-questionable.ts similarity index 67% rename from server/src/instrument/2450/status-questionable.ts rename to server/src/instrument/provider/status-questionable.ts index f1b02bb2..daa85c0c 100644 --- a/server/src/instrument/2450/status-questionable.ts +++ b/server/src/instrument/provider/status-questionable.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const statusQuestionableCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['status'], kind: CompletionItemKind.Module, @@ -100,55 +104,37 @@ Register is set to 0 upon detection.' }, ] -const statusQuestionableSignatures: Array = [ - SignatureInformation.create( - 'status.questionable.getmap(bitNumber)', - undefined, - ParameterInformation.create( - 'bitNumber', - 'The bit number to check (0 to 14).' - ), - ), - SignatureInformation.create( - 'status.questionable.setmap(bitNumber, setEvent[, clearEvent])', - undefined, - ParameterInformation.create( - 'bitNumber', - 'The bit number that is mapped to an event (0 to 14).' - ), - ParameterInformation.create( - 'setEvent', - 'The number of the event that sets the bits in the condition and event registers; 0 if no mapping.' - ), - ParameterInformation.create( - 'clearEvent', - 'The number of the event that clears the bit in the condition register; 0 if no mapping.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'status.questionable.getmap(bitNumber)', + parameters: [ + { + documentation: 'The bit number to check (0 to 14).', + label: 'bitNumber', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'status.questionable.setmap(bitNumber, setEvent[, clearEvent])', + parameters: [ + { + documentation: 'The bit number that is mapped to an event (0 to 14).', + label: 'bitNumber', + }, + { + documentation: 'The number of the event that sets the bits in the condition and event registers; 0 if \ +no mapping is set.', + label: 'setEvent', + }, + { + documentation: 'The number of the event that clears the bit in the condition register; 0 if no \ +mapping is set.', + label: 'clearEvent', + }, + ], + }, ] - -export async function getStatusQuestionableCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusQuestionableCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getStatusQuestionableSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusQuestionableSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/status-standard-enums.ts b/server/src/instrument/provider/status-standard-enums.ts similarity index 71% rename from server/src/instrument/2450/status-standard-enums.ts rename to server/src/instrument/provider/status-standard-enums.ts index 5319eb82..4c4e595e 100644 --- a/server/src/instrument/2450/status-standard-enums.ts +++ b/server/src/instrument/provider/status-standard-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const statusStandardEnumCompletions: Array = [ +export const completions: Array = [ { data: ['standard', 'status'], detail: 'status.standard.OPC: 1', @@ -37,16 +37,3 @@ const statusStandardEnumCompletions: Array = [ label: 'PON' }, ] - -export async function getStatusStandardEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusStandardEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/status-standard.ts b/server/src/instrument/provider/status-standard.ts similarity index 90% rename from server/src/instrument/2450/status-standard.ts rename to server/src/instrument/provider/status-standard.ts index 9b4d84e8..b9686893 100644 --- a/server/src/instrument/2450/status-standard.ts +++ b/server/src/instrument/provider/status-standard.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const statusStandardCompletions: Array = [ +export const completions: Array = [ { data: ['status'], kind: CompletionItemKind.Module, @@ -91,16 +91,3 @@ the OPC (1) and PON (129) registers are set.' label: 'event', }, ] - -export async function getStatusStandardCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusStandardCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/status.ts b/server/src/instrument/provider/status.ts similarity index 89% rename from server/src/instrument/2450/status.ts rename to server/src/instrument/provider/status.ts index e42a3d5f..943a2056 100644 --- a/server/src/instrument/2450/status.ts +++ b/server/src/instrument/provider/status.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const statusCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'status' @@ -62,7 +62,7 @@ If using the GPIB, USB, or VXI-11 serial poll sequence to retrieve the status by then B6 is the Request for Service (RQS) bit. When set, it indicates that a serial poll request (SRQ) has occurred.' }, kind: CompletionItemKind.Constant, - label: 'status.condition', + label: 'condition', }, { data: ['status'], @@ -107,16 +107,3 @@ the MSB (1) and OSB (129) registers are set.' label: 'request_enable', }, ] - -export async function getStatusCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(statusCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/lua/string.ts b/server/src/instrument/provider/string.ts similarity index 51% rename from server/src/lua/string.ts rename to server/src/instrument/provider/string.ts index af2f4856..688e03c6 100644 --- a/server/src/lua/string.ts +++ b/server/src/instrument/provider/string.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const stringCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'string' @@ -165,163 +169,172 @@ Returns a copy of the string s with all cased characters converted to uppercase. }, ] -const stringSignatures: Array = [ - SignatureInformation.create( - 'string.byte(s[, index])', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ParameterInformation.create( - 'index', - 'An optional one-based index. Defaults to 1.' - ), - ), - SignatureInformation.create( - 'string.char([...])', - undefined, - ParameterInformation.create( - '...', - 'Zero or more integers representing character codes.' - ), - ), - SignatureInformation.create( - 'string.dump(f)', - undefined, - ParameterInformation.create( - 'f', - 'A function to convert to a binary string.' - ), - ), - SignatureInformation.create( - 'string.find(s, pattern[, start[, plain]])', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ParameterInformation.create( - 'pattern', - 'A pattern string.' - ), - ParameterInformation.create( - 'start', - 'The index to start searching. Defaults to 1.' - ), - ParameterInformation.create( - 'plain', - 'Whether or not to perform a plain-text search. Defaults to false (disabled).' - ), - ), - SignatureInformation.create( - 'string.format(formatstring[, ...])', - undefined, - ParameterInformation.create( - 'formatstring', - 'A C-like printf format string.' - ), - ParameterInformation.create( - '...', - 'Zero or more arguments as required by the formatstring.' - ), - ), - SignatureInformation.create( - 'string.gsub(s, pattern, repl[, n])', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ParameterInformation.create( - 'pattern', - 'A pattern string.' - ), - ParameterInformation.create( - 'repl', - 'A replacement string or replacement function that returns the string to use for the match substitution.' - ), - ParameterInformation.create( - 'n', - 'The maximum number of substitutions to perform. Defaults to all occurrences.' - ), - ), - SignatureInformation.create( - 'string.len(s)', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ), - SignatureInformation.create( - 'string.lower(s)', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ), - SignatureInformation.create( - 'string.rep(s, n)', - undefined, - ParameterInformation.create( - 's', - 'The source string.' - ), - ParameterInformation.create( - 'n', - 'The number of times to duplicate the source string s.' - ), - ), - SignatureInformation.create( - 'string.sub(s, start[, end])', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ParameterInformation.create( - 'start', - 'The one-based index to begin the substring (inclusive). May be negative.' - ), - ParameterInformation.create( - 'end', - 'An optional one-based index to end the substring (inclusive). May be negative. Defaults to -1.' - ), - ), - SignatureInformation.create( - 'string.upper(s)', - undefined, - ParameterInformation.create( - 's', - 'The target string.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.byte(s[, index])', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + { + documentation: 'An optional one-based index. Defaults to 1.', + label: 'index', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.char([...])', + parameters: [ + { + documentation: 'Zero or more integers representing character codes.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.dump(f)', + parameters: [ + { + documentation: 'A function to convert to a binary string.', + label: 'f', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.find(s, pattern[, start[, plain]])', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + { + documentation: 'A pattern string.', + label: 'pattern', + }, + { + documentation: 'The index to start searching. Defaults to 1.', + label: 'start', + }, + { + documentation: 'Whether or not to perform a plain-text search. Defaults to false (disabled).', + label: 'plain', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.format(formatstring[, ...])', + parameters: [ + { + documentation: 'A C-like printf format string.', + label: 'formatstring', + }, + { + documentation: 'Zero or more arguments as required by the formatstring.', + label: '...', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.gsub(s, pattern, repl[, n])', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + { + documentation: 'A pattern string.', + label: 'pattern', + }, + { + documentation: 'A replacement string or replacement function that returns the string to use for the \ +match substitution.', + label: 'repl', + }, + { + documentation: 'The maximum number of substitutions to perform. Defaults to all occurrences.', + label: 'n', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.len(s)', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.lower(s)', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.rep(s, n)', + parameters: [ + { + documentation: 'The source string.', + label: 's', + }, + { + documentation: 'The number of times to duplicate the source string s.', + label: 'n', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.sub(s, start[, end])', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + { + documentation: 'The one-based index to begin the substring (inclusive). May be negative.', + label: 'start', + }, + { + documentation: 'An optional one-based index to end the substring (inclusive). May be negative. \ +Defaults to -1.', + label: 'end', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'string.upper(s)', + parameters: [ + { + documentation: 'The target string.', + label: 's', + }, + ], + }, ] - -export async function getStringCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(stringCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getStringSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(stringSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/table.ts b/server/src/instrument/provider/table.ts new file mode 100644 index 00000000..f469cd43 --- /dev/null +++ b/server/src/instrument/provider/table.ts @@ -0,0 +1,172 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + kind: CompletionItemKind.Module, + label: 'table' + }, + { + data: ['table'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction concat(t, sep, start, end)\n```\n\ +\n\ +table.concat(t[, sep[, start[, end]]]) -> string\n\ +\n\ +Returns the concatenation of all sequential, non-nil values of the given table t starting at index 1. An emtpy string \ +is returned if the start index is greater than the end index. The string separator sep defaults to an empty string, \ +the start index defaults to 1, and the end index defaults to the size of the table.' + }, + kind: CompletionItemKind.Function, + label: 'concat' + }, + { + data: ['table'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction insert(t, index, v)\n```\n\ntable.insert(t[, index], v)\n\ +\n\ +Inserts the value v into table t at the index. If index is omitted, then the new value is inserted at the end of the \ +table.' + }, + kind: CompletionItemKind.Function, + label: 'insert' + }, + { + data: ['table'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction remove(t, index)\n```\n\ntable.remove(t[, index]) -> any\n\ +\n\ +Remove and return the element of table t at the index. If index is omitted, then the last table element is removed.' + }, + kind: CompletionItemKind.Function, + label: 'remove' + }, + { + data: ['table'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction sort(t, f)\n```\n\ntable.sort(t[, f])\n\ +\n\ +Performs an in-place sort of table t using the function f as a callback. If the function f is omitted, then the less \ +than operator (<) is used.\n\ +\n\ +Function f must accept two arguments and return true when the first is less than the second.' + }, + kind: CompletionItemKind.Function, + label: 'sort' + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'table.concat(t[, sep[, start[, end]]])', + parameters: [ + { + documentation: 'The target table.', + label: 't', + }, + { + documentation: 'The string to add between each element. Defaults to an empty string.', + label: 'sep', + }, + { + documentation: 'The starting index (inclusive). Defaults to 1.', + label: 'start', + }, + { + documentation: 'The ending index (inclusive). Defaults to the size of the table.', + label: 'end', + }, + ], + }, + { + documentation: 'Insert an element into the last position of the table.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'table.insert(t, v)', + parameters: [ + { + documentation: 'The target table.', + label: 't', + }, + { + documentation: 'The value to insert.', + label: 'v', + }, + ], + }, + { + documentation: 'Insert an element into the specified table index.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'table.insert(t, index, v)', + parameters: [ + { + documentation: 'The target table.', + label: 't', + }, + { + documentation: 'The one-based index of the new value.', + label: 'index', + }, + { + documentation: 'The value to insert.', + label: 'v', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'table.remove(t[, index])', + parameters: [ + { + documentation: 'The target table.', + label: 't', + }, + { + documentation: 'The one-based index to remove.', + label: 'index', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'table.sort(t[, f])', + parameters: [ + { + documentation: 'The target table.', + label: 't', + }, + { + documentation: 'An optional sorting function that accepts two arguments and returns true when the \ +first is less than the second. Defaults to using the less than operator (<).', + label: 'f', + }, + ], + }, +] diff --git a/server/src/instrument/2450/timer.ts b/server/src/instrument/provider/timer.ts similarity index 76% rename from server/src/instrument/2450/timer.ts rename to server/src/instrument/provider/timer.ts index 5ae40a50..6cca7264 100644 --- a/server/src/instrument/2450/timer.ts +++ b/server/src/instrument/provider/timer.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const timerCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'timer' @@ -45,16 +45,3 @@ Returns the elapsed time in seconds (1 μs resolution) since the timer was last label: 'gettime', }, ] - -export async function getTimerCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(timerCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-blender.ts b/server/src/instrument/provider/trigger-blender.ts similarity index 77% rename from server/src/instrument/2450/trigger-blender.ts rename to server/src/instrument/provider/trigger-blender.ts index 1ce8d8f6..354a88b0 100644 --- a/server/src/instrument/2450/trigger-blender.ts +++ b/server/src/instrument/provider/trigger-blender.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const triggerBlenderCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -111,39 +115,16 @@ number of events detected.' }, ] -const triggerBlenderSignatures: Array = [ - SignatureInformation.create( - 'trigger.blender[].wait(timeout)', - undefined, - ParameterInformation.create( - 'timeout', - 'Timeout in seconds.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.blender[].wait(timeout)', + parameters: [ + { + documentation: 'Timeout in seconds.', + label: 'timeout', + }, + ], + }, ] - -export async function getTriggerBlenderCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerBlenderCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerBlenderSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerBlenderSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-digin.ts b/server/src/instrument/provider/trigger-digin.ts similarity index 72% rename from server/src/instrument/2450/trigger-digin.ts rename to server/src/instrument/provider/trigger-digin.ts index 29ab3b0f..83978bbc 100644 --- a/server/src/instrument/2450/trigger-digin.ts +++ b/server/src/instrument/provider/trigger-digin.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const triggerDiginCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -82,39 +86,16 @@ number of events detected.' }, ] -const triggerDiginSignatures: Array = [ - SignatureInformation.create( - 'trigger.digin[].wait(timeout)', - undefined, - ParameterInformation.create( - 'timeout', - 'Timeout in seconds.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.digin[].wait(timeout)', + parameters: [ + { + documentation: 'Timeout in seconds.', + label: 'timeout', + }, + ], + }, ] - -export async function getTriggerDiginCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerDiginCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerDiginSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerDiginSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-digout.ts b/server/src/instrument/provider/trigger-digout.ts similarity index 87% rename from server/src/instrument/2450/trigger-digout.ts rename to server/src/instrument/provider/trigger-digout.ts index c99d70bf..9a478a61 100644 --- a/server/src/instrument/2450/trigger-digout.ts +++ b/server/src/instrument/provider/trigger-digout.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const triggerDigoutCompletions: Array = [ +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -92,16 +92,3 @@ trigger.EVENT_NONE.' label: 'stimulus', }, ] - -export async function getTriggerDigoutCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerDigoutCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-enums.ts b/server/src/instrument/provider/trigger-enums.ts similarity index 97% rename from server/src/instrument/2450/trigger-enums.ts rename to server/src/instrument/provider/trigger-enums.ts index 2021aae7..20ffe8a4 100644 --- a/server/src/instrument/2450/trigger-enums.ts +++ b/server/src/instrument/provider/trigger-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const triggerEnumCompletions: Array = [ +export const completions: Array = [ { data: ['trigger'], kind: CompletionItemKind.EnumMember, @@ -200,7 +200,7 @@ drain.' kind: MarkupKind.PlainText, value: 'If the active interface is GPIB, then trigger upon receiving a GET command. On VXI-11, trigger \ when the device_trigger method is invoked. If neither of those interfaces are active, then trigger upon receiving a \ -\\*TRG message.' +*TRG message.' }, kind: CompletionItemKind.EnumMember, label: 'EVENT_COMMAND' @@ -707,16 +707,3 @@ when the device_trigger method is invoked. If neither of those interfaces are ac label: 'WAIT_OR' }, ] - -export async function getTriggerEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-lanin.ts b/server/src/instrument/provider/trigger-lanin.ts similarity index 72% rename from server/src/instrument/2450/trigger-lanin.ts rename to server/src/instrument/provider/trigger-lanin.ts index 28f73e75..4d3f4267 100644 --- a/server/src/instrument/2450/trigger-lanin.ts +++ b/server/src/instrument/provider/trigger-lanin.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const triggerLaninCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -83,39 +87,16 @@ number of events detected.' }, ] -const triggerLaninSignatures: Array = [ - SignatureInformation.create( - 'trigger.lanin[].wait(timeout)', - undefined, - ParameterInformation.create( - 'timeout', - 'Timeout in seconds.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.lanin[].wait(timeout)', + parameters: [ + { + documentation: 'Timeout in seconds.', + label: 'timeout', + }, + ], + }, ] - -export async function getTriggerLaninCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerLaninCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerLaninSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerLaninSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-lanout.ts b/server/src/instrument/provider/trigger-lanout.ts similarity index 91% rename from server/src/instrument/2450/trigger-lanout.ts rename to server/src/instrument/provider/trigger-lanout.ts index e95442d6..4e82c7fe 100644 --- a/server/src/instrument/2450/trigger-lanout.ts +++ b/server/src/instrument/provider/trigger-lanout.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const triggerLanoutCompletions: Array = [ +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -144,16 +144,3 @@ trigger.EVENT_NONE.' label: 'stimulus', }, ] - -export async function getTriggerLanoutCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerLanoutCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/trigger-model.ts b/server/src/instrument/provider/trigger-model.ts new file mode 100644 index 00000000..8e3f4315 --- /dev/null +++ b/server/src/instrument/provider/trigger-model.ts @@ -0,0 +1,1011 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + data: ['trigger'], + kind: CompletionItemKind.Module, + label: 'model' + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction abort()\n```\n\ +\n\ +Stop all trigger model commands.' + }, + kind: CompletionItemKind.Function, + label: 'abort', + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction getblocklist()\n```\n\ntrigger.model.getblocklist() -> string\n\ +\n\ +Returns the present blocks in the trigger model as a string.' + }, + kind: CompletionItemKind.Function, + label: 'getblocklist', + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction getbranchcount(blockNumber)\n```\n\ +\n\ +trigger.model.getbranchcount(blockNumber) -> number\n\ +\n\ +Returns the counter value of the specified BRANCH_COUNTER block as a number. If execution has not yet reached the \ +block, then a 0 is returned.' + }, + kind: CompletionItemKind.Function, + label: 'getbranchcount', + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction initiate()\n```\n\ +\n\ +Start the trigger model.' + }, + kind: CompletionItemKind.Function, + label: 'initiate', + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction load(typeString, typeParam, ...)\n```\n\ +\n\ +Load a predefined trigger model configuration.' + }, + kind: CompletionItemKind.Function, + label: 'load', + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction setblock(blockNumber, trigger.BLOCK_*, blockParams, ...)\n```\n\ +\n\ +Add a block to the trigger model.' + }, + kind: CompletionItemKind.Function, + label: 'setblock', + }, + { + data: ['model', 'trigger'], + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction state()\n```\n\ +\n\ +trigger.model.state() -> trigger.STATE_\\*, trigger.STATE_\\*, number\n\ +\n\ +Returns `overallStatus, engineStatus, blockNumber` where \ +*overallStatus* is the overall trigger model status, \ +*engineStatus* is the present status of the trigger engine, \ +and *blockNumber* is the last executed block number.\n\ +\n\ +Trigger state is updated every 100 ms.' + }, + kind: CompletionItemKind.Function, + label: 'state', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.getbranchcount(blockNumber)', + parameters: [ + { + documentation: 'The sequence of the BRANCH_COUNTER block in the trigger model.', + label: 'blockNumber', + }, + ], + }, + { + documentation: 'Load trigger model from Source and Measure config lists.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("ConfigList", measureConfigList, sourceConfigList[, delay][, bufferName])', + parameters: [ + { + documentation: 'The string "ConfigList".', + label: '"ConfigList"', + }, + { + documentation: 'A string that contains the name of the measurement configuration list to use.', + label: 'measureConfigList', + }, + { + documentation: 'A string that contains the name of the source configuration list to use.', + label: 'sourceConfigList', + }, + { + documentation: 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.', + label: 'delay', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Load a basic duration loop trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("DurationLoop", duration[, delay][, bufferName])', + parameters: [ + { + documentation: 'The string "DurationLoop".', + label: '"DurationLoop"', + }, + { + documentation: 'The amount of time for which to make measurements (167 ns to 100 ks).', + label: 'duration', + }, + { + documentation: 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.', + label: 'delay', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Clear the trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("Empty")', + parameters: [ + { + documentation: 'The string "Empty".', + label: '"Empty"', + }, + ], + }, + { + documentation: 'Load a basic grade binning trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("GradeBinning", components, startInLine, startDelay, endDelay, \ +limit1High, limit1Low[, limit1Pattern]\ +[, limit2High][, limit2Low][, limit2Pattern]\ +[, limit3High][, limit3Low][, limit3Pattern]\ +[, limit4High][, limit4Low][, limit4Pattern]\ +[, allPattern][, bufferName])', + parameters: [ + { + documentation: 'The string "GradeBinning".', + label: '"GradeBinning"', + }, + { + documentation: 'The number of components to measure (1 to 268,435,455).', + label: 'components', + }, + { + documentation: 'The digital input line that starts the test (5 or 6)', + label: 'startInLine', + }, + { + documentation: 'The delay time before each measurement (167 ns to 10 ks); 0 for no delay.', + label: 'startDelay', + }, + { + documentation: 'The delay time after each measurement (167 ns to 10 ks); 0 for no delay.', + label: 'endDelay', + }, + { + documentation: 'The first upper limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value lower than limit1Low.', + label: 'limit1High', + }, + { + documentation: 'The first lower limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value higher than limit1High.', + label: 'limit1Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 1; defaults \ +to 1. Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.', + label: 'limit1Pattern', + }, + { + documentation: 'The second upper limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value lower than limit2Low.', + label: 'limit2High', + }, + { + documentation: 'The second lower limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value higher than limit2High.', + label: 'limit2Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 2; defaults \ +to 2. Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.', + label: 'limit2Pattern', + }, + { + documentation: 'The third upper limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value lower than limit3Low.', + label: 'limit3High', + }, + { + documentation: 'The third lower limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value higher than limit3High.', + label: 'limit3Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 3; defaults \ +to 4. Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.', + label: 'limit3Pattern', + }, + { + documentation: 'The fourth upper limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value lower than limit4Low.', + label: 'limit4High', + }, + { + documentation: 'The fourth lower limit that the measurement is compared against.\n\ +To mark this limit as unused, set this value higher than limit4High.', + label: 'limit4Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 4; defaults \ +to 8. Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.', + label: 'limit4Pattern', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when all limits have passed; defaults to 15. \ +Sent on digital I/O lines 1 to 4, where 1 is the least significant bit.', + label: 'allPattern', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Load a basic logic trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("LogicTrigger", digInLine, digOutLine, count, clear[, delay][, bufferName])', + parameters: [ + { + documentation: 'The string "LogicTrigger".', + label: '"LogicTrigger"', + }, + { + documentation: 'The digital input line (1 to 6); also the event that the trigger model will wait on \ +in block 1.', + label: 'digInLine', + }, + { + documentation: 'The digital output line (1 to 6).', + label: 'digOutLine', + }, + { + documentation: 'The number of measurements the instrument will make.', + label: 'count', + }, + { + documentation: 'Use trigger.CLEAR_NEVER to immediately act on any previously detected triggers and \ +not clear them (default) or trigger.CLEAR_ENTER to clear previously detected trigger events when entering the wait \ +block.', + label: 'clear', + }, + { + documentation: 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.', + label: 'delay', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Load a basic event loop trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("LoopUntilEvent", triggerEvent, position, clear[, delay][, bufferName])', + parameters: [ + { + documentation: 'The string "LoopUntilEvent".', + label: '"LoopUntilEvent"', + }, + { + documentation: 'The event that ends infinite triggering or readings set to occur before the trigger; \ +value is some trigger.EVENT_* enumeration besides trigger.EVENT_NONE.', + label: 'triggerEvent', + }, + { + documentation: 'The number of readings to make in relation to the size of the reading buffer; enter \ +as some percentage out of 100.', + label: 'position', + }, + { + documentation: 'Use trigger.CLEAR_NEVER to immediately act on any previously detected triggers and \ +not clear them (default) or trigger.CLEAR_ENTER to clear previously detected trigger events when entering the wait \ +block.', + label: 'clear', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Load a basic looping trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("SimpleLoop", count[, delay][, bufferName])', + parameters: [ + { + documentation: 'The string "SimpleLoop".', + label: '"SimpleLoop"', + }, + { + documentation: 'The number of measurements the instrument will make.', + label: 'count', + }, + { + documentation: 'The delay time before each measurement (167 ns to 10 ks); default is 0 for no delay.', + label: 'delay', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Load a basic sort binning trigger model.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.load("SortBinning", components, startInLine, startDelay, endDelay, \ +limit1High, limit1Low[, limit1Pattern]\ +[, limit2High][, limit2Low][, limit2Pattern]\ +[, limit3High][, limit3Low][, limit3Pattern]\ +[, limit4High][, limit4Low][, limit4Pattern]\ +[, allPattern][, bufferName])', + parameters: [ + { + documentation: 'The string "SortBinning".', + label: '"SortBinning"', + }, + { + documentation: 'The number of components to measure (1 to 268,435,455).', + label: 'components', + }, + { + documentation: 'The digital input line that starts the test (5 or 6)', + label: 'startInLine', + }, + { + documentation: 'The delay time before each measurement (167 ns to 10 ks); 0 for no delay.', + label: 'startDelay', + }, + { + documentation: 'The delay time after each measurement (167 ns to 10 ks); 0 for no delay.', + label: 'endDelay', + }, + { + documentation: 'The first upper limit that the measurement is compared against.', + label: 'limit1High', + }, + { + documentation: 'The first lower limit that the measurement is compared against.', + label: 'limit1Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 1; defaults \ +to 1', + label: 'limit1Pattern', + }, + { + documentation: 'The second upper limit that the measurement is compared against.', + label: 'limit2High', + }, + { + documentation: 'The second lower limit that the measurement is compared against.', + label: 'limit2Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 2; defaults \ +to 2', + label: 'limit2Pattern', + }, + { + documentation: 'The third upper limit that the measurement is compared against.', + label: 'limit3High', + }, + { + documentation: 'The third lower limit that the measurement is compared against.', + label: 'limit3Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 3; defaults \ +to 4', + label: 'limit3Pattern', + }, + { + documentation: 'The fourth upper limit that the measurement is compared against.', + label: 'limit4High', + }, + { + documentation: 'The fourth lower limit that the measurement is compared against.', + label: 'limit4Low', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when the measurement fails limit 4; defaults \ +to 8', + label: 'limit4Pattern', + }, + { + documentation: 'The bit pattern (1 to 15) that is sent when all limits have passed; defaults to 15.', + label: 'allPattern', + }, + { + documentation: 'The name of the reading buffer, which may be a default buffer (defbuffer1 or \ +defbuffer2) or a user‑defined buffer; defaults to defbuffer1.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Transfer execution to the specified block number.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ALWAYS, branchToBlock)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_ALWAYS" enumeration.', + label: 'trigger.BLOCK_BRANCH_ALWAYS', + }, + { + documentation: 'The block number to execute when the trigger model reaches this block.', + label: 'branchToBlock', + }, + ], + }, + { + documentation: 'Transfer execution if the total number of branches is less than the specified counter; \ +otherwise continue.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_COUNTER, targetCount, branchToBlock)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_COUNTER" enumeration.', + label: 'trigger.BLOCK_BRANCH_COUNTER', + }, + { + documentation: 'The number of times to repeat.', + label: 'targetCount', + }, + { + documentation: 'The block number to execute when the counter is less than the targetCount value.', + label: 'branchToBlock', + }, + ], + }, + { + documentation: 'Transfer execution if the delta between the last two measurements (ultimate - penultimate) is \ +less than the specified value; otherwise continue.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_DELTA, targetDifference, branchToBlock\ +[, measureBlock])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_DELTA" enumeration.', + label: 'trigger.BLOCK_BRANCH_DELTA', + }, + { + documentation: 'The value against which the block compares the difference between the measurements.', + label: 'targetDifference', + }, + { + documentation: 'The block number to execute when the difference between the measurements is less than \ +or equal to the targetDifference.', + label: 'branchToBlock', + }, + { + documentation: 'The block number that makes the measurements to be compared; if this is 0 or \ +undefined, the trigger model uses a previous measure block.', + label: 'measureBlock', + }, + ], + }, + { + documentation: 'Transfer execution if a measurement meets the specified criteria.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_LIMIT_CONSTANT, limitType, limitA, limitB, \ +branchToBlock[, measureBlock])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_LIMIT_CONSTANT" enumeration.', + label: 'trigger.BLOCK_BRANCH_LIMIT_CONSTANT', + }, + { + documentation: 'The type of limit, which can be some trigger.LIMIT_*.', + label: 'limitType', + }, + { + documentation: 'The lower limit that the measurement is tested against as a number. Limit is ignored \ +if limitType is set to trigger.LIMIT_ABOVE.\n\ +If limitType is set to trigger.LIMIT_INSIDE or LIMIT_OUTSIDE, then this is the low limit that the measurement is \ +compared against.\n\ +If limitType is set to trigger.LIMIT_BELOW, then the measurement must be below this value.', + label: 'limitA', + }, + { + documentation: 'The upper limit that the measurement is tested against as a number. Limit is ignored \ +if limitType is set to trigger.LIMIT_BELOW.\n\ +If limitType is set to trigger.LIMIT_INSIDE or LIMIT_OUTSIDE, then this is the low limit that the measurement is \ +compared against.\n\ +If limitType is set to trigger.LIMIT_ABOVE, then the measurement must be above this value.', + label: 'limitB', + }, + { + documentation: 'The block number to execute when the measurement meets the defined criteria.', + label: 'branchToBlock', + }, + { + documentation: 'The block number that makes the measurements to be compared; if this is 0 or \ +undefined, the trigger model uses the previous measure block.', + label: 'measureBlock', + }, + ], + }, + { + documentation: 'Transfer execution if a measurement meets the criteria specified by a loaded measurement \ +configuration list.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_LIMIT_DYNAMIC, limitType, limitNumber, \ +branchToBlock[, measureBlock])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_LIMIT_DYNAMIC" enumeration.', + label: 'trigger.BLOCK_BRANCH_LIMIT_DYNAMIC', + }, + { + documentation: 'The type of limit, which can be some trigger.LIMIT_*.', + label: 'limitType', + }, + { + documentation: 'The limit number (1 or 2).', + label: 'limitNumber', + }, + { + documentation: 'The block number to execute when the measurement meets the criteria set in the \ +configuration list.', + label: 'branchToBlock', + }, + { + documentation: 'The block number that makes the measurements to be compared; if this is 0 or \ +undefined, the trigger model uses the previous measure block.', + label: 'measureBlock', + }, + ], + }, + { + documentation: 'Transfer execution if this block has not been executed; otherwise continue.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ONCE, branchToBlock)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_ONCE" enumeration.', + label: 'trigger.BLOCK_BRANCH_ONCE', + }, + { + documentation: 'The block number to execute when the trigger model first encounters this block.', + label: 'branchToBlock', + }, + ], + }, + { + documentation: 'Transfer execution if this block has been executed; otherwise continue.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ONCE_EXCLUDED, branchToBlock)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_ONCE_EXCLUDED" enumeration.', + label: 'trigger.BLOCK_BRANCH_ONCE_EXCLUDED', + }, + { + documentation: 'The block number to execute when the trigger model encounters this block after the \ +first encounter.', + label: 'branchToBlock', + }, + ], + }, + { + documentation: 'Transfer execution if the specified event has occurred; otherwise continue.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BRANCH_ON_EVENT, event, branchToBlock)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BRANCH_ON_EVENT" enumeration.', + label: 'trigger.BLOCK_BRANCH_ON_EVENT', + }, + { + documentation: 'Some trigger.EVENT_* that must occur before the trigger model branches to the \ +specified block.', + label: 'event', + }, + { + documentation: 'The block number to execute when the specified event occurs.', + label: 'branchToBlock', + }, + ], + }, + { + documentation: 'Clear the specified reading buffer.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_BUFFER_CLEAR[, bufferName])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_BUFFER_CLEAR" enumeration.', + label: 'trigger.BLOCK_BUFFER_CLEAR', + }, + { + documentation: 'The name of an existing buffer; if no buffer is defined, defbuffer1 is used.', + label: 'bufferName', + }, + ], + }, + { + documentation: 'Recall the settings at the next index of the specified source/measurement configuration list.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_CONFIG_NEXT, configurationList)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_CONFIG_NEXT" enumeration.', + label: 'trigger.BLOCK_CONFIG_NEXT', + }, + { + documentation: 'A string that defines the source or measure configuration list to recall.', + label: 'configurationList', + }, + ], + }, + { + documentation: 'Recall the settings at the previous index of the specified source/measurement configuration \ +list.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_CONFIG_PREV, configurationList)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_CONFIG_PREV" enumeration.', + label: 'trigger.BLOCK_CONFIG_PREV', + }, + { + documentation: 'A string that defines the source or measure configuration list to recall.', + label: 'configurationList', + }, + ], + }, + { + documentation: 'Recall the settings stored in the specified source/measurement configuration list.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_CONFIG_RECALL, configurationList[, index])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_CONFIG_RECALL" enumeration.', + label: 'trigger.BLOCK_CONFIG_RECALL', + }, + { + documentation: 'A string that defines the source or measure configuration list to recall.', + label: 'configurationList', + }, + { + documentation: 'The index in the configuration list to recall; default is 1.', + label: 'index', + }, + ], + }, + { + documentation: 'Halt measurement and trigger model execution for the specified amount of time. Background \ +measurements will continue, as will any infinite measurements set by a previous block.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_DELAY_CONSTANT, time)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_DELAY_CONSTANT" enumeration.', + label: 'trigger.BLOCK_DELAY_CONSTANT', + }, + { + documentation: 'The amount of time to delay in seconds (+167e-9 to 10 000, or 0 for no delay).', + label: 'time', + }, + ], + }, + { + documentation: 'Halt measurement and trigger model execution for a remotely programmable amount of time. \ +Background measurements will continue, as will any infinite measurements set by a previous block.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_DELAY_DYNAMIC, trigger.USER_DELAY_*)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_DELAY_DYNAMIC" enumeration.', + label: 'trigger.BLOCK_DELAY_DYNAMIC', + }, + { + documentation: 'Either USER_DELAY_M or USER_DELAY_S depending on whether you want to use the \ +measure or source user delays, respectively. Where is the index of the userdelay array attribute to use.', + label: 'trigger.USER_DELAY_*', + }, + ], + }, + { + documentation: 'Send a given bit pattern (0 to 63) on the specified digital I/O line. The least significant \ +bit maps to digital I/O line 1 and the most significant bit to line 6.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_DIGITAL_IO, bitPattern, bitMask)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_DIGITAL_IO" enumeration.', + label: 'trigger.BLOCK_DIGITAL_IO', + }, + { + documentation: 'Sets the value that specifies the output line bit pattern (0 to 63).', + label: 'bitPattern', + }, + { + documentation: 'Specifies the bit mask; if omitted, all lines are driven (0 to 63).', + label: 'bitMask', + }, + ], + }, + { + documentation: 'Post the specified event to the event log. Using this block too often in a trigger model \ +could overflow the event log. It may also take away from the time needed to process more critical trigger model \ +blocks.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_LOG_EVENT, eventNumber, message)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_LOG_EVENT" enumeration.', + label: 'trigger.BLOCK_LOG_EVENT', + }, + { + documentation: 'Some trigger.LOG_*. You can also set trigger.LOG_WARN_ABORT, which aborts the trigger \ +model immediately and posts a warning message to the event log.', + label: 'eventNumber', + }, + { + documentation: 'A string up to 31 characters.', + label: 'message', + }, + ], + }, + { + documentation: 'Take the specified number of measurements. If an infinite measure count is given, then \ +execution continues until the next MEASURE block.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_MEASURE[, bufferName][, count])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_MEASURE" enumeration.', + label: 'trigger.BLOCK_MEASURE', + }, + { + documentation: 'The name of an existing buffer; if no buffer is defined, defbuffer1 is used.', + label: 'bufferName', + }, + { + documentation: 'The number of readings to make before moving to the next block in the trigger model; \ +set to a specific number or trigger.COUNT_INFINITE or trigger.COUNT_STOP to stop infinite measurements.', + label: 'count', + }, + ], + }, + { + documentation: 'Placeholder block to prevent trigger model renumbering.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_NOP)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_NOP" enumeration.', + label: 'trigger.BLOCK_NOP', + }, + ], + }, + { + documentation: 'Generate the specified trigger event and continue.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_NOTIFY, trigger.EVENT_NOTIFY*)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_NOTIFY" enumeration.', + label: 'trigger.BLOCK_NOTIFY', + }, + { + documentation: 'Some trigger.EVENT_NOTIFY*.', + label: 'trigger.EVENT_NOTIFY*', + }, + ], + }, + { + documentation: 'Resets the total branch count of the specified COUNTER block.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_RESET_BRANCH_COUNT, counter)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_RESET_BRANCH_COUNT" enumeration.', + label: 'trigger.BLOCK_RESET_BRANCH_COUNT', + }, + { + documentation: 'The block number of the counter to be reset.', + label: 'counter', + }, + ], + }, + { + documentation: 'Sets the source to the specified output state.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_SOURCE_OUTPUT, state)', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_SOURCE_OUTPUT" enumeration.', + label: 'trigger.BLOCK_SOURCE_OUTPUT', + }, + { + documentation: 'Either smu.OFF to turn off the output source or smu.ON to turn it on.', + label: 'state', + }, + ], + }, + { + documentation: 'Halts execution until the specified event occurs.', + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.model.setblock(blockNumber, trigger.BLOCK_WAIT, event[, clear][, logic][, event][, event])', + parameters: [ + { + documentation: 'The sequence of the block in the trigger model.', + label: 'blockNumber', + }, + { + documentation: 'The "trigger.BLOCK_WAIT" enumeration.', + label: 'trigger.BLOCK_WAIT', + }, + { + documentation: 'Some trigger.EVENT_* that must occur before the trigger block allows trigger \ +execution to continue.', + label: 'event', + }, + { + documentation: 'To clear previously detected trigger events when entering the wait block use \ +trigger.CLEAR_ENTER. To immediately act on any previously detected triggers and not clear them use \ +trigger.CLEAR_NEVER. Defaults to trigger.CLEAR_NEVER.', + label: 'clear', + }, + { + documentation: 'To force each event to occur before the trigger model continues use trigger.WAIT_AND. \ +To continue trigger model execution if at least one event occurs use trigger.WAIT_OR.', + label: 'logic', + }, + { + documentation: 'Some trigger.EVENT_* that must occur before the trigger block allows trigger \ +execution to continue.', + label: 'event', + }, + { + documentation: 'Some trigger.EVENT_* that must occur before the trigger block allows trigger \ +execution to continue.', + label: 'event', + }, + ], + }, +] diff --git a/server/src/instrument/2450/trigger-timer-start.ts b/server/src/instrument/provider/trigger-timer-start.ts similarity index 88% rename from server/src/instrument/2450/trigger-timer-start.ts rename to server/src/instrument/provider/trigger-timer-start.ts index d10af457..c45df003 100644 --- a/server/src/instrument/2450/trigger-timer-start.ts +++ b/server/src/instrument/provider/trigger-timer-start.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const triggerTimerStartCompletions: Array = [ +export const completions: Array = [ { data: ['timer', 'trigger'], kind: CompletionItemKind.Module, @@ -94,16 +94,3 @@ When set to 0, event processing is disabled and the timer triggers based on its label: 'stimulus', }, ] - -export async function getTriggerTimerStartCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerTimerStartCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-timer.ts b/server/src/instrument/provider/trigger-timer.ts similarity index 82% rename from server/src/instrument/2450/trigger-timer.ts rename to server/src/instrument/provider/trigger-timer.ts index f38dad23..c9459adc 100644 --- a/server/src/instrument/2450/trigger-timer.ts +++ b/server/src/instrument/provider/trigger-timer.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const triggerTimerCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -150,39 +154,16 @@ number of events detected.' }, ] -const triggerTimerSignatures: Array = [ - SignatureInformation.create( - 'trigger.timer[].wait(timeout)', - undefined, - ParameterInformation.create( - 'timeout', - 'Maximum amount of time in seconds to wait for the trigger.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.timer[].wait(timeout)', + parameters: [ + { + documentation: 'Maximum amount of time in seconds to wait for the trigger.', + label: 'timeout', + }, + ], + }, ] - -export async function getTriggerTimerCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerTimerCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerTimerSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerTimerSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-tsplinkin.ts b/server/src/instrument/provider/trigger-tsplinkin.ts similarity index 71% rename from server/src/instrument/2450/trigger-tsplinkin.ts rename to server/src/instrument/provider/trigger-tsplinkin.ts index 3235504a..1911d2cc 100644 --- a/server/src/instrument/2450/trigger-tsplinkin.ts +++ b/server/src/instrument/provider/trigger-tsplinkin.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const triggerTsplinkinCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -84,39 +88,16 @@ number of events detected.' }, ] -const triggerTsplinkinSignatures: Array = [ - SignatureInformation.create( - 'trigger.tsplinkin[].wait(timeout)', - undefined, - ParameterInformation.create( - 'timeout', - 'The timeout value in seconds.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.tsplinkin[].wait(timeout)', + parameters: [ + { + documentation: 'The timeout value in seconds.', + label: 'timeout', + }, + ], + }, ] - -export async function getTriggerTsplinkinCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerTsplinkinCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerTsplinkinSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerTsplinkinSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger-tsplinkout.ts b/server/src/instrument/provider/trigger-tsplinkout.ts similarity index 87% rename from server/src/instrument/2450/trigger-tsplinkout.ts rename to server/src/instrument/provider/trigger-tsplinkout.ts index c6361584..37e8d82f 100644 --- a/server/src/instrument/2450/trigger-tsplinkout.ts +++ b/server/src/instrument/provider/trigger-tsplinkout.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const triggerTsplinkoutCompletions: Array = [ +export const completions: Array = [ { data: ['trigger'], documentation: { @@ -92,16 +92,3 @@ trigger.EVENT_NONE.' label: 'stimulus', }, ] - -export async function getTriggerTsplinkoutCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerTsplinkoutCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/trigger.ts b/server/src/instrument/provider/trigger.ts similarity index 61% rename from server/src/instrument/2450/trigger.ts rename to server/src/instrument/provider/trigger.ts index e9b8b30d..69e3df12 100644 --- a/server/src/instrument/2450/trigger.ts +++ b/server/src/instrument/provider/trigger.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const triggerCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'trigger' @@ -53,39 +57,16 @@ The event detector is automatically reset and rearmed when this function returns }, ] -const triggerSignatures: Array = [ - SignatureInformation.create( - 'trigger.wait(timeout)', - undefined, - ParameterInformation.create( - 'timeout', - 'The timeout value in seconds.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'trigger.wait(timeout)', + parameters: [ + { + documentation: 'The timeout value in seconds.', + label: 'timeout', + }, + ], + }, ] - -export async function getTriggerCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTriggerSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(triggerSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/tsplink-enums.ts b/server/src/instrument/provider/tsplink-enums.ts similarity index 82% rename from server/src/instrument/2450/tsplink-enums.ts rename to server/src/instrument/provider/tsplink-enums.ts index 19365db2..b592dfba 100644 --- a/server/src/instrument/2450/tsplink-enums.ts +++ b/server/src/instrument/provider/tsplink-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const tsplinkEnumCompletions: Array = [ +export const completions: Array = [ { data: ['tsplink'], documentation: { @@ -67,16 +67,3 @@ as output.' label: 'STATE_LOW' }, ] - -export async function getTsplinkEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tsplinkEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/tsplink-line.ts b/server/src/instrument/provider/tsplink-line.ts similarity index 83% rename from server/src/instrument/2450/tsplink-line.ts rename to server/src/instrument/provider/tsplink-line.ts index a73b4751..27b9670e 100644 --- a/server/src/instrument/2450/tsplink-line.ts +++ b/server/src/instrument/provider/tsplink-line.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const tsplinkLineCompletions: Array = [ +export const completions: Array = [ { data: ['tsplink'], documentation: { @@ -68,16 +68,3 @@ Get or set the state of a TSP-Link trigger line to tsplink.STATE_HIGH or STATE_L label: 'state', }, ] - -export async function getTsplinkLineCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tsplinkLineCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/tsplink.ts b/server/src/instrument/provider/tsplink.ts similarity index 75% rename from server/src/instrument/2450/tsplink.ts rename to server/src/instrument/provider/tsplink.ts index 81a6fd6b..364c397e 100644 --- a/server/src/instrument/2450/tsplink.ts +++ b/server/src/instrument/provider/tsplink.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const tsplinkCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'tsplink' @@ -133,49 +137,29 @@ while line 2 is set high (1).' }, ] -const tsplinkSignatures: Array = [ - SignatureInformation.create( - 'tsplink.initialize([expectedNodes])', - undefined, - ParameterInformation.create( - 'expectedNodes', - 'The number of nodes expected on the system as a number from 1 to 32.\n\ -An error is logged if the return value is not equal to this number.' - ), - ), - SignatureInformation.create( - 'tsplink.writeport(pattern)', - undefined, - ParameterInformation.create( - 'pattern', - 'Value to write to the port as a number from 0 to 7.\n\ -The given value is a binary representation of the high-low pattern that will be written to the I/O port.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tsplink.initialize([expectedNodes])', + parameters: [ + { + documentation: 'The number of nodes expected on the system as a number from 1 to 32.\n\ +An error is logged if the return value is not equal to this number.', + label: 'expectedNodes', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tsplink.writeport(pattern)', + parameters: [ + { + documentation: 'Value to write to the port as a number from 0 to 7.\n\ +The given value is a binary representation of the high-low pattern that will be written to the I/O port.', + label: 'pattern', + }, + ], + }, ] - -export async function getTsplinkCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tsplinkCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTsplinkSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tsplinkSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/tspnet-enums.ts b/server/src/instrument/provider/tspnet-enums.ts similarity index 71% rename from server/src/instrument/2450/tspnet-enums.ts rename to server/src/instrument/provider/tspnet-enums.ts index 0925a4b1..45ae3016 100644 --- a/server/src/instrument/2450/tspnet-enums.ts +++ b/server/src/instrument/provider/tspnet-enums.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind } from 'vscode-languageserver' -const tspnetEnumCompletions: Array = [ +export const completions: Array = [ { data: ['tspnet'], kind: CompletionItemKind.EnumMember, @@ -39,16 +39,3 @@ const tspnetEnumCompletions: Array = [ label: 'TERM_LFCR' }, ] - -export async function getTspnetEnumCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tspnetEnumCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/tspnet-tsp.ts b/server/src/instrument/provider/tspnet-tsp.ts similarity index 56% rename from server/src/instrument/2450/tspnet-tsp.ts rename to server/src/instrument/provider/tspnet-tsp.ts index 44f0132b..1bd07a29 100644 --- a/server/src/instrument/2450/tspnet-tsp.ts +++ b/server/src/instrument/provider/tspnet-tsp.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const tspnetTspCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { data: ['tspnet'], kind: CompletionItemKind.Module, @@ -89,75 +93,58 @@ Output from previous commands is discarded.' }, ] -const tspnetTspSignatures: Array = [ - SignatureInformation.create( - 'tspnet.tsp.abort(connectionID)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ), - SignatureInformation.create( - 'tspnet.tsp.rbtablecopy(connectionID, name[, startIndex, endIndex])', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ParameterInformation.create( - 'name', - 'The full name of the reading buffer name and synchronous table to copy.' - ), - ParameterInformation.create( - 'startIndex', - 'One-based integer start value.' - ), - ParameterInformation.create( - 'endIndex', - 'One-based integer end value.' - ), - ), - SignatureInformation.create( - 'tspnet.tsp.runscript(connectionID, name, script)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ParameterInformation.create( - 'name', - 'The name that is assigned to the script.' - ), - ParameterInformation.create( - 'script', - 'The body of the script as a string.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.tsp.abort(connectionID)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.tsp.rbtablecopy(connectionID, name[, startIndex, endIndex])', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + { + documentation: 'The full name of the reading buffer name and synchronous table to copy.', + label: 'name', + }, + { + documentation: 'One-based integer start value.', + label: 'startIndex', + }, + { + documentation: 'One-based integer end value.', + label: 'endIndex', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.tsp.runscript(connectionID, name, script)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + { + documentation: 'The name that is assigned to the script.', + label: 'name', + }, + { + documentation: 'The body of the script as a string.', + label: 'script', + }, + ], + }, ] - -export async function getTspnetTspCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tspnetTspCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTspnetTspSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tspnetTspSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/tspnet.ts b/server/src/instrument/provider/tspnet.ts similarity index 60% rename from server/src/instrument/2450/tspnet.ts rename to server/src/instrument/provider/tspnet.ts index fe167113..e985688b 100644 --- a/server/src/instrument/2450/tspnet.ts +++ b/server/src/instrument/provider/tspnet.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const tspnetCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'tspnet' @@ -188,143 +192,144 @@ commands.' }, ] -const tspnetSignatures: Array = [ - SignatureInformation.create( - 'tspnet.clear(connectionID)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ), - SignatureInformation.create( - 'tspnet.connect(ipAddress[, portNumber, initString])', - undefined, - ParameterInformation.create( - 'ipAddress', - 'IPv4 address string.' - ), - ParameterInformation.create( - 'portNumber', - 'Port number (default 5025).' - ), - ParameterInformation.create( - 'initString', - 'Initialization string to send.' - ), - ), - SignatureInformation.create( - 'tspnet.disconnect(connectionID)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ), - SignatureInformation.create( - 'tspnet.execute(connectionID, commandString[, formatString])', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ParameterInformation.create( - 'commandString', - 'The command to send to the remote device.' - ), - ParameterInformation.create( - 'formatString', - 'Format string for the output. Maximum of 10 specifiers. Format specifiers include:\n\ +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.clear(connectionID)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.connect(ipAddress[, portNumber, initString])', + parameters: [ + { + documentation: 'IPv4 address string.', + label: 'ipAddress', + }, + { + documentation: 'Port number (default 5025).', + label: 'portNumber', + }, + { + documentation: 'Initialization string to send.', + label: 'initString', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.disconnect(connectionID)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.execute(connectionID, commandString[, formatString])', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + { + documentation: 'The command to send to the remote device.', + label: 'commandString', + }, + { + documentation: 'Format string for the output. Maximum of 10 specifiers. Format specifiers include:\n\ %[width]s to read until the specified length\n\ %[max width]t to read until the specified length or until punctuation is found\n\ %[max width]n to read until the specified length or until a newline or carriage return is found\n\ -%d to read a punctuation-delimited number.' - ), - ), - SignatureInformation.create( - 'tspnet.idn(connectionID)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ), - SignatureInformation.create( - 'tspnet.read(connectionID[, formatString])', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ParameterInformation.create( - 'formatString', - 'Format string for the output. Maximum of 10 specifiers. Format specifiers include:\n\ +%d to read a punctuation-delimited number.', + label: 'formatString', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.idn(connectionID)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.read(connectionID[, formatString])', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + { + documentation: 'Format string for the output. Maximum of 10 specifiers. Format specifiers include:\n\ %[width]s to read until the specified length\n\ %[max width]t to read until the specified length or until punctuation is found\n\ %[max width]n to read until the specified length or until a newline or carriage return is found\n\ -%d to read a punctuation-delimited number.' - ), - ), - SignatureInformation.create( - 'tspnet.readavailable(connectionID)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ), - SignatureInformation.create( - 'tspnet.termination(connectionID[, termSequence])', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ParameterInformation.create( - 'termSequence', - 'One of:\n\ +%d to read a punctuation-delimited number.', + label: 'formatString', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.readavailable(connectionID)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.termination(connectionID[, termSequence])', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + { + documentation: 'One of:\n\ tspnet.TERM_LF (default for TSP-enabled devices)\n\ tspnet.TERM_CR\n\ tspnet.TERM_CRLF (default for non TSP-enabled devices)\n\ -tspnet.TERM_LFCR' - ), - ), - SignatureInformation.create( - 'tspnet.write(connectionID, inputString)', - undefined, - ParameterInformation.create( - 'connectionID', - 'Connection reference returned from the tspnet.connect() function.' - ), - ParameterInformation.create( - 'inputString', - 'The string to be written.' - ), - ), +tspnet.TERM_LFCR', + label: 'termSequence', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'tspnet.write(connectionID, inputString)', + parameters: [ + { + documentation: 'Connection reference returned from the tspnet.connect() function.', + label: 'connectionID', + }, + { + documentation: 'The string to be written.', + label: 'inputString', + }, + ], + }, ] - -export async function getTspnetCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tspnetCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTspnetSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tspnetSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/upgrade.ts b/server/src/instrument/provider/upgrade.ts similarity index 79% rename from server/src/instrument/2450/upgrade.ts rename to server/src/instrument/provider/upgrade.ts index 63ad09f1..72065b1d 100644 --- a/server/src/instrument/2450/upgrade.ts +++ b/server/src/instrument/provider/upgrade.ts @@ -17,7 +17,7 @@ import { CompletionItem, CompletionItemKind, MarkupKind } from 'vscode-languageserver' -const upgradeCompletions: Array = [ +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'upgrade', @@ -51,16 +51,3 @@ An error is logged if no suitable firmware file is found.' label: 'unit', }, ] - -export async function getUpgradeCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(upgradeCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/2450/userstring.ts b/server/src/instrument/provider/userstring.ts similarity index 56% rename from server/src/instrument/2450/userstring.ts rename to server/src/instrument/provider/userstring.ts index 1ba234ec..0a893afb 100644 --- a/server/src/instrument/2450/userstring.ts +++ b/server/src/instrument/provider/userstring.ts @@ -15,9 +15,13 @@ */ 'use strict' -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' -const userstringCompletions: Array = [ +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ { kind: CompletionItemKind.Module, label: 'userstring' @@ -68,59 +72,42 @@ Returns a string if the given name exists; otherwise nil is returned and an erro }, ] -const userstringSignatures: Array = [ - SignatureInformation.create( - 'userstring.add(name, value)', - undefined, - ParameterInformation.create( - 'name', - 'The name of the string.' - ), - ParameterInformation.create( - 'value', - 'The value of the string.' - ), - ), - SignatureInformation.create( - 'userstring.delete(name)', - undefined, - ParameterInformation.create( - 'name', - 'Name of the user‑defined string to delete.' - ), - ), - SignatureInformation.create( - 'userstring.get(name)', - undefined, - ParameterInformation.create( - 'name', - 'Name of the user‑defined string.' - ), - ), +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'userstring.add(name, value)', + parameters: [ + { + documentation: 'The name of the string.', + label: 'name', + }, + { + documentation: 'The value of the string.', + label: 'value', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'userstring.delete(name)', + parameters: [ + { + documentation: 'Name of the user‑defined string to delete.', + label: 'name', + }, + ], + }, + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'userstring.get(name)', + parameters: [ + { + documentation: 'Name of the user‑defined string.', + label: 'name', + }, + ], + }, ] - -export async function getUserstringCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(userstringCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getUserstringSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(userstringSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/instrument/provider/waitcomplete.ts b/server/src/instrument/provider/waitcomplete.ts new file mode 100644 index 00000000..7d32ce1f --- /dev/null +++ b/server/src/instrument/provider/waitcomplete.ts @@ -0,0 +1,53 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation } from 'vscode-languageserver' + +import { InstrumentSpec } from '..' + +import { FormattableSignatureInformation } from '.' + +export const completions: Array = [ + { + documentation: { + kind: MarkupKind.Markdown, + value: '```lua\nfunction waitcomplete(group)\n```\n\nwaitcomplete([group])\n\ +\n\ +Wait for all overlapped commands to complete.\n\ +\n\ +If no group is specified, the local group is used. \ +If 0, this function waits for all nodes in the system. \ +A group number may only be specified when this node is the master node.' + }, + kind: CompletionItemKind.Function, + label: 'waitcomplete', + }, +] + +export const signatures: Array = [ + { + documentation: undefined, + getFormattedParameters: (spec: InstrumentSpec): Array => new Array(), + label: 'waitcomplete([group])', + parameters: [ + { + documentation: 'Specifies which TSP-Link group on which to wait or 0 for all nodes.', + label: 'group', + }, + ], + }, +] diff --git a/server/src/instrument/raw-tsb-help/2450_v_2460.zip b/server/src/instrument/raw-tsb-help/2450_v_2460.zip new file mode 100644 index 00000000..a7b4f62e Binary files /dev/null and b/server/src/instrument/raw-tsb-help/2450_v_2460.zip differ diff --git a/server/src/instrument/raw-tsb-help/2450_v_2461.txt b/server/src/instrument/raw-tsb-help/2450_v_2461.txt new file mode 100644 index 00000000..2b51980c --- /dev/null +++ b/server/src/instrument/raw-tsb-help/2450_v_2461.txt @@ -0,0 +1,50 @@ +2450_tsb +smu.measure.terminals + +2461_tsb +smu.terminals +script.catalog() +smu.digitize.read() +smu.digitize.displaydigits +smu.digitize.limit[Y].autoclear +smu.digitize.limit[Y].clear() +smu.digitize.limit[Y].low.value +smu.digitize.limit[Y].fail +smu.digitize.limit[Y].enable +smu.digitize.limit[Y].high.value +smu.digitize.rel.acquire() +smu.digitize.math.enable +smu.digitize.math.format +smu.digitize.math.mxb.bfactor +smu.digitize.math.mxb.mfactor +smu.digitize.math.percent +smu.digitize.userdelay[N] +smu.digitize.rel.level +smu.digitize.rel.enable +smu.digitize.count +smu.digitize.range +trigger.model.setblock() — trigger.BLOCK_DIGITIZE +smu.digitize.func +smu.digitize.aperture +smu.digitize.samplerate +smu.digitize.readwithtime() +smu.digitize.limit[Y].audible +acal.count +acal.lastrun.internaltemp +acal.lastrun.time +acal.lastrun.time +acal.run() +smu.digitize.unit +acal.lastrun.tempdiff +smu.contact.enable +smu.contact.threshold +smu.contact.check() +smu.contact.checkall() +smu.source.pulse.level +smu.source.pulsetrain() +smu.source.pulsesweeplinearstep() +smu.source.pulsesweeplinear() +smu.source.pulsesweeplog() +smu.source.pulsesweeplist() +trigger.model.setblock() — trigger.BLOCK_SOURCE_PULSE_OUTPUT +smu.source.pulse.xlimit.level diff --git a/server/src/lua/index.ts b/server/src/lua/index.ts deleted file mode 100644 index f9699485..00000000 --- a/server/src/lua/index.ts +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { CompletionItem, SignatureInformation } from 'vscode-languageserver' - -import { getCoroutineCompletions, getCoroutineSignatures } from './coroutine' -import { getFunctionCompletions, getFunctionSignatures } from './functions' -import { getKeywordCompletions } from './keywords' -import { getMathCompletions, getMathSignatures } from './math' -import { getOSCompletions, getOSSignatures } from './os' -import { getStringCompletions, getStringSignatures } from './string' -import { getTableCompletions, getTableSignatures } from './table' - -const completionsLua: Array = new Array() -const signaturesLua: Array = new Array() - -export async function getLuaCompletions(): Promise> { - return completionsLua - .concat(await getCoroutineCompletions()) - .concat(await getFunctionCompletions()) - .concat(await getKeywordCompletions()) - .concat(await getMathCompletions()) - .concat(await getOSCompletions()) - .concat(await getStringCompletions()) - .concat(await getTableCompletions()) -} - -export async function getLuaSignatures(): Promise> { - return signaturesLua - .concat(await getCoroutineSignatures()) - .concat(await getFunctionSignatures()) - .concat(await getMathSignatures()) - .concat(await getOSSignatures()) - .concat(await getStringSignatures()) - .concat(await getTableSignatures()) -} diff --git a/server/src/lua/table.ts b/server/src/lua/table.ts deleted file mode 100644 index 4391ec3a..00000000 --- a/server/src/lua/table.ts +++ /dev/null @@ -1,179 +0,0 @@ -/* - * Copyright 2018 Tektronix Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -'use strict' - -import { CompletionItem, CompletionItemKind, MarkupKind, ParameterInformation, SignatureInformation } from 'vscode-languageserver' - -const tableCompletions: Array = [ - { - kind: CompletionItemKind.Module, - label: 'table' - }, - { - data: ['table'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction concat(t, sep, start, end)\n```\n\ -\n\ -table.concat(t[, sep[, start[, end]]]) -> string\n\ -\n\ -Returns the concatenation of all sequential, non-nil values of the given table t starting at index 1. An emtpy string \ -is returned if the start index is greater than the end index. The string separator sep defaults to an empty string, \ -the start index defaults to 1, and the end index defaults to the size of the table.' - }, - kind: CompletionItemKind.Function, - label: 'concat' - }, - { - data: ['table'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction insert(t, index, v)\n```\n\ntable.insert(t[, index], v)\n\ -\n\ -Inserts the value v into table t at the index. If index is omitted, then the new value is inserted at the end of the \ -table.' - }, - kind: CompletionItemKind.Function, - label: 'insert' - }, - { - data: ['table'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction remove(t, index)\n```\n\ntable.remove(t[, index]) -> any\n\ -\n\ -Remove and return the element of table t at the index. If index is omitted, then the last table element is removed.' - }, - kind: CompletionItemKind.Function, - label: 'remove' - }, - { - data: ['table'], - documentation: { - kind: MarkupKind.Markdown, - value: '```lua\nfunction sort(t, f)\n```\n\ntable.sort(t[, f])\n\ -\n\ -Performs an in-place sort of table t using the function f as a callback. If the function f is omitted, then the less \ -than operator (<) is used.\n\ -\n\ -Function f must accept two arguments and return true when the first is less than the second.' - }, - kind: CompletionItemKind.Function, - label: 'sort' - }, -] - -const tableSignatures: Array = [ - SignatureInformation.create( - 'table.concat(t[, sep[, start[, end]]])', - undefined, - ParameterInformation.create( - 't', - 'The target table.' - ), - ParameterInformation.create( - 'sep', - 'The string to add between each element. Defaults to an empty string.' - ), - ParameterInformation.create( - 'start', - 'The starting index (inclusive). Defaults to 1.' - ), - ParameterInformation.create( - 'end', - 'The ending index (inclusive). Defaults to the size of the table.' - ), - ), - SignatureInformation.create( - 'table.insert(t, v)', - 'Insert an element into the last position of the table.', - ParameterInformation.create( - 't', - 'The target table.' - ), - ParameterInformation.create( - 'v', - 'The value to insert.' - ), - ), - SignatureInformation.create( - 'table.insert(t, index, v)', - 'Insert an element into the specified table index.', - ParameterInformation.create( - 't', - 'The target table.' - ), - ParameterInformation.create( - 'index', - 'The one-based index of the new value.' - ), - ParameterInformation.create( - 'v', - 'The value to insert.' - ), - ), - SignatureInformation.create( - 'table.remove(t[, index])', - undefined, - ParameterInformation.create( - 't', - 'The target table.' - ), - ParameterInformation.create( - 'index', - 'The one-based index to remove.' - ), - ), - SignatureInformation.create( - 'table.sort(t[, f])', - undefined, - ParameterInformation.create( - 't', - 'The target table.' - ), - ParameterInformation.create( - 'f', - 'An optional sorting function that accepts two arguments and returns true when the first is less than the \ -second. Defaults to using the less than operator (<).' - ), - ), -] - -export async function getTableCompletions(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tableCompletions) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} - -export async function getTableSignatures(): Promise> { - return new Promise>(( - resolve: (value?: Array) => void, - reject: (reason?: Error) => void - ): void => { - try { - resolve(tableSignatures) - } catch (e) { - reject(new Error(e.toString())) - } - }) -} diff --git a/server/src/server.ts b/server/src/server.ts index 36058e0c..cf0b34ac 100644 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -15,8 +15,9 @@ */ 'use strict' -import { CompletionItem, createConnection, IConnection, InitializedParams, InitializeResult, IPCMessageReader, IPCMessageWriter, ParameterInformation, SignatureHelp, SignatureInformation, TextDocumentChangeEvent, TextDocumentItem, TextDocumentPositionParams, TextDocuments } from 'vscode-languageserver' +import { CompletionItem, createConnection, IConnection, InitializedParams, InitializeResult, IPCMessageReader, IPCMessageWriter, SignatureHelp, TextDocumentChangeEvent, TextDocumentItem, TextDocumentPositionParams, TextDocuments } from 'vscode-languageserver' +import { ContentParser } from './contentParser' import { TspManager } from './tspManager' const manager: TspManager = new TspManager() @@ -31,6 +32,9 @@ const connection: IConnection = createConnection( // only const documents: TextDocuments = new TextDocuments() +// Create a content parser to provide regular-expression based document parsing +const parser: ContentParser = new ContentParser(documents) + // After the server has started the client sends an initialize request. The server receives in the // passed params the rootPath of the workspace plus the client capabilities. connection.onInitialize((params: InitializedParams): InitializeResult => { @@ -82,206 +86,39 @@ documents.onDidClose((params: TextDocumentChangeEvent) => { }) // This handler provides the initial list of completion items. -connection.onCompletion((textDocumentPosition: TextDocumentPositionParams): Array | undefined => { - const content = documents.get(textDocumentPosition.textDocument.uri) - - if (content === undefined) { - return - } - - const offset: number = content.offsetAt(textDocumentPosition.position) - - const namespaceRegexp = new RegExp('^[a-zA-Z.\\[\\]0-9]*') - - // get all text before the cursor position, - // convert the string to an array of characters, - // reverse the array of characters, - // convert the array to a string - // (we need to reverse because we don't know where the namespace starts) - const reverseText = content.getText().slice(0, offset).split('').reverse().join('') - const reverseMatches = reverseText.match(namespaceRegexp) - - const results: Array = new Array() - - const tspItem = manager.get(textDocumentPosition.textDocument.uri) +connection.onCompletion((params: TextDocumentPositionParams): Array | undefined => { + const tspItem = manager.get(params.textDocument.uri) if (tspItem === undefined) { return } - if (reverseMatches === null) { - return - } - - let firstMatch = reverseMatches.shift() - - if (firstMatch === undefined || firstMatch === '') { - for (const compl of tspItem.completions) { - // get root namespace completions - if (compl.data === undefined) { - results.push(compl) - } - } - - return results - } - - let endingQualifier = false - - // remove any namespace qualifier at position 0 - if (firstMatch.indexOf('.') === 0) { - firstMatch = firstMatch.slice(1) - endingQualifier = true - - // return if we just deleted the entire string - if (firstMatch.length === 0) { - return - } - } - - // un-reverse the string and remove square brackets and their contents - const unreversed = firstMatch.split('').reverse().join('').replace(/\[[0-9]\]/g, '') - // split the unreversed string on namespace qualifiers and reverse the namespace domains - const namespaceArray: Array = unreversed.split('.').reverse() - - for (const compl of tspItem.completions) { - // if the completion has a data field, then it's not a root namespace - if (compl.data !== undefined && compl.data instanceof Array) { - if (compl.data.join('.') === namespaceArray.join('.')) { - results.push(compl) - } - } - else { - // prevent the same namespace from showing up again if it is 1 deep - if (endingQualifier) { - continue - } - - // root namespaces only have label fields, so partial match against that - const partialMatches = compl.label.match(namespaceArray.join('.')) - - if (partialMatches === null) { - continue - } - - const partial = partialMatches.shift() - if (partial !== undefined && partial !== '') { - results.push(compl) - } - } - } - - // sort on CompletionItem.kind - if (results.length > 0) { - results.sort((a: CompletionItem, b: CompletionItem): number => { - if (a.kind !== undefined && b.kind !== undefined) { - return a.kind - b.kind - } - else { - return a.label.localeCompare(b.label) - } - }) - } - - return results + return parser.getCompletions(params.textDocument.uri, params.position, tspItem) }) // This handler resolves additional information for the item selected in the completion list. connection.onCompletionResolve((item: CompletionItem): CompletionItem => { - return item -}) - -connection.onSignatureHelp((params: TextDocumentPositionParams) => { - const content = documents.get(params.textDocument.uri) - - if (content === undefined) { - return + if (parser.lastCompletionUri === undefined) { + return item } - const offset: number = content.offsetAt(params.position) - const openParenOffset: number = content.getText().lastIndexOf('(', offset) - const closeParenOffset: number = content.getText().indexOf(')', offset) - const commaIndices: Array = new Array() - - if (closeParenOffset === -1) { - return - } - - // stop providing signature info if the cursor is outside of the parenthesis - if (offset <= openParenOffset || offset > closeParenOffset) { - return - } + const tspItem = manager.get(parser.lastCompletionUri) - const callRegexp = new RegExp('^[a-zA-Z.\\[\\]0-9]*') - - // get all text before the open parenthesis offset, - // convert the string to an array of characters, - // reverse the array of characters, - // convert the array to a string - // (we need to reverse because we don't know where the function call starts) - const reverseText = content.getText().slice(0, openParenOffset).split('').reverse().join('') - const reverseMatches = reverseText.match(callRegexp) - - if (reverseMatches === null) { - return - } - - const firstMatch = reverseMatches.shift() - - if (firstMatch === undefined) { - return + if (tspItem === undefined) { + return item } - // un-reverse the string and remove digits inside of square brackets - const unreversed = firstMatch.split('').reverse().join('').replace(/\[[0-9]\]/g, '[]') + return parser.getCompletionDoc(item, tspItem) +}) +connection.onSignatureHelp((params: TextDocumentPositionParams): SignatureHelp | undefined => { const tspItem = manager.get(params.textDocument.uri) - if (tspItem === undefined || tspItem.signatures === undefined) { + if (tspItem === undefined) { return } - const results: Array = new Array() - - // add all matching signatures to the results array - for (const signa of tspItem.signatures) { - const signaBeforeParams = signa.label.slice(0, signa.label.indexOf('(')) - - if (signaBeforeParams.localeCompare(unreversed) === 0) { - results.push(signa) - } - } - - // get the index of each comma between our surrounding parenthesis - for (let i = openParenOffset + 1; i < closeParenOffset;) { - const commaIndex = content.getText().indexOf(',', i) - if (commaIndex >= i) { - commaIndices.push(commaIndex) - i = commaIndex + 1 - } - else { - i++ - } - } - - // compare the current offset to the index of the last comma to get the active parameter - let activeParam = 0 - commaIndices.forEach((element: number) => { - if (offset > element) { - activeParam++ - } - else { - return - } - }) - - const sig: SignatureHelp = { - activeParameter: activeParam, - activeSignature: 0, - signatures: results - } - - return sig + return parser.getSignatures(params.textDocument.uri, params.position, tspItem) }) // Make the text document manager listen on the connection for open, change and close text diff --git a/server/src/tspManager.ts b/server/src/tspManager.ts index df980298..7d98a3ac 100644 --- a/server/src/tspManager.ts +++ b/server/src/tspManager.ts @@ -15,19 +15,20 @@ */ 'use strict' -import { CompletionItem, SignatureInformation, TextDocumentItem } from 'vscode-languageserver' +import { TextDocumentItem } from 'vscode-languageserver' -import { getLuaCompletions, getLuaSignatures } from './lua' +import { ApiSpec, CommandSet, InstrumentSpec } from './instrument' +import { getLuaApiSpec, getLuaInstrumentSpec } from './instrument/lua' +import { generateCommandSet } from './instrument/provider' import { Model } from './model' import { Shebang } from './shebang' import { PoolEntry, TspPool } from './tspPool' -interface TspItem { - completions: Array - node?: Map> +export interface TspItem { + commandSet: CommandSet + node?: Map rawShebang?: string shebang?: Array - signatures: Array } export class TspManager { @@ -85,6 +86,10 @@ export class TspManager { } if (tspCompletion.shebang === undefined) { + if (this.dict.has(uri)) { + return this.dict.delete(uri) + } + return true } @@ -196,13 +201,11 @@ export class TspManager { resolve: (value?: TspItem) => void, reject: (reason?: Error) => void ): Promise => { - const luaCompletions: Array = new Array() - const luaSignatures: Array = new Array() let shebangTokens: Array try { // get native Lua completions - luaCompletions.concat(await getLuaCompletions()) - luaSignatures.concat(await getLuaSignatures()) + const apiLua: Array = await getLuaApiSpec() + const specLua: InstrumentSpec = await getLuaInstrumentSpec() // parse shebang tokens shebangTokens = await Shebang.tokenize((shebangLine === undefined) ? '' : shebangLine) @@ -213,8 +216,7 @@ export class TspManager { }) const basicTspItem: TspItem = { - completions: luaCompletions, - signatures: luaSignatures + commandSet: await generateCommandSet(apiLua, specLua) } if (shebangLine !== undefined) { @@ -253,27 +255,8 @@ export class TspManager { ): Promise => { const result: TspItem = item - // if no shebang is present, then just provide Lua items + // if no shebang is present, then return what we were given if (result.shebang === undefined) { - try { - result.completions = await getLuaCompletions() - result.signatures = await getLuaSignatures() - } - catch (e) { - reject(new Error('Lua Completions: ' + e.toString())) - - return - } - - try { - result.signatures = await getLuaSignatures() - } - catch (e) { - reject(new Error('Lua Signatures: ' + e.toString())) - - return - } - resolve(result) return @@ -294,19 +277,17 @@ export class TspManager { // if element has no node number, then assume master model if (token.node === undefined) { - - result.completions = entry.completions - result.signatures = entry.signatures + result.commandSet = entry.commandSet } else { if (result.node === undefined) { result.node = new Map() } - if (entry.completions !== undefined) { + if (entry.commandSet !== undefined) { result.node.set( token.node, - entry.completions + entry.commandSet ) } } diff --git a/server/src/tspPool.ts b/server/src/tspPool.ts index 60519cda..3c590fe2 100644 --- a/server/src/tspPool.ts +++ b/server/src/tspPool.ts @@ -15,19 +15,19 @@ */ 'use strict' -import { CompletionItem, SignatureInformation } from 'vscode-languageserver' - -import { get2450Completions, get2450Signatures } from './instrument/2450' +import { ApiSpec, CommandSet, InstrumentSpec } from './instrument' +import { get2450ApiSpec, get2450InstrumentSpec } from './instrument/2450' // import { get2460Completions, get2460Signatures } from './instrument/2460' // import { get2461Completions, get2461Signatures } from './instrument/2461' // import { get6500Completions, get6500Signatures } from './instrument/6500' -import { getLuaCompletions, getLuaSignatures } from './lua' +import { generateCommandSet } from './instrument/provider' import { Model } from './model' export interface PoolEntry { - completions: Array + apiSpec: Array + commandSet: CommandSet + instrumentSpec: InstrumentSpec references: number - signatures: Array } export class TspPool { @@ -92,122 +92,27 @@ export class TspPool { resolve: (value?: PoolEntry) => void, reject: (reason?: Error) => void ) : Promise => { - let complLua: Array = new Array() - let signaLua: Array = new Array() - - try { - complLua = await getLuaCompletions() - } - catch (e) { - reject(new Error('Unable to load Lua completions')) - } - - try { - signaLua = await getLuaSignatures() - } - catch (e) { - reject(new Error('Unable to load Lua signatures')) - } - switch (model) { case Model.KI2450: - let compl2450: Array = new Array() - let signa2450: Array = new Array() - try { - compl2450 = await get2450Completions() - } - catch (e) { - reject(new Error('Unable to load 2450 completions')) - } + const api2450: Array = await get2450ApiSpec() + const spec2450: InstrumentSpec = await get2450InstrumentSpec() - try { - signa2450 = await get2450Signatures() + const cmdSet2450: CommandSet = await generateCommandSet(api2450, spec2450) + + resolve({ + apiSpec: api2450, + commandSet: cmdSet2450, + instrumentSpec: spec2450, + references: 1 + }) } catch (e) { - reject(new Error('Unable to load 2450 signatures')) + reject(new Error('2450 load failure: ' + e.toString())) } - resolve({ - completions: complLua.concat(compl2450), - references: 1, - signatures: signaLua.concat(signa2450) - }) break - // case Model.KI2460: - // let compl2460: Array = new Array() - // let signa2460: Array = new Array() - - // try { - // compl2460 = await get2460Completions() - // } - // catch (e) { - // reject(new Error('Unable to load 2460 completions')) - // } - - // try { - // signa2460 = await get2460Signatures() - // } - // catch (e) { - // reject(new Error('Unable to load 2460 signatures')) - // } - - // resolve({ - // completions: compl2460, - // references: 1, - // signatures: signa2460 - // }) - // break - // case Model.KI2461: - // /* fall through */ - // case Model.KI2461SYS: - // let compl2461: Array = new Array() - // let signa2461: Array = new Array() - - // try { - // compl2461 = await get2461Completions() - // } - // catch (e) { - // reject(new Error('Unable to load 2461 completions')) - // } - - // try { - // signa2461 = await get2461Signatures() - // } - // catch (e) { - // reject(new Error('Unable to load 2461 signatures')) - // } - - // resolve({ - // completions: compl2461, - // references: 1, - // signatures: signa2461 - // }) - // break - // case Model.KI6500: - // let compl6500: Array = new Array() - // let signa6500: Array = new Array() - - // try { - // compl6500 = await get6500Completions() - // } - // catch (e) { - // reject(new Error('Unable to load 6500 completions')) - // } - - // try { - // signa6500 = await get6500Signatures() - // } - // catch (e) { - // reject(new Error('Unable to load 6500 signatures')) - // } - - // resolve({ - // completions: compl6500, - // references: 1, - // signatures: signa6500 - // }) - // break + default: reject(new Error(`Model ${model} not supported`)) } diff --git a/test/server/src/instrument/2450/index.test.ts b/test/server/src/instrument/2450/index.test.ts new file mode 100644 index 00000000..cc70ddeb --- /dev/null +++ b/test/server/src/instrument/2450/index.test.ts @@ -0,0 +1,129 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import * as isEqual from 'lodash.isequal' +import { suite, test } from 'mocha-typescript' + +import { ApiSpec } from '../../../../../server/src/instrument' +import * as Namespace from '../../../../../server/src/instrument/2450' +import { emptySpec } from '../emptySpec' + +@suite class Model2450IndexTest { + @test('Exports ApiSpec array') + exportsCompletions(): void { + // tslint:disable-next-line:no-magic-numbers + const totalModules = 70 + + assert(Namespace.get2450ApiSpec().length === totalModules, 'Unexpected number of 2450 ApiSpec modules') + + const uniqueNamespaces: Map = new Map() + Namespace.get2450ApiSpec().forEach((value: ApiSpec) => { + switch (value.label) { + case 'beeper': + case 'buffer.write': + case 'buffer': + case 'coroutine': + case 'createconfigscript': + case 'dataqueue': + case 'delay': + case 'digio.line': + case 'digio': + case 'display.input': + case 'display': + case 'eventlog': + case 'exit': + case 'file': + case 'format': + case 'functions': + case 'gpib': + case 'keywords': + case 'lan': + case 'localnode': + case 'math': + case 'node': + case 'opc': + case 'os': + case 'printbuffer': + case 'printnumber': + case 'reset': + case 'script': + case 'smu.interlock': + case 'smu.measure.autozero': + case 'smu.measure.configlist': + case 'smu.measure.filter': + case 'smu.measure.limit.high': + case 'smu.measure.limit.low': + case 'smu.measure.limit': + case 'smu.measure.math.mxb': + case 'smu.measure.math': + case 'smu.measure.rel': + case 'smu.measure': + case 'smu.source.configlist': + case 'smu.source.ilimit': + case 'smu.source.protect': + case 'smu.source.vlimit': + case 'smu.source': + case 'smu': + case 'status.operation': + case 'status.questionable': + case 'status.standard': + case 'status': + case 'string': + case 'table': + case 'timer': + case 'trigger.blender': + case 'trigger.digin': + case 'trigger.digout': + case 'trigger.lanin': + case 'trigger.lanout': + case 'trigger.model': + case 'trigger.timer.start': + case 'trigger.timer': + case 'trigger.tsplinkin': + case 'trigger.tsplinkout': + case 'trigger': + case 'tsplink.line': + case 'tsplink': + case 'tspnet.tsp': + case 'tspnet': + case 'upgrade': + case 'userstring': + case 'waitcomplete': + uniqueNamespaces.set( + value.label, + (uniqueNamespaces.has(value.label)) ? + uniqueNamespaces[value.label] + 1 : + 1 + ) + + return + default: + assert(false, '2450 ApiSpec contains an unknown namespace "' + value.label + '"') + } + }) + + assert(uniqueNamespaces.size === totalModules, '2450 ApiSpec contains duplicate namespaces') + } + + @test('Exports InstrumentSpec') + exportsInstrumentSpec(): void { + assert( + ! isEqual(Namespace.get2450InstrumentSpec(), emptySpec), + '2450 InstrumentSpec is an empty specification' + ) + } +} diff --git a/test/server/src/instrument/emptySpec.ts b/test/server/src/instrument/emptySpec.ts new file mode 100644 index 00000000..68e076e1 --- /dev/null +++ b/test/server/src/instrument/emptySpec.ts @@ -0,0 +1,40 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +'use strict' + +import { InstrumentSpec } from '../../../../server/src/instrument' + +export const emptySpec: InstrumentSpec = { + beeper: { maxHertz: NaN, maxSeconds: NaN, minHertz: NaN, minSeconds: NaN }, + current: { + measure: { level: { high: NaN, low: NaN }, range: { default: NaN, high: NaN, low: NaN } }, + source: { rangeDefault: NaN, ranges: [ NaN ] } + }, + overflow: NaN, + resistance: { level: { high: NaN, low: NaN }, range: { default: NaN, high: NaN, low: NaN } }, + smuInterlock: { maxNominalVoltageTripped: NaN, maxSourceVoltageTripped: NaN }, + smuMeasureAutorange: { + currentLowDefault: NaN, + resistanceHighDefault: NaN, + resistanceLowDefault: NaN, + voltageLowDefault: NaN + }, + smuSourceSweepLog: { currentLevelLow: NaN, voltageLevelLow: NaN }, + voltage: { + measure: { level: { high: NaN, low: NaN }, range: { default: NaN, high: NaN, low: NaN } }, + source: { rangeDefault: NaN, ranges: [ NaN ] } + } +} diff --git a/test/server/src/instrument/lua/index.test.ts b/test/server/src/instrument/lua/index.test.ts new file mode 100644 index 00000000..490a2cff --- /dev/null +++ b/test/server/src/instrument/lua/index.test.ts @@ -0,0 +1,54 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import * as isEqual from 'lodash.isequal' +import { suite, test } from 'mocha-typescript' + +import { ApiSpec } from '../../../../../server/src/instrument' +import * as Namespace from '../../../../../server/src/instrument/lua' +import { emptySpec } from '../emptySpec' + +@suite class LuaIndexTest { + @test('Exports ApiSpec array') + exportsCompletions(): void { + // tslint:disable-next-line:no-magic-numbers + assert(Namespace.getLuaApiSpec().length === 7, 'Lua ApiSpec contains unknown namespaces') + + Namespace.getLuaApiSpec().forEach((value: ApiSpec) => { + switch (value.label) { + case 'coroutine': + case 'functions': + case 'keywords': + case 'math': + case 'os': + case 'string': + case 'table': + return + default: + assert(false, 'Lua ApiSpec contains an unknown namespace "' + value.label + '"') + } + }) + } + + @test('Exports empty InstrumentSpec') + exportsEmptyInstrumentSpec(): void { + assert( + isEqual(Namespace.getLuaInstrumentSpec(), emptySpec), + 'Lua InstrumentSpec is not an empty specification' + ) + } +} diff --git a/test/server/src/instrument/provider/beeper.test.ts b/test/server/src/instrument/provider/beeper.test.ts new file mode 100644 index 00000000..4e3f7e24 --- /dev/null +++ b/test/server/src/instrument/provider/beeper.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/beeper' +import { emptySpec } from '../emptySpec' + +@suite class BeeperTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Beeper to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Beeper' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Beeper to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/buffer-enums.test.ts b/test/server/src/instrument/provider/buffer-enums.test.ts new file mode 100644 index 00000000..70697dc3 --- /dev/null +++ b/test/server/src/instrument/provider/buffer-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/buffer-enums' + +@suite class BufferEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Buffer-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Buffer-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Buffer-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/buffer-write.test.ts b/test/server/src/instrument/provider/buffer-write.test.ts new file mode 100644 index 00000000..e1f03470 --- /dev/null +++ b/test/server/src/instrument/provider/buffer-write.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/buffer-write' +import { emptySpec } from '../emptySpec' + +@suite class BufferWriteTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Buffer-Write to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Buffer-Write' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Buffer-Write to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/buffer.test.ts b/test/server/src/instrument/provider/buffer.test.ts new file mode 100644 index 00000000..4024c492 --- /dev/null +++ b/test/server/src/instrument/provider/buffer.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/buffer' +import { emptySpec } from '../emptySpec' + +@suite class BufferTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Buffer to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Buffer' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Buffer to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/bufferVar.test.ts b/test/server/src/instrument/provider/bufferVar.test.ts new file mode 100644 index 00000000..5d460559 --- /dev/null +++ b/test/server/src/instrument/provider/bufferVar.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/bufferVar' + +@suite class BufferVarTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected BufferVar to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from BufferVar' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from BufferVar' + ) + } +} diff --git a/test/server/src/instrument/provider/coroutine.test.ts b/test/server/src/instrument/provider/coroutine.test.ts new file mode 100644 index 00000000..95dbd4f2 --- /dev/null +++ b/test/server/src/instrument/provider/coroutine.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/coroutine' +import { emptySpec } from '../emptySpec' + +@suite class CoroutineTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Coroutine to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Coroutine' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Coroutine to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/createconfigscript.test.ts b/test/server/src/instrument/provider/createconfigscript.test.ts new file mode 100644 index 00000000..bf93c386 --- /dev/null +++ b/test/server/src/instrument/provider/createconfigscript.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/createconfigscript' +import { emptySpec } from '../emptySpec' + +@suite class CreateconfigscriptTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Createconfigscript to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Createconfigscript' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Createconfigscript to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/dataqueue.test.ts b/test/server/src/instrument/provider/dataqueue.test.ts new file mode 100644 index 00000000..132a6b31 --- /dev/null +++ b/test/server/src/instrument/provider/dataqueue.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/dataqueue' +import { emptySpec } from '../emptySpec' + +@suite class DataqueueTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Dataqueue to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Dataqueue' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Dataqueue to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/delay.test.ts b/test/server/src/instrument/provider/delay.test.ts new file mode 100644 index 00000000..c63b821e --- /dev/null +++ b/test/server/src/instrument/provider/delay.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/delay' +import { emptySpec } from '../emptySpec' + +@suite class DelayTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Delay to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Delay' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Delay to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/digio-enums.test.ts b/test/server/src/instrument/provider/digio-enums.test.ts new file mode 100644 index 00000000..4b104c5f --- /dev/null +++ b/test/server/src/instrument/provider/digio-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/digio-enums' + +@suite class DigioEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Digio-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Digio-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Digio-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/digio-line.test.ts b/test/server/src/instrument/provider/digio-line.test.ts new file mode 100644 index 00000000..bd51cea9 --- /dev/null +++ b/test/server/src/instrument/provider/digio-line.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/digio-line' + +@suite class DigioLineTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Digio-Line to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Digio-Line' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Digio-Line' + ) + } +} diff --git a/test/server/src/instrument/provider/digio.test.ts b/test/server/src/instrument/provider/digio.test.ts new file mode 100644 index 00000000..1f1b600b --- /dev/null +++ b/test/server/src/instrument/provider/digio.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/digio' +import { emptySpec } from '../emptySpec' + +@suite class DigioTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Digio to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Digio' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Digio to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/display-enums.test.ts b/test/server/src/instrument/provider/display-enums.test.ts new file mode 100644 index 00000000..350bf19f --- /dev/null +++ b/test/server/src/instrument/provider/display-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/display-enums' + +@suite class DisplayEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Display-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Display-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Display-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/display-input.test.ts b/test/server/src/instrument/provider/display-input.test.ts new file mode 100644 index 00000000..52a9bbd6 --- /dev/null +++ b/test/server/src/instrument/provider/display-input.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/display-input' +import { emptySpec } from '../emptySpec' + +@suite class DisplayInputTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Display-Input to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Display-Input' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Display-Input to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/display.test.ts b/test/server/src/instrument/provider/display.test.ts new file mode 100644 index 00000000..24235ec4 --- /dev/null +++ b/test/server/src/instrument/provider/display.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/display' +import { emptySpec } from '../emptySpec' + +@suite class DisplayTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Display to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Display' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Display to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/eventlog-enums.test.ts b/test/server/src/instrument/provider/eventlog-enums.test.ts new file mode 100644 index 00000000..2d14f758 --- /dev/null +++ b/test/server/src/instrument/provider/eventlog-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/eventlog-enums' + +@suite class EventlogEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Eventlog-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Eventlog-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Eventlog-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/eventlog.test.ts b/test/server/src/instrument/provider/eventlog.test.ts new file mode 100644 index 00000000..ade777ba --- /dev/null +++ b/test/server/src/instrument/provider/eventlog.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/eventlog' +import { emptySpec } from '../emptySpec' + +@suite class EventlogTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Eventlog to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Eventlog' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Eventlog to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/exit.test.ts b/test/server/src/instrument/provider/exit.test.ts new file mode 100644 index 00000000..cab60031 --- /dev/null +++ b/test/server/src/instrument/provider/exit.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/exit' + +@suite class ExitTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Exit to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Exit' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Exit' + ) + } +} diff --git a/test/server/src/instrument/provider/file-enums.test.ts b/test/server/src/instrument/provider/file-enums.test.ts new file mode 100644 index 00000000..f6cdfe30 --- /dev/null +++ b/test/server/src/instrument/provider/file-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/file-enums' + +@suite class FileEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected File-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from File-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from File-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/file.test.ts b/test/server/src/instrument/provider/file.test.ts new file mode 100644 index 00000000..9a1d8172 --- /dev/null +++ b/test/server/src/instrument/provider/file.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/file' +import { emptySpec } from '../emptySpec' + +@suite class FileTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected File to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from File' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected File to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/format-enums.test.ts b/test/server/src/instrument/provider/format-enums.test.ts new file mode 100644 index 00000000..5addfda6 --- /dev/null +++ b/test/server/src/instrument/provider/format-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/format-enums' + +@suite class FormatEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Format-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Format-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Format-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/format.test.ts b/test/server/src/instrument/provider/format.test.ts new file mode 100644 index 00000000..63a25fb7 --- /dev/null +++ b/test/server/src/instrument/provider/format.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/format' + +@suite class FormatTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Format to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Format' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Format' + ) + } +} diff --git a/test/server/src/instrument/provider/functions.test.ts b/test/server/src/instrument/provider/functions.test.ts new file mode 100644 index 00000000..27a05faf --- /dev/null +++ b/test/server/src/instrument/provider/functions.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/functions' +import { emptySpec } from '../emptySpec' + +@suite class FunctionsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Functions to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Functions' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Functions to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/gpib.test.ts b/test/server/src/instrument/provider/gpib.test.ts new file mode 100644 index 00000000..0f0c3b61 --- /dev/null +++ b/test/server/src/instrument/provider/gpib.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/gpib' + +@suite class GpibTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Gpib to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Gpib' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Gpib' + ) + } +} diff --git a/test/server/src/instrument/provider/keywords.test.ts b/test/server/src/instrument/provider/keywords.test.ts new file mode 100644 index 00000000..468debc2 --- /dev/null +++ b/test/server/src/instrument/provider/keywords.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/keywords' + +@suite class KeywordsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Keywords to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Keywords' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Keywords' + ) + } +} diff --git a/test/server/src/instrument/provider/lan-enums.test.ts b/test/server/src/instrument/provider/lan-enums.test.ts new file mode 100644 index 00000000..8b2f021a --- /dev/null +++ b/test/server/src/instrument/provider/lan-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/lan-enums' + +@suite class LanEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Lan-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Lan-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Lan-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/lan.test.ts b/test/server/src/instrument/provider/lan.test.ts new file mode 100644 index 00000000..ac2ce7a3 --- /dev/null +++ b/test/server/src/instrument/provider/lan.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/lan' +import { emptySpec } from '../emptySpec' + +@suite class LanTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Lan to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Lan' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Lan to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/localnode-enums.test.ts b/test/server/src/instrument/provider/localnode-enums.test.ts new file mode 100644 index 00000000..b3cb7758 --- /dev/null +++ b/test/server/src/instrument/provider/localnode-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/localnode-enums' + +@suite class LocalnodeEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Localnode-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Localnode-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Localnode-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/locanode.test.ts b/test/server/src/instrument/provider/locanode.test.ts new file mode 100644 index 00000000..b87147a9 --- /dev/null +++ b/test/server/src/instrument/provider/locanode.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/localnode' +import { emptySpec } from '../emptySpec' + +@suite class LocalnodeTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Localnode to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Localnode' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Localnode to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/math-enums.test.ts b/test/server/src/instrument/provider/math-enums.test.ts new file mode 100644 index 00000000..59d1f3b9 --- /dev/null +++ b/test/server/src/instrument/provider/math-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/math-enums' + +@suite class MathEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Math-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Math-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Math-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/math.test.ts b/test/server/src/instrument/provider/math.test.ts new file mode 100644 index 00000000..329c8496 --- /dev/null +++ b/test/server/src/instrument/provider/math.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/math' +import { emptySpec } from '../emptySpec' + +@suite class MathTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Math to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Math' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Math to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/node.test.ts b/test/server/src/instrument/provider/node.test.ts new file mode 100644 index 00000000..127f354c --- /dev/null +++ b/test/server/src/instrument/provider/node.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/node' +import { emptySpec } from '../emptySpec' + +@suite class NodeTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Node to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Node' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Node to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/opc.test.ts b/test/server/src/instrument/provider/opc.test.ts new file mode 100644 index 00000000..f36c2dfb --- /dev/null +++ b/test/server/src/instrument/provider/opc.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/opc' + +@suite class OpcTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Opc to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Opc' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Opc' + ) + } +} diff --git a/test/server/src/instrument/provider/os.test.ts b/test/server/src/instrument/provider/os.test.ts new file mode 100644 index 00000000..5b39fe9e --- /dev/null +++ b/test/server/src/instrument/provider/os.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/os' +import { emptySpec } from '../emptySpec' + +@suite class OsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected OS to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from OS' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected OS to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/printbuffer.test.ts b/test/server/src/instrument/provider/printbuffer.test.ts new file mode 100644 index 00000000..4540c5a7 --- /dev/null +++ b/test/server/src/instrument/provider/printbuffer.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/printbuffer' +import { emptySpec } from '../emptySpec' + +@suite class PrintbufferTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Printbuffer to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Printbuffer' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Printbuffer to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/printnumber.test.ts b/test/server/src/instrument/provider/printnumber.test.ts new file mode 100644 index 00000000..9bebab27 --- /dev/null +++ b/test/server/src/instrument/provider/printnumber.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/printnumber' +import { emptySpec } from '../emptySpec' + +@suite class PrintnumberTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Printnumber to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Printnumber' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Printnumber to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/reset.test.ts b/test/server/src/instrument/provider/reset.test.ts new file mode 100644 index 00000000..d62478b7 --- /dev/null +++ b/test/server/src/instrument/provider/reset.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/reset' +import { emptySpec } from '../emptySpec' + +@suite class ResetTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Reset to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Reset' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Reset to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/script.test.ts b/test/server/src/instrument/provider/script.test.ts new file mode 100644 index 00000000..7b56fb48 --- /dev/null +++ b/test/server/src/instrument/provider/script.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/script' +import { emptySpec } from '../emptySpec' + +@suite class ScriptTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Script to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Script' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Script to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/scriptVar.test.ts b/test/server/src/instrument/provider/scriptVar.test.ts new file mode 100644 index 00000000..179bc724 --- /dev/null +++ b/test/server/src/instrument/provider/scriptVar.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/scriptVar' +import { emptySpec } from '../emptySpec' + +@suite class ScriptVarTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected ScriptVar to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from ScriptVar' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected ScriptVar to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/smu-enums.test.ts b/test/server/src/instrument/provider/smu-enums.test.ts new file mode 100644 index 00000000..e6b34338 --- /dev/null +++ b/test/server/src/instrument/provider/smu-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-enums' + +@suite class SmuEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-interlock.test.ts b/test/server/src/instrument/provider/smu-interlock.test.ts new file mode 100644 index 00000000..746549ca --- /dev/null +++ b/test/server/src/instrument/provider/smu-interlock.test.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import { CommandDocumentation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-interlock' +import { emptySpec } from '../emptySpec' + +@suite class SmuInterlockTest { + @test('CompletionDocs formatted properly') + completionDocsFormattedProperly(): void { + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(emptySpec) + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + key + ) + }) + + return + } + }) + } + + @test('Exports completionDocs') + exportsCompletionDocs(): void { + assert( + Namespace.completionDocs !== undefined, + 'Expected Smu-Interlock to export completionDocs' + ) + } + + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Interlock to export completions' + ) + } + + @test('Exports no signatures') + exportsNoSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Interlock' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-autozero.test.ts b/test/server/src/instrument/provider/smu-measure-autozero.test.ts new file mode 100644 index 00000000..8d62a780 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-autozero.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-autozero' + +@suite class SmuMeasureAutozeroTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Autozero to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Autozero' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Autozero' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-configlist.test.ts b/test/server/src/instrument/provider/smu-measure-configlist.test.ts new file mode 100644 index 00000000..ada5d5af --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-configlist.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-configlist' +import { emptySpec } from '../emptySpec' + +@suite class SmuMeasureConfiglistTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Configlist to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Configlist' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Smu-Measure-Configlist to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-filter.test.ts b/test/server/src/instrument/provider/smu-measure-filter.test.ts new file mode 100644 index 00000000..0bc28181 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-filter.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-filter' + +@suite class SmuMeasureFilterTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Filter to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Filter' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Filter' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-limit-high.test.ts b/test/server/src/instrument/provider/smu-measure-limit-high.test.ts new file mode 100644 index 00000000..686eafb7 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-limit-high.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-limit-high' + +@suite class SmuMeasureLimitHighTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Limit-High to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Limit-High' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Limit-High' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-limit-low.test.ts b/test/server/src/instrument/provider/smu-measure-limit-low.test.ts new file mode 100644 index 00000000..f931ba38 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-limit-low.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-limit-low' + +@suite class SmuMeasureLimitLowTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Limit-Low to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Limit-Low' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Limit-Low' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-limit.test.ts b/test/server/src/instrument/provider/smu-measure-limit.test.ts new file mode 100644 index 00000000..6f477da8 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-limit.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-limit' + +@suite class SmuMeasureLimitTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Limit to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Limit' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Limit' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-math-mxb.test.ts b/test/server/src/instrument/provider/smu-measure-math-mxb.test.ts new file mode 100644 index 00000000..d0adb611 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-math-mxb.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-math-mxb' + +@suite class SmuMeasureMathMxbTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Math-Mxb to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Math-Mxb' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Math-Mxb' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-math.test.ts b/test/server/src/instrument/provider/smu-measure-math.test.ts new file mode 100644 index 00000000..3f7d16ce --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-math.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-math' + +@suite class SmuMeasureMathTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Math to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Measure-Math' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Math' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure-rel.test.ts b/test/server/src/instrument/provider/smu-measure-rel.test.ts new file mode 100644 index 00000000..5a858e78 --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure-rel.test.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import { CommandDocumentation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure-rel' +import { emptySpec } from '../emptySpec' + +@suite class SmuMeasureRelTest { + @test('CompletionDocs formatted properly') + completionDocsFormattedProperly(): void { + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(emptySpec) + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + key + ) + }) + + return + } + }) + } + + @test('Exports completionDocs') + exportsCompletionDocs(): void { + assert( + Namespace.completionDocs !== undefined, + 'Expected Smu-Measure-Rel to export completionDocs' + ) + } + + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure-Rel to export completions' + ) + } + + @test('Exports no signatures') + exportsNoSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Measure-Rel' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-measure.test.ts b/test/server/src/instrument/provider/smu-measure.test.ts new file mode 100644 index 00000000..aaba695e --- /dev/null +++ b/test/server/src/instrument/provider/smu-measure.test.ts @@ -0,0 +1,150 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { CommandDocumentation, FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-measure' +import { emptySpec } from '../emptySpec' + +@suite class SmuMeasureTest { + @test('CompletionDocs formatted properly') + completionDocsFormattedProperly(): void { + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(emptySpec) + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + key + ) + }) + + return + } + }) + } + + @test('CompletionDocs formatter handles undefined') + completionsDocsFormatterHandlesUndefined(): void { + const undefinedMeasureRangeSpec = emptySpec + undefinedMeasureRangeSpec.current.measure.range.default = undefined + undefinedMeasureRangeSpec.voltage.measure.range.default = undefined + undefinedMeasureRangeSpec.resistance.range.default = undefined + + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(undefinedMeasureRangeSpec) + + if (key.localeCompare('smu.measure.range') !== 0) { + return + } + + const matches = docString.match(/(UNDEFINED)+/g) + + if (matches === null || matches.length === 0) { + assert( + false, + 'Failed to properly mark specification value as "UNDEFINED"' + ) + } + else { + return + } + }) + } + + @test('Exports completionDocs') + exportsCompletionDocs(): void { + assert( + Namespace.completionDocs !== undefined, + 'Expected Smu-Measure to export completionDocs' + ) + } + + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Measure to export completions' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Smu-Measure to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/smu-source-configlist.test.ts b/test/server/src/instrument/provider/smu-source-configlist.test.ts new file mode 100644 index 00000000..a8153dce --- /dev/null +++ b/test/server/src/instrument/provider/smu-source-configlist.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-source-configlist' +import { emptySpec } from '../emptySpec' + +@suite class SmuSourceConfiglistTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Source-Configlist to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Source-Configlist' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Smu-Source-Configlist to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/smu-source-ilimit.test.ts b/test/server/src/instrument/provider/smu-source-ilimit.test.ts new file mode 100644 index 00000000..173ec738 --- /dev/null +++ b/test/server/src/instrument/provider/smu-source-ilimit.test.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import { CommandDocumentation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-source-ilimit' +import { emptySpec } from '../emptySpec' + +@suite class SmuSourceIlimitTest { + @test('CompletionDocs formatted properly') + completionDocsFormattedProperly(): void { + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(emptySpec) + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + key + ) + }) + + return + } + }) + } + + @test('Exports completionDocs') + exportsCompletionDocs(): void { + assert( + Namespace.completionDocs !== undefined, + 'Expected Smu-Source-Ilimit to export completionDocs' + ) + } + + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Source-Ilimit to export completions' + ) + } + + @test('Exports no signatures') + exportsNoSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Source-Ilimit' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-source-protect.test.ts b/test/server/src/instrument/provider/smu-source-protect.test.ts new file mode 100644 index 00000000..7190b0f9 --- /dev/null +++ b/test/server/src/instrument/provider/smu-source-protect.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu-source-protect' + +@suite class SmuSourceProtectTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Source-Protect to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu-Source-Protect' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Source-Protect' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-source-vlimit.test.ts b/test/server/src/instrument/provider/smu-source-vlimit.test.ts new file mode 100644 index 00000000..c941f573 --- /dev/null +++ b/test/server/src/instrument/provider/smu-source-vlimit.test.ts @@ -0,0 +1,71 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import { CommandDocumentation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-source-vlimit' +import { emptySpec } from '../emptySpec' + +@suite class SmuSourceVlimitTest { + @test('CompletionDocs formatted properly') + completionDocsFormattedProperly(): void { + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(emptySpec) + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + key + ) + }) + + return + } + }) + } + + @test('Exports completionDocs') + exportsCompletionDocs(): void { + assert( + Namespace.completionDocs !== undefined, + 'Expected Smu-Source-Vlimit to export completionDocs' + ) + } + + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Source-Vlimit to export completions' + ) + } + + @test('Exports no signatures') + exportsNoSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu-Source-Vlimit' + ) + } +} diff --git a/test/server/src/instrument/provider/smu-source.test.ts b/test/server/src/instrument/provider/smu-source.test.ts new file mode 100644 index 00000000..474ee9da --- /dev/null +++ b/test/server/src/instrument/provider/smu-source.test.ts @@ -0,0 +1,122 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { CommandDocumentation, FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/smu-source' +import { emptySpec } from '../emptySpec' + +@suite class SmuSourceTest { + @test('CompletionDocs formatted properly') + completionDocsFormattedProperly(): void { + Namespace.completionDocs.forEach((value: CommandDocumentation, key: string) => { + const docString = value.toString(emptySpec) + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + key + ) + }) + + return + } + }) + } + + @test('Exports completionDocs') + exportsCompletionDocs(): void { + assert( + Namespace.completionDocs !== undefined, + 'Expected Smu-Source to export completionDocs' + ) + } + + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu-Source to export completions' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Smu-Source to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/smu.test.ts b/test/server/src/instrument/provider/smu.test.ts new file mode 100644 index 00000000..60993437 --- /dev/null +++ b/test/server/src/instrument/provider/smu.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/smu' + +@suite class SmuTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Smu to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Smu' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Smu' + ) + } +} diff --git a/test/server/src/instrument/provider/status-enums.test.ts b/test/server/src/instrument/provider/status-enums.test.ts new file mode 100644 index 00000000..4e7c070e --- /dev/null +++ b/test/server/src/instrument/provider/status-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/status-enums' + +@suite class StatusEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Status-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Status-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Status-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/status-operation.test.ts b/test/server/src/instrument/provider/status-operation.test.ts new file mode 100644 index 00000000..a7d9c395 --- /dev/null +++ b/test/server/src/instrument/provider/status-operation.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/status-operation' +import { emptySpec } from '../emptySpec' + +@suite class StatusOperationTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Status-Operation to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Status-Operation' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Status-Operation to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/status-questionable.test.ts b/test/server/src/instrument/provider/status-questionable.test.ts new file mode 100644 index 00000000..0d2bacb3 --- /dev/null +++ b/test/server/src/instrument/provider/status-questionable.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/status-questionable' +import { emptySpec } from '../emptySpec' + +@suite class StatusQuestionableTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Status-Questionable to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Status-Questionable' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Status-Questionable to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/status-standard-enums.test.ts b/test/server/src/instrument/provider/status-standard-enums.test.ts new file mode 100644 index 00000000..aaad9acc --- /dev/null +++ b/test/server/src/instrument/provider/status-standard-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/status-standard-enums' + +@suite class StatusStandardEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Status-Standard-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Status-Standard-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Status-Standard-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/status-standard.test.ts b/test/server/src/instrument/provider/status-standard.test.ts new file mode 100644 index 00000000..bc3dc2d6 --- /dev/null +++ b/test/server/src/instrument/provider/status-standard.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/status-standard' + +@suite class StatusStandardTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Status-Standard to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Status-Standard' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Status-Standard' + ) + } +} diff --git a/test/server/src/instrument/provider/status.test.ts b/test/server/src/instrument/provider/status.test.ts new file mode 100644 index 00000000..6afb4a64 --- /dev/null +++ b/test/server/src/instrument/provider/status.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/status' + +@suite class StatusTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Status to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Status' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Status' + ) + } +} diff --git a/test/server/src/instrument/provider/string.test.ts b/test/server/src/instrument/provider/string.test.ts new file mode 100644 index 00000000..17597253 --- /dev/null +++ b/test/server/src/instrument/provider/string.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/string' +import { emptySpec } from '../emptySpec' + +@suite class StringTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected String to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from String' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected String to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/table.test.ts b/test/server/src/instrument/provider/table.test.ts new file mode 100644 index 00000000..f054c484 --- /dev/null +++ b/test/server/src/instrument/provider/table.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/table' +import { emptySpec } from '../emptySpec' + +@suite class TableTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Table to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Table' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Table to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/timer.test.ts b/test/server/src/instrument/provider/timer.test.ts new file mode 100644 index 00000000..a3665bed --- /dev/null +++ b/test/server/src/instrument/provider/timer.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/timer' + +@suite class TimerTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Timer to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Timer' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Timer' + ) + } +} diff --git a/test/server/src/instrument/provider/trigger-blender.test.ts b/test/server/src/instrument/provider/trigger-blender.test.ts new file mode 100644 index 00000000..c1ab1d72 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-blender.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-blender' +import { emptySpec } from '../emptySpec' + +@suite class TriggerBlenderTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Blender to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Blender' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger-Blender to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/trigger-digin.test.ts b/test/server/src/instrument/provider/trigger-digin.test.ts new file mode 100644 index 00000000..726c8dd3 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-digin.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-digin' +import { emptySpec } from '../emptySpec' + +@suite class TriggerDiginTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Digin to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Digin' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger-Digin to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/trigger-digout.test.ts b/test/server/src/instrument/provider/trigger-digout.test.ts new file mode 100644 index 00000000..7c30329e --- /dev/null +++ b/test/server/src/instrument/provider/trigger-digout.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-digout' + +@suite class TriggerDigoutTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Digout to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Digout' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Trigger-Digout' + ) + } +} diff --git a/test/server/src/instrument/provider/trigger-enums.test.ts b/test/server/src/instrument/provider/trigger-enums.test.ts new file mode 100644 index 00000000..dc363dd9 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-enums' + +@suite class TriggerEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Trigger-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/trigger-lanin.test.ts b/test/server/src/instrument/provider/trigger-lanin.test.ts new file mode 100644 index 00000000..bb3b5b23 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-lanin.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-lanin' +import { emptySpec } from '../emptySpec' + +@suite class TriggerLaninTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Lanin to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Lanin' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger-Lanin to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/trigger-lanout.test.ts b/test/server/src/instrument/provider/trigger-lanout.test.ts new file mode 100644 index 00000000..cda72f8f --- /dev/null +++ b/test/server/src/instrument/provider/trigger-lanout.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-lanout' + +@suite class TriggerLanoutTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Lanout to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Lanout' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Trigger-Lanout' + ) + } +} diff --git a/test/server/src/instrument/provider/trigger-model.test.ts b/test/server/src/instrument/provider/trigger-model.test.ts new file mode 100644 index 00000000..53792de8 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-model.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-model' +import { emptySpec } from '../emptySpec' + +@suite class TriggerModelTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Model to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Model' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger-Model to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/trigger-timer-start.test.ts b/test/server/src/instrument/provider/trigger-timer-start.test.ts new file mode 100644 index 00000000..3d942e26 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-timer-start.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-timer-start' + +@suite class TriggerTimerStartTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Timer-Start to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Timer-Start' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Trigger-Timer-Start' + ) + } +} diff --git a/test/server/src/instrument/provider/trigger-timer.test.ts b/test/server/src/instrument/provider/trigger-timer.test.ts new file mode 100644 index 00000000..514c8840 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-timer.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-timer' +import { emptySpec } from '../emptySpec' + +@suite class TriggerTimerTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Timer to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Timer' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger-Timer to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/trigger-tsplinkin.test.ts b/test/server/src/instrument/provider/trigger-tsplinkin.test.ts new file mode 100644 index 00000000..d9a6e721 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-tsplinkin.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-tsplinkin' +import { emptySpec } from '../emptySpec' + +@suite class TriggerTsplinkinTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Tsplinkin to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Tsplinkin' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger-Tsplinkin to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/trigger-tsplinkout.test.ts b/test/server/src/instrument/provider/trigger-tsplinkout.test.ts new file mode 100644 index 00000000..8d9313c0 --- /dev/null +++ b/test/server/src/instrument/provider/trigger-tsplinkout.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/trigger-tsplinkout' + +@suite class TriggerTsplinkoutTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger-Tsplinkout to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger-Tsplinkout' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Trigger-Tsplinkout' + ) + } +} diff --git a/test/server/src/instrument/provider/trigger.test.ts b/test/server/src/instrument/provider/trigger.test.ts new file mode 100644 index 00000000..d3a05031 --- /dev/null +++ b/test/server/src/instrument/provider/trigger.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/trigger' +import { emptySpec } from '../emptySpec' + +@suite class TriggerTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Trigger to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Trigger' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Trigger to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/tsplink-enums.test.ts b/test/server/src/instrument/provider/tsplink-enums.test.ts new file mode 100644 index 00000000..be382631 --- /dev/null +++ b/test/server/src/instrument/provider/tsplink-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/tsplink-enums' + +@suite class TsplinkEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Tsplink-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Tsplink-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Tsplink-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/tsplink-line.test.ts b/test/server/src/instrument/provider/tsplink-line.test.ts new file mode 100644 index 00000000..48bb9d95 --- /dev/null +++ b/test/server/src/instrument/provider/tsplink-line.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/tsplink-line' + +@suite class TsplinkLineTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Tsplink-Line to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Tsplink-Line' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Tsplink-Line' + ) + } +} diff --git a/test/server/src/instrument/provider/tsplink.test.ts b/test/server/src/instrument/provider/tsplink.test.ts new file mode 100644 index 00000000..25d9f022 --- /dev/null +++ b/test/server/src/instrument/provider/tsplink.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/tsplink' +import { emptySpec } from '../emptySpec' + +@suite class TsplinkTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Tsplink to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Tsplink' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Tsplink to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/tspnet-enums.test.ts b/test/server/src/instrument/provider/tspnet-enums.test.ts new file mode 100644 index 00000000..81277d67 --- /dev/null +++ b/test/server/src/instrument/provider/tspnet-enums.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/tspnet-enums' + +@suite class TspnetEnumsTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Tspnet-Enums to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Tspnet-Enums' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Tspnet-Enums' + ) + } +} diff --git a/test/server/src/instrument/provider/tspnet-tsp.test.ts b/test/server/src/instrument/provider/tspnet-tsp.test.ts new file mode 100644 index 00000000..62cfafe2 --- /dev/null +++ b/test/server/src/instrument/provider/tspnet-tsp.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/tspnet-tsp' +import { emptySpec } from '../emptySpec' + +@suite class TspnetTspTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Tspnet-Tsp to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Tspnet-Tsp' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Tspnet-Tsp to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/tspnet.test.ts b/test/server/src/instrument/provider/tspnet.test.ts new file mode 100644 index 00000000..81450d60 --- /dev/null +++ b/test/server/src/instrument/provider/tspnet.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/tspnet' +import { emptySpec } from '../emptySpec' + +@suite class TspnetTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Tspnet to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Tspnet' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Tspnet to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/upgrade.test.ts b/test/server/src/instrument/provider/upgrade.test.ts new file mode 100644 index 00000000..baa1512d --- /dev/null +++ b/test/server/src/instrument/provider/upgrade.test.ts @@ -0,0 +1,46 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' + +import * as Namespace from '../../../../../server/src/instrument/provider/upgrade' + +@suite class UpgradeTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Upgrade to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Upgrade' + ) + } + + @test('Exports no signatures') + exportsSignatures(): void { + assert( + ! Namespace.hasOwnProperty('signatures'), + 'Unexpected signatures export from Upgrade' + ) + } +} diff --git a/test/server/src/instrument/provider/userstring.test.ts b/test/server/src/instrument/provider/userstring.test.ts new file mode 100644 index 00000000..a33215f2 --- /dev/null +++ b/test/server/src/instrument/provider/userstring.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/userstring' +import { emptySpec } from '../emptySpec' + +@suite class UserstringTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Userstring to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Userstring' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Userstring to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/test/server/src/instrument/provider/waitcomplete.test.ts b/test/server/src/instrument/provider/waitcomplete.test.ts new file mode 100644 index 00000000..0a2fdb27 --- /dev/null +++ b/test/server/src/instrument/provider/waitcomplete.test.ts @@ -0,0 +1,99 @@ +/* + * Copyright 2018 Tektronix Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +// tslint:disable:no-implicit-dependencies prefer-function-over-method +import { assert } from 'chai' +import { suite, test } from 'mocha-typescript' +import { ParameterInformation } from 'vscode-languageclient' + +import { FormattableSignatureInformation } from '../../../../../server/src/instrument/provider' +import * as Namespace from '../../../../../server/src/instrument/provider/waitcomplete' +import { emptySpec } from '../emptySpec' + +@suite class WaitcompleteTest { + @test('Exports completions') + exportsCompletions(): void { + assert( + Namespace.completions !== undefined, + 'Expected Waitcomplete to export completions' + ) + } + + @test('Exports no completionDocs') + exportsNoCompletionDocs(): void { + assert( + ! Namespace.hasOwnProperty('completionDocs'), + 'Unexpected completionDocs export from Waitcomplete' + ) + } + + @test('Exports signatures') + exportsSignatures(): void { + assert( + Namespace.signatures !== undefined, + 'Expected Waitcomplete to export signatures' + ) + } + + @test('Signatures formatted properly') + signaturesFormattedProperly(): void { + Namespace.signatures.forEach((element: FormattableSignatureInformation) => { + const formattedParams = element.getFormattedParameters(emptySpec) + + if (formattedParams.length === 0) { + assert(true) + + return + } + + formattedParams.forEach((value: ParameterInformation) => { + if (value.documentation !== undefined) { + let docString: string + + if (typeof value.documentation === 'string') { + docString = value.documentation + } + else if (typeof value.documentation === 'object') { + docString = value.documentation.value + } + else { + assert( + false, + 'Unknown type for ParameterInformation.documentation: ' + typeof value.documentation + ) + + return + } + + const matches = docString.match(/%\{[0-9]+\}/) + + if (matches === null || matches.length > 0) { + return + } + else { + matches.forEach((matched: string) => { + assert( + false, + 'Matched a replacement string "' + matched + '" from ' + element.label + ) + }) + + return + } + } + }) + }) + } +} diff --git a/tslint.json b/tslint.json index 45a99f36..30dedb65 100644 --- a/tslint.json +++ b/tslint.json @@ -38,11 +38,11 @@ "no-parameter-reassignment": true, "no-reference": false, // add exceptions as an array: [true, "exception1", "exception2"] - "no-unnecessary-type-assertion": true, + // "no-unnecessary-type-assertion": true, "no-var-requires": true, "only-arrow-functions": false, "prefer-for-of": true, - "promise-function-async": true, + // "promise-function-async": true, "typedef": [ true, "call-signature", @@ -58,7 +58,7 @@ "unified-signatures": true, // Functionality - "await-promise": true, + // "await-promise": true, "ban-comma-operator": true, "ban": false, "curly": [true, "ignore-same-line"], @@ -79,10 +79,10 @@ "no-dynamic-delete": true, "no-empty": true, "no-eval": true, - "no-floating-promises": true, - "no-for-in-array": true, + // "no-floating-promises": true, + // "no-for-in-array": true, "no-implicit-dependencies": true, - "no-inferred-empty-object-type": true, + // "no-inferred-empty-object-type": true, "no-invalid-template-strings": true, "no-invalid-this": true, "no-misused-new": true, @@ -97,28 +97,28 @@ // bypassed with the magic /* falls through */ comment "no-switch-case-fall-through": true, "no-this-assignment": true, - "no-unbound-method": true, + // "no-unbound-method": true, "no-unnecessary-class": true, - "no-unsafe-any": true, + // "no-unsafe-any": true, "no-unsafe-finally": true, "no-unused-expression": true, - "no-use-before-declare": true, + // "no-use-before-declare": true, "no-var-keyword": true, - "no-void-expression": [true, "ignore-arrow-function-shorthand"], + // "no-void-expression": [true, "ignore-arrow-function-shorthand"], "prefer-conditional-expression": [true, "check-else-if"], "prefer-object-spread": true, "radix": true, - "restrict-plus-operands": true, - "strict-boolean-expressions": true, - "strict-type-predicates": true, + // "restrict-plus-operands": true, + // "strict-boolean-expressions": true, + // "strict-type-predicates": true, "switch-default": false, "triple-equals": true, - "use-default-type-parameter": true, + // "use-default-type-parameter": true, "use-isnan": true, // Maintainability "cyclomatic-complexity": false, - "deprecation": true, + // "deprecation": true, "eofline": true, "indent": [true, "spaces", 4], "linebreak-style": [true, "LF"], @@ -141,7 +141,7 @@ "shorthand-first" ], "prefer-const": true, - "prefer-readonly": true, + // "prefer-readonly": true, "trailing-comma": [ true, { @@ -180,12 +180,12 @@ "interface-name": false, "interface-over-type-literal": true, "jsdoc-format": [true, "check-multiline-start"], - "match-default-export-name": true, + // "match-default-export-name": true, "newline-before-return": true, "newline-per-chained-call": false, "new-parens": true, "no-angle-bracket-type-assertion": true, - "no-boolean-literal-compare": true, + // "no-boolean-literal-compare": true, "no-consecutive-blank-lines": true, "no-irregular-whitespace": true, "no-parameter-properties": false, @@ -194,7 +194,7 @@ "no-trailing-whitespace": true, "no-unnecessary-callback-wrapper": true, "no-unnecessary-initializer": true, - "no-unnecessary-qualifier": true, + // "no-unnecessary-qualifier": true, "number-literal-format": true, "object-literal-key-quotes": [true, "as-needed"], "object-literal-shorthand": true, @@ -215,7 +215,7 @@ "prefer-template": false, "prefer-while": true, "quotemark": [true, "single", "avoid-escape"], - "return-undefined": true, + // "return-undefined": true, "semicolon": [true, "never"], "space-before-function-paren": [ true, diff --git a/utils/cmdset_differ.sh b/utils/cmdset_differ.sh new file mode 100644 index 00000000..18c45151 --- /dev/null +++ b/utils/cmdset_differ.sh @@ -0,0 +1,75 @@ +#!/usr/bin/env bash + +cmdset_differ() { + # USAGE: cmdset_differ dirA dirB file + + local -a dir_a_cmds=( ) + local -a dir_b_cmds=( ) + + local -a dir_a_has=( ) + local -a dir_b_has=( ) + + ## load dirA command names + for f in "${1}"/*.htm; do + local headername + headername="$(grep '^).*(?=\<)' -)" || return + dir_a_cmds[${#dir_a_cmds[@]}]="$headername" + done + + ## load dirB command names + for f in "${2}"/*.htm; do + local headername + headername="$(grep '^).*(?=\<)' -)" || return + dir_b_cmds[${#dir_b_cmds[@]}]="$headername" + done + + ## O(n^2) array search! + for cmdA in "${dir_a_cmds[@]}"; do + local -i match=0 + + for cmdB in "${dir_b_cmds[@]}"; do + if [[ "$cmdA" == "$cmdB" ]]; then + match=1 + break + fi + done + + if [ "$match" -eq 0 ]; then + dir_a_has[${#dir_a_has[@]}]="$cmdA" + fi + done + + ## O(n^2) array search (again)! + for cmdB in "${dir_b_cmds[@]}"; do + local -i match=0 + + for cmdA in "${dir_a_cmds[@]}"; do + if [[ "$cmdB" == "$cmdA" ]]; then + match=1 + break + fi + done + + if [ "$match" -eq 0 ]; then + dir_b_has[${#dir_b_has[@]}]="$cmdB" + fi + done + + if [[ "${#dir_a_has[@]}" -eq 0 && "${#dir_b_has[@]}" -eq 0 ]]; then + echo 'No differences!' + return + fi + + ## output to file + echo "${1}" > "${3}" || return + for aHas in "${dir_a_has[@]}"; do + echo "$aHas" >> "${3}" || return + done + + echo -e "\n${2}" >> "${3}" || return + for bHas in "${dir_b_has[@]}"; do + echo "$bHas" >> "${3}" || return + done +} + +cmdset_differ "$@" diff --git a/utils/differ.sh b/utils/differ.sh new file mode 100644 index 00000000..f1d46623 --- /dev/null +++ b/utils/differ.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +differ() { + # USAGE: differ dirA dirB dirOutput + + for f in "${1}"/*.htm; do + local filename name + filename="$(basename "$f")" + name="${filename//.htm/}" + local file_b="${2}"/"$filename" + + if [ -f "$file_b" ]; then + local diffcontent + + diffcontent="$(diff "$f" "$file_b")" + + if [ -n "$diffcontent" ]; then + local headername + headername="$(grep '^).*(?=\<)' -)" || return + echo "$diffcontent" >> "${3}"/"$headername"-"$name".diff || return + fi + fi + done +} + +differ "$@"