-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensured type errors when a structure definition is given instead of a…
… structure value.
- Loading branch information
Showing
19 changed files
with
166 additions
and
32 deletions.
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
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 |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import Type from './Type'; | ||
import type { BasisTypeName } from '../basis/BasisConstants'; | ||
import type TypeSet from './TypeSet'; | ||
import Glyphs from '../lore/Glyphs'; | ||
import type Spaces from '../parser/Spaces'; | ||
import type Locales from '../locale/Locales'; | ||
import type StructureType from './StructureType'; | ||
|
||
export default class StructureDefinitionType extends Type { | ||
readonly type: StructureType; | ||
|
||
constructor(definition: StructureType) { | ||
super(); | ||
|
||
this.type = definition; | ||
} | ||
|
||
getDescriptor() { | ||
return 'StructureDefinitionType'; | ||
} | ||
|
||
getGrammar() { | ||
return []; | ||
} | ||
|
||
computeConflicts() { | ||
return []; | ||
} | ||
|
||
/** Compatible if it's the same structure definition, or the given type is a refinement of the given structure.*/ | ||
acceptsAll(types: TypeSet): boolean { | ||
return types.list().every((type) => { | ||
if ( | ||
type instanceof StructureDefinitionType && | ||
this.type.definition === type.type.definition | ||
) | ||
return true; | ||
}); | ||
} | ||
|
||
simplify() { | ||
return this; | ||
} | ||
|
||
getDescriptionInputs(locales: Locales) { | ||
return [locales.getName(this.type.definition.names)]; | ||
} | ||
|
||
getBasisTypeName(): BasisTypeName { | ||
return 'structuredefinition'; | ||
} | ||
|
||
clone() { | ||
return new StructureDefinitionType(this.type) as this; | ||
} | ||
|
||
toWordplay(_: Spaces | undefined) { | ||
return `•${this.type.definition.names.toWordplay(_)}`; | ||
} | ||
|
||
getNodeLocale(locales: Locales) { | ||
return locales.get((l) => l.node.StructureDefinitionType); | ||
} | ||
|
||
getGlyphs() { | ||
return Glyphs.Type; | ||
} | ||
} |
Oops, something went wrong.