OsmAnd Translator: Options loading fix

This commit is contained in:
aFedasenka 2012-10-01 10:00:07 +02:00
parent b8cf1f4551
commit 9f1eb8986e

View file

@ -1,8 +1,6 @@
package net.osmand.translator.handlers; package net.osmand.translator.handlers;
import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader;
import java.io.IOException; import java.io.IOException;
import java.io.PrintStream; import java.io.PrintStream;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -52,6 +50,7 @@ public class TranslationHandler {
String source = Files.toString(new File(inFile), Charset.defaultCharset()); String source = Files.toString(new File(inFile), Charset.defaultCharset());
CompilationUnit unit = parse(inFile, source); CompilationUnit unit = parse(inFile, source);
AST ast = unit.getAST();
try { try {
unit.recordModifications(); unit.recordModifications();
NameTable.initialize(unit); NameTable.initialize(unit);
@ -87,6 +86,12 @@ public class TranslationHandler {
private static CompilationUnit parse(String filename, String source) { private static CompilationUnit parse(String filename, String source) {
System.out.println("parsing " + filename); System.out.println("parsing " + filename);
ASTParser parser = ASTParser.newParser(AST.JLS3); ASTParser parser = ASTParser.newParser(AST.JLS3);
String[] args = new String[]{filename};
try {
Options.load(args);
} catch (IOException e) {
e.printStackTrace();
}
Map<String, String> compilerOptions = Options.getCompilerOptions(); Map<String, String> compilerOptions = Options.getCompilerOptions();
parser.setCompilerOptions(compilerOptions); parser.setCompilerOptions(compilerOptions);
parser.setSource(source.toCharArray()); parser.setSource(source.toCharArray());