Skip to content

Commit

Permalink
Initial code commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Sipkab committed Dec 30, 2019
1 parent 8fa82a4 commit fa094e5
Show file tree
Hide file tree
Showing 31 changed files with 2,281 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?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.8"/>
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src"/>
<classpathentry kind="output" path="bin"/>
</classpath>
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/bin/
28 changes: 28 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>SakerJavaIDEConfigurationParserPlugin</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>
15 changes: 15 additions & 0 deletions META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: saker.java.ide.eclipse
Bundle-SymbolicName: saker.java.ide.eclipse;singleton:=true
Bundle-Version: 1.0.0.qualifier
Automatic-Module-Name: saker.java.ide.eclipse
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Require-Bundle: saker.build.ide.eclipse;bundle-version="1.0.0",
org.eclipse.core.resources;bundle-version="3.13.400",
org.eclipse.core.runtime;bundle-version="3.15.300",
org.eclipse.jdt.core;bundle-version="3.18.0",
org.eclipse.jdt.launching;bundle-version="3.14.0",
org.eclipse.swt;bundle-version="3.111.0",
org.eclipse.jdt.ui;bundle-version="3.18.0",
org.eclipse.ui;bundle-version="3.113.0"
6 changes: 6 additions & 0 deletions build.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
source.. = src/
output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.xml,\
icons/
Binary file added icons/add_sub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/clear_sub.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/clear_sub.png_red
Binary file not shown.
Binary file added icons/[email protected]
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added icons/[email protected]_red
Binary file not shown.
18 changes: 18 additions & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
<extension
id="saker.java.ide.eclipse.extension.ideConfigurationTypeHandler"
name="Java IDE configuration handler"
point="saker.build.ide.eclipse.extension.ideConfigurationTypeHandler">
<parser class="saker.java.ide.eclipse.JavaIDEConfigurationTypeHandler" type="saker.java.compile.ide.configuration" type_name="Java">
</parser>
</extension>
<extension
id="saker.java.ide.eclipse.extension.params.installation.environmentUserParameterContributor"
name="Java Installation Environment Parameter Contributor"
point="saker.build.ide.eclipse.extension.environmentUserParameterContributor">
<contributor
class="saker.java.ide.eclipse.params.JavaInstallationEnvironmentUserParameterContributor"></contributor>
</extension>
</plugin>
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package saker.java.ide.eclipse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import org.eclipse.jdt.core.IClasspathAttribute;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import saker.build.ide.eclipse.extension.ideconfig.AbstractIDEProjectConfigurationEntry;
import saker.build.ide.eclipse.extension.ideconfig.IIDEProjectConfigurationEntry;

public class AddExportsContainerProjectConfigurationEntry extends AbstractIDEProjectConfigurationEntry {
private static final Image IMG_ENTRY = JavaIDEConfigurationTypeHandler.getComposedImage(
AbstractUIPlugin.imageDescriptorFromPlugin(JavaUI.ID_PLUGIN, "icons/full/obj16/module_obj.png"), null);

private List<AddExportsProjectConfigurationEntry> addExportEntries = new ArrayList<>();

public AddExportsContainerProjectConfigurationEntry(Collection<AddExportsData> addexportscoll) {
for (AddExportsData addexport : addexportscoll) {
addExportEntries.add(new AddExportsProjectConfigurationEntry(addexport));
}
}

public void contribute(List<IClasspathAttribute> extraattrlist) {
Set<String> exports = new TreeSet<>();
for (AddExportsProjectConfigurationEntry entry : addExportEntries) {
if (!entry.isSelected()) {
continue;
}
exports.addAll(entry.getAddExports().toCommandLineStrings());
}
if (exports.isEmpty()) {
//nothing to modify
return;
}
for (Iterator<IClasspathAttribute> it = extraattrlist.iterator(); it.hasNext();) {
IClasspathAttribute a = it.next();
if (IClasspathAttribute.ADD_EXPORTS.equals(a.getName())) {
for (String cmdopd : a.getValue().split(":")) {
exports.add(cmdopd);
}
it.remove();
}
}
extraattrlist.add(JavaCore.newClasspathAttribute(IClasspathAttribute.ADD_EXPORTS, String.join(":", exports)));
}

@Override
public IIDEProjectConfigurationEntry[] getSubEntries() {
return addExportEntries.toArray(new AddExportsProjectConfigurationEntry[addExportEntries.size()]);
}

@Override
public String getLabel() {
return "Add exports";
}

@Override
public Image getImage() {
return IMG_ENTRY;
}

@Override
public String toString() {
return getClass().getSimpleName() + "[addExports=" + addExportEntries + "]";
}

}
68 changes: 68 additions & 0 deletions src/saker/java/ide/eclipse/AddExportsData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package saker.java.ide.eclipse;

import java.util.Collection;
import java.util.Set;
import java.util.TreeSet;

public class AddExportsData {
public final String module;
public final String pack;
public final Set<String> target;

public AddExportsData(String module, String pack, Set<String> target) {
this.module = module;
this.pack = pack;
this.target = target;
}

@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((module == null) ? 0 : module.hashCode());
result = prime * result + ((pack == null) ? 0 : pack.hashCode());
result = prime * result + ((target == null) ? 0 : target.hashCode());
return result;
}

@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
AddExportsData other = (AddExportsData) obj;
if (module == null) {
if (other.module != null)
return false;
} else if (!module.equals(other.module))
return false;
if (pack == null) {
if (other.pack != null)
return false;
} else if (!pack.equals(other.pack))
return false;
if (target == null) {
if (other.target != null)
return false;
} else if (!target.equals(other.target))
return false;
return true;
}

@Override
public String toString() {
//don't modify, keep this as the command line representation
return module + "/" + pack + "=" + String.join(",", target);
}

public Collection<String> toCommandLineStrings() {
Collection<String> result = new TreeSet<>();
for (String targetstr : target) {
result.add(module + "/" + pack + "=" + targetstr);
}
return result;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package saker.java.ide.eclipse;

import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.plugin.AbstractUIPlugin;

import saker.build.ide.eclipse.extension.ideconfig.AbstractIDEProjectConfigurationEntry;

public class AddExportsProjectConfigurationEntry extends AbstractIDEProjectConfigurationEntry {
private static final Image IMG_ENTRY = JavaIDEConfigurationTypeHandler.getComposedImage(
AbstractUIPlugin.imageDescriptorFromPlugin(JavaUI.ID_PLUGIN, "icons/full/obj16/module_obj.png"),
AbstractUIPlugin.imageDescriptorFromPlugin(JavaIDEConfigurationTypeHandler.PLUGIN_ID, "icons/add_sub.png"));

private AddExportsData addExports;

public AddExportsProjectConfigurationEntry(AddExportsData addExports) {
this.addExports = addExports;
}

public AddExportsData getAddExports() {
return addExports;
}

@Override
public String getLabel() {
return addExports.toString();
}

@Override
public Image getImage() {
return IMG_ENTRY;
}

@Override
public String toString() {
return getClass().getSimpleName() + "[addExports=" + addExports + "]";
}

}
11 changes: 11 additions & 0 deletions src/saker/java/ide/eclipse/ClassPathConfigurationEntry.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package saker.java.ide.eclipse;

import java.util.Collection;

import org.eclipse.jdt.core.IClasspathEntry;

import saker.build.ide.eclipse.extension.ideconfig.IIDEProjectConfigurationEntry;

public interface ClassPathConfigurationEntry extends IIDEProjectConfigurationEntry {
public void contribute(Collection<IClasspathEntry> entries);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
package saker.java.ide.eclipse;

import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.swt.graphics.Image;

import saker.build.ide.eclipse.extension.ideconfig.AbstractIDEProjectConfigurationEntry;
import saker.build.ide.eclipse.extension.ideconfig.IIDEProjectConfigurationEntry;

public class ClassPathContainerConfigurationEntry extends AbstractIDEProjectConfigurationEntry
implements ClassPathConfigurationEntry {
private static final Image IMG_ENTRY = JavaIDEConfigurationTypeHandler.getImageFromPlugin(JavaUI.ID_PLUGIN,
"icons/full/obj16/library_obj.png");

private List<ClassPathConfigurationEntry> classpathEntries = new ArrayList<>();
private transient Set<ClassPathConfigurationEntry> removalClasspathEntries = new LinkedHashSet<>();

public ClassPathContainerConfigurationEntry() {
}

public void addClassPathEntry(ClassPathConfigurationEntry entry) {
this.classpathEntries.add(entry);
}

public void addRemovalClassPathEntry(ClassPathConfigurationEntry entry) {
this.removalClasspathEntries.add(entry);
}

public boolean isEmpty() {
return classpathEntries.isEmpty();
}

public void initSelection() {
for (ClassPathConfigurationEntry cpentry : classpathEntries) {
if (cpentry.isSelected()) {
this.setSelected(true);
return;
}
}
this.setSelected(false);
}

@Override
public void contribute(Collection<IClasspathEntry> entries) {
for (ClassPathConfigurationEntry sentry : removalClasspathEntries) {
if (!sentry.isSelected()) {
continue;
}
sentry.contribute(entries);
}
for (ClassPathConfigurationEntry sentry : classpathEntries) {
if (!sentry.isSelected() || removalClasspathEntries.contains(sentry)) {
continue;
}
sentry.contribute(entries);
}
}

@Override
public IIDEProjectConfigurationEntry[] getSubEntries() {
return classpathEntries.toArray(new IIDEProjectConfigurationEntry[0]);
}

@Override
public String getLabel() {
return "Classpath";
}

@Override
public Image getImage() {
return IMG_ENTRY;
}

@Override
public String toString() {
return getClass().getSimpleName() + "[" + classpathEntries + "]";
}
}
Loading

0 comments on commit fa094e5

Please sign in to comment.