Skip to content

fix: #239 correct suggestion word ranges - #486

Open
liuxy0551 wants to merge 1 commit into
DTStack:nextfrom
liuxy0551:fix_239
Open

fix: #239 correct suggestion word ranges#486
liuxy0551 wants to merge 1 commit into
DTStack:nextfrom
liuxy0551:fix_239

Conversation

@liuxy0551

Copy link
Copy Markdown
Collaborator

问题

  1. 表名信息识别存在不准确 #239

getSuggestionAtCaretPosition 生成表名候选时,table.wordRanges 会错误包含表名后的空格、AS 或别名。

修改内容

  • BasicSQL 中统一计算候选词范围
  • 使用后续最近候选的起始位置截断当前候选
  • 过滤空格、注释等非默认 channel token
  • 保留 db. 等未完成限定表名
  • MySQL、Flink、Spark、Hive、PostgreSQL、Trino、Impala、GenericSQL 统一接入
  • 新增跨方言参数化回归测试

验证

  • 新增测试:34/34 通过
  • pnpm run check-types 通过
  • pnpm run prettier-check 通过
  • git diff --check 通过

#239 中提到的运行结果会是:

{
  "syntax": [
    {
      "syntaxContextType": "table",
      "wordRanges": [
        {
          "text": "current_catalog_schema1",
          "line": 1,
          "startIndex": 14,
          "endIndex": 36,
          "startColumn": 15,
          "endColumn": 38
        }
      ]
    }
  ],
  "keywords": ["FORCE", "IGNORE", "USE", "...", "AS", "..."]
}

@liuxy0551
liuxy0551 requested a review from Cythia828 July 29, 2026 09:11
Comment on lines +107 to +111
const rangeEndTokenIndex =
endTokenIndex <= caretTokenIndex &&
(allTokens[endTokenIndex]?.text === '.' || previousVisibleToken?.text === '.')
? endTokenIndex + 1
: endTokenIndex;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1 只够覆盖单层 db.table。若出现 db.schema.table 且被下一个候选截断在 schema,则 table 会被丢掉。这是未覆盖的边界。看是补一个多层限定名用例确认行为还是说在注释里明确"当前仅支持单层保留"。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants