refactor: standard naming (#278)
* refactor: rename flinksql to flink * refactor: rename pgsql to postgresql * refactor: rename trinosql to trino * refactor: replace all default exports with named export * refactor: rename basicParser to basicSQL * refactor: rename basic-parser-types to types * refactor: replace arrow func with plain func
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import TrinoSQL from 'src/parser/trino';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { TrinoSQL } from 'src/parser/trino';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
|
||||
|
||||
const syntaxSql = fs.readFileSync(
|
||||
path.join(__dirname, 'fixtures', 'multipleStatement.sql'),
|
||||
@ -9,14 +9,14 @@ const syntaxSql = fs.readFileSync(
|
||||
);
|
||||
|
||||
describe('TrinoSQL Multiple Statements Syntax Suggestion', () => {
|
||||
const parser = new TrinoSQL();
|
||||
const trino = new TrinoSQL();
|
||||
|
||||
test('Create table ', () => {
|
||||
const pos: CaretPosition = {
|
||||
lineNumber: 1,
|
||||
column: 14,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE_CREATE
|
||||
);
|
||||
@ -30,7 +30,7 @@ describe('TrinoSQL Multiple Statements Syntax Suggestion', () => {
|
||||
lineNumber: 9,
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE
|
||||
);
|
||||
@ -44,7 +44,7 @@ describe('TrinoSQL Multiple Statements Syntax Suggestion', () => {
|
||||
lineNumber: 15,
|
||||
column: 13,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE
|
||||
);
|
||||
@ -58,7 +58,7 @@ describe('TrinoSQL Multiple Statements Syntax Suggestion', () => {
|
||||
lineNumber: 21,
|
||||
column: 65,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(syntaxSql, pos)?.syntax;
|
||||
const suggestion = syntaxes?.find(
|
||||
(syn) => syn.syntaxContextType === EntityContextType.TABLE
|
||||
);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import TrinoSQL from 'src/parser/trino';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { TrinoSQL } from 'src/parser/trino';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
|
||||
import { commentOtherLine } from 'test/helper';
|
||||
|
||||
const syntaxSql = fs.readFileSync(
|
||||
@ -9,7 +9,7 @@ const syntaxSql = fs.readFileSync(
|
||||
'utf-8'
|
||||
);
|
||||
|
||||
describe('PostgreSQL Syntax Suggestion with collect entity', () => {
|
||||
describe('PostgreSql Syntax Suggestion with collect entity', () => {
|
||||
const trino = new TrinoSQL();
|
||||
|
||||
test('select with no column', () => {
|
||||
|
@ -1,7 +1,7 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import TrinoSQL from 'src/parser/trino';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/basic-parser-types';
|
||||
import { TrinoSQL } from 'src/parser/trino';
|
||||
import { CaretPosition, EntityContextType } from 'src/parser/common/types';
|
||||
import { commentOtherLine } from 'test/helper';
|
||||
|
||||
const syntaxSql = fs.readFileSync(
|
||||
@ -10,12 +10,12 @@ const syntaxSql = fs.readFileSync(
|
||||
);
|
||||
|
||||
describe('Trino SQL Syntax Suggestion', () => {
|
||||
const parser = new TrinoSQL();
|
||||
const trino = new TrinoSQL();
|
||||
|
||||
test('Validate Syntax SQL', () => {
|
||||
expect(parser.validate(syntaxSql).length).not.toBe(0);
|
||||
expect(parser.validate(syntaxSql).length).not.toBe(0);
|
||||
expect(parser.validate(syntaxSql).length).not.toBe(0);
|
||||
expect(trino.validate(syntaxSql).length).not.toBe(0);
|
||||
expect(trino.validate(syntaxSql).length).not.toBe(0);
|
||||
expect(trino.validate(syntaxSql).length).not.toBe(0);
|
||||
});
|
||||
|
||||
test('Insert table ', () => {
|
||||
@ -23,7 +23,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 1,
|
||||
column: 18,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -41,7 +41,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
column: 20,
|
||||
};
|
||||
const syntaxes =
|
||||
parser.getSuggestionAtCaretPosition(commentOtherLine(syntaxSql, pos.lineNumber), pos)
|
||||
trino.getSuggestionAtCaretPosition(commentOtherLine(syntaxSql, pos.lineNumber), pos)
|
||||
?.syntax ?? [];
|
||||
|
||||
const suggestion = syntaxes?.find(
|
||||
@ -60,7 +60,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 5,
|
||||
column: 17,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -77,7 +77,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 7,
|
||||
column: 26,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -94,7 +94,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 9,
|
||||
column: 28,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -111,7 +111,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 11,
|
||||
column: 15,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -128,7 +128,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 13,
|
||||
column: 27,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -145,7 +145,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 15,
|
||||
column: 17,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -162,7 +162,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 17,
|
||||
column: 26,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -180,7 +180,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
column: 21,
|
||||
};
|
||||
const syntaxes =
|
||||
parser.getSuggestionAtCaretPosition(commentOtherLine(syntaxSql, pos.lineNumber), pos)
|
||||
trino.getSuggestionAtCaretPosition(commentOtherLine(syntaxSql, pos.lineNumber), pos)
|
||||
?.syntax ?? [];
|
||||
|
||||
const suggestion = syntaxes?.find(
|
||||
@ -198,7 +198,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 21,
|
||||
column: 22,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -215,7 +215,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 23,
|
||||
column: 30,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -233,7 +233,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 25,
|
||||
column: 37,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -251,7 +251,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 27,
|
||||
column: 31,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -269,7 +269,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 29,
|
||||
column: 32,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -287,7 +287,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 31,
|
||||
column: 28,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -304,7 +304,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 33,
|
||||
column: 21,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -321,7 +321,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 35,
|
||||
column: 27,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
@ -338,7 +338,7 @@ describe('Trino SQL Syntax Suggestion', () => {
|
||||
lineNumber: 37,
|
||||
column: 27,
|
||||
};
|
||||
const syntaxes = parser.getSuggestionAtCaretPosition(
|
||||
const syntaxes = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(syntaxSql, pos.lineNumber),
|
||||
pos
|
||||
)?.syntax;
|
||||
|
@ -1,20 +1,20 @@
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import TrinoSQL from 'src/parser/trino';
|
||||
import { CaretPosition } from 'src/parser/common/basic-parser-types';
|
||||
import { TrinoSQL } from 'src/parser/trino';
|
||||
import { CaretPosition } from 'src/parser/common/types';
|
||||
import { commentOtherLine } from 'test/helper';
|
||||
|
||||
const tokenSql = fs.readFileSync(path.join(__dirname, 'fixtures', 'tokenSuggestion.sql'), 'utf-8');
|
||||
|
||||
describe('Trino SQL Token Suggestion', () => {
|
||||
const parser = new TrinoSQL();
|
||||
const trino = new TrinoSQL();
|
||||
|
||||
test('After ALTER', () => {
|
||||
const pos: CaretPosition = {
|
||||
lineNumber: 1,
|
||||
column: 7,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -27,7 +27,7 @@ describe('Trino SQL Token Suggestion', () => {
|
||||
lineNumber: 3,
|
||||
column: 8,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -47,7 +47,7 @@ describe('Trino SQL Token Suggestion', () => {
|
||||
lineNumber: 5,
|
||||
column: 12,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -60,7 +60,7 @@ describe('Trino SQL Token Suggestion', () => {
|
||||
lineNumber: 7,
|
||||
column: 8,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -73,7 +73,7 @@ describe('Trino SQL Token Suggestion', () => {
|
||||
lineNumber: 9,
|
||||
column: 10,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -86,7 +86,7 @@ describe('Trino SQL Token Suggestion', () => {
|
||||
lineNumber: 11,
|
||||
column: 6,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
@ -105,7 +105,7 @@ describe('Trino SQL Token Suggestion', () => {
|
||||
lineNumber: 13,
|
||||
column: 8,
|
||||
};
|
||||
const suggestion = parser.getSuggestionAtCaretPosition(
|
||||
const suggestion = trino.getSuggestionAtCaretPosition(
|
||||
commentOtherLine(tokenSql, pos.lineNumber),
|
||||
pos
|
||||
)?.keywords;
|
||||
|
Reference in New Issue
Block a user