Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

goto definition for beans and methods references in spel expressions #1360

Merged
merged 3 commits into from
Oct 4, 2024

Conversation

vudayani
Copy link
Collaborator

@vudayani vudayani commented Oct 1, 2024

No description provided.

@martinlippert martinlippert added this to the 4.26.0.RELEASE milestone Oct 1, 2024
@martinlippert
Copy link
Member

Some newly created files are missing copyright statements at the top. Can you add them?

@vudayani vudayani force-pushed the spel-definition-provider branch 2 times, most recently from 164c6cd to 988c0d9 Compare October 3, 2024 05:41
IAnnotationBinding binding = a.resolveAnnotationBinding();
if (binding != null && binding.getAnnotationType() != null
&& Annotations.VALUE.equals(binding.getAnnotationType().getQualifiedName())) {
return parseSpelAndFetchLocation(cancelToken, project, cu, offset);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think I was looking at this PR in the past and just didn't look closely enough :-
I think I like everything except this piece. We're only interested in this literal the cursor is at and nothing else. At this point whatever parseSpelAndFetchLocation(...) is doing is wrong. No need to visit the CU and find all possible SPEL expressions and collect them. Instead of CU you should really visit just one single annotation.

Anyway, I'd try to extract SPEL Region from the found annotation a (line 101). Once you have the Region check that offset paremter is within that region. If yes, then:

			List<TokenData> beanReferenceTokens = computeTokens(snippet, offset);
							if (beanReferenceTokens != null && beanReferenceTokens.size() > 0) {
								locationLink.addAll(findLocationLinksForBeanRef(project, offset, beanReferenceTokens));
							}

							Optional<Tuple2<String, String>> result = parseAndExtractMethodClassPairFromSpel(snippet,
									offset);
							result.ifPresent(tuple -> {
								locationLink.addAll(findLocationLinksForMethodRef(tuple.getT1(), tuple.getT2(), project));
							});

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, this makes sense. Thanks for pointing this out. Removed the unnecessary parsing logic.

@BoykoAlex BoykoAlex merged commit f4c4121 into spring-projects:main Oct 4, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: vscode something that is specific for VSCode theme: spel-support type: enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants