MCPcopy Index your code
hub / github.com/ChinaSiro/claude-code-sourcemap / pushSpaces

Method pushSpaces

package/cli.js:742–742  ·  view source on GitHub ↗
(q)

Source from the content-addressed store, hash-verified

740`,Y=this.buffer[_+1];else K=_;if(Y==="#"||q&&xG8.has(Y))break;if(z===`
741`){let $=this.continueScalar(_+1);if($===-1)break;_=Math.max(_,$-2)}}else{if(q&&xG8.has(z))break;K=_}if(!z&&!this.atEnd)return this.setNext("plain-scalar");return yield Pn6.SCALAR,yield*this.pushToIndex(K+1,!0),q?"flow":"doc"}*pushCount(q){if(q>0)return yield this.buffer.substr(this.pos,q),this.pos+=q,q;return 0}*pushToIndex(q,K){let _=this.buffer.slice(this.pos,q);if(_)return yield _,this.pos+=_.length,_.length;else if(K)yield"";return 0}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Wh1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let q=this.flowLevel>0,K=this.charAt(1);if(Eu(K)||q&&xG8.has(K)){if(!q)this.indentNext=this.indentValue+1;else if(this.flowKey)this.flowKey=!1;return(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}}return 0}*pushTag(){if(this.charAt(1)==="<"){let q=this.pos+2,K=this.buffer[q];while(!Eu(K)&&K!==">")K=this.buffer[++q];return yield*this.pushToIndex(K===">"?q+1:q,!1)}else{let q=this.pos+1,K=this.buffer[q];while(K)if(hR_.has(K))K=this.buffer[++q];else if(K==="%"&&m44.has(this.buffer[q+1])&&m44.has(this.buffer[q+2]))K=this.buffer[q+=3];else break;return yield*this.pushToIndex(q,!1)}}*pushNewline(){let q=this.buffer[this.pos];if(q===`
742`)return yield*this.pushCount(1);else if(q==="\r"&&this.charAt(1)===`
743`)return yield*this.pushCount(2);else return 0}*pushSpaces(q){let K=this.pos-1,_;do _=this.buffer[++K];while(_===" "||q&&_==="\t");let z=K-this.pos;if(z>0)yield this.buffer.substr(this.pos,z),this.pos=K;return z}*pushUntil(q){let K=this.pos,_=this.buffer[K];while(!q(_))_=this.buffer[++K];return yield*this.pushToIndex(K,!1)}}CR_.Lexer=p44});var fh1=m((xR_)=>{class B44{constructor(){this.lineStarts=[],this.addNewLine=(q)=>this.lineStarts.push(q),this.linePos=(q)=>{let K=0,_=this.lineStarts.length;while(K<_){let Y=K+_>>1;if(this.lineStarts[Y]<q)K=Y+1;else _=Y}if(this.lineStarts[K]===q)return{line:K+1,col:1};if(K===0)return{line:0,col:q};let z=this.lineStarts[K-1];return{line:K,col:q-z+1}}}}xR_.LineCounter=B44});var Zh1=m((pR_)=>{var uR_=U6("process"),g44=bG8(),mR_=Dh1();function q76(q,K){for(let _=0;_<q.length;++_)if(q[_].type===K)return!0;return!1}function F44(q){for(let K=0;K<q.length;++K)switch(q[K].type){case"space":case"comment":case"newline":break;default:return K}return-1}function Q44(q){switch(q?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function IG8(q){switch(q.type){case"document":return q.start;case"block-map":{let K=q.items[q.items.length-1];return K.sep??K.start}case"block-seq":return q.items[q.items.length-1].start;default:return[]}}function Xv6(q){if(q.length===0)return[];let K=q.length;q:while(--K>=0)switch(q[K].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break q}while(q[++K]?.type==="space");return q.splice(K,q.length)}function U44(q){if(q.start.type==="flow-seq-start"){for(let K of q.items)if(K.sep&&!K.value&&!q76(K.start,"explicit-key-ind")&&!q76(K.sep,"map-value-ind")){if(K.key)K.value=K.key;if(delete K.key,Q44(K.value))if(K.value.end)Array.prototype.push.apply(K.value.end,K.sep);else K.value.end=K.sep;else Array.prototype.push.apply(K.start,K.sep);delete K.sep}}}class d44{constructor(q){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new mR_.Lexer,this.onNewLine=q}*parse(q,K=!1){if(this.onNewLine&&this.offset===0)this.onNewLine(0);for(let _ of this.lexer.lex(q,K))yield*this.next(_);if(!K)yield*this.end()}*next(q){if(this.source=q,uR_.env.LOG_TOKENS)console.log("|",g44.prettyToken(q));if(this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=q.length;return}let K=g44.tokenType(q);if(!K){let _=`Not a YAML token: ${q}`;yield*this.pop({type:"error",offset:this.offset,message:_,source:q}),this.offset+=q.length}else if(K==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=K,yield*this.step(),K){case"newline":if(this.atNewLine=!0,this.indent=0,this.onNewLine)this.onNewLine(this.offset+q.length);break;case"space":if(this.atNewLine&&q[0]===" ")this.indent+=q.length;break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":if(this.atNewLine)this.indent+=q.length;break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=q.length}}*end(){while(this.stack.length>0)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let q=this.peek(1);if(this.type==="doc-end"&&(!q||q.type!=="doc-end")){while(this.stack.length>0)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!q)return yield*this.stream();switch(q.type){case"document":return yield*this.document(q);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(q);case"block-scalar":return yield*this.blockScalar(q);case"block-map":return yield*this.blockMap(q);case"block-seq":return yield*this.blockSequence(q);case"flow-collection":return yield*this.flowCollection(q);case"doc-end":return yield*this.documentEnd(q)}yield*this.pop()}peek(q){return this.stack[this.stack.length-q]}*pop(q){let K=q??this.stack.pop();if(!K)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield K;else{let _=this.peek(1);if(K.type==="block-scalar")K.indent="indent"in _?_.indent:0;else if(K.type==="flow-collection"&&_.type==="document")K.indent=0;if(K.type==="flow-collection")U44(K);switch(_.type){case"document":_.value=K;break;case"block-scalar":_.props.push(K);break;case"block-map":{let z=_.items[_.items.length-1];if(z.value){_.items.push({start:[],key:K,sep:[]}),this.onKeyLine=!0;return}else if(z.sep)z.value=K;else{Object.assign(z,{key:K,sep:[]}),this.onKeyLine=!z.explicitKey;return}break}case"block-seq":{let z=_.items[_.items.length-1];if(z.value)_.items.push({start:[],value:K});else z.value=K;break}case"flow-collection":{let z=_.items[_.items.length-1];if(!z||z.value)_.items.push({start:[],key:K,sep:[]});else if(z.sep)z.value=K;else Object.assign(z,{key:K,sep:[]});return}default:yield*this.pop(),yield*this.pop(K)}if((_.type==="document"||_.type==="block-map"||_.type==="block-seq")&&(K.type==="block-map"||K.type==="block-seq")){let z=K.items[K.items.length-1];if(z&&!z.sep&&!z.value&&z.start.length>0&&F44(z.start)===-1&&(K.indent===0||z.start.every((Y)=>Y.type!=="comment"||Y.indent<K.indent))){if(_.type==="document")_.end=z.start;else _.items.push({start:z.start});K.items.splice(-1,1)}}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let q={type:"document",offset:this.offset,start:[]};if(this.type==="doc-start")q.start.push(this.sourceToken);this.stack.push(q);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(q){if(q.value)return yield*this.lineEnd(q);switch(this.type){case"doc-start":{if(F44(q.start)!==-1)yield*this.pop(),yield*this.step();else q.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":q.start.push(this.sourceToken);return}let K=this.startBlockValue(q);if(K)this.stack.push(K);else yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(q){if(this.type==="map-value-ind"){let K=IG8(this.peek(2)),_=Xv6(K),z;if(q.end)z=q.end,z.push(this.sourceToken),delete q.end;else z=[this.sourceToken];let Y={type:"block-map",offset:q.offset,indent:q.indent,items:[{start:_,key:q,sep:z}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=Y}else yield*this.lineEnd(q)}*blockScalar(q){switch(this.type){case"space":case"comment":case"newline":q.props.push(this.sourceToken);return;case"scalar":if(q.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let K=this.source.indexOf(`
744`)+1;while(K!==0)this.onNewLine(this.offset+K),K=this.source.indexOf(`
745`,K)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(q){let K=q.items[q.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,K.value){let _="end"in K.value?K.value.end:void 0;if((Array.isArray(_)?_[_.length-1]:void 0)?.type==="comment")_?.push(this.sourceToken);else q.items.push({start:[this.sourceToken]})}else if(K.sep)K.sep.push(this.sourceToken);else K.start.push(this.sourceToken);return;case"space":case"comment":if(K.value)q.items.push({start:[this.sourceToken]});else if(K.sep)K.sep.push(this.sourceToken);else{if(this.atIndentedComment(K.start,q.indent)){let z=q.items[q.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,K.start),z.push(this.sourceToken),q.items.pop();return}}K.start.push(this.sourceToken)}return}if(this.indent>=q.indent){let _=!this.onKeyLine&&this.indent===q.indent,z=_&&(K.sep||K.explicitKey)&&this.type!=="seq-item-ind",Y=[];if(z&&K.sep&&!K.value){let $=[];for(let A=0;A<K.sep.length;++A){let O=K.sep[A];switch(O.type){case"newline":$.push(A);break;case"space":break;case"comment":if(O.indent>q.indent)$.length=0;break;default:$.length=0}}if($.length>=2)Y=K.sep.splice($[1])}switch(this.type){case"anchor":case"tag":if(z||K.value)Y.push(this.sourceToken),q.items.push({start:Y}),this.onKeyLine=!0;else if(K.sep)K.sep.push(this.sourceToken);else K.start.push(this.sourceToken);return;case"explicit-key-ind":if(!K.sep&&!K.explicitKey)K.start.push(this.sourceToken),K.explicitKey=!0;else if(z||K.value)Y.push(this.sourceToken),q.items.push({start:Y,explicitKey:!0});else this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]});this.onKeyLine=!0;return;case"map-value-ind":if(K.explicitKey)if(!K.sep)if(q76(K.start,"newline"))Object.assign(K,{key:null,sep:[this.sourceToken]});else{let $=Xv6(K.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:null,sep:[this.sourceToken]}]})}else if(K.value)q.items.push({start:[],key:null,sep:[this.sourceToken]});else if(q76(K.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:Y,key:null,sep:[this.sourceToken]}]});else if(Q44(K.key)&&!q76(K.sep,"newline")){let $=Xv6(K.start),A=K.key,O=K.sep;O.push(this.sourceToken),delete K.key,delete K.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:$,key:A,sep:O}]})}else if(Y.length>0)K.sep=K.sep.concat(Y,this.sourceToken);else K.sep.push(this.sourceToken);else if(!K.sep)Object.assign(K,{key:null,sep:[this.sourceToken]});else if(K.value||z)q.items.push({start:Y,key:null,sep:[this.sourceToken]});else if(q76(K.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]});else K.sep.push(this.sourceToken);this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let $=this.flowScalar(this.type);if(z||K.value)q.items.push({start:Y,key:$,sep:[]}),this.onKeyLine=!0;else if(K.sep)this.stack.push($);else Object.assign(K,{key:$,sep:[]}),this.onKeyLine=!0;return}default:{let $=this.startBlockValue(q);if($){if($.type==="block-seq"){if(!K.explicitKey&&K.sep&&!q76(K.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else if(_)q.items.push({start:Y});this.stack.push($);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(q){let K=q.items[q.items.length-1];switch(this.type){case"newline":if(K.value){let _="end"in K.value?K.value.end:void 0;if((Array.isArray(_)?_[_.length-1]:void 0)?.type==="comment")_?.push(this.sourceToken);else q.items.push({start:[this.sourceToken]})}else K.start.push(this.sourceToken);return;case"space":case"comment":if(K.value)q.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(K.start,q.indent)){let z=q.items[q.items.length-2]?.value?.end;if(Array.isArray(z)){Array.prototype.push.apply(z,K.start),z.push(this.sourceToken),q.items.pop();return}}K.start.push(this.sourceToken)}return;case"anchor":case"tag":if(K.value||this.indent<=q.indent)break;K.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==q.indent)break;if(K.value||q76(K.start,"seq-item-ind"))q.items.push({start:[this.sourceToken]});else K.start.push(this.sourceToken);return}if(this.indent>q.indent){let _=this.startBlockValue(q);if(_){this.stack.push(_);return}}yield*this.pop(),yield*this.step()}*flowCollection(q){let K=q.items[q.items.length-1];if(this.type==="flow-error-end"){let _;do yield*this.pop(),_=this.peek(1);while(_&&_.type==="flow-collection")}else if(q.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":if(!K||K.sep)q.items.push({start:[this.sourceToken]});else K.start.push(this.sourceToken);return;case"map-value-ind":if(!K||K.value)q.items.push({start:[],key:null,sep:[this.sourceToken]});else if(K.sep)K.sep.push(this.sourceToken);else Object.assign(K,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":if(!K||K.value)q.items.push({start:[this.sourceToken]});else if(K.sep)K.sep.push(this.sourceToken);else K.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let z=this.flowScalar(this.type);if(!K||K.value)q.items.push({start:[],key:z,sep:[]});else if(K.sep)this.stack.push(z);else Object.assign(K,{key:z,sep:[]});return}case"flow-map-end":case"flow-seq-end":q.end.push(this.sourceToken);return}let _=this.startBlockValue(q);if(_)this.stack.push(_);else yield*this.pop(),yield*this.step()}else{let _=this.peek(2);if(_.type==="block-map"&&(this.type==="map-value-ind"&&_.indent===q.indent||this.type==="newline"&&!_.items[_.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&_.type!=="flow-collection"){let z=IG8(_),Y=Xv6(z);U44(q);let $=q.end.splice(1,q.end.length);$.push(this.sourceToken);let A={type:"block-map",offset:q.offset,indent:q.indent,items:[{start:Y,key:q,sep:$}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=A}else yield*this.lineEnd(q)}}flowScalar(q){if(this.onNewLine){let K=this.source.indexOf(`

Callers 6

parseStreamMethod · 0.95
parseLineStartMethod · 0.95
parseBlockStartMethod · 0.95
parseDocumentMethod · 0.95
parseFlowCollectionMethod · 0.95
pushIndicatorsMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected