已合并
Fix LSP import definition navigation #11174
已合并
wdc创建于 5 天前
wdc
wdc
5 天前

关联的Issue

https://gitcode.com/openharmony/arkcompiler_ets_frontend/issues/11939

提交类型

  • 需求
  • bugfix

需求背景/Description

不涉及。

问题现象&&分析/Reason

[Phenomenon]

  • ArkTS LSP 中,Ctrl+左键点击 import * as aaaa from './test2' 的 namespace alias aaaa,会停留在当前 import 声明,无法打开目标模块。
  • export * as components from './components/tsindex' 中的 alias components 同样无法跳转。

[Root Cause]

  • IDE definition 请求实际进入 api.cpp::GetDefinitionAtPosition。该入口已经负责将字符偏移转换为 UTF-8 字节偏移。
  • GetDefinitionAtPositionImpl 为 namespace alias 找到的是 ImportNamespaceSpecifier 声明;原有通用逻辑只返回该本地声明的位置,没有继续读取所属 import/re-export 的 source。
  • import path 已由 GetImportFilePath 在同一 API 入口提前处理,并已有 GetImportFilePath1 单测覆盖,不属于本次代码修改。

修改方案/Scheme

  • api.cpp 增加 namespace alias 目标模块解析:识别 ImportNamespaceSpecifier,取得其所属的 ETSImportDeclaration
  • 同时兼容普通 namespace import 和 ETSReExportDeclaration 包装的 export * as
  • 普通模块返回 ImportInfo().ResolvedSource()dynamic@ 模块返回 ImportInfo().TextSource()
  • 测试直接调用 IDE 使用的 LSPAPI::getDefinitionAtPosition,不修改或测试无真实调用者的 GetDefinitionAndBoundSpan.

测试结果(测试截图直接贴在对应测试项,主干已知问题需明确引入pr/责任人)

新增以下 LSP gtest 回归用例:

  • GetDefinitionAtPosition_ImportNamespaceAliasDeclaration:覆盖点击 from 前的 alias。
  • GetDefinitionAtPosition_ImportNamespaceModulePath:覆盖点击 from 后的模块路径。
  • GetDefinitionAtPosition_ImportNamespaceAliasUsage:覆盖点击 new aaaa.A() 中的 alias 使用位置。
  • GetDefinitionAtPosition_ReExportNamespaceAliasInDeclaration:覆盖 export * as components

已有 GetImportFilePath1 继续覆盖 import path 通过公开 API 跳转。

本地验证:

  • 修改涉及的 LSP 源文件与测试对象均编译通过。
  • clang-format-14 --dry-run --Werrorgit diff --check 通过。
  • 完整测试目标构建被当前前端/runtime_core 组合的基线接口不匹配阻塞:generateBin.cpp 调用的 ark::panda_file::GetVersionByApi 在 runtime_core 中不存在;该失败与本 PR 修改无关,完整用例结果以本 PR CI 为准。

功能测试(除仅涉及文本外必测项)wiki

  1. es2abc测试用例(Debug模式)
  • 已通过
  • 不涉及,无需验证(仅修改 LSP definition 逻辑及其单元测试)
  1. Verifier测试
  • 已通过
  • 不涉及,无需验证
  1. 64位RK编译
  • 已通过
  • 不涉及,无需验证
  1. 编译mac平台sdk
  • 已通过
  • 不涉及,无需验证

混淆测试(涉及arkguard改动时必测项)wiki

  1. 单元测试
  • 已通过
  • 不涉及,无需验证(未修改 arkguard)
  1. Compiler测试套
  • 已通过
  • 不涉及,无需验证
  1. TSC extra测试套
  • 已通过
  • 不涉及,无需验证
  1. Test262测试套
  • 已通过
  • 不涉及,无需验证
  1. Benchmark测试
  • 已通过
  • 不涉及,无需验证
  1. 应用自动化测试套
  • 已通过
  • 不涉及,无需验证
  1. 是否创建全局变量,若创建全局变量,是否有清空操作
  • 创建了全局变量,且已清空
  • 创建了全局变量,未清空
  • 未创建全局变量

兼容性测试(指令生成、文件格式修改时)

  1. 小版本兼容性测试
  • 已增加版本号
  • 已通过
  • 不涉及,无需验证
  1. 大版本兼容性测试
  • 已通过
  • 不涉及,无需验证
  1. es2abc版本兼容性测试
  • 涉及,变更影响 API/字节码版本,需同步修改到其他分支
  • 涉及,变更影响 API/字节码版本,无需同步到其他分支
  • 不涉及,变更不涉及 API/字节码版本
  1. 是否涉及词法环境修改
  • 涉及,影响热重载场景,需排查影响
  • 涉及,不影响热重载场景
  • 不涉及

性能测试(新增语法检查等场景)

  • 已通过
  • 不涉及,无需验证

指令/abc格式修改自检

  • 涉及,已同步
  • 不涉及

是否已执行L0用例

  • 已验证
  • 不涉及。仅修改 LSP definition 查询逻辑,不影响编译产物或运行时行为。
likedislike
Pull Request已成功合入, 合并人@openharmony_ci
(感谢 wdc 的贡献)
wdcwdc
5 天前 关联了issue:[LSP][Bug] Ctrl+click on namespace import alias or import path cannot navigate to target module
openharmony_ciopenharmony_ci成员
5 天前 添加了label:waiting_on_author
openharmony_ci
openharmony_ci成员
5 天前 评论:

感谢提交 Pull Requests !此PR未通过DCO校验。
校验失败可能原因:

1. 未签署“DCO协议”(开发者原创声明协议),在线签署、查看签署状态

2. Commits 中未包含 Signed-off-by信息,参考FAQ处理

修复上述问题后,在PR的评论框输入“check dco” ,单击”评论”,系统将再次进行DCO校验。

当前检测到如下Commits 未包含Signed-off-by信息:


Thanks for submitting a pull request. This pull request has not passed the DCO check.
Possible causes:

1. You have not signed the Developer Certificate of Origin (DCO). Sign the DCO and check DCO status.

2. The commits do not contain the Signed-off-by information. To resolve this issue, see FAQs.

After resolving the preceding issues, enter check dco in the comment box of this pull request and click Comment. The system will check DCO status again.

The following commits do not contain the Signed-off-by information:

likedislike
openharmony_ciopenharmony_ci成员
5 天前 添加了label:dco检查失败
wdcwdc
5 天前 修改了pull request 的描述
此处折叠了211条消息 查看更多
wdc
wdc
4 小时前 评论:

submit

likedislike
openharmony_ciopenharmony_ci成员
4 小时前 关闭了关联的issue
openharmony_ciopenharmony_ci成员
4 小时前 合入了pull request,合并节点 SHA:d555b817fe82b2bb3f842c2d949fad09b7159be3
openharmony_ciopenharmony_ci成员
4 小时前 删除了label:waiting_for_review
openharmony_ciopenharmony_ci成员
4 小时前 添加了label:merged