haxe.js 1.6 KB

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