Skip to content
Open
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
11 changes: 10 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vscode-db2i",
"displayName": "Db2 for IBM i",
"description": "Db2 for IBM i tools in VS Code",
"version": "1.14.0",
"version": "1.14.0-dev1",
"engines": {
"vscode": "^1.95.0"
},
Expand Down Expand Up @@ -365,6 +365,11 @@
]
},
"commands": [
{
"command": "vscode-db2i.language.getStatements",
"title": "Get statements",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.json.pasteGenerator",
"title": "Paste JSON as SQL",
Expand Down Expand Up @@ -794,6 +799,10 @@
],
"menus": {
"commandPalette": [
{
"command": "vscode-db2i.language.getStatements",
"when": "never"
},
{
"command": "vscode-db2i.getStatementUri",
"when": "editorLangId == sql"
Expand Down
9 changes: 9 additions & 0 deletions src/contributes.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
]
},
"commands": [
{
"command": "vscode-db2i.language.getStatements",
"title": "Get statements",
"category": "Db2 for i"
},
{
"command": "vscode-db2i.json.pasteGenerator",
"title": "Paste JSON as SQL",
Expand All @@ -114,6 +119,10 @@
],
"menus": {
"commandPalette": [
{
"command": "vscode-db2i.language.getStatements",
"when": "never"
},
{
"command": "vscode-db2i.getStatementUri",
"when": "editorLangId == sql"
Expand Down
28 changes: 27 additions & 1 deletion src/language/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { commands, Uri, window, workspace } from "vscode";
import { completionProvider } from "./providers/completionProvider";
import { formatProvider } from "./providers/formatProvider";
import { signatureProvider } from "./providers/parameterProvider";
import { problemProvider } from "./providers/problemProvider";
import { getSqlDocument } from "./providers/logic/parse";
import { StatementType } from "./sql/types";

export function languageInit() {
let functionality = [];
Expand All @@ -12,6 +15,29 @@ export function languageInit() {
signatureProvider,
problemProvider
);


functionality.push(...registerLanguageCommands());

return functionality;
}

function registerLanguageCommands() {
return [
// Programmable API that is not callable through the UI.
// Solely for the use for other extensions.
commands.registerCommand(`vscode-db2i.language.getStatements`, async (uri?: Uri) => {
const document = await workspace.openTextDocument(uri);

if (document) {
const doc = getSqlDocument(document);
if (doc) {
const groups = doc.getStatementGroups();
return groups.map(g => ({
range: g.range,
type: g.statements[0] ? g.statements[0].type : StatementType.Unknown
}));
}
}
})
]
}
Loading