mirror of
https://github.com/github/codeql.git
synced 2025-12-18 09:43:15 +01:00
Kotlin: Comments and tweaks in Label
This commit is contained in:
@@ -3,20 +3,38 @@ package com.github.codeql
|
||||
import java.io.PrintWriter
|
||||
import java.io.StringWriter
|
||||
|
||||
/**
|
||||
* This represents a label (`#...`) in a TRAP file.
|
||||
*/
|
||||
interface Label<T>
|
||||
|
||||
class IntLabel<T>(val name: Int): Label<T> {
|
||||
override fun toString(): String = "#$name"
|
||||
/**
|
||||
* The label `#i`, e.g. `#123`. Most labels we generate are of this
|
||||
* form.
|
||||
*/
|
||||
class IntLabel<T>(val i: Int): Label<T> {
|
||||
override fun toString(): String = "#$i"
|
||||
}
|
||||
|
||||
/**
|
||||
* The label `#name`, e.g. `#compilation`. This is used when labels are
|
||||
* shared between different components (e.g. when both the interceptor
|
||||
* and the extractor need to refer to the same label).
|
||||
*/
|
||||
class StringLabel<T>(val name: String): Label<T> {
|
||||
override fun toString(): String = "#$name"
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not really a label, but just a `*`. Used in the rare cases
|
||||
* when we only need to refer to something once, to save adding
|
||||
* unnecessary labels.
|
||||
*/
|
||||
class StarLabel<T>: Label<T> {
|
||||
override fun toString(): String = "*"
|
||||
}
|
||||
|
||||
// TODO: Remove this and all of its uses
|
||||
fun <T> fakeLabel(): Label<T> {
|
||||
if (false) {
|
||||
println("Fake label")
|
||||
|
||||
Reference in New Issue
Block a user