This repository has been archived by the owner on May 13, 2023. It is now read-only.
forked from CoolCrabs/brachyura
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[6/?] Improved task support: Eclipse source lookup path editing support
One step closer towards the ultimate galimulator debugging experience
- Loading branch information
Showing
13 changed files
with
335 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
...hyura/src/main/java/io/github/coolcrabs/brachyura/ide/source/JarDepSourceLookupEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package io.github.coolcrabs.brachyura.ide.source; | ||
|
||
import java.io.StringWriter; | ||
import java.nio.file.Path; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
|
||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import io.github.coolcrabs.brachyura.dependency.JavaJarDependency; | ||
import io.github.coolcrabs.brachyura.util.XmlUtil.FormattedXMLStreamWriter; | ||
|
||
public class JarDepSourceLookupEntry implements SourceLookupEntry { | ||
|
||
@NotNull | ||
private final Path sourcesJar; | ||
|
||
public JarDepSourceLookupEntry(@NotNull JavaJarDependency dep) { | ||
Path sourcesJar = dep.sourcesJar; | ||
if (sourcesJar == null) { | ||
throw new IllegalArgumentException("JavaJarDependency has no sources jar attached."); | ||
} | ||
this.sourcesJar = sourcesJar; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTType() { | ||
return "org.eclipse.debug.core.containerType.externalArchive"; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTValue() { | ||
StringWriter writer = new StringWriter(); | ||
try (FormattedXMLStreamWriter xmlWriter = new FormattedXMLStreamWriter(writer)) { | ||
xmlWriter.writeStartDocument("UTF-8", "1.0"); | ||
xmlWriter.writeEmptyElement("archive"); | ||
xmlWriter.writeAttribute("detectRoot", "true"); // I have no idea what this does | ||
xmlWriter.writeAttribute("path", sourcesJar.toAbsolutePath().toString()); | ||
xmlWriter.writeEndDocument(); | ||
} catch (XMLStreamException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
return writer.toString(); | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
...yura/src/main/java/io/github/coolcrabs/brachyura/ide/source/JavaJRESourceLookupEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package io.github.coolcrabs.brachyura.ide.source; | ||
|
||
import java.io.StringWriter; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
|
||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import io.github.coolcrabs.brachyura.ide.Eclipse; | ||
import io.github.coolcrabs.brachyura.util.XmlUtil.FormattedXMLStreamWriter; | ||
|
||
public class JavaJRESourceLookupEntry implements SourceLookupEntry { | ||
|
||
private int javaVersion; | ||
|
||
public JavaJRESourceLookupEntry(int javaVersion) { | ||
this.javaVersion = javaVersion; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTType() { | ||
return "org.eclipse.jdt.launching.sourceContainer.classpathContainer"; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTValue() { | ||
StringWriter writer = new StringWriter(); | ||
try (FormattedXMLStreamWriter xmlWriter = new FormattedXMLStreamWriter(writer)) { | ||
xmlWriter.writeStartDocument("UTF-8", "1.0"); | ||
xmlWriter.writeEmptyElement("classpathContainer"); | ||
xmlWriter.writeAttribute("path", Eclipse.JDT_JRE_CONTAINER_JVM + getJavaVersion()); | ||
xmlWriter.writeEndDocument(); | ||
} catch (XMLStreamException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
return writer.toString(); | ||
} | ||
|
||
@Contract(pure = true) | ||
public int getJavaVersion() { | ||
return javaVersion; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
.../src/main/java/io/github/coolcrabs/brachyura/ide/source/JavaProjectSourceLookupEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
package io.github.coolcrabs.brachyura.ide.source; | ||
|
||
import java.io.StringWriter; | ||
|
||
import javax.xml.stream.XMLStreamException; | ||
|
||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import io.github.coolcrabs.brachyura.project.java.BuildModule; | ||
import io.github.coolcrabs.brachyura.project.java.SimpleJavaProject; | ||
import io.github.coolcrabs.brachyura.util.XmlUtil.FormattedXMLStreamWriter; | ||
|
||
/** | ||
* Creates a debug source lookup entry that provides the source of another java project. | ||
* Usually it will be another brachyura build module, but really can be any java project under a given name | ||
* however doing that increases the risk of the project not running on other computers. | ||
* | ||
* <p>Dependencies of that project are excluded and may need to be added manually using | ||
* {@link JarDepSourceLookupEntry}. | ||
* | ||
* <p>It is generally preferable to use this class over {@link JarDepSourceLookupEntry} if possible | ||
* as those two projects will more or less be linked, making hotswapping easier. | ||
* | ||
* @author Geolykt | ||
* @since 0.90.5 | ||
*/ | ||
public class JavaProjectSourceLookupEntry implements SourceLookupEntry { | ||
|
||
@NotNull | ||
private final String projectName; | ||
|
||
public JavaProjectSourceLookupEntry(@NotNull BuildModule module) { | ||
this.projectName = module.getModuleName(); | ||
} | ||
|
||
public JavaProjectSourceLookupEntry(@NotNull SimpleJavaProject project) { | ||
this(project.projectModule.get()); | ||
} | ||
|
||
public JavaProjectSourceLookupEntry(@NotNull String projectName) { | ||
this.projectName = projectName; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTType() { | ||
return "org.eclipse.jdt.launching.sourceContainer.javaProject"; | ||
} | ||
|
||
@Override | ||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTValue() { | ||
StringWriter writer = new StringWriter(); | ||
try (FormattedXMLStreamWriter xmlWriter = new FormattedXMLStreamWriter(writer)) { | ||
xmlWriter.writeStartDocument("UTF-8", "1.0"); | ||
xmlWriter.writeEmptyElement("javaProject"); | ||
xmlWriter.writeAttribute("name", getProjectName()); | ||
xmlWriter.writeEndDocument(); | ||
} catch (XMLStreamException e) { | ||
throw new IllegalStateException(e); | ||
} | ||
return writer.toString(); | ||
} | ||
|
||
@NotNull | ||
@Contract(pure = true) | ||
public String getProjectName() { | ||
return projectName; | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
brachyura/src/main/java/io/github/coolcrabs/brachyura/ide/source/SourceLookupEntry.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package io.github.coolcrabs.brachyura.ide.source; | ||
|
||
import org.jetbrains.annotations.Contract; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
public interface SourceLookupEntry { | ||
|
||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTType(); | ||
|
||
@NotNull | ||
@Contract(value = "-> !null", pure = true) | ||
public String getEclipseJDTValue(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.