cm-mode-kevscript
Advanced tools
Comparing version 1.0.0 to 1.0.2
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("CodeMirror"),require("KevoreeRegistryClient"));else if("function"==typeof define&&define.amd)define(["CodeMirror","KevoreeRegistryClient"],t);else{var n="object"==typeof exports?t(require("CodeMirror"),require("KevoreeRegistryClient")):t(e.CodeMirror,e.KevoreeRegistryClient);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./src/hint/hint.js")}({"./src/hint/hint.js":function(e,t,n){function r(e,t){return Object.keys(t).forEach(function(n){e=e.replace(new RegExp("{{"+n+"}}","g"),t[n])}),e}function a(e){return"org.kevoree.NodeType"===e.metaClassName()?"node":"org.kevoree.GroupType"===e.metaClassName()?"group":"org.kevoree.ChannelType"===e.metaClassName()?"channel":"org.kevoree.ComponentType"===e.metaClassName()?"component":void 0}function i(e,t,n){function i(){return n.getModel()}function f(){return i().nodes.array.concat(i().groups.array).concat(i().hubs.array)}function p(e){return f().find(function(t){return t.name===e})}function u(e){return e.class.startsWith("org.kevoree.ComponentType")?"component":e.class.startsWith("org.kevoree.ChannelType")?"channel":e.class.startsWith("org.kevoree.GroupType")?"group":e.class.startsWith("org.kevoree.NodeType")?"node":"tdef"}function m(){e.doc.replaceSelection(" ")}var d,l=e.getCursor(),y=e.getTokenAt(l),h=y.string,x=y.start,v=y.end,g=[];if("typedef"===y.type||"typedef"===y.state.state){if("namespace"===y.type)return d=h,h=d.trim(),x+=d.length-h.length,s.namespace.all().then(function(e){t({list:e.filter(function(e){return 0===h.trim().length||e.name.startsWith(h)}).sort(function(e,t){return e.name.localeCompare(t.name)}).map(function(e){return{type:"namespace",typeText:"n",text:e.name,bufferText:e.name+"."}}).map(function(e){return{text:e.bufferText,className:"cm-kevs-hint-elem",render:function(t){var n=r(c,e);t.append(n)}}}),from:o.Pos(l.line,x),to:o.Pos(l.line,v)})});x="."===h?y.end:y.start;var b="."===h?y.state.namespace:"kevoree";return s.tdef.getLatestsByNamespace(b).then(function(e){t({list:e.filter(function(e){return"."===h||0===h.trim().length||e.name.startsWith(h)}).sort(function(e,t){return e.name.localeCompare(t.name)}).map(function(e){var t=JSON.parse(e.model),n=u(t);return{type:n,typeText:n.substr(0,1),text:e.name,bufferText:e.name,desc:"latest version: "+e.version,from:o.Pos(l.line,x)}}).map(function(e){return{text:e.bufferText,className:"cm-kevs-hint-elem",render:function(t){var n=r(c,e);t.append(n)},from:e.from,to:e.to}}),from:o.Pos(l.line,y.end),to:o.Pos(l.line,y.end)})})}switch(y.state.state){case"start":"identifier"===y.type?"attach"===y.state.stmt||"detach"===y.state.stmt?g=i().groups.array.map(function(e){return{type:"group",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}).filter(function(e){return 0===h.length||e.text.startsWith(h)}):"bind"!==y.state.stmt&&"unbind"!==y.state.stmt||(g=i().hubs.array.map(function(e){return{type:"channel",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}).filter(function(e){return 0===h.length||e.text.startsWith(h)})):(d=h,h=d.trim(),x+=d.length-h.length,g=[{text:"add",desc:"create an instance"},{text:"remove",desc:"remove an instance"},{text:"set",desc:"change a param value"},{text:"bind",desc:"connect a port to a chan"},{text:"unbind",desc:"disconnect a port from a chan"},{text:"attach",desc:"connect a node to a group"},{text:"detach",desc:"disconnect a node from a group"},{text:"network",desc:"define a node network value"},{text:"start",desc:"start an instance"},{text:"stop",desc:"stop an instance"},{text:"move",desc:"move an instance to another node"}].map(function(e){return e.type="stmt",e.bufferText=e.text+" ",e}).filter(function(e){return 0===h.length||e.text.startsWith(h)}).sort(function(e,t){return e.text.localeCompare(t.text)}));break;case"addStmt":case"bindStmt":case"unbindStmt":"add"===h||"set"===h||"bind"===h||"unbind"===h?m():(d=h,h=d.trim(),x+=d.length-h.length,g=i().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)})));break;case"setStmt":"set"===h?m():3===y.state.instancePath.length?g=i().nodes.array.map(function(e){return{type:"node",text:e.name,bufferText:e.name+" = ''",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}).filter(function(e){return e.text.startsWith(h)}):2===y.state.instancePath.length?(d=p(y.state.instancePath[0]))&&(g=d.typeDefinition.dictionaryType.attributes.array.map(function(e){return{type:"attr",text:e.name+(e.fragmentDependant?"/<node>":""),bufferText:e.fragmentDependant?e.name+"/":e.name,desc:(e.optional?"optional ":"")+'"'+e.datatype.toString().toLowerCase()+'"'}}),"org.kevoree.ContainerNode"===d.metaClassName()&&(g=g.concat(d.components.array.map(function(e){return{type:"component",text:e.name,bufferText:e.name+".",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}))),g=g.filter(function(e){return e.text.startsWith(h)})):(d=h,h=d.trim(),x+=d.length-h.length,g=f().map(function(e){return{type:a(e.typeDefinition),text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)})));break;case"attachStmt":case"detachStmt":"attach"===h||"detach"===h?m():(d=h,h=d.trim(),x+=d.length-h.length,g=i().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)})));break;case"network":"network"===h?m():(d=h,h=d.trim(),x+=d.length-h.length,g=i().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)})));break;case"networkStmt":h="",x+=1,g=i().nodes.array.map(function(e){return{type:"node",text:e.name,bufferText:e.name+".",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}});break;case"tdefversion":"/"===h&&(h="",x=y.end,v+=1),g=[{type:"version",text:"LATEST",desc:"the latest available version"}].concat(i().select("packages["+(y.state.namespace||"kevoree")+"]/typeDefinitions[name="+y.state.typedef+"]").array.map(function(e){return{type:"version",text:e.version,desc:e.eContainer().name+"."+e.name}})),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)}));break;case"duversion":return"/"===h&&(h="",x=y.end,v+=1),s.du.getLatests(y.state.namespace||"kevoree",y.state.typedef,y.state.version).then(function(e){return e.length>0?[{type:"version",bufferText:"{"+e.map(function(e,t,n){var r=" "+e.platform+": '"+e.version+"'";return t<n-1&&(r+=" "),r}).join(", ")+"}",text:e.map(function(e,t,n){var r=e.platform+"="+e.version;return t<n-1&&(r+=" "),r}).join(", "),desc:"current latest deploy units"}]:[]}).catch(function(){return[]}).then(function(e){return s.du.getReleases(y.state.namespace||"kevoree",y.state.typedef,y.state.version).then(function(t){return t.length>0?e.concat([{type:"version",bufferText:"{"+t.map(function(e,t,n){var r=" "+e.platform+": '"+e.version+"'";return t<n-1&&(r+=" "),r}).join(", ")+"}",text:t.map(function(e,t,n){var r=e.platform+"="+e.version;return t<n-1&&(r+=" "),r}).join(", "),desc:"current latest deploy units (stable)"}]):e}).catch(function(){return e})}).then(function(e){return e.concat([{type:"version",text:"LATEST",desc:"always get latest deploy units"},{type:"version",text:"RELEASE",desc:"always get latest deploy units (stable)"}])}).then(function(e){t({list:e.filter(function(e){return e.text.startsWith(h)}).map(function(e){return e.typeText=e.type.substr(0,1),{text:e.bufferText,className:"cm-kevs-hint-elem",render:function(t){var n=r(c,e);t.append(n)}}}),from:o.Pos(l.line,x),to:o.Pos(l.line,v)})});case"instancepath":case"instancepathInstancepath":case"namelistInstancepath":if("set"===y.state.stmt){var D=p(y.state.instancePath[0]);D&&(1===y.state.instancePath.length?(g=D.typeDefinition.dictionaryType.attributes.array.map(function(e){return{type:"attr",text:e.name+(e.fragmentDependant?"/<node>":""),bufferText:e.name+(e.fragmentDependant?"/":" = ''"),desc:(e.optional?"optional ":"")+'"'+e.datatype.toString().toLowerCase()+'"',from:o.Pos(l.line,y.end)}}),D.components&&(g=g.concat(D.components.array.map(function(e){return{type:"component",text:e.name,bufferText:e.name+".",desc:e.typeDefinition.name+"/"+e.typeDefinition.version,from:o.Pos(l.line,y.end)}})))):2===y.state.instancePath.length&&("delimiter"===y.type&&"/"===y.string&&(h="",x+=1,D.subNodes&&(g=D.subNodes.array.map(function(e){return{type:"node",text:e.name,bufferText:e.name+" = ''",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}))),D.components&&(d=D.findComponentsByID(y.state.instancePath[1]))&&(g=d.typeDefinition.dictionaryType.attributes.array.map(function(e){return{type:"attr",text:e.name,bufferText:e.name+" = ''",desc:(e.optional?"optional ":"")+'"'+e.datatype.toString().toLowerCase()+'"',from:o.Pos(l.line,y.end)}}))))}else if("bind"===y.state.stmt||"unbind"===y.state.stmt){if(0===y.state.instancePath.length)g=i().hubs.array.map(function(e){return{type:"channel",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,from:o.Pos(l.line,y.end)}});else if(1===y.state.instancePath.length)"delimiter"===y.type&&"."===y.string?(d=i().findNodesByID(y.state.instancePath[0]))&&(g=d.components.array.map(function(e){return{type:"component",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+".",from:o.Pos(l.line,y.end)}})):(g=i().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)})));else if(2===y.state.instancePath.length&&"delimiter"===y.type&&"."===y.string&&(d=i().findNodesByID(y.state.instancePath[0]))){var T=d.findComponentsByID(y.state.instancePath[1]);T&&(g=T.typeDefinition.provided.array.map(function(e){return{type:"input",text:e.name,from:o.Pos(l.line,y.end)}}).concat(T.typeDefinition.required.array.map(function(e){return{type:"output",text:e.name,from:o.Pos(l.line,y.end)}})))}}else"attach"!==y.state.stmt&&"detach"!==y.state.stmt||(0===y.state.instancePath.length&&"wildcard"!==y.type?g=i().groups.array.map(function(e){return{type:"group",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,from:o.Pos(l.line,y.end)}}):1===y.state.instancePath.length&&("delimiter"===y.type&&"."===y.string?(d=i().findNodesByID(y.state.instancePath[0]))&&(g=d.components.array.map(function(e){return{type:"component",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+".",from:o.Pos(l.line,y.end)}})):(" "===h&&(h="",x+=1),g=i().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}),h.length>0&&(g=g.filter(function(e){return e.text.startsWith(h)})))));break;default:g=[]}return t({list:g.map(function(e){return e.bufferText=e.bufferText||e.text,e.typeText=function(){return e.type.substr(0,1)},e}).map(function(e){return{text:e.bufferText,className:"cm-kevs-hint-elem",render:function(t){var n=r(c,e);t.append(n)},from:e.from,to:e.to}}),from:o.Pos(l.line,x),to:o.Pos(l.line,v)})}var o=n(0),s=n(1),c='<div class="hint-primary"><div class="hint-anchor {{type}}">{{typeText}}</div><div class="hint-text">{{text}}</div></div><div class="hint-secondary">{{desc}}</div>';o.registerHelper("hint","kevscript",i)},0:function(t,n){t.exports=e},1:function(e,n){e.exports=t}})}); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("CodeMirror"),require("KevoreeRegistryClient"));else if("function"==typeof define&&define.amd)define(["CodeMirror","KevoreeRegistryClient"],t);else{var n="object"==typeof exports?t(require("CodeMirror"),require("KevoreeRegistryClient")):t(e.CodeMirror,e.KevoreeRegistryClient);for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(this,function(e,t){return function(e){function t(r){if(n[r])return n[r].exports;var a=n[r]={i:r,l:!1,exports:{}};return e[r].call(a.exports,a,a.exports,t),a.l=!0,a.exports}var n={};return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s="./src/hint/hint.js")}({"./src/hint/hint.js":function(e,t,n){function r(e,t){return Object.keys(t).forEach(function(n){e=e.replace(new RegExp("{{"+n+"}}","g"),t[n])}),e}function a(e){return function(t){t.innerHTML=r(f,e)}}function i(e){return"org.kevoree.NodeType"===e.metaClassName()?"node":"org.kevoree.GroupType"===e.metaClassName()?"group":"org.kevoree.ChannelType"===e.metaClassName()?"channel":"org.kevoree.ComponentType"===e.metaClassName()?"component":void 0}function o(e,t,n){function r(){return n.getModel()}function o(){return r().nodes.array.concat(r().groups.array).concat(r().hubs.array)}function f(e){return o().find(function(t){return t.name===e})}function u(e){return e.class.startsWith("org.kevoree.ComponentType")?"component":e.class.startsWith("org.kevoree.ChannelType")?"channel":e.class.startsWith("org.kevoree.GroupType")?"group":e.class.startsWith("org.kevoree.NodeType")?"node":"tdef"}function p(){e.doc.replaceSelection(" ")}var m,d=e.getCursor(),l=e.getTokenAt(d),y=l.string,h=l.start,x=l.end,v=[];if("typedef"===l.type||"typedef"===l.state.state){if("namespace"===l.type)return m=y,y=m.trim(),h+=m.length-y.length,c.namespace.all().then(function(e){t({list:e.filter(function(e){return 0===y.trim().length||e.name.startsWith(y)}).sort(function(e,t){return e.name.localeCompare(t.name)}).map(function(e){return{type:"namespace",typeText:"n",text:e.name,bufferText:e.name+"."}}).map(function(e){return{text:e.bufferText,className:"cm-kevs-hint-elem",render:a(e)}}),from:s.Pos(d.line,h),to:s.Pos(d.line,x)})});h="."===y?l.end:l.start;var g="."===y?l.state.namespace:"kevoree";return c.tdef.getLatestsByNamespace(g).then(function(e){t({list:e.filter(function(e){return"."===y||0===y.trim().length||e.name.startsWith(y)}).sort(function(e,t){return e.name.localeCompare(t.name)}).map(function(e){var t=JSON.parse(e.model),n=u(t);return{type:n,typeText:n.substr(0,1),text:e.name,bufferText:e.name,desc:"latest version: "+e.version,from:s.Pos(d.line,h)}}).map(function(e){return{text:e.bufferText,className:"cm-kevs-hint-elem",render:a(e),from:e.from,to:e.to}}),from:s.Pos(d.line,l.end),to:s.Pos(d.line,l.end)})})}switch(l.state.state){case"start":"identifier"===l.type?"attach"===l.state.stmt||"detach"===l.state.stmt?v=r().groups.array.map(function(e){return{type:"group",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}).filter(function(e){return 0===y.length||e.text.startsWith(y)}):"bind"!==l.state.stmt&&"unbind"!==l.state.stmt||(v=r().hubs.array.map(function(e){return{type:"channel",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}).filter(function(e){return 0===y.length||e.text.startsWith(y)})):(m=y,y=m.trim(),h+=m.length-y.length,v=[{text:"add",desc:"create an instance"},{text:"remove",desc:"remove an instance"},{text:"set",desc:"change a param value"},{text:"bind",desc:"connect a port to a chan"},{text:"unbind",desc:"disconnect a port from a chan"},{text:"attach",desc:"connect a node to a group"},{text:"detach",desc:"disconnect a node from a group"},{text:"network",desc:"define a node network value"},{text:"start",desc:"start an instance"},{text:"stop",desc:"stop an instance"},{text:"move",desc:"move an instance to another node"}].map(function(e){return e.type="stmt",e.bufferText=e.text+" ",e}).filter(function(e){return 0===y.length||e.text.startsWith(y)}).sort(function(e,t){return e.text.localeCompare(t.text)}));break;case"addStmt":case"bindStmt":case"unbindStmt":"add"===y||"set"===y||"bind"===y||"unbind"===y?p():(m=y,y=m.trim(),h+=m.length-y.length,v=r().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)})));break;case"setStmt":"set"===y?p():3===l.state.instancePath.length?v=r().nodes.array.map(function(e){return{type:"node",text:e.name,bufferText:e.name+" = ''",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}).filter(function(e){return e.text.startsWith(y)}):2===l.state.instancePath.length?(m=f(l.state.instancePath[0]))&&(v=m.typeDefinition.dictionaryType.attributes.array.map(function(e){return{type:"attr",text:e.name+(e.fragmentDependant?"/<node>":""),bufferText:e.fragmentDependant?e.name+"/":e.name,desc:(e.optional?"optional ":"")+'"'+e.datatype.toString().toLowerCase()+'"'}}),"org.kevoree.ContainerNode"===m.metaClassName()&&(v=v.concat(m.components.array.map(function(e){return{type:"component",text:e.name,bufferText:e.name+".",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}))),v=v.filter(function(e){return e.text.startsWith(y)})):(m=y,y=m.trim(),h+=m.length-y.length,v=o().map(function(e){return{type:i(e.typeDefinition),text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)})));break;case"attachStmt":case"detachStmt":"attach"===y||"detach"===y?p():(m=y,y=m.trim(),h+=m.length-y.length,v=r().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)})));break;case"network":"network"===y?p():(m=y,y=m.trim(),h+=m.length-y.length,v=r().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)})));break;case"networkStmt":y="",h+=1,v=r().nodes.array.map(function(e){return{type:"node",text:e.name,bufferText:e.name+".",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}});break;case"tdefversion":"/"===y&&(y="",h=l.end,x+=1),v=[{type:"version",text:"LATEST",desc:"the latest available version"}].concat(r().select("packages["+(l.state.namespace||"kevoree")+"]/typeDefinitions[name="+l.state.typedef+"]").array.map(function(e){return{type:"version",text:e.version,desc:e.eContainer().name+"."+e.name}})),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)}));break;case"duversion":return"/"===y&&(y="",h=l.end,x+=1),c.du.getLatests(l.state.namespace||"kevoree",l.state.typedef,l.state.version).then(function(e){return e.length>0?[{type:"version",bufferText:"{"+e.map(function(e,t,n){var r=" "+e.platform+": '"+e.version+"'";return t<n-1&&(r+=" "),r}).join(", ")+"}",text:e.map(function(e,t,n){var r=e.platform+"="+e.version;return t<n-1&&(r+=" "),r}).join(", "),desc:"current latest deploy units"}]:[]}).catch(function(){return[]}).then(function(e){return c.du.getReleases(l.state.namespace||"kevoree",l.state.typedef,l.state.version).then(function(t){return t.length>0?e.concat([{type:"version",bufferText:"{"+t.map(function(e,t,n){var r=" "+e.platform+": '"+e.version+"'";return t<n-1&&(r+=" "),r}).join(", ")+"}",text:t.map(function(e,t,n){var r=e.platform+"="+e.version;return t<n-1&&(r+=" "),r}).join(", "),desc:"current latest deploy units (stable)"}]):e}).catch(function(){return e})}).then(function(e){return e.concat([{type:"version",text:"LATEST",desc:"always get latest deploy units"},{type:"version",text:"RELEASE",desc:"always get latest deploy units (stable)"}])}).then(function(e){t({list:e.filter(function(e){return e.text.startsWith(y)}).map(function(e){return e.typeText=e.type.substr(0,1),{text:e.bufferText,className:"cm-kevs-hint-elem",render:a(e)}}),from:s.Pos(d.line,h),to:s.Pos(d.line,x)})});case"instancepath":case"instancepathInstancepath":case"namelistInstancepath":if("set"===l.state.stmt){var b=f(l.state.instancePath[0]);b&&(1===l.state.instancePath.length?(v=b.typeDefinition.dictionaryType.attributes.array.map(function(e){return{type:"attr",text:e.name+(e.fragmentDependant?"/<node>":""),bufferText:e.name+(e.fragmentDependant?"/":" = ''"),desc:(e.optional?"optional ":"")+'"'+e.datatype.toString().toLowerCase()+'"',from:s.Pos(d.line,l.end)}}),b.components&&(v=v.concat(b.components.array.map(function(e){return{type:"component",text:e.name,bufferText:e.name+".",desc:e.typeDefinition.name+"/"+e.typeDefinition.version,from:s.Pos(d.line,l.end)}})))):2===l.state.instancePath.length&&("delimiter"===l.type&&"/"===l.string&&(y="",h+=1,b.subNodes&&(v=b.subNodes.array.map(function(e){return{type:"node",text:e.name,bufferText:e.name+" = ''",desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}))),b.components&&(m=b.findComponentsByID(l.state.instancePath[1]))&&(v=m.typeDefinition.dictionaryType.attributes.array.map(function(e){return{type:"attr",text:e.name,bufferText:e.name+" = ''",desc:(e.optional?"optional ":"")+'"'+e.datatype.toString().toLowerCase()+'"',from:s.Pos(d.line,l.end)}}))))}else if("bind"===l.state.stmt||"unbind"===l.state.stmt){if(0===l.state.instancePath.length)v=r().hubs.array.map(function(e){return{type:"channel",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,from:s.Pos(d.line,l.end)}});else if(1===l.state.instancePath.length)"delimiter"===l.type&&"."===l.string?(m=r().findNodesByID(l.state.instancePath[0]))&&(v=m.components.array.map(function(e){return{type:"component",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+".",from:s.Pos(d.line,l.end)}})):(v=r().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+"."}}),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)})));else if(2===l.state.instancePath.length&&"delimiter"===l.type&&"."===l.string&&(m=r().findNodesByID(l.state.instancePath[0]))){var D=m.findComponentsByID(l.state.instancePath[1]);D&&(v=D.typeDefinition.provided.array.map(function(e){return{type:"input",text:e.name,from:s.Pos(d.line,l.end)}}).concat(D.typeDefinition.required.array.map(function(e){return{type:"output",text:e.name,from:s.Pos(d.line,l.end)}})))}}else"attach"!==l.state.stmt&&"detach"!==l.state.stmt||(0===l.state.instancePath.length&&"wildcard"!==l.type?v=r().groups.array.map(function(e){return{type:"group",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,from:s.Pos(d.line,l.end)}}):1===l.state.instancePath.length&&("delimiter"===l.type&&"."===l.string?(m=r().findNodesByID(l.state.instancePath[0]))&&(v=m.components.array.map(function(e){return{type:"component",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version,bufferText:e.name+".",from:s.Pos(d.line,l.end)}})):(" "===y&&(y="",h+=1),v=r().nodes.array.map(function(e){return{type:"node",text:e.name,desc:e.typeDefinition.name+"/"+e.typeDefinition.version}}),y.length>0&&(v=v.filter(function(e){return e.text.startsWith(y)})))));break;default:v=[]}return t({list:v.map(function(e){return e.bufferText=e.bufferText||e.text,e.typeText=function(){return e.type.substr(0,1)},e}).map(function(e){return{text:e.bufferText,className:"cm-kevs-hint-elem",render:a(e),from:e.from,to:e.to}}),from:s.Pos(d.line,h),to:s.Pos(d.line,x)})}var s=n(0),c=n(1),f='<div class="hint-primary"><div class="hint-anchor {{type}}">{{typeText}}</div><div class="hint-text">{{text}}</div></div><div class="hint-secondary">{{desc}}</div>';s.registerHelper("hint","kevscript",o)},0:function(t,n){t.exports=e},1:function(e,n){e.exports=t}})}); |
{ | ||
"name": "cm-mode-kevscript", | ||
"version": "1.0.0", | ||
"version": "1.0.2", | ||
"description": "KevScript mode for CodeMirror", | ||
@@ -5,0 +5,0 @@ "main": "src/mode/kevscript.js", |
@@ -5,2 +5,3 @@ var CodeMirror = require('codemirror'); | ||
var HINT_TPL = '<div class="hint-primary"><div class="hint-anchor {{type}}">{{typeText}}</div><div class="hint-text">{{text}}</div></div><div class="hint-secondary">{{desc}}</div>'; | ||
function renderTpl(tpl, data) { | ||
@@ -12,2 +13,9 @@ Object.keys(data).forEach(function (key) { | ||
} | ||
function renderHtml(data) { | ||
return function (elem) { | ||
elem.innerHTML = renderTpl(HINT_TPL, data); | ||
}; | ||
} | ||
function getTypeDefinitionType(tdef) { | ||
@@ -111,6 +119,3 @@ if (tdef.metaClassName() === 'org.kevoree.NodeType') { | ||
className: 'cm-kevs-hint-elem', | ||
render: function (elem) { | ||
var renderedTpl = renderTpl(HINT_TPL, data); | ||
elem.append(renderedTpl); | ||
} | ||
render: renderHtml(data) | ||
}; | ||
@@ -155,6 +160,3 @@ }), | ||
className: 'cm-kevs-hint-elem', | ||
render: function (elem) { | ||
var renderedTpl = renderTpl(HINT_TPL, data); | ||
elem.append(renderedTpl); | ||
}, | ||
render: renderHtml(data), | ||
from: data.from, | ||
@@ -519,6 +521,3 @@ to: data.to | ||
className: 'cm-kevs-hint-elem', | ||
render: function (elem) { | ||
var renderedTpl = renderTpl(HINT_TPL, item); | ||
elem.append(renderedTpl); | ||
} | ||
render: renderHtml(item) | ||
}; | ||
@@ -743,6 +742,3 @@ }), | ||
className: 'cm-kevs-hint-elem', | ||
render: function (elem) { | ||
var renderedTpl = renderTpl(HINT_TPL, data); | ||
elem.append(renderedTpl); | ||
}, | ||
render: renderHtml(data), | ||
from: data.from, | ||
@@ -749,0 +745,0 @@ to: data.to |
110446
1949