diff --git a/checker/ets/helpers.cpp b/checker/ets/helpers.cpp index fe56e102cca02f4adac24c8640e3d3ef0c04a66b..c58e782e5544cb7995704b522a1e341875f61b76 100644 --- a/checker/ets/helpers.cpp +++ b/checker/ets/helpers.cpp @@ -883,6 +883,12 @@ std::vector ETSChecker::GetNameForSynteticObjectType(const uti } } + // Handle './' type of imports. + if (synthetic_name.empty()) { + util::UString s_v(std::string("."), Allocator()); + synthetic_name.emplace_back(s_v.View()); + } + return synthetic_name; } diff --git a/test/parser/ets/import_tests/relative_import/import_all_alias_relative-expected.txt b/test/parser/ets/import_tests/relative_import/import_all_alias_relative-expected.txt new file mode 100644 index 0000000000000000000000000000000000000000..d0ec543de45c19128ff7eeb4606dc84b1042075c --- /dev/null +++ b/test/parser/ets/import_tests/relative_import/import_all_alias_relative-expected.txt @@ -0,0 +1,115 @@ +{ + "type": "Program", + "statements": [ + { + "type": "ImportDeclaration", + "source": { + "type": "StringLiteral", + "value": "./", + "loc": { + "start": { + "line": 16, + "column": 22 + }, + "end": { + "line": 16, + "column": 31 + } + } + }, + "specifiers": [ + { + "type": "ImportNamespaceSpecifier", + "local": { + "type": "Identifier", + "name": "all", + "decorators": [], + "loc": { + "start": { + "line": 16, + "column": 13 + }, + "end": { + "line": 16, + "column": 16 + } + } + }, + "loc": { + "start": { + "line": 16, + "column": 8 + }, + "end": { + "line": 16, + "column": 16 + } + } + } + ], + "loc": { + "start": { + "line": 16, + "column": 1 + }, + "end": { + "line": 16, + "column": 31 + } + } + }, + { + "type": "ClassDeclaration", + "definition": { + "id": { + "type": "Identifier", + "name": "ETSGLOBAL", + "decorators": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "superClass": null, + "implements": [], + "body": [], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + }, + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 1 + } + } + } + ], + "loc": { + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 17, + "column": 1 + } + } +} diff --git a/test/parser/ets/import_tests/relative_import/import_all_alias_relative.ets b/test/parser/ets/import_tests/relative_import/import_all_alias_relative.ets new file mode 100644 index 0000000000000000000000000000000000000000..c9bd0fdd4968c20f103f91bb20206d68ee5101f1 --- /dev/null +++ b/test/parser/ets/import_tests/relative_import/import_all_alias_relative.ets @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2022 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import * as all from "./Point"