Skip to content

Commit

Permalink
fix: BAD uri lacks scheme warning when the config is empty (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
Vigilans authored and jdneo committed Sep 2, 2019
1 parent 317ca34 commit 9c2b865
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
4 changes: 2 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))

Expand Down Expand Up @@ -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.
- Fix the issue that the checkstyle output may not be correctly parsed.
13 changes: 9 additions & 4 deletions src/checkstyleConfigurationManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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') ||
Expand All @@ -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(); });
}
Expand Down
4 changes: 2 additions & 2 deletions src/commands/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async function queryForConfiguration(): Promise<string | undefined> {
},
{
label: '$(link) Use URL...',
detail: 'Use a Checkstyle file accessible via HTTP.',
detail: 'Use a Checkstyle configuration accessible via HTTP.',
value: ':input',
},
{
Expand Down Expand Up @@ -81,7 +81,7 @@ async function browseForConfiguration(): Promise<string | undefined> {

async function inputConfiguration(): Promise<string | undefined> {
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,
Expand Down

0 comments on commit 9c2b865

Please sign in to comment.