Skip to content

Commit bdbec8e

Browse files
committed
First version of the Vye GWT Eclipse plugin
0 parents  commit bdbec8e

File tree

15 files changed

+454
-0
lines changed

15 files changed

+454
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.classpath
2+
bin

.project

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Vue GWT</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.pde.ManifestBuilder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
<buildCommand>
19+
<name>org.eclipse.pde.SchemaBuilder</name>
20+
<arguments>
21+
</arguments>
22+
</buildCommand>
23+
</buildSpec>
24+
<natures>
25+
<nature>org.eclipse.pde.PluginNature</nature>
26+
<nature>org.eclipse.jdt.core.javanature</nature>
27+
</natures>
28+
</projectDescription>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
4+
org.eclipse.jdt.core.compiler.compliance=1.8
5+
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6+
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7+
org.eclipse.jdt.core.compiler.source=1.8

META-INF/MANIFEST.MF

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: Vue GWT
4+
Bundle-SymbolicName: Vue_GWT;singleton:=true
5+
Bundle-Activator: com.axellience.vuegwt.eclipse.Startup
6+
Bundle-Version: 1.0.0.alpha
7+
Bundle-Vendor: Axellience
8+
Require-Bundle: org.eclipse.core.resources,
9+
org.eclipse.core.runtime,
10+
org.eclipse.ui,
11+
org.eclipse.jdt.core;bundle-version="3.13.100"
12+
Bundle-RequiredExecutionEnvironment: JavaSE-1.8

build.properties

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source.. = src/
2+
output.. = bin/
3+
bin.includes = plugin.xml,\
4+
META-INF/,\
5+
.,
6+
jars.compile.order = .,\
7+
lib/
8+
src.includes = lib/

build.xml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<!-- WARNING: Eclipse auto-generated file.
3+
Any modifications will be overwritten.
4+
To include a user specific buildfile here, simply create one in the same
5+
directory with the processing instruction <?eclipse.ant.import?>
6+
as the first entry and export the buildfile again. --><project basedir="." default="build" name="Vue GWT">
7+
<property environment="env"/>
8+
<property name="ECLIPSE_HOME" value="../../Applications/eclipse/"/>
9+
<property name="debuglevel" value="source,lines,vars"/>
10+
<property name="target" value="1.8"/>
11+
<property name="source" value="1.8"/>
12+
<path id="Plug-in Dependencies.libraryclasspath">
13+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.resources_3.12.0.v20170417-1558.jar"/>
14+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.runtime_3.13.0.v20170207-1030.jar"/>
15+
<pathelement location="${ECLIPSE_HOME}plugins/javax.inject_1.0.0.v20091030.jar"/>
16+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.osgi_3.12.50.v20170928-1321.jar"/>
17+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.osgi.compatibility.state_1.1.0.v20170516-1513.jar"/>
18+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.equinox.common_3.9.0.v20170207-1454.jar"/>
19+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.jobs_3.9.2.v20171030-1027.jar"/>
20+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.equinox.registry_3.7.0.v20170222-1344.jar"/>
21+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.equinox.preferences_3.7.0.v20170126-2132.jar"/>
22+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.contenttype_3.6.0.v20170207-1037.jar"/>
23+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.equinox.app_1.3.400.v20150715-1528.jar"/>
24+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.ui_3.109.0.v20170411-1742.jar"/>
25+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.swt_3.106.2.v20171129-0543.jar"/>
26+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.swt.win32.win32.x86_64_3.106.2.v20171129-0543.jar"/>
27+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.jface_3.13.2.v20171022-1656.jar"/>
28+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.core.commands_3.9.0.v20170530-1048.jar"/>
29+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.ui.workbench_3.110.1.v20170704-1208.jar"/>
30+
<pathelement location="${ECLIPSE_HOME}plugins/org.eclipse.e4.ui.workbench3_0.14.0.v20160630-0740.jar"/>
31+
</path>
32+
<path id="Vue GWT.classpath">
33+
<path refid="Plug-in Dependencies.libraryclasspath"/>
34+
<pathelement location="bin"/>
35+
</path>
36+
<target name="init">
37+
<mkdir dir="bin"/>
38+
<copy includeemptydirs="false" todir="bin">
39+
<fileset dir="src">
40+
<exclude name="**/*.java"/>
41+
</fileset>
42+
</copy>
43+
</target>
44+
<target name="clean">
45+
<delete dir="bin"/>
46+
</target>
47+
<target depends="clean" name="cleanall"/>
48+
<target depends="build-subprojects,build-project" name="build"/>
49+
<target name="build-subprojects"/>
50+
<target depends="init" name="build-project">
51+
<echo message="${ant.project.name}: ${ant.file}"/>
52+
<javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
53+
<src path="src"/>
54+
<classpath refid="Vue GWT.classpath"/>
55+
</javac>
56+
</target>
57+
<target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
58+
<target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
59+
<copy todir="${ant.library.dir}">
60+
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
61+
</copy>
62+
<unzip dest="${ant.library.dir}">
63+
<patternset includes="jdtCompilerAdapter.jar"/>
64+
<fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
65+
</unzip>
66+
</target>
67+
<target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
68+
<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
69+
<antcall target="build"/>
70+
</target>
71+
</project>

plugin.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<?eclipse version="3.4"?>
3+
<plugin>
4+
<extension
5+
point="org.eclipse.ui.startup">
6+
<startup
7+
class="com.axellience.vuegwt.eclipse.Startup">
8+
</startup>
9+
</extension>
10+
</plugin>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package com.axellience.vuegwt.eclipse;
2+
3+
import org.eclipse.core.resources.ResourcesPlugin;
4+
import org.eclipse.ui.IStartup;
5+
6+
import com.axellience.vuegwt.eclipse.templatewatcher.VueTemplateWatcher;
7+
8+
public class Startup implements IStartup {
9+
private VueTemplateWatcher vueTemplateWatcher;
10+
11+
@Override
12+
public void earlyStartup() {
13+
this.vueTemplateWatcher = new VueTemplateWatcher();
14+
ResourcesPlugin.getWorkspace().addResourceChangeListener(vueTemplateWatcher);
15+
}
16+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package com.axellience.vuegwt.eclipse.projectmanager;
2+
3+
import java.util.Collections;
4+
import java.util.List;
5+
import java.util.Optional;
6+
import java.util.stream.Collectors;
7+
import java.util.stream.Stream;
8+
9+
import org.eclipse.core.resources.IResource;
10+
import org.eclipse.core.runtime.IPath;
11+
import org.eclipse.jdt.core.IClasspathEntry;
12+
import org.eclipse.jdt.core.IJavaProject;
13+
import org.eclipse.jdt.core.IPackageFragmentRoot;
14+
import org.eclipse.jdt.core.JavaModelException;
15+
16+
public class VueProjectInfo {
17+
private final IJavaProject javaProject;
18+
19+
VueProjectInfo(IJavaProject javaProject) {
20+
this.javaProject = javaProject;
21+
}
22+
23+
public Optional<IPath> getResourceSourcePath(IResource resource) {
24+
return this.getSourcePaths().stream().filter(sourcePath -> sourcePath.isPrefixOf(resource.getFullPath()))
25+
.findFirst();
26+
}
27+
28+
public List<IPath> getSourcePaths() {
29+
try {
30+
return Stream.of(javaProject.getResolvedClasspath(true))
31+
.filter(entry -> entry.getContentKind() == IPackageFragmentRoot.K_SOURCE)
32+
.map(IClasspathEntry::getPath).collect(Collectors.toList());
33+
} catch (JavaModelException e) {
34+
e.printStackTrace();
35+
}
36+
37+
return Collections.emptyList();
38+
}
39+
40+
public Optional<IPath> getOutputPath() {
41+
try {
42+
return Optional.of(javaProject.getOutputLocation());
43+
} catch (JavaModelException e) {
44+
e.printStackTrace();
45+
}
46+
47+
return Optional.empty();
48+
}
49+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package com.axellience.vuegwt.eclipse.projectmanager;
2+
3+
import java.util.HashMap;
4+
import java.util.Map;
5+
import java.util.Optional;
6+
7+
import org.eclipse.core.resources.IProject;
8+
import org.eclipse.core.resources.IResource;
9+
import org.eclipse.core.runtime.IPath;
10+
import org.eclipse.jdt.core.JavaCore;
11+
import org.eclipse.jdt.internal.core.JavaProject;
12+
13+
public class VueProjectsManager {
14+
private final Map<IProject, VueProjectInfo> vueProjectInfoCache;
15+
16+
public VueProjectsManager() {
17+
vueProjectInfoCache = new HashMap<>();
18+
}
19+
20+
public Optional<IPath> getResourceSourcePath(IResource resource) {
21+
return getInfoForProject(resource.getProject())
22+
.flatMap(projectInfo -> projectInfo.getResourceSourcePath(resource));
23+
}
24+
25+
public Optional<VueProjectInfo> getInfoForProject(IProject project) {
26+
if (vueProjectInfoCache.containsKey(project))
27+
return Optional.of(vueProjectInfoCache.get(project));
28+
29+
if (!project.isOpen() || !isJavaProject(project))
30+
return Optional.empty();
31+
32+
VueProjectInfo vueProjectInfo = new VueProjectInfo(JavaCore.create(project));
33+
vueProjectInfoCache.put(project, vueProjectInfo);
34+
return Optional.of(vueProjectInfo);
35+
}
36+
37+
public boolean isJavaProject(IProject project) {
38+
return JavaProject.hasJavaNature(project);
39+
}
40+
}

0 commit comments

Comments
 (0)