• Home
  • Raw
  • Download

Lines Matching refs:node

142     return (node: ts.SourceFile) => {
143 const hasTsNoCheckOrTsIgnore = ts.hasTsNoCheckOrTsIgnoreFlag(node);
144 compilingEtsOrTsFiles.push(path.normalize(node.fileName));
145 pagesDir = path.resolve(path.dirname(node.fileName));
146 resourceFileName = path.resolve(node.fileName);
148 storedFileInfo.transformCacheFiles[node.fileName] = {
149 mtimeMs: fs.existsSync(node.fileName) ? fs.statSync(node.fileName).mtimeMs : 0,
152 transformLog.sourceFile = node;
153 preprocessIdAttrs(node.fileName);
155 path.resolve(node.fileName) === path.resolve(projectConfig.projectPath, 'app.ets') ||
156 /\.ts$/.test(node.fileName))) {
157 node = ts.visitEachChild(node, processResourceNode, context);
160 … const processedNode: ts.SourceFile = ts.getTypeExportImportAndConstEnumTransformer(context)(node);
169 return node;
172 node = ts.visitEachChild(node, processAllNodes, context);
173 node = createEntryNode(node, context, entryNodeKey, id);
178 const statements: ts.Statement[] = Array.from(node.statements);
180 generateId(statements, node);
185 node = ts.factory.updateSourceFile(node, statements);
188 … const processedNode: ts.SourceFile = ts.getTypeExportImportAndConstEnumTransformer(context)(node);
196 return node;
198 return node;
202 function entryKeyNode(node: ts.Node): ts.Expression {
203 if (node && node.decorators && node.decorators.length) {
204 node.decorators.forEach(item => {
215 function isESObjectNode(node: ts.Node): boolean {
216 if (node.kind === ts.SyntaxKind.TypeReference) {
217 const n: TypeReferenceNode = node as TypeReferenceNode;
225 function processAllNodes(node: ts.Node): ts.Node {
227 ts.isImportDeclaration(node)) {
228 processImportModule(node);
230 (ts.isImportDeclaration(node) || ts.isImportEqualsDeclaration(node) ||
231 …ts.isExportDeclaration(node) && node.moduleSpecifier && ts.isStringLiteral(node.moduleSpecifier)))…
232 processImport(node, pagesDir, transformLog.errors);
234 if (ts.isStructDeclaration(node)) {
235 componentCollection.currentClassName = node.name.getText();
236 … componentCollection.entryComponent === componentCollection.currentClassName && entryKeyNode(node);
237 node = processComponentClass(node, context, transformLog.errors, program);
243 } else if (ts.isFunctionDeclaration(node)) {
244 if (hasDecorator(node, COMPONENT_EXTEND_DECORATOR, null, transformLog.errors)) {
245 node = processExtend(node, transformLog.errors, COMPONENT_EXTEND_DECORATOR);
246 } else if (hasDecorator(node, COMPONENT_BUILDER_DECORATOR) && node.name && node.body &&
247 ts.isBlock(node.body)) {
248 CUSTOM_BUILDER_METHOD.add(node.name.getText());
249 builderTypeParameter.params = getPossibleBuilderTypeParameter(node.parameters);
251 ts.factory.createNodeArray(Array.from(node.parameters));
253 node = ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers,
254 node.asteriskToken, node.name, node.typeParameters, parameters, node.type,
255 processComponentBlock(node.body, false, transformLog.errors, false, true,
256 node.name.getText(), undefined, true));
258 node = processBuildMember(node, context, transformLog.errors, true);
259 } else if (hasDecorator(node, COMPONENT_STYLES_DECORATOR)) {
260 if (node.parameters.length === 0) {
261 node = undefined;
266 pos: node.getStart()
269 } else if (hasDecorator(node, COMPONENT_CONCURRENT_DECORATOR)) {
271 node = processConcurrent(node);
272 … } else if (hasDecorator(node, COMPONENT_ANIMATABLE_EXTEND_DECORATOR, null, transformLog.errors)) {
273 node = processExtend(node, transformLog.errors, COMPONENT_ANIMATABLE_EXTEND_DECORATOR);
275 } else if (isResource(node)) {
276 node = processResourceData(node as ts.CallExpression);
277 } else if (isWorker(node)) {
278 node = processWorker(node as ts.NewExpression);
279 } else if (isAnimateTo(node)) {
280 node = processAnimateTo(node as ts.CallExpression);
281 } else if (isCustomDialogController(node)) {
282 node = createCustomDialogController(node.parent, node, transformLog.errors);
283 } else if (isESObjectNode(node)) {
284 node = ts.factory.createKeywordTypeNode(ts.SyntaxKind.AnyKeyword);
286 return ts.visitEachChild(node, processAllNodes, context);
288 function processResourceNode(node: ts.Node): ts.Node {
289 if (isResource(node)) {
290 node = processResourceData(node as ts.CallExpression);
292 return ts.visitEachChild(node, processResourceNode, context);
297 function generateId(statements: ts.Statement[], node: ts.SourceFile): void {
321 ts.factory.createStringLiteral(path.basename(node.fileName, EXTNAME_ETS) + '_'),
340 function isCustomDialogController(node: ts.Expression) {
341 const tempParent: ts.Node = node.parent;
343 if (!node.parent && node.original) {
345 node.parent = node.original.parent;
347 if (ts.isNewExpression(node) && node.expression && ts.isIdentifier(node.expression) &&
348 node.expression.escapedText.toString() === SET_CONTROLLER_CTR_TYPE) {
352 node.parent = tempParent;
357 function createCustomDialogController(parent: ts.Expression, node: ts.NewExpression,
359 if (node.arguments && node.arguments.length === 1 &&
360 ts.isObjectLiteralExpression(node.arguments[0]) && node.arguments[0].properties) {
361 … const newproperties: ts.ObjectLiteralElementLike[] = node.arguments[0].properties.map((item) => {
369 return ts.factory.createNewExpression(node.expression, node.typeArguments,
372 return node;
376 function isCustomDialogControllerPropertyAssignment(node: ts.ObjectLiteralElementLike,
378 if (ts.isPropertyAssignment(node) && ts.isIdentifier(node.name) &&
379 node.name.getText() === CUSTOM_DIALOG_CONTROLLER_BUILDER) {
380 if (node.initializer) {
381 const componentName: string = getName(node.initializer);
386 validateCustomDialogControllerBuilderInit(node, log);
392 function validateCustomDialogControllerBuilderInit(node: ts.ObjectLiteralElementLike,
397 pos: node.getStart()
402 node: ts.PropertyAssignment, componentName: string): ts.PropertyAssignment {
403 if (ts.isCallExpression(node.initializer)) {
404 return ts.factory.updatePropertyAssignment(node, node.name,
405 processCustomDialogControllerBuilder(parent, node.initializer, componentName));
410 node: ts.CallExpression, componentName: string): ts.ArrowFunction {
411 …const newExp: ts.Expression = createCustomComponentNewExpression(node, componentName, false, false…
413 return createCustomComponentBuilderArrowFunction(node, parent, jsDialog, newExp);
416 function createCustomComponentBuilderArrowFunction(node: ts.CallExpression, parent: ts.Expression,
433 partialUpdateConfig.partialUpdateMode ? assignComponentParams(node) : undefined,
458 export function isResource(node: ts.Node): boolean {
459 return ts.isCallExpression(node) && ts.isIdentifier(node.expression) &&
460 (node.expression.escapedText.toString() === RESOURCE ||
461 node.expression.escapedText.toString() === RESOURCE_RAWFILE) && node.arguments.length > 0;
464 export function isAnimateTo(node: ts.Node): boolean {
465 return ts.isCallExpression(node) && ts.isIdentifier(node.expression) &&
466 node.expression.escapedText.toString() === ATTRIBUTE_ANIMATETO;
469 export function processResourceData(node: ts.CallExpression,
471 if (ts.isStringLiteral(node.arguments[0])) {
472 if (node.expression.getText() === RESOURCE_RAWFILE) {
473 isResourcefile(node, previewLog);
474 return createResourceParam(0, RESOURCE_TYPE.rawfile, [node.arguments[0]]);
476 return getResourceDataNode(node, previewLog);
479 return node;
482 function getResourceDataNode(node: ts.CallExpression,
484 const resourceData: string[] = (node.arguments[0] as ts.StringLiteral).text.trim().split('.');
485 if (preCheckResourceData(resourceData, resources, node.arguments[0].getStart(), previewLog)) {
491 pos: node.getStart()
493 return node;
497 projectConfig.compileHar ? Array.from(node.arguments) : Array.from(node.arguments).slice(1));
499 return node;
502 function isResourcefile(node: ts.CallExpression, previewLog: {isAcceleratePreview: boolean, log: Lo…
503 if (process.env.rawFileResource && !storedFileInfo.resourcesArr.has(node.arguments[0].text) &&
507 message: `No such '${node.arguments[0].text}' resource in current module.`,
508 pos: node.getStart()
600 function isWorker(node: ts.Node): boolean {
601 return ts.isNewExpression(node) && ts.isPropertyAccessExpression(node.expression) &&
602 ts.isIdentifier(node.expression.name) &&
603 node.expression.name.escapedText.toString() === WORKER_OBJECT;
606 function processWorker(node: ts.NewExpression): ts.Node {
607 if (node.arguments.length && ts.isStringLiteral(node.arguments[0])) {
608 const args: ts.Expression[] = Array.from(node.arguments);
610 const workerPath: string = node.arguments[0].text;
614 return ts.factory.updateNewExpression(node, node.expression, node.typeArguments, args);
616 return node;
619 export function processAnimateTo(node: ts.CallExpression): ts.CallExpression {
620 return ts.factory.updateCallExpression(node, ts.factory.createPropertyAccessExpression(
622 node.typeArguments, node.arguments);
625 function processExtend(node: ts.FunctionDeclaration, log: LogInfo[],
627 …const componentName: string = isExtendFunction(node, { decoratorName: '', componentName: '' }, tru…
628 if (componentName && node.body && node.body.statements.length) {
632 const attrSet: ts.CallExpression = node.body.statements[0].expression;
633 if (isOriginalExtend(node.body)) {
638 bodynode = ts.visitEachChild(node.body, traverseExtendExpression, contextGlobal);
641 if (node.name.getText().startsWith('__' + componentName + '__')) {
642 extendFunctionName = node.name.getText();
644 extendFunctionName = '__' + componentName + '__' + node.name.getText();
645 collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.escapedText.toString());
647 … return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken,
648 ts.factory.createIdentifier(extendFunctionName), node.typeParameters,
649node.parameters, ts.factory.createToken(ts.SyntaxKind.VoidKeyword), isOriginalExtend(node.body) ?
650 ts.factory.updateBlock(node.body, statementArray) : bodynode);
653 bindComponentAttr(node.body.statements[0],
655 … return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken,
656 node.name, node.typeParameters,
657 …[...node.parameters, ...createAnimatableParameterNode()], ts.factory.createToken(ts.SyntaxKind.Voi…
658 ts.factory.updateBlock(node.body, createAnimatableBody(componentName, node.name,
659 node.parameters, statementArray)));
662 function traverseExtendExpression(node: ts.Node): ts.Node {
663 if (ts.isExpressionStatement(node) && isDollarNode(node, componentName)) {
665 ts.factory.createExpressionStatement(processExtendBody(node.expression, componentName));
670 return ts.visitEachChild(node, traverseExtendExpression, contextGlobal);
760 function processConcurrent(node: ts.FunctionDeclaration): ts.FunctionDeclaration {
761 if (node.body) {
764 ...node.body.statements];
765 …return ts.factory.updateFunctionDeclaration(node, undefined, node.modifiers, node.asteriskToken, n…
766node.typeParameters, node.parameters, node.type, ts.factory.updateBlock(node.body, statementArray)…
768 return node;
771 export function isOriginalExtend(node: ts.Block): boolean {
772 let innerNode: ts.Node = node.statements[0];
773 if (node.statements.length === 1 && ts.isExpressionStatement(innerNode)) {
785 function isDollarNode(node: ts.ExpressionStatement, componentName: string): boolean {
786 let innerNode: ts.Node = node;
801 function processExtendBody(node: ts.Node, componentName?: string): ts.Expression {
802 switch (node.kind) {
804 return ts.factory.createCallExpression(processExtendBody(node.expression, componentName),
805 undefined, node.arguments);
808 processExtendBody(node.expression, componentName), node.name);
811 return ts.factory.createIdentifier(node.escapedText.toString().replace(INSTANCE, ''));
826 export function isExtendFunction(node: ts.FunctionDeclaration, extendResult: ExtendResult,
828 if (node.decorators && node.decorators.length) {
829 for (let i = 0, len = node.decorators.length; i < len; i++) {
830 if (ts.isCallExpression(node.decorators[i].expression)) {
831 … parseExtendNode(node.decorators[i].expression as ts.CallExpression, extendResult, checkArguments);
841 function parseExtendNode(node: ts.CallExpression, extendResult: ExtendResult, checkArguments: boole…
842 if (ts.isIdentifier(node.expression)) {
843 extendResult.decoratorName = node.expression.escapedText.toString();
845 node.arguments && node.arguments.length !== 1) {
849 pos: node.getStart()
853 if (node.arguments.length && ts.isIdentifier(node.arguments[0])) {
854 extendResult.componentName = node.arguments[0].escapedText.toString();
858 function createEntryNode(node: ts.SourceFile, context: ts.TransformationContext,
870 return context.factory.updateSourceFile(node, [...node.statements, entryNode]);
876 context.factory.updateSourceFile(node, [...node.statements, ...entryNodes]) :
877 context.factory.updateSourceFile(node, [...node.statements]);
880 return node;
885 return context.factory.updateSourceFile(node, [...node.statements, statementsArray]);