-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7f0de27
commit a260115
Showing
13 changed files
with
237 additions
and
211 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './markers'; | ||
export * from './support_types'; | ||
export * from './tree'; | ||
export * from './visitor'; |
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 |
---|---|---|
@@ -1,4 +1,3 @@ | ||
export * from './markers'; | ||
export * from './support_types'; | ||
export * from './tree'; | ||
export * from './visitor'; |
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 |
---|---|---|
@@ -1,7 +1,62 @@ | ||
import {Tree} from "../core"; | ||
import {Markers, Tree, TreeVisitor, UUID} from "../core"; | ||
import {YamlVisitor} from "./visitor"; | ||
|
||
export interface Yaml extends Tree { | ||
get id(): UUID; | ||
|
||
withId(id: UUID): Yaml; | ||
|
||
get markers(): Markers; | ||
|
||
withMarkers(markers: Markers): Yaml; | ||
|
||
isAcceptable<P>(v: TreeVisitor<Tree, P>, p: P): boolean; | ||
|
||
accept<R extends Tree, P>(v: TreeVisitor<R, P>, p: P): R | null; | ||
|
||
acceptYaml<P>(v: YamlVisitor<P>, p: P): Yaml | null; | ||
} | ||
|
||
type Constructor<T = {}> = new (...args: any[]) => T; | ||
|
||
const YamlSymbol = Symbol('Yaml'); | ||
|
||
export function isYaml(tree: any & Tree): tree is Yaml { | ||
return tree && tree[YamlSymbol] === true; | ||
} | ||
|
||
export function YamlMixin<TBase extends Constructor<Object>>(Base: TBase) { | ||
abstract class YamlMixed extends Base implements Yaml { | ||
[YamlSymbol]: true = true; | ||
|
||
abstract get id(): UUID; | ||
|
||
abstract withId(id: UUID): Yaml; | ||
|
||
abstract get markers(): Markers; | ||
|
||
abstract withMarkers(markers: Markers): Yaml; | ||
|
||
public isAcceptable<P>(v: TreeVisitor<Tree, P>, p: P): boolean { | ||
return v.isAdaptableTo(YamlVisitor); | ||
} | ||
|
||
public accept<R extends Tree, P>(v: TreeVisitor<R, P>, p: P): R | null { | ||
return this.acceptYaml(v.adapt(YamlVisitor), p) as R | null; | ||
} | ||
|
||
public acceptYaml<P>(v: YamlVisitor<P>, p: P): Yaml | null { | ||
return v.defaultValue(this, p) as Yaml | null; | ||
} | ||
} | ||
|
||
return YamlMixed; | ||
} | ||
|
||
export * as Yaml from './tree'; | ||
|
||
export interface YamlKey extends Tree { | ||
// get value(): string; | ||
|
||
withPrefix(prefix: string): YamlKey; | ||
} | ||
} |
Oops, something went wrong.