Files and imports
ImportBase
The language-neutral contract for a registered import.
A @skmtc/lang-* package provides a concrete subclass (TsImport, GoImport, …) that owns the language's import shape and rendering. The engine and CodeFileBase only ever see this neutral surface:
mergeKey()- identity for dedup AND the handle aFileuses to arrange its import section (typically the module / package path). Two imports with the same key collapse viamerge.merge(other)- combine a same-key import into this one (e.g. union their symbols). The subclass narrowsotherto its own type.toString()- render the standalone import. A languageFileMAY re-arrange instead (e.g. Go groups every package into oneimport ( … )block keyed bymergeKey()), sotoString()is the per-import render, not the whole section.
The split is deliberate: the merge of imports is language-neutral (it lives on CodeFileBase); the arrangement of the import section is language-specific (it lives in the concrete File.toString()).
Signature
import { ImportBase } from '@skmtc/core'
abstract class ImportBaseMethods
mergeKey
mergeKey(): stringIdentity for dedup and arrangement - typically the module or package path. Imports sharing a mergeKey() are merged via merge; a File may also group or sort its imports by this key.
merge
merge(other: ImportBase): ImportBaseCombine another import that shares this mergeKey() into a single import. The concrete subclass narrows other to its own type (and throws if handed a foreign import - which only happens if two languages wrote to one file, a misconfiguration).
toString
toString(): stringRender the standalone import. The File may re-arrange via mergeKey.