brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [27/27] brooklyn-ui git commit: apply code review to ui #7 codemirror yaml-parse and completion
Date Thu, 18 Feb 2016 10:37:19 GMT
apply code review to ui #7 codemirror yaml-parse and completion

and some styling tweaks so highlight is correct


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/b9ba6544
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/b9ba6544
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/b9ba6544

Branch: refs/heads/master
Commit: b9ba6544dd0a4a8fec6519ab6b3145f7956ad578
Parents: e1646d7
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Thu Feb 18 10:36:23 2016 +0000
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Thu Feb 18 10:36:23 2016 +0000

----------------------------------------------------------------------
 .../webapp/assets/css/codemirror-brooklyn.css   | 21 ++++++++++++++------
 .../brooklyn-yaml-completion-proposals.js       | 16 ++++++++++-----
 .../js/util/code-complete/js-yaml-parser.js     |  5 +++++
 src/main/webapp/index.html                      |  2 +-
 4 files changed, 32 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/assets/css/codemirror-brooklyn.css
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/css/codemirror-brooklyn.css b/src/main/webapp/assets/css/codemirror-brooklyn.css
index b1b2c54..e751df3 100644
--- a/src/main/webapp/assets/css/codemirror-brooklyn.css
+++ b/src/main/webapp/assets/css/codemirror-brooklyn.css
@@ -28,16 +28,25 @@
 .CodeMirror .CodeMirror-gutter.CodeMirror-linenumbers {
 }
 
+ul.CodeMirror-hints {
+  overflow: scroll;
+  width: 320px;
+}
 li.CodeMirror-hint {
   max-width: inherit;
   overflow: visible;
+  /* nice trick: table has stretchability based on content (line inline) but otherwise acts
like div 
+   * (following content is not on same line). this causes wide (overflow) content to get
the right background when active;
+   * otherwise with div the content is shown but background only applies to non-overflow
part. */
+  display: table;
+  /* but width of table defaults to ignoring padding so we have to fix it to be parent's
less padding */ 
+  min-width: 312px;
 }
-ul.CodeMirror-hints {
-  overflow: scroll;
-  max-width: 30em;
-}
-
 .CodeMirror-hints .CodeMirror-hint.summary {
   font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
   font-style: italic;
-}
\ No newline at end of file
+}
+li.CodeMirror-hint-active {
+  /* override show-hint to have roughly brooklyn colors instead of blue */
+  background: #549e2b;
+}

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
index 3dfecd7..e183411 100644
--- a/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
+++ b/src/main/webapp/assets/js/util/code-complete/brooklyn-yaml-completion-proposals.js
@@ -56,14 +56,20 @@ define([
         
         if (n.result === null) {
             n.type = 'null';
-        } else if (typeof n.result === 'object') {
+        } else if (n.kind == 'sequence') {
+            if (typeof n.result.length === 'undefined') {
+                console.log("WARN: mismatch expected list but had no length", n);
+            }
+            n.type = 'list';
+        } else if (n.kind == 'mapping') {
             if (typeof n.result.length !== 'undefined') {
-                // ^^^ messy way to check is parent a list
-                n.type = 'list';
-            } else {
-                n.type = 'map';
+                console.log("WARN: mismatch expected map but had length", n);
             }
+            n.type = 'map';
         } else {
+            if (n.kind != 'scalar') {
+                console.log("WARN: mismatch expected scalar/primitive", n);
+            }
             n.type = 'primitive';
         }
         

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
----------------------------------------------------------------------
diff --git a/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js b/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
index 98092f0..b95ebe0 100644
--- a/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
+++ b/src/main/webapp/assets/js/util/code-complete/js-yaml-parser.js
@@ -18,8 +18,13 @@ define([
     }
 
     function closeYamlNode(node, state) {
+        // character offset where this block ends, i.e. 1 means after the first character
+        // NB: if parser unsure may contain additional whitespace
         node.end = state.position;
+        // the actual parsed object
         node.result = state.result;
+        // {mapping,scalar,sequence}
+        node.kind = state.kind;
     }
 
     /** returns a YamlParseNode containing { doc, parent, children, start, end, result }
*/ 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/b9ba6544/src/main/webapp/index.html
----------------------------------------------------------------------
diff --git a/src/main/webapp/index.html b/src/main/webapp/index.html
index 4652377..b554599 100644
--- a/src/main/webapp/index.html
+++ b/src/main/webapp/index.html
@@ -27,10 +27,10 @@
     <title>Brooklyn JS REST client</title>
 
     <link rel="stylesheet" href="/assets/css/codemirror.css">
-    <link rel="stylesheet" href="/assets/css/codemirror-brooklyn.css">
     <link rel="stylesheet" href="/assets/js/libs/font-awesome/css/font-awesome.css">
     <link rel="stylesheet" href="/assets/css/show-hint.css">
     <link rel="stylesheet" href="/assets/css/styles.css">
+    <link rel="stylesheet" href="/assets/css/codemirror-brooklyn.css">
     <link rel="stylesheet" href="/assets/css/brooklyn.css">
     <style>
         body {


Mime
View raw message