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(spx): inputAssistant Provider will filter Token effect in different code page #911

Merged
merged 6 commits into from
Sep 18, 2024

Conversation

molinla
Copy link
Contributor

@molinla molinla commented Sep 14, 2024

Overview

this pr is about:

  • add sidebar collapse animation.
  • flat all categories, click nav tab or scoll will both sync category title position or nav active idx.
  • inputAssistant will filter inputAssistantItems for different code page.

Copy link

qiniu-prow bot commented Sep 14, 2024

Hi @molinla. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@molinla
Copy link
Contributor Author

molinla commented Sep 14, 2024

@nighca thanks to review.

if (!isInStageCode) return true
// some effect may empty but pre-defined in tokens like if, function, const, etc.
if (!usage.effect && token.id.pkgPath === 'gop') return true
return ['All'].includes(usage.effect)
Copy link
Collaborator

Choose a reason for hiding this comment

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

之前 tool 上有两个字段 callEffecttargetcallEffect 是描述它的行为特点(会产生什么样的副作用,主要用来控制展示时的图标),target 是描述它可以被调用的对象(是 sprite 代码可以调用还是 stage 代码可以调用);你这里的 effect 是对标哪个?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这里对标的是 target,在预定好的 token 里面 effect 就是 All、Sprite 和 Stage,如果从 WASM 获取就是对应的 StructName 当作这个方法属于的结构体的名称,所以这里用了 Include 来判断哪些是可以给 Stage 用的,目前我测试出来 预定义的 Token 已经全部覆盖了,还没有其他的所以就只写了 All

Copy link
Collaborator

@nighca nighca Sep 14, 2024

Choose a reason for hiding this comment

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

这里对标的是 target

有两个问题:

  • 既然对标的是 target,为什么命名为 effect..我理解不了这个名字
  • 我看下边又会 usageType2Icon(usage.effect),这个跟“对标 target”是矛盾的;我们应该不是用 sprite/stage/all 这样的信息来决定 icon 的?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

callEffect 在 usage 上有个属性是 type,它的内容是 func,bool,float 这种,目前是判断是哪些字符串然后返回对应的 Icon

Copy link
Contributor Author

Choose a reason for hiding this comment

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

懂了我去改一下

/** transform from wasm token usage type item like 'func, keyword, bool, byte, float32, etc.' into Icon type */
// todo: add more case type transform to type
export function usageType2Icon(type: string): Icon {
/** transform pre-defined token usage effect or from wasm token usage type item like 'func, keyword, bool, byte, float32, etc.' into Icon type */
Copy link
Collaborator

Choose a reason for hiding this comment

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

effect 跟 type 明显是不同的两个概念,建议拆开两个函数 usageEffect2Icon & usageType2Icon,可以减少犯错的机会

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,明白了。这里主要是因为有的时候 document 模块查询不到内容只能通过 wasm 的 type 来判断,我还是分为两个独立的函数稳妥一点

declaration: 'Loop with range',
sample: 'for i <- start:end {}',
insertText: 'for ${1:i} <- ${2:start}:${3:end} {\n\t${4:}\n}'
},
{
id: '2',
effect: '',
effect: 'code',
target: '',
Copy link
Collaborator

Choose a reason for hiding this comment

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

target 取值为 '' 是什么概念?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

非常抱歉这里确实是改漏了,我会把这个 target 的值改为 'All'

@@ -12,6 +12,7 @@ export type UsageId = string

export type TokenUsage = {
id: UsageId
target: string
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nit: 可能的话最好进一步限制一下类型,比如

Suggested change
target: string
target: 'Sprite' | 'All' | ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的,后面的 commit 我会把 target 类型约束一下

…onStructName2Target` to transform wasm definition into TokenUsage Target
@nighca nighca merged commit 2f7a646 into goplus:trailhead_code Sep 18, 2024
3 checks passed
@molinla molinla deleted the sidebar branch September 18, 2024 01:43
callme-taota pushed a commit to callme-taota/builder that referenced this pull request Sep 19, 2024
…fferent code page (goplus#911)

* feat: add animation in sidebar, refactor sidebar inputAssistant to show whole categories

* feat: filter inputAssistant item in different code page

* refactor: rename some vue ref element variable name

* refactor: refactor tokens property sample, refactor inputAssistant will not merge wasm usages.

* fix: fix some tokens sample

* refactor: refactor `usageEffect2Icon` into 2 functions, add `definitionStructName2Target` to transform wasm definition into TokenUsage Target
nighca pushed a commit that referenced this pull request Sep 20, 2024
* feat: fill the document.

* feat`WASM Compiler`: get struct field & method into completion item. (#913)

* feat: get struct field & method into completion item .

* fix: fix the bug of wrong if statements.

* refactor(spx): inputAssistant Provider will filter Token effect in different  code page (#911)

* feat: add animation in sidebar, refactor sidebar inputAssistant to show whole categories

* feat: filter inputAssistant item in different code page

* refactor: rename some vue ref element variable name

* refactor: refactor tokens property sample, refactor inputAssistant will not merge wasm usages.

* fix: fix some tokens sample

* refactor: refactor `usageEffect2Icon` into 2 functions, add `definitionStructName2Target` to transform wasm definition into TokenUsage Target

* feat(spx-gui): implement audio preview (#908)

* feat: implement audio preview

* feat: complete audio player event ,audio player wave bar has different performance in playing

* fix: rename `getScopesItems` -> `getCompletionItems`. (#916)

fix: fix wrong if statement.

* feat(spx-gui): completion menu doc (#917)

* feat: completion menu document

* refactor: refactor CompletionItem props undefined

* refactor: update completion menu doc css animation and method `getCompletionItemByIdx`

* docs: add necessary comment in completion menu item

* refactor(spx-gui): refactor Audio player props (#918)

* refactor: refactor `AudioPreview.vue` props into `File` and update related types

* fix: fix `PreprocessModal.vue` component css style variable incorrect using

* fix: fix `File` class related by using reactive ts type mismatch error

* feat: add some document.

---------

Co-authored-by: molinla <61045398+molinla@users.noreply.github.com>
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