diff --git a/package.json b/package.json index 0d1587fc..491ffbef 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "vscode-db2i", "displayName": "Db2 for IBM i", "description": "Db2 for IBM i tools in VS Code", - "version": "1.7.0", + "version": "1.7.0-syntaxcheck2", "engines": { "vscode": "^1.95.0" }, diff --git a/src/language/providers/index.ts b/src/language/providers/index.ts index 44a3df44..589ad98e 100644 --- a/src/language/providers/index.ts +++ b/src/language/providers/index.ts @@ -3,6 +3,9 @@ import { formatProvider } from "./formatProvider"; import { hoverProvider, openProvider } from "./hoverProvider"; import { signatureProvider } from "./parameterProvider"; import { problemProvider } from "./problemProvider"; +import { Db2StatusProvider } from "./statusProvider"; + +export const sqlLanguageStatus = new Db2StatusProvider(); export function languageInit() { let functionality = []; @@ -13,7 +16,8 @@ export function languageInit() { signatureProvider, hoverProvider, openProvider, - problemProvider + problemProvider, + sqlLanguageStatus ); return functionality; diff --git a/src/language/providers/problemProvider.ts b/src/language/providers/problemProvider.ts index 0e0bc2a7..ad059f9f 100644 --- a/src/language/providers/problemProvider.ts +++ b/src/language/providers/problemProvider.ts @@ -18,7 +18,7 @@ export interface CompletionType { let currentTimeout: NodeJS.Timeout; let sqlDiagnosticCollection = languages.createDiagnosticCollection(`db2i-sql`); -function getTimeout() { +export function getCheckerTimeout() { return (Configuration.get(`syntaxCheckInterval`) || 1500); } @@ -67,6 +67,6 @@ export const problemProvider = workspace.onDidChangeTextDocument(e => { } } } - }, getTimeout()); + }, getCheckerTimeout()); } }); \ No newline at end of file diff --git a/src/language/providers/statusProvider.ts b/src/language/providers/statusProvider.ts new file mode 100644 index 00000000..242212d4 --- /dev/null +++ b/src/language/providers/statusProvider.ts @@ -0,0 +1,26 @@ +import { Disposable, languages, LanguageStatusSeverity } from "vscode"; +import { SQLStatementChecker } from "../../connection/syntaxChecker"; +import { getCheckerTimeout } from "./problemProvider"; + +export class Db2StatusProvider extends Disposable { + private item = languages.createLanguageStatusItem(`sql`, {language: `sql`}); + constructor() { + super(() => this.item.dispose()); + + this.item.name = `SQL Language Status`; + this.setState(false); + } + + setState(hasJob: Boolean) { + if (hasJob) { + const checker = SQLStatementChecker.get(); + const checkerTimeout = getCheckerTimeout() / 1000; + this.item.text = `SQL assistance available. ${checker ? `Syntax checking enabled (every ${checkerTimeout}s after editing)` : `Syntax checking not available.`}`; + this.item.detail = `You're connected to an IBM i - you can use the advanced SQL language tooling. ${checker ? `` : `Syntax checking not available. This means that the syntax checker did not install when connecting to this system.`}`; + this.item.severity = checker ? LanguageStatusSeverity.Information : LanguageStatusSeverity.Warning; + } else { + this.item.text = `Basic SQL assistance available`; + this.item.detail = `Connect to an IBM i to enable advanced SQL language tooling.`; + } + } +} \ No newline at end of file diff --git a/src/views/jobManager/jobManagerView.ts b/src/views/jobManager/jobManagerView.ts index e967a3a5..41c91a08 100644 --- a/src/views/jobManager/jobManagerView.ts +++ b/src/views/jobManager/jobManagerView.ts @@ -12,6 +12,7 @@ import { SelfCodesQuickPickItem } from "./selfCodes/selfCodesBrowser"; import { updateStatusBar } from "./statusBar"; import { setCancelButtonVisibility } from "../results"; import { JDBCOptions } from "@ibm/mapepire-js/dist/src/types"; +import { sqlLanguageStatus } from "../../language/providers"; const selectJobCommand = `vscode-db2i.jobManager.selectJob`; const activeColor = new vscode.ThemeColor(`minimapGutter.addedBackground`); @@ -304,6 +305,7 @@ export class JobManagerView implements TreeDataProvider { const selectedJob = JobManager.getSelection(); setCancelButtonVisibility(selectedJob && selectedJob.job.getStatus() === "busy"); + sqlLanguageStatus.setState(selectedJob !== undefined); commands.executeCommand(`setContext`, `vscode-db2i:jobManager.hasJob`, selectedJob !== undefined); }