|
From: <caw...@us...> - 2007-01-18 14:14:53
|
Revision: 1787
http://svn.sourceforge.net/rubyeclipse/?rev=1787&view=rev
Author: cawilliams
Date: 2007-01-18 06:14:47 -0800 (Thu, 18 Jan 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/plugin.xml
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyVMContainer.java
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-18 14:11:30 UTC (rev 1786)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-18 14:14:47 UTC (rev 1787)
@@ -33,17 +33,17 @@
</extension>
<extension
point="org.rubypeople.rdt.core.loadpathVariableInitializer">
- <classpathVariableInitializer
+ <loadpathVariableInitializer
variable="RUBY_LIB"
- class="org.rubypeople.jdt.internal.launching.RubyLoadpathVariablesInitializer">
- </classpathVariableInitializer>
+ class="org.rubypeople.rdt.internal.launching.RubyLoadpathVariablesInitializer">
+ </loadpathVariableInitializer>
</extension>
<extension
point="org.rubypeople.rdt.core.loadpathContainerInitializer">
- <classpathContainerInitializer
+ <loadpathContainerInitializer
class="org.rubypeople.rdt.internal.launching.RubyContainerInitializer"
id="org.rubypeople.rdt.launching.RUBY_CONTAINER">
- </classpathContainerInitializer>
+ </loadpathContainerInitializer>
</extension>
</plugin>
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyVMContainer.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyVMContainer.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyVMContainer.java 2007-01-18 14:14:47 UTC (rev 1787)
@@ -0,0 +1,100 @@
+package org.rubypeople.rdt.internal.launching;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.ILoadpathContainer;
+import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.launching.IInterpreter;
+import org.rubypeople.rdt.launching.IInterpreterInstallChangedListener;
+import org.rubypeople.rdt.launching.PropertyChangeEvent;
+
+public class RubyVMContainer implements ILoadpathContainer {
+
+ private static Map fgLoadpathEntries;
+ private IInterpreter fInterpreter;
+ private IPath fPath;
+
+ public RubyVMContainer(IInterpreter interpreter, IPath path) {
+ fInterpreter = interpreter;
+ fPath = path;
+ }
+
+ public String getDescription() {
+ return "Ruby System Library";
+ }
+
+ public ILoadpathEntry[] getLoadpathEntries() {
+ return getLoadpathEntries(fInterpreter);
+ }
+
+ /**
+ * Returns the loadpath entries associated with the given VM.
+ *
+ * @param vm
+ * @return loadpath entries
+ */
+ private static ILoadpathEntry[] getLoadpathEntries(IInterpreter vm) {
+ if (fgLoadpathEntries == null) {
+ fgLoadpathEntries = new HashMap(10);
+ // add a listener to clear cached value when a VM changes or is removed
+ IInterpreterInstallChangedListener listener = new IInterpreterInstallChangedListener() {
+ public void defaultInterpreterInstallChanged(IInterpreter previous, IInterpreter current) {
+ }
+
+ public void interpreterChanged(PropertyChangeEvent event) {
+ if (event.getSource() != null) {
+ fgLoadpathEntries.remove(event.getSource());
+ }
+ }
+
+ public void interpreterAdded(IInterpreter newVm) {
+ }
+
+ public void interpreterRemoved(IInterpreter removedVm) {
+ fgLoadpathEntries.remove(removedVm);
+ }
+ };
+ RubyRuntime.addInterpreterInstallChangedListener(listener);
+ }
+ ILoadpathEntry[] entries = (ILoadpathEntry[])fgLoadpathEntries.get(vm);
+ if (entries == null) {
+ entries = computeLoadpathEntries(vm);
+ fgLoadpathEntries.put(vm, entries);
+ }
+ return entries;
+ }
+
+ /**
+ * Computes the loadpath entries associated with a VM - one entry per library.
+ *
+ * @param vm
+ * @return loadpath entries
+ */
+ private static ILoadpathEntry[] computeLoadpathEntries(IInterpreter vm) {
+ IPath[] libs = vm.getLibraryLocations();
+ List entries = new ArrayList(libs.length);
+ for (int i = 0; i < libs.length; i++) {
+ entries.add(RubyCore.newLibraryEntry(libs[i], false));
+ }
+ return (ILoadpathEntry[])entries.toArray(new ILoadpathEntry[entries.size()]);
+ }
+
+ /**
+ * @see ILoadpathContainer#getKind()
+ */
+ public int getKind() {
+ return ILoadpathContainer.K_DEFAULT_SYSTEM;
+ }
+
+ /**
+ * @see ILoadpathContainer#getPath()
+ */
+ public IPath getPath() {
+ return fPath;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|