Skip to content

Commit

Permalink
feat: support trinosql language (DTStack#56)
Browse files Browse the repository at this point in the history
  • Loading branch information
HaydenOrz authored Oct 25, 2023
1 parent 6d0eabf commit adbd3df
Show file tree
Hide file tree
Showing 5 changed files with 859 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export { registerFlinkSQLLanguage } from './flinksql/flinksql.contribution';
export { registerSparkSQLLanguage } from './sparksql/sparksql.contribution';
export { registerHiveSQLLanguage } from './hivesql/hivesql.contribution';
export { registerTrinoSQLLanguage } from './trinosql/trinosql.contribution';

export * from './_.contribution';
export * from './languageService';
Expand Down
18 changes: 18 additions & 0 deletions src/trinosql/TrinoSQLWorker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { worker } from '../fillers/monaco-editor-core';
import TrinoSQL from 'dt-sql-parser/dist/parser/trinosql';
import { ICreateData } from '../_.contribution';
import { BaseSQLWorker } from '../baseSQLWorker';

export class TrinoSQLWorker extends BaseSQLWorker {
protected _ctx: worker.IWorkerContext;
protected parser: TrinoSQL;
constructor(ctx: worker.IWorkerContext, createData: ICreateData) {
super();
this._ctx = ctx;
this.parser = new TrinoSQL();
}
}

export function create(ctx: worker.IWorkerContext, createData: ICreateData): TrinoSQLWorker {
return new TrinoSQLWorker(ctx, createData);
}
36 changes: 36 additions & 0 deletions src/trinosql/trinosql.contribution.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import {
CompletionService,
diagnosticDefault,
LanguageServiceDefaults,
LanguageServiceDefaultsImpl,
loadLanguage,
modeConfigurationDefault,
registerLanguage
} from '../_.contribution';
import { languages } from '../fillers/monaco-editor-core';

const languageId = 'trinosql';

registerTrinoSQLLanguage;

export function registerTrinoSQLLanguage(completionService?: CompletionService) {
registerLanguage({
id: languageId,
extensions: [],
aliases: ['TrinoSQL', 'trinosql', 'trino', 'prestosql'],
loader: () => import('./trinosql')
});

loadLanguage(languageId);

const defaults: LanguageServiceDefaults = new LanguageServiceDefaultsImpl(
languageId,
diagnosticDefault,
modeConfigurationDefault,
completionService
);

languages.onLanguage(languageId, () => {
import('../setupLanguageMode').then((mode) => mode.setupLanguageMode(defaults));
});
}
Loading

0 comments on commit adbd3df

Please sign in to comment.