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 CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules;
  6. var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
  7. var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
  8. var CStyleFoldMode = require("./folding/csharp").FoldMode;
  9. var Mode = function() {
  10. this.HighlightRules = CSharpHighlightRules;
  11. this.$outdent = new MatchingBraceOutdent();
  12. this.$behaviour = new CstyleBehaviour();
  13. this.foldingRules = new CStyleFoldMode();
  14. };
  15. oop.inherits(Mode, TextMode);
  16. (function() {
  17. this.lineCommentStart = "//";
  18. this.blockComment = {start: "/*", end: "*/"};
  19. this.getNextLineIndent = function(state, line, tab) {
  20. var indent = this.$getIndent(line);
  21. var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
  22. var tokens = tokenizedLine.tokens;
  23. if (tokens.length && tokens[tokens.length-1].type == "comment") {
  24. return indent;
  25. }
  26. if (state == "start") {
  27. var match = line.match(/^.*[\{\(\[]\s*$/);
  28. if (match) {
  29. indent += tab;
  30. }
  31. }
  32. return indent;
  33. };
  34. this.checkOutdent = function(state, line, input) {
  35. return this.$outdent.checkOutdent(line, input);
  36. };
  37. this.autoOutdent = function(state, doc, row) {
  38. this.$outdent.autoOutdent(doc, row);
  39. };
  40. this.createWorker = function(session) {
  41. return null;
  42. };
  43. this.$id = "ace/mode/csharp";
  44. }).call(Mode.prototype);
  45. exports.Mode = Mode;
  46. });