Skip to content

Fix various NPEs caused by dynamically computed method calls#1704

Merged
chagong merged 5 commits intomicrosoft:developfrom
ljfa-ag:dynamic-method-npe-fix
Sep 28, 2025
Merged

Fix various NPEs caused by dynamically computed method calls#1704
chagong merged 5 commits intomicrosoft:developfrom
ljfa-ag:dynamic-method-npe-fix

Conversation

@ljfa-ag
Copy link
Contributor

@ljfa-ag ljfa-ag commented Sep 3, 2025

Groovy method calls where the method name is an interpolated string (for example "${foo}"(...)) are currently causing NPEs in various places. Autocompletion doesn't work in the entire file when such a call is used anywhere in a build.gradle file. The problem is that "MethodCallExpression.getMethodAsString()" returns null for these dynamic method calls.

I have mostly moved constant strings to the front of equals comparisons to avoid the NPEs. In some cases I have replaced "getMethodAsString()" by "getMethod().getText()", which is not null.

This fixes #1562.

@ljfa-ag
Copy link
Contributor Author

ljfa-ag commented Sep 3, 2025

@microsoft-github-policy-service agree

@chagong chagong merged commit 61c520d into microsoft:develop Sep 28, 2025
1 check passed
@ljfa-ag ljfa-ag deleted the dynamic-method-npe-fix branch October 2, 2025 13:45
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.

Gradle autocompletion (ctrl + space) fails with error

2 participants