Files
JiboSDK/lib/rules/rule-grammar.js

1 line
2.1 KiB
JavaScript
Raw Normal View History

2026-03-22 03:21:45 +02:00
"use strict";var e=function(e){return e&&e.__esModule?e["default"]:e},r=function(){function e(e,r){for(var t in r){var i=r[t];i.configurable=!0,i.value&&(i.writable=!0)}Object.defineProperties(e,r)}return function(r,t,i){return t&&e(r.prototype,t),i&&e(r,i),r}}(),t=function(e,r){if(!(e instanceof r))throw new TypeError("Cannot call a class as a function")},i=e(require("path")),n=e(require("react")),a=e(require("./error-popup")),o=e(require("./gutter-popup")),s=void 0;try{s=require("jibo-parser")}catch(u){console.warn("Error importing jibo-parser. Simulator will not support robust parsing. "+u)}var l=function(){function e(){t(this,e),this.start()}return r(e,{onChange:{value:function(){this.marker&&(this.marker.destroy(),this.lineNumber&&this.lineNumber.parentNode&&this.lineNumber.parentNode.removeChild(this.lineNumber));var e=this.editor.getText();try{s&&s.syntax_check(e)}catch(r){var t=JSON.parse(r.message);if(t.info.line){var i=[[t.info.line-1,t.info.column-1],[t.info.line-1,t.info.column]];this.marker=this.editor.markBufferRange(i,{invalidate:"never"}),this.editor.decorateMarker(this.marker,{type:"highlight","class":"jibo-highlight-red"}),this.editor.decorateMarker(this.marker,{type:"line-number","class":"jibo-line-number-red"});var u=document.createElement("div");n.render(n.createElement(a,{message:t.info.msg,marker:this.marker}),u),this.editor.decorateMarker(this.marker,{type:"overlay",item:u})}else{var i=[[0,0],[0,1]];this.marker=this.editor.markBufferRange(i,{invalidate:"never"}),this.editor.decorateMarker(this.marker,{type:"line-number","class":"jibo-line-number-red"});var u=document.createElement("div");n.render(n.createElement(o,{message:t.info.msg,marker:this.marker}),u),this.editor.decorateMarker(this.marker,{type:"overlay",item:u})}console.log(t)}}},start:{value:function(){var e=this;atom.workspace.observeActivePaneItem(function(r){if(r&&r.constructor&&"TextEditor"===r.constructor.name){var t=i.extname(r.getPath());e.dispoable&&e.dispoable.dispose(),(".nli"===t||".rule"===t||".grm"===t)&&(e.editor=r,e.dispoable=r.onDidStopChanging(e.onChange.bind(e)))}})}}}),e}();module.exports=new l;