forked from DTStack/dt-sql-parser
-
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.
feat: support trinosql language (DTStack#56)
- Loading branch information
Showing
5 changed files
with
859 additions
and
0 deletions.
There are no files selected for viewing
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
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,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); | ||
} |
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,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)); | ||
}); | ||
} |
Oops, something went wrong.