Changeset View
Changeset View
Standalone View
Standalone View
src/script/data/indentation/ada.js
Show First 20 Lines • Show All 43 Lines • ▼ Show 20 Line(s) | |||||
44 | // - recognise various multi line statements | 44 | // - recognise various multi line statements | ||
45 | // - indent once only after case statement | 45 | // - indent once only after case statement | ||
46 | // - add checkParens() for aligning parameters in multiline arg list | 46 | // - add checkParens() for aligning parameters in multiline arg list | ||
47 | // - refactoring & optimisations | 47 | // - refactoring & optimisations | ||
48 | 48 | | |||
49 | // TODO: 'protected', 'task', 'select' & | 49 | // TODO: 'protected', 'task', 'select' & | ||
50 | // possibly other keywords not recognised | 50 | // possibly other keywords not recognised | ||
51 | 51 | | |||
52 | "use strict"; | | |||
53 | | ||||
54 | // required katepart js libraries | 52 | // required katepart js libraries | ||
55 | require ("range.js"); | 53 | require ("range.js"); | ||
56 | require ("cursor.js"); | 54 | require ("cursor.js"); | ||
57 | require ("string.js"); | 55 | require ("string.js"); | ||
58 | 56 | | |||
59 | //BEGIN USER CONFIGURATION | 57 | //BEGIN USER CONFIGURATION | ||
60 | 58 | | |||
61 | // send debug output to terminal | 59 | // send debug output to terminal | ||
62 | // the ada indenter recognises this as a document variable | 60 | // the ada indenter recognises this as a document variable | ||
63 | var debugMode = false; | 61 | var debugMode = false; | ||
64 | 62 | | |||
65 | //END USER CONFIGURATION | 63 | //END USER CONFIGURATION | ||
66 | 64 | | |||
67 | const AdaComment = /\s*--.*$/; | 65 | var AdaComment = /\s*--.*$/; | ||
68 | const unfStmt = /([.=\(]|:=[^;]*)\s*$/; | 66 | var unfStmt = /([.=\(]|:=[^;]*)\s*$/; | ||
69 | const unfLoop = /^\s*(for|while)\b(?!.*\bloop\b)/i; | 67 | var unfLoop = /^\s*(for|while)\b(?!.*\bloop\b)/i; | ||
70 | const AdaBlockStart = /^\s*(if\b|while\b|else\b|elsif\b|loop\b|for\b.*\b(loop|use)\b|declare\b|begin\b|type\b.*\bis\b[^;]*$|(type\b.*)?\brecord\b|procedure\b|function\b|with\s+function\b|accept\b|do\b|task\b|generic\b|package\b|private\b|then\b|when\b|is\b)/i; | 68 | var AdaBlockStart = /^\s*(if\b|while\b|else\b|elsif\b|loop\b|for\b.*\b(loop|use)\b|declare\b|begin\b|type\b.*\bis\b[^;]*$|(type\b.*)?\brecord\b|procedure\b|function\b|with\s+function\b|accept\b|do\b|task\b|generic\b|package\b|private\b|then\b|when\b|is\b)/i; | ||
71 | const StatementStart = /^\s*(if|when|while|else|elsif|loop|for\b.*\b(loop|use)|begin)\b/i; | 69 | var StatementStart = /^\s*(if|when|while|else|elsif|loop|for\b.*\b(loop|use)|begin)\b/i; | ||
72 | 70 | | |||
73 | function dbg() { | 71 | function dbg() { | ||
74 | if (debugMode) { | 72 | if (debugMode) { | ||
75 | debug.apply(this, arguments); | 73 | debug.apply(this, arguments); | ||
76 | } | 74 | } | ||
77 | } | 75 | } | ||
78 | 76 | | |||
79 | 77 | | |||
80 | //BEGIN global variables and functions | 78 | //BEGIN global variables and functions | ||
81 | 79 | | |||
82 | // none implemented | 80 | // none implemented | ||
83 | 81 | | |||
84 | //END global variables and functions | 82 | //END global variables and functions | ||
85 | 83 | | |||
86 | 84 | | |||
87 | // regexp of keywords & patterns that cause reindenting of the current line. | 85 | // regexp of keywords & patterns that cause reindenting of the current line. | ||
88 | const AdaReIndent = /^\s*((then|end|elsif|when|exception|begin|is|record|private)\s+|<<\w+>>|end;|[#\)])(.*)$/; | 86 | var AdaReIndent = /^\s*((then|end|elsif|when|exception|begin|is|record|private)\s+|<<\w+>>|end;|[#\)])(.*)$/; | ||
89 | 87 | | |||
90 | // characters which trigger indent, beside the default '\n' | 88 | // characters which trigger indent, beside the default '\n' | ||
91 | var triggerCharacters = " \t)#>;"; | 89 | var triggerCharacters = " \t)#>;"; | ||
92 | 90 | | |||
93 | // check if the trigger characters are in the right context, | 91 | // check if the trigger characters are in the right context, | ||
94 | // otherwise running the indenter might be annoying to the user | 92 | // otherwise running the indenter might be annoying to the user | ||
95 | function reindentTrigger(line) | 93 | function reindentTrigger(line) | ||
96 | { | 94 | { | ||
▲ Show 20 Lines • Show All 702 Lines • Show Last 20 Lines |