mode-abap.js 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. ace.define("ace/mode/abap_highlight_rules",["require","exports","module","ace/lib/oop","ace/mode/text_highlight_rules"], function(require, exports, module) {
  2. "use strict";
  3. var oop = require("../lib/oop");
  4. var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
  5. var AbapHighlightRules = function() {
  6. var keywordMapper = this.createKeywordMapper({
  7. "variable.language": "this",
  8. "keyword":
  9. "ADD ALIAS ALIASES ASCENDING ASSERT ASSIGN ASSIGNING AT BACK" +
  10. " CALL CASE CATCH CHECK CLASS CLEAR CLOSE CNT COLLECT COMMIT COMMUNICATION COMPUTE CONCATENATE CONDENSE CONSTANTS CONTINUE CONTROLS CONVERT CREATE CURRENCY" +
  11. " DATA DEFINE DEFINITION DEFERRED DELETE DESCENDING DESCRIBE DETAIL DIVIDE DO" +
  12. " ELSE ELSEIF ENDAT ENDCASE ENDCLASS ENDDO ENDEXEC ENDFORM ENDFUNCTION ENDIF ENDIFEND ENDINTERFACE ENDLOOP ENDMETHOD ENDMODULE ENDON ENDPROVIDE ENDSELECT ENDTRY ENDWHILE EVENT EVENTS EXEC EXIT EXPORT EXPORTING EXTRACT" +
  13. " FETCH FIELDS FORM FORMAT FREE FROM FUNCTION" +
  14. " GENERATE GET" +
  15. " HIDE" +
  16. " IF IMPORT IMPORTING INDEX INFOTYPES INITIALIZATION INTERFACE INTERFACES INPUT INSERT IMPLEMENTATION" +
  17. " LEAVE LIKE LINE LOAD LOCAL LOOP" +
  18. " MESSAGE METHOD METHODS MODIFY MODULE MOVE MULTIPLY" +
  19. " ON OVERLAY OPTIONAL OTHERS" +
  20. " PACK PARAMETERS PERFORM POSITION PROGRAM PROVIDE PUT" +
  21. " RAISE RANGES READ RECEIVE RECEIVING REDEFINITION REFERENCE REFRESH REJECT REPLACE REPORT RESERVE RESTORE RETURN RETURNING ROLLBACK" +
  22. " SCAN SCROLL SEARCH SELECT SET SHIFT SKIP SORT SORTED SPLIT STANDARD STATICS STEP STOP SUBMIT SUBTRACT SUM SUMMARY SUPPRESS" +
  23. " TABLES TIMES TRANSFER TRANSLATE TRY TYPE TYPES" +
  24. " UNASSIGN ULINE UNPACK UPDATE" +
  25. " WHEN WHILE WINDOW WRITE" +
  26. " OCCURS STRUCTURE OBJECT PROPERTY" +
  27. " CASTING APPEND RAISING VALUE COLOR" +
  28. " CHANGING EXCEPTION EXCEPTIONS DEFAULT CHECKBOX COMMENT" +
  29. " ID NUMBER FOR TITLE OUTPUT" +
  30. " WITH EXIT USING" +
  31. " INTO WHERE GROUP BY HAVING ORDER BY SINGLE" +
  32. " APPENDING CORRESPONDING FIELDS OF TABLE" +
  33. " LEFT RIGHT OUTER INNER JOIN AS CLIENT SPECIFIED BYPASSING BUFFER UP TO ROWS CONNECTING" +
  34. " EQ NE LT LE GT GE NOT AND OR XOR IN LIKE BETWEEN",
  35. "constant.language":
  36. "TRUE FALSE NULL SPACE",
  37. "support.type":
  38. "c n i p f d t x string xstring decfloat16 decfloat34",
  39. "keyword.operator":
  40. "abs sign ceil floor trunc frac acos asin atan cos sin tan" +
  41. " abapOperator cosh sinh tanh exp log log10 sqrt" +
  42. " strlen xstrlen charlen numofchar dbmaxlen lines"
  43. }, "text", true, " ");
  44. var compoundKeywords = "WITH\\W+(?:HEADER\\W+LINE|FRAME|KEY)|NO\\W+STANDARD\\W+PAGE\\W+HEADING|"+
  45. "EXIT\\W+FROM\\W+STEP\\W+LOOP|BEGIN\\W+OF\\W+(?:BLOCK|LINE)|BEGIN\\W+OF|"+
  46. "END\\W+OF\\W+(?:BLOCK|LINE)|END\\W+OF|NO\\W+INTERVALS|"+
  47. "RESPECTING\\W+BLANKS|SEPARATED\\W+BY|USING\\W+(?:EDIT\\W+MASK)|"+
  48. "WHERE\\W+(?:LINE)|RADIOBUTTON\\W+GROUP|REF\\W+TO|"+
  49. "(?:PUBLIC|PRIVATE|PROTECTED)(?:\\W+SECTION)?|DELETING\\W+(?:TRAILING|LEADING)"+
  50. "(?:ALL\\W+OCCURRENCES)|(?:FIRST|LAST)\\W+OCCURRENCE|INHERITING\\W+FROM|"+
  51. "LINE-COUNT|ADD-CORRESPONDING|AUTHORITY-CHECK|BREAK-POINT|CLASS-DATA|CLASS-METHODS|"+
  52. "CLASS-METHOD|DIVIDE-CORRESPONDING|EDITOR-CALL|END-OF-DEFINITION|END-OF-PAGE|END-OF-SELECTION|"+
  53. "FIELD-GROUPS|FIELD-SYMBOLS|FUNCTION-POOL|MOVE-CORRESPONDING|MULTIPLY-CORRESPONDING|NEW-LINE|"+
  54. "NEW-PAGE|NEW-SECTION|PRINT-CONTROL|RP-PROVIDE-FROM-LAST|SELECT-OPTIONS|SELECTION-SCREEN|"+
  55. "START-OF-SELECTION|SUBTRACT-CORRESPONDING|SYNTAX-CHECK|SYNTAX-TRACE|TOP-OF-PAGE|TYPE-POOL|"+
  56. "TYPE-POOLS|LINE-SIZE|LINE-COUNT|MESSAGE-ID|DISPLAY-MODE|READ(?:-ONLY)?|"+
  57. "IS\\W+(?:NOT\\W+)?(?:ASSIGNED|BOUND|INITIAL|SUPPLIED)";
  58. this.$rules = {
  59. "start" : [
  60. {token : "string", regex : "`", next : "string"},
  61. {token : "string", regex : "'", next : "qstring"},
  62. {token : "doc.comment", regex : /^\*.+/},
  63. {token : "comment", regex : /".+$/},
  64. {token : "invalid", regex: "\\.{2,}"},
  65. {token : "keyword.operator", regex: /\W[\-+%=<>*]\W|\*\*|[~:,\.&$]|->*?|=>/},
  66. {token : "paren.lparen", regex : "[\\[({]"},
  67. {token : "paren.rparen", regex : "[\\])}]"},
  68. {token : "constant.numeric", regex: "[+-]?\\d+\\b"},
  69. {token : "variable.parameter", regex : /sy|pa?\d\d\d\d\|t\d\d\d\.|innnn/},
  70. {token : "keyword", regex : compoundKeywords},
  71. {token : "variable.parameter", regex : /\w+-\w+(?:-\w+)*/},
  72. {token : keywordMapper, regex : "\\b\\w+\\b"},
  73. {caseInsensitive: true}
  74. ],
  75. "qstring" : [
  76. {token : "constant.language.escape", regex : "''"},
  77. {token : "string", regex : "'", next : "start"},
  78. {defaultToken : "string"}
  79. ],
  80. "string" : [
  81. {token : "constant.language.escape", regex : "``"},
  82. {token : "string", regex : "`", next : "start"},
  83. {defaultToken : "string"}
  84. ]
  85. };
  86. };
  87. oop.inherits(AbapHighlightRules, TextHighlightRules);
  88. exports.AbapHighlightRules = AbapHighlightRules;
  89. });
  90. ace.define("ace/mode/folding/coffee",["require","exports","module","ace/lib/oop","ace/mode/folding/fold_mode","ace/range"], function(require, exports, module) {
  91. "use strict";
  92. var oop = require("../../lib/oop");
  93. var BaseFoldMode = require("./fold_mode").FoldMode;
  94. var Range = require("../../range").Range;
  95. var FoldMode = exports.FoldMode = function() {};
  96. oop.inherits(FoldMode, BaseFoldMode);
  97. (function() {
  98. this.getFoldWidgetRange = function(session, foldStyle, row) {
  99. var range = this.indentationBlock(session, row);
  100. if (range)
  101. return range;
  102. var re = /\S/;
  103. var line = session.getLine(row);
  104. var startLevel = line.search(re);
  105. if (startLevel == -1 || line[startLevel] != "#")
  106. return;
  107. var startColumn = line.length;
  108. var maxRow = session.getLength();
  109. var startRow = row;
  110. var endRow = row;
  111. while (++row < maxRow) {
  112. line = session.getLine(row);
  113. var level = line.search(re);
  114. if (level == -1)
  115. continue;
  116. if (line[level] != "#")
  117. break;
  118. endRow = row;
  119. }
  120. if (endRow > startRow) {
  121. var endColumn = session.getLine(endRow).length;
  122. return new Range(startRow, startColumn, endRow, endColumn);
  123. }
  124. };
  125. this.getFoldWidget = function(session, foldStyle, row) {
  126. var line = session.getLine(row);
  127. var indent = line.search(/\S/);
  128. var next = session.getLine(row + 1);
  129. var prev = session.getLine(row - 1);
  130. var prevIndent = prev.search(/\S/);
  131. var nextIndent = next.search(/\S/);
  132. if (indent == -1) {
  133. session.foldWidgets[row - 1] = prevIndent!= -1 && prevIndent < nextIndent ? "start" : "";
  134. return "";
  135. }
  136. if (prevIndent == -1) {
  137. if (indent == nextIndent && line[indent] == "#" && next[indent] == "#") {
  138. session.foldWidgets[row - 1] = "";
  139. session.foldWidgets[row + 1] = "";
  140. return "start";
  141. }
  142. } else if (prevIndent == indent && line[indent] == "#" && prev[indent] == "#") {
  143. if (session.getLine(row - 2).search(/\S/) == -1) {
  144. session.foldWidgets[row - 1] = "start";
  145. session.foldWidgets[row + 1] = "";
  146. return "";
  147. }
  148. }
  149. if (prevIndent!= -1 && prevIndent < indent)
  150. session.foldWidgets[row - 1] = "start";
  151. else
  152. session.foldWidgets[row - 1] = "";
  153. if (indent < nextIndent)
  154. return "start";
  155. else
  156. return "";
  157. };
  158. }).call(FoldMode.prototype);
  159. });
  160. ace.define("ace/mode/abap",["require","exports","module","ace/mode/abap_highlight_rules","ace/mode/folding/coffee","ace/range","ace/mode/text","ace/lib/oop"], function(require, exports, module) {
  161. "use strict";
  162. var Rules = require("./abap_highlight_rules").AbapHighlightRules;
  163. var FoldMode = require("./folding/coffee").FoldMode;
  164. var Range = require("../range").Range;
  165. var TextMode = require("./text").Mode;
  166. var oop = require("../lib/oop");
  167. function Mode() {
  168. this.HighlightRules = Rules;
  169. this.foldingRules = new FoldMode();
  170. }
  171. oop.inherits(Mode, TextMode);
  172. (function() {
  173. this.lineCommentStart = '"'
  174. this.getNextLineIndent = function(state, line, tab) {
  175. var indent = this.$getIndent(line);
  176. return indent;
  177. };
  178. this.$id = "ace/mode/abap";
  179. }).call(Mode.prototype);
  180. exports.Mode = Mode;
  181. });