Skip to content

Commit

Permalink
🐛 Add one to line numbers from java bundle (konveyor#339)
Browse files Browse the repository at this point in the history
This should correct the off-by-one issues with java line numbers.

Signed-off-by: Fabian von Feilitzsch <[email protected]>
  • Loading branch information
fabianvf authored Sep 20, 2023
1 parent 1433229 commit dca2d15
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
22 changes: 11 additions & 11 deletions demo-output.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,15 @@
- 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<String> element = new GenericClass<String>(\"Hello world!\");"
lineNumber: 2
lineNumber: 3
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java
kind: Method
name: main
- 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<String> element = new GenericClass<String>(\"Hello world!\");\n14 element.get();\n15 }\n16 }\n"
lineNumber: 9
lineNumber: 10
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java
kind: Method
Expand All @@ -225,17 +225,17 @@
category: potential
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:2
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<String> element = new GenericClass<String>(\"Hello world!\");"
lineNumber: 2
lineNumber: 3
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java
kind: Method
name: main
- 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:9
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<String> element = new GenericClass<String>(\"Hello world!\");\n14 element.get();\n15 }\n16 }\n"
lineNumber: 9
lineNumber: 10
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java
kind: Method
Expand All @@ -247,7 +247,7 @@
- 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<String> element = new GenericClass<String>(\"Hello world!\");\n14 element.get();\n15 }\n16 }\n"
lineNumber: 13
lineNumber: 14
variables:
VariableName: element
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/App.java
Expand All @@ -269,15 +269,15 @@
- uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
message: condition entries should evaluate out of order
codeSnip: " 1 package com.example.apps;\n 2 \n 3 import javax.ejb.SessionBean;\n 4 import javax.ejb.Singleton;\n 5 \n 6 @Singleton\n 7 public class Bean implements SessionBean {\n 8 }\n"
lineNumber: 5
lineNumber: 6
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
kind: Class
name: Singleton
- uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
message: condition entries should evaluate out of order
codeSnip: " 1 package com.example.apps;\n 2 \n 3 import javax.ejb.SessionBean;\n 4 import javax.ejb.Singleton;\n 5 \n 6 @Singleton\n 7 public class Bean implements SessionBean {\n 8 }\n"
lineNumber: 6
lineNumber: 7
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
kind: Class
Expand All @@ -289,15 +289,15 @@
- uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
message: condition entries should evaluate in order
codeSnip: " 1 package com.example.apps;\n 2 \n 3 import javax.ejb.SessionBean;\n 4 import javax.ejb.Singleton;\n 5 \n 6 @Singleton\n 7 public class Bean implements SessionBean {\n 8 }\n"
lineNumber: 5
lineNumber: 6
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
kind: Class
name: Singleton
- uri: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
message: condition entries should evaluate in order
codeSnip: " 1 package com.example.apps;\n 2 \n 3 import javax.ejb.SessionBean;\n 4 import javax.ejb.Singleton;\n 5 \n 6 @Singleton\n 7 public class Bean implements SessionBean {\n 8 }\n"
lineNumber: 6
lineNumber: 7
variables:
file: file:///analyzer-lsp/examples/java/src/main/java/com/example/apps/Singleton.java
kind: Class
Expand Down
4 changes: 2 additions & 2 deletions provider/internal/java/filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (p *javaServiceClient) convertToIncidentContext(symbol protocol.WorkspaceSy
return provider.IncidentContext{}, err
}

lineNumber := int(symbol.Location.Range.Start.Line)
lineNumber := int(symbol.Location.Range.Start.Line) + 1
incident := provider.IncidentContext{
FileURI: u,
LineNumber: &lineNumber,
Expand Down Expand Up @@ -184,7 +184,7 @@ func (p *javaServiceClient) convertSymbolRefToIncidentContext(symbol protocol.Wo
Character: ref.Range.End.Character,
},
}
lineNumber := int(ref.Range.Start.Line)
lineNumber := int(ref.Range.Start.Line) + 1
incident.LineNumber = &lineNumber

return incident, nil
Expand Down

0 comments on commit dca2d15

Please sign in to comment.