Advertisement
Guest User

mode-semicolonlineend

a guest
Jul 19th, 2015
875
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. define("ace/worker/mirror",["require","exports","module","ace/range","ace/document","ace/lib/lang"], function(require, exports, module) {
  2. "use strict";
  3.  
  4. var Range = require("../range").Range;
  5. var Document = require("../document").Document;
  6. var lang = require("../lib/lang");
  7.    
  8. var Mirror = exports.Mirror = function(sender) {
  9.     this.sender = sender;
  10.     var doc = this.doc = new Document("");
  11.    
  12.     var deferredUpdate = this.deferredUpdate = lang.delayedCall(this.onUpdate.bind(this));
  13.    
  14.     var _self = this;
  15.     sender.on("change", function(e) {
  16.         var data = e.data;
  17.         if (data[0].start) {
  18.             doc.applyDeltas(data);
  19.         } else {
  20.             for (var i = 0; i < data.length; i += 2) {
  21.                 if (Array.isArray(data[i+1])) {
  22.                     var d = {action: "insert", start: data[i], lines: data[i+1]};
  23.                 } else {
  24.                     var d = {action: "remove", start: data[i], end: data[i+1]};
  25.                 }
  26.                 doc.applyDelta(d, true);
  27.             }
  28.         }
  29.         if (_self.$timeout)
  30.             return deferredUpdate.schedule(_self.$timeout);
  31.         _self.onUpdate();
  32.     });
  33. };
  34.  
  35. (function() {
  36.    
  37.     this.$timeout = 500;
  38.    
  39.     this.setTimeout = function(timeout) {
  40.         this.$timeout = timeout;
  41.     };
  42.    
  43.     this.setValue = function(value) {
  44.         this.doc.setValue(value);
  45.         this.deferredUpdate.schedule(this.$timeout);
  46.     };
  47.    
  48.     this.getValue = function(callbackId) {
  49.         this.sender.callback(this.doc.getValue(), callbackId);
  50.     };
  51.    
  52.     this.onUpdate = function() {
  53.     };
  54.    
  55.     this.isPending = function() {
  56.         return this.deferredUpdate.isPending();
  57.     };
  58.    
  59. }).call(Mirror.prototype);
  60.  
  61. });
  62.  
  63. define("ace/mode/semicolonlineend",["require","exports","module","ace/lib/oop","ace/worker/mirror"], function(require, exports, module) {
  64. "use strict";
  65.  
  66. var oop = require("../lib/oop");
  67. var Mirror = require("../worker/mirror").Mirror;
  68.  
  69. var SemicolonLineEndCheckWorker = exports.SemicolonLineEndCheckWorker = function (sender) {
  70.     Mirror.call(this, sender);
  71.     this.setTimeout(500);
  72.     this.setOptions();
  73. };
  74.  
  75. oop.inherits(SemicolonLineEndCheckWorker, Mirror);
  76.  
  77. (function() {
  78.  
  79.     this.onUpdate = function () {
  80.         var text = this.doc.getValue();
  81.         var lines = text.replace(/^#!.*\n/, "\n").match(/[^\r\n]+/g);
  82.  
  83.         var errors = [];
  84.  
  85.         for (var i = 0; i < lines.length; i++) {
  86.             var lastLineCharacter = lines[i].trim().slice(-1);
  87.             if (lastLineCharacter === ';')
  88.                 continue;
  89.  
  90.             errors.push({
  91.                 row: i,
  92.                 column: lines[i].length-1,
  93.                 text: "Missing semicolon at the end of the line",
  94.                 type: "warning",
  95.                 raw: "Missing semicolon"
  96.             });
  97.  
  98.         }
  99.  
  100.         this.sender.emit("annotate", errors);
  101.     };
  102.  
  103. }).call(SemicolonLineEndCheckWorker.prototype);
  104.  
  105. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement