Skip to content
This repository has been archived by the owner on Nov 18, 2022. It is now read-only.

Commit

Permalink
Merge pull request #382 from chuck-flowers/master
Browse files Browse the repository at this point in the history
Changes the readonly fields in the
  • Loading branch information
nrc committed Jul 24, 2018
2 parents f2752fe + c2a41e0 commit f6ed71b
Showing 1 changed file with 44 additions and 25 deletions.
69 changes: 44 additions & 25 deletions src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,41 +30,60 @@ function fromStringToRevealOutputChannelOn(value: string): RevealOutputChannelOn
}

export class RLSConfiguration {
public readonly rustupPath: string;
public readonly logToFile: boolean;
public readonly revealOutputChannelOn: RevealOutputChannelOn = RevealOutputChannelOn.Never;
public readonly updateOnStartup: boolean;
public readonly channel: string;
public readonly componentName: string;
public get rustupPath(): string {
return this.configuration.get('rust-client.rustupPath', 'rustup');
}

public get logToFile(): boolean {
return this.configuration.get<boolean>('rust-client.logToFile', false);
}

public get revealOutputChannelOn(): RevealOutputChannelOn {
return RLSConfiguration.readRevealOutputChannelOn(this.configuration);
}

public get updateOnStartup(): boolean {
return this.configuration.get<boolean>('rust-client.updateOnStartup', true);
}

public get channel(): string {
return RLSConfiguration.readChannel(this.rustupPath, this.configuration, this.wsPath);
}

public get componentName(): string {
return this.configuration.get('rust-client.rls-name', 'rls');
}

/**
* If specified, RLS will be spawned by executing a file at the given path.
*/
public readonly rlsPath: string | null;
public get rlsPath(): string | null {
// Path to the rls. Prefer `rust-client.rlsPath` if present, otherwise consider
// the depreacted `rls.path` setting.
const rlsPath = this.configuration.get('rls.path', null);
if (rlsPath) {
console.warn('`rls.path` has been deprecated; prefer `rust-client.rlsPath`');
}

const rustClientRlsPath = this.configuration.get('rust-client.rlsPath', null);
if (!rustClientRlsPath) {
return rlsPath;
}

return rustClientRlsPath;
}

private readonly configuration: WorkspaceConfiguration;
private readonly wsPath: string;

public static loadFromWorkspace(wsPath: string): RLSConfiguration {
const configuration = workspace.getConfiguration();
return new RLSConfiguration(configuration, wsPath);
}

private constructor(configuration: WorkspaceConfiguration, wsPath: string) {
this.rustupPath = configuration.get('rust-client.rustupPath', 'rustup');
this.logToFile = configuration.get<boolean>('rust-client.logToFile', false);
this.revealOutputChannelOn = RLSConfiguration.readRevealOutputChannelOn(configuration);
this.updateOnStartup = configuration.get<boolean>('rust-client.updateOnStartup', true);

this.channel = RLSConfiguration.readChannel(this.rustupPath, configuration, wsPath);
this.componentName = configuration.get('rust-client.rls-name', 'rls');

// Path to the rls. Prefer `rust-client.rlsPath` if present, otherwise consider
// the depreacted `rls.path` setting.
const rlsPath = configuration.get('rls.path', null);
if (rlsPath) {
console.warn('`rls.path` has been deprecated; prefer `rust-client.rlsPath`');
}
this.rlsPath = configuration.get('rust-client.rlsPath', null);
if (!this.rlsPath) {
this.rlsPath = rlsPath;
}
this.configuration = configuration;
this.wsPath = wsPath;
}

public rustupConfig(): RustupConfig {
Expand Down

0 comments on commit f6ed71b

Please sign in to comment.