diff --git a/extensions/vscode-aml/README.md b/extensions/vscode-aml/README.md index e12c44417..3e8cdc301 100644 --- a/extensions/vscode-aml/README.md +++ b/extensions/vscode-aml/README.md @@ -16,16 +16,17 @@ This Visual Studio Code extension provides language support for [AML](https://az ## Roadmap -- graph preview +- diagram preview + open in Azimutt - convert AML to PostgreSQL, JSON, DOT, Mermaid, Markdown (Command Palette) - convert SQL and JSON to AML (Command Palette) -- Add parsing errors -- auto-complete -- quick-fixes (code actions) -- Go-to-definition for relations (cf https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.DocumentSymbolProvider.html) -- hover info -- Add diagram preview & Open in Azimutt -- Add AML support in Markdown +- Add parsing errors ([createDiagnosticCollection](https://code.visualstudio.com/api/references/vscode-api#languages.createDiagnosticCollection)?) +- auto-complete (cf [registerCompletionItemProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCompletionItemProvider.html)) +- rename (cf [registerRenameProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerRenameProvider.html)) +- hover infos (cf [registerHoverProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerHoverProvider.html)) +- go-to-definition (cf [registerDefinitionProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerDefinitionProvider.html) and [registerImplementationProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerImplementationProvider.html)) +- quick-fixes (cf [registerCodeActionProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCodeActionProvider.html)) +- hints with actions (cf [registerCodeLensProvider](https://microsoft.github.io/monaco-editor/typedoc/functions/languages.registerCodeLensProvider.html)) +- AML support in Markdown - Connect to a database diff --git a/extensions/vscode-aml/src/web/extension.ts b/extensions/vscode-aml/src/web/extension.ts index da5dd75a3..60ff5df3d 100644 --- a/extensions/vscode-aml/src/web/extension.ts +++ b/extensions/vscode-aml/src/web/extension.ts @@ -36,7 +36,7 @@ export function activate(context: ExtensionContext) { vscode.commands.registerTextEditorCommand('aml.fromSQL', (editor: TextEditor) => convertSqlToAml(editor)), vscode.commands.registerTextEditorCommand('aml.convert', (editor: TextEditor) => convertAmlToDialect(editor)), vscode.commands.registerTextEditorCommand('aml.preview', (editor: TextEditor) => previewAml(editor, context)), - vscode.languages.registerDocumentSymbolProvider({scheme: 'file', language: 'aml'}, new AmlDocumentSymbolProvider()), + vscode.languages.registerDocumentSymbolProvider({language: 'aml'}, new AmlDocumentSymbolProvider()), ) } @@ -169,7 +169,7 @@ const updateAmlPreviewReal = (document: TextDocument, panel: WebviewPanel) => { function buildAmlPreview(aml: string): string | undefined { // const res = parseAml(aml) // const content = res.result ? generateMermaid(res.result) : aml // TODO: render mermaid as svg - const content = aml + const content = aml.trim() return ` @@ -178,11 +178,16 @@ function buildAmlPreview(aml: string): string | undefined { AML preview + Open in Azimutt
${content}
` } +function openInAzimuttUrl(aml: string): string { + return 'https://azimutt.app/create?aml=' + encodeURIComponent(aml) +} + // see https://microsoft.github.io/monaco-editor/typedoc/interfaces/languages.DocumentSymbolProvider.html class AmlDocumentSymbolProvider implements DocumentSymbolProvider { provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult { @@ -191,7 +196,7 @@ class AmlDocumentSymbolProvider implements DocumentSymbolProvider { let match: RegExpExecArray | null = null while (match = regex.exec(document.getText())) { const [all, lr, keyword, name] = match || [] - if (name === 'rel') continue + if (name === 'rel') { continue } const range = new Range( document.positionAt(match.index + lr.length + (keyword || '').length), document.positionAt(match.index + all.length)