mirror of
https://github.com/denoland/std.git
synced 2024-11-22 04:59:05 +00:00
refactor(yaml): inline readAnchorProperty()
(#5853)
This commit is contained in:
parent
c7835496e4
commit
a55ee9c84d
@ -1377,6 +1377,31 @@ export class LoaderState {
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
readAnchorProperty(): boolean {
|
||||||
|
let ch = this.peek();
|
||||||
|
if (ch !== AMPERSAND) return false;
|
||||||
|
|
||||||
|
if (this.anchor !== null) {
|
||||||
|
return this.throwError(
|
||||||
|
"Cannot read anchor property: duplicate anchor property",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
ch = this.next();
|
||||||
|
|
||||||
|
const position = this.position;
|
||||||
|
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
||||||
|
ch = this.next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.position === position) {
|
||||||
|
return this.throwError(
|
||||||
|
"Cannot read anchor property: name of an anchor node must contain at least one character",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.anchor = this.input.slice(position, this.position);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
readDocument() {
|
readDocument() {
|
||||||
const documentStart = this.position;
|
const documentStart = this.position;
|
||||||
@ -1506,32 +1531,6 @@ export class LoaderState {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function readAnchorProperty(state: LoaderState): boolean {
|
|
||||||
let ch = state.peek();
|
|
||||||
if (ch !== AMPERSAND) return false;
|
|
||||||
|
|
||||||
if (state.anchor !== null) {
|
|
||||||
return state.throwError(
|
|
||||||
"Cannot read anchor property: duplicate anchor property",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
ch = state.next();
|
|
||||||
|
|
||||||
const position = state.position;
|
|
||||||
while (ch !== 0 && !isWhiteSpaceOrEOL(ch) && !isFlowIndicator(ch)) {
|
|
||||||
ch = state.next();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state.position === position) {
|
|
||||||
return state.throwError(
|
|
||||||
"Cannot read anchor property: name of an anchor node must contain at least one character",
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
state.anchor = state.input.slice(position, state.position);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
function readAlias(state: LoaderState): boolean {
|
function readAlias(state: LoaderState): boolean {
|
||||||
if (state.peek() !== ASTERISK) return false;
|
if (state.peek() !== ASTERISK) return false;
|
||||||
|
|
||||||
@ -1599,7 +1598,7 @@ function composeNode(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (indentStatus === 1) {
|
if (indentStatus === 1) {
|
||||||
while (state.readTagProperty() || readAnchorProperty(state)) {
|
while (state.readTagProperty() || state.readAnchorProperty()) {
|
||||||
if (state.skipSeparationSpace(true, -1)) {
|
if (state.skipSeparationSpace(true, -1)) {
|
||||||
atNewLine = true;
|
atNewLine = true;
|
||||||
allowBlockCollections = allowBlockStyles;
|
allowBlockCollections = allowBlockStyles;
|
||||||
|
Loading…
Reference in New Issue
Block a user