!516 the codecheck of the related pr about kit performance
Some checks failed
CI / build (10.x) (push) Has been cancelled
CI / build (12.x) (push) Has been cancelled
CI / build (14.x) (push) Has been cancelled
Code scanning - action / CodeQL-Build (push) Has been cancelled
Update package-lock.json / build (push) Has been cancelled
Publish Nightly / build (push) Has been cancelled
Twoslash Code Sample Repros / build (push) Has been cancelled

Merge pull request !516 from liyancheng/kit-codecheck
This commit is contained in:
openharmony_ci 2024-11-11 09:21:36 +00:00 committed by Gitee
commit 1cd64675c7
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
9 changed files with 67 additions and 67 deletions

View File

@ -39301,7 +39301,7 @@ var ts;
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
ts.isSendableFunctionOrType = isSendableFunctionOrType;
var JSON_SUFFIX = ".json";
var JSON_SUFFIX = '.json';
var KIT_PREFIX = '@kit.';
var DEFAULT_KEYWORD = 'default';
var ETS_DECLARATION = '.d.ets';
@ -39405,7 +39405,7 @@ var ts;
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
function inWhiteList(moduleSpecifierText, importName, inEtsContext) {
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
return true;
}
@ -39438,7 +39438,7 @@ var ts;
}
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
var aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError_1 = true;
return;
}

View File

@ -47719,7 +47719,7 @@ var ts;
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
ts.isSendableFunctionOrType = isSendableFunctionOrType;
var JSON_SUFFIX = ".json";
var JSON_SUFFIX = '.json';
var KIT_PREFIX = '@kit.';
var DEFAULT_KEYWORD = 'default';
var ETS_DECLARATION = '.d.ets';
@ -47831,7 +47831,7 @@ var ts;
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
function inWhiteList(moduleSpecifierText, importName, inEtsContext) {
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
return true;
}
@ -47865,7 +47865,7 @@ var ts;
}
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
var aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError_1 = true;
return;
}
@ -172344,13 +172344,12 @@ var ts;
while (pos < end) {
var token = ts.scanner.scan();
var textPos = ts.scanner.getTextPos();
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
if (textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
var isSourceFileOrInMarkedKitImport = !ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos);
if (isSourceFileOrInMarkedKitImport && textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
}
pos = textPos;
if (token === 1 /* SyntaxKind.EndOfFileToken */) {

View File

@ -47718,7 +47718,7 @@ var ts;
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
ts.isSendableFunctionOrType = isSendableFunctionOrType;
var JSON_SUFFIX = ".json";
var JSON_SUFFIX = '.json';
var KIT_PREFIX = '@kit.';
var DEFAULT_KEYWORD = 'default';
var ETS_DECLARATION = '.d.ets';
@ -47830,7 +47830,7 @@ var ts;
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
function inWhiteList(moduleSpecifierText, importName, inEtsContext) {
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
return true;
}
@ -47864,7 +47864,7 @@ var ts;
}
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
var aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError_1 = true;
return;
}
@ -172763,13 +172763,12 @@ var ts;
while (pos < end) {
var token = ts.scanner.scan();
var textPos = ts.scanner.getTextPos();
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
if (textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
var isSourceFileOrInMarkedKitImport = !ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos);
if (isSourceFileOrInMarkedKitImport && textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
}
pos = textPos;
if (token === 1 /* SyntaxKind.EndOfFileToken */) {

View File

@ -47709,7 +47709,7 @@ var ts;
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
ts.isSendableFunctionOrType = isSendableFunctionOrType;
var JSON_SUFFIX = ".json";
var JSON_SUFFIX = '.json';
var KIT_PREFIX = '@kit.';
var DEFAULT_KEYWORD = 'default';
var ETS_DECLARATION = '.d.ets';
@ -47821,7 +47821,7 @@ var ts;
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
function inWhiteList(moduleSpecifierText, importName, inEtsContext) {
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
return true;
}
@ -47855,7 +47855,7 @@ var ts;
}
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
var aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError_1 = true;
return;
}
@ -172754,13 +172754,12 @@ var ts;
while (pos < end) {
var token = ts.scanner.scan();
var textPos = ts.scanner.getTextPos();
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
if (textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
var isSourceFileOrInMarkedKitImport = !ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos);
if (isSourceFileOrInMarkedKitImport && textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
}
pos = textPos;
if (token === 1 /* SyntaxKind.EndOfFileToken */) {

View File

@ -47709,7 +47709,7 @@ var ts;
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
ts.isSendableFunctionOrType = isSendableFunctionOrType;
var JSON_SUFFIX = ".json";
var JSON_SUFFIX = '.json';
var KIT_PREFIX = '@kit.';
var DEFAULT_KEYWORD = 'default';
var ETS_DECLARATION = '.d.ets';
@ -47821,7 +47821,7 @@ var ts;
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
function inWhiteList(moduleSpecifierText, importName, inEtsContext) {
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
return true;
}
@ -47855,7 +47855,7 @@ var ts;
}
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
var aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError_1 = true;
return;
}
@ -172754,13 +172754,12 @@ var ts;
while (pos < end) {
var token = ts.scanner.scan();
var textPos = ts.scanner.getTextPos();
if (!ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos)) {
if (textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
var isSourceFileOrInMarkedKitImport = !ts.isSourceFile(parent) || !ts.isInMarkedKitImport(parent, pos, textPos);
if (isSourceFileOrInMarkedKitImport && textPos <= end) {
if (token === 79 /* SyntaxKind.Identifier */) {
ts.Debug.fail("Did not expect ".concat(ts.Debug.formatSyntaxKind(parent.kind), " to have an Identifier in its trivia"));
}
nodes.push(createNode(token, pos, textPos, parent));
}
pos = textPos;
if (token === 1 /* SyntaxKind.EndOfFileToken */) {

View File

@ -47699,7 +47699,7 @@ var ts;
return (ts.isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
ts.isSendableFunctionOrType = isSendableFunctionOrType;
var JSON_SUFFIX = ".json";
var JSON_SUFFIX = '.json';
var KIT_PREFIX = '@kit.';
var DEFAULT_KEYWORD = 'default';
var ETS_DECLARATION = '.d.ets';
@ -47811,7 +47811,7 @@ var ts;
'@kit.AccountKit', '@kit.MapKit', '@kit.Penkit', '@kit.ScenarioFusionKit',
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText, importName, inEtsContext) {
function inWhiteList(moduleSpecifierText, importName, inEtsContext) {
if (whiteListForErrorSymbol.some(function (info) { return (info.kitName === moduleSpecifierText && info.symbolName === importName); })) {
return true;
}
@ -47845,7 +47845,7 @@ var ts;
}
var importName = ts.unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
var aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError_1 = true;
return;
}

View File

@ -1056,10 +1056,10 @@ namespace ts {
return (isIdentifier(nameExpr) && nameExpr.escapedText.toString() === 'Sendable');
}
const JSON_SUFFIX = ".json";
const JSON_SUFFIX = '.json';
const KIT_PREFIX = '@kit.';
const DEFAULT_KEYWORD = 'default';
const ETS_DECLARATION = '.d.ets'
const ETS_DECLARATION = '.d.ets';
const OHOS_KIT_CONFIG_PATH = './openharmony/ets/build-tools/ets-loader/kit_configs';
const HMS_KIT_CONFIG_PATH = './hms/ets/build-tools/ets-loader/kit_configs';
@ -1122,7 +1122,9 @@ namespace ts {
function createNameImportDeclaration(factory: NodeFactory, isType: boolean, name: Identifier, source: string,
oldStatement: ImportDeclaration, importSpecifier: TextRange): ImportDeclaration {
const oldModuleSpecifier = oldStatement.moduleSpecifier;
const newModuleSpecifier = setNoOriginalText(setVirtualNodeAndKitImportFlags(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
const newModuleSpecifier = setNoOriginalText(setVirtualNodeAndKitImportFlags(
factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end)
);
const newImportClause = setVirtualNodeAndKitImportFlags(factory.createImportClause(isType, name, undefined), importSpecifier.pos, importSpecifier.end);
const newImportDeclaration = setVirtualNodeAndKitImportFlags(
factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
@ -1132,14 +1134,17 @@ namespace ts {
function createBindingImportDeclaration(factory: NodeFactory, isType: boolean, propname: string, name: Identifier, source: string,
oldStatement: ImportDeclaration, importSpecifier: TextRange): ImportDeclaration {
const oldModuleSpecifier = oldStatement.moduleSpecifier;
const newModuleSpecifier = setNoOriginalText(setVirtualNodeAndKitImportFlags(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
const newModuleSpecifier = setNoOriginalText(
setVirtualNodeAndKitImportFlags(factory.createStringLiteral(source), oldModuleSpecifier.pos, oldModuleSpecifier.end));
const newPropertyName = setNoOriginalText(setVirtualNodeAndKitImportFlags(factory.createIdentifier(propname), name.pos, name.end));
// The location information of the newImportSpecific is created using the location information of the old importSpecifier.
const newImportSpecific = setVirtualNodeAndKitImportFlags(factory.createImportSpecifier(false, newPropertyName, name), importSpecifier.pos, importSpecifier.end);
const newImportSpecific = setVirtualNodeAndKitImportFlags(
factory.createImportSpecifier(false, newPropertyName, name), importSpecifier.pos, importSpecifier.end);
// The location information of the newNamedBindings is created using the location information of the old importSpecifier.
const newNamedBindings = setVirtualNodeAndKitImportFlags(factory.createNamedImports([newImportSpecific]), importSpecifier.pos, importSpecifier.end);
// The location information of the newImportClause is created using the location information of the old importSpecifier.
const newImportClause = setVirtualNodeAndKitImportFlags(factory.createImportClause(isType, undefined, newNamedBindings), importSpecifier.pos, importSpecifier.end);
const newImportClause = setVirtualNodeAndKitImportFlags(
factory.createImportClause(isType, undefined, newNamedBindings), importSpecifier.pos, importSpecifier.end);
const newImportDeclaration = setVirtualNodeAndKitImportFlags(
factory.createImportDeclaration(undefined, newImportClause, newModuleSpecifier), oldStatement.pos, oldStatement.end);
return newImportDeclaration;
@ -1169,14 +1174,14 @@ namespace ts {
}
function excludeStatementForKitImport(statement: Statement): boolean {
if (!isImportDeclaration(statement) || // check is ImportDeclaration
!statement.importClause || // exclude import 'mode'
statement.importClause.isLazy || // exclude import lazy, it may report error
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
!isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
if (!isImportDeclaration(statement) || // check is ImportDeclaration
!statement.importClause || // exclude import 'mode'
statement.importClause.isLazy || // exclude import lazy, it may report error
(statement.importClause.namedBindings && ts.isNamespaceImport(statement.importClause.namedBindings)) || // exclude namespace import
!isStringLiteral(statement.moduleSpecifier) || statement.illegalDecorators || // exclude if may has error
!statement.moduleSpecifier.text.startsWith(KIT_PREFIX) || // is not kit import
statement.modifiers || // exclude if has modifiers
statement.assertClause) { // not support assertClause
statement.modifiers || // exclude if has modifiers
statement.assertClause) { // not support assertClause
return true;
}
return false;
@ -1204,7 +1209,7 @@ namespace ts {
'@kit.ServiceCollaborationKit', '@kit.SpeechKit', '@kit.VisionKit',
]);
function InWhiteList(moduleSpecifierText: string, importName: string, inEtsContext: boolean): boolean {
function inWhiteList(moduleSpecifierText: string, importName: string, inEtsContext: boolean): boolean {
if (whiteListForErrorSymbol.some(info => (info.kitName === moduleSpecifierText && info.symbolName === importName))) {
return true;
}
@ -1244,7 +1249,7 @@ namespace ts {
const importName = unescapeLeadingUnderscores(element.propertyName ? element.propertyName.escapedText : element.name.escapedText);
const aliasName = element.name;
if (InWhiteList(moduleSpecifierText, importName, inEtsContext)) {
if (inWhiteList(moduleSpecifierText, importName, inEtsContext)) {
hasError = true;
return;
}
@ -1303,7 +1308,7 @@ namespace ts {
list.push(...newImportStatements);
markKitImport(statement, markedkitImportRanges);
}
)
);
return list;
}
}

View File

@ -802,9 +802,9 @@ namespace ts {
/* @internal */ TypeCached = 1 << 27, // If a type was cached for node at any point
/* @internal */ Deprecated = 1 << 28, // If has '@deprecated' JSDoc tag
/* @internal */ KitImportFlags = 1 << 29, // If node was in a converted kit-import statement
EtsContext = 1 << 30, // If context was parsed as a Struct
/* @internal */ NoOriginalText = 1 << 31, // If don't has original text in source file
/* @internal */ KitImportFlags = 1 << 29, // If node was in a converted kit-import statement
EtsContext = 1 << 30, // If context was parsed as a Struct
/* @internal */ NoOriginalText = 1 << 31, // If don't has original text in source file
BlockScoped = Let | Const,

View File

@ -184,13 +184,12 @@ namespace ts {
while (pos < end) {
const token = scanner.scan();
const textPos = scanner.getTextPos();
if (!isSourceFile(parent) || !isInMarkedKitImport(parent, pos, textPos)) {
if (textPos <= end) {
if (token === SyntaxKind.Identifier) {
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent.kind)} to have an Identifier in its trivia`);
}
nodes.push(createNode(token, pos, textPos, parent));
const isSourceFileOrInMarkedKitImport: boolean = !isSourceFile(parent) || !isInMarkedKitImport(parent, pos, textPos);
if (isSourceFileOrInMarkedKitImport && textPos <= end) {
if (token === SyntaxKind.Identifier) {
Debug.fail(`Did not expect ${Debug.formatSyntaxKind(parent.kind)} to have an Identifier in its trivia`);
}
nodes.push(createNode(token, pos, textPos, parent));
}
pos = textPos;
if (token === SyntaxKind.EndOfFileToken) {