Permalink
Browse files

Added initial format support to wrmldoc

  • Loading branch information...
1 parent 4a0f09d commit 67603f12553c8411009d02a6a79c8858fd48e696 @markmasse markmasse committed Mar 1, 2016
Showing with 3,149 additions and 1,325 deletions.
  1. +1 −2 core/src/main/java/org/wrml/model/rest/LinkTemplate.java
  2. +1 −1 core/src/main/java/org/wrml/runtime/format/SystemFormat.java
  3. +42 −1 core/src/main/java/org/wrml/runtime/format/application/vnd/wrml/wrmldoc/WrmldocDataBuilder.java
  4. +19 −2 core/src/main/java/org/wrml/runtime/format/text/html/WrmldocFormatter.java
  5. +1 −9 core/src/main/java/org/wrml/runtime/rest/DefaultApiLoader.java
  6. +10 −1 core/src/main/resources/org/wrml/runtime/format/text/html/index.html
  7. +11 −0 wrmldoc/ace/ace.js
  8. +1 −0 wrmldoc/ace/mode-html.js
  9. +1 −0 wrmldoc/ace/mode-java.js
  10. +1 −0 wrmldoc/ace/mode-json.js
  11. +1 −0 wrmldoc/ace/mode-xml.js
  12. +1 −0 wrmldoc/ace/mode-yaml.js
  13. +2 −1 wrmldoc/css/app/_variables.scss
  14. +72 −6 wrmldoc/css/app/apps/api.scss
  15. +40 −0 wrmldoc/css/app/apps/apiBrowser.scss
  16. +20 −5 wrmldoc/css/app/apps/header.scss
  17. +12 −2 wrmldoc/css/app/components/_base.scss
  18. +117 −30 wrmldoc/css/wrmldoc.css
  19. +1 −1 wrmldoc/css/wrmldoc.min.css
  20. +146 −16 wrmldoc/css/wrmldoc.scss
  21. +117 −30 wrmldoc/css/wrmldoc.tmp.css
  22. +56 −16 wrmldoc/js/app/Wrmldoc.coffee
  23. +225 −14 wrmldoc/js/app/apps/api/show/ApiShowView.coffee
  24. +62 −363 wrmldoc/js/app/apps/api/show/templates/api_show.eco
  25. +390 −0 wrmldoc/js/app/apps/api/show/templates/resource_show.eco
  26. +34 −0 wrmldoc/js/app/apps/apiBrowser/ApiBrowserApp.coffee
  27. +33 −0 wrmldoc/js/app/apps/apiBrowser/show/ApiBrowserShowView.coffee
  28. +63 −0 wrmldoc/js/app/apps/apiBrowser/show/templates/api_browser_show.eco
  29. +82 −0 wrmldoc/js/app/apps/header/show/HeaderShowView.coffee
  30. +62 −33 wrmldoc/js/app/apps/header/show/templates/header.eco
  31. +16 −38 wrmldoc/js/app/apps/model/show/ModelShowView.coffee
  32. +51 −58 wrmldoc/js/app/apps/model/show/templates/model_show.eco
  33. +20 −2 wrmldoc/js/app/apps/relation/show/RelationShowView.coffee
  34. +22 −26 wrmldoc/js/app/apps/relation/show/templates/relation_show.eco
  35. +15 −0 wrmldoc/js/app/apps/schema/show/SchemaShowView.coffee
  36. +115 −37 wrmldoc/js/app/apps/schema/show/templates/schema_show.eco
  37. +6 −0 wrmldoc/js/app/config/marionette/renderer.coffee
  38. +34 −34 wrmldoc/js/app/entities/_base/Model.coffee
  39. +970 −362 wrmldoc/js/wrmldoc.js
  40. +276 −235 wrmldoc/js/wrmldoc.min.js
@@ -61,7 +61,7 @@
* <p/>
* <p>
* A link ends with its pointy-end pointing to the end point. This end point is the resource that the referrer resource
- * was referencing with its link.
+ * is referencing with its link.
* </p>
*
* @see Api
@@ -70,7 +70,6 @@
* @see URI
* @see Link
* @see LinkRelation
- * @see org.wrml.runtime.schema.LinkSlot
* @see LinkValue
* @see Schema
* @see Document
@@ -82,7 +82,7 @@
vnd_wrml_swagger_api(new UniqueName("application/vnd.wrml.swagger.api+json"),
"The WRML System Format representing the \"application/vnd.wrml.swagger.api\" media type.",
URI.create("http://wrml.org"),
- URI.create(""), "txt"),
+ URI.create(""), "json"),
vnd_wrml_wrmldoc(new UniqueName("application/vnd.wrml.wrmldoc+json"),
"The WRML System Format representing the \"application/vnd.wrml.wrmldoc\" media type.",
@@ -25,9 +25,11 @@
package org.wrml.runtime.format.application.vnd.wrml.wrmldoc;
import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ArrayNode;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.commons.lang3.StringUtils;
import org.wrml.model.Model;
+import org.wrml.model.format.Format;
import org.wrml.model.rest.Api;
import org.wrml.model.rest.Document;
import org.wrml.model.rest.LinkRelation;
@@ -38,12 +40,16 @@
import org.wrml.model.schema.Schema;
import org.wrml.runtime.Context;
import org.wrml.runtime.Keys;
+import org.wrml.runtime.format.FormatLoader;
+import org.wrml.runtime.format.Formatter;
import org.wrml.runtime.format.application.vnd.wrml.complete.api.CompleteApiBuilder;
import org.wrml.runtime.format.application.vnd.wrml.complete.schema.CompleteSchemaBuilder;
+import org.wrml.runtime.rest.ApiLoader;
import org.wrml.runtime.schema.SchemaLoader;
import java.io.IOException;
import java.net.URI;
+import java.util.SortedSet;
public class WrmldocDataBuilder {
@@ -166,10 +172,44 @@ else if (model instanceof DocumentNotFoundErrorReport) {
final ObjectNode jstreeDataNode = _JstreeDataBuilder.buildJstreeData(objectMapper, context);
wrmlDataNode.put(PropertyName.jstree.name(), jstreeDataNode);
+ final ObjectNode formatsDataNode = buildFormatsData(objectMapper, model);
+ wrmlDataNode.put(PropertyName.formats.name(), formatsDataNode);
+
return wrmlDataNode;
}
+ public ObjectNode buildFormatsData(final ObjectMapper objectMapper, final Model model) {
+
+ final ObjectNode formatsNode = objectMapper.createObjectNode();
+
+ final Context context = model.getContext();
+ final FormatLoader formatLoader = context.getFormatLoader();
+ final SortedSet<URI> formatUris = formatLoader.getLoadedFormatUris();
+ final URI defaultFormatUri = formatLoader.getDefaultFormatUri();
+
+ for (final URI formatUri : formatUris) {
+ final Formatter formatter = formatLoader.getFormatter(formatUri);
+ if (formatter.isApplicableTo(model.getSchemaUri())) {
+
+ final Format format = formatLoader.loadFormat(formatUri);
+ final String mediaTypeString = String.valueOf(format.getMediaType());
+ final ObjectNode formatNode = objectMapper.createObjectNode();
+ formatsNode.put(mediaTypeString, formatNode);
+
+ formatNode.put("uri", String.valueOf(formatUri));
+ formatNode.put("title", format.getTitle());
+ formatNode.put("mediaType", mediaTypeString);
+ formatNode.put("fileExtension", format.getFileExtension());
+ formatNode.put("isDefault", formatUri.equals(defaultFormatUri));
+
+ }
+ }
+
+ return formatsNode;
+ }
+
+
public enum PropertyName {
docroot,
documentTitle,
@@ -179,7 +219,8 @@ else if (model instanceof DocumentNotFoundErrorReport) {
schema,
api,
relation,
- jstree;
+ jstree,
+ formats;
}
}
@@ -79,6 +79,8 @@ public void writeModel(final OutputStream out, final Model model, final ModelWri
try {
+ final MessageFormat pageTemplate = getTemplate(SHELL_PAGE_TEMPLATE_RESOURCE);
+
final ObjectNode wrmldocData = _WrmldocDataBuilder.buildWrmldocData(objectMapper, model);
final String documentTitle = wrmldocData.get(WrmldocDataBuilder.PropertyName.documentTitle.name()).asText();
@@ -100,8 +102,23 @@ public void writeModel(final OutputStream out, final Model model, final ModelWri
final JsonNode jstreeDataNode = wrmldocData.get(WrmldocDataBuilder.PropertyName.jstree.name());
final String jstreeValue = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(jstreeDataNode);
- final MessageFormat pageTemplate = getTemplate(SHELL_PAGE_TEMPLATE_RESOURCE);
- final String renderedPage = renderPage(pageTemplate, _WrmldocDataBuilder.getDocroot(), dotMin, documentTitle, documentIcon, schemaUriString, modelValue, schemaValue, apiValue, relationValue, jstreeValue);
+ final JsonNode formatsDataNode = wrmldocData.get(WrmldocDataBuilder.PropertyName.formats.name());
+ final String formatsValue = objectMapper.writerWithDefaultPrettyPrinter().writeValueAsString(formatsDataNode);
+
+ final String renderedPage =
+ renderPage(
+ pageTemplate,
+ _WrmldocDataBuilder.getDocroot(),
+ dotMin,
+ documentTitle,
+ documentIcon,
+ schemaUriString,
+ modelValue,
+ schemaValue,
+ apiValue,
+ relationValue,
+ jstreeValue,
+ formatsValue);
IOUtils.write(renderedPage, out);
@@ -518,18 +518,10 @@ private void loadSystemApis() {
apiBuilder.uri(apiUri).title(systemApi.getTitle()).description(systemApi.getDescription());
+ // NOTE: This call to docroot will automatically *Api* as a default response schema at the root
apiBuilder.docroot(systemApi.getDocrootId());
apiBuilder.resource(SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, systemApi.getPrimaryEndpointId(), systemApi.getDefaultSchemaInterface(), true);
- // TODO: Rework the SchemaNamespace
- /*
- * if (systemApi == SystemApi.Schema) { apiBuilder.link(SYSTEM_API_DOCROOT_FULL_PATH, SystemLinkRelation.self.getUri(), SYSTEM_API_DOCROOT_FULL_PATH,
- * SchemaNamespace.class); apiBuilder.link(SYSTEM_API_DOCROOT_FULL_PATH, SystemLinkRelation.element.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, Schema.class);
- * apiBuilder.link(SYSTEM_API_DOCROOT_FULL_PATH, SystemLinkRelation.child.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SchemaNamespace.class);
- * apiBuilder.link(SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SystemLinkRelation.element.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, Schema.class);
- * apiBuilder.link(SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SystemLinkRelation.child.getUri(), SYSTEM_API_PRIMARY_ENDPOINT_FULL_PATH, SchemaNamespace.class); }
- */
-
final Api api = apiBuilder.toApi();
loadApi(api);
}
@@ -55,7 +55,9 @@
"relation" : {8},
- "jstree" : {9}
+ "jstree" : {9},
+
+ "formats" : {10}
'}';
@@ -66,6 +68,13 @@
<script type="text/javascript" src="{0}jstree/jstree{1}.js"></script>
+ <script type="text/javascript" src="{0}ace/ace.js"></script>
+ <script type="text/javascript" src="{0}ace/mode-html.js"></script>
+ <script type="text/javascript" src="{0}ace/mode-java.js"></script>
+ <script type="text/javascript" src="{0}ace/mode-json.js"></script>
+ <script type="text/javascript" src="{0}ace/mode-xml.js"></script>
+ <script type="text/javascript" src="{0}ace/mode-yaml.js"></script>
+
<!-- Uses wrmldoc for app logic -->
<script type="text/javascript" src="{0}js/wrmldoc{1}.js"></script>
View
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
@@ -0,0 +1 @@
+ace.define("ace/mode/json_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text_highlight_rules").TextHighlightRules,s=function(){this.$rules={start:[{token:"variable",regex:'["](?:(?:\\\\.)|(?:[^"\\\\]))*?["]\\s*(?=:)'},{token:"string",regex:'"',next:"string"},{token:"constant.numeric",regex:"0[xX][0-9a-fA-F]+\\b"},{token:"constant.numeric",regex:"[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?\\b"},{token:"constant.language.boolean",regex:"(?:true|false)\\b"},{token:"invalid.illegal",regex:"['](?:(?:\\\\.)|(?:[^'\\\\]))*?[']"},{token:"invalid.illegal",regex:"\\/\\/.*$"},{token:"paren.lparen",regex:"[[({]"},{token:"paren.rparen",regex:"[\\])}]"},{token:"text",regex:"\\s+"}],string:[{token:"constant.language.escape",regex:/\\(?:x[0-9a-fA-F]{2}|u[0-9a-fA-F]{4}|["\\\/bfnrt])/},{token:"string",regex:'[^"\\\\]+'},{token:"string",regex:'"',next:"start"},{token:"string",regex:"",next:"start"}]}};r.inherits(s,i),t.JsonHighlightRules=s}),ace.define("ace/mode/matching_brace_outdent",["require","exports","module","ace/range"],function(e,t,n){"use strict";var r=e("../range").Range,i=function(){};(function(){this.checkOutdent=function(e,t){return/^\s+$/.test(e)?/^\s*\}/.test(t):!1},this.autoOutdent=function(e,t){var n=e.getLine(t),i=n.match(/^(\s*\})/);if(!i)return 0;var s=i[1].length,o=e.findMatchingBracket({row:t,column:s});if(!o||o.row==t)return 0;var u=this.$getIndent(e.getLine(o.row));e.replace(new r(t,0,t,s-1),u)},this.$getIndent=function(e){return e.match(/^\s*/)[0]}}).call(i.prototype),t.MatchingBraceOutdent=i}),ace.define("ace/mode/behaviour/cstyle",["require","exports","module","ace/lib/oop","ace/mode/behaviour","ace/token_iterator","ace/lib/lang"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../behaviour").Behaviour,s=e("../../token_iterator").TokenIterator,o=e("../../lib/lang"),u=["text","paren.rparen","punctuation.operator"],a=["text","paren.rparen","punctuation.operator","comment"],f,l={},c=function(e){var t=-1;e.multiSelect&&(t=e.selection.index,l.rangeCount!=e.multiSelect.rangeCount&&(l={rangeCount:e.multiSelect.rangeCount}));if(l[t])return f=l[t];f=l[t]={autoInsertedBrackets:0,autoInsertedRow:-1,autoInsertedLineEnd:"",maybeInsertedBrackets:0,maybeInsertedRow:-1,maybeInsertedLineStart:"",maybeInsertedLineEnd:""}},h=function(e,t,n,r){var i=e.end.row-e.start.row;return{text:n+t+r,selection:[0,e.start.column+1,i,e.end.column+(i?0:1)]}},p=function(){this.add("braces","insertion",function(e,t,n,r,i){var s=n.getCursorPosition(),u=r.doc.getLine(s.row);if(i=="{"){c(n);var a=n.getSelectionRange(),l=r.doc.getTextRange(a);if(l!==""&&l!=="{"&&n.getWrapBehavioursEnabled())return h(a,l,"{","}");if(p.isSaneInsertion(n,r))return/[\]\}\)]/.test(u[s.column])||n.inMultiSelectMode?(p.recordAutoInsert(n,r,"}"),{text:"{}",selection:[1,1]}):(p.recordMaybeInsert(n,r,"{"),{text:"{",selection:[1,1]})}else if(i=="}"){c(n);var d=u.substring(s.column,s.column+1);if(d=="}"){var v=r.$findOpeningBracket("}",{column:s.column+1,row:s.row});if(v!==null&&p.isAutoInsertedClosing(s,u,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}else{if(i=="\n"||i=="\r\n"){c(n);var m="";p.isMaybeInsertedClosing(s,u)&&(m=o.stringRepeat("}",f.maybeInsertedBrackets),p.clearMaybeInsertedClosing());var d=u.substring(s.column,s.column+1);if(d==="}"){var g=r.findMatchingBracket({row:s.row,column:s.column+1},"}");if(!g)return null;var y=this.$getIndent(r.getLine(g.row))}else{if(!m){p.clearMaybeInsertedClosing();return}var y=this.$getIndent(u)}var b=y+r.getTabString();return{text:"\n"+b+"\n"+y+m,selection:[1,b.length,1,b.length]}}p.clearMaybeInsertedClosing()}}),this.add("braces","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="{"){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.end.column,i.end.column+1);if(u=="}")return i.end.column++,i;f.maybeInsertedBrackets--}}),this.add("parens","insertion",function(e,t,n,r,i){if(i=="("){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return h(s,o,"(",")");if(p.isSaneInsertion(n,r))return p.recordAutoInsert(n,r,")"),{text:"()",selection:[1,1]}}else if(i==")"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f==")"){var l=r.$findOpeningBracket(")",{column:u.column+1,row:u.row});if(l!==null&&p.isAutoInsertedClosing(u,a,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("parens","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="("){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==")")return i.end.column++,i}}),this.add("brackets","insertion",function(e,t,n,r,i){if(i=="["){c(n);var s=n.getSelectionRange(),o=r.doc.getTextRange(s);if(o!==""&&n.getWrapBehavioursEnabled())return h(s,o,"[","]");if(p.isSaneInsertion(n,r))return p.recordAutoInsert(n,r,"]"),{text:"[]",selection:[1,1]}}else if(i=="]"){c(n);var u=n.getCursorPosition(),a=r.doc.getLine(u.row),f=a.substring(u.column,u.column+1);if(f=="]"){var l=r.$findOpeningBracket("]",{column:u.column+1,row:u.row});if(l!==null&&p.isAutoInsertedClosing(u,a,i))return p.popAutoInsertedClosing(),{text:"",selection:[1,1]}}}}),this.add("brackets","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&s=="["){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u=="]")return i.end.column++,i}}),this.add("string_dquotes","insertion",function(e,t,n,r,i){if(i=='"'||i=="'"){c(n);var s=i,o=n.getSelectionRange(),u=r.doc.getTextRange(o);if(u!==""&&u!=="'"&&u!='"'&&n.getWrapBehavioursEnabled())return h(o,u,s,s);if(!u){var a=n.getCursorPosition(),f=r.doc.getLine(a.row),l=f.substring(a.column-1,a.column),p=f.substring(a.column,a.column+1),d=r.getTokenAt(a.row,a.column),v=r.getTokenAt(a.row,a.column+1);if(l=="\\"&&d&&/escape/.test(d.type))return null;var m=d&&/string|escape/.test(d.type),g=!v||/string|escape/.test(v.type),y;if(p==s)y=m!==g;else{if(m&&!g)return null;if(m&&g)return null;var b=r.$mode.tokenRe;b.lastIndex=0;var w=b.test(l);b.lastIndex=0;var E=b.test(l);if(w||E)return null;if(p&&!/[\s;,.})\]\\]/.test(p))return null;y=!0}return{text:y?s+s:"",selection:[1,1]}}}}),this.add("string_dquotes","deletion",function(e,t,n,r,i){var s=r.doc.getTextRange(i);if(!i.isMultiLine()&&(s=='"'||s=="'")){c(n);var o=r.doc.getLine(i.start.row),u=o.substring(i.start.column+1,i.start.column+2);if(u==s)return i.end.column++,i}})};p.isSaneInsertion=function(e,t){var n=e.getCursorPosition(),r=new s(t,n.row,n.column);if(!this.$matchTokenType(r.getCurrentToken()||"text",u)){var i=new s(t,n.row,n.column+1);if(!this.$matchTokenType(i.getCurrentToken()||"text",u))return!1}return r.stepForward(),r.getCurrentTokenRow()!==n.row||this.$matchTokenType(r.getCurrentToken()||"text",a)},p.$matchTokenType=function(e,t){return t.indexOf(e.type||e)>-1},p.recordAutoInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isAutoInsertedClosing(r,i,f.autoInsertedLineEnd[0])||(f.autoInsertedBrackets=0),f.autoInsertedRow=r.row,f.autoInsertedLineEnd=n+i.substr(r.column),f.autoInsertedBrackets++},p.recordMaybeInsert=function(e,t,n){var r=e.getCursorPosition(),i=t.doc.getLine(r.row);this.isMaybeInsertedClosing(r,i)||(f.maybeInsertedBrackets=0),f.maybeInsertedRow=r.row,f.maybeInsertedLineStart=i.substr(0,r.column)+n,f.maybeInsertedLineEnd=i.substr(r.column),f.maybeInsertedBrackets++},p.isAutoInsertedClosing=function(e,t,n){return f.autoInsertedBrackets>0&&e.row===f.autoInsertedRow&&n===f.autoInsertedLineEnd[0]&&t.substr(e.column)===f.autoInsertedLineEnd},p.isMaybeInsertedClosing=function(e,t){return f.maybeInsertedBrackets>0&&e.row===f.maybeInsertedRow&&t.substr(e.column)===f.maybeInsertedLineEnd&&t.substr(0,e.column)==f.maybeInsertedLineStart},p.popAutoInsertedClosing=function(){f.autoInsertedLineEnd=f.autoInsertedLineEnd.substr(1),f.autoInsertedBrackets--},p.clearMaybeInsertedClosing=function(){f&&(f.maybeInsertedBrackets=0,f.maybeInsertedRow=-1)},r.inherits(p,i),t.CstyleBehaviour=p}),ace.define("ace/mode/folding/cstyle",["require","exports","module","ace/lib/oop","ace/range","ace/mode/folding/fold_mode"],function(e,t,n){"use strict";var r=e("../../lib/oop"),i=e("../../range").Range,s=e("./fold_mode").FoldMode,o=t.FoldMode=function(e){e&&(this.foldingStartMarker=new RegExp(this.foldingStartMarker.source.replace(/\|[^|]*?$/,"|"+e.start)),this.foldingStopMarker=new RegExp(this.foldingStopMarker.source.replace(/\|[^|]*?$/,"|"+e.end)))};r.inherits(o,s),function(){this.foldingStartMarker=/(\{|\[)[^\}\]]*$|^\s*(\/\*)/,this.foldingStopMarker=/^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/,this.singleLineBlockCommentRe=/^\s*(\/\*).*\*\/\s*$/,this.tripleStarBlockCommentRe=/^\s*(\/\*\*\*).*\*\/\s*$/,this.startRegionRe=/^\s*(\/\*|\/\/)#?region\b/,this._getFoldWidgetBase=this.getFoldWidget,this.getFoldWidget=function(e,t,n){var r=e.getLine(n);if(this.singleLineBlockCommentRe.test(r)&&!this.startRegionRe.test(r)&&!this.tripleStarBlockCommentRe.test(r))return"";var i=this._getFoldWidgetBase(e,t,n);return!i&&this.startRegionRe.test(r)?"start":i},this.getFoldWidgetRange=function(e,t,n,r){var i=e.getLine(n);if(this.startRegionRe.test(i))return this.getCommentRegionBlock(e,i,n);var s=i.match(this.foldingStartMarker);if(s){var o=s.index;if(s[1])return this.openingBracketBlock(e,s[1],n,o);var u=e.getCommentFoldRange(n,o+s[0].length,1);return u&&!u.isMultiLine()&&(r?u=this.getSectionRange(e,n):t!="all"&&(u=null)),u}if(t==="markbegin")return;var s=i.match(this.foldingStopMarker);if(s){var o=s.index+s[0].length;return s[1]?this.closingBracketBlock(e,s[1],n,o):e.getCommentFoldRange(n,o,-1)}},this.getSectionRange=function(e,t){var n=e.getLine(t),r=n.search(/\S/),s=t,o=n.length;t+=1;var u=t,a=e.getLength();while(++t<a){n=e.getLine(t);var f=n.search(/\S/);if(f===-1)continue;if(r>f)break;var l=this.getFoldWidgetRange(e,"all",t);if(l){if(l.start.row<=s)break;if(l.isMultiLine())t=l.end.row;else if(r==f)break}u=t}return new i(s,o,u,e.getLine(u).length)},this.getCommentRegionBlock=function(e,t,n){var r=t.search(/\s*$/),s=e.getLength(),o=n,u=/^\s*(?:\/\*|\/\/|--)#?(end)?region\b/,a=1;while(++n<s){t=e.getLine(n);var f=u.exec(t);if(!f)continue;f[1]?a--:a++;if(!a)break}var l=n;if(l>o)return new i(o,r,l,t.length)}}.call(o.prototype)}),ace.define("ace/mode/json",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/json_highlight_rules","ace/mode/matching_brace_outdent","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle","ace/worker/worker_client"],function(e,t,n){"use strict";var r=e("../lib/oop"),i=e("./text").Mode,s=e("./json_highlight_rules").JsonHighlightRules,o=e("./matching_brace_outdent").MatchingBraceOutdent,u=e("./behaviour/cstyle").CstyleBehaviour,a=e("./folding/cstyle").FoldMode,f=e("../worker/worker_client").WorkerClient,l=function(){this.HighlightRules=s,this.$outdent=new o,this.$behaviour=new u,this.foldingRules=new a};r.inherits(l,i),function(){this.getNextLineIndent=function(e,t,n){var r=this.$getIndent(t);if(e=="start"){var i=t.match(/^.*[\{\(\[]\s*$/);i&&(r+=n)}return r},this.checkOutdent=function(e,t,n){return this.$outdent.checkOutdent(t,n)},this.autoOutdent=function(e,t,n){this.$outdent.autoOutdent(t,n)},this.createWorker=function(e){var t=new f(["ace"],"ace/mode/json_worker","JsonWorker");return t.attachToDocument(e.getDocument()),t.on("annotate",function(t){e.setAnnotations(t.data)}),t.on("terminate",function(){e.clearAnnotations()}),t},this.$id="ace/mode/json"}.call(l.prototype),t.Mode=l})
Oops, something went wrong.

0 comments on commit 67603f1

Please sign in to comment.