VSCode A-Shell ExtensionSkip to Installation Guide to avoid my ramblings.Updates[
Fix] compil.ps1 - Jorge pointed out that compil.ps1 cannot handle directory references with spaces, this should now not be an issue. See the $cmd_args variable declaration for more details.
ProgressWe've made a little progress but it still doesn't have a language server, which would be required to make it really powerful. However, I do use it every day for all of my development work now. This is partly due to the extension, and partly due to the power of VSCode. I won't yammer on about VSCode, it needs to be experienced to fully understand its useful qualities. However, I'll add a few notes about how I use it.
You guys bringing this up has reinvigorated me and as such I've fixed a few bugs in the latest build. When our workload calms down, I'll get the project up and running properly again.
I've added the image of the Hermosa Pier to a) inspire me and b) because it makes this post feel like a 90's software manual
.
What can it do?1. Highlight syntax.
2. Show/hide sections of code, it correctly recognises routines and functions for the most part. It still has a few issues in this area but functions are pretty solid now.
3. Compile with a single command. When running compile locally, it is as fast as APN.
4. List compilation errors with links that snap you to the location of the error when clicked. This
should work fine across files/includes.
What can't it do?1. It won't scan code for errors live although APN doesn't do this either.
2. Go to Definition. Although VSCode's search is very powerful which does circumvent this somewhat.
3. AutoComplete. It can partially do this, however this is using VSCode's built in attempt which can be a little flakey.
All of these issues would be solved by implementing a Language Server, which would really improve things. It would allow for modern code monitoring as seen in languages like Javascript, which would allow you to see errors pop up live as you are typing. This however would take
considerable effort to implement.
Useful VSCode Functionality1. Command Palette (Ctrl + Shift + P) - used to execute many special commands within the IDE
2. File Search (Ctrl + P) - as it sounds, great for your workflow if your workspace is setup correctly
3. Find in Folder (Shift + Alt + F or right-click folder) - similar to a GUI based grep/find in linux, a decent replacement for Go to Definition in APN
4. Tasks: Run Build Task (Ctrl + Shift + B) - run a task, we use this for Compile
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Installation GuideSee each Step below for more detail1. Download latest Version
2. Install VSCode and Create a Workspace
3. Install VSCode Extension using .vsix file (e.g. ashell-1.0.2.vsix)
4. Add a new Compiler Task in VSCode
5. Customise compil.ps1 Script
Step 1: Download latest Version1. Go to
A-Shell Extension bitbucket
2. Download
ashell-1.0.2.vsix (or latest version)
3. Download
comil.ps1Step 2: Install VSCode and Create a Workspace1. Install
VSCode2. Open VSCode
3. Click File
4. Click Open Folder...
5. Open the highest level folder that contains your A-Shell Files
6. Create a new Folder called
aux-files at the top level of this workspace, this needs to be here as it is used by the Compiler Task (see Step 4: Add a new Compiler Task in VSCode)
7. Move
compil.ps1 file downloaded in
Step 1 in to
aux-files VSCode Workspaces are a little like Projects in APN. There are many reasons to use them, the most important of which is File Search (Ctrl + P) which will search across your open Workspace for files. This is a powerful way to access files without having to use the explorer manually. Another feature I use regularly is Find in Folder (Shift + Alt + F or right-click a folder in the Explorer), which I use in lieu of Go to Definition.
Step 3: Install VSCode Extension1. Open VSCode
2. Click Extensions (left sidebar)
3. Click the ellipsis (top right of left sidebar)
4. Click "Install from VSIX..."
5. Select the .vsix file downloaded in
Step 16. Reload your VSCode instance
You should now see A-Shell Language Module in the Extensions list. At this point you are ready to use the Syntax Highlighter but
not the compiler!
Step 4: Add a new Compiler Task in VSCode1. Use the Command Palette (Ctrl+Shift+P) and type "Tasks"
2. Click "Tasks: Open User Tasks"
3. Add the following object to the "tasks": [ ] array;
{
"label": "A-Shell Compile",
"type": "shell",
"command": "${workspaceFolder}\\aux-files\\compil.ps1",
"args": [
"${file}",
"${workspaceFolder}"
],
"options": {
"cwd": "c:\\"
},
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"reveal": "always",
"revealProblems": "always",
"focus": false,
"echo": true,
"showReuseMessage": false,
"panel": "shared",
"clear": true
},
"problemMatcher": {
"owner": "ashell",
"fileLocation": [
"autoDetect",
"${fileDirname}"
],
"pattern": {
"regexp": "^(\\d+),(.+),(\\d+),(.+),(.+)$",
"file": 2,
"line": 3,
"column": 1,
"message": 4,
"code": 5
}
}
}
Step 5: Customise compil.ps1 Script1. Open up
compil.ps12. Read the comments in the file
3. You likely will have to change the location of
ashed.ini and
compil.exe on lines 18 and 19. We have our
ashed.ini at the top level of our A-Shell directory and compil.exe is in our local c:/.
4. You may also want to change the compiler arguments but I'll leave that up to you. I've left in what we use, I expect they will work for you. If you don't use certain flags then you may get weird results if you've structured your files in a certain way.
Step X: Stuff that I may have missed but I can't be sure... You can skip this (maybe)!1. You may need to install and/or update PowerShell on Windows
2. You may want to change your VSCode User Settings to recognise different word separators. Command Palette > Preferences: Open User Settings and add this line after "editor.wordSeparators";
"[ashell]": { "editor.wordSeparators": "`~!@#%^&*()-=+[{]}\\|;:\",.<>/?" },
We use this REGEX because we use apostrophes in our variable/routine/function names e.g. PRINT'ALL'TENANTS. If you didn't have the above set, then when you double-clicked PRINT'ALL'TENANTS it would treat PRINT, ALL and TENANTS as separate words. A minor annoyance.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
General InformationNow when you run the Command Palette >
Tasks: Run Build Task (Ctrl + Shift + B) VSCode will attempt to run compil via the compil.ps1 script on
any file you have focused in VSCode! If everything is setup correctly, then this should result in a short "Building..." loading spinner followed by the Problems tab being populated (or not, if there are no errors in the file).
The extension should automatically switch VSCode's Language to A-Shell when opening the following list of file extensions. If it doesn't then you can manually assign a language to a file by clicking the far bottom right toolbar and selecting A-Shell or use Command Palette >
Change Language Mode.
.bp .bas .bsi .map .max .bav .mav .r10 .r11
The CompilerThe file compil.ps1 is a wrapper script for the compil operation, it passes the run command with the required arguments to compil.exe. It then outputs a temporary file which is parsed by VSCode, the result is shown in the Problems panel. The compil.ps1 script is only required to re-order this data and if compil.exe were able to output the format we require, then we could cut this step out.
tasks.json allows this format to be customised however after some experimentation it does appear to require certain elements (such as Column #). For this reason the first part of each line in the problems file is 1 (a fake column number). An example line would be as follows;
column, filename, line #, error, code
1, dsk11\077251\tenjson.bas, 429, Unmapped variable: COMPNY'NO, 123
1, dsk11\077251\tenjson.bas, 430, Your code is terrible, 123
Future DevelopmentLet me know in a reply below if I've missed any commonly used A-Shell file extensions, or if there are keywords/functions/compiler statements I've missed. I've been adding to the syntax highlighter as I've been doing day to day work, so I have no doubt that I am missing a bunch of these.
At some point soon™ I'll open source the main BitBucket Repo so that you guys can pull down the source and add/change whatever you want. I'll also get the documentation on the extension sorted, as it is a mess at the moment.
Once this is done, I'll happily hand-over the project to Microsabio, if you guys want it. Otherwise it can remain a community project!
Publishing the ExtensionIf MicroSabio have a Microsoft corporation account, then feel free to publish it. I am not sure if there is any reason to until the extension is a little more fleshed out. I was going to do this under the OmniLedger umbrella but we use our corporation account fairly heavily.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
P.S. I realise I've stolen MicroSabio's company logo for use in this extension, please let me know and I'll remove it. However, I consider the extension to be the property of the MicroSabio community and withhold no rights (outside of bragging) for myself or for OmniLedger.