-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(ast): followup changes for YAML 1.2 Schemas
Refs #3481
- Loading branch information
Showing
11 changed files
with
69 additions
and
88 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -38,5 +38,6 @@ class ScalarTag { | |
return node; | ||
} | ||
} | ||
/* eslint-enable class-methods-use-this */ | ||
|
||
export default ScalarTag; |
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,22 @@ | ||
import ScalarTag from './ScalarTag'; | ||
/* eslint-disable class-methods-use-this */ | ||
class Tag { | ||
public static readonly uri: string = ''; | ||
|
||
class Tag extends ScalarTag { | ||
public tag: string = ''; | ||
public readonly tag: string = ''; | ||
|
||
constructor() { | ||
this.tag = (this.constructor as typeof Tag).uri; | ||
} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
public test(node: any): boolean { | ||
return true; | ||
} | ||
|
||
public resolve(node: any): any { | ||
return node; | ||
} | ||
} | ||
/* eslint-enable class-methods-use-this */ | ||
|
||
export default Tag; |
15 changes: 4 additions & 11 deletions
15
packages/apidom-ast/src/yaml/schemas/failsafe/GenericMapping.ts
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,21 +1,14 @@ | ||
import Tag from '../Tag'; | ||
import { YamlNodeKind } from '../../nodes/YamlTag'; | ||
|
||
/* eslint-disable class-methods-use-this */ | ||
class GenericMapping extends Tag { | ||
public static uri: string = 'tag:yaml.org,2002:map'; | ||
public static readonly uri: string = 'tag:yaml.org,2002:map'; | ||
|
||
constructor() { | ||
super(); | ||
this.tag = GenericMapping.uri; | ||
} | ||
|
||
public static test(node: any): boolean { | ||
public test(node: any): boolean { | ||
return node.tag.kind === YamlNodeKind.Mapping; | ||
} | ||
|
||
public static resolve(node: any): any { | ||
return node; | ||
} | ||
} | ||
/* eslint-enable class-methods-use-this */ | ||
|
||
export default GenericMapping; |
15 changes: 4 additions & 11 deletions
15
packages/apidom-ast/src/yaml/schemas/failsafe/GenericSequence.ts
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,21 +1,14 @@ | ||
import Tag from '../Tag'; | ||
import { YamlNodeKind } from '../../nodes/YamlTag'; | ||
|
||
/* eslint-disable class-methods-use-this */ | ||
class GenericSequence extends Tag { | ||
public static uri: string = 'tag:yaml.org,2002:seq'; | ||
public static readonly uri: string = 'tag:yaml.org,2002:seq'; | ||
|
||
constructor() { | ||
super(); | ||
this.tag = GenericSequence.uri; | ||
} | ||
|
||
public static test(node: any): boolean { | ||
public test(node: any): boolean { | ||
return node.tag.kind === YamlNodeKind.Sequence; | ||
} | ||
|
||
public static resolve(node: any): any { | ||
return node; | ||
} | ||
} | ||
/* eslint-enable class-methods-use-this */ | ||
|
||
export default GenericSequence; |
11 changes: 1 addition & 10 deletions
11
packages/apidom-ast/src/yaml/schemas/failsafe/GenericString.ts
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,16 +1,7 @@ | ||
import Tag from '../Tag'; | ||
|
||
class GenericString extends Tag { | ||
public static uri: string = 'tag:yaml.org,2002:str'; | ||
|
||
constructor() { | ||
super(); | ||
this.tag = GenericString.uri; | ||
} | ||
|
||
public static resolve(node: any): any { | ||
return node; | ||
} | ||
public static readonly uri: string = 'tag:yaml.org,2002:str'; | ||
} | ||
|
||
export default GenericString; |
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,24 +1,21 @@ | ||
import Tag from '../Tag'; | ||
|
||
/* eslint-disable class-methods-use-this */ | ||
class Null extends Tag { | ||
public static uri: string = 'tag:yaml.org,2002:null'; | ||
public static readonly uri: string = 'tag:yaml.org,2002:null'; | ||
|
||
constructor() { | ||
super(); | ||
this.tag = Null.uri; | ||
} | ||
|
||
public static test(node: any): boolean { | ||
public test(node: any): boolean { | ||
return /^null$/.test(node.content); | ||
} | ||
|
||
public static resolve(node: any): any { | ||
public resolve(node: any): any { | ||
const nodeClone = node.clone(); | ||
|
||
nodeClone.content = null; | ||
|
||
return nodeClone; | ||
} | ||
} | ||
/* eslint-enable class-methods-use-this */ | ||
|
||
export default Null; |
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