@@ -200,13 +200,17 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx)
200200 } else if (arg .getValue () instanceof J .Identifier ) {
201201 J .Identifier value = (J .Identifier ) arg .getValue ();
202202 valueValue = value .getSimpleName ();
203+ } else if (arg .getValue () instanceof J .FieldAccess ) {
204+ valueValue = arg .getValue ().printTrimmed (getCursor ());
203205 } else if (arg .getValue () instanceof G .GString ) {
204206 G .GString value = (G .GString ) arg .getValue ();
205207 List <J > strings = value .getStrings ();
206208 if (!strings .isEmpty () && strings .get (0 ) instanceof G .GString .Value ) {
207209 G .GString .Value versionGStringValue = (G .GString .Value ) strings .get (0 );
208210 if (versionGStringValue .getTree () instanceof J .Identifier ) {
209211 valueValue = ((J .Identifier ) versionGStringValue .getTree ()).getSimpleName ();
212+ } else if (versionGStringValue .getTree () instanceof J .FieldAccess ) {
213+ valueValue = versionGStringValue .getTree ().printTrimmed (getCursor ());
210214 }
211215 }
212216 }
@@ -454,11 +458,13 @@ private void gatherVariables(J.MethodInvocation method) {
454458 artifactValue = ((J .Assignment ) depArgs .get (1 )).getAssignment ();
455459 versionExp = ((J .Assignment ) depArgs .get (2 )).getAssignment ();
456460 }
457- if (groupValue instanceof J .Literal && artifactValue instanceof J .Literal && versionExp instanceof J .Identifier ) {
461+ if (groupValue instanceof J .Literal && artifactValue instanceof J .Literal && ( versionExp instanceof J .Identifier || versionExp instanceof J . FieldAccess ) ) {
458462 J .Literal groupLiteral = (J .Literal ) groupValue ;
459463 J .Literal artifactLiteral = (J .Literal ) artifactValue ;
460464 if (groupLiteral .getValue () instanceof String && artifactLiteral .getValue () instanceof String && shouldResolveVersion ((String ) groupLiteral .getValue (), (String ) artifactLiteral .getValue ())) {
461- String versionVariableName = ((J .Identifier ) versionExp ).getSimpleName ();
465+ String versionVariableName = versionExp instanceof J .Identifier ?
466+ ((J .Identifier ) versionExp ).getSimpleName () :
467+ (versionExp ).printTrimmed (getCursor ());
462468 acc .variableNames .computeIfAbsent (versionVariableName , it -> new HashMap <>())
463469 .computeIfAbsent (new GroupArtifact ((String ) groupLiteral .getValue (), (String ) artifactLiteral .getValue ()), it -> new HashSet <>())
464470 .add (method .getSimpleName ());
@@ -624,6 +630,10 @@ public J.Assignment visitAssignment(J.Assignment assignment, ExecutionContext ex
624630 return a ;
625631 }
626632 Map <GroupArtifact , Set <String >> groupArtifactSetMap = acc .versionPropNameToGA .get ("gradle." + a .getVariable ());
633+ // Guard to ensure that an unsupported notation doesn't throw an exception
634+ if (groupArtifactSetMap == null ) {
635+ return a ;
636+ }
627637 GroupArtifact ga = groupArtifactSetMap .entrySet ().stream ().findFirst ().map (Map .Entry ::getKey ).orElse (null );
628638 if (ga == null ) {
629639 return a ;
0 commit comments