Skip to content

Commit dbc8582

Browse files
committed
feat(postgre): changed to camelCase for postgreSQL
1 parent 2d552eb commit dbc8582

10 files changed

+19541
-20378
lines changed

src/grammar/postgresql/PostgreSqlParser.g4

+923-969
Large diffs are not rendered by default.

src/lib/postgresql/PostgreSqlParser.interp

+249-253
Large diffs are not rendered by default.

src/lib/postgresql/PostgreSqlParser.ts

+16,406-17,046
Large diffs are not rendered by default.

src/lib/postgresql/PostgreSqlParserListener.ts

+1,191-1,284
Large diffs are not rendered by default.

src/lib/postgresql/PostgreSqlParserVisitor.ts

+711-765
Large diffs are not rendered by default.

src/parser/postgresql/index.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ export class PostgreSQL extends BasicSQL<PostgreSqlLexer, ProgramContext, Postgr
2323
}
2424

2525
protected preferredRules: Set<number> = new Set([
26-
PostgreSqlParser.RULE_table_name_create, // table name
27-
PostgreSqlParser.RULE_table_name, // table name that will be created
28-
PostgreSqlParser.RULE_function_name, // function name
29-
PostgreSqlParser.RULE_function_name_create, // function name that will be created
30-
PostgreSqlParser.RULE_schema_name_create, // schema name that will be created
31-
PostgreSqlParser.RULE_schema_name, // schema name
32-
PostgreSqlParser.RULE_view_name_create, // view name that will be created
33-
PostgreSqlParser.RULE_view_name, // view name
34-
PostgreSqlParser.RULE_database_name_create, // database name that will be created
35-
PostgreSqlParser.RULE_database_name, // database name
36-
PostgreSqlParser.RULE_procedure_name_create, // procedure name that will be created
37-
PostgreSqlParser.RULE_procedure_name, // procedure name
38-
PostgreSqlParser.RULE_column_name_create, // column name that will be created
39-
PostgreSqlParser.RULE_column_name, // column name
26+
PostgreSqlParser.RULE_tableNameCreate, // table name
27+
PostgreSqlParser.RULE_tableName, // table name that will be created
28+
PostgreSqlParser.RULE_functionName, // function name
29+
PostgreSqlParser.RULE_functionNameCreate, // function name that will be created
30+
PostgreSqlParser.RULE_schemaNameCreate, // schema name that will be created
31+
PostgreSqlParser.RULE_schemaName, // schema name
32+
PostgreSqlParser.RULE_viewNameCreate, // view name that will be created
33+
PostgreSqlParser.RULE_viewName, // view name
34+
PostgreSqlParser.RULE_databaseNameCreate, // database name that will be created
35+
PostgreSqlParser.RULE_databaseName, // database name
36+
PostgreSqlParser.RULE_procedureNameCreate, // procedure name that will be created
37+
PostgreSqlParser.RULE_procedureName, // procedure name
38+
PostgreSqlParser.RULE_columnNameCreate, // column name that will be created
39+
PostgreSqlParser.RULE_columnName, // column name
4040
]);
4141

4242
protected get splitListener() {
@@ -69,59 +69,59 @@ export class PostgreSQL extends BasicSQL<PostgreSqlLexer, ProgramContext, Postgr
6969

7070
let syntaxContextType: EntityContextType | StmtContextType | undefined = void 0;
7171
switch (ruleType) {
72-
case PostgreSqlParser.RULE_table_name_create: {
72+
case PostgreSqlParser.RULE_tableNameCreate: {
7373
syntaxContextType = EntityContextType.TABLE_CREATE;
7474
break;
7575
}
76-
case PostgreSqlParser.RULE_table_name: {
76+
case PostgreSqlParser.RULE_tableName: {
7777
syntaxContextType = EntityContextType.TABLE;
7878
break;
7979
}
80-
case PostgreSqlParser.RULE_function_name_create: {
80+
case PostgreSqlParser.RULE_functionNameCreate: {
8181
syntaxContextType = EntityContextType.FUNCTION_CREATE;
8282
break;
8383
}
84-
case PostgreSqlParser.RULE_function_name: {
84+
case PostgreSqlParser.RULE_functionName: {
8585
syntaxContextType = EntityContextType.FUNCTION;
8686
break;
8787
}
88-
case PostgreSqlParser.RULE_schema_name_create: {
88+
case PostgreSqlParser.RULE_schemaNameCreate: {
8989
syntaxContextType = EntityContextType.DATABASE_CREATE;
9090
break;
9191
}
92-
case PostgreSqlParser.RULE_schema_name: {
92+
case PostgreSqlParser.RULE_schemaName: {
9393
syntaxContextType = EntityContextType.DATABASE;
9494
break;
9595
}
96-
case PostgreSqlParser.RULE_view_name_create: {
96+
case PostgreSqlParser.RULE_viewNameCreate: {
9797
syntaxContextType = EntityContextType.VIEW_CREATE;
9898
break;
9999
}
100-
case PostgreSqlParser.RULE_view_name: {
100+
case PostgreSqlParser.RULE_viewName: {
101101
syntaxContextType = EntityContextType.VIEW;
102102
break;
103103
}
104-
case PostgreSqlParser.RULE_database_name_create: {
104+
case PostgreSqlParser.RULE_databaseNameCreate: {
105105
syntaxContextType = EntityContextType.DATABASE_CREATE;
106106
break;
107107
}
108-
case PostgreSqlParser.RULE_database_name: {
108+
case PostgreSqlParser.RULE_databaseName: {
109109
syntaxContextType = EntityContextType.DATABASE;
110110
break;
111111
}
112-
case PostgreSqlParser.RULE_procedure_name_create: {
112+
case PostgreSqlParser.RULE_procedureNameCreate: {
113113
syntaxContextType = EntityContextType.PROCEDURE_CREATE;
114114
break;
115115
}
116-
case PostgreSqlParser.RULE_procedure_name: {
116+
case PostgreSqlParser.RULE_procedureName: {
117117
syntaxContextType = EntityContextType.PROCEDURE;
118118
break;
119119
}
120-
case PostgreSqlParser.RULE_column_name_create: {
120+
case PostgreSqlParser.RULE_columnNameCreate: {
121121
syntaxContextType = EntityContextType.COLUMN_CREATE;
122122
break;
123123
}
124-
case PostgreSqlParser.RULE_column_name: {
124+
case PostgreSqlParser.RULE_columnName: {
125125
syntaxContextType = EntityContextType.COLUMN;
126126
break;
127127
}

src/parser/postgresql/postgreEntityCollector.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
type QueryCreateTableContext,
1919
type SelectStatementContext,
2020
type SingleStmtContext,
21-
Table_refContext,
21+
TableRefContext,
2222
type TableNameContext,
2323
type TableNameCreateContext,
2424
type ViewNameContext,
@@ -47,7 +47,7 @@ export class PostgreSqlEntityCollector extends EntityCollector implements Postgr
4747
? [
4848
{
4949
attrName: AttrName.alias,
50-
endContextList: [Table_refContext.name],
50+
endContextList: [TableRefContext.name],
5151
},
5252
]
5353
: undefined
@@ -67,7 +67,7 @@ export class PostgreSqlEntityCollector extends EntityCollector implements Postgr
6767
? [
6868
{
6969
attrName: AttrName.alias,
70-
endContextList: [Table_refContext.name],
70+
endContextList: [TableRefContext.name],
7171
},
7272
]
7373
: undefined

src/parser/postgresql/postgreErrorListener.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ import { PostgreSqlParser } from '../../lib/postgresql/PostgreSqlParser';
55

66
export class PostgreSqlErrorListener extends ParseErrorListener {
77
private objectNames: Map<number, string> = new Map([
8-
[PostgreSqlParser.RULE_database_name, 'database'],
9-
[PostgreSqlParser.RULE_database_name_create, 'database'],
10-
[PostgreSqlParser.RULE_table_name, 'table'],
11-
[PostgreSqlParser.RULE_table_name_create, 'table'],
12-
[PostgreSqlParser.RULE_view_name, 'view'],
13-
[PostgreSqlParser.RULE_view_name_create, 'view'],
14-
[PostgreSqlParser.RULE_function_name, 'function'],
15-
[PostgreSqlParser.RULE_function_name_create, 'function'],
16-
[PostgreSqlParser.RULE_column_name, 'column'],
17-
[PostgreSqlParser.RULE_column_name_create, 'column'],
18-
[PostgreSqlParser.RULE_schema_name_create, 'schema'],
19-
[PostgreSqlParser.RULE_schema_name, 'schema'],
20-
[PostgreSqlParser.RULE_procedure_name_create, 'procedure'],
21-
[PostgreSqlParser.RULE_procedure_name, 'procedure'],
8+
[PostgreSqlParser.RULE_databaseName, 'database'],
9+
[PostgreSqlParser.RULE_databaseNameCreate, 'database'],
10+
[PostgreSqlParser.RULE_tableName, 'table'],
11+
[PostgreSqlParser.RULE_tableNameCreate, 'table'],
12+
[PostgreSqlParser.RULE_viewName, 'view'],
13+
[PostgreSqlParser.RULE_viewNameCreate, 'view'],
14+
[PostgreSqlParser.RULE_functionName, 'function'],
15+
[PostgreSqlParser.RULE_functionNameCreate, 'function'],
16+
[PostgreSqlParser.RULE_columnName, 'column'],
17+
[PostgreSqlParser.RULE_columnNameCreate, 'column'],
18+
[PostgreSqlParser.RULE_schemaNameCreate, 'schema'],
19+
[PostgreSqlParser.RULE_schemaName, 'schema'],
20+
[PostgreSqlParser.RULE_procedureNameCreate, 'procedure'],
21+
[PostgreSqlParser.RULE_procedureName, 'procedure'],
2222
]);
2323

2424
public getExpectedText(parser: Parser, token: Token) {
@@ -57,23 +57,23 @@ export class PostgreSqlErrorListener extends ParseErrorListener {
5757
const [ruleType] = candidate;
5858
const name = this.objectNames.get(ruleType);
5959
switch (ruleType) {
60-
case PostgreSqlParser.RULE_table_name:
61-
case PostgreSqlParser.RULE_function_name:
62-
case PostgreSqlParser.RULE_schema_name:
63-
case PostgreSqlParser.RULE_view_name:
64-
case PostgreSqlParser.RULE_database_name:
65-
case PostgreSqlParser.RULE_procedure_name:
66-
case PostgreSqlParser.RULE_column_name: {
60+
case PostgreSqlParser.RULE_tableName:
61+
case PostgreSqlParser.RULE_functionName:
62+
case PostgreSqlParser.RULE_schemaName:
63+
case PostgreSqlParser.RULE_viewName:
64+
case PostgreSqlParser.RULE_databaseName:
65+
case PostgreSqlParser.RULE_procedureName:
66+
case PostgreSqlParser.RULE_columnName: {
6767
result.push(`{existing}${name}`);
6868
break;
6969
}
70-
case PostgreSqlParser.RULE_table_name_create:
71-
case PostgreSqlParser.RULE_function_name_create:
72-
case PostgreSqlParser.RULE_schema_name_create:
73-
case PostgreSqlParser.RULE_view_name_create:
74-
case PostgreSqlParser.RULE_database_name_create:
75-
case PostgreSqlParser.RULE_procedure_name_create:
76-
case PostgreSqlParser.RULE_column_name_create: {
70+
case PostgreSqlParser.RULE_tableNameCreate:
71+
case PostgreSqlParser.RULE_functionNameCreate:
72+
case PostgreSqlParser.RULE_schemaNameCreate:
73+
case PostgreSqlParser.RULE_viewNameCreate:
74+
case PostgreSqlParser.RULE_databaseNameCreate:
75+
case PostgreSqlParser.RULE_procedureNameCreate:
76+
case PostgreSqlParser.RULE_columnNameCreate: {
7777
result.push(`{new}${name}`);
7878
break;
7979
}

test/parser/postgresql/listener.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe('PostgreSQL Listener Tests', () => {
1111
test('Listener enterTableName', async () => {
1212
class MyListener extends PostgreSqlParserListener {
1313
result = '';
14-
enterTable_ref = (ctx) => {
14+
enterTableRef = (ctx) => {
1515
this.result = ctx.getText().toLowerCase();
1616
};
1717
}

test/parser/postgresql/visitor.test.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('MySQL Visitor Tests', () => {
2121
visitProgram = (ctx) => {
2222
return this.visitChildren(ctx);
2323
};
24-
visitTable_ref = (ctx) => {
24+
visitTableRef = (ctx) => {
2525
return ctx.getText().toLowerCase();
2626
};
2727
}

0 commit comments

Comments
 (0)