Fix translator configuration

This commit is contained in:
Victor Shcherb 2012-09-18 00:52:59 +02:00
parent 02f2b5211e
commit d83fa5c3c4
11 changed files with 240 additions and 229 deletions

View file

@ -1,7 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="target/classes"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="var" path="M2_REPO/com/google/guava/guava/13.0/guava-13.0.jar"/>
<classpathentry kind="var" path="M2_REPO/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar"/>
<classpathentry kind="var" path="M2_REPO/com/google/code/findbugs/jsr305/2.0.1/jsr305-2.0.1.jar"/>
<classpathentry kind="var" path="M2_REPO/junit/junit/4.10/junit-4.10.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/core/org.eclipse.core.contenttype/3.4.100.v20100505-1235/org.eclipse.core.contenttype-3.4.100.v20100505-1235.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/core/org.eclipse.core.jobs/3.5.0.v20100515/org.eclipse.core.jobs-3.5.0.v20100515.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/core/org.eclipse.core.resources/3.6.0.v20100526-0737/org.eclipse.core.resources-3.6.0.v20100526-0737.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/core/org.eclipse.core.runtime/3.6.0.v20100505/org.eclipse.core.runtime-3.6.0.v20100505.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/equinox/org.eclipse.equinox.common/3.6.0.v20100503/org.eclipse.equinox.common-3.6.0.v20100503.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/equinox/org.eclipse.equinox.preferences/3.3.0.v20100503/org.eclipse.equinox.preferences-3.3.0.v20100503.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/tycho/org.eclipse.jdt.core/3.8.1.v20120531-0637/org.eclipse.jdt.core-3.8.1.v20120531-0637.jar"/>
<classpathentry kind="var" path="M2_REPO/org/eclipse/osgi/org.eclipse.osgi/3.6.0.v20100517/org.eclipse.osgi-3.6.0.v20100517.jar"/>
<classpathentry kind="var" path="M2_REPO/org/jibx/config/3rdparty/org/eclipse/org.eclipse.text/3.5.100.v20110505-0800/org.eclipse.text-3.5.100.v20110505-0800.jar"/>
</classpath>

View file

@ -1 +1,2 @@
bin
target

View file

@ -1,28 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>net.osmand.translator</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.ManifestBuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<name>translator</name>
<comment/>
<projects/>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
</buildCommand>
<buildCommand>
<name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
<triggers>full,incremental,</triggers>
<arguments>
<dictionary>
<key>LaunchConfigHandle</key>
<value>&lt;project&gt;/.externalToolBuilders/org.eclipse.pde.ManifestBuilder.launch</value>
</dictionary>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.pde.SchemaBuilder</name>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>

View file

@ -1,15 +0,0 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Translator
Bundle-SymbolicName: net.osmand.translator;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-Activator: net.osmand.translator.Activator
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.jdt;bundle-version="3.7.2",
org.eclipse.jdt.core;bundle-version="3.7.3",
org.eclipse.jdt.ui;bundle-version="3.7.2",
org.eclipse.jface.text;bundle-version="3.7.2",
org.eclipse.core.resources;bundle-version="3.7.101"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7

View file

@ -1,6 +0,0 @@
source.. = src/
output.. = bin/
bin.includes = plugin.xml,\
META-INF/,\
.,\
icons/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 983 B

View file

@ -1,62 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
point="org.eclipse.ui.commands">
<category
name="Sample Category"
id="net.osmand.translator.commands.category">
</category>
<command
name="Sample Command"
categoryId="net.osmand.translator.commands.category"
id="net.osmand.translator.commands.sampleCommand">
</command>
</extension>
<extension
point="org.eclipse.ui.handlers">
<handler
commandId="net.osmand.translator.commands.sampleCommand"
class="net.osmand.translator.handlers.TranslationHandler">
</handler>
</extension>
<extension
point="org.eclipse.ui.bindings">
<key
commandId="net.osmand.translator.commands.sampleCommand"
contextId="org.eclipse.ui.contexts.window"
sequence="M1+6"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration">
</key>
</extension>
<extension
point="org.eclipse.ui.menus">
<menuContribution
locationURI="menu:org.eclipse.ui.main.menu?after=additions">
<menu
label="Translate To C++"
mnemonic="M"
id="net.osmand.translator.menus.sampleMenu">
<command
commandId="net.osmand.translator.commands.sampleCommand"
mnemonic="S"
id="net.osmand.translator.menus.sampleCommand">
</command>
</menu>
</menuContribution>
<menuContribution
locationURI="toolbar:org.eclipse.ui.main.toolbar?after=additions">
<toolbar
id="net.osmand.translator.toolbars.sampleToolbar">
<command
commandId="net.osmand.translator.commands.sampleCommand"
icon="icons/sample.gif"
tooltip="Say hello world"
id="net.osmand.translator.toolbars.sampleCommand">
</command>
</toolbar>
</menuContribution>
</extension>
</plugin>

View file

@ -0,0 +1,147 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>net.osmand.translator</groupId>
<artifactId>translator</artifactId>
<packaging>jar</packaging>
<version>1</version>
<name>translator</name>
<build>
<directory>target</directory>
<outputDirectory>target/classes</outputDirectory>
<finalName>${artifactId}-${version}</finalName>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src</sourceDirectory>
<testSourceDirectory>test/src</testSourceDirectory>
<resources>
<resource>
<directory>src/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>test/resources</directory>
</testResource>
</testResources>
<pluginManagement>
<plugins>
<!-- Copy dependent jars -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.5</version>
<!-- <executions> <execution> <id>copy-dependencies</id> <phase>generate-resources</phase> <goals> <goal>copy-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.directory}/lib</outputDirectory> <excludeTransitive>true</excludeTransitive>
</configuration> </execution> </executions> -->
</plugin>
<plugin>
<artifactId>maven-plugin-plugin</artifactId>
<version>2.4.3</version>
</plugin>
<plugin>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.5</version>
<goals>
<project>net.osmand.translator</project>
</goals>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>13.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.google.code.findbugs</groupId>
<artifactId>jsr305</artifactId>
<version>2.0.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.contenttype</artifactId>
<version>3.4.100.v20100505-1235</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.registry</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.jobs</artifactId>
<version>3.5.0.v20100515</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.resources</artifactId>
<version>3.6.0.v20100526-0737</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.expressions</artifactId>
</exclusion>
<exclusion>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.filesystem</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.core</groupId>
<artifactId>org.eclipse.core.runtime</artifactId>
<version>3.6.0.v20100505</version>
<exclusions>
<exclusion>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.app</artifactId>
</exclusion>
</exclusions>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.common</artifactId>
<version>3.6.0.v20100503</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.equinox</groupId>
<artifactId>org.eclipse.equinox.preferences</artifactId>
<version>3.3.0.v20100503</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>org.eclipse.jdt.core</artifactId>
<version>3.8.1.v20120531-0637</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.eclipse.osgi</groupId>
<artifactId>org.eclipse.osgi</artifactId>
<version>3.6.0.v20100517</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jibx.config.3rdparty.org.eclipse</groupId>
<artifactId>org.eclipse.text</artifactId>
<version>3.5.100.v20110505-0800</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.10</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View file

@ -1,61 +0,0 @@
package net.osmand.translator;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "net.osmand.translator"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
*/
public void start(BundleContext context) throws Exception {
super.start(context);
plugin = this;
}
/*
* (non-Javadoc)
* @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
*/
public void stop(BundleContext context) throws Exception {
plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
/**
* Returns an image descriptor for the image file at the given
* plug-in relative path
*
* @param path the path
* @return the image descriptor
*/
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
}

View file

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

View file

@ -3,9 +3,6 @@ package net.osmand.translator.handlers;
import net.osmand.translator.utils.FieldsHandler;
import net.osmand.translator.utils.MethodHandler;
import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
@ -13,7 +10,6 @@ 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;
@ -28,22 +24,22 @@ import org.eclipse.jdt.core.dom.CompilationUnit;
import org.eclipse.jface.text.Document;
//import org.eclipse.jface.text.Document;
public class TranslationHandler extends AbstractHandler {
public Object execute(ExecutionEvent event) throws ExecutionException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IWorkspaceRoot root = workspace.getRoot();
IPath path = root.getProject("DataExtactionOSM").getFile("src/net/osmand/osm/MapUtils.java").getFullPath();
// 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);
return null;
}
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();
// 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);
@ -52,21 +48,20 @@ public class TranslationHandler extends AbstractHandler {
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();
}
}
for (IProject project : projects) {
try {
printProjectInfo(project);
} catch (CoreException e) {
e.printStackTrace();
}
}
}
private void printProjectInfo(IProject project) throws CoreException,
JavaModelException {
private void printProjectInfo(IProject project) throws CoreException, JavaModelException {
System.out.println("Working in project " + project.getName());
// Check if we have a Java project
if (project.isNatureEnabled("org.eclipse.jdt.core.javanature")) {
@ -75,34 +70,31 @@ public class TranslationHandler extends AbstractHandler {
}
}
private void printPackageInfos(IJavaProject javaProject)
throws JavaModelException {
IPackageFragment[] packages = javaProject.getPackageFragments();
for (IPackageFragment mypackage : packages) {
// Package fragments include all packages in the
// classpath
// We will only look at the package from the source
// folder
// K_BINARY would include also included JARS, e.g.
// rt.jar
if (mypackage.getKind() == IPackageFragmentRoot.K_SOURCE) {
System.out.println("Package " + mypackage.getElementName());
printICompilationUnitInfo(mypackage);
private void printPackageInfos(IJavaProject javaProject) throws JavaModelException {
IPackageFragment[] packages = javaProject.getPackageFragments();
for (IPackageFragment mypackage : packages) {
// Package fragments include all packages in the
// classpath
// We will only look at the package from the source
// folder
// K_BINARY would include also included JARS, e.g.
// rt.jar
if (mypackage.getKind() == IPackageFragmentRoot.K_SOURCE) {
System.out.println("Package " + mypackage.getElementName());
printICompilationUnitInfo(mypackage);
}
}
}
}
}
}
private void printICompilationUnitInfo(IPackageFragment mypackage)
throws JavaModelException {
private void printICompilationUnitInfo(IPackageFragment mypackage) throws JavaModelException {
for (ICompilationUnit unit : mypackage.getCompilationUnits()) {
printCompilationUnitDetails(unit);
}
}
private void printCompilationUnitDetails(ICompilationUnit unit)
throws JavaModelException {
private void printCompilationUnitDetails(ICompilationUnit unit) throws JavaModelException {
System.out.println("Source file " + unit.getElementName());
Document doc = new Document(unit.getSource());
System.out.println("Has number of lines: " + doc.getNumberOfLines());