Easier way for rules to check identifier usages
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 领域
- devtools
调研方向
首先跟踪重构规则的模式匹配和标识符比较代码;该 issue 未指定具体的文件或测试。定义一个 (~usage id) 模式匹配 free-identifiers 的使用、syntax-free-identifiers 的使用以及提议的阶段级默认值时,什么才算“完成”,同时检查 #379 中的相关要求。
由索引模型根据 Issue 内容生成。
描述
Consider the hash-ref-set!-to-hash-ref! rule:
(define-refactoring-rule hash-ref-set!-to-hash-ref!
#:description "This expression can be replaced with a simpler, equivalent `hash-ref!` expression."
#:literals (hash-ref hash-set! define)
(hash-ref
h1:id
k1:pure-expression
(_:lambda-by-any-name
()
(define v1:id initializer:value-initializer)
(hash-set! h2:id k2:pure-expression v2:id)
v3:id))
#:when (free-identifier=? #'h1 #'h2)
#:when (syntax-free-identifier=? #'k1 #'k2)
#:when (free-identifier=? #'v1 #'v2)
#:when (free-identifier=? #'v1 #'v3)
(hash-ref! h1 k1 initializer.failure-result-form))
It needs to do quite a bit of work to check that some identifiers are usages of others. Those free-identifier=? checks ought to be easier to write. It might be useful to have a (~usage id) syntax pattern that matches any identifier that's free-identifier=? to #'id. That would let me write the above rule like this:
(define-refactoring-rule hash-ref-set!-to-hash-ref!
#:description "This expression can be replaced with a simpler, equivalent `hash-ref!` expression."
#:literals (hash-ref hash-set! define)
(hash-ref
h:id
k1:pure-expression
(_:lambda-by-any-name
()
(define v:id initializer:value-initializer)
(hash-set! (~usage h) k2:pure-expression (~usage v))
(~usage v)))
#:when (syntax-free-identifier=? #'k1 #'k2)
(hash-ref! h k1 initializer.failure-result-form))
Might be worthwhile to make it match any syntax object that's syntax-free-identifier=? too. This could also help with #379, as ~usage could default to (resyntax-local-phase-level) (or whatever equivalent I come up with) instead of (syntax-local-phase-level) like free-identifier=? does.
- 主要语言
- Racket
- 星标
- 70
- 派生
- 11
- PR 合并指标
- 30 天内没有已合并 PR
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
jackfirth/resyntax 的其他 Issue
-
documentation
难度 2/5 1-3 小时 新手友好度 68/100
-
documentation
难度 4/5 3-5 天 新手友好度 45/100
-
testing
难度 4/5 3-5 天 新手友好度 45/100
-
testing
难度 3/5 1-2 天 新手友好度 75/100
-
testing
难度 4/5 3-5 天 新手友好度 68/100
查看 jackfirth/resyntax 的全部 Issue
相似的 Issue
-
area: harness bug status: needs-triage
难度 2/5 1-3 小时 新手友好度 75/100
Human-Agent-Society/reef#625 ·
-
难度 2/5 1-3 小时 新手友好度 75/100
vercel-labs/just-bash#464 ·
-
难度 2/5 1-3 小时 新手友好度 70/100
-
难度 2/5 1-3 小时 新手友好度 75/100
-
难度 2/5 1-3 小时 新手友好度 75/100