You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2021/04/27 15:12:46 UTC
[brooklyn-ui] 04/15: fix dsl detection edge case debug message for
numbers and boolean values
This is an automated email from the ASF dual-hosted git repository.
heneveld pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/brooklyn-ui.git
commit 8a0ad3f5939b029c1cbaa1d690ce8a7f6d6eae07
Author: Alex Heneveld <al...@cloudsoftcorp.com>
AuthorDate: Wed Apr 21 15:28:59 2021 +0100
fix dsl detection edge case debug message for numbers and boolean values
---
.../app/components/providers/blueprint-service.provider.js | 2 +-
.../app/components/util/model/dsl.model.js | 13 ++++++++++---
2 files changed, 11 insertions(+), 4 deletions(-)
diff --git a/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js b/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
index 7f78da1..1639577 100644
--- a/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
+++ b/ui-modules/blueprint-composer/app/components/providers/blueprint-service.provider.js
@@ -485,7 +485,7 @@ function BlueprintService($log, $q, $sce, paletteApi, iconGenerator, dslService)
resolve(parsed);
}
} catch (ex) {
- $log.debug(ex);
+ $log.debug("Cannot detect whether this is a DSL expression; assuming not", ex);
reject(ex, input);
}
});
diff --git a/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js b/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js
index 7b78a0a..323d73d 100644
--- a/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js
+++ b/ui-modules/blueprint-composer/app/components/util/model/dsl.model.js
@@ -37,6 +37,7 @@ export const KIND = {
ENTITY : {family: FAMILY.REFERENCE, name: 'entity object'},
STRING : {family: FAMILY.CONSTANT, name: 'constant string'},
NUMBER : {family: FAMILY.CONSTANT, name: 'constant number'},
+ OTHER : {family: FAMILY.CONSTANT, name: 'constant other'},
PORT : {family: FAMILY.CONSTANT, name: 'constant port'},
};
@@ -656,10 +657,16 @@ export class DslParser {
if (this.s instanceof String || typeof this.s === 'string') {
return this.parseString(this.s.toString().trim(), entity, entityResolver);
}
- // else ... TODO support JSON objects (for YAML syntax)
- else {
- throw new DslError("Unable to parse: " + typeof this.s);
+ // NUMBER and OTHER kinds are in the CONSTANT family which means they aren't DSL expressions
+ // (API here could be improved!)
+ if (typeof this.s === 'number') {
+ return new Dsl(KIND.NUMBER, this.s)
+ }
+ if (typeof this.s === 'boolean') {
+ return new Dsl(KIND.OTHER, this.s)
}
+ // TODO support JSON objects (for YAML syntax)
+ throw new DslError("Unable to parse: " + typeof this.s);
}
/**