csharp.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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 CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
  7. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  8. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  9. var CStyleFoldMode = require("./folding/csharp").FoldMode;
  10. var Mode = function() {
  11. this.HighlightRules = CSharpHighlightRules;
  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. this.createWorker = function(session) {
  42. return null;
  43. };
  44. }).call(Mode.prototype);
  45. exports.Mode = Mode;
  46. });