Printable idea sheet
configuration_import_root_alias
reqlan rq/language/imports.rq:92
Katz 0.296
An import path may start with an alias string, then `/`, then a relative path under that alias's import-root directory.
Default alias string: `@`, written as `@/` plus a path relative to the import root.
Default import-root directory: the workspace folder that contains the `.rq` file ( not the document directory ).
The path after `/` is joined to that alias's import-root directory; the alias itself must be followed by `/` ( e. g. `@reqs` is not aliased ).
Alias strings and import-root directories are configured as configuration_import_roots in the applying `.reqlan/config.json` from configuration_location.
A configured relative `root` resolves against the base root ( parent of `.reqlan` ); an omitted `root` keeps the workspace-folder default.
When several configured aliases could match a path, the longest alias wins.
Related path forms: import_paths, comment_reference_import_root_alias. Completion: code_completion.
File references and the language server use the same locate rule as check: load `importRoots` from the applying `.reqlan/config.json` for the source file ( configuration_location ), then `resolve_rq_path` and join the workspace when the result is relative — including paths with spaces such as `my file.ts`.
- example
- //rq-ignore-error
`from "@/path/relative/to/import/root.rq" import idea` - implementation
- reqlan-path-resolve.ts, file-path-rewrite.ts, reqlan-completion-provider.ts, reqlan-path-completion.ts, reqlan-comment-diagnostics.ts, register-comment-reference-links.ts, path.rs, path_resolve.rs, broken.rs, sync.rs, comment.rs, analysis.rs, session.rs
- tests
- path-resolve.test.ts:resolves import-root alias against the workspace folder, path-resolve.test.ts:leaves non-aliased relative paths document-relative, path-resolve.test.ts:matchImportRootAlias requires alias then slash, path-resolve.test.ts:loads importRoots list from nearest base config, path-resolve.test.ts:resolves using config importRoots mapping, path-resolve.test.ts:rewrite leaves aliased paths unchanged, completion.test.ts:completes import-root alias paths, config.test.ts:multiple importRoots map aliases to different roots, config.test.ts:longest alias wins when mappings overlap, config.test.ts:aliased path uses relative root from applying config, config.test.ts:aliased path uses workspace folder when root is omitted, path.rs:match_import_root_alias_requires_alias_then_slash, path.rs:resolves_default_alias_against_workspace_folder, path_resolve.rs:locate_aliased_file_ref_joins_workspace_root, path_resolve.rs:locate_uses_import_roots_from_applying_config, broken_references.rs:check_accepts_import_root_alias_file_refs, broken_references.rs:check_honours_import_roots_from_applying_config, parity.rs:import_root_alias_file_refs_match_check, parity.rs:import_root_config_file_refs_match_check, comment-reference-resolution.test.ts:creates a document link for an import-root aliased comment reference, comment.rs:resolves_aliased_qualified_comment_path
Interactive page: configuration_import_root_alias