-
Notifications
You must be signed in to change notification settings - Fork 190
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
add modifiers to debug render tree #1559
Merged
NullVoxPopuli
merged 2 commits into
glimmerjs:main
from
patricklx:add-modifiers-to-debug-render-tree
Mar 9, 2024
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,6 +56,7 @@ import type { UpdatingVM } from '../../vm'; | |
import type { InternalVM } from '../../vm/append'; | ||
import type { BlockArgumentsImpl } from '../../vm/arguments'; | ||
|
||
import { ConcreteBounds } from '../../bounds'; | ||
import { hasCustomDebugRenderTreeLifecycle } from '../../component/interfaces'; | ||
import { resolveComponent } from '../../component/resolve'; | ||
import { isCurriedType, isCurriedValue, resolveCurriedValue } from '../../curried-value'; | ||
|
@@ -489,8 +490,46 @@ export class ComponentElementOperations implements ElementOperations { | |
this.attributes[name] = deferred; | ||
} | ||
|
||
addModifier(modifier: ModifierInstance): void { | ||
addModifier(vm: InternalVM, modifier: ModifierInstance, capturedArgs: CapturedArguments): void { | ||
this.modifiers.push(modifier); | ||
|
||
if (vm.env.debugRenderTree !== undefined) { | ||
const { manager, definition, state } = modifier; | ||
|
||
// TODO: we need a stable object for the debugRenderTree as the key, add support for | ||
// the case where the state is a primitive, or if in practice we always have/require | ||
// an object, then change the internal types to reflect that | ||
if (state === null || (typeof state !== 'object' && typeof state !== 'function')) { | ||
return; | ||
} | ||
|
||
let { element, constructing } = vm.elements(); | ||
let name = manager.getDebugName(definition.state); | ||
let instance = manager.getDebugInstance(state); | ||
|
||
assert(constructing, `Expected a constructing element in addModifier`); | ||
|
||
let bounds = new ConcreteBounds(element, constructing, constructing); | ||
|
||
vm.env.debugRenderTree.create(state, { | ||
type: 'modifier', | ||
name, | ||
args: capturedArgs, | ||
instance, | ||
}); | ||
|
||
vm.env.debugRenderTree.didRender(state, bounds); | ||
|
||
// For tearing down the debugRenderTree | ||
vm.associateDestroyable(state); | ||
|
||
vm.updateWith(new DebugRenderTreeUpdateOpcode(state)); | ||
vm.updateWith(new DebugRenderTreeDidRenderOpcode(state, bounds)); | ||
|
||
registerDestructor(state, () => { | ||
vm.env.debugRenderTree?.willDestroy(state); | ||
}); | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Most of these are analogous to the component equivalent in the same file |
||
} | ||
|
||
flush(vm: InternalVM): ModifierInstance[] { | ||
|
@@ -645,8 +684,6 @@ APPEND_OPCODES.add(Op.GetComponentSelf, (vm, { op1: _state, op2: _names }) => { | |
instance: valueForRef(selfRef), | ||
}); | ||
|
||
vm.associateDestroyable(instance); | ||
|
||
registerDestructor(instance, () => { | ||
vm.env.debugRenderTree?.willDestroy(instance); | ||
}); | ||
|
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prints error stack traces from tests to console, useful for debugging, like clicking on error location to jump to the code