Skip to content
This repository has been archived by the owner on Mar 8, 2020. It is now read-only.

Commit

Permalink
Fix #2385 … (#50)
Browse files Browse the repository at this point in the history
* Update to composer-common 0.14.2

Signed-off-by: m-g-k <[email protected]>

* * Fix #2385
* Update composer-common
* Fix circular-dependency models

Signed-off-by: m-g-k <[email protected]>
  • Loading branch information
m-g-k authored and mbwhite committed Nov 14, 2017
1 parent 792f202 commit b63c98f
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 29 deletions.
23 changes: 14 additions & 9 deletions client/.vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
2 changes: 1 addition & 1 deletion client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
14 changes: 7 additions & 7 deletions client/snippets/composer-acl.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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"
Expand Down
8 changes: 4 additions & 4 deletions client/snippets/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@
"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"
},
"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"
Expand Down
10 changes: 10 additions & 0 deletions composer.code-workspace
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"folders": [
{
"path": "client"
},
{
"path": "server"
}
]
}
16 changes: 11 additions & 5 deletions server/.vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -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"

}
2 changes: 1 addition & 1 deletion server/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
23 changes: 21 additions & 2 deletions server/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Expand Down

0 comments on commit b63c98f

Please sign in to comment.