Skip to content

test: suggestion wordRanges with range #409

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 19 additions & 1 deletion test/parser/flink/suggestion/multipleStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ describe('FlinkSQL Multiple Statements Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges?.length).toBe(2);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 16,
startIndex: 306,
endIndex: 307,
startColumn: 14,
endColumn: 16,
},
{
text: '.',
line: 16,
startIndex: 308,
endIndex: 308,
startColumn: 16,
endColumn: 17,
},
]);
});

test('Insert into table ', () => {
Expand Down
12 changes: 11 additions & 1 deletion test/parser/flink/suggestion/syntaxSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,17 @@ describe('Flink SQL Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['cat']);
expect(suggestion?.wordRanges?.length).toBe(1);
expect(suggestion?.wordRanges).toEqual([
{
text: 'cat',
line: 1,
startIndex: 13,
endIndex: 15,
startColumn: 14,
endColumn: 17,
},
]);
});

test('Select table', () => {
Expand Down
20 changes: 19 additions & 1 deletion test/parser/hive/suggestion/multipleStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ describe('HiveSQL Multiple Statements Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges?.length).toBe(2);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 9,
startIndex: 272,
endIndex: 273,
startColumn: 14,
endColumn: 16,
},
{
text: '.',
line: 9,
startIndex: 274,
endIndex: 274,
startColumn: 16,
endColumn: 17,
},
]);
});

test('Insert into table ', () => {
Expand Down
28 changes: 27 additions & 1 deletion test/parser/hive/suggestion/syntaxSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,33 @@ describe('Hive SQL Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
expect(suggestion?.wordRanges?.length).toBe(3);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 1,
startIndex: 12,
endIndex: 13,
startColumn: 13,
endColumn: 15,
},
{
text: '.',
line: 1,
startIndex: 14,
endIndex: 14,
startColumn: 15,
endColumn: 16,
},
{
text: 'tb',
line: 1,
startIndex: 15,
endIndex: 16,
startColumn: 16,
endColumn: 18,
},
]);
});

test('Select table ', () => {
Expand Down
20 changes: 19 additions & 1 deletion test/parser/impala/suggestion/multipleStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ describe('ImpalaSQL Multiple Statements Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges?.length).toBe(2);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 9,
startIndex: 203,
endIndex: 204,
startColumn: 14,
endColumn: 16,
},
{
text: '.',
line: 9,
startIndex: 205,
endIndex: 205,
startColumn: 16,
endColumn: 17,
},
]);
});

test('Insert into table ', () => {
Expand Down
28 changes: 27 additions & 1 deletion test/parser/impala/suggestion/syntaxSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,33 @@ describe('Impala SQL Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['cat', '.', 'a']);
expect(suggestion?.wordRanges?.length).toBe(3);
expect(suggestion?.wordRanges).toEqual([
{
text: 'cat',
line: 1,
startIndex: 14,
endIndex: 16,
startColumn: 15,
endColumn: 18,
},
{
text: '.',
line: 1,
startIndex: 17,
endIndex: 17,
startColumn: 18,
endColumn: 19,
},
{
text: 'a',
line: 1,
startIndex: 18,
endIndex: 18,
startColumn: 19,
endColumn: 20,
},
]);
});

test('Function call', () => {
Expand Down
20 changes: 19 additions & 1 deletion test/parser/mysql/suggestion/multipleStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ describe('MySQL Multiple Statements Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges?.length).toBe(2);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 9,
startIndex: 306,
endIndex: 307,
startColumn: 14,
endColumn: 16,
},
{
text: '.',
line: 9,
startIndex: 308,
endIndex: 308,
startColumn: 16,
endColumn: 17,
},
]);
});

test('Insert into table ', () => {
Expand Down
28 changes: 27 additions & 1 deletion test/parser/mysql/suggestion/syntaxSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,33 @@ describe('MySQL Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
expect(suggestion?.wordRanges?.length).toBe(3);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 1,
startIndex: 12,
endIndex: 13,
startColumn: 13,
endColumn: 15,
},
{
text: '.',
line: 1,
startIndex: 14,
endIndex: 14,
startColumn: 15,
endColumn: 16,
},
{
text: 'tb',
line: 1,
startIndex: 15,
endIndex: 16,
startColumn: 16,
endColumn: 18,
},
]);
});

test('Select table ', () => {
Expand Down
20 changes: 19 additions & 1 deletion test/parser/postgresql/suggestion/multipleStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,24 @@ describe('PgSQL Multiple Statements Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges?.length).toBe(2);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 21,
startIndex: 682,
endIndex: 683,
startColumn: 62,
endColumn: 64,
},
{
text: '.',
line: 21,
startIndex: 684,
endIndex: 684,
startColumn: 64,
endColumn: 65,
},
]);
});
});
12 changes: 11 additions & 1 deletion test/parser/postgresql/suggestion/suggestionWithEntity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,17 @@ describe('PostgreSql Syntax Suggestion with collect entity', () => {
(syn) => syn.syntaxContextType === EntityContextType.COLUMN
);
expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['a_column']);
expect(suggestion?.wordRanges?.length).toBe(1);
expect(suggestion?.wordRanges).toEqual([
{
text: 'a_column',
line: 13,
startIndex: 399,
endIndex: 406,
startColumn: 27,
endColumn: 35,
},
]);

const entities = postgre.getAllEntities(sql, pos);
expect(entities.length).toBe(1);
Expand Down
28 changes: 27 additions & 1 deletion test/parser/postgresql/suggestion/syntaxSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,33 @@ describe('Postgre SQL Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
expect(suggestion?.wordRanges?.length).toBe(3);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 3,
startIndex: 88,
endIndex: 89,
startColumn: 13,
endColumn: 15,
},
{
text: '.',
line: 3,
startIndex: 90,
endIndex: 90,
startColumn: 15,
endColumn: 16,
},
{
text: 'tb',
line: 3,
startIndex: 91,
endIndex: 92,
startColumn: 16,
endColumn: 18,
},
]);
});

test('Alter table ', () => {
Expand Down
20 changes: 19 additions & 1 deletion test/parser/spark/suggestion/multipleStatement.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,25 @@ describe('SparkSQL Multiple Statements Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.']);
expect(suggestion?.wordRanges?.length).toBe(2);
expect(suggestion?.wordRanges).toEqual([
{
endColumn: 17,
endIndex: 258,
line: 9,
startColumn: 15,
startIndex: 257,
text: 'db',
},
{
endColumn: 18,
endIndex: 259,
line: 9,
startColumn: 17,
startIndex: 259,
text: '.',
},
]);
});

test('Insert into table ', () => {
Expand Down
28 changes: 27 additions & 1 deletion test/parser/spark/suggestion/syntaxSuggestion.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,33 @@ describe('Spark SQL Syntax Suggestion', () => {
);

expect(suggestion).not.toBeUndefined();
expect(suggestion?.wordRanges.map((token) => token.text)).toEqual(['db', '.', 'tb']);
expect(suggestion?.wordRanges?.length).toBe(3);
expect(suggestion?.wordRanges).toEqual([
{
text: 'db',
line: 1,
startIndex: 12,
endIndex: 13,
startColumn: 13,
endColumn: 15,
},
{
text: '.',
line: 1,
startIndex: 14,
endIndex: 14,
startColumn: 15,
endColumn: 16,
},
{
text: 'tb',
line: 1,
startIndex: 15,
endIndex: 16,
startColumn: 16,
endColumn: 18,
},
]);
});

test('Select table ', () => {
Expand Down
Loading