Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving Command-Parsing in OPAL with Scallop-Library #226

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from

Conversation

thanhtung24
Copy link

No description provided.

thanhtung24 and others added 3 commits November 3, 2024 13:14
# Conflicts:
#	DEVELOPING_OPAL/tools/src/main/scala/org/opalj/support/info/Purity.scala
@errt
Copy link
Collaborator

errt commented Nov 7, 2024

Note that there is a compile error in the continuous integration that needs to be fixed

val begin = Calendar.getInstance()
Console.println(begin.getTime)

time {
if (purityConf.multiProjects.get) {
for (subp <- purityConf.classPathFiles.get.head.listFiles().filter(_.isDirectory)) {
for (subp <- purityConf.classPathFiles.get.flatMap(_.listFiles).filter(_.isDirectory)) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of a flatMap, make this two iterations (see https://docs.scala-lang.org/tour/for-comprehensions.html for an example)

object AnalysisCommandParser {
def parse(runnerName: Option[String], analysisLevel: Option[String]): Option[FPCFLazyAnalysisScheduler] =
runnerName.get match {
case "Purity" =>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right approach. One would have to change this class for every analysis that should be parsed as an analysis command. Instead, we would need a way to defer this parsing to an existing command, e.g. the FieldAssignabilityCommand, EscapeCommand, or, for the case that is now here, a PurityCommand.


class PurityConf(args: Array[String]) extends ScallopConf(args) with OpalConf {

private object analysis extends Subcommand(AnalysisCommand.name) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a lot of boiler plate. Can we get make something general out of this that we then just invoke from here?

subcommand.foreach(_.printHelp())
sys.exit(0)
case ScallopException(message) =>
println(s"Error: $message")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should still use the OPALLogger facilities to print errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants