Skip to content

feat(slicing): emit param annotations as separate ANNOTATION slices#243

Merged
prabhu merged 5 commits into
AppThreat:mainfrom
abdul-levo:feat/emit-annotation-slices
Mar 17, 2026
Merged

feat(slicing): emit param annotations as separate ANNOTATION slices#243
prabhu merged 5 commits into
AppThreat:mainfrom
abdul-levo:feat/emit-annotation-slices

Conversation

@abdul-levo
Copy link
Copy Markdown
Contributor

Instead of adding an annotations field to ParamDef (which changes the schema), parameter annotations are now emitted as separate ObjectUsageSlice entries with label=ANNOTATION using the existing CallDef type.

Removed annotations field from ParamDef (no schema change) Changed computeUsageSlice to return List instead of Option For each MethodParameterIn annotation, emit a new ANNOTATION entry with the param name in name and annotation in resolvedMethod This preserves backward compatibility — existing tools ignore the extra entries, while new consumers can read ANNOTATION entries to discover @RequestBody, @PathVariable, @RequestParam, @RequestHeader etc.

Summary
Emits parameter annotations (e.g. @RequestBody, @PathVariable) as separate ObjectUsageSlice entries with label=ANNOTATION
Removes the previously added annotations field from ParamDef — no schema change
Uses existing CallDef type so downstream tools don't need parser updates
How it works
For a method like confirm(@RequestBody OrderRequest body, @RequestHeader String key):

PARAM entry for body (unchanged, same as before)
ANNOTATION entry: name=body, resolvedMethod=@RequestBody, label=ANNOTATION
ANNOTATION entry: name=key, resolvedMethod=@RequestHeader, label=ANNOTATION

Instead of adding an annotations field to ParamDef (which changes the schema),
parameter annotations are now emitted as separate ObjectUsageSlice entries
with label=ANNOTATION using the existing CallDef type.

Removed annotations field from ParamDef (no schema change)
Changed computeUsageSlice to return List instead of Option
For each MethodParameterIn annotation, emit a new ANNOTATION entry with the param name in name and annotation in resolvedMethod
This preserves backward compatibility — existing tools ignore the extra
entries, while new consumers can read ANNOTATION entries to discover
@RequestBody, @PathVariable, @RequestParam, @RequestHeader etc.
@prabhu
Copy link
Copy Markdown
Contributor

prabhu commented Mar 11, 2026

Changed computeUsageSlice to return List instead of Option

I think this will make the json larger since they will never get filtered out. Can you refine the PR to retain the Option?

In general, guide it with a prompt to make only the required functional change instead of other generic changes.

@abdul-levo
Copy link
Copy Markdown
Contributor Author

Changed computeUsageSlice to return List instead of Option

I think this will make the json larger since they will never get filtered out. Can you refine the PR to retain the Option?

In general, guide it with a prompt to make only the required functional change instead of other generic changes.

Sure @prabhu

…arately

instead of List. Param annotation slices are now collected in a
separate paramAnnotationSlices function, combined in computeSlices.
@abdul-levo
Copy link
Copy Markdown
Contributor Author

Changed computeUsageSlice to return List instead of Option

I think this will make the json larger since they will never get filtered out. Can you refine the PR to retain the Option?

In general, guide it with a prompt to make only the required functional change instead of other generic changes.

Prabhu Can you check it out once I refined the PR

param.method -> ObjectUsageSlice(
targetObj = annDef,
definedBy = Some(annDef),
invokedCalls = List.empty,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can you ask claude if we can track the self-invocation of the annotation here instead of returning an empty list?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

sure @prabhu

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Can you ask claude if we can track the self-invocation of the annotation here instead of returning an empty list?

can you check out once and share your feedback?

@prabhu
Copy link
Copy Markdown
Contributor

prabhu commented Mar 11, 2026

Can you run sbt clean stage scalafmt test?

@abdul-levo
Copy link
Copy Markdown
Contributor Author

Can you run sbt clean stage scalafmt test?

Done @prabhu

Copy link
Copy Markdown
Contributor

@prabhu prabhu left a comment

Choose a reason for hiding this comment

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

Thank you!

@prabhu
Copy link
Copy Markdown
Contributor

prabhu commented Mar 17, 2026

@abdul-levo did you push your changes? The test is still failing due to formatting issues.

https://github.com/AppThreat/atom/actions/runs/22974943140/job/67401986301?pr=243

@abdul-levo
Copy link
Copy Markdown
Contributor Author

@abdul-levo did you push your changes? The test is still failing due to formatting issues.

https://github.com/AppThreat/atom/actions/runs/22974943140/job/67401986301?pr=243

Yeah @prabhu i pushed it.

@prabhu prabhu merged commit 40be8dc into AppThreat:main Mar 17, 2026
23 checks passed
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