Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request 113 #121

Merged
merged 5 commits into from
Sep 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 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 @@ -374,6 +375,34 @@ 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:
```
{
"Language": {
"Type": "customFunctions",
"functions": [
{
"key": "SampleFunctionName",
"insertText":"SampleFunctionName('var1')",
"index": 1,
"detail": "function description that will display in the hover",
"documentation": "function documentaion that will display in the hover\r\nThis is line 2"
}
]
}
}
```
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.
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@
"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",
Expand Down Expand Up @@ -341,4 +346,4 @@
"webpack-cli": "^3.3.11"
},
"dependencies": {}
}
}
21 changes: 20 additions & 1 deletion server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ interface ExampleSettings {
ignoreGotoScope: boolean;
customWords: string;
customWordPath: string;
customFunctions: string;
customFunctionPath: string;
languageType: string;
trace: any; // expect trace.server is string enum 'off', 'messages', 'verbose'
}
Expand All @@ -69,6 +71,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 @@ -219,7 +222,23 @@ 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 Down