|
From: <caw...@us...> - 2007-01-19 19:08:40
|
Revision: 1815
http://svn.sourceforge.net/rubyeclipse/?rev=1815&view=rev
Author: cawilliams
Date: 2007-01-19 11:08:37 -0800 (Fri, 19 Jan 2007)
Log Message:
-----------
yay for no broken builds!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/plugin.xml
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/AbstractRuntimeLoadpathEntry.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathEntry.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathResolver.java
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-19 19:03:28 UTC (rev 1814)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-19 19:08:37 UTC (rev 1815)
@@ -62,10 +62,10 @@
<extension
point="org.rubypeople.rdt.launching.runtimeLoadpathEntryResolvers">
<runtimeLoadpathEntryResolver
- container="org.rubypeople.rdt.launching.JRE_CONTAINER"
- variable="JRE_LIB"
- class="org.rubypeople.rdt.internal.launching.JRERuntimeLoadpathEntryResolver"
- id="org.rubypeople.rdt.launching.JRE_RESOLVER">
+ container="org.rubypeople.rdt.launching.RUBY_CONTAINER"
+ variable="RUBY_LIB"
+ class="org.rubypeople.rdt.internal.launching.RubyVMRuntimeLoadpathEntryResolver"
+ id="org.rubypeople.rdt.launching.RUBYVM_RESOLVER">
</runtimeLoadpathEntryResolver>
<runtimeLoadpathEntryResolver
runtimeLoadpathEntryId="org.rubypeople.rdt.launching.loadpathentry.variableLoadpathEntry"
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/AbstractRuntimeLoadpathEntry.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/AbstractRuntimeLoadpathEntry.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/AbstractRuntimeLoadpathEntry.java 2007-01-19 19:08:37 UTC (rev 1815)
@@ -0,0 +1,233 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
+import org.rubypeople.rdt.launching.IRuntimeLoadpathEntry;
+import org.rubypeople.rdt.launching.IRuntimeLoadpathEntry2;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+/**
+ * Common function for runtime classpath entries.
+ * <p>
+ * Clients implementing runtime classpath entries must subclass this
+ * class.
+ * </p>
+ * @since 3.0
+ */
+public abstract class AbstractRuntimeLoadpathEntry extends PlatformObject implements IRuntimeLoadpathEntry2 {
+
+ private IPath sourceAttachmentPath = null;
+ private IPath rootSourcePath = null;
+ private int classpathProperty = IRuntimeLoadpathEntry.USER_CLASSES;
+ /**
+ * Associated ruby project, or <code>null</code>
+ */
+ private IRubyProject fRubyProject;
+
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>false</code>.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.internal.launching.IRuntimeLoadpathEntry2#isComposite()
+ */
+ public boolean isComposite() {
+ return false;
+ }
+
+ /* (non-rubydoc)
+ *
+ * Default implementation returns an empty collection.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.internal.launching.IRuntimeLoadpathEntry2#getRuntimeLoadpathEntries()
+ */
+ public IRuntimeLoadpathEntry[] getRuntimeLoadpathEntries() throws CoreException {
+ return new IRuntimeLoadpathEntry[0];
+ }
+
+ /**
+ * Throws an exception with the given message and underlying exception.
+ *
+ * @param message error message
+ * @param exception underlying exception or <code>null</code> if none
+ * @throws CoreException
+ */
+ protected void abort(String message, Throwable exception) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IRubyLaunchConfigurationConstants.ERR_INTERNAL_ERROR, message, exception);
+ throw new CoreException(status);
+ }
+
+ /* (non-rubydoc)
+ *
+ * Default implementation generates a string containing an XML
+ * document. Subclasses should override <code>buildMemento</code>
+ * to specify the contents of the required <code>memento</code>
+ * node.
+ *
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getMemento()
+ */
+ public String getMemento() throws CoreException {
+ Document doc= DebugPlugin.newDocument();
+ Element root = doc.createElement("runtimeLoadpathEntry"); //$NON-NLS-1$
+ doc.appendChild(root);
+ root.setAttribute("id", getTypeId()); //$NON-NLS-1$
+ Element memento = doc.createElement("memento"); //$NON-NLS-1$
+ root.appendChild(memento);
+ buildMemento(doc, memento);
+ return DebugPlugin.serializeDocument(doc);
+ }
+
+ /**
+ * Constructs a memento for this classpath entry in the given
+ * document and element. The memento element has already been
+ * appended to the document.
+ *
+ * @param document XML document
+ * @param memento element node for client specific attributes
+ * @throws CoreException if unable to create a memento
+ */
+ protected abstract void buildMemento(Document document, Element memento) throws CoreException;
+
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getPath()
+ */
+ public IPath getPath() {
+ return null;
+ }
+
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getResource()
+ */
+ public IResource getResource() {
+ return null;
+ }
+
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getSourceAttachmentPath()
+ */
+ public IPath getSourceAttachmentPath() {
+ return sourceAttachmentPath;
+ }
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#setSourceAttachmentPath(org.eclipse.core.runtime.IPath)
+ */
+ public void setSourceAttachmentPath(IPath path) {
+ sourceAttachmentPath = path;
+ }
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getSourceAttachmentRootPath()
+ */
+ public IPath getSourceAttachmentRootPath() {
+ return rootSourcePath;
+ }
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#setSourceAttachmentRootPath(org.eclipse.core.runtime.IPath)
+ */
+ public void setSourceAttachmentRootPath(IPath path) {
+ rootSourcePath = path;
+ }
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getLoadpathProperty()
+ */
+ public int getLoadpathProperty() {
+ return classpathProperty;
+ }
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#setLoadpathProperty(int)
+ */
+ public void setLoadpathProperty(int property) {
+ classpathProperty = property;
+ }
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getLocation()
+ */
+ public String getLocation() {
+ return null;
+ }
+
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getSourceAttachmentLocation()
+ */
+ public String getSourceAttachmentLocation() {
+ return null;
+ }
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getSourceAttachmentRootLocation()
+ */
+ public String getSourceAttachmentRootLocation() {
+ return null;
+ }
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getVariableName()
+ */
+ public String getVariableName() {
+ return null;
+ }
+ /* (non-rubydoc)
+ *
+ * Default implementation returns <code>null</code>.
+ * Subclasses should override if required.
+ *
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getLoadpathEntry()
+ */
+ public ILoadpathEntry getLoadpathEntry() {
+ return null;
+ }
+ /* (non-rubydoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getrubyProject()
+ */
+ public IRubyProject getRubyProject() {
+ return fRubyProject;
+ }
+
+ /**
+ * Sets the ruby project associated with this entry.
+ *
+ * @param javaProject
+ */
+ protected void setRubyProject(IRubyProject javaProject) {
+ fRubyProject = javaProject;
+ }
+}
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathEntry.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathEntry.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathEntry.java 2007-01-19 19:08:37 UTC (rev 1815)
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.rubypeople.rdt.launching.IRuntimeLoadpathEntry;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+
+
+public class VariableLoadpathEntry extends AbstractRuntimeLoadpathEntry {
+ public static final String TYPE_ID = "org.rubypeople.rdt.launching.loadpathentry.variableLoadpathEntry"; //$NON-NLS-1$
+ private String variableString;
+
+ public VariableLoadpathEntry() {
+ }
+
+ public VariableLoadpathEntry(String variableString) {
+ this.variableString = variableString;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.internal.launching.AbstractRuntimeLoadpathEntry#buildMemento(org.w3c.dom.Document, org.w3c.dom.Element)
+ */
+ protected void buildMemento(Document document, Element memento) throws CoreException {
+ memento.setAttribute("variableString", variableString); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry2#initializeFrom(org.w3c.dom.Element)
+ */
+ public void initializeFrom(Element memento) throws CoreException {
+ variableString = memento.getAttribute("variableString"); //$NON-NLS-1$
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry2#getTypeId()
+ */
+ public String getTypeId() {
+ return TYPE_ID;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry2#getRuntimeLoadpathEntries(org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public IRuntimeLoadpathEntry[] getRuntimeLoadpathEntries(ILaunchConfiguration configuration) throws CoreException {
+ return new IRuntimeLoadpathEntry[0];
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry2#getName()
+ */
+ public String getName() {
+ return variableString;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getType()
+ */
+ public int getType() {
+ return OTHER;
+ }
+ /**
+ * @return Returns the variableString.
+ */
+ public String getVariableString() {
+ return variableString;
+ }
+ /**
+ * @param variableString The variableString to set.
+ */
+ public void setVariableString(String variableString) {
+ this.variableString = variableString;
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntry#getPath()
+ */
+// public IPath getPath() {
+// try {
+// String path = StringVariableManager.getDefault().performStringSubstitution(variableString);
+// return new Path(path);
+// } catch (CoreException ce) {
+// return null;
+// }
+// }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ public int hashCode() {
+ if (variableString != null)
+ return variableString.hashCode();
+ return 0;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ public boolean equals(Object obj) {
+ if (obj instanceof VariableLoadpathEntry) {
+ VariableLoadpathEntry other= (VariableLoadpathEntry)obj;
+ if (variableString != null) {
+ return variableString.equals(other.variableString);
+ }
+ }
+ return false;
+ }
+
+}
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathResolver.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathResolver.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VariableLoadpathResolver.java 2007-01-19 19:08:37 UTC (rev 1815)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2005 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.variables.VariablesPlugin;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.launching.IRuntimeLoadpathEntry;
+import org.rubypeople.rdt.launching.IRuntimeLoadpathEntryResolver;
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.RubyRuntime;
+
+
+public class VariableLoadpathResolver implements IRuntimeLoadpathEntryResolver {
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntryResolver#resolveRuntimeLoadpathEntry(org.eclipse.jdt.launching.IRuntimeLoadpathEntry, org.eclipse.debug.core.ILaunchConfiguration)
+ */
+ public IRuntimeLoadpathEntry[] resolveRuntimeLoadpathEntry(IRuntimeLoadpathEntry entry, ILaunchConfiguration configuration) throws CoreException {
+ return resolveRuntimeLoadpathEntry(entry);
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntryResolver#resolveRuntimeLoadpathEntry(org.eclipse.jdt.launching.IRuntimeLoadpathEntry, org.eclipse.jdt.core.IJavaProject)
+ */
+ public IRuntimeLoadpathEntry[] resolveRuntimeLoadpathEntry(IRuntimeLoadpathEntry entry, IRubyProject project) throws CoreException {
+ return resolveRuntimeLoadpathEntry(entry);
+ }
+
+ private IRuntimeLoadpathEntry[] resolveRuntimeLoadpathEntry(IRuntimeLoadpathEntry entry) throws CoreException{
+ String variableString = ((VariableLoadpathEntry)entry).getVariableString();
+ String strpath = VariablesPlugin.getDefault().getStringVariableManager().performStringSubstitution(variableString);
+ IPath path = new Path(strpath).makeAbsolute();
+ IRuntimeLoadpathEntry archiveEntry = RubyRuntime.newArchiveRuntimeLoadpathEntry(path);
+ return new IRuntimeLoadpathEntry[] { archiveEntry };
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.jdt.launching.IRuntimeLoadpathEntryResolver#resolveVMInstall(org.eclipse.jdt.core.ILoadpathEntry)
+ */
+ public IVMInstall resolveVMInstall(ILoadpathEntry entry) throws CoreException {
+ return null;
+ }
+}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-01-19 19:03:28 UTC (rev 1814)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/RubyRuntime.java 2007-01-19 19:08:37 UTC (rev 1815)
@@ -37,6 +37,7 @@
import org.rubypeople.rdt.internal.launching.LaunchingMessages;
import org.rubypeople.rdt.internal.launching.LaunchingPlugin;
import org.rubypeople.rdt.internal.launching.ListenerList;
+import org.rubypeople.rdt.internal.launching.RuntimeLoadpathEntry;
import org.rubypeople.rdt.internal.launching.RuntimeLoadpathEntryResolver;
import org.rubypeople.rdt.internal.launching.VMDefinitionsContainer;
@@ -884,4 +885,30 @@
private static IRubyModel getRubyModel() {
return RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
}
+
+ /**
+ * Returns a new runtime classpath entry for the given archive (possibly
+ * external).
+ *
+ * @param path absolute path to an archive
+ * @return runtime classpath entry
+ * @since 0.9.0
+ */
+ public static IRuntimeLoadpathEntry newArchiveRuntimeLoadpathEntry(IPath path) {
+ ILoadpathEntry cpe = RubyCore.newLibraryEntry(path);
+ return newRuntimeLoadpathEntry(cpe);
+ }
+
+ /**
+ * Returns a runtime classpath entry that corresponds to the given
+ * classpath entry. The classpath entry may not be of type <code>CPE_SOURCE</code>
+ * or <code>CPE_CONTAINER</code>.
+ *
+ * @param entry a classpath entry
+ * @return runtime classpath entry
+ * @since 0.9.0
+ */
+ private static IRuntimeLoadpathEntry newRuntimeLoadpathEntry(ILoadpathEntry entry) {
+ return new RuntimeLoadpathEntry(entry);
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|