feat: add Extra field to store additional AST node metadata#152
Merged
Duslia merged 6 commits intocloudwego:mainfrom Feb 25, 2026
Merged
feat: add Extra field to store additional AST node metadata#152Duslia merged 6 commits intocloudwego:mainfrom
Duslia merged 6 commits intocloudwego:mainfrom
Conversation
Duslia
reviewed
Jan 26, 2026
lang/golang/parser/file.go
Outdated
| } | ||
| if len(collects.anonymousFunctions) > 0 { | ||
| v.Extra = map[string]any{} | ||
| v.Extra["AnonymousFunctions"] = collects.anonymousFunctions |
Member
There was a problem hiding this comment.
在初始化的时候把 Extra初始化? 不然以后其他人使用 Extra 的时候都得记得判空了
Duslia
reviewed
Jan 26, 2026
lang/golang/parser/file.go
Outdated
| if len(collects.directCalls) > 0 { | ||
| for i, dep := range v.Dependencies { | ||
| if collects.directCalls[dep.FileLine] { | ||
| v.Dependencies[i].SetExtra("FunctionIsCall", true) |
8344691 to
5f1455d
Compare
Collect direct calls and anonymous functions in Go parser and store them in the Extra field of Function, Dependency, Type, and Var.
5f1455d to
b43dd60
Compare
welkeyever
reviewed
Feb 24, 2026
docs/uniast-en.md
Outdated
| "EndOffset": 3564 | ||
| "EndOffset": 3564, | ||
| "Extra": { | ||
| "FunctionIsCall": true |
Member
There was a problem hiding this comment.
FunctionIsCall -> FunctionIsCalled ?
simuleite
pushed a commit
to simuleite/abcoder
that referenced
this pull request
Feb 28, 2026
…o#152) * feat: add Extra field to store additional AST node metadata Collect direct calls and anonymous functions in Go parser and store them in the Extra field of Function, Dependency, Type, and Var. * feat: add custom extra info * docs: update uniast docs and version * use const * doc: update uniast version * doc: change FunctionIsCall to IsInvoked
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Collect direct calls and anonymous functions in Go parser and store them in the Extra field of Function, Dependency, Type, and Var.
What type of PR is this?
feat
Check the PR title.
(Optional) Translate the PR title into Chinese.
feat:增加 Extra Field 去存储额外的 AST 元信息
(Optional) More detailed description for this PR(en: English/zh: Chinese).
en:
Extrafield to theDependencyto record whether a func or method is actually invoked viaCallExpr. This information is only added toFunction-typeFunctionCallsandMethodCalls, and toVars-typeDependencies.Extrafield toFunction, and add a fieldAnonymousFunctionsinside it to record the anonymous functions defined in this Function.Extrafield toVar, and include aAnonymousFunctionsfield within it to record the anonymousFunctiondefined in the initializationExprof thisVar.ExtratoType(it's added for symmetry).Compatibility Analysis
Dependency
Extraonly appears in:FunctionCallorMethodCallsof aFunctionDependencyof aVarFunction or Var
- Source Code
Other Language Related
Extrafields here will have no data (the field does not exist)structduring JSON unmarshalling, theExtrafield will be directly ignoredmapduring JSON unmarshalling, theExtrafield will exist in themap, but it will not be affected unless this field is specifically specifiedzh(optional):
(Optional) Which issue(s) this PR fixes:
(optional) The PR that updates user documentation: