Compare commits

...

10 Commits

Author SHA1 Message Date
Dag
aa92d04ed4 Update changelog 2023-01-20 00:00:17 +01:00
Dag
a7b0d69266 Use const keyword 2023-01-19 23:43:45 +01:00
Dag
b4f7e6c830 Added empty test suite 2023-01-19 23:43:26 +01:00
Dag
35da45bc3c Regenerated json files 2023-01-19 23:26:20 +01:00
Dag
2891bfe000 Point to Run menu 2023-01-19 22:15:27 +01:00
Dag
85cb76a14c Remove reference to monokai 2023-01-19 22:15:01 +01:00
Dag Evensberget
f210995b98 Use LFS 2020-05-09 19:36:25 +10:00
Dag Evensberget
8eed3f72fd Add package lock file 2020-02-06 10:46:54 +10:00
Dag Evensberget
b439d7f865 Add instructions to run in Extension Development Host 2020-02-06 10:42:44 +10:00
Dag Evensberget
f380fdc207 Tidy changelog 2020-02-06 10:00:37 +10:00
13 changed files with 2742 additions and 98 deletions

21
.eslintrc.json Normal file
View File

@ -0,0 +1,21 @@
{
"env": {
"browser": true,
"es2021": true
},
"extends": [
"eslint:recommended",
"plugin:@typescript-eslint/recommended"
],
"overrides": [
],
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest"
},
"plugins": [
"@typescript-eslint"
],
"rules": {
}
}

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
*.xcf filter=lfs diff=lfs merge=lfs -text

View File

@ -8,49 +8,50 @@ Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how
### 0.0.1
Initial release with syntax highlighting.
- Initial release with syntax highlighting.
### 0.2.0
Added hierarchical [outline view](https://code.visualstudio.com/docs/getstarted/userinterface#_outline-view).
- Added hierarchical [outline view](https://code.visualstudio.com/docs/getstarted/userinterface#_outline-view).
### 0.2.2
Fixed image in README to reflect new features.
- Fixed image in README to reflect new features.
### 0.2.3
Tidy README and clean up `devDependencies`.
- Tidy README and clean up `devDependencies`.
### 0.2.4
Mention support for [Breadcrumbs](https://code.visualstudio.com/updates/v1_26#_breadcrumbs).
- Mention support for [Breadcrumbs](https://code.visualstudio.com/updates/v1_26#_breadcrumbs).
### 0.2.5
Add icon to marketplace.
- Add icon to marketplace.
### 0.2.6
Move manual installation instructions to [INSTALL.md](INSTALL.md). Add transparent icon borders.
- Move manual installation instructions to [INSTALL.md](INSTALL.md). Add transparent icon borders.
### 0.2.7
Set banner background to Monokai dark background.
- Set banner background to Monokai dark background.
### 0.2.8
Use default banner background.
- Use default banner background.
### 0.2.9
Add badges to README
- Add badges to README
## [1.0.0] - 2019-12-02
- Tidy README
- Add license badge
## Not yet released
## [1.0.1] - 2021-01-19
- Migrate from `vscode` to `vscode-test` [as described on the VS Code site](https://code.visualstudio.com/api/working-with-extensions/testing-extension#migrating-from-vscode).
- Use more recent version of libraries to avoid security vulnerability found by GitHub's dependabot.

View File

@ -1,10 +1,10 @@
# Installation
# Manual installation
>This is a [Visual Studio Code](https://code.visualstudio.com/download) extension. It is best installed from the [on-line extensions marketplace](https://marketplace.visualstudio.com/items?itemName=svaberg.swmf-grammar), or from inside VS Code `Preferences/Extensions` and search for `swmf-grammar`.
_Alternatively_, the extension can be built and installed manually as in the next section. This should only be required for developers.
## Manual installation from source code
## Build the extension
1. Clone the repository and enter into the folder
@ -19,14 +19,32 @@ _Alternatively_, the extension can be built and installed manually as in the nex
npm install
```
3. Create a package using `vsce`
3. Compile with `npm`
```bash
npm run compile
```
At this point the extension may be debugged in the Extension Development Host:
```bash
code .
```
followed by the `Run/Start Debugging` dropdown (or the `F5` key). To observe the extension in action, view the file `demo.in`.
To complete the manual installation, follow the remaining steps to manually create and install the package:
## Package and install the extension
4. Create a package using `vsce`
```bash
vsce package
```
This should generate a `swmf-grammar-?.?.?.vsix` file in the current directory.
4. Manually install the extension in VS Code (you may want to replace the wildcards in the version number)
5. Manually install the extension in VS Code (you may want to replace the wildcards in the version number)
```bash
code --install-extension swmf-grammar-?.?.?.vsix

View File

@ -1,5 +1,5 @@
#ECHO
Highlighting demo using Monokai dark theme.
Highlighting demo using dark theme.
#BEGIN_COMP SC Marker with folding button in margin

3
images/icon.xcf Normal file
View File

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:96f1e9c2ba8b74a9fdb75bb1b486a54d1d8a1e079054f1b1f4813e962eb64cb3
size 14180

2508
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,58 +1,73 @@
{
"name": "swmf-grammar",
"displayName": "SWMF Configuration",
"description": "Syntax highlights and outline view for SWMF configuration files",
"version": "1.0.0",
"publisher": "svaberg",
"repository": {
"type": "git",
"url": "https://github.com/svaberg/SWMF-grammar"
},
"license": "MIT",
"engines": {
"vscode": "^1.41.0"
},
"categories": [
"Programming Languages",
"Formatters"
],
"icon": "images/icon.png",
"main": "./out/extension.js",
"activationEvents": [
"onLanguage:swmf-config"
],
"contributes": {
"languages": [
{
"id": "swmf-config",
"aliases": [
"SWMF Config",
"swmf"
],
"extensions": [
".in",
".IN"
],
"configuration": "./language-configuration.json"
}
"name": "swmf-grammar",
"displayName": "SWMF Configuration",
"description": "Syntax highlights and outline view for SWMF configuration files",
"version": "1.0.1",
"publisher": "svaberg",
"repository": {
"type": "git",
"url": "https://github.com/svaberg/SWMF-grammar.git"
},
"license": "MIT",
"engines": {
"vscode": "^1.74.0"
},
"categories": [
"Programming Languages",
"Formatters"
],
"activationEvents": [
"onLanguage:swmf-config"
],
"icon": "images/icon.png",
"main": "./out/extension.js",
"contributes": {
"languages": [
{
"id": "swmf-config",
"aliases": [
"SWMF Config",
"swmf"
],
"grammars": [
{
"language": "swmf-config",
"scopeName": "source.swmf",
"path": "./syntaxes/swmf.tmLanguage.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile"
},
"devDependencies": {
"typescript": "^3.7.5",
"vscode-test": "^1.3.0",
"@types/vscode": "^1.41.0"
}
"extensions": [
".in",
".IN"
],
"configuration": "./language-configuration.json"
}
],
"grammars": [
{
"language": "swmf-config",
"scopeName": "source.swmf",
"path": "./syntaxes/swmf.tmLanguage.json"
}
]
},
"scripts": {
"vscode:prepublish": "npm run compile",
"compile": "tsc -p ./",
"watch": "tsc -watch -p ./",
"pretest": "npm run compile && npm run lint",
"lint": "eslint src --ext ts",
"test": "node ./out/test/runTest.js"
},
"devDependencies": {
"@types/glob": "^8.0.0",
"@types/mocha": "^10.0.1",
"@types/node": "16.x",
"@types/vscode": "^1.74.0",
"@typescript-eslint/eslint-plugin": "^5.48.2",
"@typescript-eslint/parser": "^5.48.2",
"@vscode/test-electron": "^2.2.0",
"eslint": "^8.28.0",
"glob": "^8.0.3",
"mocha": "^10.1.0",
"typescript": "^4.9.3"
},
"bugs": {
"url": "https://github.com/svaberg/SWMF-grammar/issues"
},
"homepage": "https://github.com/svaberg/SWMF-grammar#readme",
"author": "Dag Evensberget"
}

View File

@ -26,24 +26,24 @@ class SwmfConfigDocumentSymbolProvider implements vscode.DocumentSymbolProvider
{
return new Promise((resolve, reject) =>
{
let symbols: vscode.DocumentSymbol[] = [];
let nodes = [symbols]
const symbols: vscode.DocumentSymbol[] = [];
const nodes = [symbols]
let inside_marker = false
let inside_run = false
let inside_userinput = false
let symbolkind_marker = vscode.SymbolKind.Field
let symbolkind_run = vscode.SymbolKind.Event
let symbolkind_cmd = vscode.SymbolKind.Function
const symbolkind_marker = vscode.SymbolKind.Field
const symbolkind_run = vscode.SymbolKind.Event
const symbolkind_cmd = vscode.SymbolKind.Function
for (var i = 0; i < document.lineCount; i++) {
var line = document.lineAt(i);
for (let i = 0; i < document.lineCount; i++) {
const line = document.lineAt(i);
let tokens = line.text.split(" ")
const tokens = line.text.split(" ")
if (line.text.startsWith("#BEGIN_COMP")) {
let marker_symbol = new vscode.DocumentSymbol(
const marker_symbol = new vscode.DocumentSymbol(
this.format(tokens[0]) + " " + tokens[1],
'Component',
symbolkind_marker,
@ -66,7 +66,7 @@ class SwmfConfigDocumentSymbolProvider implements vscode.DocumentSymbolProvider
}
else if (line.text.startsWith("#RUN") || line.text.startsWith("#END")) {
let run_symbol = new vscode.DocumentSymbol(
const run_symbol = new vscode.DocumentSymbol(
this.format(tokens[0]),
'Session separator',
symbolkind_run,
@ -82,7 +82,7 @@ class SwmfConfigDocumentSymbolProvider implements vscode.DocumentSymbolProvider
}
else if (line.text.startsWith("#USERINPUTBEGIN")) {
let user_symbol = new vscode.DocumentSymbol(
const user_symbol = new vscode.DocumentSymbol(
this.format(tokens[0]),
'User module',
vscode.SymbolKind.Interface,
@ -104,7 +104,7 @@ class SwmfConfigDocumentSymbolProvider implements vscode.DocumentSymbolProvider
}
}
else if (line.text.startsWith("#")) {
let cmd_symbol = new vscode.DocumentSymbol(
const cmd_symbol = new vscode.DocumentSymbol(
this.format(tokens[0]),
'',
symbolkind_cmd,

23
src/test/runTest.ts Normal file
View File

@ -0,0 +1,23 @@
import * as path from 'path';
import { runTests } from '@vscode/test-electron';
async function main() {
try {
// The folder containing the Extension Manifest package.json
// Passed to `--extensionDevelopmentPath`
const extensionDevelopmentPath = path.resolve(__dirname, '../../');
// The path to test runner
// Passed to --extensionTestsPath
const extensionTestsPath = path.resolve(__dirname, './suite/index');
// Download VS Code, unzip it and run the integration test
await runTests({ extensionDevelopmentPath, extensionTestsPath });
} catch (err) {
console.error('Failed to run tests');
process.exit(1);
}
}
main();

View File

@ -0,0 +1,15 @@
import * as assert from 'assert';
// You can import and use all API from the 'vscode' module
// as well as import your extension to test it
import * as vscode from 'vscode';
// import * as myExtension from '../../extension';
suite('Extension Test Suite', () => {
vscode.window.showInformationMessage('Start all tests.');
test('Sample test', () => {
assert.strictEqual(-1, [1, 2, 3].indexOf(5));
assert.strictEqual(-1, [1, 2, 3].indexOf(0));
});
});

38
src/test/suite/index.ts Normal file
View File

@ -0,0 +1,38 @@
import * as path from 'path';
import * as Mocha from 'mocha';
import * as glob from 'glob';
export function run(): Promise<void> {
// Create the mocha test
const mocha = new Mocha({
ui: 'tdd',
color: true
});
const testsRoot = path.resolve(__dirname, '..');
return new Promise((c, e) => {
glob('**/**.test.js', { cwd: testsRoot }, (err, files) => {
if (err) {
return e(err);
}
// Add files to the test suite
files.forEach(f => mocha.addFile(path.resolve(testsRoot, f)));
try {
// Run the mocha test
mocha.run(failures => {
if (failures > 0) {
e(new Error(`${failures} tests failed.`));
} else {
c();
}
});
} catch (err) {
console.error(err);
e(err);
}
});
});
}

View File

@ -1,16 +1,17 @@
{
"compilerOptions": {
"module": "commonjs",
"target": "es6",
"outDir": "out",
"lib": [
"es6"
],
"sourceMap": true,
"rootDir": "src"
},
"exclude": [
"node_modules",
".vscode-test"
]
}
"compilerOptions": {
"module": "commonjs",
"target": "ES2020",
"outDir": "out",
"lib": [
"ES2020"
],
"sourceMap": true,
"rootDir": "src",
"strict": true /* enable all strict type-checking options */
/* Additional Checks */
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */
// "noUnusedParameters": true, /* Report errors on unused parameters. */
}
}