Skip to content

feat(jdk-codemodel): stamp declaration-site source locations on local variables and formal parameters#104

Merged
deer merged 1 commit into
mainfrom
param_location
Jul 5, 2026
Merged

feat(jdk-codemodel): stamp declaration-site source locations on local variables and formal parameters#104
deer merged 1 commit into
mainfrom
param_location

Conversation

@deer

@deer deer commented Jul 5, 2026

Copy link
Copy Markdown
Collaborator

Method and constructor parameters, local variable declarations, and enhanced-for loop variables previously carried no SourceLocation at all, unlike fields, methods, and constructors, which have had their declaration positions stamped since JdkInitializer was introduced. This change closes that gap using the same Trees.getSourcePositions() mechanism already in place elsewhere: JdkInitializer.getFormalParameters now accepts the enclosing MethodTree/CompilationUnitTree and stamps each FormalParameterDescriptor with its declaration position by matching parameters to their VariableTree by index, and JdkStatementConverter stamps SourceLocation.FilePosition on LocalVariableDeclaration and EnhancedFor using JdkExpressionConverter's existing addSourceLocation helper (now package-private so both converters can share it).

Together with the earlier usage-site stamping on identifiers/method invocations and the Symbol.Field-to-FieldDescriptor change, this completes declaration-site position coverage for the symbol kinds most commonly needed for source navigation. Lambda parameters are intentionally excluded: LambdaParameter is a plain Composite record rather than Traitable, and promoting it would require the same marshalling boilerplate FormalParameterDescriptor carries, which is deferred to a separate change. Five new tests were added to LocationTraitTests covering method parameters, constructor parameters, local variable declarations, and enhanced-for loop variables.

@deer deer merged commit 1018f2f into main Jul 5, 2026
1 check passed
@deer deer deleted the param_location branch July 5, 2026 05:09
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.

1 participant