diff --git a/CHANGELOG.md b/CHANGELOG.md index 2da0760..64061c0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ It is in the file `package.json` --> +## [0.3.10] - 2020-01-20 + +- Add support for Ampersand 4.0. This release of ampersand has a new command line interface. The plugin now + automatically detects the version you use. The daemon is launched using the correct command. +- Support for (deprecated!!) `PATTERN`/`ENDPATTERN`, `PROCESS`/`ENDPROCESS`, and `SERVICE`/`ENDSERVICE` syntax reinstated + ## [0.3.9] - 2019-08-23 - Fix launching on MacOS diff --git a/package-lock.json b/package-lock.json index 1fff050..f950c8b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "language-ampersand", - "version": "0.3.0", + "version": "0.3.9", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -659,9 +659,9 @@ } }, "lodash": { - "version": "4.17.11", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz", - "integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg==", + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, "lodash.isfunction": { diff --git a/package.json b/package.json index 92f8e08..bb0aead 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "language-ampersand", "displayName": "Ampersand (ADL) language support", - "version": "0.3.9", + "version": "0.3.10", "publisher": "AmpersandTarski", "description": "Language support for Ampersand scripts", "categories": [ diff --git a/snippets/ampersand.json b/snippets/ampersand.json index 1dc3717..35d765e 100644 --- a/snippets/ampersand.json +++ b/snippets/ampersand.json @@ -285,13 +285,17 @@ "description": "propbutton arguments", "body":[ "cRud BOX ", - " [ label: TXT \"${1:buttontext}\" -- text to show on the button", - " , property: ${2:propertyrelation} cRUd -- relation of type [PROP] whose value is toggled when user presses button", - " , color: TXT \"${3|primary,secondary,success,warning,danger,info,light,dark,link|}\" -- primary=blue secondary=grey, success=green, warning=yellow, danger=red, info=lightblue, light=grey, dark=black", - " , disabledcolor: TXT \"${4|primary,secondary,success,warning,danger,info,light,dark,link|}\" -- precede color with `outline-` (e.g. `outline-primary`) to make an outline-button", - " , disabled: ${5:propertyExpression} cRud -- when [PROP]-type expression is not empty, button is disabled (user cannot click it)", - " , hide: ${6:propertyExpression} cRud -- when [PROP]-type expression is not empty, button does not show on screen", - " , popovertext: TXT \"${7:hovertext}\" -- text that shows when user hovers cursor over the button", + " [ label: TXT \"${1:buttontext}\" -- text to show on the button (label text)", + " , label1: TXT \"${2:buttontext}\" -- label text = label+label1", + " , label2: TXT \"${3:buttontext}\" -- label text = label+label1+label2", + " , label3: TXT \"${4:buttontext}\" -- label text = label+label1+label2+label3", + " , property: ${5:propertyrelation} cRUd -- relation of type [PROP] whose value is toggled when user presses button", + " , color: TXT \"${6|primary,secondary,success,warning,danger,info,light,dark,link|}\" -- primary=blue secondary=grey, success=green, warning=yellow, danger=red, info=lightblue, light=grey, dark=black", + " , disabledcolor: TXT \"${7|primary,secondary,success,warning,danger,info,light,dark,link|}\" -- precede color with `outline-` (e.g. `outline-primary`) to make an outline-button", + " , disabled: ${8:propertyExpression} cRud -- when [PROP]-type expression is not empty, button is disabled (user cannot click it)", + " , hide: ${9:propertyExpression} cRud -- when [PROP]-type expression is not empty, button does not show on screen", + " , disabledpopovertext: TXT \"${11:disabledhovertext}\" -- text that shows when user hovers cursor over the button when it is disabled", + " , popovertext: TXT \"${10:hovertext}\" -- text that shows when user hovers cursor over the button", " ]" ] }, diff --git a/src/extension.ts b/src/extension.ts index 86b7a5a..afffb2d 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -161,9 +161,20 @@ export function activate(context: vscode.ExtensionContext) { let file = path.join(os.tmpdir(), "ampersandDaemon-" + hash + ".txt"); context.subscriptions.push({dispose: () => {try {fs.unlinkSync(file);} catch (e) {};}}); fs.writeFileSync(file, ""); - + let versionString : string = getVersion(); let runAmpersandCommand : string = "ampersand"; - let runAmpersandArgs : string = "--daemon"; + var runAmpersandArgs : string = ""; + let version : string = versionString.substr(10,3) + if (version === "v4.") { + runAmpersandArgs = "daemon" + } else if (version === "v3.") { + runAmpersandArgs = "--daemon" + } else { + vscode.window.showErrorMessage + ('The version of ampersand you have installed, is not supported: '+versionString) + + } + let opts : vscode.TerminalOptions = os.type().startsWith("Windows") ? {shellPath: "cmd.exe", shellArgs: ["/k", runAmpersandCommand , runAmpersandArgs]} : @@ -178,6 +189,16 @@ export function activate(context: vscode.ExtensionContext) { } +function getVersion() : string { + const { execSync } = require('child_process'); + // stderr is sent to stderr of parent process + // you can set options.stdio if you want it to go elsewhere + let command = `${constants.extension.generatorName} --version`; + let version = execSync(command); + var string = new TextDecoder("utf-8").decode(version); + return string + +} function checkVersion () { @@ -196,7 +217,7 @@ function checkVersion () { return " " + b } } - let r1 = /Ampersand-(v[0-9]+\.[0-9]+\.[0-9]+) \[(.*)?\],/ ; + let r1 = /Ampersand-(v[0-9]+\.[0-9]+\.[0-9]+) \[(.*)?\]/ ; var m : RegExpMatchArray | null ; var result : string | null = null ; if (m = xs.match(r1)) { diff --git a/syntaxes/ampersand.tmLanguage.json b/syntaxes/ampersand.tmLanguage.json index 3bee6c6..836aa1c 100644 --- a/syntaxes/ampersand.tmLanguage.json +++ b/syntaxes/ampersand.tmLanguage.json @@ -8,13 +8,14 @@ [ { "comment": "to be reviewed using https://www.sublimetext.com/docs/3/scope_naming.html"}, { "include": "#COMMENTS" }, { "include": "#CONTEXT" }, + { "include": "#ENDPATTERN" }, { "include": "#META" }, { "include": "#PURPOSE" }, { "include": "#INCLUDE" }, { "include": "#CONCEPT" }, { "include": "#CLASSIFY" }, - { "include": "#REPRESENT" }, - { "include": "#IDENT" }, + { "include": "#REPRESENT" }, + { "include": "#IDENT" }, { "include": "#RELATION" }, { "include": "#MSGMEANING" }, { "include": "#PRAGMA" }, @@ -103,7 +104,7 @@ "CONTEXT": { "patterns": - [ { "match": "\\b(CONTEXT)\\s+(\")?([^\"]*)(\\2)?(\\s+IN\\s+(DUTCH|ENGLISH))?", + [ { "match": "\\b(CONTEXT|PATTERN|PROCESS)\\s+(\")?([^\"]*)(\\2)?(\\s+IN\\s+(DUTCH|ENGLISH))?", "captures": { "0": { "name":"meta.context.ampersand"}, "1": { "name":"keyword.operator.context.ampersand"}, @@ -117,6 +118,16 @@ ] }, + "ENDPATTERN": + { "patterns": + [ { "match": "\\b(ENDPATTERN|ENDPROCESS)\\b", + "captures": { + "1": { "name":"keyword.operator.context.language.ampersand"} + } + } + ] + }, + "META": { "patterns": [ { "match": "\\b(META)\\s+(\")([^\"]*)(\")\\s+(\")([^\"]*)(\")", @@ -182,7 +193,7 @@ }, { "comment":"PURPOSE \"\" -- tnx to https://github.com/Microsoft/vscode-textmate/issues/41", "name": "meta.purpose.ampersand", - "begin": "\\b(PURPOSE)\\s+(CONTEXT|CONCEPT|RELATION|RULE|INTERFACE|API|GUI)\\s+(?:(\\w+)|(\")([^\"]+)(\"))(?:\\s*(IN)\\s+(DUTCH|ENGLISH))?(?:\\s+(REF)\\s+(\")([^\"]*)(\"))?", + "begin": "\\b(PURPOSE)\\s+(CONTEXT|PATTERN|PROCESS|CONCEPT|RELATION|RULE|INTERFACE|API|GUI)\\s+(?:(\\w+)|(\")([^\"]+)(\"))(?:\\s*(IN)\\s+(DUTCH|ENGLISH))?(?:\\s+(REF)\\s+(\")([^\"]*)(\"))?", "beginCaptures": { "0": { "name":"meta.purpose.begin.ampersand"}, "1": { "name":"keyword.operator.purpose.ampersand"}, @@ -307,23 +318,23 @@ }, { "comment": "CLASSIFY IS /\\ ...", "name": "meta.classify.is.ampersand", - "begin": "\\b(CLASSIFY)\\s+(?:([A-Z]\\w*)|(\")([A-Z][^\"]*)(\"))(?:\\s*(,)\\s*(?:([A-Z]\\w*)|(\")([A-Z][^\"]*)(\")))*\\s+(IS)\\s+(?:([A-Z]\\w*)|(\")([A-Z][^\"]*)(\"))", + "begin": "\\b(CLASSIFY)\\s(?:\\s*(?:([A-Z]\\w*)|(\")([A-Z][^\"]*)(\"))\\s*(,))*(?:\\s*(?:([A-Z]\\w*)|(\")([A-Z][^\"]*)(\")))\\s+(IS)\\s+(?:([A-Z]\\w*)|(\")([A-Z][^\"]*)(\"))", "beginCaptures": { "0": { "name":"meta.classify.is.begin.ampersand"}, "1": { "name":"keyword.operator.classify.ampersand"}, - "2": { "name":"variable.concept.ampersand"}, + "2": { "name":"variable.unquoted.concept.ampersand"}, "3": { "name":"punctuation.statement.classify.ampersand"}, - "4": { "name":"variable.concept.ampersand"}, + "4": { "name":"variable.quoted.concept.ampersand"}, "5": { "name":"punctuation.statement.classify.ampersand"}, "6": { "name":"punctuation.statement.classify.ampersand"}, - "7": { "name":"variable.concept.ampersand"}, + "7": { "name":"variable.unquoted.concept.ampersand"}, "8": { "name":"punctuation.statement.classify.ampersand"}, - "9": { "name":"variable.concept.ampersand"}, + "9": { "name":"variable.quoted.concept.ampersand"}, "10": { "name":"punctuation.statement.classify.ampersand"}, "11": { "name":"keyword.operator.classify.ampersand"}, - "12": { "name":"variable.concept.ampersand"}, + "12": { "name":"variable.unquoted.concept.ampersand"}, "13": { "name":"punctuation.statement.classify.ampersand"}, - "14": { "name":"variable.concept.ampersand"}, + "14": { "name":"variable.quoted.concept.ampersand"}, "15": { "name":"punctuation.statement.classify.ampersand"} }, "end": "^(?=\\s*([^A-Z/]|VIOLATION|ROLE|SERVICE|RULE|INCLUDE|CONCEPT|CLASSIFY|REPRESENT|IDENT|RELATION|[a-z]\\w*\\s*::|POPULATION|INTERFACE|VIEW|MEANING|MESSAGE|PRAGMA))",