Skip to content

Commit

Permalink
Develop (#123)
Browse files Browse the repository at this point in the history
* RegEx fix for labels with leading spaces.

* 98-Issue linting with multiple levels of quoting

* RegEx improvement for quoted strings

* Replace parenthesis and quoted strings with empty ones.
- Removed repetitive Trim()s
- Removed unnecessary RegEx tests
- Simplified line split on semicolon due to above changes.
- Results: Faster execution. Better coverage for split on semicolon

* - Cleanup lines[] array at start so repeated test/replace not needed
- Removed unnecessary trim()s
- Removed boolean equality tests. if(x.test == true) vs if(x.test)
- Fixed GOTO/GOSUB when followed by more than one space GOTO <s><s> 100

* RegEx fix-ups to support recent changes

* Corrected comment

* Linter RegEx cleanup

* FOR/NEXT tracking improvements and updated error messages
- Nested For/Next statements now validated
- NEXT with no variable is now allowed
- One line per error: Removed extraneous, repeated diagnostic messages
- Reworded / Clarified some error messages for consistency

* Minor code clean-up

* Replace char-at-a-time split on ; with split(";")

* Maintain original character spacing for Intellisense error markers
- RegEx improvements and consistency between client and server
- Improved getWord() function

* Corrected indentation for ELSE END with trailing comment (issue #45)

* Corrects Label error with GOTO/GOSUB. Issue #99
- Also now allows dotted numeric labels such as GOTO 100.5

* Revert "Corrects Label error with GOTO/GOSUB. Issue #99"

This reverts commit 68b0166.

* Inspect TM Scopes->Inspect Editor Token and Scopes

* Fix error processing customWordPath when last
line is blank. May relate to #24.

* Changed GOTO/GOSUB scope jumping message from Error to Warning

* Numerous updates related to For/Next and Label tracking
- Issue #45: Alignment of If/Else
- Issue #96: Allow periods in labels
- Issue #99: Corrected Label error with GOTO/GOSUB.
- Issue #104: Corrected For/Next with leading label
- Issue #105: Changed GOTO scope jumping message from Error to Warning
- RegEx: Label comments to include "REM, *, and !"
- NEXT can be used without FOR variable.

* Shipping 2.0.7

* Re-introduce accidentally deleted /doc files

* Fixes issue 107: FOR/NEXT error when no whitespace after FOR variable.

* Shipping 2.0.8

* Issue #110: Do not change indentation of comment lines

* Issue #111: Added user setting to control indentation of comment lines.

* Bump elliptic from 6.5.2 to 6.5.3 (#119)

Bumps [elliptic](https://github.com/indutny/elliptic) from 6.5.2 to 6.5.3.
- [Release notes](https://github.com/indutny/elliptic/releases)
- [Commits](indutny/elliptic@v6.5.2...v6.5.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Update Extension Guide.md

Updated AccuTerm connector and host program links.

* Feature request 113 (#121)

* Update package.json

Added MVBasic.customFunctionPath

* Update server.ts

added functionality to Load CustomFunction definition

* Add files via upload

* Update Extension Guide.md

added documentation for Custom functions and subroutines 6.8

* Update server.ts

Removed `data: functions[i].index,` for now since Microsoft has not responded yet.  It works without it, and it's no longer in the Microsoft API documentation.

* - Fix issue with startLoop/endLoop in server code parser
- Clean up unused variable in server
- Expand docs on new customFunctions feature

* Shipping 2.0.9

Co-authored-by: Kevin Powick <[email protected]>
Co-authored-by: Ian McGowan <[email protected]>
Co-authored-by: Peter Schellenbach <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Brent Blair <[email protected]>
  • Loading branch information
6 people authored Sep 1, 2020
1 parent a452ca5 commit 3e911fa
Show file tree
Hide file tree
Showing 11 changed files with 114 additions and 16 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,10 @@
## 2.0.8

- Fixed a bug with FOR/NEXT recognition and spacing (#107)

## 2.0.9

- Fixed a bug with LOOP/REPEAT recognition and spacing (no issue)
- Fixed a bug with formatting for comment lines (#110)
- Added new indentComment setting to control comment indentation (#111)
- Added new customFunctionPath setting to allow users to contribute custom functions/subroutines for IntelliSense and linting (#113)
4 changes: 2 additions & 2 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mvbasic",
"displayName": "MV Basic",
"description": "MV Basic",
"version": "2.0.8",
"version": "2.0.9",
"publisher": "mvextensions",
"license": "MIT",
"icon": "../images/mvbasic-logo.png",
Expand Down
28 changes: 28 additions & 0 deletions client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var UseGateway: boolean;
var UsingRest: boolean;
var margin: number;
var indent: number;
var indentComment: string;
var formattingEnabled: boolean;
var editFiles: any;
var customWordColor: any;
Expand Down Expand Up @@ -85,6 +86,7 @@ export function activate(context: vscode.ExtensionContext) {
UsingRest = vscode.workspace.getConfiguration("MVBasic").get("UseRestFS");
margin = vscode.workspace.getConfiguration("MVBasic").get("margin");
indent = vscode.workspace.getConfiguration("MVBasic").get("indent");
indentComment = vscode.workspace.getConfiguration("MVBasic").get("indentComment");
formattingEnabled = vscode.workspace.getConfiguration("MVBasic").get("formattingEnabled");
editFiles = vscode.workspace.getConfiguration("MVBasic").get("EditFiles");
customWordColor = vscode.workspace.getConfiguration("MVBasic").get("customWordColor");
Expand Down Expand Up @@ -390,6 +392,32 @@ export function activate(context: vscode.ExtensionContext) {
if (RowLevel[i] === undefined) { continue; }

indentation = (RowLevel[i] * indent) + margin

// Comment indent rules
if (rComment.test(lineText)) {
switch (indentComment) {
case "left": {
// Indent comment to margin position 0
indentation = 0;
break;
}
case "margin": {
// Indent comment to margin position
indentation = margin;
break;
}
case "code": {
// Indent comment with code
break;
}
default: {
// No change to indent if indentComment = "ignore",
// is missing, or has an invalid value.
continue;
}
}
}

if (new RegExp("(^case\\s)", "i").test(lineText)) {
indentation -= indent
}
Expand Down
38 changes: 36 additions & 2 deletions doc/Extension Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ All other trademarks and service marks are property of their respective holders.
- [6.5 Internal Subroutine lookup](#65-internal-subroutine-lookup)
- [6.6 Compiling and Cataloging your programs](#66-compiling-and-cataloging-your-programs)
- [6.7 Formatting Programs](#67-formatting-programs)
- [6.8 Custom functions and subroutines](#68-custom-functions-and-subroutines)
- [7. Sample Settings Files](#7-sample-settings-files)
- [7.1 Universe](#71-universe)
- [7.2 Unidata](#72-unidata)
Expand Down Expand Up @@ -240,9 +241,9 @@ Content-Type: application/json

### 5.2 Option 2 - AccuTerm

To use AccuTerm to connect the MV Basic extension to your MV server, you must be running AccuTerm 7.1 or above (with [this add-on](https://zdownload.blob.core.windows.net/accuterm/Miscellaneous/Windows/x86/1.0.5.0/accuterm-vscode-connector.exe)) or AccuTerm [8.0.1020](https://zdownload.blob.core.windows.net/accuterm/Standard/Windows/x86/8.0.1020.0/atwin_8.0.1020.exe) or above (no add-on required).
To use AccuTerm to connect the MV Basic extension to your MV server, you must be running AccuTerm 7.1 or above (with [this add-on](https://zdownload.blob.core.windows.net/accuterm/Miscellaneous/Windows/x86/1.0.6.0/accuterm-vscode-connector.exe)) or AccuTerm [8.0.1020](https://zdownload.blob.core.windows.net/accuterm/Standard/Windows/x86/8.0.1020.0/atwin_8.0.1020.exe) or above (no add-on required).

The latest version of the AccuTerm host programs should be used with this connector (8.0.7). You can verify your version by typing FTABOUT at a command prompt (TCL) in the ACCUTERM account. You can download version 8.0.7 with [this link](https://zdownload.blob.core.windows.net/accuterm/Host-Programs/Windows/x86/8.0.7.0/pickbp.exe).
The latest version of the AccuTerm host programs should be used with this connector (8.0.7). You can verify your version by typing FTABOUT at a command prompt (TCL) in the ACCUTERM account. You can download version 8.0.10 with [this link](https://zdownload.blob.core.windows.net/accuterm/Host-Programs/Windows/x86/8.0.10.0/pickbp.exe).

*Note: the 8.0.1020 release of AccuTerm 8 **does not** include the latest host programs. You should update the host programs after installing 8.0.1020. See above.*

Expand Down Expand Up @@ -374,6 +375,39 @@ After the option is selected, results are displayed in the `MV Basic` Output win

**Right clicking** and selecting `Format Document`, will format your BASIC program. The formatting is based on the 2 settings, `MVBasic.indent` and `MVBasic.margin` that have default values of 3 and 5.

### 6.8 Custom functions and subroutines

This allows you to autocomplete and document your popular functions and subroutines.

This is a sample of the autocompleted function that is also displaying the documentation on hover:
![Find References](screenshots/sampleFunctions.png)

This is a sample of the json file that you use to document the functions and subroutines:

``` json
{
"Language": {
"Type": "customFunctionPath",
"functions": [
{
"key": "SampleFunctionName",
"insertText":"SampleFunctionName('var1')",
"kind": 2,
"detail": "function description that will display in the hover",
"documentation": "function documentaion that will display in the hover\r\nThis is line 2"
}
]
}
}
```

> Note, the `kind` property should map to the [CompletionItemKind](https://code.visualstudio.com/api/references/vscode-api#CompletionItemKind) enumerator from the VS Code api. Typically you will likely set this to `2` to classify items as a _function_ definition.
This is the MVBasic extension setting that points to the above json file:
| Setting | Value | Description |
| -------------------------- | ---------------------------------- | ----------------------------------------------------------------- |
| MVBasic.customFunctionPath | c:\users\user\customFunctions.json | Path to a file that contains key value pairs for custom functions |

[(top)](#table-of-contents)

## 7. Sample Settings Files
Expand Down
Binary file added doc/screenshots/sampleFunctions.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mvbasic",
"displayName": "MV Basic",
"description": "MV Basic",
"version": "2.0.8",
"version": "2.0.9",
"publisher": "mvextensions",
"license": "MIT",
"icon": "images/mvbasic-logo.png",
Expand Down Expand Up @@ -139,12 +139,23 @@
"type": "string",
"description": "Path to a file that contains key value pairs for custom words"
},
"MVBasic.customFunctionPath": {
"scope": "resource",
"type": "string",
"description": "Path to a file that contains key value pairs for custom functions"
},
"MVBasic.indent": {
"scope": "resource",
"type": "number",
"default": 3,
"description": "The number of characters to use when indenting code blocks."
},
"MVBasic.indentComment": {
"scope": "resource",
"type": "string",
"default": "ignore",
"description": "Indentation of comment lines. Set to: left, margin, code, or ignore."
},
"MVBasic.maxNumberOfProblems": {
"scope": "resource",
"type": "number",
Expand Down
4 changes: 2 additions & 2 deletions server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "mvbasic",
"displayName": "MV Basic",
"description": "MV Basic",
"version": "2.0.8",
"version": "2.0.9",
"publisher": "mvextensions",
"license": "MIT",
"icon": "../images/mvbasic-logo.png",
Expand Down
22 changes: 20 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ interface ExampleSettings {
ignoreGotoScope: boolean;
customWords: string;
customWordPath: string;
customFunctionPath: string;
languageType: string;
trace: any; // expect trace.server is string enum 'off', 'messages', 'verbose'
}
Expand All @@ -69,6 +70,7 @@ interface DocumentLine {
let maxNumberOfProblems: number;
let customWordList: string;
let customWordPath: string;
let customFunctionPath: string;
let languageType: string;
let logLevel: number;
let Intellisense: CompletionItem[] = [];
Expand Down Expand Up @@ -220,6 +222,22 @@ function loadIntelliSense() {
}
}

// Load CustomFunction definition
if (customFunctionPath !== "") {
var functionDefinition = fs.readFileSync(customFunctionPath, "utf8");
var customFunctionList = JSON.parse(functionDefinition);
var functions = customFunctionList.Language.functions;
for (let i = 0; i < functions.length; i++) {
Intellisense.push({
label: functions[i].key,
insertText: functions[i].insertText,
kind: functions[i].kind,
detail: functions[i].detail,
documentation: functions[i].documentation
});
}
}

if (logLevel) {
connection.console.log(
`[Server(${process.pid})] Language definition loaded for ${languageType}`
Expand All @@ -242,8 +260,8 @@ function validateTextDocument(textDocument: TextDocument): void {
let rBlockEnd = new RegExp("(^| )(end|end case|next|next\\s+.+|repeat)$", "i");
let rStartFor = new RegExp("(^| )for\\s+[\\w.]+\\s*=", "i");
let rEndFor = new RegExp("(^| )next($|\\s+.+$)", "i");
let rStartLoop = new RegExp("(^| )loop\\s*?", "i");
let rEndLoop = new RegExp("(^| )repeat\\s*$", "i");
let rStartLoop = new RegExp("(^| )loop( |$)\\s*?", "i");
let rEndLoop = new RegExp("(^| )repeat( |$)\\s*$", "i");
let rStartCase = new RegExp("(^| )begin case$", "i");
let rEndCase = new RegExp("^\\s*end case$", "i");
let rElseEnd = new RegExp("^\\s*end else$", "i");
Expand Down

0 comments on commit 3e911fa

Please sign in to comment.