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

Schematic Tree fixes #11274

Merged
merged 10 commits into from
Jul 3, 2018
Merged

Schematic Tree fixes #11274

merged 10 commits into from
Jul 3, 2018

Conversation

clydin
Copy link
Member

@clydin clydin commented Jun 16, 2018

Based on #11178

Brocco
Brocco previously approved these changes Jun 18, 2018
Copy link
Contributor

@hansl hansl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love the cleanup in general, some comments.

@@ -211,6 +212,20 @@ export class SimpleMemoryHost implements Host<{}> {
const content = this._cache.get(from);
if (content) {
this._cache.delete(from);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This side effect should be moved to the end of the function (next to the set) to avoid inconsistent state if an exception is thrown.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


tree.visit(path => {
if (!filter(path)) {
this.delete(path);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will delete files (as actions), no? A FilterTree should contains only actions that are pertained to files that match the pattern, unless you intend to do something else here. But if I have a tree that contains file1 and file2 and return FilterTree(x => x != file2), it would actually delete file2 which is probably not what we mean (and not what FilteredTree would have done).

I don’t see a test on actions of filtertree which would have caught this.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New host tree specific filter added that does not use delete.

@@ -98,6 +96,7 @@ export class HostTree implements Tree {
private _id = _uniqueId++;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t see this part being fixed from my previous PR; IDs need to be negative to avoid ID clash with VirtualTree.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -426,3 +404,17 @@ export class HostTree implements Tree {
);
}
}

export class HostCreateTree extends HostTree {
constructor(host: virtualFs.Host) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be the same host type as it’s superclass (ReadonlyHost<{}>)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -16,34 +16,41 @@ export function empty() {
}

export function branch(tree: Tree) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add TODOs to these functions to remove those VirtualTree hacks for 7.0

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

const newBackend = new virtualFs.SimpleMemoryHost();
// cast to allow access
const originalBackend = (tree as FilterHostTree)._backend;
originalBackend.list(normalize('/'))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you just filtering the root?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed. Fixed with additional tests.

@clydin clydin merged commit 9582b84 into angular:master Jul 3, 2018
@clydin clydin deleted the host-virtual branch July 3, 2018 16:52
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 12, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants