From f549c97f9e6d9f978fc105d5186548d3a5e1caf1 Mon Sep 17 00:00:00 2001 From: Shawn Hurley Date: Mon, 16 Oct 2023 09:47:28 -0400 Subject: [PATCH] :bug: Adding test to make sure that we don't find match in doc comment (#374) fixes #361 requires https://github.com/konveyor/java-analyzer-bundle/pull/75 Signed-off-by: Shawn Hurley --- demo-output.yaml | 26 +++++++++---------- .../src/main/java/com/example/apps/App.java | 4 +++ provider/internal/java/service_client.go | 3 ++- 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/demo-output.yaml b/demo-output.yaml index ad732aaf..7d557225 100644 --- a/demo-output.yaml +++ b/demo-output.yaml @@ -203,16 +203,16 @@ incidents: - uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java message: apiextensions/v1beta1/customresourcedefinitions is deprecated, apiextensions/v1/customresourcedefinitions should be used instead - codeSnip: " 1 package com.example.apps;\n 2 \n 3 import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;\n 4 \n 5 public class App \n 6 {\n 7 \n 8 public static void main( String[] args )\n 9 {\n10 CustomResourceDefinition crd = new CustomResourceDefinition();\n11 System.out.println( crd );\n12 \n13 GenericClass element = new GenericClass(\"Hello world!\");" + codeSnip: " 1 package com.example.apps;\n 2 \n 3 import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;\n 4 \n 5 public class App \n 6 {\n 7 \n 8 /**\n 9 * {@link CustomResourceDefinition}\n10 * @param args\n11 */\n12 public static void main( String[] args )\n13 {" lineNumber: 3 variables: file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java - kind: Method - name: main + kind: Module + name: io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition - uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java message: apiextensions/v1beta1/customresourcedefinitions is deprecated, apiextensions/v1/customresourcedefinitions should be used instead - codeSnip: " 1 package com.example.apps;\n 2 \n 3 import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;\n 4 \n 5 public class App \n 6 {\n 7 \n 8 public static void main( String[] args )\n 9 {\n10 CustomResourceDefinition crd = new CustomResourceDefinition();\n11 System.out.println( crd );\n12 \n13 GenericClass element = new GenericClass(\"Hello world!\");\n14 element.get();\n15 }\n16 }\n" - lineNumber: 10 + codeSnip: " 4 \n 5 public class App \n 6 {\n 7 \n 8 /**\n 9 * {@link CustomResourceDefinition}\n10 * @param args\n11 */\n12 public static void main( String[] args )\n13 {\n14 CustomResourceDefinition crd = new CustomResourceDefinition();\n15 System.out.println( crd );\n16 \n17 GenericClass element = new GenericClass(\"Hello world!\");\n18 element.get();\n19 }\n20 }\n" + lineNumber: 14 variables: file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java kind: Method @@ -228,16 +228,16 @@ incidents: - uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java message: java found apiextensions/v1/customresourcedefinitions found file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java:3 - codeSnip: " 1 package com.example.apps;\n 2 \n 3 import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;\n 4 \n 5 public class App \n 6 {\n 7 \n 8 public static void main( String[] args )\n 9 {\n10 CustomResourceDefinition crd = new CustomResourceDefinition();\n11 System.out.println( crd );\n12 \n13 GenericClass element = new GenericClass(\"Hello world!\");" + codeSnip: " 1 package com.example.apps;\n 2 \n 3 import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;\n 4 \n 5 public class App \n 6 {\n 7 \n 8 /**\n 9 * {@link CustomResourceDefinition}\n10 * @param args\n11 */\n12 public static void main( String[] args )\n13 {" lineNumber: 3 variables: file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java - kind: Method - name: main + kind: Module + name: io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition - uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java - message: java found apiextensions/v1/customresourcedefinitions found file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java:10 - codeSnip: " 1 package com.example.apps;\n 2 \n 3 import io.fabric8.kubernetes.api.model.apiextensions.v1beta1.CustomResourceDefinition;\n 4 \n 5 public class App \n 6 {\n 7 \n 8 public static void main( String[] args )\n 9 {\n10 CustomResourceDefinition crd = new CustomResourceDefinition();\n11 System.out.println( crd );\n12 \n13 GenericClass element = new GenericClass(\"Hello world!\");\n14 element.get();\n15 }\n16 }\n" - lineNumber: 10 + message: java found apiextensions/v1/customresourcedefinitions found file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java:14 + codeSnip: " 4 \n 5 public class App \n 6 {\n 7 \n 8 /**\n 9 * {@link CustomResourceDefinition}\n10 * @param args\n11 */\n12 public static void main( String[] args )\n13 {\n14 CustomResourceDefinition crd = new CustomResourceDefinition();\n15 System.out.println( crd );\n16 \n17 GenericClass element = new GenericClass(\"Hello world!\");\n18 element.get();\n19 }\n20 }\n" + lineNumber: 14 variables: file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java kind: Method @@ -248,8 +248,8 @@ incidents: - uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java message: found generic call - codeSnip: " 4 \n 5 public class App \n 6 {\n 7 \n 8 public static void main( String[] args )\n 9 {\n10 CustomResourceDefinition crd = new CustomResourceDefinition();\n11 System.out.println( crd );\n12 \n13 GenericClass element = new GenericClass(\"Hello world!\");\n14 element.get();\n15 }\n16 }\n" - lineNumber: 14 + codeSnip: " 8 /**\n 9 * {@link CustomResourceDefinition}\n10 * @param args\n11 */\n12 public static void main( String[] args )\n13 {\n14 CustomResourceDefinition crd = new CustomResourceDefinition();\n15 System.out.println( crd );\n16 \n17 GenericClass element = new GenericClass(\"Hello world!\");\n18 element.get();\n19 }\n20 }\n" + lineNumber: 18 variables: VariableName: element file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java diff --git a/examples/java/src/main/java/com/example/apps/App.java b/examples/java/src/main/java/com/example/apps/App.java index 559b7b24..1bf6ecd6 100644 --- a/examples/java/src/main/java/com/example/apps/App.java +++ b/examples/java/src/main/java/com/example/apps/App.java @@ -5,6 +5,10 @@ public class App { + /** + * {@link CustomResourceDefinition} + * @param args + */ public static void main( String[] args ) { CustomResourceDefinition crd = new CustomResourceDefinition(); diff --git a/provider/internal/java/service_client.go b/provider/internal/java/service_client.go index 4e1f03ca..4a93905e 100644 --- a/provider/internal/java/service_client.go +++ b/provider/internal/java/service_client.go @@ -50,6 +50,7 @@ func (p *javaServiceClient) Evaluate(ctx context.Context, cap string, conditionI } symbols := p.GetAllSymbols(ctx, cond.Referenced.Pattern, cond.Referenced.Location) + p.log.Info("Symbols retrieved", "symbols", symbols) incidents := []provider.IncidentContext{} switch locationToCode[strings.ToLower(cond.Referenced.Location)] { @@ -71,7 +72,7 @@ func (p *javaServiceClient) Evaluate(ctx context.Context, cap string, conditionI case 9: incidents, err = p.filterVariableDeclaration(symbols) case 10: - incidents, err = p.filterTypeReferences(ctx, symbols) + incidents, err = p.filterDefault(symbols) case 11: incidents, err = p.filterDefault(symbols) default: