Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(tools/spxls): improve completion support #1215

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

aofei
Copy link
Member

@aofei aofei commented Jan 9, 2025

Copy link

qiniu-prow bot commented Jan 9, 2025

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

Choose a reason for hiding this comment

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Comments suppressed due to low confidence (2)

spx-gui/src/components/editor/code-editor/document-base/gop.ts:80

  • The 'TODO' comment in the 'definition' field should be resolved to ensure the 'name' is accurate and finalized.
definition: { name: 'import_declaration' }, // TODO

tools/spxls/internal/server/spx_definition.go:310

  • [nitpick] The use of the string literal "main" could be replaced with a constant or predefined variable to avoid magic strings.
if pkg.Path() != "main" {
tools/spxls/internal/server/completion.go Show resolved Hide resolved
tools/spxls/internal/server/completion.go Show resolved Hide resolved
tools/spxls/internal/server/completion.go Show resolved Hide resolved
tools/spxls/internal/server/completion.go Outdated Show resolved Hide resolved
for scope := ctx.innermostScope; scope != nil; scope = scope.Parent() {
for _, name := range scope.Names() {
obj := scope.Lookup(name)
if !isExportedOrMainPkgObject(obj) || !isTypeCompatible(obj.Type(), ctx.expectedType) {
if !isExportedOrMainPkgObject(obj) || !isTypeCompatible(obj.Type(), typ) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: 看到这里代码想到有一种 case,不确定有没有被覆盖到:

println "size:", size
setXpos ypos
currentVisible := visible

按 gop 的设定,这里的 sizeypos 等是希望用户用着就像在用 field(甚至 variable)一样,所以在补全中最好也会出现

Copy link
Member Author

Choose a reason for hiding this comment

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

https://github.com/goplus/builder/compare/e7daa88a627b0ddb675f5e3ab2b0bb1fe5fb897c..c4267bd24fc35158b0a0d7fb65e72f9b08344a47 中调整了一下类型匹配过滤的逻辑,给 SpxDefinition 引入了个 Type 字段,用作在创建 SpxDefinition 时提供的类型提示,这样方便尽可能地采集所有能用的项。

另外 println 有点特殊,它被识别成了 invalid type 且没有签名,应该是因为 gop 对这几个 builtin 方法做了特殊转换的关系。这个我打算放到后面要做的 gop builtin 支持中一起处理。

Copy link
Collaborator

Choose a reason for hiding this comment

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

OK

@qiniu-ci
Copy link

This PR has been deployed to the preview environment. You can explore it using the preview URL.

Warning

Please note that deployments in the preview environment are temporary and will be automatically cleaned up after a certain period. Make sure to explore it before it is removed. For any questions, contact the Go+ Builder team.

@nighca nighca merged commit af1dd07 into goplus:dev Jan 21, 2025
8 checks passed
@nighca nighca mentioned this pull request Jan 21, 2025
@aofei aofei deleted the spxls-completion branch January 21, 2025 10:18
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.

3 participants