mirror of
https://github.com/github/codeql.git
synced 2026-05-02 20:25:13 +02:00
Make standard library locations consistent between Java and Kotlin
This commit is contained in:
committed by
Ian Lynagh
parent
547b60d68f
commit
64e1367e59
@@ -1,5 +1,6 @@
|
||||
package com.github.codeql
|
||||
|
||||
import com.intellij.openapi.vfs.StandardFileSystems
|
||||
import org.jetbrains.kotlin.ir.declarations.IrClass
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclaration
|
||||
import org.jetbrains.kotlin.ir.declarations.IrDeclarationParent
|
||||
@@ -45,9 +46,15 @@ fun getIrClassVirtualFile(irClass: IrClass): VirtualFile? {
|
||||
return null
|
||||
}
|
||||
|
||||
fun getRawIrClassBinaryPath(irClass: IrClass): String? {
|
||||
return getIrClassVirtualFile(irClass)?.getPath()
|
||||
}
|
||||
fun getRawIrClassBinaryPath(irClass: IrClass) =
|
||||
getIrClassVirtualFile(irClass)?.let {
|
||||
val path = it.path
|
||||
if(it.fileSystem.protocol == StandardFileSystems.JRT_PROTOCOL)
|
||||
// For JRT files, which we assume to be the JDK, hide the containing JAR path to match the Java extractor's behaviour.
|
||||
"/${path.split("!/", limit = 2)[1]}"
|
||||
else
|
||||
path
|
||||
}
|
||||
|
||||
fun getIrClassBinaryPath(irClass: IrClass): String {
|
||||
return getRawIrClassBinaryPath(irClass)
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
package main;
|
||||
|
||||
public class Q {}
|
||||
@@ -0,0 +1,3 @@
|
||||
package main
|
||||
|
||||
class W {}
|
||||
@@ -0,0 +1,2 @@
|
||||
| Q.java:0:0:0:0 | Q |
|
||||
| W.kt:0:0:0:0 | W |
|
||||
@@ -0,0 +1,7 @@
|
||||
import java
|
||||
|
||||
from File f
|
||||
where f.getExtension() in ["java", "kt"]
|
||||
select f
|
||||
|
||||
// This test is mainly a consistency test; just checking that both the Java and Kotlin source were extracted here
|
||||
Reference in New Issue
Block a user