MCPcopy Index your code
hub / github.com/alibaba/lowcode-engine / linkPieces

Function linkPieces

modules/code-generator/src/utils/nodeToJSX.ts:185–219  ·  view source on GitHub ↗
(pieces: CodePiece[])

Source from the content-addressed store, hash-verified

183}
184
185function linkPieces(pieces: CodePiece[]): string {
186 const tagsPieces = pieces.filter((p) => p.type === PIECE_TYPE.TAG);
187 if (tagsPieces.length !== 1) {
188 throw new CodeGeneratorError('Only one tag definition required', tagsPieces);
189 }
190 const tagName = tagsPieces[0].value;
191
192 const beforeParts = pieces
193 .filter((p) => p.type === PIECE_TYPE.BEFORE)
194 .map((p) => p.value)
195 .join('');
196
197 const afterParts = pieces
198 .filter((p) => p.type === PIECE_TYPE.AFTER)
199 .map((p) => p.value)
200 .join('');
201
202 const childrenParts = pieces
203 .filter((p) => p.type === PIECE_TYPE.CHILDREN)
204 .map((p) => p.value)
205 .join('');
206
207 let attrsParts = pieces
208 .filter((p) => p.type === PIECE_TYPE.ATTR)
209 .map((p) => p.value)
210 .join(' ');
211
212 attrsParts = attrsParts ? ` ${attrsParts}` : '';
213
214 if (childrenParts) {
215 return `${beforeParts}<${tagName}${attrsParts}>${childrenParts}</${tagName}>${afterParts}`;
216 }
217
218 return `${beforeParts}<${tagName}${attrsParts} />${afterParts}`;
219}
220
221function generateNodeSchema(
222 nodeItem: IPublicTypeNodeSchema,

Callers 1

generateNodeSchemaFunction · 0.85

Calls 2

filterMethod · 0.65
mapMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…