diff --git a/abl.tmLanguage.json b/abl.tmLanguage.json index 2b63a1a..6307fcb 100644 --- a/abl.tmLanguage.json +++ b/abl.tmLanguage.json @@ -590,6 +590,9 @@ { "include": "#handle-methods" }, + { + "include": "#get-query" + }, { "include": "#abl-functions" }, @@ -1108,6 +1111,29 @@ } ] }, + "get-query" :{ + "begin": "(?i)\\b(get)\\s+(first|next|prev|last|current)\\b", + "beginCaptures": { + "1": { + "name": "keyword.other.abl" + }, + "2": { + "name": "keyword.other.abl" + } + }, + "end": "(?i)\\s*(?=share-lock|exclusive-lock|no-lock|\\.)", + "patterns": [ + { + "include": "#variable-name" + }, + { + "include": "#preprocessors" + }, + { + "include": "#comment" + } + ] + }, "attribute-access": { "begin": ":", "end": "(?=:)|(?=\\s*)", diff --git a/spec/db-table-and-field/query-get.spec.js b/spec/db-table-and-field/query-get.spec.js new file mode 100644 index 0000000..ce2ccce --- /dev/null +++ b/spec/db-table-and-field/query-get.spec.js @@ -0,0 +1,137 @@ +const { assert, expect } = require('chai'); +const shared = require('../shared.js'); + +describe('', () => { + let statement = `get first qttFoo + no-lock.`; + let expectedTokens = [ + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'get' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'first' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 16, "scopes": ["source.abl", "variable.other.abl"] } // 'qttFoo' + ], + [ + { "startIndex": 0, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 11, "scopes": ["source.abl", "keyword.other.abl"] }, // 'no-lock' + { "startIndex": 11, "endIndex": 12, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ] + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `get first qttFoo. + +if available(ttFoo) then +do: +end.`; + let expectedTokens = [ + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'get' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'first' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 16, "scopes": ["source.abl", "variable.other.abl"] }, // 'qttFoo' + { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ], + [ + { "startIndex": 0, "endIndex": 1, "scopes": ["source.abl"] } // '' + ], + [ + { "startIndex": 0, "endIndex": 2, "scopes": ["source.abl", "keyword.other.abl"] }, // 'if' + { "startIndex": 2, "endIndex": 3, "scopes": ["source.abl", "meta.function-call.abl"] }, // ' ' + { "startIndex": 3, "endIndex": 12, "scopes": ["source.abl", "meta.function-call.abl", "support.function.abl"] }, // 'available' + { "startIndex": 12, "endIndex": 13, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "meta.brace.round.js"] }, // '(' + { "startIndex": 13, "endIndex": 18, "scopes": ["source.abl", "meta.function-call.abl", "meta.function.arguments.abl", "variable.other.abl"] }, // 'ttFoo' + { "startIndex": 18, "endIndex": 19, "scopes": ["source.abl", "meta.function-call.abl", "meta.brace.round.js"] }, // ')' + { "startIndex": 19, "endIndex": 20, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 20, "endIndex": 24, "scopes": ["source.abl", "keyword.other.abl"] } // 'then' + ], + [ + { "startIndex": 0, "endIndex": 2, "scopes": ["source.abl", "meta.block.abl", "keyword.other.abl"] }, // 'do' + { "startIndex": 2, "endIndex": 3, "scopes": ["source.abl", "punctuation.terminator.abl"] } // ':' + ], + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'end' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ] + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `get first qttFoo /* all foos by bar squared */ + no-lock.`; + let expectedTokens = [ + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'get' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'first' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 16, "scopes": ["source.abl", "variable.other.abl"] }, // 'qttFoo' + { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 17, "endIndex": 19, "scopes": ["source.abl", "comment.block.source.abl"] }, // '/*' + { "startIndex": 19, "endIndex": 44, "scopes": ["source.abl", "comment.block.source.abl", "comment"] }, // ' all foos by bar squared ' + { "startIndex": 44, "endIndex": 46, "scopes": ["source.abl", "comment.block.source.abl"] } // '*/' + ], + [ + { "startIndex": 0, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 11, "scopes": ["source.abl", "keyword.other.abl"] }, // 'no-lock' + { "startIndex": 11, "endIndex": 12, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ] + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `get first qttFoo // excludes single bars + exclusive-lock.`; + let expectedTokens = [ + [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'get' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'first' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 16, "scopes": ["source.abl", "variable.other.abl"] }, // 'qttFoo' + { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 17, "endIndex": 40, "scopes": ["source.abl", "comment.line.double-slash.abl"] } // '// excludes single bars' + ], + [ + { "startIndex": 0, "endIndex": 2, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 2, "endIndex": 16, "scopes": ["source.abl", "keyword.other.abl"] }, // 'exclusive-lock' + { "startIndex": 16, "endIndex": 17, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ] + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `get first {&BROWSE-NAME}.`; + let expectedTokens = [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'get' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 9, "scopes": ["source.abl", "keyword.other.abl"] }, // 'first' + { "startIndex": 9, "endIndex": 10, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 10, "endIndex": 11, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.section.abl"] }, // '{' + { "startIndex": 11, "endIndex": 12, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.definition.preprocessor.abl"] }, // '&' + { "startIndex": 12, "endIndex": 23, "scopes": ["source.abl", "meta.preprocessor.abl", "entity.name.function.preprocessor.abl"] }, // 'BROWSE-NAME' + { "startIndex": 23, "endIndex": 24, "scopes": ["source.abl", "meta.preprocessor.abl", "punctuation.section.abl"] }, // '}' + { "startIndex": 24, "endIndex": 25, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +}) + +describe('', () => { + let statement = `get last qttFoo.`; + let expectedTokens = [ + { "startIndex": 0, "endIndex": 3, "scopes": ["source.abl", "keyword.other.abl"] }, // 'get' + { "startIndex": 3, "endIndex": 4, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 4, "endIndex": 8, "scopes": ["source.abl", "keyword.other.abl"] }, // 'last' + { "startIndex": 8, "endIndex": 9, "scopes": ["source.abl"] }, // ' ' + { "startIndex": 9, "endIndex": 15, "scopes": ["source.abl", "variable.other.abl"] }, // 'qttFoo' + { "startIndex": 15, "endIndex": 16, "scopes": ["source.abl", "punctuation.terminator.abl"] } // '.' + ]; + shared.itShouldMatchExpectedScopes(statement, expectedTokens); +})