diff --git a/client/.vscode/tasks.json b/client/.vscode/tasks.json index 1992757..acff7f5 100755 --- a/client/.vscode/tasks.json +++ b/client/.vscode/tasks.json @@ -8,23 +8,28 @@ // A task runner that calls a custom npm script that compiles the extension. { - "version": "0.1.0", + "version": "2.0.0", // we want to run npm "command": "npm", - // the command is a shell script - "isShellCommand": true, - - // show the output window only if unrecognized errors occur. - "showOutput": "silent", - // we run the custom script "compile" as defined in package.json "args": ["run", "compile", "--loglevel", "silent"], // The tsc compiler is started in watching mode - "isWatching": true, + "isBackground": true, // use the standard tsc in watch mode problem matcher to find compile problems in the output. - "problemMatcher": "$tsc-watch" + "problemMatcher": "$tsc-watch", + + // show the output window only if unrecognized errors occur. + "presentation": { + "echo": true, + "reveal": "silent", + "focus": false, + "panel": "shared" + }, + + // the command is a shell script + "type": "shell" } \ No newline at end of file diff --git a/client/package.json b/client/package.json index 4a00668..d7eb543 100755 --- a/client/package.json +++ b/client/package.json @@ -11,7 +11,7 @@ ], "homepage": "https://hyperledger.github.io/composer/", "license": "Apache-2.0", - "version": "0.14.2", + "version": "0.15.0", "publisher": "HyperledgerComposer", "icon": "icon.png", "engines": { diff --git a/client/snippets/composer-acl.json b/client/snippets/composer-acl.json index 445cf7d..f8f2f14 100644 --- a/client/snippets/composer-acl.json +++ b/client/snippets/composer-acl.json @@ -5,9 +5,9 @@ "rule ${1:BasicRuleName} {", "\tdescription: \"${2:Description of the Basic ACL rule}\"", "\tparticipant: \"${3:ANY}\"", - "\toperation: ${4:ALL | CREATE, READ, UPDATE, DELETE}", + "\toperation: ${4|ALL,CREATE,READ,UPDATE,DELETE|}", "\tresource: \"${5:org.acme.SampleAsset}\"", - "\taction: ${6:ALLOW | DENY}$0", + "\taction: ${6|ALLOW,DENY|}$0", "}" ], "description": "Basic Composer ACL Rule" @@ -18,10 +18,10 @@ "rule ${1:ConditionalRuleName} {", "\tdescription: \"${2:Description of the Conditional ACL rule}\"", "\tparticipant(${3:p}): \"${4:org.acme.SampleParticipant}\"", - "\toperation: ${5:ALL | CREATE, READ, UPDATE, DELETE}", + "\toperation: ${5|ALL,CREATE,READ,UPDATE,DELETE|}", "\tresource(${6:r}): \"${7:org.acme.SampleAsset}\"", "\tcondition: ($3 === $6)", - "\taction: ${8:ALLOW | DENY}$0", + "\taction: ${8|ALLOW,DENY|}$0", "}" ], "description": "Conditional Composer ACL Rule" @@ -32,11 +32,11 @@ "rule ${1:TransactionalRuleName} {", "\tdescription: \"${2:Description of the Transactional ACL rule}\"", "\tparticipant: \"${3:ANY}\"", - "\toperation: ${4:ALL | CREATE, READ, UPDATE, DELETE}", + "\toperation: ${4|ALL,CREATE,READ,UPDATE,DELETE|}", "\tresource(${5:res}): \"${6:org.acme.SampleAsset}\"", - "\ttransaction(${7:tx}): \"${8:org.acme.SampeTxn}\"", + "\ttransaction(${7:tx}): \"${8:org.acme.SampleTxn}\"", "\tcondition: ($7.asset.type() === $5.asset.type())", - "\taction: ${9:ALLOW | DENY}$0", + "\taction: ${9|ALLOW,DENY|}$0", "}" ], "description": "Transactional Composer ACL Rule" diff --git a/client/snippets/composer.json b/client/snippets/composer.json index 28aed87..5654e0b 100755 --- a/client/snippets/composer.json +++ b/client/snippets/composer.json @@ -20,8 +20,8 @@ "Transaction": { "prefix": "transaction", "body": [ - "transaction ${1:transactionName} identified by ${2:transactionKey} {", - "\to String ${2}$0", + "transaction ${1:transactionName} {", + "\to String ${2:detail}$0", "}" ], "description": "Composer Transaction" @@ -29,8 +29,8 @@ "Event": { "prefix": "event", "body": [ - "event ${1:eventName} identified by ${2:eventKey} {", - "\to String ${2}$0", + "event ${1:eventName} {", + "\to String ${2:detail}$0", "}" ], "description": "Composer Event" diff --git a/composer.code-workspace b/composer.code-workspace new file mode 100644 index 0000000..3647867 --- /dev/null +++ b/composer.code-workspace @@ -0,0 +1,10 @@ +{ + "folders": [ + { + "path": "client" + }, + { + "path": "server" + } + ] +} \ No newline at end of file diff --git a/server/.vscode/tasks.json b/server/.vscode/tasks.json index 6a159d6..1a6ea1c 100755 --- a/server/.vscode/tasks.json +++ b/server/.vscode/tasks.json @@ -1,9 +1,15 @@ { - "version": "0.1.0", + "version": "2.0.0", "command": "npm", - "isShellCommand": true, - "showOutput": "silent", "args": ["run", "watch"], - "isWatching": true, - "problemMatcher": "$tsc-watch" + "isBackground": true, + "problemMatcher": "$tsc-watch", + "presentation": { + "echo": true, + "reveal": "silent", + "focus": false, + "panel": "shared" + }, + "type": "shell" + } \ No newline at end of file diff --git a/server/package.json b/server/package.json index f3bec40..45c9b95 100755 --- a/server/package.json +++ b/server/package.json @@ -1,7 +1,7 @@ { "name": "composer-support-server", "description": "HyperledgerComposer server", - "version": "0.14.2", + "version": "0.15.0", "author": "Hyperledger Composer", "publisher": "HyperledgerComposer", "license": "Apache-2.0", diff --git a/server/src/server.ts b/server/src/server.ts index 69e1a1d..7ab6e37 100755 --- a/server/src/server.ts +++ b/server/src/server.ts @@ -42,6 +42,7 @@ let documents: TextDocuments = new TextDocuments(); // for open, change and close text document events documents.listen(connection); + // After the server has started the client sends an initialize request. The server receives // in the passed params the rootPath of the workspace plus the client capabilities. let workspaceRoot: string; @@ -70,8 +71,8 @@ connection.onInitialize((params): InitializeResult => { // The content of a text document has changed. This event is emitted // when the text document first opened or when its content has changed. -documents.onDidChangeContent((change) => { - validateTextDocument(change.document); +documents.onDidChangeContent((doc) => { + validateTextDocument(doc.document); }); // The settings interface describes the server relevant settings part @@ -278,16 +279,34 @@ function validateTextDocument(textDocument: TextDocument): void { */ function validateCtoModelFile(textDocument: TextDocument): void { try { + //hack to workaround circularly dependent documents + let currentModels=[]; + documents.all().forEach( (textDocument: TextDocument) => { + if (textDocument.languageId == "composer") { + let model = new ModelFile(modelManager, textDocument.getText(), textDocument.uri); + if (! modelManager.getModelFile(model.getNamespace())) { + //only add if not existing + currentModels.push(model); + } + } + }); + //connection.console.log("SERVER addModelFiles: " + currentModels.length); //debug + modelManager.addModelFiles(currentModels); + + let modelContents = textDocument.getText(); //*.cto file //add or update, depending on existance. ModelFile and modelManager calls may throw an exception let model = new ModelFile(modelManager, modelContents, textDocument.uri); if (modelManager.getModelFile(model.getNamespace())) { + //connection.console.log("SERVER update model: " + model.getNamespace()); //debug modelManager.updateModelFile(model); } else { + //connection.console.log("SERVER add model: " + model.getNamespace()); //debug modelManager.addModelFile(model); } sendDiagnosticSuccess(textDocument.uri); //all OK } catch (err) { + //connection.console.log("SERVER model err: " + err.toString()); //debug buildAndSendDiagnosticFromException(err, textDocument.lineCount, textDocument.uri); } }