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

Method pushToIndex

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

Source from the content-addressed store, hash-verified

738`&&Y>=this.pos&&Y+1+K>A)q=Y;else break}while(!0);return yield Pn6.SCALAR,yield*this.pushToIndex(q+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let q=this.flowLevel>0,K=this.pos-1,_=this.pos-1,z;while(z=this.buffer[++_])if(z===":"){let Y=this.buffer[_+1];if(Eu(Y)||q&&xG8.has(Y))break;K=_}else if(Eu(z)){let Y=this.buffer[_+1];if(z==="\r")if(Y===`
739`)_+=1,z=`
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(`

Callers 5

parseQuotedScalarMethod · 0.95
parseBlockScalarMethod · 0.95
parsePlainScalarMethod · 0.95
pushTagMethod · 0.95
pushUntilMethod · 0.95

Calls 1

sliceMethod · 0.45

Tested by

no test coverage detected