You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Design: strict import mode and scopes for component statements #1959
Design note for strict import mode (#374) and component statements (#575), on top of code segments (#1934).
Scopes keep two lists
Loaded: the transitive closure, as today. Used for duplicate checks and the output <script> list. The first pass still flags duplicates rather than fixing them.
Visible: per file, itself plus its direct imports. Used for name resolution under strict mode.
The dependency graph needs to expose each file's direct imports.
Strict mode (a setting, default TBD)
Every file is strict, including .brs.
.bs files: direct imports. .brs files and CDATA blocks: direct ' bs:import "..." comments.
xml <script> tags count as strict. Scripts in the same xml don't see each other.
Global functions and Library statements stay visible.
bs:import requires an import; it doesn't perform one. It's an error if the component doesn't load the target.
Diagnostic
Quick fix
Cannot find X
Add import / ' bs:import
Import of Z isn't loaded by component Y
Add <script> to Y's xml
Migration: add a fix-all for missing imports, and allow bs:disable for files not converted yet.
Component statements
The #575 proposal doc already defines the scope: the component body, the file's other functions, the file's imports and the parent. That's an XmlScope whose root is a statement instead of an xml file.
One component per file (diagnostic otherwise), so the file stays one code segment.
Pull the component definition (name, parent, interface, children) out of XmlScope, so an xml file and a statement can both provide it.
Create scopes from statements using the provideScope events.
Generate the xml and codebehind at build time, not as virtual:/ files.
Open questions
Should interface functions and onChange handlers resolve only against the component's direct scripts?
Strict mode default.
Component statements in source/.
Order
Two-list scopes.
Strict mode, then bs:import.
Pull the component definition out of XmlScope.
Component statements.
Later: resolve import-only files once per file instead of per scope.
Activity