Skip to content

Commit

Permalink
eclipse-theiaGH-6432: Deprecated getDefaultWorkspacePath.
Browse files Browse the repository at this point in the history
Use `WorkspaceService#getDefaultWorkspaceUri` instead.

Closes eclipse-theia#6432

Signed-off-by: Akos Kitta <[email protected]>
  • Loading branch information
Akos Kitta authored and akosyakov committed Feb 24, 2020
1 parent c009da4 commit 8ad626d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- [cli] enable static compression of build artifacts [#6266](https://github.com/eclipse-theia/theia/pull/6266)
- to disable pass `--no-static-compression` to `theia build` or `theia watch`.
- [workspace] Deprecated `getDefaultWorkspacePath` on the `WorkspaceService` as the method name was misleading. Use `getDefaultWorkspaceUri` instead. [#6432](https://github.com/eclipse-theia/theia/issues/6432)

Breaking changes:

Expand Down
25 changes: 20 additions & 5 deletions packages/workspace/src/browser/workspace-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export class WorkspaceService implements FrontendApplicationContribution {
@postConstruct()
protected async init(): Promise<void> {
this.applicationName = FrontendApplicationConfigProvider.get().applicationName;
const wpUriString = await this.getDefaultWorkspacePath();
const wpStat = await this.toFileStat(wpUriString);
await this.setWorkspace(wpStat);
const wsUriString = await this.getDefaultWorkspaceUri();
const wsStat = await this.toFileStat(wsUriString);
await this.setWorkspace(wsStat);

this.watcher.onFilesChanged(event => {
if (this._workspace && FileChangeEvent.isAffected(event, new URI(this._workspace.uri))) {
Expand All @@ -88,9 +88,16 @@ export class WorkspaceService implements FrontendApplicationContribution {
}

/**
* Get the path of the workspace to use initially.
* Resolves to the default workspace URI as string.
*
* The default implementation tries to extract the default workspace location
* from the `window.location.hash`, then falls-back to the most recently
* used workspace root from the server.
*
* It is not ensured that the resolved workspace URI is valid, it can point
* to a non-existing location.
*/
protected getDefaultWorkspacePath(): MaybePromise<string | undefined> {
protected getDefaultWorkspaceUri(): MaybePromise<string | undefined> {
// Prefer the workspace path specified as the URL fragment, if present.
if (window.location.hash.length > 1) {
// Remove the leading # and decode the URI.
Expand All @@ -103,6 +110,14 @@ export class WorkspaceService implements FrontendApplicationContribution {
}
}

/**
* Get the path of the workspace to use initially.
* @deprecated use `WorkspaceService#getDefaultWorkspaceUri` instead.
*/
protected getDefaultWorkspacePath(): MaybePromise<string | undefined> {
return this.getDefaultWorkspaceUri();
}

/**
* Set the URL fragment to the given workspace path.
*/
Expand Down

0 comments on commit 8ad626d

Please sign in to comment.