feat(jdk-codemodel): stamp declaration-site source locations on local variables and formal parameters#104
Merged
Merged
Conversation
… variables and formal parameters
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.
Method and constructor parameters, local variable declarations, and enhanced-for loop variables previously carried no
SourceLocationat all, unlike fields, methods, and constructors, which have had their declaration positions stamped sinceJdkInitializerwas introduced. This change closes that gap using the sameTrees.getSourcePositions()mechanism already in place elsewhere:JdkInitializer.getFormalParametersnow accepts the enclosingMethodTree/CompilationUnitTreeand stamps eachFormalParameterDescriptorwith its declaration position by matching parameters to theirVariableTreeby index, andJdkStatementConverterstampsSourceLocation.FilePositiononLocalVariableDeclarationandEnhancedForusingJdkExpressionConverter's existingaddSourceLocationhelper (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-FieldDescriptorchange, this completes declaration-site position coverage for the symbol kinds most commonly needed for source navigation. Lambda parameters are intentionally excluded:LambdaParameteris a plainCompositerecord rather thanTraitable, and promoting it would require the same marshalling boilerplateFormalParameterDescriptorcarries, which is deferred to a separate change. Five new tests were added toLocationTraitTestscovering method parameters, constructor parameters, local variable declarations, and enhanced-for loop variables.