-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7d87e8e
commit b87d966
Showing
5 changed files
with
105 additions
and
4 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import type { LanguageDefinition } from '../types'; | ||
|
||
export const pgsqlLanguageDefinition: LanguageDefinition = { | ||
aliases: ['PostgreSQL', 'postgres', 'pg', 'postgre'], | ||
extensions: [], | ||
id: 'pgsql', | ||
loader: () => import('./pgsql.js'), | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { testTokenization } from '../../test/testRunner'; | ||
|
||
import { pgsqlLanguageDefinition } from './pgsql.contribution'; | ||
|
||
// Given this is an extension of the base pgsql language from monaco-editor | ||
// which has tests, then just a simple test to ensure it generally works. | ||
|
||
testTokenization('pgsql', pgsqlLanguageDefinition, [ | ||
[ | ||
{ | ||
line: 'SELECT * FROM sch.MyTable WHERE MyColumn IN (1,2)', | ||
tokens: [ | ||
{ startIndex: 0, type: 'keyword.sql' }, | ||
{ startIndex: 6, type: 'white.sql' }, | ||
{ startIndex: 7, type: 'operator.sql' }, | ||
{ startIndex: 8, type: 'white.sql' }, | ||
{ startIndex: 9, type: 'keyword.sql' }, | ||
{ startIndex: 13, type: 'white.sql' }, | ||
{ startIndex: 14, type: 'identifier.sql' }, | ||
{ startIndex: 17, type: 'delimiter.sql' }, | ||
{ startIndex: 18, type: 'identifier.sql' }, | ||
{ startIndex: 25, type: 'white.sql' }, | ||
{ startIndex: 26, type: 'keyword.sql' }, | ||
{ startIndex: 31, type: 'white.sql' }, | ||
{ startIndex: 32, type: 'identifier.sql' }, | ||
{ startIndex: 40, type: 'white.sql' }, | ||
{ startIndex: 41, type: 'operator.sql' }, | ||
{ startIndex: 43, type: 'white.sql' }, | ||
{ startIndex: 44, type: 'delimiter.parenthesis.sql' }, | ||
{ startIndex: 45, type: 'number.sql' }, | ||
{ startIndex: 46, type: 'delimiter.sql' }, | ||
{ startIndex: 47, type: 'number.sql' }, | ||
{ startIndex: 48, type: 'delimiter.parenthesis.sql' }, | ||
], | ||
}, | ||
], | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { | ||
conf, | ||
language, | ||
} from 'monaco-editor/esm/vs/basic-languages/pgsql/pgsql'; | ||
|
||
language.builtinFunctions.push( | ||
...[ | ||
// pg16 functions | ||
'any_value', | ||
'array_simple', | ||
'array_shuffle', | ||
'date_add', | ||
'date_substract', | ||
'erf', | ||
'erfc', | ||
'json_agg_strict', | ||
'json_array', | ||
'json_arrayagg', | ||
'json_object_agg_strict', | ||
'json_object_agg_unique', | ||
'json_object_agg_unique_strict', | ||
'json_objectagg', | ||
'jsonb_agg_strict', | ||
'jsonb_object_agg_strict', | ||
'jsonb_object_agg_unique', | ||
'jsonb_object_agg_unique_strict', | ||
'pg_input_is_valid', | ||
'pg_input_error_info', | ||
'pg_split_walfile_name', | ||
'random_normal', | ||
// pg17 functions | ||
'icu_unicode_version', | ||
'json', | ||
'json_exists', | ||
'json_query', | ||
'json_scalar', | ||
'json_serialize', | ||
'json_table', | ||
'json_value', | ||
'pg_basetype', | ||
'pg_column_toast_chunk_id', | ||
'pg_sync_replication_slots', | ||
'to_bin', | ||
'to_oct', | ||
'to_regtypemod', | ||
'unicode_assigned', | ||
'unicode_version', | ||
'uuid_extract_timestamp', | ||
'uuid_extract_version', | ||
'xmltext', | ||
], | ||
); | ||
|
||
// Re-sort the list of functions, and remove potential duplicates | ||
language.builtinFunctions = (language.builtinFunctions as string[]) | ||
.sort() | ||
.filter((x, i, a) => !i || x !== a[i - 1]); | ||
|
||
export { conf, language }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters