dot.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. define(function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextMode = require("./text").Mode;
  5. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  6. var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules;
  7. var DotFoldMode = require("./folding/cstyle").FoldMode;
  8. var Mode = function() {
  9. this.HighlightRules = DotHighlightRules;
  10. this.$outdent = new MatchingBraceOutdent();
  11. this.foldingRules = new DotFoldMode();
  12. };
  13. oop.inherits(Mode, TextMode);
  14. (function() {
  15. this.lineCommentStart = ["//", "#"];
  16. this.blockComment = {start: "/*", end: "*/"};
  17. this.getNextLineIndent = function(state, line, tab) {
  18. var indent = this.$getIndent(line);
  19. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  20. var tokens = tokenizedLine.tokens;
  21. var endState = tokenizedLine.state;
  22. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  23. return indent;
  24. }
  25. if (state == "start") {
  26. var match = line.match(/^.*(?:\bcase\b.*\:|[\{\(\[])\s*$/);
  27. if (match) {
  28. indent += tab;
  29. }
  30. }
  31. return indent;
  32. };
  33. this.checkOutdent = function(state, line, input) {
  34. return this.$outdent.checkOutdent(line, input);
  35. };
  36. this.autoOutdent = function(state, doc, row) {
  37. this.$outdent.autoOutdent(doc, row);
  38. };
  39. this.$id = "ace/mode/dot";
  40. }).call(Mode.prototype);
  41. exports.Mode = Mode;
  42. });