* Merge core, third-party, and user snippets, with precedence user > third * party > core.
()
| 145 | * party > core. |
| 146 | */ |
| 147 | private mergeSnippets() { |
| 148 | this.mergedSnippets = {}; |
| 149 | |
| 150 | // We make a list of all entries from all sources, in order of increasing |
| 151 | // precedence: user > third party > core. |
| 152 | const entries = [ |
| 153 | ...Object.entries(cloneDeep(this.coreSnippets)), |
| 154 | ...Object.values(this.thirdPartySnippets).flatMap((snippets) => |
| 155 | Object.entries(cloneDeep(snippets)) |
| 156 | ), |
| 157 | ...Object.entries(cloneDeep(this.userSnippets)), |
| 158 | ]; |
| 159 | |
| 160 | entries.forEach(([key, value]) => { |
| 161 | if (this.mergedSnippets.hasOwnProperty(key)) { |
| 162 | const { definitions, ...rest } = value; |
| 163 | const mergedSnippet = this.mergedSnippets[key]; |
| 164 | |
| 165 | // NB: We make sure that the new definitions appear before the previous |
| 166 | // ones so that they take precedence |
| 167 | mergedSnippet.definitions = definitions.concat( |
| 168 | ...mergedSnippet.definitions |
| 169 | ); |
| 170 | |
| 171 | merge(mergedSnippet, rest); |
| 172 | } else { |
| 173 | this.mergedSnippets[key] = value; |
| 174 | } |
| 175 | }); |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Looks in merged collection of snippets for a snippet with key |
no outgoing calls
no test coverage detected