Skip to content

Commit

Permalink
[console] remove rubyDeprecated (#5162)
Browse files Browse the repository at this point in the history
  • Loading branch information
xavierpinho authored Dec 5, 2024
1 parent 3bb8548 commit b239663
Showing 1 changed file with 2 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,10 @@ class ImportCode[T <: Project](console: io.joern.console.Console[T])(implicit
def csharp: Frontend = new BinaryFrontend("csharp", Languages.CSHARP, "C# Source Frontend (Roslyn)")
def llvm: Frontend = new BinaryFrontend("llvm", Languages.LLVM, "LLVM Bitcode Frontend")
def php: SourceBasedFrontend = new SourceBasedFrontend("php", Languages.PHP, "PHP source frontend", "php")
def ruby: SourceBasedFrontend = new RubyFrontend("Ruby source frontend", false)
def rubyDeprecated: SourceBasedFrontend = new RubyFrontend("Ruby source deprecated frontend", true)
def ruby: SourceBasedFrontend = SourceBasedFrontend("ruby", Languages.RUBYSRC, "Ruby source frontend", "rb")

private def allFrontends: List[Frontend] =
List(
c,
cpp,
ghidra,
kotlin,
java,
jvm,
javascript,
jssrc,
swiftsrc,
golang,
llvm,
php,
python,
csharp,
ruby,
rubyDeprecated
)
List(c, cpp, ghidra, kotlin, java, jvm, javascript, jssrc, swiftsrc, golang, llvm, php, python, csharp, ruby)

// this is only abstract to force people adding frontends to make a decision whether the frontend consumes binaries or source
abstract class Frontend(val name: String, val language: String, val description: String = "")(implicit
Expand Down Expand Up @@ -140,30 +122,6 @@ class ImportCode[T <: Project](console: io.joern.console.Console[T])(implicit
}
}

/** Only a wrapper so as to more easily pick the deprecated variant without having to provide the
* `--useDeprecatedFrontend` flag each time.
*
* @param useDeprecatedFrontend
* If set, will invoke the frontend with the `--useDeprecatedFrontend` flag
*/
private class RubyFrontend(description: String, useDeprecatedFrontend: Boolean = false)
extends SourceBasedFrontend("ruby", Languages.RUBYSRC, description, "rb") {
private val deprecatedFlag = "--useDeprecatedFrontend"

private def addDeprecatedFlagIfNeeded(args: List[String]): List[String] = {
Option.when(useDeprecatedFrontend && !args.contains(deprecatedFlag))(deprecatedFlag).toList ++ args
}

override def cpgGeneratorForLanguage(
language: String,
config: FrontendConfig,
rootPath: Path,
args: List[String]
): Option[CpgGenerator] = {
super.cpgGeneratorForLanguage(language, config, rootPath, addDeprecatedFlagIfNeeded(args))
}
}

class SwiftSrcFrontend(name: String, language: String, description: String, extension: String)
extends SourceBasedFrontend(name, language, description, extension) {
override def apply(inputPath: String, projectName: String, args: List[String]): Cpg = {
Expand Down

0 comments on commit b239663

Please sign in to comment.