Skip to content

Commit

Permalink
Fixes for FINALLY blocks; additional FOR terminators
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Judge authored and chriscamicas committed Mar 3, 2024
1 parent 1c3efbb commit 6b16c22
Show file tree
Hide file tree
Showing 6 changed files with 210 additions and 9 deletions.
57 changes: 51 additions & 6 deletions abl.tmLanguage.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
}
},
"comment": "The lookahead on the regex for the closing colon is required to make this scope end properly",
"end": "\\s*(?=:)",
"end": "(?=:)",
"patterns": [
{
"include": "#access-modifier"
Expand Down Expand Up @@ -326,6 +326,9 @@
{
"include": "#block-label"
},
{
"include": "#end-block"
},
{
"include": "#end-function-procedure-method-block"
},
Expand Down Expand Up @@ -497,6 +500,9 @@
},
{
"include": "#variable-name"
},
{
"include": "#punctuation-period"
}
]
},
Expand Down Expand Up @@ -1751,7 +1757,7 @@
"name": "storage.data.table.abl"
}
},
"end": "(?i)\\s*(?=where|no-lock|share-lock|exclusive-lock|tenant-where|use-index|table-scan|using|no-prefetch|left|outer-join|,|:)\\s*",
"end": "(?i)\\s*(?=where|no-lock|share-lock|exclusive-lock|tenant-where|use-index|table-scan|using|no-prefetch|left|outer-join|break|by|transaction,|:)\\s*",
"patterns": [
{
"include": "#fields-except-list"
Expand Down Expand Up @@ -1789,7 +1795,7 @@
"name": "keyword.other.abl"
}
},
"end": "(?i)\\s*(?=where|no-lock|share-lock|exclusive-lock|tenant-where|use-index|table-scan|using|no-prefetch|left|outer-join|,|:)\\s*",
"end": "(?i)\\s*(?=where|no-lock|share-lock|exclusive-lock|tenant-where|use-index|table-scan|using|no-prefetch|left|outer-join|break|by|transaction|,|:)\\s*",
"patterns": [
{
"match": "(?i)\\s*(each|first|last|of)\\s*",
Expand Down Expand Up @@ -1963,6 +1969,9 @@
{
"include": "#block-statement"
},
{
"include": "#end-block"
},
{
"include": "#property-call"
},
Expand Down Expand Up @@ -2107,8 +2116,16 @@
"name": "keyword.other.abl"
}
},
"end": "(?<=\\s)",
"end": "(?=\\s|\\)|\\.)",
"patterns": [
{
"match": "(?i)\\s*(class)\\s*",
"captures": {
"1": {
"name": "keyword.other.abl"
}
}
},
{
"include": "#dll-type"
},
Expand All @@ -2123,6 +2140,18 @@
},
{
"include": "#type-name"
},
{
"include": "#parens"
},
{
"include": "#string"
},
{
"include": "#punctuation-period"
},
{
"include": "#punctuation-comma"
}
]
},
Expand Down Expand Up @@ -2581,8 +2610,20 @@
}
}
},
"end-block": {
"comment": "Certain blocks have the option of END <block name>",
"match": "(?i)\\s*(end)\\s+(CASE|CATCH|CLASS|CONSTRUCTOR|DESTRUCTOR|ENUM|FINALLY|FUNCTION|GET|INTERFACE|METHOD|PROCEDURE|SET|TRIGGERS)\\s*",
"captures": {
"1": {
"name": "keyword.other.abl"
},
"2": {
"name": "keyword.other.abl"
}
}
},
"block-statement": {
"begin": "(?i)\\s*(do|repeat)\\s*",
"begin": "(?i)(?<!end)\\s*(do|repeat|finally)\\s*",
"beginCaptures": {
"1": {
"name": "keyword.other.abl"
Expand Down Expand Up @@ -3252,6 +3293,10 @@
"match": ","
},
"punctuation-semicolon": {
"name": "punctuation.terminator.abl",
"match": ";"
},
"punctuation-period": {
"name": "punctuation.terminator.abl",
"match": "\\."
},
Expand Down Expand Up @@ -3381,7 +3426,7 @@
"name": "keyword.other.abl"
},
"keywords-f": {
"match": "(?i)(?<![\\w-])(false|false-leaks|fetch|field|fields|file|file-access-d|file-access-da|file-access-dat|file-access-date|file-access-t|file-access-ti|file-access-tim|file-access-time|file-info|file-infor|file-inform|file-informa|file-informat|file-informati|file-informatio|file-information|filename|fill-in|filters|final|finally|find|find|find-case-sensitive|find-global|find-next-occurrence|find-prev-occurrence|find-select|find-wrap-around|finder|firehose-cursor|first|first-of|fix-codepage|fixed-only|flags|float|focus|focus-in|font|font-table|for|force-file|form|forma|format|forward|forwards|fram|frame|frame-db|frame-down|frame-field|frame-file|frame-inde|frame-index|frame-line|frame-val|frame-valu|frame-value|from|from-c|from-ch|from-cha|from-char|from-chars|from-cur|from-curr|from-curre|from-curren|from-current|from-p|from-pi|from-pix|from-pixe|from-pixel|from-pixels|fromnoreorder|full-width|function|function-call-type)(?![\\w-])",
"match": "(?i)(?<![\\w-])(false|false-leaks|fetch|field|fields|file|file-access-d|file-access-da|file-access-dat|file-access-date|file-access-t|file-access-ti|file-access-tim|file-access-time|file-info|file-infor|file-inform|file-informa|file-informat|file-informati|file-informatio|file-information|filename|fill-in|filters|finally|final|find|find-case-sensitive|find-global|find-next-occurrence|find-prev-occurrence|find-select|find-wrap-around|finder|firehose-cursor|first|first-of|fix-codepage|fixed-only|flags|float|focus|focus-in|font|font-table|for|force-file|form|forma|format|forward|forwards|fram|frame|frame-db|frame-down|frame-field|frame-file|frame-inde|frame-index|frame-line|frame-val|frame-valu|frame-value|from|from-c|from-ch|from-cha|from-char|from-chars|from-cur|from-curr|from-curre|from-curren|from-current|from-p|from-pi|from-pix|from-pixe|from-pixel|from-pixels|fromnoreorder|full-width|function|function-call-type)(?![\\w-])",
"name": "keyword.other.abl"
},
"keywords-g": {
Expand Down
51 changes: 51 additions & 0 deletions spec/blocks/finally-blocks.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const { assert, expect } = require('chai');
const shared = require('../shared.js');

describe('', () => {
let statement = `FINALLY:
ASSIGN oBusinessEntityDescriptor = ?.
END FINALLY.`;
let expectedTokens = [
[
{ "startIndex": 0, "endIndex": 7, "scopes": ["source.abl", "meta.block.abl", "keyword.other.abl"] }, // 'FINALLY'
{ "startIndex": 7, "endIndex": 9, "scopes": ["source.abl"] } // ':'
],
[
{ "startIndex": 0, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 4, "endIndex": 10, "scopes": ["source.abl", "keyword.other.abl"] }, // 'ASSIGN'
{ "startIndex": 10, "endIndex": 11, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 11, "endIndex": 36, "scopes": ["source.abl", "variable.other.abl"] }, // 'oBusinessEntityDescriptor'
{ "startIndex": 36, "endIndex": 37, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 37, "endIndex": 38, "scopes": ["source.abl", "keyword.operator.source.abl"] }, // '='
{ "startIndex": 38, "endIndex": 39, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 39, "endIndex": 40, "scopes": ["source.abl", "constant.language.abl"] }, // '?'
{ "startIndex": 40, "endIndex": 41, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
],
[
{ "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'END'
{ "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 4, "endIndex": 11, "scopes": ["source.abl", "keyword.other.abl"] }, // 'FINALLY'
{ "startIndex": 11, "endIndex": 12, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.'
]
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})

describe('', () => {
let statement = `FINALLY:
END. // no finally on END`;
let expectedTokens = [
[
{ "startIndex": 0, "endIndex": 7, "scopes": ["source.abl", "meta.block.abl", "keyword.other.abl"] }, // 'FINALLY'
{ "startIndex": 7, "endIndex": 9, "scopes": ["source.abl"] } // ':'
],
[
{ "startIndex": 0, "endIndex": 2, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 2, "endIndex": 5, "scopes": ["source.abl", "keyword.other.abl"] }, // 'END'
{ "startIndex": 5, "endIndex": 6, "scopes": ["source.abl", "punctuation.terminator.abl"] }, // '.'
{ "startIndex": 6, "endIndex": 7, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 7, "endIndex": 27, "scopes": ["source.abl", "comment.line.double-slash.abl"] } // '// no finally on END'
]
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})
93 changes: 92 additions & 1 deletion spec/db-table-and-field/foreach.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -433,4 +433,95 @@ describe('', () => {
{ "startIndex": 0, "endIndex": 11, "scopes": ["source.abl"] } // ' @Befor'
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})
})

describe('', () => {
let statement = `FOR EACH ttTaskMethods
BREAK BY ttTaskMethods.ClassName:`;
let expectedTokens = [
[
{ "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'FOR'
{ "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 4, "endIndex": 8, "scopes": ["source.abl", "keyword.other.abl"] }, // 'EACH'
{ "startIndex": 8, "endIndex": 9, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 9, "endIndex": 22, "scopes": ["source.abl", "storage.data.table.abl"] } // 'ttTaskMethods'
],
[
{ "startIndex": 0, "endIndex": 8, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 8, "endIndex": 13, "scopes": ["source.abl", "keyword.other.abl"] }, // 'BREAK'
{ "startIndex": 13, "endIndex": 14, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 14, "endIndex": 16, "scopes": ["source.abl", "keyword.other.abl"] }, // 'BY'
{ "startIndex": 16, "endIndex": 17, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 17, "endIndex": 40, "scopes": ["source.abl", "storage.data.table.abl"] }, // 'ttTaskMethods.ClassName'
{ "startIndex": 40, "endIndex": 42, "scopes": ["source.abl"] } // ':'
]
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})

describe('', () => {
let statement = `FOR EACH ttTaskMethods BY ttTaskMethods.ClassName:`;
let expectedTokens = [
{ "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'FOR'
{ "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 4, "endIndex": 8, "scopes": ["source.abl", "keyword.other.abl"] }, // 'EACH'
{ "startIndex": 8, "endIndex": 9, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 9, "endIndex": 22, "scopes": ["source.abl", "storage.data.table.abl"] }, // 'ttTaskMethods'
{ "startIndex": 22, "endIndex": 23, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 23, "endIndex": 25, "scopes": ["source.abl", "keyword.other.abl"] }, // 'BY'
{ "startIndex": 25, "endIndex": 26, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 26, "endIndex": 49, "scopes": ["source.abl", "storage.data.table.abl"] }, // 'ttTaskMethods.ClassName'
{ "startIndex": 49, "endIndex": 51, "scopes": ["source.abl"] } // ':'
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})

describe('', () => {
let statement = `FOR EACH ttTaskMethods transACTION:`;
let expectedTokens = [
{ "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'FOR'
{ "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 4, "endIndex": 8, "scopes": ["source.abl", "keyword.other.abl"] }, // 'EACH'
{ "startIndex": 8, "endIndex": 9, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 9, "endIndex": 22, "scopes": ["source.abl", "storage.data.table.abl"] }, // 'ttTaskMethods'
{ "startIndex": 22, "endIndex": 23, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 23, "endIndex": 34, "scopes": ["source.abl", "keyword.other.abl"] }, // 'transACTION'
{ "startIndex": 34, "endIndex": 36, "scopes": ["source.abl"] } // ':'
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})

describe('', () => {
let statement = `FOR EACH ttTaskMethods WHERE ttTaskMethods.field <> ?
BY ttTaskMethods.ClassName
TRANSACTION:`;
let expectedTokens = [
[
{ "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'FOR'
{ "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 4, "endIndex": 8, "scopes": ["source.abl", "keyword.other.abl"] }, // 'EACH'
{ "startIndex": 8, "endIndex": 9, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 9, "endIndex": 22, "scopes": ["source.abl", "storage.data.table.abl"] }, // 'ttTaskMethods'
{ "startIndex": 22, "endIndex": 23, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 23, "endIndex": 28, "scopes": ["source.abl", "keyword.other.abl"] }, // 'WHERE'
{ "startIndex": 28, "endIndex": 29, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 29, "endIndex": 48, "scopes": ["source.abl", "storage.data.table.abl"] }, // 'ttTaskMethods.field'
{ "startIndex": 48, "endIndex": 49, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 49, "endIndex": 51, "scopes": ["source.abl", "keyword.operator.source.abl"] }, // '<>'
{ "startIndex": 51, "endIndex": 52, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 52, "endIndex": 53, "scopes": ["source.abl", "constant.language.abl"] } // '?'
],
[
{ "startIndex": 0, "endIndex": 2, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 2, "endIndex": 4, "scopes": ["source.abl", "keyword.other.abl"] }, // 'BY'
{ "startIndex": 4, "endIndex": 5, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 5, "endIndex": 28, "scopes": ["source.abl", "storage.data.table.abl"] } // 'ttTaskMethods.ClassName'
],
[
{ "startIndex": 0, "endIndex": 2, "scopes": ["source.abl"] }, // ' '
{ "startIndex": 2, "endIndex": 13, "scopes": ["source.abl", "meta.block.label.abl"] }, // 'TRANSACTION'
{ "startIndex": 13, "endIndex": 15, "scopes": ["source.abl"] } // ':'
]
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})
14 changes: 14 additions & 0 deletions spec/db-table-and-field/issue#88.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,18 @@ describe('', () => {
]
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})

describe('', () => {
let statement = `//exclusive-lock:
//no-lock:`;
let expectedTokens = [
[
{ "startIndex": 0, "endIndex": 17, "scopes": ["source.abl", "comment.line.double-slash.abl"] } // '//exclusive-lock:'
],
[
{ "startIndex": 0, "endIndex": 10, "scopes": ["source.abl", "comment.line.double-slash.abl"] } // '//no-lock:'
]
];
shared.itShouldMatchExpectedScopes(statement, expectedTokens);
})
2 changes: 1 addition & 1 deletion spec/method-definition/constructor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ end constructor.`;
{ "startIndex": 68, "endIndex": 69, "scopes": ["source.abl", "meta.define.method.abl"] }, // ' '
{ "startIndex": 69, "endIndex": 71, "scopes": ["source.abl", "meta.define.method.abl", "keyword.other.abl"] }, // 'as'
{ "startIndex": 71, "endIndex": 72, "scopes": ["source.abl", "meta.define.method.abl"] }, // ' '
{ "startIndex": 72, "endIndex": 78, "scopes": ["source.abl", "meta.define.method.abl", "keyword.other.abl"] }, // 'Object'
{ "startIndex": 72, "endIndex": 78, "scopes": ["source.abl", "meta.define.method.abl", "entity.name.type.abl"] }, // 'Object'
{ "startIndex": 78, "endIndex": 79, "scopes": ["source.abl", "meta.define.method.abl", "meta.brace.round.js"] }, // ')'
{ "startIndex": 79, "endIndex": 81, "scopes": ["source.abl"] } // ':'
],
Expand Down
2 changes: 1 addition & 1 deletion spec/method-definition/method.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ end method.`;
{ "startIndex": 64, "endIndex": 65, "scopes": ["source.abl", "meta.define.method.abl"] }, // ' '
{ "startIndex": 65, "endIndex": 67, "scopes": ["source.abl", "meta.define.method.abl", "keyword.other.abl"] }, // 'as'
{ "startIndex": 67, "endIndex": 68, "scopes": ["source.abl", "meta.define.method.abl"] }, // ' '
{ "startIndex": 68, "endIndex": 74, "scopes": ["source.abl", "meta.define.method.abl", "keyword.other.abl"] }, // 'Object'
{ "startIndex": 68, "endIndex": 74, "scopes": ["source.abl", "meta.define.method.abl", "entity.name.type.abl"] }, // 'Object'
{ "startIndex": 74, "endIndex": 75, "scopes": ["source.abl", "meta.define.method.abl", "meta.brace.round.js"] }, // ')'
{ "startIndex": 75, "endIndex": 77, "scopes": ["source.abl"] } // ':'
],
Expand Down

0 comments on commit 6b16c22

Please sign in to comment.