Merge remote-tracking branch 'origin/master'

This commit is contained in:
Weblate 2012-09-18 12:00:14 +02:00
commit a61f05caf7
7 changed files with 63 additions and 50 deletions

View file

@ -40,8 +40,8 @@ go_ahead == ['pokračujte rovno'].
go_ahead(Dist) == ['pokračujte ', D]:- distance(Dist) == D.
and_arrive_destination == ['a dorazíte do cieľa'].
and_arrive_intermediate == ['and arrive at your via point '].
reached_intermediate == ['you have reached your via point'].
and_arrive_intermediate == ['a dorazíte cez Váš prechodný bod '].
reached_intermediate == ['dorazili ste k Vášmu prechodnému bodu'].
then == ['potom '].
reached_destination == ['dorazili ste do cieľa'].

View file

@ -1,5 +1,10 @@
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<resources>
<string name="intermediate_point_too_far">Prechodný bod %1$s je príliš daľeko od najbližšej cesty.</string>
<string name="arrived_at_intermediate_point">Dorazili ste k Vášmu prechodnému bodu</string>
<string name="context_menu_item_intermediate_point">Pridať prechodný bod</string>
<string name="map_widget_intermediate_distance">Prechodný bod</string>
<string name="ending_point_too_far">Štartovací bod je príliš ďaleko od najbližšej cesty.</string>
<string name="poi_filter_parking">Parkovanie</string>
<string name="poi_filter_emergency">Pomoc v núdzi</string>
<string name="poi_filter_public_transport">Verejná doprava</string>

View file

@ -1,5 +0,0 @@
package net.osmand.translator;
public class TranslatorMain {
}

View file

@ -1,5 +1,11 @@
package net.osmand.translator.handlers;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.PrintStream;
import net.osmand.translator.utils.FieldsHandler;
import net.osmand.translator.utils.MethodHandler;
@ -10,6 +16,7 @@ import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.ICompilationUnit;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IMethod;
@ -22,45 +29,40 @@ import org.eclipse.jdt.core.dom.AST;
import org.eclipse.jdt.core.dom.ASTParser;
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jface.text.Document;
//import org.eclipse.jface.text.Document;
public class TranslationHandler {
public static void execute() {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IPath path = root.getProject("DataExtactionOSM").getFile("src/net/osmand/osm/MapUtils.java").getFullPath();
public static void execute(String inFile, PrintStream out) throws IOException {
// parse "MapUtils.java"
// IPath path = Path.fromOSString("/DataExtractionOSM/src/net/osmand/osm/MapUtils.java");
IFile iFile = root.getFileForLocation(path);
ICompilationUnit unit = (ICompilationUnit) JavaCore.create(iFile);
CompilationUnit parse = parse(unit);
FieldsHandler.printFieldsInfo(parse);
System.out.println();
MethodHandler.printMethodsInfo(parse);
}
private static CompilationUnit parse(ICompilationUnit unit) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setKind(ASTParser.K_COMPILATION_UNIT);
parser.setSource(unit);
parser.setResolveBindings(true);
return (CompilationUnit) parser.createAST(null); // parse
}
// ///////////////////////////////////////////////////////////////////////////
private void getProjects(IWorkspaceRoot root) {
IProject[] projects = root.getProjects();
for (IProject project : projects) {
try {
printProjectInfo(project);
} catch (CoreException e) {
e.printStackTrace();
}
BufferedReader fr = new BufferedReader(new FileReader(new File(inFile)));
String readLine;
String buf = "";
while ((readLine = fr.readLine()) != null) {
buf += readLine;
}
fr.close();
CompilationUnit parse = parse(buf);
FieldsHandler.printFieldsInfo(parse, out);
out.println();
MethodHandler.printMethodsInfo(parse, out);
}
private static CompilationUnit parse(String source) {
ASTParser parser = ASTParser.newParser(AST.JLS3);
parser.setResolveBindings(true);
// parser.setCompilerOptions(Options.getCompilerOptions());
parser.setSource(source.toCharArray());
parser.setResolveBindings(true);
// parser.setUnitName(name + ".java");
// parser.setEnvironment(new String[] { getComGoogleDevtoolsJ2objcPath() },
// new String[] { tempDir.getAbsolutePath() }, null, true);
CompilationUnit unit = (CompilationUnit) parser.createAST(null);
// assertNoCompilationErrors(unit);
return unit;
}
private void printProjectInfo(IProject project) throws CoreException, JavaModelException {
System.out.println("Working in project " + project.getName());
// Check if we have a Java project

View file

@ -1,5 +1,7 @@
package net.osmand.translator.utils;
import java.io.PrintStream;
import net.osmand.translator.visitor.FieldVisitor;
import org.eclipse.jdt.core.dom.CompilationUnit;
@ -10,7 +12,7 @@ import org.eclipse.jdt.core.dom.VariableDeclarationFragment;
public class FieldsHandler extends AbstractHandler{
public static void printFieldsInfo(CompilationUnit parse) {
public static void printFieldsInfo(CompilationUnit parse, PrintStream out) {
FieldVisitor fVisitor = new FieldVisitor();
parse.accept(fVisitor);
for (FieldDeclaration field : fVisitor.getFields()) {
@ -23,6 +25,9 @@ public class FieldsHandler extends AbstractHandler{
// type
applyType(field.getType(), buffer);
// name
if(binding == null){
continue;
}
buffer.append(binding.getJavaElement().getElementName());
// array brackets
if (binding.getType().isArray()) {
@ -34,8 +39,8 @@ public class FieldsHandler extends AbstractHandler{
}
// end of string
buffer.append(";");
System.out.println(buffer);
// System.out.println();
out.println(buffer);
// out.println();
}
}

View file

@ -1,5 +1,7 @@
package net.osmand.translator.utils;
import java.io.PrintStream;
import net.osmand.translator.visitor.MethodVisitor;
import org.eclipse.jdt.core.dom.Block;
@ -9,7 +11,7 @@ import org.eclipse.jdt.core.dom.Type;
public class MethodHandler extends AbstractHandler{
public static void printMethodsInfo(CompilationUnit parse) {
public static void printMethodsInfo(CompilationUnit parse, PrintStream out) {
MethodVisitor mVisitor = new MethodVisitor();
parse.accept(mVisitor);
for (MethodDeclaration method : mVisitor.getMethods()) {
@ -29,8 +31,8 @@ public class MethodHandler extends AbstractHandler{
buffer.append("{");
fillBody(method, buffer);
buffer.append("}");
System.out.println(buffer);
System.out.println();
out.println(buffer);
out.println();
}
}
@ -39,9 +41,9 @@ public class MethodHandler extends AbstractHandler{
}
private static void fillBody(MethodDeclaration method, StringBuffer buffer) {
Block body = method.getBody();
System.out.println(body);
Block body = method.getBody();
buffer.append(body);
}
private void parseSimpleForStatement() {

View file

@ -1,13 +1,17 @@
package net.osmand.translator.test;
import java.io.File;
import java.io.IOException;
import net.osmand.translator.handlers.TranslationHandler;
import org.junit.Test;
public class TranslatorTest {
@Test
public void simpleTest(){
public void simpleTest() throws IOException{
TranslationHandler.execute(new File("test/resources/MapUtils.java").getAbsolutePath(), System.out);
System.out.println("SUCCESS !!!!! ");
}