Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[quality] There are two identical InMemoryTextResource implementations #9191

Closed
kittaakos opened this issue Mar 12, 2021 · 1 comment · Fixed by #9504
Closed

[quality] There are two identical InMemoryTextResource implementations #9191

kittaakos opened this issue Mar 12, 2021 · 1 comment · Fixed by #9504
Labels
help wanted issues meant to be picked up, require help quality issues related to code and application quality

Comments

@kittaakos
Copy link
Contributor

Bug Description:

https://github.com/eclipse-theia/theia/blob/master/packages/search-in-workspace/src/browser/in-memory-text-resource.ts
https://github.com/eclipse-theia/theia/blob/master/packages/bulk-edit/src/browser/bulk-edit-tree/in-memory-text-resource.ts

Steps to Reproduce:

Additional Information

  • Operating System:
  • Theia Version:
@kittaakos
Copy link
Contributor Author

Here is one more:

@injectable()
export class InMemoryResources implements ResourceResolver {
protected readonly resources = new SyncReferenceCollection<string, MutableResource>(uri => new MutableResource(new URI(uri)));
add(uri: URI, contents: string): Resource {
const resourceUri = uri.toString();
if (this.resources.has(resourceUri)) {
throw new Error(`Cannot add already existing in-memory resource '${resourceUri}'`);
}
const resource = this.acquire(resourceUri);
resource.saveContents(contents);
return resource;
}
update(uri: URI, contents: string): Resource {
const resourceUri = uri.toString();
const resource = this.resources.get(resourceUri);
if (!resource) {
throw new Error(`Cannot update non-existed in-memory resource '${resourceUri}'`);
}
resource.saveContents(contents);
return resource;
}
resolve(uri: URI): Resource {
const uriString = uri.toString();
if (!this.resources.has(uriString)) {
throw new Error(`In memory '${uriString}' resource does not exist.`);
}
return this.acquire(uriString);
}
protected acquire(uri: string): ReferenceMutableResource {
const reference = this.resources.acquire(uri);
return new ReferenceMutableResource(reference);
}
}

@vince-fugnitto vince-fugnitto added help wanted issues meant to be picked up, require help quality issues related to code and application quality labels Mar 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted issues meant to be picked up, require help quality issues related to code and application quality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants