Factor out common logic for Dot output format names/suffixes
Instead of having two `switch` statements on the Dot format enumeration, give each Dot enumeration value a way to identify its own preferred file suffix and command-line format name. This removes some warnings about `switch` statements without default cases. It also creates strong static enforcement that any new Dot format *must* also provide this information.
This commit is contained in:
parent
11b636f764
commit
37fe595fbd
|
@ -77,19 +77,7 @@ public class IFDSExplorer {
|
|||
System.err.println("Domain:\n" + r.getProblem().getDomain().toString());
|
||||
}
|
||||
|
||||
String irFileName = null;
|
||||
switch (DotUtil.getOutputType()) {
|
||||
case PDF:
|
||||
irFileName = "ir.pdf";
|
||||
break;
|
||||
case PS:
|
||||
case EPS:
|
||||
irFileName = "ir.ps";
|
||||
break;
|
||||
case SVG:
|
||||
irFileName = "ir.svg";
|
||||
break;
|
||||
}
|
||||
String irFileName = "ir." + DotUtil.getOutputType().suffix;
|
||||
String outputFile = scratchDirectory + File.separatorChar + irFileName;
|
||||
String dotFile = scratchDirectory + File.separatorChar + "ir.dt";
|
||||
|
||||
|
|
|
@ -20,7 +20,6 @@ import java.util.Iterator;
|
|||
|
||||
import com.ibm.wala.util.WalaException;
|
||||
import com.ibm.wala.util.collections.Iterator2Collection;
|
||||
import com.ibm.wala.util.debug.Assertions;
|
||||
import com.ibm.wala.util.graph.Graph;
|
||||
|
||||
/**
|
||||
|
@ -33,7 +32,16 @@ public class DotUtil {
|
|||
*
|
||||
*/
|
||||
public static enum DotOutputType {
|
||||
PS, SVG, PDF, EPS
|
||||
PS("ps"),
|
||||
SVG("svg"),
|
||||
PDF("pdf"),
|
||||
EPS("eps");
|
||||
|
||||
public final String suffix;
|
||||
|
||||
DotOutputType(final String suffix) {
|
||||
this.suffix = suffix;
|
||||
}
|
||||
}
|
||||
|
||||
private static DotOutputType outputType = DotOutputType.PDF;
|
||||
|
@ -51,19 +59,7 @@ public class DotUtil {
|
|||
}
|
||||
|
||||
private static String outputTypeCmdLineParam() {
|
||||
switch (outputType) {
|
||||
case PS:
|
||||
return "-Tps";
|
||||
case EPS:
|
||||
return "-Teps";
|
||||
case SVG:
|
||||
return "-Tsvg";
|
||||
case PDF:
|
||||
return "-Tpdf";
|
||||
default:
|
||||
Assertions.UNREACHABLE();
|
||||
return null;
|
||||
}
|
||||
return "-T" + outputType.suffix;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue