!450 [Linter] 回退SendableFunction相关问题修复

Merge pull request !450 from azwenqiang/0812_bugfix_faultId
This commit is contained in:
openharmony_ci 2024-08-14 03:26:23 +00:00 committed by Gitee
commit 347b48503a
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
6 changed files with 21 additions and 16 deletions

View File

@ -198426,7 +198426,7 @@ var ts;
var _this = this;
var callback = function (node) {
// Namespace import will introduce closure in the es2abc compiler stage
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node, faultId)) {
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node)) {
return;
}
// The "b" of "A.b" should not be checked since it's load from object "A"
@ -198502,13 +198502,13 @@ var ts;
}
return false;
};
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node, faultId) {
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node) {
// Namespace import cannot be determined by the true symbol
var sym = TypeScriptLinter.tsTypeChecker.getSymbolAtLocation(node);
var decls = sym === null || sym === void 0 ? void 0 : sym.getDeclarations();
if (decls === null || decls === void 0 ? void 0 : decls.length) {
if (ts.isNamespaceImport(decls[0])) {
this.incrementCounters(node, faultId);
this.incrementCounters(node, FaultID.SendableCapturedVars);
return true;
}
}

View File

@ -198171,7 +198171,7 @@ var ts;
var _this = this;
var callback = function (node) {
// Namespace import will introduce closure in the es2abc compiler stage
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node, faultId)) {
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node)) {
return;
}
// The "b" of "A.b" should not be checked since it's load from object "A"
@ -198247,13 +198247,13 @@ var ts;
}
return false;
};
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node, faultId) {
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node) {
// Namespace import cannot be determined by the true symbol
var sym = TypeScriptLinter.tsTypeChecker.getSymbolAtLocation(node);
var decls = sym === null || sym === void 0 ? void 0 : sym.getDeclarations();
if (decls === null || decls === void 0 ? void 0 : decls.length) {
if (ts.isNamespaceImport(decls[0])) {
this.incrementCounters(node, faultId);
this.incrementCounters(node, FaultID.SendableCapturedVars);
return true;
}
}

View File

@ -187265,7 +187265,7 @@ var ts;
var _this = this;
var callback = function (node) {
// Namespace import will introduce closure in the es2abc compiler stage
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node, faultId)) {
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node)) {
return;
}
// The "b" of "A.b" should not be checked since it's load from object "A"
@ -187341,13 +187341,13 @@ var ts;
}
return false;
};
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node, faultId) {
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node) {
// Namespace import cannot be determined by the true symbol
var sym = TypeScriptLinter.tsTypeChecker.getSymbolAtLocation(node);
var decls = sym === null || sym === void 0 ? void 0 : sym.getDeclarations();
if (decls === null || decls === void 0 ? void 0 : decls.length) {
if (ts.isNamespaceImport(decls[0])) {
this.incrementCounters(node, faultId);
this.incrementCounters(node, FaultID.SendableCapturedVars);
return true;
}
}

View File

@ -187265,7 +187265,7 @@ var ts;
var _this = this;
var callback = function (node) {
// Namespace import will introduce closure in the es2abc compiler stage
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node, faultId)) {
if (!ts.isIdentifier(node) || _this.checkNamespaceImportVar(node)) {
return;
}
// The "b" of "A.b" should not be checked since it's load from object "A"
@ -187341,13 +187341,13 @@ var ts;
}
return false;
};
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node, faultId) {
TypeScriptLinter.prototype.checkNamespaceImportVar = function (node) {
// Namespace import cannot be determined by the true symbol
var sym = TypeScriptLinter.tsTypeChecker.getSymbolAtLocation(node);
var decls = sym === null || sym === void 0 ? void 0 : sym.getDeclarations();
if (decls === null || decls === void 0 ? void 0 : decls.length) {
if (ts.isNamespaceImport(decls[0])) {
this.incrementCounters(node, faultId);
this.incrementCounters(node, FaultID.SendableCapturedVars);
return true;
}
}

View File

@ -47,7 +47,12 @@ export function runArkTSLinter(tsBuilderProgram: BuilderProgram, srcFile?: Sourc
const tscDiagnosticsLinter = new TSCCompiledProgram(tsBuilderProgram);
const program = tscDiagnosticsLinter.getProgram();
const compilerOptions = program.getCompilerOptions();
const changedFiles = collectChangedFilesFromProgramState(programState, arkTSVersion, compilerOptions.compatibleSdkVersion, compilerOptions.compatibleSdkVersionStage);
const changedFiles = collectChangedFilesFromProgramState(
programState,
arkTSVersion,
compilerOptions.compatibleSdkVersion,
compilerOptions.compatibleSdkVersionStage
);
// Set arkTSVersion info for file .tsbuildinfo.
// File .tsbuildinfo.linter dosen't need to set arkTSVersion because it dosen't contain linter diagnostics.
programState.arkTSVersion = arkTSVersion;

View File

@ -1307,7 +1307,7 @@ export class TypeScriptLinter {
private scanCapturedVarsInSendableScope(startNode: ts.Node, scope: ts.Node, faultId: FaultID): void {
const callback = (node: ts.Node): void => {
// Namespace import will introduce closure in the es2abc compiler stage
if (!ts.isIdentifier(node) || this.checkNamespaceImportVar(node, faultId)) {
if (!ts.isIdentifier(node) || this.checkNamespaceImportVar(node)) {
return;
}
@ -1397,13 +1397,13 @@ export class TypeScriptLinter {
return false;
}
private checkNamespaceImportVar(node: ts.Node, faultId: FaultID): boolean {
private checkNamespaceImportVar(node: ts.Node): boolean {
// Namespace import cannot be determined by the true symbol
const sym = TypeScriptLinter.tsTypeChecker.getSymbolAtLocation(node);
const decls = sym?.getDeclarations();
if (decls?.length) {
if (ts.isNamespaceImport(decls[0])) {
this.incrementCounters(node, faultId);
this.incrementCounters(node, FaultID.SendableCapturedVars);
return true;
}
}