forked from dotnet/java-interop
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.java
More file actions
74 lines (64 loc) · 2.37 KB
/
App.java
File metadata and controls
74 lines (64 loc) · 2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* This Java source file was generated by the Gradle 'init' task.
*/
package com.microsoft.android;
import java.io.IOException;
import com.github.javaparser.*;
import com.github.javaparser.ParserConfiguration;
import com.microsoft.android.ast.*;
import com.microsoft.android.util.Parameter;
public class App {
public static final String APP_NAME = "java-source-utils";
public static void main (final String[] args) throws Throwable {
JavaSourceUtilsOptions options;
try {
options = JavaSourceUtilsOptions.parse(args);
if (options == null) {
System.out.println(APP_NAME + " " + JavaSourceUtilsOptions.HELP_STRING);
return;
}
} catch (Throwable t) {
System.err.println(APP_NAME + ": error: " + t.getMessage());
if (JavaSourceUtilsOptions.verboseOutput) {
t.printStackTrace(System.err);
}
System.err.println("Usage: " + APP_NAME + " " + JavaSourceUtilsOptions.HELP_STRING);
System.exit(1);
return;
}
try {
final JavaParser parser = createParser(options);
final JniPackagesInfoFactory packagesFactory = new JniPackagesInfoFactory(parser);
final JniPackagesInfo packages = packagesFactory.parse(options.inputFiles);
if ((options.outputParamsTxt = Parameter.normalize(options.outputParamsTxt, "")).length() > 0) {
generateParamsTxt(options.outputParamsTxt, packages);
}
generateXml(options.outputJavadocXml, packages);
options.close();
}
catch (Throwable t) {
options.close();
System.err.println(APP_NAME + ": internal error: " + t.getMessage());
if (JavaSourceUtilsOptions.verboseOutput) {
t.printStackTrace(System.err);
}
System.exit(2);
return;
}
}
static JavaParser createParser(JavaSourceUtilsOptions options) throws IOException {
final ParserConfiguration config = options.createConfiguration();
final JavaParser parser = new JavaParser(config);
return parser;
}
static void generateParamsTxt(String filename, JniPackagesInfo packages) throws Throwable {
try (final ParameterNameGenerator paramsTxtGen = new ParameterNameGenerator(filename)) {
paramsTxtGen.writePackages(packages);
}
}
static void generateXml(String filename, JniPackagesInfo packages) throws Throwable {
try (final JavadocXmlGenerator javadocXmlGen = new JavadocXmlGenerator(filename)) {
javadocXmlGen.writePackages(packages);
}
}
}