diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d95d70..a1f73cb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,7 +3,7 @@ All notable changes to the "vscode-checkstyle" extension will be documented in t Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. -##[1.2.0] +## [1.2.0] ### Added - Open the Problems panel when click the status icon in the status bar. ([#176](https://github.com/jdneo/vscode-checkstyle/issues/176)) @@ -104,4 +104,4 @@ Initial release for the new Checkstyle extension, the new extension contains fol - Add setting ```checkstyle.autocheck```. ### Fixed -- Fix the issue that the checkstyle output may not be correctly parsed. \ No newline at end of file +- Fix the issue that the checkstyle output may not be correctly parsed. diff --git a/src/checkstyleConfigurationManager.ts b/src/checkstyleConfigurationManager.ts index 37d723a..01038bb 100644 --- a/src/checkstyleConfigurationManager.ts +++ b/src/checkstyleConfigurationManager.ts @@ -28,14 +28,19 @@ class CheckstyleConfigurationManager implements vscode.Disposable { } } - public get configUri(): vscode.Uri { - // Starts with / or X:/ or X:\, where X is a Windows disk drive - if (/^([c-zC-Z]:)?[/\\]/.test(this.config.path)) { + public get configUri(): vscode.Uri | undefined { + if (!this.config.path) { + return undefined; + } else if (/^([c-zC-Z]:)?[/\\]/.test(this.config.path)) { // Starts with / or X:/ or X:\, where X is a Windows disk drive return vscode.Uri.file(this.config.path); } else { return vscode.Uri.parse(this.config.path); } } + public get isConfigFromLocalFs(): boolean { + return !!(this.configUri && this.configUri.scheme === 'file' + && !Object.values(BuiltinConfiguration).includes(this.config.path)); + } public onDidChangeConfiguration(e: vscode.ConfigurationChangeEvent): void { if (e.affectsConfiguration('java.checkstyle.configuration') || @@ -54,7 +59,7 @@ class CheckstyleConfigurationManager implements vscode.Disposable { this.configWatcher.close(); this.configWatcher = undefined; } - if (this.configUri.scheme === 'file' && !Object.values(BuiltinConfiguration).includes(this.config.path)) { + if (this.isConfigFromLocalFs) { this.configWatcher = chokidar.watch(this.config.path); this.configWatcher.on('all', (_event: string) => { this.syncServer(); }); } diff --git a/src/commands/config.ts b/src/commands/config.ts index fde3b7a..2dabb26 100644 --- a/src/commands/config.ts +++ b/src/commands/config.ts @@ -44,7 +44,7 @@ async function queryForConfiguration(): Promise { }, { label: '$(link) Use URL...', - detail: 'Use a Checkstyle file accessible via HTTP.', + detail: 'Use a Checkstyle configuration accessible via HTTP.', value: ':input', }, { @@ -81,7 +81,7 @@ async function browseForConfiguration(): Promise { async function inputConfiguration(): Promise { const configPath: string | undefined = await window.showInputBox({ - prompt: 'Enter configuration path here.', + prompt: 'Enter configuration URL here.', placeHolder: 'Supports http(s)://...', value: 'https://', ignoreFocusOut: true,