--- /dev/null
+package eu.svjatoslav.inspector.java;
+
+import eu.svjatoslav.commons.commandline.parameterparser.Parser;
+import eu.svjatoslav.commons.commandline.parameterparser.parameter.FileParameter;
+import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameter;
+import eu.svjatoslav.commons.commandline.parameterparser.parameter.StringParameters;
+
+public class CommandlineConfiguration {
+
+ public CommandlineConfiguration (String args[]){
+ Parser parser = buildCommandlineParameterParser();
+ if (!parser.parse(args)) {
+ parser.showHelp();
+ }
+ }
+
+ public Parser buildCommandlineParameterParser() {
+ Parser parser = new Parser();
+
+ parser.add(
+ new FileParameter("JAR file"))
+ .mustExist()
+ .addAliases("-j");
+
+ parser.add(
+ new StringParameter("graph name"))
+ .setMandatory()
+ .addAliases("-n");
+
+ parser.add(
+ new StringParameters("whitelist glob"))
+ .addAliases("-w");
+
+ parser.add(
+ new StringParameters("blacklist glob"))
+ .addAliases("-b");
+
+ return parser;
+ }
+
+}
*/
public class Main {
public static void main(String[] args) {
- if (args.length == 0) {
- System.err.println("usage: javainspect [PROJECT_DIR] [PACKAGE_GLOB] [GRAPH_NAME]");
- System.exit(1);
- }
-
- String projectDir = args[0];
- String packageGlob = args[1];
- String graphName = args[2];
+ CommandlineConfiguration commandlineConfiguration = new CommandlineConfiguration(args);
+ System.out.println("Commandline config validated");
ClassGraph cg = new ClassGraph();
cg.setTargetDirectoryPath(getProperty("user.dir") + separator);
- cg.addProject(projectDir);
- cg.whitelistClassGlob(packageGlob);
- cg.setKeepDotFile(true);
- cg.generateGraph(graphName);
+// cg.addProject(projectDir);
+// cg.whitelistClassGlob(packageGlob);
+// cg.setKeepDotFile(true);
+// cg.generateGraph(graphName);
}
}
import java.util.ArrayList;
import java.util.List;
+import static eu.svjatoslav.commons.string.tokenizer.Terminator.TerminationStrategy.DROP;
+import static eu.svjatoslav.commons.string.tokenizer.Terminator.TerminationStrategy.PRESERVE;
+
public class JavaFile {
public static final String UTF_8 = "UTF-8";
final Tokenizer tokenizer = new Tokenizer(contents.toString());
// empty space
- tokenizer.addTerminator(" ", true);
- tokenizer.addTerminator("\t", true);
- tokenizer.addTerminator("\n", true);
-
- tokenizer.addTerminator(";", false);
- tokenizer.addTerminator("{", false);
- tokenizer.addTerminator("}", false);
- tokenizer.addTerminator("(", false);
- tokenizer.addTerminator(")", false);
- tokenizer.addTerminator("[", false);
- tokenizer.addTerminator("]", false);
- tokenizer.addTerminator("<", false);
- tokenizer.addTerminator(">", false);
- tokenizer.addTerminator(",", false);
- tokenizer.addTerminator("@", false);
+ tokenizer.addTerminator(" ", DROP);
+ tokenizer.addTerminator("\t", DROP);
+ tokenizer.addTerminator("\n", DROP);
+
+ tokenizer.addTerminator(";", PRESERVE);
+ tokenizer.addTerminator("{", PRESERVE);
+ tokenizer.addTerminator("}", PRESERVE);
+ tokenizer.addTerminator("(", PRESERVE);
+ tokenizer.addTerminator(")", PRESERVE);
+ tokenizer.addTerminator("[", PRESERVE);
+ tokenizer.addTerminator("]", PRESERVE);
+ tokenizer.addTerminator("<", PRESERVE);
+ tokenizer.addTerminator(">", PRESERVE);
+ tokenizer.addTerminator(",", PRESERVE);
+ tokenizer.addTerminator("@", PRESERVE);
// comments
- tokenizer.addTerminator("//", "\n", true);
- tokenizer.addTerminator("/*", "*/", true);
+ tokenizer.addTerminator("//", "\n", DROP);
+ tokenizer.addTerminator("/*", "*/", DROP);
final Modifiers modifiers = new Modifiers();
imports.add(imp);
- tokenizer.expectNextToken(";");
+ tokenizer.expectAndConsumeNextToken(";");
}
private void parseInterface(final Tokenizer tokenizer)
packageName = match.token;
- tokenizer.expectNextToken(";");
+ tokenizer.expectAndConsumeNextToken(";");
}
private void readFile() throws IOException {
inputStream.close();
}
- public void skipUntilSemicolon(final Tokenizer tokenizer) {
+ public void skipUntilSemicolon(final Tokenizer tokenizer) throws InvalidSyntaxException {
while (true) {
final TokenizerMatch token = tokenizer.getNextToken();