fix @extend

Signed-off-by: houhaoyu <houhaoyu@huawei.com>
Change-Id: I6149aca8befdc3330b2513366e44917b97d2d53e
This commit is contained in:
houhaoyu
2022-03-19 00:06:14 +08:00
parent 60593dda0a
commit 8d2f1bfb55
3 changed files with 8 additions and 2 deletions
+1
View File
@@ -51,6 +51,7 @@ export function createLanguageService(rootFileNames: string[]): ts.LanguageServi
const compilerOptions: ts.CompilerOptions = ts.readConfigFile(
path.resolve(__dirname, '../tsconfig.json'), ts.sys.readFile).config.compilerOptions;
Object.assign(compilerOptions, {
'allowJs': false,
'moduleResolution': ts.ModuleResolutionKind.NodeJs,
'target': ts.ScriptTarget.ES2017,
'baseUrl': path.resolve(projectConfig.projectPath),
+2 -2
View File
@@ -395,8 +395,8 @@ export function collectExtend(collectionSet: Map<string, Set<string>>, component
}
}
function isExtendFunction(node: ts.FunctionDeclaration): string {
if (node.decorators && node.decorators[0].expression &&
export function isExtendFunction(node: ts.FunctionDeclaration): string {
if (node.decorators && node.decorators[0].expression && node.decorators[0].expression.expression &&
node.decorators[0].expression.expression.escapedText.toString() === CHECK_COMPONENT_EXTEND_DECORATOR &&
node.decorators[0].expression.arguments) {
return node.decorators[0].expression.arguments[0].escapedText.toString();
+5
View File
@@ -62,6 +62,7 @@ import {
import { projectConfig } from '../main';
import { collectExtend } from './process_ui_syntax';
import { importModuleCollection } from "./ets_checker";
import { isExtendFunction } from "./process_ui_syntax";
export interface ComponentCollection {
entryComponent: string;
@@ -300,6 +301,10 @@ function visitAllNode(node: ts.Node, sourceFileNode: ts.SourceFile, allComponent
if (ts.isMethodDeclaration(node) && hasDecorator(node, COMPONENT_BUILDER_DECORATOR)) {
CUSTOM_BUILDER_METHOD.add(node.name.getText());
}
if (ts.isFunctionDeclaration(node) && isExtendFunction(node)) {
let componentName: string = isExtendFunction(node);
collectExtend(EXTEND_ATTRIBUTE, componentName, node.name.getText());
}
node.getChildren().forEach((item: ts.Node) => visitAllNode(item, sourceFileNode, allComponentNames, log));
}