MCPcopy Create free account
hub / github.com/breck7/scroll / synthesizeParticle

Method synthesizeParticle

external/.scrollLibs.js:19820–19840  ·  view source on GitHub ↗
(particleCount = 1, indentCount = -1, parsersAlreadySynthesized = [], seed = Date.now())

Source from the content-addressed store, hash-verified

19818 }
19819 // todo: refactor
19820 synthesizeParticle(particleCount = 1, indentCount = -1, parsersAlreadySynthesized = [], seed = Date.now()) {
19821 let inScopeParserIds = this._getInScopeParserIds()
19822 const catchAllParserId = this._getFromExtended(ParsersConstants.catchAllParser)
19823 if (catchAllParserId) inScopeParserIds.push(catchAllParserId)
19824 const thisId = this.id
19825 if (!parsersAlreadySynthesized.includes(thisId)) parsersAlreadySynthesized.push(thisId)
19826 const lines = []
19827 while (particleCount) {
19828 const line = this._generateSimulatedLine(seed)
19829 if (line) lines.push(" ".repeat(indentCount >= 0 ? indentCount : 0) + line)
19830 this._getConcreteNonErrorInScopeParticleDefinitions(inScopeParserIds.filter(parserId => !parsersAlreadySynthesized.includes(parserId)))
19831 .filter(def => this._shouldSynthesize(def, parsersAlreadySynthesized))
19832 .forEach(def => {
19833 const chain = parsersAlreadySynthesized // .slice(0)
19834 chain.push(def.id)
19835 def.synthesizeParticle(1, indentCount + 1, chain, seed).forEach(line => lines.push(line))
19836 })
19837 particleCount--
19838 }
19839 return lines
19840 }
19841 get atomParser() {
19842 if (!this._atomParser) {
19843 const atomParsingStrategy = this._getFromExtended(ParsersConstants.atomParser)

Callers

nothing calls this directly

Calls 7

_getInScopeParserIdsMethod · 0.95
_shouldSynthesizeMethod · 0.95
_getFromExtendedMethod · 0.80
forEachMethod · 0.80
filterMethod · 0.45

Tested by

no test coverage detected