text: define(function(require, exports, module) {
  "use strict";
  
  var oop = require("../lib/oop");
  var TextMode = require("./text").Mode;
  var SolidityHighlightRules = require("./solidity_highlight_rules").SolidityHighlightRules;
  var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  var Range = require("../range").Range;
  var WorkerClient = require("../worker/worker_client").WorkerClient;
  var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  var CStyleFoldMode = require("./folding/cstyle").FoldMode;
  
  var Mode = function() {
      this.HighlightRules = SolidityHighlightRules;
  
      this.$outdent = new MatchingBraceOutdent();
      this.$behaviour = new CstyleBehaviour();
      this.foldingRules = new CStyleFoldMode();
  };
  oop.inherits(Mode, TextMode);
  
  (function() {
  
      this.lineCommentStart = "//";
      this.blockComment = {start: "/*", end: "*/"};
  
      this.getNextLineIndent = function(state, line, tab) {
          var indent = this.$getIndent(line);
  
          var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
          var tokens = tokenizedLine.tokens;
          var endState = tokenizedLine.state;
  
          if (tokens.length && tokens[tokens.length-1].type == "comment") {
              return indent;
          }
  
          if (state == "start") {
              var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
              if (match) {
                  indent += tab;
              }
          } else if (state == "doc_comment") {
              if (endState == "start") {
                  return "";
              }
              var match = line.match(/^\s*(\/?)\*/);
              if (match) {
                  if (match[1]) {
                      indent += " ";
                  }
                  indent += "* ";
              }
          }
  
          return indent;
      };
  
      this.checkOutdent = function(state, line, input) {
          return this.$outdent.checkOutdent(line, input);
      };
  
      this.autoOutdent = function(state, doc, row) {
          this.$outdent.autoOutdent(doc, row);
      };
  
  //    this.createWorker = function(session) {
  //        var worker = new WorkerClient(["ace"], "ace/mode/solidity_worker", "SolidityWorker");
  //        worker.attachToDocument(session.getDocument());
  //
  //        worker.on("jslint", function(results) {
  //            session.setAnnotations(results.data);
  //        });
  //
  //        worker.on("terminate", function() {
  //            session.clearAnnotations();
  //        });
  //
  //        return worker;
  //    };
  
      this.$id = "ace/mode/solidity";
  }).call(Mode.prototype);
  
  exports.Mode = Mode;
  });
  