You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1 Add support for line numbers as reference points:
243
+
UPDATE FILE "file.py"
244
+
INSERT AFTER LINE 123
245
+
WITH CONTENT '''...''';
246
+
247
+
2 Add support for regular expressions to match lines:
248
+
UPDATE FILE "file.py"
249
+
INSERT AFTER LINE REGEX r'@@\s*={10,}\s*PERFORMANCE\s+METRICS\s*={10,}\s*@@'
250
+
WITH CONTENT '''...''';
251
+
252
+
3 Add support for "anchored" line markers that must match from start/end of line:
253
+
UPDATE FILE "file.py"
254
+
INSERT AFTER LINE START "@@ ============ PERFORMANCE METRICS"
255
+
WITH CONTENT '''...''';
256
+
*/
241
257
// <specifying-locations-in-code>
242
258
/**
243
259
lineMarker: Points to specific line via its trimmed contents.
@@ -323,13 +339,31 @@ module.exports = grammar({
323
339
324
340
/**
325
341
<details topic="Relative Indent Strings">
326
-
<summary>A relative indent prefix is used within strings in CONTENT blocks to simplify matching indentation with the existing code being changed</summary>
327
-
<p>Syntax:</p>
328
-
<ol>
329
-
<li>`@N:` is the relative indent prefix</li>
330
-
<li>`N` is an integer representing the relative indent *level* (can be negative)</li>
331
-
<li>`content` is the actual code or text for that line</li>
332
-
</ol>
342
+
<summary>A *relative* indent prefix is used for each line within strings in CONTENT blocks to simplify matching indentation with the existing code being changed</summary>
343
+
<syntax>
344
+
The patter is @N:line where:
345
+
- `@N:` is the *RELATIVE* indent prefix;
346
+
- `N` is an integer representing the relative indent *level* (can be negative) compared to the *reference point*;
347
+
- `line` is the actual content for that line (comes immediately after prefix)
348
+
</syntax>
349
+
<prefix-examples>
350
+
- `@0:` Same level as reference point
351
+
- `@1:` 1 more indent level than reference point
352
+
- `@-1:` 1 less indent level than reference point</li>
353
+
</prefix-examples>
354
+
<reference-point>
355
+
Some reference points:
356
+
- AFTER/BEFORE LINE/FUNCTION/CLASS: The referenced item (rather than one line after or before it)
357
+
- INSERT INSIDE FUNCTION/CLASS TOP/BOTTOM: The function/class body
358
+
- `BODY`: The body of the function/class being modified
359
+
- `WHOLE`: The first line of the block where the function/class etc is defined
360
+
</reference-point>
361
+
<key-points>
362
+
The relative indent level *MUST* change logically with code structure:
363
+
- Increment N when entering a nested block (if/for/while/try etc...)
364
+
- Decrement N when exiting a nested block
365
+
NOTE: If you get `E999 IndentationError` message or any other indentation error, check that your relative indent levels follow these rules.
366
+
</key-points>
333
367
<examples>
334
368
<li>'@7:single-quote-string'</li>
335
369
<li>"@-3:double-quote-string"</li>
@@ -338,22 +372,12 @@ module.exports = grammar({
338
372
@0:multi
339
373
@-1:line
340
374
'''</li>
341
-
<li>"""
375
+
<li>\"\"\"
342
376
@0:multi
343
377
@-1:line
344
-
"""</li>
378
+
\"\"\"</li>
345
379
</examples>
346
380
347
-
<p>Key points:</p>
348
-
<ol>
349
-
<li>Each line must start with `@N:` where `N` represents the indentation level</li>
350
-
<li>Indentation level *MUST* change logically with code structure:
351
-
- *MUST* increment N when entering a new block (class body, function body, if statement, loop, etc.)
352
-
- *MUST* Decrement N when exiting a block
353
-
</li>
354
-
<li>The actual content follows immediately after the prefix (@N:)</li>
355
-
</ol>
356
-
357
381
<example>
358
382
[...] WITH CONTENT '''
359
383
@0:class myClass:
@@ -370,6 +394,7 @@ module.exports = grammar({
370
394
Remember: The relative indentation prefix (@N:) is used to indicate the logical structure
371
395
of the code. The CEDARScript interpreter will handle the actual formatting and indentation
0 commit comments