You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-01-15 15:37:04
|
Revision: 1772
http://svn.sourceforge.net/rubyeclipse/?rev=1772&view=rev
Author: cawilliams
Date: 2007-01-15 07:36:59 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
fix broken test
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java 2007-01-15 15:29:21 UTC (rev 1771)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java 2007-01-15 15:36:59 UTC (rev 1772)
@@ -7,7 +7,6 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
public class TC_RubyProject extends ModifyingResourceTest {
@@ -76,10 +75,13 @@
}
/**
- * Test that a ruby script
- * has a corresponding resource.
+ * Test that a ruby script has a corresponding resource.
+ * @throws CoreException
*/
- public void testRubyScriptCorrespondingResource() throws RubyModelException {
+ public void testRubyScriptCorrespondingResource() throws CoreException {
+ addRubyNature("RubyProjectTests");
+ createFolder("RubyProjectTests/q");
+ createFile("RubyProjectTests/q/A.rb", "");
IRubyScript element= getRubyScript("RubyProjectTests", "", "q", "A.rb");
IResource corr= element.getCorrespondingResource();
IResource res= getWorkspace().getRoot().getProject("RubyProjectTests").getFolder("q").getFile("A.rb");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 15:29:23
|
Revision: 1771
http://svn.sourceforge.net/rubyeclipse/?rev=1771&view=rev
Author: cawilliams
Date: 2007-01-15 07:29:21 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
fix broken test
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-01-15 15:20:55 UTC (rev 1770)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-01-15 15:29:21 UTC (rev 1771)
@@ -38,7 +38,7 @@
protected abstract List<IFile> getFilesToCompile();
protected abstract void analyzeFiles() throws CoreException;
- protected static List compilers(MarkerManager markerManager) {
+ protected static List<SingleFileCompiler> singleFileCompilers(MarkerManager markerManager) {
return ListUtil.create(new RubyCodeAnalyzer(markerManager),
new TaskCompiler(markerManager));
}
@@ -46,21 +46,25 @@
public void compile(IProgressMonitor monitor) throws CoreException {
analyzeFiles();
List<IFile> files = getFilesToCompile();
- int fileCount = files.size();
- monitor.beginTask("Building "+project.getName() + "...", fileCount * (singleFileCompilers.size() + multiFileCompilers.size() + 2));
+ int filesToClear = getFilesToClear().size();
+ int taskCount = (filesToClear * 2) + (files.size() * (singleFileCompilers.size() + multiFileCompilers.size()));
+
+ monitor.beginTask("Building "+project.getName() + "...", taskCount);
monitor.subTask("Removing Markers...");
removeMarkers(markerManager);
- monitor.worked(fileCount);
+ monitor.worked(filesToClear);
monitor.subTask("Removing Search Indices...");
flushIndexEntries(symbolIndex);
- monitor.worked(fileCount);
+ monitor.worked(filesToClear);
compileFiles(files, monitor);
monitor.done();
}
- private void compileFiles(List<IFile> list, IProgressMonitor monitor) throws CoreException {
+ protected abstract List getFilesToClear();
+
+ private void compileFiles(List<IFile> list, IProgressMonitor monitor) throws CoreException {
for (MultipleFileCompiler compiler : multiFileCompilers) {
if (monitor.isCanceled())
return;
@@ -76,8 +80,8 @@
}
private void compileFile(IFile file, IProgressMonitor monitor) throws CoreException {
- for (Iterator cIter = singleFileCompilers.iterator(); cIter.hasNext();) {
- SingleFileCompiler fileCompiler = (SingleFileCompiler) cIter.next();
+ for (Iterator<SingleFileCompiler> cIter = singleFileCompilers.iterator(); cIter.hasNext();) {
+ SingleFileCompiler fileCompiler = cIter.next();
fileCompiler.compileFile(file);
monitor.worked(1);
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java 2007-01-15 15:20:55 UTC (rev 1770)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java 2007-01-15 15:29:21 UTC (rev 1771)
@@ -22,7 +22,7 @@
private CleanRdtCompiler(IProject project, SymbolIndex symbolIndex,
MarkerManager markerManager) {
- this(project,symbolIndex, markerManager, compilers(markerManager));
+ this(project,symbolIndex, markerManager, singleFileCompilers(markerManager));
}
protected void flushIndexEntries(SymbolIndex symbolIndex) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java 2007-01-15 15:20:55 UTC (rev 1770)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java 2007-01-15 15:29:21 UTC (rev 1771)
@@ -20,7 +20,7 @@
private final IResourceDelta rootDelta;
public IncrementalRdtCompiler(IProject project, IResourceDelta delta,
- SymbolIndex symbolIndex, IMarkerManager markerManager, List singleCompilers) {
+ SymbolIndex symbolIndex, IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers) {
super(project, symbolIndex, markerManager, singleCompilers);
this.rootDelta = delta;
}
@@ -32,7 +32,7 @@
private IncrementalRdtCompiler(IProject project, IResourceDelta delta,
SymbolIndex symbolIndex, MarkerManager manager) {
- this(project, delta, symbolIndex, manager, compilers(manager));
+ this(project, delta, symbolIndex, manager, singleFileCompilers(manager));
}
protected void removeMarkers(IMarkerManager markerManager) {
@@ -77,4 +77,9 @@
filesToClear.addAll(filesToCompile);
}
+ @Override
+ protected List getFilesToClear() {
+ return filesToClear;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java 2007-01-15 15:20:55 UTC (rev 1770)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java 2007-01-15 15:29:21 UTC (rev 1771)
@@ -25,7 +25,7 @@
monitor.assertTaskBegun("Building test...", 2);
monitor.assertDone(2);
- List subTasks = ListUtil.create(REMOVING_MARKERS_SUB_TASK);
+ List subTasks = ListUtil.create(REMOVING_MARKERS_SUB_TASK, REMOVING_INDICES_SUB_TASK);
monitor.assertSubTasks(subTasks);
assertMarkersRemoved(ListUtil.create(t1));
assertIndexFlushed(ListUtil.create(t1));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 15:20:56
|
Revision: 1770
http://svn.sourceforge.net/rubyeclipse/?rev=1770&view=rev
Author: cawilliams
Date: 2007-01-15 07:20:55 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
small changes to help tests (but many are still failing - I can't get the ShamLaunchConfigurationDelegate hooked up into the process to count the launches!)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui.tests/plugin.xml
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/plugin.xml 2007-01-15 15:20:00 UTC (rev 1769)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/plugin.xml 2007-01-15 15:20:55 UTC (rev 1770)
@@ -33,6 +33,7 @@
<import plugin="org.rubypeople.rdt.debug.core"/>
<import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.ui.console"/>
+ <import plugin="org.rubypeople.rdt.core.tests"/>
</requires>
<extension
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-01-15 15:20:00 UTC (rev 1769)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-01-15 15:20:55 UTC (rev 1770)
@@ -1,17 +1,12 @@
package org.rubypeople.rdt.internal.debug.ui.launcher;
-import java.io.ByteArrayInputStream;
import java.io.File;
import java.util.Arrays;
import junit.framework.Assert;
-import junit.framework.TestCase;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IFolder;
-import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationType;
@@ -23,6 +18,7 @@
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
+import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator;
import org.rubypeople.rdt.internal.launching.RubyInterpreter;
@@ -31,7 +27,7 @@
import org.rubypeople.rdt.launching.IInterpreter;
import org.rubypeople.rdt.ui.IRubyConstants;
-public class TC_RubyApplicationShortcut extends TestCase {
+public class TC_RubyApplicationShortcut extends ModifyingResourceTest {
protected ShamRubyApplicationShortcut shortcut;
protected IFile rubyFile, nonRubyFile;
@@ -41,54 +37,36 @@
super(name);
}
- protected IProject getOrCreateProject(String pName) throws CoreException {
- IProject p = RdtDebugUiPlugin.getWorkspace().getRoot().getProject(pName);
- if (!p.exists()) {
- p.create(null);
- p.open(null);
+ protected ILaunchConfiguration createConfiguration(IFile pFile) {
+ ILaunchConfiguration config = null;
+ try {
+ ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(SHAM_LAUNCH_CONFIG_TYPE);
+ ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, pFile.getName());
+ wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, pFile.getProject().getName());
+ wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, pFile.getProjectRelativePath().toString());
+ wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
+ wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getDefault().getSelectedInterpreter().getName());
+ wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator");
+ config = wc.doSave();
+ } catch (CoreException ce) {
+ //ignore
}
- return p;
+ return config;
}
- protected IFile getOrCreateFile(String pName) throws CoreException {
- IFile f = RdtDebugUiPlugin.getWorkspace().getRoot().getFile(new Path(pName));
- if (!f.exists()) {
- f.create(new ByteArrayInputStream(new byte[0]), true, null);
- }
- return f;
- }
-
- protected IFolder getOrCreateDir(String pName) throws CoreException {
- IFolder f = RdtDebugUiPlugin.getWorkspace().getRoot().getFolder(new Path(pName));
- if (!f.exists()) {
- f.create(true, true, null);
- }
- return f;
- }
-
- protected void createLaunchConfiguration(String pName, IFile pFile) throws Exception {
- ILaunchConfigurationType configType = DebugPlugin.getDefault().getLaunchManager().getLaunchConfigurationType(SHAM_LAUNCH_CONFIG_TYPE);
- ILaunchConfigurationWorkingCopy wc = configType.newInstance(null, pName);
- wc.setAttribute(RubyLaunchConfigurationAttribute.PROJECT_NAME, pFile.getProject().getName());
- wc.setAttribute(RubyLaunchConfigurationAttribute.FILE_NAME, pFile.getProjectRelativePath().toString());
- wc.setAttribute(RubyLaunchConfigurationAttribute.WORKING_DIRECTORY, "");
- wc.setAttribute(RubyLaunchConfigurationAttribute.SELECTED_INTERPRETER, RubyRuntime.getDefault().getSelectedInterpreter().getName());
- wc.setAttribute(ILaunchConfiguration.ATTR_SOURCE_LOCATOR_ID, "org.rubypeople.rdt.debug.ui.rubySourceLocator");
- wc.doSave();
- }
-
protected ILaunchConfiguration[] getLaunchConfigurations() throws CoreException {
ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
return launchManager.getLaunchConfigurations(launchManager.getLaunchConfigurationType(SHAM_LAUNCH_CONFIG_TYPE));
}
- protected void setUp() throws CoreException {
+ protected void setUp() throws Exception {
shortcut = new ShamRubyApplicationShortcut();
- this.getOrCreateProject("/project1");
- this.getOrCreateDir("/project1/folderOne");
- nonRubyFile = this.getOrCreateFile("/project1/folderOne/myFile.java");
- rubyFile = this.getOrCreateFile("/project1/folderOne/myFile.rb");
+// createProject("project1");
+ createRubyProject("project1");
+ createFolder("project1/folderOne");
+ nonRubyFile = createFile("project1/folderOne/myFile.java", "");
+ rubyFile = createFile("project1/folderOne/myFile.rb", "");
ILaunchConfiguration[] configs = this.getLaunchConfigurations();
for (int i = 0; i < configs.length; i++) {
@@ -99,8 +77,15 @@
ShamApplicationLaunchConfigurationDelegate.resetLaunches();
IInterpreter interpreterOne = new RubyInterpreter("InterpreterOne", new File("C:/RubyInstallRootOne"));
RubyRuntime.getDefault().setInstalledInterpreters(Arrays.asList(new IInterpreter[] { interpreterOne}));
-
+
+ super.setUp();
}
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ deleteProject("project1");
+ }
public void testNoInterpreterInstalled() throws Exception {
@@ -109,14 +94,13 @@
shortcut.launch(selection, ILaunchManager.RUN_MODE);
assertTrue("A dialog has been shown.", shortcut.didShowDialog);
-
}
public void testLaunchWithSelectedRubyFile() throws Exception {
ISelection selection = new StructuredSelection(rubyFile);
shortcut.launch(selection, ILaunchManager.RUN_MODE);
-
+
assertEquals("A configuration has been created", 1, this.getLaunchConfigurations().length);
assertEquals("A launch took place.", 1, ShamApplicationLaunchConfigurationDelegate.getLaunches());
assertTrue("The shortcut should not log a message when asked to launch the correct file type.", !shortcut.didLog());
@@ -134,8 +118,8 @@
public void testLaunchWithSelectionMultipleConfigurationsExist() throws Exception {
shortcut.expectException();
- this.createLaunchConfiguration("id1", rubyFile);
- this.createLaunchConfiguration("id2", rubyFile);
+ this.createConfiguration(rubyFile);
+ this.createConfiguration(rubyFile);
ISelection selection = new StructuredSelection(rubyFile);
shortcut.launch(selection, ILaunchManager.RUN_MODE);
@@ -147,7 +131,7 @@
}
public void testLaunchWithSelectionMultipleSelections() throws Exception {
- ISelection selection = new StructuredSelection(new Object[] { rubyFile, this.getOrCreateFile("project1/folderOne/yourFile.rb")});
+ ISelection selection = new StructuredSelection(new Object[] { rubyFile, createFile("project1/folderOne/yourFile.rb", "")});
shortcut.launch(selection, ILaunchManager.RUN_MODE);
ILaunchConfiguration[] configurations = this.getLaunchConfigurations();
assertEquals("A configuration has been created", 1, configurations.length);
@@ -168,7 +152,7 @@
}
public void testLaunchWithSelectionWhenFileNamesSameInDifferentDirectory() throws Exception {
- IFile anotherRubyFileWithSameNameInDifferentFolder = this.getOrCreateFile("project1/myFile.rb");
+ IFile anotherRubyFileWithSameNameInDifferentFolder = createFile("project1/myFile.rb", "");
ISelection selection = new StructuredSelection(rubyFile);
shortcut.launch(selection, ILaunchManager.RUN_MODE);
@@ -183,8 +167,7 @@
}
public void testLaunchFromEditorWithRubyFile() throws Exception {
-
- IFile file = this.getOrCreateFile("/project1/test.rb");
+ IFile file = createFile("project1/test.rb", "");
RubySourceLocator sourceLocator = new RubySourceLocator();
String fullPath = RdtDebugUiPlugin.getWorkspace().getRoot().getLocation().toOSString() + File.separator + file.getFullPath().toOSString();
Object sourceElement = sourceLocator.getSourceElement(fullPath);
@@ -199,8 +182,7 @@
}
public void testLaunchFromEditorWithTxtFile() throws Exception {
-
- IFile file = this.getOrCreateFile("/project1/test.txt");
+ IFile file = createFile("project1/test.txt", "");
IEditorInput input = new FileEditorInput(file);
IEditorPart txtEditor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(input, "org.eclipse.ui.DefaultTextEditor");
@@ -242,7 +224,7 @@
protected void log(Throwable t) {
if (!expectingException)
- throw new RuntimeException("Unexpected throwable", t);
+ throw new RuntimeException("Unexpected throwable: " + t.getMessage(), t);
didLog = true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 15:20:05
|
Revision: 1769
http://svn.sourceforge.net/rubyeclipse/?rev=1769&view=rev
Author: cawilliams
Date: 2007-01-15 07:20:00 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
use absolute path not toString to write file location
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java 2007-01-15 14:19:08 UTC (rev 1768)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java 2007-01-15 15:20:00 UTC (rev 1769)
@@ -245,7 +245,7 @@
writer.write("\" ");
writer.write(ATTR_PATH);
writer.write("=\"");
- writer.write(entry.getInstallLocation().toString());
+ writer.write(entry.getInstallLocation().getAbsolutePath());
writer.write("\"");
if (entry.equals(selectedInterpreter)) {
writer.write(" ");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 14:19:12
|
Revision: 1768
http://svn.sourceforge.net/rubyeclipse/?rev=1768&view=rev
Author: cawilliams
Date: 2007-01-15 06:19:08 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
fix broken tests
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_ResourceAdapterFactory.java
Modified: trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_ResourceAdapterFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_ResourceAdapterFactory.java 2007-01-15 13:49:34 UTC (rev 1767)
+++ trunk/org.rubypeople.rdt.ui.tests/src/org/rubypeople/rdt/internal/ui/TC_ResourceAdapterFactory.java 2007-01-15 14:19:08 UTC (rev 1768)
@@ -1,19 +1,20 @@
package org.rubypeople.rdt.internal.ui;
-import junit.framework.TestCase;
-
-import org.rubypeople.eclipse.shams.resources.ShamFile;
-import org.rubypeople.eclipse.shams.resources.ShamProject;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.core.RubyScript;
-public class TC_ResourceAdapterFactory extends TestCase {
+public class TC_ResourceAdapterFactory extends ModifyingResourceTest {
+ private static final String PROJECT_NAME = "adapterTest";
private ResourceAdapterFactory factory;
+ private IProject project;
public TC_ResourceAdapterFactory(String name) {
super(name);
@@ -21,24 +22,30 @@
protected void setUp() throws Exception {
super.setUp();
+ this.project = createProject(PROJECT_NAME);
factory = new ResourceAdapterFactory();
}
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ deleteProject(PROJECT_NAME);
+ }
- public void testGetAdapterForRBFile() {
- ShamFile file = new ShamFile("mustBeA.rb");
+ public void testGetAdapterForRBFile() throws CoreException {
+ IFile file = createFile(PROJECT_NAME + "/mustBeA.rb", "");
assertEquals(RubyScript.class, factory.getAdapter(file, IRubyElement.class).getClass());
assertTrue(factory.getAdapter(file, IRubyElement.class) instanceof IRubyScript);
}
- public void testGetAdapterForRBWFile() {
- ShamFile file = new ShamFile("mustBeA.rbw");
+ public void testGetAdapterForRBWFile() throws CoreException {
+ IFile file = createFile(PROJECT_NAME + "/mustBeA.rbw", "");
assertEquals(RubyScript.class, factory.getAdapter(file, IRubyElement.class).getClass());
assertTrue(factory.getAdapter(file, IRubyElement.class) instanceof IRubyScript);
}
- public void testGetAdapterForProject() {
- ShamProject project = new ShamProject("AProject");
- project.addNature(RubyCore.NATURE_ID);
+ public void testGetAdapterForProject() throws CoreException {
+ addRubyNature(PROJECT_NAME);
assertEquals(RubyProject.class, factory.getAdapter(project, IRubyElement.class).getClass());
assertTrue(factory.getAdapter(project, IRubyElement.class) instanceof IRubyProject);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 13:49:36
|
Revision: 1767
http://svn.sourceforge.net/rubyeclipse/?rev=1767&view=rev
Author: cawilliams
Date: 2007-01-15 05:49:34 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
fix unstranslated strings
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/FoldingConfigurationBlock.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/FoldingConfigurationBlock.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/FoldingConfigurationBlock.java 2007-01-15 13:44:21 UTC (rev 1766)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/FoldingConfigurationBlock.java 2007-01-15 13:49:34 UTC (rev 1767)
@@ -19,7 +19,15 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
-
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.SelectionEvent;
@@ -33,19 +41,8 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
-
-import org.eclipse.jface.viewers.ComboViewer;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-
-import org.eclipse.jface.text.Assert;
-import org.rubypeople.rdt.internal.ui.RubyUIMessages;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.RubyUIMessages;
import org.rubypeople.rdt.internal.ui.text.folding.RubyFoldingStructureProviderDescriptor;
import org.rubypeople.rdt.internal.ui.text.folding.RubyFoldingStructureProviderRegistry;
import org.rubypeople.rdt.internal.ui.util.PixelConverter;
@@ -160,7 +157,7 @@
/* check box for new editors */
fFoldingCheckbox= new Button(composite, SWT.CHECK);
- fFoldingCheckbox.setText(RubyUIMessages.getString("FoldingConfigurationBlock.enable")); //$NON-NLS-1$
+ fFoldingCheckbox.setText(PreferencesMessages.FoldingConfigurationBlock_enable);
gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
fFoldingCheckbox.setLayoutData(gd);
fFoldingCheckbox.addSelectionListener(new SelectionListener() {
@@ -188,7 +185,7 @@
Label comboLabel= new Label(comboComp, SWT.CENTER);
gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_CENTER);
comboLabel.setLayoutData(gd);
- comboLabel.setText(RubyUIMessages.getString("FoldingConfigurationBlock.combo_caption")); //$NON-NLS-1$
+ comboLabel.setText(PreferencesMessages.FoldingConfigurationBlock_combo_caption);
label= new Label(composite, SWT.CENTER);
gd= new GridData(GridData.FILL_HORIZONTAL | GridData.VERTICAL_ALIGN_BEGINNING);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-01-15 13:44:21 UTC (rev 1766)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.java 2007-01-15 13:49:34 UTC (rev 1767)
@@ -158,6 +158,8 @@
public static String ProjectSelectionDialog_title;
public static String ProjectSelectionDialog_desciption;
public static String ProjectSelectionDialog_filter;
+ public static String FoldingConfigurationBlock_enable;
+ public static String FoldingConfigurationBlock_combo_caption;
static {
NLS.initializeMessages(BUNDLE_NAME, PreferencesMessages.class);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-01-15 13:44:21 UTC (rev 1766)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/preferences/PreferencesMessages.properties 2007-01-15 13:49:34 UTC (rev 1767)
@@ -179,4 +179,7 @@
ProjectSelectionDialog_title=Project Specific Configuration
ProjectSelectionDialog_desciption=&Select the project to configure:
-ProjectSelectionDialog_filter=&Filter projects with no project specific settings
\ No newline at end of file
+ProjectSelectionDialog_filter=&Filter projects with no project specific settings
+
+FoldingConfigurationBlock_enable= Enable f&olding
+FoldingConfigurationBlock_combo_caption= Select folding to &use:
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 13:44:26
|
Revision: 1766
http://svn.sourceforge.net/rubyeclipse/?rev=1766&view=rev
Author: cawilliams
Date: 2007-01-15 05:44:21 -0800 (Mon, 15 Jan 2007)
Log Message:
-----------
add self, undef, defined? and also sort them so that we can insert them in order (and easily tell if we have duplicates)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/rubyeditor/RubyEditorPreferences.properties
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/rubyeditor/RubyEditorPreferences.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/rubyeditor/RubyEditorPreferences.properties 2007-01-15 03:00:47 UTC (rev 1765)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/rubyeditor/RubyEditorPreferences.properties 2007-01-15 13:44:21 UTC (rev 1766)
@@ -1 +1 @@
-keywords=BEGIN,END,alias,begin,do,end,yield,if,until,elsif,else,while,unless,for,in,super,retry,redo,break,case,when,throw,and,or,not,raise,rescue,ensure,new,each,def,class,module,return,false,true,nil,then,next
\ No newline at end of file
+keywords=BEGIN,END,alias,and,begin,break,case,class,def,defined?,do,each,else,elsif,end,ensure,false,for,if,in,module,new,next,nil,not,or,raise,redo,rescue,retry,return,self,super,then,throw,true,undef,unless,until,when,while,yield
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-15 03:00:48
|
Revision: 1765
http://svn.sourceforge.net/rubyeclipse/?rev=1765&view=rev
Author: cawilliams
Date: 2007-01-14 19:00:47 -0800 (Sun, 14 Jan 2007)
Log Message:
-----------
preliminary checkin of some in-progress work on hooking together loadpaths, interpreters and library containers
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterLabelProvider.java
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
trunk/org.rubypeople.rdt.launching/plugin.xml
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingMessages.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingPlugin.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IInterpreter.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyInterpreter.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RubyRuntime.java
trunk/org.rubypeople.rdt.launching.tests/src/org/rubypeople/rdt/internal/launching/TC_RunnerLaunching.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/CompositeId.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainer.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainerInitializer.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VMDefinitionsContainer.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/VMStandin.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/AbstractInterpreter.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/ExecutionArguments.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IInterpreter2.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IInterpreterInstallChangedListener.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IInterpreterInstallType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IRubyLaunchConfigurationConstants.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/PropertyChangeEvent.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -48,6 +48,7 @@
import org.rubypeople.rdt.internal.core.RubyModel;
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.RubyProject;
+import org.rubypeople.rdt.internal.core.SetLoadpathOperation;
import org.rubypeople.rdt.internal.core.SymbolIndexResourceChangeListener;
import org.rubypeople.rdt.internal.core.builder.IndexUpdater;
import org.rubypeople.rdt.internal.core.builder.MassIndexUpdaterJob;
@@ -1098,5 +1099,155 @@
}
return null;
}
+
+ public static void setLoadpathContainer(final IPath containerPath, IRubyProject[] affectedProjects, ILoadpathContainer[] respectiveContainers, IProgressMonitor monitor) throws RubyModelException {
+ if (affectedProjects.length != respectiveContainers.length) Assert.isTrue(false, "Projects and containers collections should have the same size"); //$NON-NLS-1$
+
+ if (monitor != null && monitor.isCanceled()) return;
+
+ if (RubyModelManager.CP_RESOLVE_VERBOSE){
+ Util.verbose(
+ "CPContainer SET - setting container\n" + //$NON-NLS-1$
+ " container path: " + containerPath + '\n' + //$NON-NLS-1$
+ " projects: {" +//$NON-NLS-1$
+ org.rubypeople.rdt.internal.compiler.util.Util.toString(
+ affectedProjects,
+ new org.rubypeople.rdt.internal.compiler.util.Util.Displayable(){
+ public String displayString(Object o) { return ((IRubyProject) o).getElementName(); }
+ }) +
+ "}\n values: {\n" +//$NON-NLS-1$
+ org.rubypeople.rdt.internal.compiler.util.Util.toString(
+ respectiveContainers,
+ new org.rubypeople.rdt.internal.compiler.util.Util.Displayable(){
+ public String displayString(Object o) {
+ StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$
+ if (o == null) {
+ buffer.append("<null>"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ ILoadpathContainer container = (ILoadpathContainer) o;
+ buffer.append(container.getDescription());
+ buffer.append(" {\n"); //$NON-NLS-1$
+ ILoadpathEntry[] entries = container.getLoadpathEntries();
+ if (entries != null){
+ for (int i = 0; i < entries.length; i++){
+ buffer.append(" "); //$NON-NLS-1$
+ buffer.append(entries[i]);
+ buffer.append('\n');
+ }
+ }
+ buffer.append(" }"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ }) +
+ "\n }\n invocation stack trace:"); //$NON-NLS-1$
+ new Exception("<Fake exception>").printStackTrace(System.out); //$NON-NLS-1$
+ }
+
+ RubyModelManager manager = RubyModelManager.getRubyModelManager();
+ if (manager.containerPutIfInitializingWithSameEntries(containerPath, affectedProjects, respectiveContainers))
+ return;
+
+ final int projectLength = affectedProjects.length;
+ final IRubyProject[] modifiedProjects;
+ System.arraycopy(affectedProjects, 0, modifiedProjects = new IRubyProject[projectLength], 0, projectLength);
+ final ILoadpathEntry[][] oldResolvedPaths = new ILoadpathEntry[projectLength][];
+
+ // filter out unmodified project containers
+ int remaining = 0;
+ for (int i = 0; i < projectLength; i++){
+
+ if (monitor != null && monitor.isCanceled()) return;
+
+ RubyProject affectedProject = (RubyProject) affectedProjects[i];
+ ILoadpathContainer newContainer = respectiveContainers[i];
+ if (newContainer == null) newContainer = RubyModelManager.CONTAINER_INITIALIZATION_IN_PROGRESS; // 30920 - prevent infinite loop
+ boolean found = false;
+ if (RubyProject.hasRubyNature(affectedProject.getProject())){
+ ILoadpathEntry[] rawClasspath = affectedProject.getRawLoadpath();
+ for (int j = 0, cpLength = rawClasspath.length; j <cpLength; j++) {
+ ILoadpathEntry entry = rawClasspath[j];
+ if (entry.getEntryKind() == ILoadpathEntry.CPE_CONTAINER && entry.getPath().equals(containerPath)){
+ found = true;
+ break;
+ }
+ }
+ }
+ if (!found){
+ modifiedProjects[i] = null; // filter out this project - does not reference the container path, or isnt't yet Java project
+ manager.containerPut(affectedProject, containerPath, newContainer);
+ continue;
+ }
+ ILoadpathContainer oldContainer = manager.containerGet(affectedProject, containerPath);
+ if (oldContainer == RubyModelManager.CONTAINER_INITIALIZATION_IN_PROGRESS) {
+ oldContainer = null;
+ }
+ if (oldContainer != null && oldContainer.equals(respectiveContainers[i])){
+ modifiedProjects[i] = null; // filter out this project - container did not change
+ continue;
+ }
+ remaining++;
+ oldResolvedPaths[i] = affectedProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ manager.containerPut(affectedProject, containerPath, newContainer);
+ }
+
+ if (remaining == 0) return;
+
+ // trigger model refresh
+ try {
+ final boolean canChangeResources = !ResourcesPlugin.getWorkspace().isTreeLocked();
+ RubyCore.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor progressMonitor) throws CoreException {
+ for(int i = 0; i < projectLength; i++){
+
+ if (progressMonitor != null && progressMonitor.isCanceled()) return;
+
+ RubyProject affectedProject = (RubyProject)modifiedProjects[i];
+ if (affectedProject == null) continue; // was filtered out
+
+ if (RubyModelManager.CP_RESOLVE_VERBOSE){
+ Util.verbose(
+ "CPContainer SET - updating affected project due to setting container\n" + //$NON-NLS-1$
+ " project: " + affectedProject.getElementName() + '\n' + //$NON-NLS-1$
+ " container path: " + containerPath); //$NON-NLS-1$
+ }
+
+ // force a refresh of the affected project (will compute deltas)
+ affectedProject.setRawLoadpath(
+ affectedProject.getRawLoadpath(),
+ SetLoadpathOperation.DO_NOT_SET_OUTPUT,
+ progressMonitor,
+ canChangeResources,
+ oldResolvedPaths[i],
+ false, // updating - no need for early validation
+ false); // updating - no need to save
+ }
+ }
+ },
+ null/*no need to lock anything*/,
+ monitor);
+ } catch(CoreException e) {
+ if (RubyModelManager.CP_RESOLVE_VERBOSE){
+ Util.verbose(
+ "CPContainer SET - FAILED DUE TO EXCEPTION\n" + //$NON-NLS-1$
+ " container path: " + containerPath, //$NON-NLS-1$
+ System.err);
+ e.printStackTrace();
+ }
+ if (e instanceof RubyModelException) {
+ throw (RubyModelException)e;
+ } else {
+ throw new RubyModelException(e);
+ }
+ } finally {
+ for (int i = 0; i < projectLength; i++) {
+ if (respectiveContainers[i] == null) {
+ manager.containerPut(affectedProjects[i], containerPath, null); // reset init in progress marker
+ }
+ }
+ }
+
+ }
+
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -7,6 +7,10 @@
public class Util {
+ public interface Displayable {
+ public String displayString(Object o);
+ }
+
private static final int DEFAULT_READING_SIZE = 8192;
public final static String UTF_8 = "UTF-8"; //$NON-NLS-1$
public static String LINE_SEPARATOR = System.getProperty("line.separator"); //$NON-NLS-1$
@@ -28,6 +32,19 @@
}
/**
+ * Converts an array of Objects into String.
+ */
+ public static String toString(Object[] objects, Displayable renderer) {
+ if (objects == null) return ""; //$NON-NLS-1$
+ StringBuffer buffer = new StringBuffer(10);
+ for (int i = 0; i < objects.length; i++){
+ if (i > 0) buffer.append(", "); //$NON-NLS-1$
+ buffer.append(renderer.displayString(objects[i]));
+ }
+ return buffer.toString();
+ }
+
+ /**
* Returns the given input stream's contents as a byte array. If a length is
* specified (ie. if length != -1), only length bytes are returned.
* Otherwise all bytes in the stream are returned. Note this doesn't close
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -1568,5 +1568,93 @@
}
}
}
+
+ /*
+ * Optimize startup case where a container for 1 project is initialized at a time with the same entries as on shutdown.
+ */
+ public boolean containerPutIfInitializingWithSameEntries(IPath containerPath, IRubyProject[] projects, ILoadpathContainer[] respectiveContainers) {
+ int projectLength = projects.length;
+ if (projectLength != 1)
+ return false;
+ final ILoadpathContainer container = respectiveContainers[0];
+ if (container == null)
+ return false;
+ IRubyProject project = projects[0];
+ if (!containerInitializationInProgress(project).contains(containerPath))
+ return false;
+ ILoadpathContainer previousSessionContainer = getPreviousSessionContainer(containerPath, project);
+ final ILoadpathEntry[] newEntries = container.getLoadpathEntries();
+ if (previousSessionContainer == null)
+ if (newEntries.length == 0) {
+ containerPut(project, containerPath, container);
+ return true;
+ } else {
+ return false;
+ }
+ final ILoadpathEntry[] oldEntries = previousSessionContainer.getLoadpathEntries();
+ if (oldEntries.length != newEntries.length)
+ return false;
+ for (int i = 0, length = newEntries.length; i < length; i++) {
+ if (!newEntries[i].equals(oldEntries[i])) {
+ if (CP_RESOLVE_VERBOSE) {
+ Util.verbose(
+ "CPContainer SET - missbehaving container\n" + //$NON-NLS-1$
+ " container path: " + containerPath + '\n' + //$NON-NLS-1$
+ " projects: {" +//$NON-NLS-1$
+ org.rubypeople.rdt.internal.compiler.util.Util.toString(
+ projects,
+ new org.rubypeople.rdt.internal.compiler.util.Util.Displayable(){
+ public String displayString(Object o) { return ((IRubyProject) o).getElementName(); }
+ }) +
+ "}\n values on previous session: {\n" +//$NON-NLS-1$
+ org.rubypeople.rdt.internal.compiler.util.Util.toString(
+ respectiveContainers,
+ new org.rubypeople.rdt.internal.compiler.util.Util.Displayable(){
+ public String displayString(Object o) {
+ StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$
+ if (o == null) {
+ buffer.append("<null>"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ buffer.append(container.getDescription());
+ buffer.append(" {\n"); //$NON-NLS-1$
+ for (int j = 0; j < oldEntries.length; j++){
+ buffer.append(" "); //$NON-NLS-1$
+ buffer.append(oldEntries[j]);
+ buffer.append('\n');
+ }
+ buffer.append(" }"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ }) +
+ "}\n new values: {\n" +//$NON-NLS-1$
+ org.rubypeople.rdt.internal.compiler.util.Util.toString(
+ respectiveContainers,
+ new org.rubypeople.rdt.internal.compiler.util.Util.Displayable(){
+ public String displayString(Object o) {
+ StringBuffer buffer = new StringBuffer(" "); //$NON-NLS-1$
+ if (o == null) {
+ buffer.append("<null>"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ buffer.append(container.getDescription());
+ buffer.append(" {\n"); //$NON-NLS-1$
+ for (int j = 0; j < newEntries.length; j++){
+ buffer.append(" "); //$NON-NLS-1$
+ buffer.append(newEntries[j]);
+ buffer.append('\n');
+ }
+ buffer.append(" }"); //$NON-NLS-1$
+ return buffer.toString();
+ }
+ }) +
+ "\n }"); //$NON-NLS-1$
+ }
+ return false;
+ }
+ }
+ containerPut(project, containerPath, container);
+ return true;
+ }
}
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_DebuggerLaunch.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -1,13 +1,13 @@
package org.rubypeople.rdt.debug.core.tests;
import java.io.ByteArrayInputStream;
+import java.io.File;
import junit.framework.TestCase;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -36,7 +36,7 @@
// to be set accordingly
String rubyInterpreterPath = FTC_ClassicDebuggerCommunicationTest.RUBY_INTERPRETER ;
System.out.println("Using interpreter: " + rubyInterpreterPath) ;
- IInterpreter rubyInterpreter = new RubyInterpreter("RubyInterpreter", new Path(rubyInterpreterPath));
+ IInterpreter rubyInterpreter = new RubyInterpreter("RubyInterpreter", new File(rubyInterpreterPath));
RubyRuntime.getDefault().addInstalledInterpreter(rubyInterpreter) ;
}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EditInterpreterDialog.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -2,9 +2,7 @@
import java.io.File;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
@@ -44,8 +42,8 @@
String interpreterName = interpreterToEdit.getName();
interpreterNameText.setText(interpreterName != null ? interpreterName : ""); //$NON-NLS-1$
- IPath installLocation = interpreterToEdit.getInstallLocation();
- interpreterLocationText.setText(installLocation != null ? installLocation.toOSString() : ""); //$NON-NLS-1$
+ File installLocation = interpreterToEdit.getInstallLocation();
+ interpreterLocationText.setText(installLocation != null ? installLocation.getAbsolutePath() : ""); //$NON-NLS-1$
}
protected void createLocationEntryField(Composite composite) {
@@ -145,7 +143,7 @@
interpreterToEdit = new RubyInterpreter(null, null);
interpreterToEdit.setName(interpreterNameText.getText());
- interpreterToEdit.setInstallLocation(new Path(interpreterLocationText.getText()));
+ interpreterToEdit.setInstallLocation(new File(interpreterLocationText.getText()));
super.okPressed();
}
protected Control createDialogArea(Composite parent) {
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterLabelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterLabelProvider.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/RubyInterpreterLabelProvider.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -1,6 +1,7 @@
package org.rubypeople.rdt.internal.debug.ui.preferences;
-import org.eclipse.core.runtime.IPath;
+import java.io.File;
+
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.swt.graphics.Image;
@@ -22,8 +23,8 @@
case 0 :
return interpreter.getName();
case 1 :
- IPath installLocation = interpreter.getInstallLocation();
- return installLocation != null ? installLocation.toOSString() : "In user path";
+ File installLocation = interpreter.getInstallLocation();
+ return installLocation != null ? installLocation.getAbsolutePath() : "In user path";
default :
return "Unknown Column Index";
}
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/launcher/TC_RubyApplicationShortcut.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -25,7 +25,6 @@
import org.eclipse.ui.part.FileEditorInput;
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator;
-import org.rubypeople.rdt.internal.debug.ui.launcher.RubyApplicationShortcut;
import org.rubypeople.rdt.internal.launching.RubyInterpreter;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
import org.rubypeople.rdt.internal.launching.RubyRuntime;
@@ -98,7 +97,7 @@
Assert.assertEquals("All configurations deleted.", 0, this.getLaunchConfigurations().length);
ShamApplicationLaunchConfigurationDelegate.resetLaunches();
- IInterpreter interpreterOne = new RubyInterpreter("InterpreterOne", new Path("C:/RubyInstallRootOne"));
+ IInterpreter interpreterOne = new RubyInterpreter("InterpreterOne", new File("C:/RubyInstallRootOne"));
RubyRuntime.getDefault().setInstalledInterpreters(Arrays.asList(new IInterpreter[] { interpreterOne}));
}
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-01-15 03:00:47 UTC (rev 1765)
@@ -19,6 +19,7 @@
<import plugin="org.rubypeople.rdt.core"/>
<import plugin="org.rubypeople.rdt.debug.core"/>
<import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.variables"/>
</requires>
<extension
@@ -30,5 +31,19 @@
id="org.rubypeople.rdt.launching.LaunchConfigurationTypeRubyApplication">
</launchConfigurationType>
</extension>
+ <extension
+ point="org.rubypeople.rdt.core.loadpathVariableInitializer">
+ <classpathVariableInitializer
+ variable="RUBY_LIB"
+ class="org.rubypeople.jdt.internal.launching.RubyLoadpathVariablesInitializer">
+ </classpathVariableInitializer>
+ </extension>
+ <extension
+ point="org.rubypeople.rdt.core.loadpathContainerInitializer">
+ <classpathContainerInitializer
+ class="org.rubypeople.rdt.internal.launching.RubyContainerInitializer"
+ id="org.rubypeople.rdt.launching.RUBY_CONTAINER">
+ </classpathContainerInitializer>
+ </extension>
</plugin>
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/CompositeId.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/CompositeId.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/CompositeId.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -0,0 +1,56 @@
+/*******************************************************************************
+ * 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 java.util.ArrayList;
+
+/**
+ * Utility class for id's made of multiple Strings
+ */
+public class CompositeId {
+ private String[] fParts;
+
+ public CompositeId(String[] parts) {
+ fParts= parts;
+ }
+
+ public static CompositeId fromString(String idString) {
+ ArrayList parts= new ArrayList();
+ int commaIndex= idString.indexOf(',');
+ while (commaIndex > 0) {
+ int length= Integer.valueOf(idString.substring(0, commaIndex)).intValue();
+ String part= idString.substring(commaIndex+1, commaIndex+1+length);
+ parts.add(part);
+ idString= idString.substring(commaIndex+1+length);
+ commaIndex= idString.indexOf(',');
+ }
+ String[] result= (String[])parts.toArray(new String[parts.size()]);
+ return new CompositeId(result);
+ }
+
+ public String toString() {
+ StringBuffer buf= new StringBuffer();
+ for (int i= 0; i < fParts.length; i++) {
+ buf.append(fParts[i].length());
+ buf.append(',');
+ buf.append(fParts[i]);
+ }
+ return buf.toString();
+ }
+
+ public String get(int index) {
+ return fParts[index];
+ }
+
+ public int getPartCount() {
+ return fParts.length;
+ }
+}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -6,6 +6,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IProcess;
@@ -85,9 +86,9 @@
protected IInterpreter convertInterpreter(IInterpreter rubyInterpreter) {
if (isUseRubyDebug()) {
- IPath rdebugLocation = rubyInterpreter.getInstallLocation().removeLastSegments(1);
+ IPath rdebugLocation = new Path(rubyInterpreter.getInstallLocation().getAbsolutePath()).removeLastSegments(1);
rdebugLocation = rdebugLocation.append("rdebug");
- return new RubyInterpreter("rdebug", rdebugLocation);
+ return new RubyInterpreter("rdebug", rdebugLocation.toFile());
} else {
return rubyInterpreter;
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingMessages.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingMessages.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -11,6 +11,18 @@
public static String RdtLaunchingPlugin_noInterpreterSelected;
public static String RdtLaunchingPlugin_interpreterNotFound;
public static String RdtLaunchingPlugin_noInterpreterSelectedTitle;
+ public static String RubyRuntime_badFormat;
+ public static String RubyRuntime_VM_type_element_with_unknown_id_1;
+ public static String RubyRuntime_VM_element_specified_with_no_id_attribute_2;
+ public static String RubyRuntime_exceptionOccurred;
+ public static String vmInstall_assert_typeNotNull;
+ public static String vmInstall_assert_idNotNull;
+ public static String AbstractInterpreterInstall_0;
+ public static String AbstractInterpreterInstall_1;
+ public static String AbstractInterpreterInstall_3;
+ public static String AbstractInterpreterInstall_4;
+ public static String LaunchingPlugin_33;
+ public static String LaunchingPlugin_34;
private RdtLaunchingMessages() {}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingPlugin.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RdtLaunchingPlugin.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -1,14 +1,30 @@
package org.rubypeople.rdt.internal.launching;
+import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.IOException;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.FactoryConfigurationError;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.transform.OutputKeys;
+import javax.xml.transform.Transformer;
+import javax.xml.transform.TransformerException;
+import javax.xml.transform.TransformerFactory;
+import javax.xml.transform.dom.DOMSource;
+import javax.xml.transform.stream.StreamResult;
+
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
import org.osgi.framework.BundleContext;
import org.rubypeople.rdt.core.RubyCore;
+import org.w3c.dom.Document;
+import org.xml.sax.helpers.DefaultHandler;
public class RdtLaunchingPlugin extends Plugin {
public static final String PLUGIN_ID = "org.rubypeople.rdt.launching"; //$NON-NLS-1$
@@ -22,6 +38,7 @@
return aPath;
}
protected static RdtLaunchingPlugin plugin;
+ private static DocumentBuilder fgXMLParser;
public RdtLaunchingPlugin() {
super();
@@ -54,4 +71,79 @@
super.stop(arg0);
savePluginPreferences() ;
}
+
+ public static String getUniqueIdentifier() {
+ return PLUGIN_ID;
+ }
+
+ /**
+ * Returns a Document that can be used to build a DOM tree
+ * @return the Document
+ * @throws ParserConfigurationException if an exception occurs creating the document builder
+ */
+ public static Document getDocument() throws ParserConfigurationException {
+ DocumentBuilderFactory dfactory= DocumentBuilderFactory.newInstance();
+ DocumentBuilder docBuilder= dfactory.newDocumentBuilder();
+ Document doc= docBuilder.newDocument();
+ return doc;
+ }
+
+ /**
+ * Serializes a XML document into a string - encoded in UTF8 format,
+ * with platform line separators.
+ *
+ * @param doc document to serialize
+ * @return the document as a string
+ */
+ public static String serializeDocument(Document doc) throws IOException, TransformerException {
+ ByteArrayOutputStream s= new ByteArrayOutputStream();
+
+ TransformerFactory factory= TransformerFactory.newInstance();
+ Transformer transformer= factory.newTransformer();
+ transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
+ transformer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
+
+ DOMSource source= new DOMSource(doc);
+ StreamResult outputTarget= new StreamResult(s);
+ transformer.transform(source, outputTarget);
+
+ return s.toString("UTF8"); //$NON-NLS-1$
+ }
+
+ public static void log(String message) {
+ log(new Status(IStatus.ERROR, getUniqueIdentifier(), IStatus.ERROR, message, null));
+ }
+
+ /**
+ * Returns a shared XML parser.
+ *
+ * @return an XML parser
+ * @throws CoreException if unable to create a parser
+ * @since 3.0
+ */
+ public static DocumentBuilder getParser() throws CoreException {
+ if (fgXMLParser == null) {
+ try {
+ fgXMLParser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ fgXMLParser.setErrorHandler(new DefaultHandler());
+ } catch (ParserConfigurationException e) {
+ abort(RdtLaunchingMessages.LaunchingPlugin_33, e);
+ } catch (FactoryConfigurationError e) {
+ abort(RdtLaunchingMessages.LaunchingPlugin_34, e);
+ }
+ }
+ return fgXMLParser;
+ }
+
+ /**
+ * 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 static void abort(String message, Throwable exception) throws CoreException {
+ IStatus status = new Status(IStatus.ERROR, RdtLaunchingPlugin.getUniqueIdentifier(), 0, message, exception);
+ throw new CoreException(status);
+ }
}
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainer.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainer.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainer.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -0,0 +1,85 @@
+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 RubyContainer implements ILoadpathContainer {
+
+ private static Map fgLoadpathEntries;
+ private IInterpreter fInterpreter;
+
+ public RubyContainer(IInterpreter interpreter, IPath containerPath) {
+ fInterpreter = interpreter;
+ }
+
+ 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()]);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainerInitializer.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainerInitializer.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyContainerInitializer.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -0,0 +1,73 @@
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.rubypeople.rdt.core.ILoadpathContainer;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.LoadpathContainerInitializer;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.launching.IInterpreter;
+import org.rubypeople.rdt.launching.IInterpreterInstallType;
+
+public class RubyContainerInitializer extends LoadpathContainerInitializer {
+
+ @Override
+ public void initialize(IPath containerPath, IRubyProject project)
+ throws CoreException {
+ int size = containerPath.segmentCount();
+ if (size > 0) {
+ if (containerPath.segment(0).equals(RubyRuntime.RUBY_CONTAINER)) {
+ IInterpreter vm = resolveInterpreter(containerPath);
+ RubyContainer container = null;
+ if (vm != null) {
+ container = new RubyContainer(vm, containerPath);
+ }
+ RubyCore.setLoadpathContainer(containerPath,
+ new IRubyProject[] { project },
+ new ILoadpathContainer[] { container }, null);
+ }
+ }
+
+ }
+
+ /**
+ * Returns the VM install associated with the container path, or
+ * <code>null</code> if it does not exist.
+ */
+ public static IInterpreter resolveInterpreter(IPath containerPath) {
+ IInterpreter vm = null;
+ if (containerPath.segmentCount() > 1) {
+ // specific Ruby VM
+ String vmTypeId = getInterpreterTypeId(containerPath);
+ String vmName = getInterpreterName(containerPath);
+ IInterpreterInstallType vmType = RubyRuntime
+ .getInterpreterInstallType(vmTypeId);
+ if (vmType != null) {
+ vm = vmType.findInterpreterInstallByName(vmName);
+ }
+ } else {
+ // workspace default Ruby VM
+ vm = RubyRuntime.getDefaultInterpreterInstall();
+ }
+ return vm;
+ }
+
+ /**
+ * Returns the VM type identifier from the given container ID path.
+ *
+ * @return the VM type identifier from the given container ID path
+ */
+ public static String getInterpreterTypeId(IPath path) {
+ return path.segment(1);
+ }
+
+ /**
+ * Returns the VM name from the given container ID path.
+ *
+ * @return the VM name from the given container ID path
+ */
+ public static String getInterpreterName(IPath path) {
+ return path.segment(2);
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyInterpreter.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -11,20 +11,22 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.rubypeople.rdt.launching.IInterpreter;
+import org.rubypeople.rdt.launching.IInterpreterInstallType;
+import org.rubypeople.rdt.launching.IVMRunner;
public class RubyInterpreter implements IInterpreter {
public static final String END_OF_OPTIONS_DELIMITER = "--";
- protected IPath installLocation;
+ protected File installLocation;
protected String name;
private final CommandExecutor commandExecutor;
- public RubyInterpreter(String aName, IPath validInstallLocation) {
+ public RubyInterpreter(String aName, File validInstallLocation) {
this(aName, validInstallLocation, new StandardCommandExecutor());
}
- public RubyInterpreter(String aName, IPath validInstallLocation, CommandExecutor commandExecutor) {
+ public RubyInterpreter(String aName, File validInstallLocation, CommandExecutor commandExecutor) {
name = aName;
installLocation = validInstallLocation;
this.commandExecutor = commandExecutor;
@@ -33,18 +35,11 @@
/* (non-Javadoc)
* @see org.rubypeople.rdt.internal.launching.IInterpreter#getInstallLocation()
*/
- public IPath getInstallLocation() {
+ public File getInstallLocation() {
return installLocation;
}
/* (non-Javadoc)
- * @see org.rubypeople.rdt.internal.launching.IInterpreter#setInstallLocation(org.eclipse.core.runtime.IPath)
- */
- public void setInstallLocation(IPath validInstallLocation) {
- installLocation = validInstallLocation;
- }
-
- /* (non-Javadoc)
* @see org.rubypeople.rdt.internal.launching.IInterpreter#getName()
*/
public String getName() {
@@ -59,8 +54,8 @@
}
public String getCommand() throws IllegalCommandException {
- if( new File(installLocation.toOSString()).isFile() ){
- return installLocation.toOSString();
+ if( installLocation.isFile() ){
+ return installLocation.getAbsolutePath();
}
String errorMessage = MessageFormat.format(RdtLaunchingMessages.RdtLaunchingPlugin_interpreterNotFound, new Object[] {this.getName()}) ;
throw new IllegalCommandException(errorMessage) ;
@@ -95,4 +90,43 @@
return false;
}
+
+ public String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String[] getInterpreterArguments() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IInterpreterInstallType getInterpreterInstallType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IVMRunner getInterpreterRunner(String mode) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public IPath[] getLibraryLocations() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setInstallLocation(File validInstallLocation) {
+ this.installLocation = validInstallLocation;
+ }
+
+ public void setInterpreterArguments(String[] vmArgs) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void setLibraryLocations(IPath[] paths) {
+ // TODO Auto-generated method stub
+
+ }
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java 2007-01-11 14:55:22 UTC (rev 1764)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyRuntime.java 2007-01-15 03:00:47 UTC (rev 1765)
@@ -1,7 +1,9 @@
package org.rubypeople.rdt.internal.launching;
import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.FileReader;
@@ -10,16 +12,33 @@
import java.io.OutputStreamWriter;
import java.io.Reader;
import java.io.Writer;
+import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;
+import javax.xml.transform.TransformerException;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Preferences;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.variables.VariablesPlugin;
import org.rubypeople.rdt.launching.IInterpreter;
+import org.rubypeople.rdt.launching.IInterpreterInstallChangedListener;
+import org.rubypeople.rdt.launching.IInterpreterInstallType;
+import org.rubypeople.rdt.launching.IRubyLaunchConfigurationConstants;
+import org.rubypeople.rdt.launching.PropertyChangeEvent;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
@@ -32,9 +51,56 @@
private static final String ATTR_PATH = "path";
private static final String ATTR_NAME = "name";
private static final String ATTR_SELECTED = "selected";
+
+ /**
+ * Loadpath container used for a project's Ruby
+ * (value <code>"org.rubypeople.rdt.launching.RUBY_CONTAINER"</code>). A
+ * container is resolved in the context of a specific Ruby project, to one
+ * or more system libraries contained in the Ruby std library. The container can have zero
+ * or two path segments following the container name. When no segments
+ * follow the container name, the workspace default Ruby is used to build a
+ * project. Otherwise the segments identify a specific Ruby used to build a
+ * project:
+ * <ol>
+ * <li>VM Install Type Identifier - identifies the type of Ruby VM used to build the
+ * project. For example, the standard VM.</li>
+ * <li>VM Install Name - a user defined name that identifies that a specific VM
+ * of the above kind. For example, <code>JRuby 1.8.4</code>. This information is
+ * shared in a projects loadpath file, so teams must agree on Ruby VM naming
+ * conventions.</li>
+ * </ol>
+ * @since 0.9.0
+ */
+ public static final String RUBY_CONTAINER = RdtLaunchingPlugin.getUniqueIdentifier() + "RUBY_CONTAINER"; //$NON-NLS-1$
+
+ /**
+ * Preference key for the String of XML that defines all installed VMs.
+ *
+ * @since 0.9.0
+ */
+ public static final String PREF_VM_XML = RdtLaunchingPlugin.getUniqueIdentifier() + ".PREF_VM_XML"; //$NON-NLS-1$
+ /**
+ * Simple identifier constant (value <code>"vmInstalls"</code>) for the
+ * VM installs extension point.
+ *
+ * @since 0.9.0
+ */
+ public static final String EXTENSION_POINT_VM_INSTALLS = "vmInstalls"; //$NON-NLS-1$
+
+ private static IInterpreterInstallType[] fgInterpreterTypes= null;
+
protected static RubyRuntime runtime;
+ private static Object fgVMLock = new Object();
+ private static boolean fgInitializingVMs;
+ private static String fgDefaultVMId;
+ private static String fgDefaultVMConnectorId;
+ /**
+ * Set of IDs of VMs contributed via vmInstalls extension point.
+ */
+ private static Set fgContributedVMs = new HashSet();
+
protected List<IInterpreter> installedInterpreters;
protected IInterpreter selectedInterpreter;
private List<Listener> listeners = new ArrayList<Listener>();
@@ -144,11 +210,11 @@
}
private void autoDetectRubyInterpreter() {
- IPath path = null;
+ File path = null;
if (Platform.getOS().equals(Platform.OS_WIN32)) {
- path = new Path("/ruby/bin/ruby.exe");
+ path = new File("/ruby/bin/ruby.exe");
} else {
- path = new Path("/usr/local/bin/ruby");
+ path = new File("/usr/local/bin/ruby");
}
IInterpreter interpreter = new RubyInterpreter("Default Ruby Interpreter", path);
installedInterpreters.add(interpreter);
@@ -206,7 +272,7 @@
public void startElement(String namespaceURI, String localName, String qName, Attributes atts) throws SAXException {
if (TAG_INTERPRETER.equals(qName)) {
String interpreterName = atts.getValue(ATTR_NAME);
- IPath installLocation = new Path(atts.getValue(ATTR_PATH));
+ File installLocation = new File(atts.getValue(ATTR_PATH));
IInterpreter interpreter = new RubyInterpreter(interpreterName, installLocation);
installedInterpreters.add(interpreter);
if (atts.getValue(ATTR_SELECTED) != null)
@@ -226,4 +292,368 @@
IPath fileLocation = stateLocation.append("runtimeConfiguration.xml");
return new File(fileLocation.toOSString());
}
+
+ public static void addInterpreterInstallChangedListener(IInterpreterInstallChangedListener listener) {
+ // TODO Implement and add to listeners, and replace the addListener(Listener) stuff
+
+ }
+ /**
+ * Returns the VM install type with the given unique id.
+ * @param id the VM install type unique id
+ * @return The VM install type for the given id, or <code>null</code> if no
+ * VM install type with the given id is registered.
+ */
+ public static IInterpreterInstallType getInterpreterInstallType(String id) {
+ IInterpreterInstallType[] vmTypes= getInterpreterInstallTypes();
+ for (int i= 0; i < vmTypes.length; i++) {
+ if (vmTypes[i].getId().equals(id)) {
+ return vmTypes[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the list of registered VM types. VM types are registered via
+ * <code>"org.rubypeople.rdt.launching.vmTypes"</code> extension point.
+ * Returns an empty list if there are no registered VM types.
+ *
+ * @return the list of registered VM types
+ */
+ public static IInterpreterInstallType[] getInterpreterInstallTypes() {
+ initializeInterpreters();
+ return fgInterpreterTypes;
+ }
+
+ public static IInterpreter getDefaultInterpreterInstall() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /**
+ * Perform VM type and VM install initialization. Does not hold locks
+ * while performing change notification.
+ *
+ * @since 3.2
+ */
+ private static void initializeInterpreters() {
+ VMDefinitionsContainer vmDefs = null;
+ boolean setPref = false;
+ boolean updateCompliance = false;
+ synchronized (fgVMLock) {
+ if (fgInterpreterTypes == null) {
+ try {
+ fgInitializingVMs = true;
+ // 1. load VM type extensions
+ initializeVMTypeExtensions();
+ try {
+ vmDefs = new VMDefinitionsContainer();
+ // 2. add persisted VMs
+ setPref = addPersistedVMs(vmDefs);
+
+ // 3. load contributed VM installs
+ addVMExtensions(vmDefs);
+ // 4. verify default VM is valid
+ String defId = vmDefs.getDefaultVMInstallCompositeID();
+ boolean validDef = false;
+ if (defId != null) {
+ Iterator iterator = vmDefs.getValidVMList().iterator();
+ while (iterator.hasNext()) {
+ IInterpreter vm = (IInterpreter) iterator.next();
+ if (getCompositeIdFromVM(vm).equals(defId)) {
+ validDef = true;
+ break;
+ }
+ }
+ }
+ if (!validDef) {
+ // use the first as the default
+ setPref = true;
+ List list = vmDefs.getValidVMList();
+ if (!list.isEmpty()) {
+ IInterpreter vm = (IInterpreter) list.get(0);
+ vmDefs.setDefaultVMInstallCompositeID(getCompositeIdFromVM(vm));
+ }
+ }
+ fgDefaultVMId = vmDefs.getDefaultVMInstallCompositeID();
+ fgDefaultVMConnectorId = vmDefs.getDefaultVMInstallConnectorTypeID();
+
+ // Create the underlying VMs for each valid VM
+ List vmList = vmDefs.getValidVMList();
+ Iterator vmListIterator = vmList.iterator();
+ while (vmListIterator.hasNext()) {
+ VMStandin vmStandin = (VMStandin) vmListIterator.next();
+ vmStandin.convertToRealVM();
+ }
+
+
+ } catch (IOException e) {
+ RdtLaunchingPlugin.log(e);
+ }
+ } finally {
+ fgInitializingVMs = false;
+ }
+ }
+ }
+ if (vmDefs != null) {
+ // notify of initial VMs for backwards compatibility
+ IInterpreterInstallType[] installTypes = getInterpreterInstallTypes();
+ for (int i = 0; i < installTypes.length; i++) {
+ IInterpreterInstallType type = installTypes[i];
+ IInterpreter[] installs = type.getInterpreterInstalls();
+ for (int j = 0; j < installs.length; j++) {
+ fireInterpreterAdded(installs[j]);
+ }
+ }
+
+ // save settings if required
+ if (setPref) {
+ try {
+ String xml = vmDefs.getAsXML();
+ RdtLaunchingPlugin.getDefault().getPluginPreferences().setValue(PREF_VM_XML, xml);
+ } catch (ParserConfigurationException e) {
+ RdtLaunchingPlugin.log(e);
+ } catch (IOException e) {
+ RdtLaunchingPlugin.log(e);
+ } catch (TransformerException e) {
+ RdtLaunchingPlugin.log(e);
+ }
+
+ }
+ }
+ }
+
+ /**
+ * Initializes vm type extensions.
+ */
+ private static void initializeVMTypeExtensions() {
+ IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(RdtLaunchingPlugin.PLUGIN_ID, "vmInstallTypes"); //$NON-NLS-1$
+ IConfigurationElement[] configs= extensionPoint.getConfigurationElements();
+ MultiStatus status= new MultiStatus(RdtLaunchingPlugin.getUniqueIdentifier(), IStatus.OK, RdtLaunchingMessages.RubyRuntime_exceptionOccurred, null);
+ fgInterpreterTypes= new IInterpreterInstallType[configs.length];
+
+ for (int i= 0; i < configs.length; i++) {
+ try {
+ IInterpreterInstallType vmType= (IInterpreterInstallType)configs[i].createExecutableExtension("class"); //$NON-NLS-1$
+ fgInterpreterTypes[i]= vmType;
+ } catch (CoreException e) {
+ status.add(e.getStatus());
+ }
+ }
+ if (!status.isOK()) {
+ //only happens on a CoreException
+ RdtLaunchingPlugin.log(status);
+ //cleanup null entries in fgVMTypes
+ List temp= new ArrayList(fgInterpreterTypes.length);
+ for (int i = 0; i < fgInterpreterTypes.length; i++) {
+ if(fgInterpreterTypes[i] != null) {
+ temp.add(fgInterpreterTypes[i]);
+ }
+ fgInterpreterTypes= new IInterpreterInstallType[temp.size()];
+ fgInterpreterTypes= (IInterpreterInstallType[])temp.toArray(fgInterpreterTypes);
+ }
+ }
+ }
+
+ /**
+ * This method loads installed JREs based an existing user preference
+ * or old vm configurations file. The VMs found in the preference
+ * or vm configurations file are added to the given VM definitions container.
+ *
+ * Returns whether the user preferences should be set - i.e. if it was
+ * not already set when initialized.
+ */
+ private static boolean addPersistedVMs(VMDefinitionsContainer vmDefs) throws IOException {
+ // Try retrieving the VM preferences from the preference store
+ String vmXMLString = getPreferences().getString(PREF_VM_XML);
+
+ // If the preference was found, load VMs from it into memory
+ if (vmXMLString.length() > 0) {
+ try {
+ ByteArrayInputStream inputStream = new ByteArrayInputStream(vmXMLString.getBytes());
+ VMDefinitionsContainer.parseXMLIntoContainer(inputStream, vmDefs);
+ return false;
+ } catch (IOException ioe) {
+ RdtLaunchingPlugin.log(ioe);
+ }
+ } else {
+ // Otherwise, look for the old file that previously held the VM definitions
+ IPath stateLocation= RdtLaunchingPlugin.getDefault().getStateLocation();
+ IPath stateFile= stateLocation.append("vmConfiguration.xml"); //$NON-NLS-1$
+ File file = new File(stateFile.toOSString());
+
+ if (file.exists()) {
+ // If file exists, load VM definitions from it into memory and write the definitions to
+ // the preference store WITHOUT triggering any processing of the new value
+ FileInputStream fileInputStream = new FileInputStream(file);
+ VMDefinitionsContainer.parseXMLIntoContainer(fileInputStream, vmDefs);
+ }
+ }
+ return true;
+ }
+
+ /**
+ * Returns the preference store for the launching plug-in.
+ *
+ * @return the preference store for the launching plug-in
+ * @since 0.9.0
+ */
+ public static Preferences getPreferences() {
+ return RdtLaunchingPlugin.getDefault().getPluginPreferences();
+ }
+
+ /**
+ * Returns a String that uniquely identifies the specified VM across all VM types.
+ *
+ * @param vm the instance of IVMInstallType to be identified
+ *
+ * @since 2.1
+ */
+ public static String getCompositeIdFromVM(IInterpreter vm) {
+ if (vm == null) {
+ return null;
+ }
+ IInterpreterInstallType vmType= vm.getInterpreterInstallType();
+ String typeID= vmType.getId();
+ CompositeId id= new CompositeId(new String[] { typeID, vm.getId() });
+ return id.toString();
+ }
+
+ /**
+ * Loads contributed VM installs
+ * @since 3.2
+ */
+ private static void addVMExtensions(VMDefinitionsContainer vmDefs) {
+ IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint(RdtLaunchingPlugin.PLUGIN_ID, RubyRuntime.EXTENSION_POINT_VM_INSTALLS);
+ IConfigurationElement[] configs= extensionPoint.getConfigurationElements();
+ for (int i = 0; i < configs.length; i++) {
+ IConfigurationElement element = configs[i];
+ try {
+ if ("vmInstall".equals(element.getName())) { //$NON-NLS-1$
+ String vmType = element.getAttribute("vmInstallType"); //$NON-NLS-1$
+ if (vmType == null) {
+ abort(MessageFormat.format("Missing required vmInstallType attribute for vmInstall contributed by {0}", //$NON-NLS-1$
+ new String[]{element.getContributor().getName()}), null);
+ }
+ String id = element.getAttribute("id"); //$NON-NLS-1$
+ if (id == null) {
+ abort(MessageFormat.format("Missing required id attribute for vmInstall contributed by {0}", //$NON-NLS-1$
+ new String[]{element.getContributor().getName()}), null);
+ }
+ IInterpreterInstallType installType = getInterpreterInstallType(vmType);
+ if (installType == null) {
+ abort(MessageFormat.format("vmInstall {0} contributed by {1} references undefined VM install type {2}", //$NON-NLS-1$
+ new String[]{id, element.getContributor().getName(), vmType}), null);
+ }
+ IInterpreter install = installType.findInterpreterInstall(id);
+ if (install == null) {
+ // only load/create if first time we've seen this VM install
+ String name = element.getAttribute("name"); //$NON-NLS-1$
+ if (name == null) {
+ abort(MessageFormat.format("vmInstall {0} contributed by {1} missing required attribute name", //$NON-NLS-1$
+ new String[]{id, element.getContributor().getName()}), null);
+ }
+ String home = element.getAttribute("home"); //$NON-NLS-1$
+ if (home == null) {
+ abort(MessageFormat.format("vmInstall {0} contributed by {1} missing required attribute home", //$NON-NLS-1$
+ new String[]{id, element.getContributor().getName()}), null);
+ }
+ String vmArgs = element.getAttribute("vmArgs"); //$NON-NLS-1$
+ VMStandin standin = new VMStandin(installType, id);
+ standin.setName(name);
+ home = substitute(home);
+ File homeDir = new File(home);
+ if (homeDir.exists()) {
+ try {
+ // adjust for relative path names
+ home = homeDir.getCanonicalPath();
+ homeDir = new File(home);
+ } catch (IOException e) {
+ }
+ }
+ IStatus status = installType.validateInstallLocation(homeDir);
+ if (!status.isOK()) {
+ abort(MessageFormat.format("Illegal install location {0} for vmInstall {1} contributed by {2}: {3}", //$NON-NLS-1$
+ new String[]{home, id, element.getContributor().getName(), status.getMessage()}), null);
+ }
+ standin.setInstallLocation(homeDir);
+ if (vmArgs != null) {
+ standin.setVMArgs(vmArgs);
+ }
+ IConfigurationElement[] libraries = element.getChildren("library"); //$NON-NLS-1$
+ IPath[] locations = null;
+ if (libraries.length > 0) {
+ locations = new IPath[libraries.length];
+ for (int j = 0; j < libraries.length; j++) {
+ IConfigurationElement library = libraries[j];
+ String libPathStr = library.getAttribute("path"); //$NON-NLS-1$
+ if (libPathStr == null) {
+ abort(MessageFormat.format("library for vmInstall {0} contributed by {1} missing required attribute libPath", //$NON-NLS-1$
+ new String[]{id, element.getContributor().getName()}), null);
+ }
+
+ IPath homePath = new Path(home);
+ IPath libPath = homePath.append(substitute(libPathStr));
+ locations[j] = libPath;
+ }
+ }
+ standin.setLibraryLocations(locations);
+ vmDefs.addVM(standin);
+ }
+ fgC...
[truncated message content] |
|
From: <caw...@us...> - 2007-01-11 14:55:24
|
Revision: 1764
http://svn.sourceforge.net/rubyeclipse/?rev=1764&view=rev
Author: cawilliams
Date: 2007-01-11 06:55:22 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
rename
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/icons/full/ctool16/module_obj.gif
Added: trunk/org.rubypeople.rdt.ui/icons/full/ctool16/module_obj.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.ui/icons/full/ctool16/module_obj.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-11 14:53:40
|
Revision: 1763
http://svn.sourceforge.net/rubyeclipse/?rev=1763&view=rev
Author: cawilliams
Date: 2007-01-11 06:53:39 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
rename
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/icons/full/ctool16/ruby_module.gif
Deleted: trunk/org.rubypeople.rdt.ui/icons/full/ctool16/ruby_module.gif
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-11 14:41:55
|
Revision: 1762
http://svn.sourceforge.net/rubyeclipse/?rev=1762&view=rev
Author: cawilliams
Date: 2007-01-11 06:41:53 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
try to fix some collateral damage from introducing the ISourceFolder stuff
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -99,8 +99,6 @@
*/
Map getOptions(boolean inheritRubyCoreOptions);
- public abstract IRubyScript[] getRubyScripts() throws RubyModelException;
-
public abstract Object[] getNonRubyResources() throws RubyModelException;
public abstract ISourceFolder[] getSourceFolders() throws RubyModelException;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/RubyElementRequestor.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -9,7 +9,6 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
@@ -63,13 +62,9 @@
try {
for (int x = 0; x < projects.length; x++) {
IRubyProject project = projects[x];
- IRubyScript[] scripts = project.getRubyScripts();
- for (int i = 0; i < scripts.length; i++) {
- IRubyScript script = scripts[i];
- IType type = findTypeInScript(typeName, script);
- if (type != null)
- return type;
- }
+ IType type = project.findType(typeName);
+ if (type != null)
+ return type;
}
} catch (RubyModelException e) {
// TODO Auto-generated catch block
@@ -77,17 +72,4 @@
}
return null;
}
-
- private IType findTypeInScript(String typeName, IRubyScript script)
- throws RubyModelException {
- IType[] types = script.getTypes();
- for (int j = 0; j < types.length; j++) {
- IType type = types[j];
- if (!type.getElementName().equals(typeName))
- continue;
- return type;
- }
- return null;
- }
-
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -52,7 +52,6 @@
import org.rubypeople.rdt.core.IRubyModelStatus;
import org.rubypeople.rdt.core.IRubyModelStatusConstants;
import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.IType;
@@ -796,25 +795,16 @@
return null;
}
- public void resetCaches() {
- // TODO Auto-generated method stub
- }
+ /*
+ * Resets this project's caches
+ */
+ public void resetCaches() {
+ RubyProjectElementInfo info = (RubyProjectElementInfo) RubyModelManager.getRubyModelManager().peekAtInfo(this);
+ if (info != null){
+ info.resetCaches();
+ }
+ }
- public IRubyScript[] getRubyScripts() throws RubyModelException {
- Object[] children;
- int length;
- IRubyScript[] scripts;
-
- System.arraycopy(
- children = getChildren(),
- 0,
- scripts = new IRubyScript[length = children.length],
- 0,
- length);
-
- return scripts;
- }
-
/**
* Returns an array of non-ruby resources contained in the receiver.
*/
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java 2007-01-11 14:17:59 UTC (rev 1761)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/browsing/RubyBrowsingContentProvider.java 2007-01-11 14:41:53 UTC (rev 1762)
@@ -23,6 +23,8 @@
import org.rubypeople.rdt.core.IRubyElementDelta;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.ISourceReference;
import org.rubypeople.rdt.core.IType;
import org.rubypeople.rdt.core.RubyCore;
@@ -63,25 +65,26 @@
startReadInDisplayThread();
try {
if (element instanceof Collection) {
- Collection elements = (Collection) element;
+ Collection elements= (Collection)element;
if (elements.isEmpty())
return NO_CHILDREN;
- Object[] result = new Object[0];
- Iterator iter = ((Collection) element).iterator();
+ Object[] result= new Object[0];
+ Iterator iter= ((Collection)element).iterator();
while (iter.hasNext()) {
- Object[] children = getChildren(iter.next());
+ Object[] children= getChildren(iter.next());
if (children != NO_CHILDREN)
- result = concatenate(result, children);
+ result= concatenate(result, children);
}
return result;
}
+ if (element instanceof ISourceFolder)
+ return getFolderContents((ISourceFolder)element);
if (fProvideMembers && element instanceof IType)
- return getChildren((IType) element);
- if (fProvideMembers && element instanceof ISourceReference
- && element instanceof IParent)
+ return getChildren((IType)element);
+ if (fProvideMembers && element instanceof ISourceReference && element instanceof IParent)
return super.getChildren(element);
if (element instanceof IRubyProject)
- return getRubyTypes((IRubyProject) element);
+ return getSourceFolderRoots((IRubyProject)element);
return super.getChildren(element);
} catch (RubyModelException e) {
return NO_CHILDREN;
@@ -90,6 +93,36 @@
}
}
+ private Object[] getFolderContents(ISourceFolder fragment) throws RubyModelException {
+ ISourceReference[] sourceRefs= fragment.getRubyScripts();
+ Object[] result= new Object[0];
+ for (int i= 0; i < sourceRefs.length; i++)
+ result= concatenate(result, getChildren(sourceRefs[i]));
+ return concatenate(result, fragment.getNonRubyResources());
+ }
+
+ protected Object[] getSourceFolderRoots(IRubyProject project) throws RubyModelException {
+ if (!project.getProject().isOpen())
+ return NO_CHILDREN;
+
+ ISourceFolderRoot[] roots= project.getSourceFolderRoots();
+ List list= new ArrayList(roots.length);
+ // filter out package fragments that correspond to projects and
+ // replace them with the package fragments directly
+ for (int i= 0; i < roots.length; i++) {
+ ISourceFolderRoot root= roots[i];
+ if (!root.isExternal()) {
+ Object[] children= root.getChildren();
+ for (int k= 0; k < children.length; k++)
+ list.add(children[k]);
+ }
+ else if (hasChildren(root)) {
+ list.add(root);
+ }
+ }
+ return concatenate(list.toArray(), project.getNonRubyResources());
+ }
+
private Object[] getChildren(IType type) throws RubyModelException{
IParent parent= type.getRubyScript();
@@ -106,28 +139,6 @@
return tempResult.toArray();
}
- private Object[] getRubyTypes(IRubyProject project)
- throws RubyModelException {
- Object[] scripts = getRubyScripts(project);
- List list = new ArrayList();
- for (int i = 0; i < scripts.length; i++) {
- IRubyScript script = (IRubyScript) scripts[i];
- Object[] types = script.getTypes();
- for (int j = 0; j < types.length; j++) {
- list.add(types[j]);
- }
- }
- return concatenate(list.toArray(), new Object[] {});
- }
-
- protected Object[] getRubyScripts(IRubyProject project)
- throws RubyModelException {
- if (!project.getProject().isOpen())
- return NO_CHILDREN;
-
- return project.getRubyScripts();
- }
-
private boolean isDisplayThread() {
Control ctrl = fViewer.getControl();
if (ctrl == null)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-11 14:18:04
|
Revision: 1761
http://svn.sourceforge.net/rubyeclipse/?rev=1761&view=rev
Author: cawilliams
Date: 2007-01-11 06:17:59 -0800 (Thu, 11 Jan 2007)
Log Message:
-----------
fix ticket #229 - some raw translation keys are being shown, rather than their text.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.properties
Modified: trunk/org.rubypeople.rdt.ui/plugin.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.properties 2007-01-11 02:05:29 UTC (rev 1760)
+++ trunk/org.rubypeople.rdt.ui/plugin.properties 2007-01-11 14:17:59 UTC (rev 1761)
@@ -33,7 +33,7 @@
viewCategoryName=Ruby
appearancePrefName=Appearance
-problemSeveritiesPageName=Errors/Warnings
+problemSeveritiesPrefName=Errors/Warnings
preferenceKeywords.general=Ruby resources call type hierarchy refactoring search
preferenceKeywords.appearance=Ruby appearance resources browsing
@@ -149,6 +149,8 @@
rubyEditorFontDefiniton.label= Ruby Editor Text Font
rubyEditorFontDefintion.description= The Ruby editor text font is used by Ruby editors.
+SurroundWithBeginRescueAction.label=Surround with begin/rescue Block
+
##########################################################################
# Rdoc Support
##########################################################################
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-11 02:05:30
|
Revision: 1760
http://svn.sourceforge.net/rubyeclipse/?rev=1760&view=rev
Author: cawilliams
Date: 2007-01-10 18:05:29 -0800 (Wed, 10 Jan 2007)
Log Message:
-----------
ignore bin directory
Property Changed:
----------------
trunk/org.rubypeople.rdt.testunit/
Property changes on: trunk/org.rubypeople.rdt.testunit
___________________________________________________________________
Name: svn:ignore
+ bin
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-07 01:01:51
|
Revision: 1759
http://svn.sourceforge.net/rubyeclipse/?rev=1759&view=rev
Author: cawilliams
Date: 2007-01-06 17:01:50 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
more test cleanup - forced me to be better about how I added the new Code DuplicationDetector. implements new MultipleFileCompiler interface (which should probably be implemented by the markermanager and index for handling the files)
Modified Paths:
--------------
trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamResource.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtTestCase.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java
Modified: trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamResource.java
===================================================================
--- trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamResource.java 2007-01-07 00:36:02 UTC (rev 1758)
+++ trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamResource.java 2007-01-07 01:01:50 UTC (rev 1759)
@@ -112,7 +112,7 @@
}
public IPath getLocation() {
- throw new RuntimeException("Need to implement on sham.");
+ return path;
}
public IMarker getMarker(long id) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-01-07 00:36:02 UTC (rev 1758)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-01-07 01:01:50 UTC (rev 1759)
@@ -1,20 +1,13 @@
package org.rubypeople.rdt.internal.core.builder;
-import java.io.IOException;
+import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.pmd.CPD;
-import org.rubypeople.rdt.internal.core.pmd.Match;
-import org.rubypeople.rdt.internal.core.pmd.PMD;
-import org.rubypeople.rdt.internal.core.pmd.TokenEntry;
import org.rubypeople.rdt.internal.core.symbols.SymbolIndex;
import org.rubypeople.rdt.internal.core.util.ListUtil;
@@ -23,15 +16,22 @@
protected final IProject project;
protected final IMarkerManager markerManager;
protected final SymbolIndex symbolIndex;
- protected final List compilers;
+ protected final List<SingleFileCompiler> singleFileCompilers;
+ protected final List<MultipleFileCompiler> multiFileCompilers;
public AbstractRdtCompiler(IProject project, SymbolIndex symbolIndex,
- IMarkerManager markerManager, List singleCompilers) {
+ IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers, List<MultipleFileCompiler> multiFileCompilers) {
this.project = project;
this.symbolIndex = symbolIndex;
this.markerManager = markerManager;
- this.compilers = singleCompilers;
+ this.singleFileCompilers = singleCompilers;
+ this.multiFileCompilers = multiFileCompilers;
}
+
+ public AbstractRdtCompiler(IProject project, SymbolIndex symbolIndex,
+ IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers) {
+ this(project, symbolIndex, markerManager, singleCompilers, new ArrayList<MultipleFileCompiler>());
+ }
protected abstract void removeMarkers(IMarkerManager markerManager);
protected abstract void flushIndexEntries(SymbolIndex symbolIndex);
@@ -47,7 +47,7 @@
analyzeFiles();
List<IFile> files = getFilesToCompile();
int fileCount = files.size();
- monitor.beginTask("Building "+project.getName() + "...", fileCount * (compilers.size() + 3));
+ monitor.beginTask("Building "+project.getName() + "...", fileCount * (singleFileCompilers.size() + multiFileCompilers.size() + 2));
monitor.subTask("Removing Markers...");
removeMarkers(markerManager);
@@ -55,53 +55,31 @@
monitor.subTask("Removing Search Indices...");
flushIndexEntries(symbolIndex);
monitor.worked(fileCount);
-
- // TODO Refactor out this stuff into a compiler, only visit files we've collected
- monitor.subTask("Finding duplicate code...");
- try {
- Iterator<Match> matches = CPD.findMatches(files);
- while (matches.hasNext()) {
- Match match = matches.next();
- addMarker(match);
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- monitor.worked(fileCount);
compileFiles(files, monitor);
monitor.done();
}
- private void addMarker(Match match) {
- StringBuffer message = new StringBuffer("Found a ");
- message.append(match.getLineCount()).append(" line (").append(match.getTokenCount()).append(" tokens) duplication");
- for (Iterator occurrences = match.iterator(); occurrences.hasNext();) {
- TokenEntry mark = (TokenEntry) occurrences.next();
- // FIXME Make TokenEntry hold an IFile pointer to source file?
- IFile file = RubyCore.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(mark.getTokenSrcID()));
- markerManager.addWarning(file, message.toString(), mark.getBeginLine(), mark.getStartOffset(), mark.getStartOffset() + match.getSourceCodeSlice().length());
- }
- }
-
- private void compileFiles(List list, IProgressMonitor monitor) throws CoreException {
- for (Iterator iter = list.iterator(); iter.hasNext();) {
- IFile file = (IFile) iter.next();
+ private void compileFiles(List<IFile> list, IProgressMonitor monitor) throws CoreException {
+ for (MultipleFileCompiler compiler : multiFileCompilers) {
+ if (monitor.isCanceled())
+ return;
+ compiler.compileFile(list, monitor);
+ }
+ for (IFile file : list) {
+ if (monitor.isCanceled())
+ return;
- if (monitor.isCanceled())
- break;
-
monitor.subTask(file.getFullPath().toString());
compileFile(file, monitor);
- }
+ }
}
private void compileFile(IFile file, IProgressMonitor monitor) throws CoreException {
- for (Iterator cIter = compilers.iterator(); cIter.hasNext();) {
+ for (Iterator cIter = singleFileCompilers.iterator(); cIter.hasNext();) {
SingleFileCompiler fileCompiler = (SingleFileCompiler) cIter.next();
fileCompiler.compileFile(file);
monitor.worked(1);
}
}
-
}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-01-07 01:01:50 UTC (rev 1759)
@@ -0,0 +1,49 @@
+package org.rubypeople.rdt.internal.core.builder;
+
+import java.io.IOException;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.pmd.CPD;
+import org.rubypeople.rdt.internal.core.pmd.Match;
+import org.rubypeople.rdt.internal.core.pmd.TokenEntry;
+
+public class CodeDuplicationDetector implements MultipleFileCompiler {
+
+ private IMarkerManager markerManager;
+
+ public CodeDuplicationDetector(IMarkerManager manager) {
+ this.markerManager = manager;
+ }
+
+ public void compileFile(List<IFile> files, IProgressMonitor monitor) throws CoreException {
+ monitor.subTask("Finding duplicate code...");
+ try {
+ Iterator<Match> matches = CPD.findMatches(files);
+ while (matches.hasNext()) {
+ Match match = matches.next();
+ addMarker(match);
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ monitor.worked(files.size());
+ }
+
+ private void addMarker(Match match) {
+ StringBuffer message = new StringBuffer("Found a ");
+ message.append(match.getLineCount()).append(" line (").append(match.getTokenCount()).append(" tokens) duplication");
+ for (Iterator occurrences = match.iterator(); occurrences.hasNext();) {
+ TokenEntry mark = (TokenEntry) occurrences.next();
+ // FIXME Make TokenEntry hold an IFile pointer to source file?
+ IFile file = RubyCore.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(mark.getTokenSrcID()));
+ markerManager.addWarning(file, message.toString(), mark.getBeginLine(), mark.getStartOffset(), mark.getStartOffset() + match.getSourceCodeSlice().length());
+ }
+ }
+
+}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java 2007-01-07 01:01:50 UTC (rev 1759)
@@ -0,0 +1,11 @@
+package org.rubypeople.rdt.internal.core.builder;
+
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface MultipleFileCompiler {
+ public void compileFile(List<IFile> file, IProgressMonitor monitor) throws CoreException;
+}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtTestCase.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtTestCase.java 2007-01-07 00:36:02 UTC (rev 1758)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtTestCase.java 2007-01-07 01:01:50 UTC (rev 1759)
@@ -15,7 +15,8 @@
import org.rubypeople.rdt.internal.core.util.ListUtil;
public abstract class AbstractRdtTestCase extends TestCase {
- static protected final String EXPECTED_TASK_NAME = "Removing Markers...";
+ static protected final String REMOVING_MARKERS_SUB_TASK = "Removing Markers...";
+ static protected final String REMOVING_INDICES_SUB_TASK = "Removing Search Indices...";
protected abstract void assertMarkersRemoved(List expectedFiles);
protected abstract void assertIndexFlushed(List expectedFiles);
@@ -69,7 +70,7 @@
compiler.compile(monitor);
- assertCompliationFor(ListUtil.create(), 2);
+ assertCompliationFor(ListUtil.create(), 0); // FIXME should be no work done for non-ruby file?
}
public void testCompileIncludesFolders() throws Exception {
@@ -88,12 +89,12 @@
setFiles(ListUtil.create(t1, t2));
compiler.compile(monitor);
-
- assertCompliationFor(ListUtil.create(t1, t2), 6);
+ int expectedWorkUnits = 8; // code analyzer, taskparser, index, markers for each file
+ assertCompliationFor(ListUtil.create(t1, t2), expectedWorkUnits);
}
public void testCancellation() throws Exception {
- monitor.cancelAfter(4);
+ monitor.cancelAfter(6);
project.addResource(t1);
project.addResource(t2);
setFiles(ListUtil.create(t1, t2));
@@ -101,9 +102,9 @@
compiler.compile(monitor);
List expectedFiles = ListUtil.create(t1);
- monitor.assertTaskBegun("Building test...", 6);
- monitor.assertDone(4);
- List subTasks = ListUtil.create(EXPECTED_TASK_NAME,
+ monitor.assertTaskBegun("Building test...", 8);
+ monitor.assertDone(6);
+ List subTasks = ListUtil.create(REMOVING_MARKERS_SUB_TASK, REMOVING_INDICES_SUB_TASK,
t1.getFullPath().toString());
monitor.assertSubTasks(subTasks);
assertMarkersRemoved(ListUtil.create(t1,t2));
@@ -129,7 +130,7 @@
protected void assertCompliationFor(List expectedFiles, int totalWork) {
monitor.assertTaskBegun("Building test...", totalWork);
monitor.assertDone(totalWork);
- List subTasks = ListUtil.create(EXPECTED_TASK_NAME);
+ List subTasks = ListUtil.create(REMOVING_MARKERS_SUB_TASK, REMOVING_INDICES_SUB_TASK);
for (Iterator iter = expectedFiles.iterator(); iter.hasNext();) {
IFile file = (IFile) iter.next();
subTasks.add(file.getFullPath().toString());
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java 2007-01-07 00:36:02 UTC (rev 1758)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java 2007-01-07 01:01:50 UTC (rev 1759)
@@ -25,7 +25,7 @@
monitor.assertTaskBegun("Building test...", 2);
monitor.assertDone(2);
- List subTasks = ListUtil.create(EXPECTED_TASK_NAME);
+ List subTasks = ListUtil.create(REMOVING_MARKERS_SUB_TASK);
monitor.assertSubTasks(subTasks);
assertMarkersRemoved(ListUtil.create(t1));
assertIndexFlushed(ListUtil.create(t1));
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-07 00:36:06
|
Revision: 1758
http://svn.sourceforge.net/rubyeclipse/?rev=1758&view=rev
Author: cawilliams
Date: 2007-01-06 16:36:02 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
start doing some test cleanup
Modified Paths:
--------------
trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFile.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/TS_Core.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyCore.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_MassIndexUpdater.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/model/
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/model/BufferTests.java
Modified: trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFile.java
===================================================================
--- trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFile.java 2007-01-06 21:40:11 UTC (rev 1757)
+++ trunk/org.rubypeople.eclipse.shams/src/org/rubypeople/eclipse/shams/resources/ShamFile.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -170,7 +170,7 @@
}
public boolean exists() {
- throw new RuntimeException("Unimplemented method in sham");
+ return true;
}
public IMarker findMarker(long id) throws CoreException {
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/TS_Core.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/TS_Core.java 2007-01-06 21:40:11 UTC (rev 1757)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/TS_Core.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -14,6 +14,7 @@
import junit.framework.Test;
import junit.framework.TestSuite;
+import org.rubypeople.rdt.core.tests.model.BufferTests;
import org.rubypeople.rdt.internal.core.TS_InternalCore;
import org.rubypeople.rdt.internal.core.builder.TS_InternalCoreBuilder;
import org.rubypeople.rdt.internal.core.parser.TS_InternalCoreParser;
@@ -31,7 +32,7 @@
suite.addTest(TS_InternalCore.suite());
suite.addTest(TS_InternalFormatter.suite());
suite.addTest(TS_Util.suite());
-
+ suite.addTestSuite(BufferTests.class);
return suite;
}
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java 2007-01-06 21:40:11 UTC (rev 1757)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -631,4 +631,48 @@
IProject project = getProject(name);
return RubyCore.create(project);
}
+
+ /*
+ * Asserts that the given actual source (usually coming from a file content) is equal to the expected one.
+ * Note that 'expected' is assumed to have the '\n' line separator.
+ * The line separators in 'actual' are converted to '\n' before the comparison.
+ */
+ protected void assertSourceEquals(String message, String expected, String actual) {
+ if (actual == null) {
+ assertEquals(message, expected, null);
+ return;
+ }
+ actual = org.rubypeople.rdt.core.tests.util.Util.convertToIndependantLineDelimiter(actual);
+ if (!actual.equals(expected)) {
+ System.out.print(org.rubypeople.rdt.core.tests.util.Util.displayString(actual.toString(), 2));
+ System.out.println(this.endChar);
+ }
+ assertEquals(message, expected, actual);
+ }
+
+ protected IFolder createFolder(IPath path) throws CoreException {
+ final IFolder folder = getWorkspaceRoot().getFolder(path);
+ getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ IContainer parent = folder.getParent();
+ if (parent instanceof IFolder && !parent.exists()) {
+ createFolder(parent.getFullPath());
+ }
+ folder.create(true, true, null);
+ }
+ },
+ null);
+
+ return folder;
+ }
+
+ protected IRubyScript getRubyScript(String path) {
+ return (IRubyScript)RubyCore.create(getFile(path));
+ }
+
+ public static void waitUntilIndexesReady() {
+
+ // TODO Find some way to wait until the indexes are ready from SymbolIndex/build process
+
+ }
}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java 2007-01-06 21:40:11 UTC (rev 1757)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -1,11 +1,14 @@
package org.rubypeople.rdt.core.tests;
import java.io.ByteArrayInputStream;
+import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.Path;
public class ModifyingResourceTest extends AbstractRubyModelTest {
@@ -19,4 +22,27 @@
file.setContents(input, IResource.FORCE, null);
return file;
}
+
+ protected IFolder createFolder(String path) throws CoreException {
+ return createFolder(new Path(path));
+ }
+
+ protected IFile createFile(String path, String content) throws CoreException {
+ return createFile(path, content.getBytes());
+ }
+
+ protected IFile createFile(String path, byte[] content) throws CoreException {
+ return createFile(path, new ByteArrayInputStream(content));
+ }
+
+ protected IFile createFile(String path, InputStream content) throws CoreException {
+ IFile file = getFile(path);
+ file.create(content, true, null);
+ try {
+ content.close();
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ return file;
+ }
}
Added: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/model/BufferTests.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/model/BufferTests.java (rev 0)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/model/BufferTests.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -0,0 +1,476 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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.core.tests.model;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.rubypeople.rdt.core.BufferChangedEvent;
+import org.rubypeople.rdt.core.IBuffer;
+import org.rubypeople.rdt.core.IBufferChangedListener;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
+
+public class BufferTests extends ModifyingResourceTest implements IBufferChangedListener {
+ protected ArrayList events = null;
+public BufferTests(String name) {
+ super(name);
+}
+/**
+ * Cache the event
+ */
+public void bufferChanged(BufferChangedEvent bufferChangedEvent) {
+ this.events.add(bufferChangedEvent);
+}
+protected IBuffer createBuffer(String path, String content) throws CoreException {
+ waitUntilIndexesReady(); // ensure that the indexer is not reading the file
+ this.createFile(path, content);
+ IRubyScript cu = this.getRubyScript(path);
+ IBuffer buffer = cu.getBuffer();
+ buffer.addBufferChangedListener(this);
+ this.events = new ArrayList();
+ return buffer;
+}
+protected void deleteBuffer(IBuffer buffer) throws CoreException {
+ buffer.removeBufferChangedListener(this);
+ IResource resource = buffer.getUnderlyingResource();
+ if (resource != null) {
+ deleteResource(resource);
+ }
+}
+
+@Override
+protected void setUp() throws Exception {
+ super.setUp();
+ try {
+ this.createRubyProject("P", new String[] {""});
+ this.createFolder("P/x/y");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+}
+
+@Override
+protected void tearDown() throws Exception {
+ super.tearDown();
+ this.deleteProject("P");
+}
+
+
+/**
+ * Tests appending to a buffer.
+ */
+public void testAppend() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ int oldLength= buffer.getLength();
+ buffer.append("\nclass B {}");
+ assertBufferEvent(oldLength, 0, "\nclass B {}");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}\n" +
+ "class B {}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+
+public void testClose() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ buffer.close();
+ assertBufferEvent(0, 0, null);
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+
+
+/**
+ * Tests getting the underlying resource of a buffer.
+ */
+public void testGetUnderlyingResource() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ IRubyScript copy = null;
+ try {
+ IFile file = this.getFile("P/x/y/A.rb");
+ assertEquals("Unexpected underlying resource", file, buffer.getUnderlyingResource());
+
+ copy = this.getRubyScript("P/x/y/A.rb").getWorkingCopy(null);
+ assertEquals("Unexpected underlying resource 2", file, copy.getBuffer().getUnderlyingResource());
+ } finally {
+ this.deleteBuffer(buffer);
+ if (copy != null) {
+ copy.discardWorkingCopy();
+ }
+ }
+}
+/**
+ * Tests deleting text at the beginning of a buffer.
+ */
+public void testDeleteBeginning() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ buffer.replace(0, 13, "");
+ assertBufferEvent(0, 13, null);
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "public class A {\n" +
+ "}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests deleting text in the middle of a buffer.
+ */
+public void testDeleteMiddle() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ // delete "public "
+ buffer.replace(13, 7, "");
+ assertBufferEvent(13, 7, null);
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n" +
+ "class A {\n" +
+ "}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests deleting text at the end of a buffer.
+ */
+public void testDeleteEnd() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ // delete "public class A {\n}"
+ buffer.replace(13, 18, "");
+ assertBufferEvent(13, 18, null);
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests the buffer char retrieval via source position
+ */
+public void testGetChar() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ assertEquals("Unexpected char at position 17", 'i', buffer.getChar(17));
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests the buffer char retrieval via source position doesn't throw an exception if the buffer is closed.
+ * (regression test for bug 46040 NPE in Eclipse console)
+ */
+public void testGetChar2() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ buffer.close();
+ try {
+ assertEquals("Unexpected char at position 17", Character.MIN_VALUE, buffer.getChar(17));
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests the buffer getLength()
+ */
+public void testGetLength() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ assertEquals("Unexpected length", 31, buffer.getLength());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests the buffer text retrieval via source position
+ */
+public void testGetText() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ assertSourceEquals("Unexpected text (1)", "p", buffer.getText(0, 1));
+ assertSourceEquals("Unexpected text (2)", "public", buffer.getText(13, 6));
+ assertSourceEquals("Unexpected text (3)", "", buffer.getText(10, 0));
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests inserting text at the beginning of a buffer.
+ */
+public void testInsertBeginning() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ buffer.replace(0, 0, "/* copyright mycompany */\n");
+ assertBufferEvent(0, 0, "/* copyright mycompany */\n");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "/* copyright mycompany */\n" +
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests replacing text at the beginning of a buffer.
+ */
+public void testReplaceBeginning() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ buffer.replace(0, 13, "package other;\n");
+ assertBufferEvent(0, 13, "package other;\n");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package other;\n" +
+ "public class A {\n" +
+ "}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests replacing text in the middle of a buffer.
+ */
+public void testReplaceMiddle() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ // replace "public class A" after the \n of package statement
+ buffer.replace(13, 14, "public class B");
+ assertBufferEvent(13, 14, "public class B");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n" +
+ "public class B {\n" +
+ "}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests replacing text at the end of a buffer.
+ */
+public void testReplaceEnd() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ // replace "}" at the end of cu with "}\n"
+ int end = buffer.getLength();
+ buffer.replace(end-1, 1, "}\n");
+ assertBufferEvent(end-1, 1, "}\n");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}\n",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests inserting text in the middle of a buffer.
+ */
+public void testInsertMiddle() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ // insert after the \n of package statement
+ buffer.replace(13, 0, "/* class comment */\n");
+ assertBufferEvent(13, 0, "/* class comment */\n");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n" +
+ "/* class comment */\n" +
+ "public class A {\n" +
+ "}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+/**
+ * Tests inserting text at the end of a buffer.
+ */
+public void testInsertEnd() throws CoreException {
+ IBuffer buffer = this.createBuffer(
+ "P/x/y/A.rb",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}"
+ );
+ try {
+ // insert after the \n of package statement
+ int end = buffer.getLength();
+ buffer.replace(end, 0, "\nclass B {}");
+ assertBufferEvent(end, 0, "\nclass B {}");
+ assertSourceEquals(
+ "unexpected buffer contents",
+ "package x.y;\n" +
+ "public class A {\n" +
+ "}\n" +
+ "class B {}",
+ buffer.getContents()
+ );
+ assertTrue("should have unsaved changes", buffer.hasUnsavedChanges());
+ } finally {
+ this.deleteBuffer(buffer);
+ }
+}
+
+/**
+ * Verify the buffer changed event.
+ * The given text must contain '\n' line separators.
+ */
+protected void assertBufferEvent(int offset, int length, String text) {
+ assertTrue("events should not be null", this.events != null);
+ assertTrue("events should not be empty", !this.events.isEmpty());
+ BufferChangedEvent event = (BufferChangedEvent) this.events.get(0);
+ assertEquals("unexpected offset", offset, event.getOffset());
+ assertEquals("unexpected length", length, event.getLength());
+ if (text == null) {
+ assertTrue("text should be null", event.getText() == null);
+ } else {
+ assertSourceEquals("unexpected text", text, event.getText());
+ }
+}
+
+protected void assertBufferEvents(String expected) {
+ StringBuffer buffer = new StringBuffer();
+ if (this.events == null)
+ buffer.append("<null>");
+ else {
+ for (int i = 0, length = this.events.size(); i < length; i++) {
+ BufferChangedEvent event = (BufferChangedEvent) this.events.get(i);
+ buffer.append('(');
+ buffer.append(event.getOffset());
+ buffer.append(", ");
+ buffer.append(event.getLength());
+ buffer.append(") ");
+ buffer.append(event.getText());
+ if (i < length-1)
+ buffer.append("\n");
+ }
+ }
+ assertSourceEquals("Unexpected buffer events", expected, buffer.toString());
+}
+}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyCore.java 2007-01-06 21:40:11 UTC (rev 1757)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyCore.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -1,33 +1,44 @@
package org.rubypeople.rdt.internal.core;
-import junit.framework.TestCase;
-
+import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
-import org.rubypeople.eclipse.shams.resources.ShamFile;
-import org.rubypeople.eclipse.shams.resources.ShamProject;
+import org.eclipse.core.runtime.CoreException;
import org.rubypeople.eclipse.testutils.ResourceTools;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
-public class TC_RubyCore extends TestCase {
+public class TC_RubyCore extends ModifyingResourceTest {
public TC_RubyCore(String name) {
super(name);
}
-
- public void testCreate() throws RubyModelException {
- ShamFile file = new ShamFile("some/folder/theFile.rb");
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ try {
+ this.createRubyProject("P", new String[] {""});
+ this.createFolder("P/x/y");
+ } catch (CoreException e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ this.deleteProject("P");
+ }
+
+ public void testCreate() throws CoreException {
+ IFile file = createFile("P/x/y/theFile.rb", "");
IRubyScript rubyFile = RubyCore.create(file);
assertNotNull("The core should create an IRubyScript when the resource is a file with .rb extension.", rubyFile);
assertEquals("The core should place the resource into the RubyFile.", file, rubyFile.getUnderlyingResource());
-
- file = new ShamFile("some/folder/theFile.xyz");
+
+ file = createFile("P/x/y/theFile.xyz", "");
assertNull("The core should not create a RubyFile when the resource is a file without the .rb extension.", RubyCore.create(file));
-
- ShamProject project = new ShamProject("aProject");
- project.addNature(RubyCore.NATURE_ID);
- assertNotNull("The core should create a RubyProject when the resource has the RubyProjectNature.", RubyCore.create(project));
}
public void testAddRubyNature() throws Exception {
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_MassIndexUpdater.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_MassIndexUpdater.java 2007-01-06 21:40:11 UTC (rev 1757)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_MassIndexUpdater.java 2007-01-07 00:36:02 UTC (rev 1758)
@@ -24,6 +24,7 @@
public class TC_MassIndexUpdater extends TestCase {
public void testUpdateProjects() throws Exception {
+ // What exactly does this test?
ShamRubyParser parser = new ShamRubyParser();
ShamIndexUpdater updater = new ShamIndexUpdater();
MassIndexUpdater massUpdater = new MassIndexUpdater(updater, parser);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-06 21:40:12
|
Revision: 1757
http://svn.sourceforge.net/rubyeclipse/?rev=1757&view=rev
Author: cawilliams
Date: 2007-01-06 13:40:11 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
add some more tests
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java 2007-01-06 21:23:21 UTC (rev 1756)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java 2007-01-06 21:40:11 UTC (rev 1757)
@@ -2,7 +2,9 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyModelException;
@@ -84,4 +86,56 @@
assertTrue("incorrect corresponding resource", corr.equals(res));
assertEquals("Project is incorrect for the ruby script", "RubyProjectTests", corr.getProject().getName());
}
+
+ /*
+ * Ensures that opening a project update the project references
+ * (regression test for bug 73253 [model] Project references not set on project open)
+ */
+ public void testProjectOpen() throws CoreException {
+ try {
+ createRubyProject("P1");
+ createRubyProject("P2", new String[0], new String[0], new String[] {"/P1"});
+ IProject p2 = getProject("P2");
+ p2.close(null);
+ p2.open(null);
+ IProject[] references = p2.getDescription().getDynamicReferences();
+ assertResourcesEqual(
+ "Unexpected referenced projects",
+ "/P1",
+ references);
+ } finally {
+ deleteProjects(new String[] {"P1", "P2"});
+ }
+ }
+
+ /*
+ * Ensures that importing a project correctly update the project references
+ * (regression test for bug 121569 [Import/Export] Importing projects in workspace, the default build order is alphabetical instead of by dependency)
+ */
+ public void testProjectImport() throws CoreException {
+ try {
+ createRubyProject("P1");
+ IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ createRubyProject("P2");
+ editFile(
+ "/P2/.loadpath",
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
+ "<loadpath>\n" +
+ " <pathentry type=\"src\" path=\"/P1\"/>\n" +
+ "</loadpath>"
+ );
+ }
+ };
+ getWorkspace().run(runnable, null);
+ waitForAutoBuild();
+ IProject[] referencedProjects = getProject("P2").getReferencedProjects();
+ assertResourcesEqual(
+ "Unexpected project references",
+ "/P1",
+ referencedProjects);
+ } finally {
+ deleteProjects(new String[] {"P1", "P2"});
+ }
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-06 21:23:22
|
Revision: 1756
http://svn.sourceforge.net/rubyeclipse/?rev=1756&view=rev
Author: cawilliams
Date: 2007-01-06 13:23:21 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
get test to pass for Rubyproject (adding Project Prerequisites), add new test for corresponding resource for script
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -131,4 +131,6 @@
void setRawLoadpath(ILoadpathEntry[] entries, IPath outputLocation, IProgressMonitor monitor)
throws RubyModelException;
+
+ public abstract ISourceFolderRoot getSourceFolderRoot(String rootPath);
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -14,25 +14,25 @@
import java.util.HashSet;
import java.util.Hashtable;
import java.util.Iterator;
+import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IProjectDescription;
import org.eclipse.core.resources.IResourceChangeEvent;
import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.ISafeRunnable;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.QualifiedName;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
-import org.eclipse.osgi.baseadaptor.loader.ClasspathEntry;
import org.rubypeople.rdt.core.IElementChangedListener;
import org.rubypeople.rdt.core.ILoadpathEntry;
+import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyModel;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.RubyCore;
@@ -183,7 +183,7 @@
public void handleException(Throwable exception) {
Util
.log(exception,
- "Exception occurred in listener of pre Java resource change notification"); //$NON-NLS-1$
+ "Exception occurred in listener of pre Ruby resource change notification"); //$NON-NLS-1$
}
public void run() throws Exception {
@@ -501,4 +501,43 @@
}
}
+
+ /*
+ * Update the roots that are affected by the addition or the removal of the given container resource.
+ */
+ public synchronized void updateRoots(IPath containerPath, IResourceDelta containerDelta, DeltaProcessor deltaProcessor) {
+ Map updatedRoots;
+ Map otherUpdatedRoots;
+ if (containerDelta.getKind() == IResourceDelta.REMOVED) {
+ updatedRoots = this.oldRoots;
+ otherUpdatedRoots = this.oldOtherRoots;
+ } else {
+ updatedRoots = this.roots;
+ otherUpdatedRoots = this.otherRoots;
+ }
+ Iterator iterator = updatedRoots.keySet().iterator();
+ while (iterator.hasNext()) {
+ IPath path = (IPath)iterator.next();
+ if (containerPath.isPrefixOf(path) && !containerPath.equals(path)) {
+ IResourceDelta rootDelta = containerDelta.findMember(path.removeFirstSegments(1));
+ if (rootDelta == null) continue;
+ DeltaProcessor.RootInfo rootInfo = (DeltaProcessor.RootInfo)updatedRoots.get(path);
+
+ if (!rootInfo.project.getPath().isPrefixOf(path)) { // only consider roots that are not included in the container
+ deltaProcessor.updateCurrentDeltaAndIndex(rootDelta, IRubyElement.SOURCE_FOLDER_ROOT, rootInfo);
+ }
+
+ ArrayList rootList = (ArrayList)otherUpdatedRoots.get(path);
+ if (rootList != null) {
+ Iterator otherProjects = rootList.iterator();
+ while (otherProjects.hasNext()) {
+ rootInfo = (DeltaProcessor.RootInfo)otherProjects.next();
+ if (!rootInfo.project.getPath().isPrefixOf(path)) { // only consider roots that are not included in the container
+ deltaProcessor.updateCurrentDeltaAndIndex(rootDelta, IRubyElement.SOURCE_FOLDER_ROOT, rootInfo);
+ }
+ }
+ }
+ }
+ }
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -15,6 +15,7 @@
import org.eclipse.core.resources.IResourceDelta;
import org.eclipse.core.resources.IResourceDeltaVisitor;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
@@ -23,6 +24,7 @@
import org.eclipse.core.runtime.SafeRunner;
import org.rubypeople.rdt.core.ElementChangedEvent;
import org.rubypeople.rdt.core.IElementChangedListener;
+import org.rubypeople.rdt.core.ILoadpathEntry;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyElementDelta;
import org.rubypeople.rdt.core.IRubyModel;
@@ -49,7 +51,7 @@
this.exclusionPatterns = exclusionPatterns;
this.entryKind = entryKind;
}
- ISourceFolderRoot getPackageFragmentRoot(IResource resource) {
+ ISourceFolderRoot getSourceFolderRoot(IResource resource) {
if (this.root == null) {
if (resource != null) {
this.root = this.project.getSourceFolderRoot(resource);
@@ -145,7 +147,7 @@
* Queue of deltas created explicily by the Ruby Model that have yet to be
* fired.
*/
- public ArrayList javaModelDeltas = new ArrayList();
+ public ArrayList rubyModelDeltas = new ArrayList();
/*
* Queue of reconcile deltas on working copies that have yet to be fired.
@@ -159,7 +161,10 @@
* and using the various get*(...) to push it.
*/
private Openable currentElement;
-
+
+ /* A set of IRubyProject whose source folder roots need to be refreshed */
+ private HashSet rootsToRefresh = new HashSet();
+
/*
* The <code>RubyElementDelta</code> corresponding to the <code>IResourceDelta</code>
* being translated.
@@ -178,13 +183,13 @@
}
public void registerRubyModelDelta(IRubyElementDelta delta) {
- this.javaModelDeltas.add(delta);
+ this.rubyModelDeltas.add(delta);
}
public void updateRubyModel(IRubyElementDelta customDelta) {
if (customDelta == null) {
- for (int i = 0, length = this.javaModelDeltas.size(); i < length; i++) {
- IRubyElementDelta delta = (IRubyElementDelta) this.javaModelDeltas.get(i);
+ for (int i = 0, length = this.rubyModelDeltas.size(); i < length; i++) {
+ IRubyElementDelta delta = (IRubyElementDelta) this.rubyModelDeltas.get(i);
this.modelUpdater.processRubyDelta(delta);
}
} else {
@@ -207,7 +212,7 @@
IRubyElementDelta deltaToNotify;
if (customDelta == null) {
- deltaToNotify = this.mergeDeltas(this.javaModelDeltas);
+ deltaToNotify = this.mergeDeltas(this.rubyModelDeltas);
} else {
deltaToNotify = customDelta;
}
@@ -331,7 +336,7 @@
* Flushes all deltas without firing them.
*/
public void flush() {
- this.javaModelDeltas = new ArrayList();
+ this.rubyModelDeltas = new ArrayList();
}
private void notifyListeners(IRubyElementDelta deltaToNotify, int eventType,
@@ -411,6 +416,10 @@
try {
stopDeltas();
checkProjectsBeingAddedOrRemoved(delta);
+ if (this.refreshedElements != null) {
+ // TODO Actually update external references too
+// createExternalArchiveDelta(null);
+ }
IRubyElementDelta translatedDelta = processResourceDelta(delta);
if (translatedDelta != null) {
registerRubyModelDelta(translatedDelta);
@@ -418,9 +427,14 @@
} finally {
startDeltas();
}
- // notifyTypeHierarchies(this.state.elementChangedListeners,
- // this.state.elementChangedListenerCount);
- fire(null, ElementChangedEvent.POST_CHANGE);
+ IElementChangedListener[] listeners;
+ int listenerCount;
+ synchronized (this.state) {
+ listeners = this.state.elementChangedListeners;
+ listenerCount = this.state.elementChangedListenerCount;
+ }
+// notifyTypeHierarchies(listeners, listenerCount);
+ fire(null, ElementChangedEvent.POST_CHANGE);
} finally {
// workaround for bug 15168 circular errors not reported
this.state.resetOldRubyProjectNames();
@@ -443,7 +457,7 @@
// this.processPostChange = false;
if(isAffectedBy(delta)) { // avoid populating for SYNC or MARKER deltas
// FIXME Update the loadpath markers
-// updateLoadpathMarkers(delta, updates);
+ updateLoadpathMarkers(delta, updates);
// RubyBuilder.buildStarting();
}
// does not fire any deltas
@@ -453,6 +467,162 @@
}
/*
+ * Update the .loadpath format, missing entries and cycle markers for the projects affected by the given delta.
+ */
+ private void updateLoadpathMarkers(IResourceDelta delta, DeltaProcessingState.ProjectUpdateInfo[] updates) {
+
+ Map preferredClasspaths = new HashMap(5);
+ Map preferredOutputs = new HashMap(5);
+ HashSet affectedProjects = new HashSet(5);
+
+ // read .loadpath files that have changed, and create markers if format is wrong or if an entry cannot be found
+ RubyModel.flushExternalFileCache();
+ updateLoadpathMarkers(delta, affectedProjects, preferredClasspaths, preferredOutputs);
+
+ // update .loadpath format markers for affected projects (dependent projects
+ // or projects that reference a library in one of the projects that have changed)
+ if (!affectedProjects.isEmpty()) {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IProject[] projects = workspaceRoot.getProjects();
+ int length = projects.length;
+ for (int i = 0; i < length; i++){
+ IProject project = projects[i];
+ RubyProject rubyProject = (RubyProject)RubyCore.create(project);
+ if (preferredClasspaths.get(rubyProject) == null) { // not already updated
+ try {
+ IPath projectPath = project.getFullPath();
+ ILoadpathEntry[] classpath = rubyProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, false/*don't generateMarkerOnError*/, false/*don't returnResolutionInProgress*/); // allowed to reuse model cache
+ for (int j = 0, cpLength = classpath.length; j < cpLength; j++) {
+ ILoadpathEntry entry = classpath[j];
+ switch (entry.getEntryKind()) {
+ case ILoadpathEntry.CPE_PROJECT:
+ if (affectedProjects.contains(entry.getPath())) {
+ rubyProject.updateLoadpathMarkers(null, null);
+ }
+ break;
+ case ILoadpathEntry.CPE_LIBRARY:
+ IPath entryPath = entry.getPath();
+ IPath libProjectPath = entryPath.removeLastSegments(entryPath.segmentCount()-1);
+ if (!libProjectPath.equals(projectPath) // if library contained in another project
+ && affectedProjects.contains(libProjectPath)) {
+ rubyProject.updateLoadpathMarkers(null, null);
+ }
+ break;
+ }
+ }
+ } catch(RubyModelException e) {
+ // project no longer exists
+ }
+ }
+ }
+ }
+ if (!affectedProjects.isEmpty() || updates != null) {
+ // update all cycle markers since the given delta may have affected cycles
+ if (updates != null) {
+ for (int i = 0, length = updates.length; i < length; i++) {
+ DeltaProcessingState.ProjectUpdateInfo info = updates[i];
+ if (!preferredClasspaths.containsKey(info.project))
+ preferredClasspaths.put(info.project, info.newResolvedPath);
+ }
+ }
+ try {
+ RubyProject.updateAllCycleMarkers(preferredClasspaths);
+ } catch (RubyModelException e) {
+ // project no longer exist
+ }
+ }
+ }
+
+ /*
+ * Check whether .classpath files are affected by the given delta.
+ * Creates/removes problem markers if needed.
+ * Remember the affected projects in the given set.
+ */
+ private void updateLoadpathMarkers(IResourceDelta delta, HashSet affectedProjects, Map preferredClasspaths, Map preferredOutputs) {
+ IResource resource = delta.getResource();
+ boolean processChildren = false;
+
+ switch (resource.getType()) {
+
+ case IResource.ROOT :
+ if (delta.getKind() == IResourceDelta.CHANGED) {
+ processChildren = true;
+ }
+ break;
+ case IResource.PROJECT :
+ IProject project = (IProject)resource;
+ int kind = delta.getKind();
+ boolean isRubyProject = RubyProject.hasRubyNature(project);
+ switch (kind) {
+ case IResourceDelta.ADDED:
+ processChildren = isRubyProject;
+ affectedProjects.add(project.getFullPath());
+ break;
+ case IResourceDelta.CHANGED:
+ processChildren = isRubyProject;
+ if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
+ // project opened or closed: remember project and its dependents
+ affectedProjects.add(project.getFullPath());
+ if (isRubyProject) {
+ RubyProject rubyProject = (RubyProject)RubyCore.create(project);
+ rubyProject.updateLoadpathMarkers(preferredClasspaths, preferredOutputs); // in case .loadpath got modified while closed
+ }
+ } else if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
+ boolean wasRubyProject = this.state.findRubyProject(project.getName()) != null;
+ if (wasRubyProject && !isRubyProject) {
+ // project no longer has Ruby nature, discard Ruby related obsolete markers
+ affectedProjects.add(project.getFullPath());
+ // flush loadpath markers
+ RubyProject javaProject = (RubyProject)RubyCore.create(project);
+ javaProject.
+ flushLoadpathProblemMarkers(
+ true, // flush cycle markers
+ true //flush loadpath format markers
+ );
+
+ // remove problems and tasks created by the builder
+ RubyBuilder.removeProblemsAndTasksFor(project);
+ }
+ } else if (isRubyProject) {
+ // check if all entries exist
+ try {
+ RubyProject javaProject = (RubyProject)RubyCore.create(project);
+ javaProject.getResolvedLoadpath(true/*ignoreUnresolvedEntry*/, true/*generateMarkerOnError*/, false/*don't returnResolutionInProgress*/);
+ } catch (RubyModelException e) {
+ // project doesn't exist: ignore
+ }
+ }
+ break;
+ case IResourceDelta.REMOVED:
+ affectedProjects.add(project.getFullPath());
+ break;
+ }
+ break;
+ case IResource.FILE :
+ /* check loadpath file change */
+ IFile file = (IFile) resource;
+ if (file.getName().equals(RubyProject.LOADPATH_FILENAME)) {
+ affectedProjects.add(file.getProject().getFullPath());
+ RubyProject rubyProject = (RubyProject)RubyCore.create(file.getProject());
+ rubyProject.updateLoadpathMarkers(preferredClasspaths, preferredOutputs);
+ break;
+ }
+// /* check custom preference file change */
+// if (file.getName().equals(JavaProject.PREF_FILENAME)) {
+// reconcilePreferenceFileUpdate(delta, file, project);
+// break;
+// }
+ break;
+ }
+ if (processChildren) {
+ IResourceDelta[] children = delta.getAffectedChildren();
+ for (int i = 0; i < children.length; i++) {
+ updateLoadpathMarkers(children[i], affectedProjects, preferredClasspaths, preferredOutputs);
+ }
+ }
+ }
+
+ /*
* Converts a <code>IResourceDelta</code> rooted in a <code>Workspace</code>
* into the corresponding set of <code>IRubyElementDelta</code>, rooted
* in the relevant <code>RubyModel</code>s.
@@ -483,18 +653,24 @@
IResource res = delta.getResource();
// find out the element type
+ RootInfo rootInfo = null;
int elementType;
IProject proj = (IProject) res;
- boolean wasJavaProject = this.manager.getRubyModel().findRubyProject(proj) != null;
+ boolean wasJavaProject = this.state.findRubyProject(proj.getName()) != null;
boolean isJavaProject = RubyProject.hasRubyNature(proj);
if (!wasJavaProject && !isJavaProject) {
elementType = NON_RUBY_RESOURCE;
} else {
- elementType = IRubyElement.RUBY_PROJECT;
+ rootInfo = this.enclosingRootInfo(res.getFullPath(), delta.getKind());
+ if (rootInfo != null && rootInfo.isRootOfProject(res.getFullPath())) {
+ elementType = IRubyElement.SOURCE_FOLDER_ROOT;
+ } else {
+ elementType = IRubyElement.RUBY_PROJECT;
+ }
}
-
+
// traverse delta
- this.traverseDelta(delta, elementType);
+ this.traverseDelta(delta, elementType, rootInfo);
if (elementType == NON_RUBY_RESOURCE
|| (wasJavaProject != isJavaProject && (delta.getKind()) == IResourceDelta.CHANGED)) { // project
@@ -518,9 +694,44 @@
return this.currentDelta;
} finally {
this.currentDelta = null;
+ this.rootsToRefresh.clear();
this.projectCachesToReset.clear();
}
}
+
+ /*
+ * Finds the root info this path is included in.
+ * Returns null if not found.
+ */
+ private RootInfo enclosingRootInfo(IPath path, int kind) {
+ while (path != null && path.segmentCount() > 0) {
+ RootInfo rootInfo = this.rootInfo(path, kind);
+ if (rootInfo != null) return rootInfo;
+ path = path.removeLastSegments(1);
+ }
+ return null;
+ }
+
+ /*
+ * Returns the root info for the given path. Look in the old roots table if kind is REMOVED.
+ */
+ private RootInfo rootInfo(IPath path, int kind) {
+ if (kind == IResourceDelta.REMOVED) {
+ return (RootInfo)this.state.oldRoots.get(path);
+ }
+ return (RootInfo)this.state.roots.get(path);
+ }
+
+ /*
+ * Refresh source folder roots of projects that were affected
+ */
+ private void refreshSourceFolderRoots() {
+ Iterator iterator = this.rootsToRefresh.iterator();
+ while (iterator.hasNext()) {
+ RubyProject project = (RubyProject)iterator.next();
+ project.updateSourceFolderRoots();
+ }
+ }
private RubyElementDelta currentDelta() {
if (this.currentDelta == null) {
@@ -757,14 +968,37 @@
RubyProject rubyProject = (RubyProject) RubyCore.create(project);
switch (delta.getKind()) {
case IResourceDelta.ADDED:
+ this.manager.batchContainerInitializations = true;
+
+ // remember project and its dependents
+ this.addToRootsToRefreshWithDependents(rubyProject);
+
// workaround for bug 15168 circular errors not reported
if (RubyProject.hasRubyNature(project)) {
this.addToParentInfo(rubyProject);
- }
- break;
+ // ensure project references are updated (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=121569)
+ try {
+ this.state.updateProjectReferences(
+ rubyProject,
+ null/*no old loadpath*/,
+ null/*compute new resolved loadpath later*/,
+ null/*read raw loadpath later*/,
+ false/*cannot change resources*/);
+ } catch (RubyModelException e1) {
+ // project always exists
+ }
+ }
+
+ this.state.rootsAreStale = true;
+ break;
case IResourceDelta.CHANGED:
if ((delta.getFlags() & IResourceDelta.OPEN) != 0) {
+ this.manager.batchContainerInitializations = true;
+
+ // project opened or closed: remember project and its dependents
+ this.addToRootsToRefreshWithDependents(rubyProject);
+
// workaround for bug 15168 circular errors not reported
if (project.isOpen()) {
if (RubyProject.hasRubyNature(project)) {
@@ -778,11 +1012,18 @@
}
this.removeFromParentInfo(rubyProject);
this.manager.removePerProjectInfo(rubyProject);
+ this.manager.containerRemove(rubyProject);
}
+ this.state.rootsAreStale = true;
} else if ((delta.getFlags() & IResourceDelta.DESCRIPTION) != 0) {
- boolean wasJavaProject = this.manager.getRubyModel().findRubyProject(project) != null;
+ boolean wasJavaProject = this.state.findRubyProject(project.getName()) != null;
boolean isJavaProject = RubyProject.hasRubyNature(project);
if (wasJavaProject != isJavaProject) {
+ this.manager.batchContainerInitializations = true;
+
+ // ruby nature added or removed: remember project and its dependents
+ this.addToRootsToRefreshWithDependents(rubyProject);
+
// workaround for bug 15168 circular errors not reported
if (isJavaProject) {
this.addToParentInfo(rubyProject);
@@ -791,14 +1032,17 @@
// will not consider the project has a classpath
this.manager.removePerProjectInfo((RubyProject) RubyCore
.create(project));
+// remove container cache for this project
+ this.manager.containerRemove(rubyProject);
// close project
try {
rubyProject.close();
} catch (RubyModelException e) {
- // java project doesn't exist: ignore
+ // ruby project doesn't exist: ignore
}
this.removeFromParentInfo(rubyProject);
}
+ this.state.rootsAreStale = true;
} else {
// in case the project was removed then added then
// changed (see bug 19799)
@@ -819,11 +1063,15 @@
break;
case IResourceDelta.REMOVED:
-
- // remove classpath cache so that initializeRoots() will not
- // consider the project has a classpath
- this.manager.removePerProjectInfo((RubyProject) RubyCore.create(resource));
- break;
+ this.manager.batchContainerInitializations = true;
+
+ // remove classpath cache so that initializeRoots() will not consider the project has a classpath
+ this.manager.removePerProjectInfo(rubyProject);
+ // remove container cache for this project
+ this.manager.containerRemove(rubyProject);
+
+ this.state.rootsAreStale = true;
+ break;
}
// in all cases, refresh the external jars for this project
@@ -847,6 +1095,14 @@
}
}
}
+
+ /*
+ * Adds the given project and its dependents to the list of the roots to refresh.
+ */
+ private void addToRootsToRefreshWithDependents(IRubyProject javaProject) {
+ this.rootsToRefresh.add(javaProject);
+ this.addDependentProjects(javaProject, this.state.projectDependencies, this.rootsToRefresh);
+ }
/*
* Adds the given element to the list of elements used as a scope for
@@ -878,15 +1134,25 @@
* Converts an <code>IResourceDelta</code> and its children into the
* corresponding <code>IRubyElementDelta</code>s.
*/
- private void traverseDelta(IResourceDelta delta, int elementType) {
+ private void traverseDelta(IResourceDelta delta, int elementType, RootInfo rootInfo) {
IResource res = delta.getResource();
+
+ // set stack of elements
+ if (this.currentElement == null && rootInfo != null) {
+ this.currentElement = rootInfo.project;
+ }
// process current delta
boolean processChildren = true;
if (res instanceof IProject) {
- processChildren = updateCurrentDeltaAndIndex(delta, elementType);
- } else {
+ processChildren = updateCurrentDeltaAndIndex(delta,
+ elementType == IRubyElement.SOURCE_FOLDER_ROOT ?
+ IRubyElement.RUBY_PROJECT : // case of prj=src,
+ elementType, rootInfo);
+ } else if (rootInfo != null) {
+ processChildren = this.updateCurrentDeltaAndIndex(delta, elementType, rootInfo);
+ } else {
// not yet inside a package fragment root
processChildren = true;
}
@@ -935,49 +1201,64 @@
* delta must be processed. @throws a RubyModelException if the delta
* doesn't correspond to a ruby element of the given type.
*/
- public boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType) {
+ public boolean updateCurrentDeltaAndIndex(IResourceDelta delta, int elementType, RootInfo rootInfo) {
Openable element;
switch (delta.getKind()) {
case IResourceDelta.ADDED:
IResource deltaRes = delta.getResource();
- element = createElement(deltaRes, elementType);
- if (element == null) { return false; }
- elementAdded(element, delta);
- return false;
+ element = createElement(deltaRes, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.state.updateRoots(deltaRes.getFullPath(), delta, this);
+ return rootInfo != null && rootInfo.inclusionPatterns != null;
+ }
+ elementAdded(element, delta, rootInfo);
+ return elementType == IRubyElement.SOURCE_FOLDER;
case IResourceDelta.REMOVED:
deltaRes = delta.getResource();
- element = createElement(deltaRes, elementType);
- if (element == null) { return false; }
- elementRemoved(element, delta);
+ element = createElement(deltaRes, elementType, rootInfo);
+ if (element == null) {
+ // resource might be containing shared roots (see bug 19058)
+ this.state.updateRoots(deltaRes.getFullPath(), delta, this);
+ return rootInfo != null && rootInfo.inclusionPatterns != null;
+ }
+ elementRemoved(element, delta, rootInfo);
if (deltaRes.getType() == IResource.PROJECT) {
// reset the corresponding project built state, since cannot
// reuse if added back
if (RubyBuilder.DEBUG)
System.out.println("Clearing last state for removed project : " + deltaRes); //$NON-NLS-1$
+ this.manager.setLastBuiltState((IProject)deltaRes, null /*no state*/);
+
+ // clean up previous session containers (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=89850)
+ this.manager.previousSessionContainers.remove(element);
}
- return false;
+ return elementType == IRubyElement.SOURCE_FOLDER;
case IResourceDelta.CHANGED:
int flags = delta.getFlags();
if ((flags & IResourceDelta.CONTENT) != 0 || (flags & IResourceDelta.ENCODING) != 0) {
// content or encoding has changed
- element = createElement(delta.getResource(), elementType);
+ element = createElement(delta.getResource(), elementType, rootInfo);
if (element == null) return false;
contentChanged(element);
} else if (elementType == IRubyElement.RUBY_PROJECT) {
if ((flags & IResourceDelta.OPEN) != 0) {
// project has been opened or closed
IProject res = (IProject) delta.getResource();
- element = createElement(res, elementType);
+ element = createElement(res, elementType, rootInfo);
if (element == null) { return false; }
if (res.isOpen()) {
if (RubyProject.hasRubyNature(res)) {
addToParentInfo(element);
currentDelta().opened(element);
-
- // refresh pkg fragment roots and caches of the
- // project (and its dependents)
- this.projectCachesToReset.add(element);
+ this.state.updateRoots(element.getPath(), delta, this);
+
+ // refresh src folder roots and caches of the project (and its dependents)
+ this.rootsToRefresh.add(element);
+ this.projectCachesToReset.add(element);
+
+// this.manager.indexManager.indexAll(res);
}
} else {
RubyModel javaModel = this.manager.getRubyModel();
@@ -998,16 +1279,16 @@
boolean isJavaProject = RubyProject.hasRubyNature(res);
if (wasJavaProject != isJavaProject) {
// project's nature has been added or removed
- element = this.createElement(res, elementType);
+ element = this.createElement(res, elementType, rootInfo);
if (element == null) return false; // note its
// resources are
// still visible as
// roots to other
// projects
if (isJavaProject) {
- elementAdded(element, delta);
+ elementAdded(element, delta, rootInfo);
} else {
- elementRemoved(element, delta);
+ elementRemoved(element, delta, rootInfo);
// reset the corresponding project built state,
// since cannot reuse if added back
if (RubyBuilder.DEBUG)
@@ -1041,7 +1322,7 @@
* Creates the openables corresponding to this resource. Returns null if
* none was found.
*/
- private Openable createElement(IResource resource, int elementType) {
+ private Openable createElement(IResource resource, int elementType, RootInfo rootInfo) {
if (resource == null) return null;
IPath path = resource.getFullPath();
@@ -1060,6 +1341,12 @@
if (this.currentElement != null
&& this.currentElement.getElementType() == IRubyElement.RUBY_PROJECT
&& ((IRubyProject) this.currentElement).getProject().equals(resource)) { return this.currentElement; }
+
+ if (rootInfo != null && rootInfo.project.getProject().equals(resource)){
+ element = rootInfo.project;
+ break;
+ }
+
IProject proj = (IProject) resource;
if (RubyProject.hasRubyNature(proj)) {
element = RubyCore.create(proj);
@@ -1071,6 +1358,38 @@
}
}
break;
+ case IRubyElement.SOURCE_FOLDER_ROOT:
+ element = rootInfo == null ? RubyCore.create(resource) : rootInfo.getSourceFolderRoot(resource);
+ break;
+ case IRubyElement.SOURCE_FOLDER:
+ if (rootInfo != null) {
+ if (rootInfo.project.contains(resource)) {
+ SourceFolderRoot root = (SourceFolderRoot) rootInfo.getSourceFolderRoot(null);
+ // create package handle
+ IPath pkgPath = path.removeFirstSegments(rootInfo.rootPath.segmentCount());
+ String[] pkgName = pkgPath.segments();
+ element = root.getSourceFolder(pkgName);
+ }
+ } else {
+ // find the element that encloses the resource
+ this.popUntilPrefixOf(path);
+
+ if (this.currentElement == null) {
+ element = RubyCore.create(resource);
+ } else {
+ // find the root
+ SourceFolderRoot root = this.currentElement.getSourceFolderRoot();
+ if (root == null) {
+ element = RubyCore.create(resource);
+ } else if (((RubyProject)root.getRubyProject()).contains(resource)) {
+ // create package handle
+ IPath pkgPath = path.removeFirstSegments(root.getPath().segmentCount());
+ String[] pkgName = pkgPath.segments();
+ element = root.getSourceFolder(pkgName);
+ }
+ }
+ }
+ break;
case IRubyElement.SCRIPT:
// find the element that encloses the resource
this.popUntilPrefixOf(path);
@@ -1104,12 +1423,12 @@
* <li>If the elemet is not a project, process it as added (see <code>basicElementAdded</code>.
* </ul> Delta argument could be null if processing an external JAR change
*/
- private void elementAdded(Openable element, IResourceDelta delta) {
+ private void elementAdded(Openable element, IResourceDelta delta, RootInfo rootInfo) {
int elementType = element.getElementType();
if (elementType == IRubyElement.RUBY_PROJECT) {
// project add is handled by RubyProject.configure() because
- // when a project is created, it does not yet have a java nature
+ // when a project is created, it does not yet have a ruby nature
if (delta != null && RubyProject.hasRubyNature((IProject) delta.getResource())) {
addToParentInfo(element);
if ((delta.getFlags() & IResourceDelta.MOVED_FROM) != 0) {
@@ -1119,9 +1438,11 @@
} else {
currentDelta().added(element);
}
-
+ this.state.updateRoots(element.getPath(), delta, this);
+
// refresh pkg fragment roots and caches of the project (and its
// dependents)
+ this.rootsToRefresh.add(element);
this.projectCachesToReset.add(element);
}
} else {
@@ -1179,8 +1500,8 @@
// create the moved from element
Openable movedFromElement = elementType != IRubyElement.RUBY_PROJECT
&& movedFromType == IRubyElement.RUBY_PROJECT ? null : // outside
- // classpath
- this.createElement(movedFromRes, movedFromType);
+ // loadpath
+ this.createElement(movedFromRes, movedFromType, rootInfo);
if (movedFromElement == null) {
// moved from outside classpath
currentDelta().added(element);
@@ -1188,6 +1509,24 @@
currentDelta().movedTo(element, movedFromElement);
}
}
+
+ switch (elementType) {
+ case IRubyElement.SOURCE_FOLDER_ROOT :
+ // when a root is added, and is on the loadpath, the project must be updated
+ RubyProject project = (RubyProject) element.getRubyProject();
+
+ // refresh src folder roots and caches of the project (and its dependents)
+ this.rootsToRefresh.add(project);
+ this.projectCachesToReset.add(project);
+
+ break;
+ case IRubyElement.SOURCE_FOLDER :
+ // reset project's source folder cache
+ project = (RubyProject) element.getRubyProject();
+ this.projectCachesToReset.add(project);
+
+ break;
+ }
}
}
@@ -1209,7 +1548,7 @@
* parent's cache of children <li>Add a REMOVED entry in the delta </ul>
* Delta argument could be null if processing an external JAR change
*/
- private void elementRemoved(Openable element, IResourceDelta delta) {
+ private void elementRemoved(Openable element, IResourceDelta delta, RootInfo rootInfo) {
int elementType = element.getElementType();
if (delta == null || (delta.getFlags() & IResourceDelta.MOVED_TO) == 0) {
@@ -1257,8 +1596,8 @@
// create the moved To element
Openable movedToElement = elementType != IRubyElement.RUBY_PROJECT
&& movedToType == IRubyElement.RUBY_PROJECT ? null : // outside
- // classpath
- this.createElement(movedToRes, movedToType);
+ // loadpath
+ this.createElement(movedToRes, movedToType, rootInfo);
if (movedToElement == null) {
// moved outside classpath
currentDelta().removed(element);
@@ -1268,13 +1607,31 @@
}
switch (elementType) {
- case IRubyElement.RUBY_PROJECT:
+ case IRubyElement.RUBY_MODEL :
+// this.manager.indexManager.reset();
+ break;
+ case IRubyElement.RUBY_PROJECT :
+ this.state.updateRoots(element.getPath(), delta, this);
- // refresh pkg fragment roots and caches of the project (and its
- // dependents)
- this.projectCachesToReset.add(element);
+ // refresh pkg fragment roots and caches of the project (and its dependents)
+ this.rootsToRefresh.add(element);
+ this.projectCachesToReset.add(element);
- break;
+ break;
+ case IRubyElement.SOURCE_FOLDER_ROOT :
+ RubyProject project = (RubyProject) element.getRubyProject();
+
+ // refresh src folder roots and caches of the project (and its dependents)
+ this.rootsToRefresh.add(project);
+ this.projectCachesToReset.add(project);
+
+ break;
+ case IRubyElement.SOURCE_FOLDER :
+ // reset sourc folder cache
+ project = (RubyProject) element.getRubyProject();
+ this.projectCachesToReset.add(project);
+
+ break;
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -1548,4 +1548,25 @@
this.containers.remove(project);
}
+ /**
+ * Sets the last built state for the given project, or null to reset it.
+ */
+ public void setLastBuiltState(IProject project, Object state) {
+ if (RubyProject.hasRubyNature(project)) {
+ // should never be requested on non-Ruby projects
+ PerProjectInfo info = getPerProjectInfo(project, true /*create if missing*/);
+ info.triedRead = true; // no point trying to re-read once using setter
+ info.savedState = state;
+ }
+ if (state == null) { // delete state file to ensure a full build happens if the workspace crashes
+ try {
+ File file = getSerializationFile(project);
+ if (file != null && file.exists())
+ file.delete();
+ } catch(SecurityException se) {
+ // could not delete file: cannot do much more
+ }
+ }
+ }
+
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelOperation.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelOperation.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelOperation.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -664,7 +664,7 @@
public void run(IProgressMonitor monitor) throws CoreException {
RubyModelManager manager = RubyModelManager.getRubyModelManager();
DeltaProcessor deltaProcessor = manager.getDeltaProcessor();
- int previousDeltaCount = deltaProcessor.javaModelDeltas.size();
+ int previousDeltaCount = deltaProcessor.rubyModelDeltas.size();
try {
progressMonitor = monitor;
pushOperation(this);
@@ -687,8 +687,8 @@
deltaProcessor = manager.getDeltaProcessor();
// update RubyModel using deltas that were recorded during this operation
- for (int i = previousDeltaCount, size = deltaProcessor.javaModelDeltas.size(); i < size; i++) {
- deltaProcessor.updateRubyModel((IRubyElementDelta)deltaProcessor.javaModelDeltas.get(i));
+ for (int i = previousDeltaCount, size = deltaProcessor.rubyModelDeltas.size(); i < size; i++) {
+ deltaProcessor.updateRubyModel((IRubyElementDelta)deltaProcessor.rubyModelDeltas.get(i));
}
// close the parents of the created elements and reset their project's cache (in case we are in an
@@ -707,7 +707,7 @@
// - the operation did produce some delta(s)
// - but the operation has not modified any resource
if (this.isTopLevelOperation()) {
- if ((deltaProcessor.javaModelDeltas.size() > previousDeltaCount || !deltaProcessor.reconcileDeltas.isEmpty())
+ if ((deltaProcessor.rubyModelDeltas.size() > previousDeltaCount || !deltaProcessor.reconcileDeltas.isEmpty())
&& !this.hasModifiedResource()) {
deltaProcessor.fire(null, DeltaProcessor.DEFAULT_CHANGE_EVENT);
} // else deltas are fired while processing the resource delta
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -2145,5 +2145,34 @@
}
}
}
+ }
+
+ public void updateLoadpathMarkers(Map preferredClasspaths, Map preferredOutputs) {
+ this.flushLoadpathProblemMarkers(false/*cycle*/, true/*format*/);
+ this.flushLoadpathProblemMarkers(false/*cycle*/, false/*format*/);
+
+ ILoadpathEntry[] classpath = this.readLoadpathFile(true/*marker*/, false/*log*/);
+
+ // remember invalid path so as to avoid reupdating it again later on
+ if (preferredClasspaths != null) {
+ preferredClasspaths.put(this, classpath == null ? INVALID_LOADPATH : classpath);
+ }
+ if (preferredOutputs != null) {
+ preferredOutputs.put(this, null);
+ }
+
+ // force classpath marker refresh
+ if (classpath != null) {
+ for (int i = 0; i < classpath.length; i++) {
+ IRubyModelStatus status = LoadpathEntry.validateLoadpathEntry(this, classpath[i], false/*src attach*/, true /*recurse in container*/);
+ if (!status.isOK()) {
+ if (status.getCode() == IRubyModelStatusConstants.INVALID_CLASSPATH && ((LoadpathEntry) classpath[i]).isOptional())
+ continue; // ignore this entry
+ this.createLoadpathProblemMarker(status);
+ }
+ }
+ IRubyModelStatus status = LoadpathEntry.validateLoadpath(this, classpath, null);
+ if (!status.isOK()) this.createLoadpathProblemMarker(status);
+ }
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -17,23 +17,15 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.core.IRubyModelMarker;
+import org.rubypeople.rdt.internal.core.parser.Error;
import org.rubypeople.rdt.internal.core.parser.MarkerUtility;
import org.rubypeople.rdt.internal.core.parser.RdtPosition;
import org.rubypeople.rdt.internal.core.parser.Warning;
-import org.rubypeople.rdt.internal.core.parser.Error;
class MarkerManager implements IMarkerManager {
public void removeProblemsAndTasksFor(IResource resource) {
- try {
- if (resource != null && resource.exists()) {
- resource.deleteMarkers(IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
- resource.deleteMarkers(IRubyModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
- }
- } catch (CoreException e) {
- // assume there were no problems
- }
+ RubyBuilder.removeProblemsAndTasksFor(resource);
}
public void createSyntaxError(IFile file, SyntaxException e) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -13,13 +13,18 @@
import java.io.DataOutputStream;
import java.util.Date;
+import java.util.Iterator;
import java.util.Map;
+import java.util.Set;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IncrementalProjectBuilder;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.rubypeople.rdt.core.IRubyModelMarker;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.symbols.SymbolIndex;
@@ -71,4 +76,22 @@
public static void writeState(Object savedState, DataOutputStream out) {
// TODO Actually write out build state to the stream!
}
+
+ public static void removeProblemsAndTasksFor(IResource resource) {
+ try {
+ if (resource != null && resource.exists()) {
+ resource.deleteMarkers(IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER, false, IResource.DEPTH_INFINITE);
+ resource.deleteMarkers(IRubyModelMarker.TASK_MARKER, false, IResource.DEPTH_INFINITE);
+
+ // delete managed markers
+// Set markerTypes = RubyModelManager.getRubyModelManager().compilationParticipants.managedMarkerTypes();
+// if (markerTypes.size() == 0) return;
+// Iterator iterator = markerTypes.iterator();
+// while (iterator.hasNext())
+// resource.deleteMarkers((String) iterator.next(), false, IResource.DEPTH_INFINITE);
+ }
+ } catch (CoreException e) {
+ // assume there were no problems
+ }
+ }
}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -15,6 +15,7 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IStorage;
import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceDescription;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -28,7 +29,11 @@
import org.eclipse.core.runtime.jobs.Job;
import org.rubypeople.rdt.core.ILoadpathEntry;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceFolder;
+import org.rubypeople.rdt.core.ISourceFolderRoot;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.internal.core.util.CharOperation;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -37,6 +42,23 @@
protected IRubyProject currentProject;
protected String endChar = ",";
+ public AbstractRubyModelTest(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ // TODO Make it so this stuff is only run once per suite, not before every method
+ super.setUp();
+
+ // ensure autobuilding is turned off
+ IWorkspaceDescription description = getWorkspace().getDescription();
+ if (description.isAutoBuilding()) {
+ description.setAutoBuilding(false);
+ getWorkspace().setDescription(description);
+ }
+ }
+
protected IRubyProject setUpRubyProject(final String projectName) throws CoreException, IOException {
this.currentProject = setUpRubyProject(projectName, "1.8.4");
return this.currentProject;
@@ -143,8 +165,8 @@
}
};
getWorkspace().run(populate, null);
- IRubyProject javaProject = RubyCore.create(project);
- return javaProject;
+ IRubyProject rubyProject = RubyCore.create(project);
+ return rubyProject;
}
/**
@@ -527,4 +549,86 @@
description.setNatureIds(new String[] {RubyCore.NATURE_ID});
project.setDescription(description, null);
}
+
+ /**
+ * Returns the specified ruby script in the given project, root, and
+ * source folder or <code>null</code> if it does not exist.
+ */
+ public IRubyScript getRubyScript(String projectName, String rootPath, String packageName, String cuName) throws RubyModelException {
+ ISourceFolder pkg= getSourceFolder(projectName, rootPath, packageName);
+ if (pkg == null) {
+ return null;
+ }
+ return pkg.getRubyScript(cuName);
+ }
+
+ /**
+ * Returns the specified package fragment in the given project and root, or
+ * <code>null</code> if it does not exist.
+ * The rootPath must be specified as a project relative path. The empty
+ * path refers to the default package fragment.
+ */
+ public ISourceFolder getSourceFolder(String projectName, String rootPath, String packageName) throws RubyModelException {
+ ISourceFolderRoot root= getSourceFolderRoot(projectName, rootPath);
+ if (root == null) {
+ return null;
+ }
+ return root.getSourceFolder(packageName);
+ }
+
+ /**
+ * Returns the specified package fragment root in the given project, or
+ * <code>null</code> if it does not exist.
+ * If relative, the rootPath must be specified as a project relative path.
+ * The empty path refers to the package fragment root that is the project
+ * folder iteslf.
+ * If absolute, the rootPath refers to either an external jar, or a resource
+ * internal to the workspace
+ */
+ public ISourceFolderRoot getSourceFolderRoot(
+ String projectName,
+ String rootPath)
+ throws RubyModelException {
+
+ IRubyProject project = getRubyProject(projectName);
+ if (project == null) {
+ return null;
+ }
+ IPath path = new Path(rootPath);
+ if (path.isAbsolute()) {
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IResource resource = workspaceRoot.findMember(path);
+ ISourceFolderRoot root;
+ if (resource == null) {
+ // external jar
+ root = project.getSourceFolderRoot(rootPath);
+ } else {
+ // resource in the workspace
+ root = project.getSourceFolderRoot(resource);
+ }
+ return root;
+ } else {
+ ISourceFolderRoot[] roots = project.getSourceFolderRoots();
+ if (roots == null || roots.length == 0) {
+ return null;
+ }
+ for (int i = 0; i < roots.length; i++) {
+ ISourceFolderRoot root = roots[i];
+ if (!root.isExternal()
+ && root.getUnderlyingResource().getProjectRelativePath().equals(path)) {
+ return root;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns the Ruby Project with the given name in this test
+ * suite's model. This is a convenience method.
+ */
+ public IRubyProject getRubyProject(String name) {
+ IProject project = getProject(name);
+ return RubyCore.create(project);
+ }
}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -8,6 +8,11 @@
import org.eclipse.core.runtime.CoreException;
public class ModifyingResourceTest extends AbstractRubyModelTest {
+
+ public ModifyingResourceTest(String name) {
+ super(name);
+ }
+
protected IFile editFile(String path, String content) throws CoreException {
IFile file = this.getFile(path);
InputStream input = new ByteArrayInputStream(content.getBytes());
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java 2007-01-06 17:59:37 UTC (rev 1755)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java 2007-01-06 21:23:21 UTC (rev 1756)
@@ -1,28 +1,33 @@
package org.rubypeople.rdt.internal.core;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.tests.ModifyingResourceTest;
public class TC_RubyProject extends ModifyingResourceTest {
-
-// public void testGetLibraryPathXML() {
-// ShamRubyProject rubyProject = new ShamRubyProject();
-// rubyProject.setProject(new ShamProject("TheWorkingProject"));
-//
-// IProject referencedProject = new ShamProject(new ShamIPath("TheReferencedProject"), "TheReferencedProject");
-// rubyProject.addLoadPathEntry(referencedProject);
-// assertEquals("XML should indicate only one referenced project.", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><loadpath><pathentry type=\"project\" path=\"" + referencedProject.getFullPath() + "\"/></loadpath>", rubyProject.getLoadPathXML());
-//
-// IProject anotherReferencedProject = new ShamProject("AnotherReferencedProject");
-// rubyProject.addLoadPathEntry(anotherReferencedProject);
-// assertEquals("XML should indicate two referenced projects.", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><loadpath><pathentry type=\"project\" path=\"" + referencedProject.getFullPath() + "\"/><pathentry type=\"project\" path=\"" + anotherReferencedProject.getFullPath() + "\"/></loadpath>", rubyProject.getLoadPathXML());
-//
-// rubyProject.removeLoadPathEntry(referencedProject);
-// assertEquals("XML should indicate one referenced project after removing one.", "<?xml version=\"1.0\" encoding=\"UTF-8\"?><loadpath><pathentry type=\"project\" path=\"" + anotherReferencedProject.getFullPath() + "\"/></loadpath>", rubyProject.getLoadPathXML());
-// }
+ public TC_RubyProject(String name) {
+ super(name);
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ // TODO Only run once per suite/class, not every method
+ super.setUp();
+ setUpRubyProject("RubyProjectTests");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+// TODO Only run once per suite/class, not every method
+ deleteProject("RubyProjectTests");
+ super.tearDown();
+ }
+
public void testGetRequiredProjectNames() throws CoreException {
try {
IRubyProject p2 = createRubyProject("P2");
@@ -54,7 +59,7 @@
"/P2/.loadpath",
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
"<loadpath>\n" +
- " <loadpathentry kind=\"src\" path=\"/P1\"/>\n" +
+ " <pathentry type=\"src\" path=\"/P1\"/>\n" +
"</loadpath>"
);
waitForAutoBuild();
@@ -67,4 +72,16 @@
deleteProjects(new String[] {"P1", "P2"});
}
}
+
+ /**
+ * Test that a ruby script
+ * has a corresponding resource.
+ */
+ public void testRubyScriptCorrespondingResource() throws RubyModelException {
+ IRubyScript element= getRubyScript("RubyProjectTests", "", "q", "A.rb");
+ IResource corr= element.getCorrespondingResource();
+ IResource res= getWorkspace().getRoot().getProject("RubyProjectTests").getFolder("q").getFile("A.rb");
+ assertTrue("incorrect corresponding resource", corr.equals(res));
+ assertEquals("Project is incorrect for the ruby script", "RubyProjectTests", corr.getProject().getName());
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-06 17:59:41
|
Revision: 1755
http://svn.sourceforge.net/rubyeclipse/?rev=1755&view=rev
Author: cawilliams
Date: 2007-01-06 09:59:37 -0800 (Sat, 06 Jan 2007)
Log Message:
-----------
apply patch from Martin Krauskopf Ticket #222 - Markus please review this and revert if this isn't right...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/ClassicDebuggerCommandFactory.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/ClassicDebuggerCommandFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/ClassicDebuggerCommandFactory.java 2007-01-05 15:49:38 UTC (rev 1754)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/ClassicDebuggerCommandFactory.java 2007-01-06 17:59:37 UTC (rev 1755)
@@ -21,15 +21,15 @@
}
public String createStepOver(RubyStackFrame stackFrame) {
- return "th " + ((RubyThread) stackFrame.getThread()).getId() + " ; next " + stackFrame.getIndex();
+ return "th " + ((RubyThread) stackFrame.getThread()).getId() + " ; next";
}
public String createStepReturn(RubyStackFrame stackFrame) {
- return "th " + ((RubyThread) stackFrame.getThread()).getId() + " ; next " + (stackFrame.getIndex() + 1);
+ return "th " + ((RubyThread) stackFrame.getThread()).getId() + " ; next " + (stackFrame.getLineNumber() + 1);
}
public String createStepInto(RubyStackFrame stackFrame) {
- return "th " + ((RubyThread) stackFrame.getThread()).getId() + " ; step " + stackFrame.getIndex();
+ return "th " + ((RubyThread) stackFrame.getThread()).getId() + " ; step";
}
public String createReadThreads() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-05 15:49:40
|
Revision: 1754
http://svn.sourceforge.net/rubyeclipse/?rev=1754&view=rev
Author: cawilliams
Date: 2007-01-05 07:49:38 -0800 (Fri, 05 Jan 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java 2007-01-05 15:49:38 UTC (rev 1754)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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.compiler;
+
+import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+
+/**
+ * Richer description of a Java problem, as detected by the compiler or some of the underlying
+ * technology reusing the compiler. With the introduction of <code>CompilationParticipant</code>,
+ * the simpler problem interface <code>IProblem</code> did not carry enough information to better
+ * separate and categorize Java problems. In order to minimize impact on existing API, Java problems
+ * are still passed around as <code>IProblem</code>, though actual implementations should explicitly
+ * extend <code>CategorizedProblem</code>. Participants can produce their own problem definitions,
+ * and given these are categorized problems, they can be better handled by clients (such as user
+ * interface).
+ *
+ * A categorized problem provides access to:
+ * <ul>
+ * <li> its location (originating source file name, source position, line number), </li>
+ * <li> its message description and a predicate to check its severity (warning or error). </li>
+ * <li> its ID : a number identifying the very nature of this problem. All possible IDs for standard Java
+ * problems are listed as constants on <code>IProblem</code>, </li>
+ * <li> its marker type : a string identfying the problem creator. It corresponds to the marker type
+ * chosen if this problem was to be persisted. Standard Java problems are associated to marker
+ * type "org.eclipse.jdt.core.problem"), </li>
+ * <li> its category ID : a number identifying the category this problem belongs to. All possible IDs for
+ * standard Java problem categories are listed in this class. </li>
+ * </ul>
+ *
+ * Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder
+ * so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected
+ * when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular
+ * their ID (attribute "id") is set to one of the IDs defined on this interface.
+ *
+ * Note: Standard Java problems produced by Java default tooling will be subclasses of this class. Technically, most
+ * API methods dealing with problems are referring to <code>IProblem</code> for backward compatibility reason.
+ * It is intended that <code>CategorizedProblem</code> will be subclassed for custom problem implementation when
+ * participating in compilation operations, so as to allow participant to contribute their own marker types, and thus
+ * defining their own domain specific problem/category IDs.
+ *
+ * @since 3.2
+ */
+public abstract class CategorizedProblem implements IProblem {
+
+ /**
+ * List of standard category IDs used by Java problems, more categories will be added
+ * in the future.
+ */
+ public static final int CAT_UNSPECIFIED = 0;
+ /** Category for problems related to buildpath */
+ public static final int CAT_BUILDPATH = 10;
+ /** Category for fatal problems related to syntax */
+ public static final int CAT_SYNTAX = 20;
+ /** Category for fatal problems in import statements */
+ public static final int CAT_IMPORT = 30;
+ /** Category for fatal problems related to types, could be addressed by some type change */
+ public static final int CAT_TYPE = 40;
+ /** Category for fatal problems related to type members, could be addressed by some field or method change */
+ public static final int CAT_MEMBER = 50;
+ /** Category for fatal problems which could not be addressed by external changes, but require an edit to be addressed */
+ public static final int CAT_INTERNAL = 60;
+ /** Category for optional problems in Javadoc */
+ public static final int CAT_JAVADOC = 70;
+ /** Category for optional problems related to coding style practices */
+ public static final int CAT_CODE_STYLE = 80;
+ /** Category for optional problems related to potential programming flaws */
+ public static final int CAT_POTENTIAL_PROGRAMMING_PROBLEM = 90;
+ /** Category for optional problems related to naming conflicts */
+ public static final int CAT_NAME_SHADOWING_CONFLICT = 100;
+ /** Category for optional problems related to deprecation */
+ public static final int CAT_DEPRECATION = 110;
+ /** Category for optional problems related to unnecessary code */
+ public static final int CAT_UNNECESSARY_CODE = 120;
+ /** Category for optional problems related to type safety in generics */
+ public static final int CAT_UNCHECKED_RAW = 130;
+ /** Category for optional problems related to internationalization of String literals */
+ public static final int CAT_NLS = 140;
+ /** Category for optional problems related to access restrictions */
+ public static final int CAT_RESTRICTION = 150;
+
+/**
+ * Returns an integer identifying the category of this problem. Categories, like problem IDs are
+ * defined in the context of some marker type. Custom implementations of <code>CategorizedProblem</code>
+ * may choose arbitrary values for problem/category IDs, as long as they are associated with a different
+ * marker type.
+ * Standard Java problem markers (i.e. marker type is "org.eclipse.jdt.core.problem") carry an
+ * attribute "categoryId" persisting the originating problem category ID as defined by this method).
+ * @return id - an integer identifying the category of this problem
+ */
+public abstract int getCategoryID();
+
+/**
+ * Returns the marker type associated to this problem, if it gets persisted into a marker by the JavaBuilder
+ * Standard Java problems are associated to marker type "org.eclipse.jdt.core.problem").
+ * Note: problem markers are expected to extend "org.eclipse.core.resources.problemmarker" marker type.
+ * @return the type of the marker which would be associated to the problem
+ */
+public abstract String getMarkerType();
+
+/**
+ * Returns the names of the extra marker attributes associated to this problem when persisted into a marker
+ * by the JavaBuilder. Extra attributes are only optional, and are allowing client customization of generated
+ * markers. By default, no EXTRA attributes is persisted, and a categorized problem only persists the following attributes:
+ * <ul>
+ * <li> <code>IMarker#MESSAGE</code> -> {@link IProblem#getMessage()}</li>
+ * <li> <code>IMarker#SEVERITY</code> -> <code> IMarker#SEVERITY_ERROR</code> or
+ * <code>IMarker#SEVERITY_WARNING</code> depending on {@link IProblem#isError()} or {@link IProblem#isWarning()}</li>
+ * <li> <code>IJavaModelMarker#ID</code> -> {@link IProblem#getID()}</li>
+ * <li> <code>IMarker#CHAR_START</code> -> {@link IProblem#getSourceStart()}</li>
+ * <li> <code>IMarker#CHAR_END</code> -> {@link IProblem#getSourceEnd()}</li>
+ * <li> <code>IMarker#LINE_NUMBER</code> -> {@link IProblem#getSourceLineNumber()}</li>
+ * <li> <code>IJavaModelMarker#ARGUMENTS</code> -> some <code>String[]</code> used to compute quickfixes </li>
+ * <li> <code>IJavaModelMarker#CATEGORY_ID</code> -> {@link CategorizedProblem#getCategoryID()}</li>
+ * </ul>
+ * The names must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>,
+ * and there must be as many names as values according to {@link #getExtraMarkerAttributeValues()}.
+ * Note that extra marker attributes will be inserted after default ones (as described in {@link CategorizedProblem#getMarkerType()},
+ * and thus could be used to override defaults.
+ * @return the names of the corresponding marker attributes
+ */
+public String[] getExtraMarkerAttributeNames() {
+ return CharOperation.NO_STRINGS;
+}
+
+/**
+ * Returns the respective values for the extra marker attributes associated to this problem when persisted into
+ * a marker by the JavaBuilder. Each value must correspond to a matching attribute name, as defined by
+ * {@link #getExtraMarkerAttributeNames()}.
+ * The values must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>.
+ * @return the values of the corresponding extra marker attributes
+ */
+public Object[] getExtraMarkerAttributeValues() {
+ return new Object[] {};
+}
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-01-05 15:49:11
|
Revision: 1753
http://svn.sourceforge.net/rubyeclipse/?rev=1753&view=rev
Author: cawilliams
Date: 2007-01-05 07:49:09 -0800 (Fri, 05 Jan 2007)
Log Message:
-----------
massive overhaul under the hood to add SourceFolderRoot into RubyElement hierarchy, and to include some actual loadpath support. This is to pave the way for referencing external libraries like the core/std ruby lib
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.core/plugin.xml
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelMarker.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/CreateSourceFolderOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessingState.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/DeltaProcessor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/LoadpathEntry.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ModelUpdater.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModel.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProjectElementInfo.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScript.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyType.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderInfo.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyBuilder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/CharOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/Util.java
trunk/org.rubypeople.rdt.core.tests/src/RubyParserCmd.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/TC_RubyProject.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEnvironmentTab.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/wizards/RubyNewTestCaseWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyModelUtil.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyProjectLibraryPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyProjectPropertyPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewClassCreationWizard.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewElementWizard.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/NewWizardMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyElementLabels.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/StandardRubyElementContentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewClassWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewContainerWizardPage.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/wizards/NewTypeWizardPage.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/schema/
trunk/org.rubypeople.rdt.core/schema/loadpathContainerInitializer.exsd
trunk/org.rubypeople.rdt.core/schema/loadpathVariableInitializer.exsd
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathContainer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathContainerInitializer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathVariableInitializer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/ObjectVector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/util/Util.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/ExternalPackageFragmentRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SetLoadpathOperation.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRoot.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/SourceFolderRootInfo.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/XMLWriter.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/util/HashtableOfArrayToObject.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/AbstractRubyModelTest.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/ModifyingResourceTest.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/util/
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/core/tests/util/Util.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/wizards/dialogfields/StringButtonStatusDialogField.java
Modified: trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-01-05 15:49:09 UTC (rev 1753)
@@ -25,5 +25,6 @@
org.eclipse.core.resources,
org.eclipse.team.core,
org.eclipse.jface.text,
- org.jruby
+ org.jruby,
+ org.eclipse.core.filesystem
Eclipse-LazyStart: true
Modified: trunk/org.rubypeople.rdt.core/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.core/plugin.xml 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/plugin.xml 2007-01-05 15:49:09 UTC (rev 1753)
@@ -1,6 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.0"?>
<plugin>
+ <extension-point id="loadpathVariableInitializer" name="%loadpathVariableInitializersName" schema="schema/loadpathVariableInitializer.exsd"/>
+ <extension-point id="loadpathContainerInitializer" name="%loadpathContainerInitializersName" schema="schema/loadpathContainerInitializer.exsd"/>
<extension
id="rubynature"
Added: trunk/org.rubypeople.rdt.core/schema/loadpathContainerInitializer.exsd
===================================================================
--- trunk/org.rubypeople.rdt.core/schema/loadpathContainerInitializer.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.core/schema/loadpathContainerInitializer.exsd 2007-01-05 15:49:09 UTC (rev 1753)
@@ -0,0 +1,124 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.jdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.jdt.core" id="loadpathContainerInitializer" name="loadpath Container Initializers"/>
+ </appInfo>
+ <documentation>
+ This extension point allows clients to contribute custom loadpath container initializers,
+ which are used to lazily bind loadpath containers to instances of org.rubypeople.rdt.core.ILoadpathContainer.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="loadpathContainerInitializer" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="loadpathContainerInitializer">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name identifying all containers for which this initializer will be activated.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the load that implements this container initializer.
+ This load must implement a public subload of <code>org.rubypeople.rdt.core.LoadpathContainerInitializer</code> with a public 0-argument constructor.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="ruby" basedOn="org.rubypeople.rdt.core.LoadpathContainerInitializer"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.9.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ Example of a declaration of a <code>loadpathContainerInitializer</code> for a loadpath container named "JDK": <pre>
+<extension point="org.eclipse.jdt.core.loadpathContainerInitializer">
+ <loadpathContainerInitializer
+ id="JDK"
+ class="com.example.MyInitializer"/>
+</extension>
+</pre>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2000, 2004 IBM Corporation and others.<br>
+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 <a
+href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
Added: trunk/org.rubypeople.rdt.core/schema/loadpathVariableInitializer.exsd
===================================================================
--- trunk/org.rubypeople.rdt.core/schema/loadpathVariableInitializer.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.core/schema/loadpathVariableInitializer.exsd 2007-01-05 15:49:09 UTC (rev 1753)
@@ -0,0 +1,113 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.core">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.core" id="loadpathVariableInitializer" name="loadpathVariableInitializer"/>
+ </appInfo>
+ <documentation>
+ This extension point allows clients to contribute custom loadpath variable initializers,
+ which are used to lazily bind loadpath variables.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence minOccurs="0" maxOccurs="unbounded">
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="loadpathVariableInitializer">
+ <complexType>
+ <attribute name="variable" type="string" use="required">
+ <annotation>
+ <documentation>
+ a unique name identifying the variable for which this initializer will be activated.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ The class that implements this variable initializer.
+This class must implement a public subclass of &lt;code&gt;org.rubypeople.rdt.core.LoadpathVariableInitializer&lt;/code&gt; with a public 0-argument constructor.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="ruby" basedOn="org.rubypeople.rdt.core.LoadpathVariableInitializer"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ 0.9.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathContainer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathContainer.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ILoadpathContainer.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -0,0 +1,9 @@
+package org.rubypeople.rdt.core;
+
+public interface ILoadpathContainer {
+
+ ILoadpathEntry[] getLoadpathEntries();
+
+ String getDescription();
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyElement.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -37,24 +37,25 @@
* A Ruby element with this type can be safely cast to <code>IRubyProject</code>.
*/
public static final int RUBY_PROJECT = 1;
+ public static final int SOURCE_FOLDER_ROOT = 2;
/**
* Constant representing a source folder
* A Ruby element with this type can be safely cast to <code>ISourceFolder</code>.
*/
- public static final int SOURCE_FOLDER = 2;
- public static final int SCRIPT = 3;
- public static final int TYPE = 4;
- public static final int METHOD = 5;
- public static final int GLOBAL = 6;
- public static final int IMPORT_DECLARATION = 7;
- public static final int CONSTANT = 8;
- public static final int CLASS_VAR = 9;
- public static final int INSTANCE_VAR = 10;
- public static final int LOCAL_VARIABLE = 11;
- public static final int BLOCK = 12;
- public static final int DYNAMIC_VAR = 13;
- public static final int FIELD = 14;
- public static final int IMPORT_CONTAINER = 15;
+ public static final int SOURCE_FOLDER = 3;
+ public static final int SCRIPT = 4;
+ public static final int TYPE = 5;
+ public static final int METHOD = 6;
+ public static final int GLOBAL = 7;
+ public static final int IMPORT_DECLARATION = 8;
+ public static final int CONSTANT = 9;
+ public static final int CLASS_VAR = 10;
+ public static final int INSTANCE_VAR = 11;
+ public static final int LOCAL_VARIABLE = 12;
+ public static final int BLOCK = 13;
+ public static final int DYNAMIC_VAR = 14;
+ public static final int FIELD = 15;
+ public static final int IMPORT_CONTAINER = 16;
/**
* Returns the first ancestor of this Ruby element that has the given type.
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelMarker.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelMarker.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelMarker.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -20,43 +20,81 @@
public interface IRubyModelMarker {
/**
- * Ruby model problem marker type (value <code>"org.rubypeople.rdt.core.problem"</code>).
- * This can be used to recognize those markers in the workspace that flag problems
- * detected by the Ruby tooling during compilation.
+ * Ruby model problem marker type (value
+ * <code>"org.rubypeople.rdt.core.problem"</code>). This can be used to
+ * recognize those markers in the workspace that flag problems detected by
+ * the Ruby tooling during compilation.
*/
- public static final String RUBY_MODEL_PROBLEM_MARKER = RubyCore.PLUGIN_ID + ".problem"; //$NON-NLS-1$
+ public static final String RUBY_MODEL_PROBLEM_MARKER = RubyCore.PLUGIN_ID
+ + ".problem"; //$NON-NLS-1$
/**
- * Ruby model transient problem marker type (value <code>"org.rubypeople.rdt.core.transient_problem"</code>).
- * This can be used to recognize those markers in the workspace that flag transient
- * problems detected by the Ruby tooling (such as a problem
- * detected by the outliner, or a problem detected during a code completion)
+ * Ruby model transient problem marker type (value
+ * <code>"org.rubypeople.rdt.core.transient_problem"</code>). This can be
+ * used to recognize those markers in the workspace that flag transient
+ * problems detected by the Ruby tooling (such as a problem detected by the
+ * outliner, or a problem detected during a code completion)
*/
- public static final String TRANSIENT_PROBLEM = RubyCore.PLUGIN_ID + ".transient_problem"; //$NON-NLS-1$
+ public static final String TRANSIENT_PROBLEM = RubyCore.PLUGIN_ID
+ + ".transient_problem"; //$NON-NLS-1$
/**
- * Ruby model task marker type (value <code>"org.rubypeople.rdt.core.task"</code>).
- * This can be used to recognize task markers in the workspace that correspond to tasks
- * specified in Ruby source comments and detected during compilation (for example, 'TO-DO: ...').
- * Tasks are identified by a task tag, which can be customized through <code>RubyCore</code>
- * option <code>"org.rubypeople.rdt.core.compiler.taskTag"</code>.
+ * Ruby model task marker type (value
+ * <code>"org.rubypeople.rdt.core.task"</code>). This can be used to
+ * recognize task markers in the workspace that correspond to tasks
+ * specified in Ruby source comments and detected during compilation (for
+ * example, 'TO-DO: ...'). Tasks are identified by a task tag, which can be
+ * customized through <code>RubyCore</code> option
+ * <code>"org.rubypeople.rdt.core.compiler.taskTag"</code>.
+ *
* @since 2.1
*/
public static final String TASK_MARKER = RubyCore.PLUGIN_ID + ".task"; //$NON-NLS-1$
-
- /**
- * Id marker attribute (value <code>"arguments"</code>).
- * Arguments are concatenated into one String, prefixed with an argument count (followed with colon
- * separator) and separated with '#' characters. For example:
- * { "foo", "bar" } is encoded as "2:foo#bar",
- * { } is encoded as "0: "
- * @since 2.0
+
+ /**
+ * Id marker attribute (value <code>"arguments"</code>). Arguments are
+ * concatenated into one String, prefixed with an argument count (followed
+ * with colon separator) and separated with '#' characters. For example: {
+ * "foo", "bar" } is encoded as "2:foo#bar", { } is encoded as "0: "
+ *
+ * @since 0.9.0
*/
- public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
-
- /**
+ public static final String ARGUMENTS = "arguments"; //$NON-NLS-1$
+
+ /**
* Id marker attribute (value <code>"id"</code>).
*/
- public static final String ID = "id"; //$NON-NLS-1$
+ public static final String ID = "id"; //$NON-NLS-1$
+ // FIXME Rename to LOADPATH_FILE_FORMAT
+ /**
+ * Classpath file format marker attribute (value
+ * <code>"classpathFileFormat"</code>). Used only on buildpath problem
+ * markers. The value of this attribute is either "true" or "false".
+ *
+ * @since 0.9.0
+ */
+ String CLASSPATH_FILE_FORMAT = "classpathFileFormat"; //$NON-NLS-1$
+
+ /**
+ * Cycle detected marker attribute (value <code>"cycleDetected"</code>).
+ * Used only on buildpath problem markers. The value of this attribute is
+ * either "true" or "false".
+ */
+ String CYCLE_DETECTED = "cycleDetected"; //$NON-NLS-1$
+
+ /**
+ * Build path problem marker type (value
+ * <code>"org.rubypeople.rdt.core.buildpath_problem"</code>). This can be
+ * used to recognize those markers in the workspace that flag problems
+ * detected by the Ruby tooling during classpath setting.
+ */
+ String BUILDPATH_PROBLEM_MARKER = RubyCore.PLUGIN_ID + ".buildpath_problem"; //$NON-NLS-1$
+
+ /**
+ * ID category marker attribute (value <code>"categoryId"</code>)
+ * @since 0.9.0
+ */
+ String CATEGORY_ID = "categoryId"; //$NON-NLS-1$
+
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyModelStatusConstants.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -258,7 +258,7 @@
* be read/written successfully.
* @since 2.1
*/
- public static final int INVALID_CLASSPATH_FILE_FORMAT = 1000;
+ public static final int INVALID_LOADPATH_FILE_FORMAT = 1000;
/**
* Status indicating that a project is involved in a build path cycle.
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IRubyProject.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -24,13 +24,12 @@
*/
package org.rubypeople.rdt.core;
-import java.util.List;
import java.util.Map;
-import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
/**
@@ -41,14 +40,8 @@
public abstract IProject getProject();
- public abstract List getLoadPathEntries();
-
- public abstract List getReferencedProjects();
-
public String[] getRequiredProjectNames() throws RubyModelException;
- public abstract void save() throws CoreException;
-
/**
* Returns the first type found following this project's classpath with the
* given fully qualified name or <code>null</code> if none is found. The
@@ -109,18 +102,33 @@
public abstract IRubyScript[] getRubyScripts() throws RubyModelException;
public abstract Object[] getNonRubyResources() throws RubyModelException;
-
- public abstract boolean isOnLoadpath(IRubyScript element);
- public IRubyScript getRubyScript(IFile file);
+ public abstract ISourceFolder[] getSourceFolders() throws RubyModelException;
- public abstract ISourceFolder getSourceFolder(String[] names);
+ public abstract ISourceFolderRoot getSourceFolderRoot(IResource resource);
- public abstract ISourceFolder getSourceFolder(IResource resource);
+ public abstract ILoadpathEntry[] getRawLoadpath() throws RubyModelException;
- public abstract ISourceFolder[] getSourceFolders() throws RubyModelException;
+ public abstract ISourceFolderRoot[] getSourceFolderRoots() throws RubyModelException;
- public abstract ISourceFolder createSourceFolder(String packName,
- boolean force, IProgressMonitor monitor) throws RubyModelException;
+ public abstract boolean isOnLoadpath(IRubyElement element);
+
+ ILoadpathEntry[] getResolvedLoadpath(boolean ignoreUnresolvedEntry) throws RubyModelException;
+ public void setRawLoadpath(ILoadpathEntry[] newEntries,
+ IPath newOutputLocation,
+ IProgressMonitor monitor,
+ boolean canChangeResource,
+ ILoadpathEntry[] oldResolvedPath,
+ boolean needValidation,
+ boolean needSave)
+ throws RubyModelException;
+
+ void setRawLoadpath(ILoadpathEntry[] entries, boolean canModifyResources, IProgressMonitor monitor) throws RubyModelException;
+
+ void setRawLoadpath(ILoadpathEntry[] entries, IProgressMonitor monitor)
+ throws RubyModelException;
+
+ void setRawLoadpath(ILoadpathEntry[] entries, IPath outputLocation, IProgressMonitor monitor)
+ throws RubyModelException;
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolder.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -5,6 +5,14 @@
public interface ISourceFolder extends IRubyElement, IParent, IOpenable {
+ /**
+ * <p>
+ * The name of package fragment for the default package (value: the empty
+ * string, <code>""</code>).
+ * </p>
+ */
+ public static final String DEFAULT_PACKAGE_NAME = ""; //$NON-NLS-1$
+
/**
* Returns whether this fragment contains at least one Ruby resource.
* @return true if this fragment contains at least one Ruby resource, false otherwise
@@ -114,5 +122,6 @@
*/
Object[] getNonRubyResources() throws RubyModelException;
IRubyScript getRubyScript(String name);
+ boolean isDefaultPackage();
}
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/ISourceFolderRoot.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -0,0 +1,113 @@
+package org.rubypeople.rdt.core;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+
+public interface ISourceFolderRoot extends IParent, IRubyElement, IOpenable {
+ /**
+ * Returns whether this package fragment root is external
+ * to the workbench (that is, a local file), and has no
+ * underlying resource.
+ * <p>
+ * This is a handle-only method.
+ * </p>
+ *
+ * @return true if this package fragment root is external
+ * to the workbench (that is, a local file), and has no
+ * underlying resource, false otherwise
+ */
+ boolean isExternal();
+
+ /**
+ * Returns the package fragment with the given package name.
+ * An empty string indicates the default package.
+ * This is a handle-only operation. The package fragment
+ * may or may not exist.
+ *
+ * @param packageName the given package name
+ * @return the package fragment with the given package name
+ */
+ ISourceFolder getSourceFolder(String names[]);
+
+ /**
+ * Creates and returns a package fragment in this root with the
+ * given dot-separated package name. An empty string specifies the default package.
+ * This has the side effect of creating all package
+ * fragments that are a prefix of the new package fragment which
+ * do not exist yet. If the package fragment already exists, this
+ * has no effect.
+ *
+ * For a description of the <code>force</code> flag, see <code>IFolder.create</code>.
+ *
+ * @param name the given dot-separated package name
+ * @param force a flag controlling how to deal with resources that
+ * are not in sync with the local file system
+ * @param monitor the given progress monitor
+ * @exception JavaModelException if the element could not be created. Reasons include:
+ * <ul>
+ * <li> This Java element does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> A <code>CoreException</code> occurred while creating an underlying resource
+ * <li> This package fragment root is read only (READ_ONLY)
+ * <li> The name is not a valid package name (INVALID_NAME)
+ * </ul>
+ * @return a package fragment in this root with the given dot-separated package name
+ * @see org.eclipse.core.resources.IFolder#create(boolean, boolean, IProgressMonitor)
+ */
+ ISourceFolder createSourceFolder(
+ String name,
+ boolean force,
+ IProgressMonitor monitor)
+ throws RubyModelException;
+
+ /**
+ * Deletes the resource of this package fragment root as specified by
+ * <code>IResource.delete(int, IProgressMonitor)</code> but excluding nested
+ * source folders.
+ * <p>
+ * If <code>NO_RESOURCE_MODIFICATION</code> is specified in
+ * <code>updateModelFlags</code> or if this package fragment root is external,
+ * this operation doesn't delete the resource. <code>updateResourceFlags</code>
+ * is then ignored.
+ * </p><p>
+ * If <code>ORIGINATING_PROJECT_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, update the raw classpath of this package
+ * fragment root's project by removing the corresponding classpath entry.
+ * </p><p>
+ * If <code>OTHER_REFERRING_PROJECTS_CLASSPATH</code> is specified in
+ * <code>updateModelFlags</code>, update the raw classpaths of all other Java
+ * projects referring to this root's resource by removing the corresponding classpath
+ * entries.
+ * </p><p>
+ * If no flags is specified in <code>updateModelFlags</code> (using
+ * <code>IResource.NONE</code>), the default behavior applies: the
+ * resource is deleted (if this package fragment root is not external) and no
+ * classpaths are updated.
+ * </p>
+ *
+ * @param updateResourceFlags bit-wise or of update resource flag constants
+ * (<code>IResource.FORCE</code> and <code>IResource.KEEP_HISTORY</code>)
+ * @param updateModelFlags bit-wise or of update resource flag constants
+ * (<code>ORIGINATING_PROJECT_CLASSPATH</code>,
+ * <code>OTHER_REFERRING_PROJECTS_CLASSPATH</code> and
+ * <code>NO_RESOURCE_MODIFICATION</code>)
+ * @param monitor a progress monitor
+ *
+ * @exception JavaModelException if this root could not be deleted. Reasons
+ * include:
+ * <ul>
+ * <li> This root does not exist (ELEMENT_DOES_NOT_EXIST)</li>
+ * <li> A <code>CoreException</code> occurred while deleting the resource
+ * or updating a classpath
+ * </li>
+ * </ul>
+ * @see org.eclipse.core.resources.IResource#delete(boolean, IProgressMonitor)
+ * @since 2.1
+ */
+ void delete(int updateResourceFlags, int updateModelFlags, IProgressMonitor monitor) throws RubyModelException;
+
+ boolean isArchive();
+
+ Object[] getNonRubyResources() throws RubyModelException;
+
+ ISourceFolder getSourceFolder(String packName);
+
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IType.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -172,4 +172,6 @@
public IMethod createMethod(String contents, IRubyElement sibling, boolean force,
IProgressMonitor progress) throws RubyModelException;
+ public ISourceFolder getSourceFolder();
+
}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathContainerInitializer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathContainerInitializer.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathContainerInitializer.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -0,0 +1,196 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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
+ * IBM Corporation - added support for requesting updates of a particular
+ * container for generic container operations.
+ * - canUpdateClasspathContainer(IPath, IJavaProject)
+ * - requestClasspathContainerUpdate(IPath, IJavaProject, IClasspathContainer)
+ * IBM Corporation - allow initializers to provide a readable description
+ * of a container reference, ahead of actual resolution.
+ * - getDescription(IPath, IJavaProject)
+ *******************************************************************************/
+package org.rubypeople.rdt.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Abstract base implementation of all classpath container initializer.
+ * Classpath variable containers are used in conjunction with the
+ * "org.eclipse.jdt.core.classpathContainerInitializer" extension point.
+ * <p>
+ * Clients should subclass this class to implement a specific classpath
+ * container initializer. The subclass must have a public 0-argument
+ * constructor and a concrete implementation of <code>initialize</code>.
+ * <p>
+ * Multiple classpath containers can be registered, each of them declares
+ * the container ID they can handle, so as to narrow the set of containers they
+ * can resolve, in other words, a container initializer is guaranteed to only be
+ * activated to resolve containers which match the ID they registered onto.
+ * <p>
+ * In case multiple container initializers collide on the same container ID, the first
+ * registered one will be invoked.
+ *
+ * @see IClasspathEntry
+ * @see IClasspathContainer
+ * @since 2.0
+ */
+public abstract class LoadpathContainerInitializer {
+
+ /**
+ * Creates a new classpath container initializer.
+ */
+ public LoadpathContainerInitializer() {
+ // a classpath container initializer must have a public 0-argument constructor
+ }
+
+ /**
+ * Binds a classpath container to a <code>IClasspathContainer</code> for a given project,
+ * or silently fails if unable to do so.
+ * <p>
+ * A container is identified by a container path, which must be formed of two segments.
+ * The first segment is used as a unique identifier (which this initializer did register onto), and
+ * the second segment can be used as an additional hint when performing the resolution.
+ * <p>
+ * The initializer is invoked if a container path needs to be resolved for a given project, and no
+ * value for it was recorded so far. The implementation of the initializer would typically set the
+ * corresponding container using <code>JavaCore#setClasspathContainer</code>.
+ * <p>
+ * A container initialization can be indirectly performed while attempting to resolve a project
+ * classpath using <code>IJavaProject#getResolvedClasspath(</code>; or directly when using
+ * <code>JavaCore#getClasspathContainer</code>. During the initialization process, any attempt
+ * to further obtain the same container will simply return <code>null</code> so as to avoid an
+ * infinite regression of initializations.
+ * <p>
+ * A container initialization may also occur indirectly when setting a project classpath, as the operation
+ * needs to resolve the classpath for validation purpose. While the operation is in progress, a referenced
+ * container initializer may be invoked. If the initializer further tries to access the referring project classpath,
+ * it will not see the new assigned classpath until the operation has completed. Note that once the Java
+ * change notification occurs (at the end of the operation), the model has been updated, and the project
+ * classpath can be queried normally.
+ * <p>
+ * This method is called by the Java model to give the party that defined
+ * this particular kind of classpath container the chance to install
+ * classpath container objects that will be used to convert classpath
+ * container entries into simpler classpath entries. The method is typically
+ * called exactly once for a given Java project and classpath container
+ * entry. This method must not be called by other clients.
+ * <p>
+ * There are a wide variety of conditions under which this method may be
+ * invoked. To ensure that the implementation does not interfere with
+ * correct functioning of the Java model, the implementation should use
+ * only the following Java model APIs:
+ * <ul>
+ * <li>{@link JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)}</li>
+ * <li>{@link JavaCore#getClasspathContainer(IPath, IJavaProject)}</li>
+ * <li>{@link JavaCore#create(org.eclipse.core.resources.IWorkspaceRoot)}</li>
+ * <li>{@link JavaCore#create(org.eclipse.core.resources.IProject)}</li>
+ * <li>{@link IJavaModel#getJavaProjects()}</li>
+ * <li>Java element operations marked as "handle-only"</li>
+ * </ul>
+ * The effects of using other Java model APIs are unspecified.
+ * </p>
+ *
+ * @param containerPath a two-segment path (ID/hint) identifying the container that needs
+ * to be resolved
+ * @param project the Java project in which context the container is to be resolved.
+ * This allows generic containers to be bound with project specific values.
+ * @throws CoreException if an exception occurs during the initialization
+ *
+ * @see JavaCore#getClasspathContainer(IPath, IJavaProject)
+ * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)
+ * @see IClasspathContainer
+ */
+ public abstract void initialize(IPath containerPath, IRubyProject project) throws CoreException;
+
+ /**
+ * Returns <code>true</code> if this container initializer can be requested to perform updates
+ * on its own container values. If so, then an update request will be performed using
+ * <code>ClasspathContainerInitializer#requestClasspathContainerUpdate</code>/
+ * <p>
+ * @param containerPath the path of the container which requires to be updated
+ * @param project the project for which the container is to be updated
+ * @return returns <code>true</code> if the container can be updated
+ * @since 2.1
+ */
+ public boolean canUpdateClasspathContainer(IPath containerPath, IRubyProject project) {
+
+ // By default, classpath container initializers do not accept updating containers
+ return false;
+ }
+
+ /**
+ * Request a registered container definition to be updated according to a container suggestion. The container suggestion
+ * only acts as a place-holder to pass along the information to update the matching container definition(s) held by the
+ * container initializer. In particular, it is not expected to store the container suggestion as is, but rather adjust
+ * the actual container definition based on suggested changes.
+ * <p>
+ * IMPORTANT: In reaction to receiving an update request, a container initializer will update the corresponding
+ * container definition (after reconciling changes) at its earliest convenience, using
+ * <code>JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], IProgressMonitor)</code>.
+ * Until it does so, the update will not be reflected in the Java Model.
+ * <p>
+ * In order to anticipate whether the container initializer allows to update its containers, the predicate
+ * <code>JavaCore#canUpdateClasspathContainer</code> should be used.
+ * <p>
+ * @param containerPath the path of the container which requires to be updated
+ * @param project the project for which the container is to be updated
+ * @param containerSuggestion a suggestion to update the corresponding container definition
+ * @throws CoreException when <code>JavaCore#setClasspathContainer</code> would throw any.
+ * @see JavaCore#setClasspathContainer(IPath, IJavaProject[], IClasspathContainer[], org.eclipse.core.runtime.IProgressMonitor)
+ * @see ClasspathContainerInitializer#canUpdateClasspathContainer(IPath, IJavaProject)
+ * @since 2.1
+ */
+ public void requestClasspathContainerUpdate(IPath containerPath, IRubyProject project, ILoadpathContainer containerSuggestion) throws CoreException {
+
+ // By default, classpath container initializers do not accept updating containers
+ }
+
+ /**
+ * Returns a readable description for a container path. A readable description for a container path can be
+ * used for improving the display of references to container, without actually needing to resolve them.
+ * A good implementation should answer a description consistent with the description of the associated
+ * target container (see <code>IClasspathContainer.getDescription()</code>).
+ *
+ * @param containerPath the path of the container which requires a readable description
+ * @param project the project from which the container is referenced
+ * @return a string description of the container
+ * @since 2.1
+ */
+ public String getDescription(IPath containerPath, IRubyProject project) {
+
+ // By default, a container path is the only available description
+ return containerPath.makeRelative().toString();
+ }
+
+ /**
+ * Returns an object which identifies a container for comparison purpose. This allows
+ * to eliminate redundant containers when accumulating classpath entries (e.g.
+ * runtime classpath computation). When requesting a container comparison ID, one
+ * should ensure using its corresponding container initializer. Indeed, a random container
+ * initializer cannot be held responsible for determining comparison IDs for arbitrary
+ * containers.
+ * <p>
+ * @param containerPath the path of the container which is being checked
+ * @param project the project for which the container is to being checked
+ * @return returns an Object identifying the container for comparison
+ * @since 3.0
+ */
+ public Object getComparisonID(IPath containerPath, IRubyProject project) {
+
+ // By default, containers are identical if they have the same containerPath first segment,
+ // but this may be refined by other container initializer implementations.
+ if (containerPath == null) {
+ return null;
+ } else {
+ return containerPath.segment(0);
+ }
+ }
+}
+
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathVariableInitializer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathVariableInitializer.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/LoadpathVariableInitializer.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -0,0 +1,52 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 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.core;
+
+/**
+ * Abstract base implementation of all classpath variable initializers.
+ * Classpath variable initializers are used in conjunction with the
+ * "org.eclipse.jdt.core.classpathVariableInitializer" extension point.
+ * <p>
+ * Clients should subclass this class to implement a specific classpath
+ * variable initializer. The subclass must have a public 0-argument
+ * constructor and a concrete implementation of <code>initialize</code>.
+ *
+ * @see ILoadpathEntry
+ * @since 2.0
+ */
+public abstract class LoadpathVariableInitializer {
+
+ /**
+ * Creates a new classpath variable initializer.
+ */
+ public LoadpathVariableInitializer() {
+ // a classpath variable initializer must have a public 0-argument constructor
+ }
+
+ /**
+ * Binds a value to the workspace classpath variable with the given name,
+ * or fails silently if this cannot be done.
+ * <p>
+ * A variable initializer is automatically activated whenever a variable value
+ * is needed and none has been recorded so far. The implementation of
+ * the initializer can set the corresponding variable using
+ * <code>JavaCore#setLoadpathVariable</code>.
+ *
+ * @param variable the name of the workspace classpath variable
+ * that requires a binding
+ *
+ * @see JavaCore#getLoadpathVariable(String)
+ * @see JavaCore#setLoadpathVariable(String, org.eclipse.core.runtime.IPath, org.eclipse.core.runtime.IProgressMonitor)
+ * @see JavaCore#setLoadpathVariables(String[], org.eclipse.core.runtime.IPath[], org.eclipse.core.runtime.IProgressMonitor)
+ */
+ public abstract void initialize(String variable);
+}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyConventions.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -7,6 +7,7 @@
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.jruby.javasupport.JavaMethod;
import org.rubypeople.rdt.internal.core.RubyModelStatus;
import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
@@ -102,4 +103,9 @@
}
return true;
}
+
+ public static IStatus validateSourceFolderName(String packName) {
+ // TODO Actually do some validation
+ return RubyModelStatus.VERIFIED_OK;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-01-05 13:44:00 UTC (rev 1752)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-01-05 15:49:09 UTC (rev 1753)
@@ -13,6 +13,7 @@
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
@@ -25,7 +26,12 @@
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
@@ -37,12 +43,11 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.rubypeople.rdt.internal.core.BatchOperation;
-import org.rubypeople.rdt.internal.core.DefaultWorkingCopyOwner;
+import org.rubypeople.rdt.internal.core.LoadpathEntry;
import org.rubypeople.rdt.internal.core.RubyCorePreferenceInitializer;
import org.rubypeople.rdt.internal.core.RubyModel;
import org.rubypeople.rdt.internal.core.RubyModelManager;
import org.rubypeople.rdt.internal.core.RubyProject;
-import org.rubypeople.rdt.internal.core.RubyScript;
import org.rubypeople.rdt.internal.core.SymbolIndexResourceChangeListener;
import org.rubypeople.rdt.internal.core.builder.IndexUpdater;
import org.rubypeople.rdt.internal.core.builder.MassIndexUpdaterJob;
@@ -274,8 +279,35 @@
* @since 0.9.0
*/
public static final String CODEASSIST_CAMEL_CASE_MATCH = PLUGIN_ID + ".codeComplete.camelCaseMatch"; //$NON-NLS-1$
+
+ // FIXME Rename to CORE_INCOMPLETE_LOADPATH
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions()
+ * @since 0.9.0
+ */
+ public static final String CORE_INCOMPLETE_CLASSPATH = PLUGIN_ID + ".incompleteClasspath"; //$NON-NLS-1$
+
+ // FIXME Rename to CORE_INCOMPATIBLE_RUBY_VERSION
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions()
+ * @since 3.0
+ */
+ public static final String CORE_INCOMPATIBLE_JDK_LEVEL = PLUGIN_ID + ".incompatibleJDKLevel"; //$NON-NLS-1$
+ // FIXME Rename to CORE_CIRCULAR_LOADPATH
+ /**
+ * Possible configurable option ID.
+ * @see #getDefaultOptions()
+ * @since 2.1
+ */
+ public static final String CORE_CIRCULAR_CLASSPATH = PLUGIN_ID + ".circularClasspath"; //$NON-NLS-1$
+ private static final boolean VERBOSE = false;
+
+
+
private SymbolIndex symbolIndex;
private ISymbolFinder symbolFinder;
@@ -433,21 +465,10 @@
return false;
}
- public static IRubyScript create(IFile aFile) {
- return create(aFile, null);
+ public static IRubyScript create(IFile file) {
+ return RubyModelManager.create(file, null/*unknown ruby project*/);
}
- public static IRubyScript create(IFile file, IRubyProject project) {
- if (project == null) {
- project = create(file.getProject());
- }
- if(isRubyLikeFileName(file.getName())) {
- return new RubyScript((RubyProject) project, file, file.getName(),
- DefaultWorkingCopyOwner.PRIMARY);
- }
- return null;
- }
-
public static IRubyProject create(IProject project) {
if (project == null) { return null; }
RubyModel rubyModel = RubyModelManager.getRubyModelManager().getRubyModel();
@@ -681,4 +702,401 @@
public static boolean isRubyLikeFileName(String name) {
return Util.isRubyLikeFileName(name);
}
+
+ /**
+ * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
+ * for all files in the project's source folder identified by the given
+ * absolute workspace-relative path.
+ * <p>
+ * The convenience method is fully equivalent to:
+ * <pre>
+ * newSourceEntry(path, new IPath[] {}, new IPath[] {}, null);
+ * </pre>
+ * </p>
+ *
+ * @param path the absolute workspace-relative path of a source folder
+ * @return a new source classpath entry
+ * @see #newSourceEntry(IPath, IPath[], IPath[])
+ */
+ public static ILoadpathEntry newSourceEntry(IPath path) {
+
+ return newSourceEntry(path, LoadpathEntry.INCLUDE_ALL, LoadpathEntry.EXCLUDE_NONE);
+ }
+
+ /**
+ * Creates and returns a new classpath entry of kind <code>CPE_SOURCE</code>
+ * for the project's source folder identified by the given absolute
+ * workspace-relative path but excluding all source files with paths
+ * matching any of the given patterns, and associated with a specific output location
+ * (that is, ".class" files are not going to the project default output location).
+ * <p>
+ * The convenience method is fully equivalent to:
+ * <pre>
+ * newSourceEntry(path, new IPath[] {}, exclusionPatterns);
+ * </pre>
+ * </p>
+ *
+ * @param path the absolute workspace-relative path of a source folder
+ * @param inclusionPatterns the possibly empty list of inclusion patterns
+ * represented as relative paths
+ * @param exclusionPatterns the possibly empty list of exclusion patterns
+ * represented as relative paths
+ * @return a new source classpath entry
+ * @since 3.0
+ */
+ public static ILoadpathEntry newSourceEntry(IPath path, IPath[] inclusionPatterns, IPath[] exclusionPatterns) {
+ if (path == null) Assert.isTrue(false, "Source path cannot be null"); //$NON-NLS-1$
+ if (!path.isAbsolute()) Assert.isTrue(false, "Path for ILoadpathEntry must be absolute"); //$NON-NLS-1$
+ if (exclusionPatterns == null) Assert.isTrue(false, "Exclusion pattern set cannot be null"); //$NON-NLS-1$
+ if (inclusionPatterns == null) Assert.isTrue(false, "Inclusion pattern set cannot be null"); //$NON-NLS-1$
+
+ return new LoadpathEntry(
+ ILoadpathEntry.CPE_SOURCE,
+ path,
+ inclusionPatterns,
+ exclusionPatterns,
+ false);
+ }
+
+ public static ILoadpathEntry newLibraryEntry(IPath path, boolean isExported) {
+
+ if (path == null) Assert.isTrue(false, "Library path cannot be null"); //$NON-NLS-1$
+ if (!path.isAbsolute()) Assert.isTrue(false, "Path for ILoadpathEntry must be absolute"); //$NON-NLS-1$
+
+ return new LoadpathEntry(
+ ILoadpathEntry.CPE_LIBRARY,
+ RubyProject.canonicalizedPath(path),
+ LoadpathEntry.INCLUDE_ALL, // inclusion patterns
+ LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ isExported);
+
+ }
+
+ public static ILoadpathEntry newProjectEntry(IPath path, boolean isExported) {
+ if (!path.isAbsolute()) Assert.isTrue(false, "Path for ILoadpathEntry must be absolute"); //$NON-NLS-1$
+
+ return new LoadpathEntry(
+ ILoadpathEntry.CPE_PROJECT,
+ path,
+ LoadpathEntry.INCLUDE_ALL, // inclusion patterns
+ LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ isExported);
+ }
+
+ public static ILoadpathEntry newVariableEntry(IPath variablePath, boolean isExported) {
+ if (variablePath == null) Assert.isTrue(false, "Variable path cannot be null"); //$NON-NLS-1$
+ if (variablePath.segmentCount() < 1) {
+ Assert.isTrue(
+ false,
+ "Illegal loadpath variable path: \'" + variablePath.makeRelative().toString() + "\', must have at least one segment"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+
+ return new LoadpathEntry(
+ ILoadpathEntry.CPE_VARIABLE,
+ variablePath,
+ LoadpathEntry.INCLUDE_ALL, // inclusion patterns
+ LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ isExported);
+ }
+
+ public static ILoadpathEntry newContainerEntry(IPath containerPath,
+ boolean isExported) {
+ if (containerPath == null) {
+ Assert.isTrue(false, "Container path cannot be null"); //$NON-NLS-1$
+ } else if (containerPath.segmentCount() < 1) {
+ Assert.isTrue(
+ false,
+ "Illegal loadpath container path: \'" + containerPath.makeRelative().toString() + "\', must have at least one segment (containerID+hints)"); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ return new LoadpathEntry(
+ ILoadpathEntry.CPE_CONTAINER,
+ containerPath,
+ LoadpathEntry.INCLUDE_ALL, // inclusion patterns
+ LoadpathEntry.EXCLUDE_NONE, // exclusion patterns
+ isExported);
+ }
+
+ public static ILoadpathEntry getResolvedLoadpathEntry(
+ ILoadpathEntry entry) {
+ if (entry.getEntryKind() != ILoadpathEntry.CPE_VARIABLE)
+ return entry;
+
+ IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot();
+ IPath resolvedPath = RubyCore.getResolvedVariablePath(entry.getPath());
+ if (resolvedPath == null)
+ return null;
+
+ Object target = RubyModel.getTarget(workspaceRoot, resolvedPath, false);
+ if (target == null)
+ return null;
+
+ // inside the workspace
+ if (target instanceof IResource) {
+ IResource resolvedResource = (IResource) target;
+ if (resolvedResource != null) {
+ switch (resolvedResource.getType()) {
+
+ case IResource.PROJECT :
+ // internal project
+ return RubyCore.newProjectEntry(
+ resolvedPath,
+ entry.isExported());
+ case IResource.FOLDER :
+ // internal binary folder
+ return RubyCore.newLibraryEntry(
+ resolvedPath,
+ entry.isExported());
+ }
+ }
+ }
+ // outside the workspace
+ if (target instanceof File) {
+ File externalFile = RubyModel.getFile(target);
+ if (externalFile != null) {
+ return RubyCore.newLibraryEntry(resolvedPath, entry.isExported());
+ } else { // external binary folder
+ if (resolvedPath.isAbsolute()){
+ return RubyCore.newLibraryEntry(resolvedPath, entry.isExported());
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Resolve a variable path (helper method).
+ *
+ * @param variablePath the given variable path
+ * @return the resolved variable path or <code>null</code> if none
+ */
+ public static IPath getResolvedVariablePath(IPath variablePath) {
+
+ if (variablePath == null)
+ return null;
+ int count = variablePath.segmentCount();
+ if (count == 0)
+ return null;
+
+ // lookup variable
+ String variableName = variablePath.segment(0);
+ IPath resolvedPath = RubyCore.getLoadpathVariable(variableName);
+ if (res...
[truncated message content] |
|
From: <caw...@us...> - 2007-01-05 13:44:02
|
Revision: 1752
http://svn.sourceforge.net/rubyeclipse/?rev=1752&view=rev
Author: cawilliams
Date: 2007-01-05 05:44:00 -0800 (Fri, 05 Jan 2007)
Log Message:
-----------
apply Martin Krauskopf's patch to avoid ConcurrentModificationExceptions (Ticket #221)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java 2007-01-04 21:14:02 UTC (rev 1751)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/parsing/MultiReaderStrategy.java 2007-01-05 13:44:00 UTC (rev 1752)
@@ -2,9 +2,9 @@
import java.io.IOException;
import java.net.SocketException;
-import java.util.Hashtable;
+import java.util.HashMap;
import java.util.Iterator;
-import java.util.Vector;
+import java.util.Map;
import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.xmlpull.v1.XmlPullParser;
@@ -12,14 +12,12 @@
public class MultiReaderStrategy extends AbstractReadStrategy {
- private Vector streamReaders;
- private Hashtable threads;
+ private Map<XmlStreamReader, Thread> threads;
private XmlStreamReader currentReader;
public MultiReaderStrategy(XmlPullParser xpp) {
super(xpp);
- streamReaders = new Vector();
- threads = new Hashtable();
+ threads = new HashMap<XmlStreamReader, Thread>();
new Thread("xml reader") {
public void run() {
@@ -37,7 +35,7 @@
Thread.sleep(1000) ; // Avoid Commodfication Exceptions
} catch (InterruptedException e) {
}
- releaseAllReader() ;
+ releaseAllReaders();
}
}
@@ -93,10 +91,9 @@
}
} while (currentReader == null && missed < 10);
}
-
- private synchronized void findReaderForTag() throws XmlStreamReaderException {
- for (Iterator iter = streamReaders.iterator(); iter.hasNext();) {
- XmlStreamReader streamReader = (XmlStreamReader) iter.next();
+
+ private synchronized void findReaderForTag() throws XmlStreamReaderException {
+ for (XmlStreamReader streamReader : threads.keySet()) {
if (streamReader.processStartElement(xpp)) {
currentReader = streamReader;
break;
@@ -104,23 +101,20 @@
}
}
- protected synchronized void releaseAllReader() {
- for (Iterator iter = streamReaders.iterator(); iter.hasNext();) {
- XmlStreamReader streamReader = (XmlStreamReader) iter.next();
- ((Thread) threads.get(streamReader)).interrupt();
- iter.remove() ;
- }
- threads.clear() ;
+ protected void releaseAllReaders() {
+ for (Iterator<Map.Entry<XmlStreamReader, Thread>> iter = threads.entrySet().iterator(); iter.hasNext();) {
+ Thread thread = iter.next().getValue();
+ thread.interrupt();
+ iter.remove();
+ }
}
protected synchronized void removeReader(XmlStreamReader streamReader) {
- ((Thread) threads.get(streamReader)).interrupt();
+ threads.get(streamReader).interrupt();
threads.remove(streamReader);
- streamReaders.remove(streamReader);
}
protected synchronized void addReader(XmlStreamReader streamReader) {
- streamReaders.add(streamReader);
threads.put(streamReader, Thread.currentThread());
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2007-01-04 21:14:07
|
Revision: 1751
http://svn.sourceforge.net/rubyeclipse/?rev=1751&view=rev
Author: mbarchfe
Date: 2007-01-04 13:14:02 -0800 (Thu, 04 Jan 2007)
Log Message:
-----------
bin.includes: more general pattern for gem
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/build.properties
Modified: trunk/org.rubypeople.rdt.launching/build.properties
===================================================================
--- trunk/org.rubypeople.rdt.launching/build.properties 2006-12-30 09:49:57 UTC (rev 1750)
+++ trunk/org.rubypeople.rdt.launching/build.properties 2007-01-04 21:14:02 UTC (rev 1751)
@@ -3,7 +3,7 @@
ruby/*,\
launching.jar,\
.options,\
- ruby-debug-0.5.gem
+ *.gem
plugin = org.rubypeople.rdt.launching
plugin.name = launching
plugin.classpath = ../org.eclipse.core.runtime/runtime.jar;../org.eclipse.core.resources/resources.jar;../org.eclipse.core.boot/boot.jar;../org.eclipse.debug.core/dtcore.jar;../org.eclipse.ui/workbench.jar;../org.apache.xerces/xmlParserAPIs.jar;../org.rubypeople.rdt.core/bin;../org.rubypeople.rdt.debug.core/bin;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-12-30 09:49:58
|
Revision: 1750
http://svn.sourceforge.net/rubyeclipse/?rev=1750&view=rev
Author: mbarchfe
Date: 2006-12-30 01:49:57 -0800 (Sat, 30 Dec 2006)
Log Message:
-----------
new ruby debug gem
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/ruby-debug-0.6.gem
Removed Paths:
-------------
trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem
Deleted: trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem
===================================================================
(Binary files differ)
Added: trunk/org.rubypeople.rdt.launching/ruby-debug-0.6.gem
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.launching/ruby-debug-0.6.gem
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-12-30 09:44:45
|
Revision: 1749
http://svn.sourceforge.net/rubyeclipse/?rev=1749&view=rev
Author: mbarchfe
Date: 2006-12-30 01:44:44 -0800 (Sat, 30 Dec 2006)
Log Message:
-----------
next step for ruby debug integration
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/PreferenceConstants.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2006-12-30 09:44:19 UTC (rev 1748)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/DebuggerRunner.java 2006-12-30 09:44:44 UTC (rev 1749)
@@ -13,79 +13,79 @@
import org.rubypeople.rdt.internal.debug.core.RdtDebugCorePlugin;
import org.rubypeople.rdt.internal.debug.core.RubyDebuggerProxy;
import org.rubypeople.rdt.internal.debug.core.model.RubyDebugTarget;
+import org.rubypeople.rdt.launching.IInterpreter;
public class DebuggerRunner extends InterpreterRunner {
private RubyDebugTarget debugTarget;
- public IProcess run(InterpreterRunnerConfiguration configuration,
- ILaunch launch) throws CoreException {
+ public IProcess run(InterpreterRunnerConfiguration configuration, ILaunch launch) throws CoreException {
debugTarget = new RubyDebugTarget(launch);
IProcess process = super.run(configuration, launch);
debugTarget.setProcess(process);
RubyDebuggerProxy proxy = new RubyDebuggerProxy(debugTarget, isUseRubyDebug());
if (proxy.checkConnection()) {
- proxy.start();
- launch.addDebugTarget(debugTarget);
+ try {
+ if (isUseRubyDebug()) {
+ String pathToRdebugExtension = getDirectoryOfRubyDebuggerFile() + "/rdebugExtension.rb";
+ proxy.registerRdebugExtension(pathToRdebugExtension);
+ }
+ proxy.start();
+ launch.addDebugTarget(debugTarget);
+ } catch (Exception e) {
+ RdtLaunchingPlugin.log(new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, e.getMessage(), e));
+ debugTarget.terminate();
+ }
} else {
- RdtLaunchingPlugin
- .log(new Status(
- IStatus.ERROR,
- RdtLaunchingPlugin.PLUGIN_ID,
- IStatus.ERROR,
- RdtLaunchingMessages.RdtLaunchingPlugin_processTerminatedBecauseNoDebuggerConnection,
- null));
+ RdtLaunchingPlugin.log(new Status(IStatus.ERROR, RdtLaunchingPlugin.PLUGIN_ID, IStatus.ERROR, RdtLaunchingMessages.RdtLaunchingPlugin_processTerminatedBecauseNoDebuggerConnection, null));
debugTarget.terminate();
}
return process;
}
- protected void addDebugCommandLineArgument(List commandLine) {
+ protected void addDebugCommandLineArgument(List<String> commandLine) {
if (isUseRubyDebug()) {
commandLine.add("--server");
commandLine.add("--port");
commandLine.add(Integer.toString(debugTarget.getPort()));
commandLine.add("--cport");
- commandLine.add(Integer.toString(debugTarget.getPort()+1));
+ commandLine.add(Integer.toString(debugTarget.getPort() + 1));
commandLine.add("-w");
- commandLine.add("-d");
+ if (isDebuggerVerbose()) {
+ commandLine.add("-d");
+ }
commandLine.add("-f");
commandLine.add("xml");
} else {
if (!debugTarget.isUsingDefaultPort()) {
- commandLine
- .add("-r"
- + debugTarget.getDebugParameterFile()
- .getAbsolutePath());
+ commandLine.add("-r" + debugTarget.getDebugParameterFile().getAbsolutePath());
}
- if (RdtDebugCorePlugin.isRubyDebuggerVerbose()) {
+ if (RdtDebugCorePlugin.isRubyDebuggerVerbose() || isDebuggerVerbose()) {
commandLine.add("-reclipseDebugVerbose");
} else {
commandLine.add("-reclipseDebug");
}
commandLine.add("-I");
- commandLine.add(RdtLaunchingPlugin.osDependentPath(DebuggerRunner
- .getDirectoryOfRubyDebuggerFile().replace('/',
- File.separatorChar)));
+ commandLine.add(RdtLaunchingPlugin.osDependentPath(DebuggerRunner.getDirectoryOfRubyDebuggerFile().replace('/', File.separatorChar)));
}
}
public static String getDirectoryOfRubyDebuggerFile() {
- return RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault())
- + "ruby";
+ return RubyCore.getOSDirectory(RdtLaunchingPlugin.getDefault()) + "ruby";
}
public boolean isUseRubyDebug() {
- // TODO: use PrefernceConstants ?
- return RdtLaunchingPlugin.getDefault().getPluginPreferences().getBoolean(
- "useRubyDebug");
+ return RdtLaunchingPlugin.getDefault().getPluginPreferences().getBoolean(PreferenceConstants.USE_RUBY_DEBUG);
}
+
+ public boolean isDebuggerVerbose() {
+ return RdtLaunchingPlugin.getDefault().getPluginPreferences().getBoolean(PreferenceConstants.VERBOSE_DEBUGGER);
+ }
- protected RubyInterpreter convertInterpreter(RubyInterpreter rubyInterpreter) {
+ protected IInterpreter convertInterpreter(IInterpreter rubyInterpreter) {
if (isUseRubyDebug()) {
- IPath rdebugLocation = rubyInterpreter.getInstallLocation()
- .removeLastSegments(1);
+ IPath rdebugLocation = rubyInterpreter.getInstallLocation().removeLastSegments(1);
rdebugLocation = rdebugLocation.append("rdebug");
return new RubyInterpreter("rdebug", rdebugLocation);
} else {
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java 2006-12-30 09:44:19 UTC (rev 1748)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunner.java 2006-12-30 09:44:44 UTC (rev 1749)
@@ -50,7 +50,7 @@
}
private List renderCommandLine(InterpreterRunnerConfiguration configuration) {
- List commandLine = new ArrayList();
+ List<String> commandLine = new ArrayList<String>();
addDebugCommandLineArgument(commandLine);
commandLine.addAll(configuration.renderLoadPath());
@@ -63,7 +63,7 @@
}
- protected void addDebugCommandLineArgument(List commandLine) {
+ protected void addDebugCommandLineArgument(List<String> commandLine) {
}
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java 2006-12-30 09:44:19 UTC (rev 1748)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/InterpreterRunnerConfiguration.java 2006-12-30 09:44:44 UTC (rev 1749)
@@ -100,20 +100,20 @@
return RubyRuntime.getDefault().getInterpreter(selectedInterpreter);
}
- protected void addToLoadPath(List loadPath, IProject project) {
+ protected void addToLoadPath(List<String> loadPath, IProject project) {
if (!project.isAccessible()) {
return ;
}
addToLoadPath(loadPath, project.getLocation().toOSString());
}
- private void addToLoadPath(List loadPath, String pathDirectory) {
+ private void addToLoadPath(List<String> loadPath, String pathDirectory) {
loadPath.add("-I");
loadPath.add(RdtLaunchingPlugin.osDependentPath(pathDirectory));
}
- protected List renderLoadPath() {
- List loadPath = new ArrayList();
+ protected List<String> renderLoadPath() {
+ List<String> loadPath = new ArrayList<String>();
RubyProject project = this.getProject();
addToLoadPath(loadPath, project.getProject());
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/PreferenceConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/PreferenceConstants.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/PreferenceConstants.java 2006-12-30 09:44:44 UTC (rev 1749)
@@ -0,0 +1,6 @@
+package org.rubypeople.rdt.internal.launching;
+
+public class PreferenceConstants {
+ public final static String USE_RUBY_DEBUG = "useRubyDebug";
+ public final static String VERBOSE_DEBUGGER = "verboseDebugger";
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-12-30 09:44:21
|
Revision: 1748
http://svn.sourceforge.net/rubyeclipse/?rev=1748&view=rev
Author: mbarchfe
Date: 2006-12-30 01:44:19 -0800 (Sat, 30 Dec 2006)
Log Message:
-----------
next step for ruby debug integration
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/ruby/eclipseDebug.rb
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/ruby/rdebugExtension.rb
Modified: trunk/org.rubypeople.rdt.launching/ruby/eclipseDebug.rb
===================================================================
--- trunk/org.rubypeople.rdt.launching/ruby/eclipseDebug.rb 2006-12-30 09:43:55 UTC (rev 1747)
+++ trunk/org.rubypeople.rdt.launching/ruby/eclipseDebug.rb 2006-12-30 09:44:19 UTC (rev 1748)
@@ -18,11 +18,11 @@
def initialize
@printers = []
end
-
+
def addPrinter(printer)
@printers << printer
end
-
+
def method_missing(methodName, *args)
@printers.each { |printer|
printer.send(methodName, *args)
@@ -33,22 +33,26 @@
class XmlPrinter
-
+
def initialize(socket)
@socket = socket
end
-
+
def out(*params)
debugIntern(false, *params)
if @socket then
@socket.printf(*params)
end
end
-
+
def printXml(s, *params)
out(s, *params)
end
-
+
+ def printError(s, *params)
+ out("<error>" + s + "</error>", *params)
+ end
+
def printVariable(name, binding, kind)
printVariableValue(name, eval(name, binding), kind)
end
@@ -66,27 +70,27 @@
valueString = value.class().name + " (" + value.length.to_s + " element(s))"
end
else
- hasChildren = value.instance_variables.length > 0 || value.class.class_variables.length > 0
+ hasChildren = value.instance_variables.length > 0 || value.class.class_variables.length > 0
valueString = value.to_s
if valueString =~ /^\"/ then
valueString.slice!(1..(valueString.length)-2)
end
- end
+ end
out("<variable name=\"%s\" kind=\"%s\" value=\"%s\" type=\"%s\" hasChildren=\"%s\" objectId=\"%#+x\"/>", CGI.escapeHTML(name), kind, CGI.escapeHTML(valueString), value.class(), hasChildren, value.respond_to?(:object_id) ? value.object_id : value.id)
end
-
+
def printBreakpoint(n, debugFuncName, file, pos)
out("<breakpoint file=\"%s\" line=\"%s\" threadId=\"%s\"/>", file, pos, DEBUGGER__.get_thread_num())
end
-
+
def printException(file, pos, exception)
out("<exception file=\"%s\" line=\"%s\" type=\"%s\" message=\"%s\" threadId=\"%s\"/>", file, pos, exception.class, CGI.escapeHTML(exception.to_s), DEBUGGER__.get_thread_num())
end
-
+
def printStepEnd(file, line, framesCount)
out("<suspended file=\"%s\" line=\"%s\" frames=\"%s\" threadId=\"%s\"/>", file, line, framesCount, DEBUGGER__.get_thread_num())
end
-
+
def printFrame(pos, n, file, line, id)
out("<frame no=\"%s\" file=\"%s\" line=\"%s\"/>", n, file, line)
end
@@ -138,16 +142,16 @@
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
class DEBUGGER__
-
+
class CommandLinePrinter
def printXml(s)
# print XML only
end
-
+
def printVariable(name, binding, kind)
stdout.printf " %s => %s\n", name, eval(name, binding).inspect
end
-
+
def printBreakpoint(n, debugFuncName, file, pos)
stdout.printf "Breakpoint %d, %s at %s:%s\n", n, debugFuncName, file, pos
stdout.flush
@@ -165,7 +169,7 @@
stdout.printf "%s:%d: `%s' (%s)\n", file, line, exception, exception.class
stdout.flush
end
-
+
def printThread(num, thread)
if thread == Thread.current
stdout.print "+"
@@ -180,23 +184,23 @@
end
stdout.print "\n"
end
-
-
+
+
def printStepEnd(file, line, framesCount)
-
+
end
-
+
def debug(*params)
-
+
end
-
+
def stdout
DEBUGGER__.stdout
end
end
-
-
-
+
+
+
class Context
attr_reader :shouldResume
def initialize
@@ -216,33 +220,33 @@
@suspend_next = false
@shouldResume = false
end
-
+
def stop_next(n=1)
@stop_next = n
end
-
+
def set_suspend
@suspend_next = true
end
-
+
def clear_suspend
@suspend_next = false
end
-
+
def stopCurrentThread
@printer.debug("Suspending : %s", Thread.current)
Thread.stop()
@printer.debug("Resumed : %s", Thread.current)
end
-
+
def trace?
@trace
end
-
+
def set_trace(arg)
@trace = arg
end
-
+
def stdout
if @socket then
@socket
@@ -250,27 +254,27 @@
DEBUGGER__.stdout
end
end
-
+
def break_points
DEBUGGER__.break_points
end
-
+
def display
DEBUGGER__.display
end
-
+
def context(th)
DEBUGGER__.context(th)
end
-
+
def set_trace_all(arg)
DEBUGGER__.set_trace(arg)
end
-
+
def set_last_thread(th)
DEBUGGER__.set_last_thread(th)
end
-
+
def debug_eval_private(str, binding)
# evaluates str like "var.@instance_var.@instance_var"
# and "var.privateMethod"
@@ -281,7 +285,7 @@
names = str.scan(/[^\[\]]*(?=\.)|.*\[.*\](?=\.)|.*$/)
# names can contain empty strings
obj = eval(names[0], binding)
- (1..names.length-1).each { |i|
+ (1..names.length-1).each { |i|
if names[i] != "" then
if names[i].length > 2 && names[i][0..1] == '@@' then
@printer.debug("Evaluating (class_var): %s on %s", names[i], obj )
@@ -311,7 +315,7 @@
raise error
end
end
-
+
def debug_silent_eval(str, binding)
begin
val = eval(str, binding)
@@ -320,7 +324,7 @@
nil
end
end
-
+
def var_list(ary, binding, kind)
ary.sort!
@printer.printXml("<variables>")
@@ -329,7 +333,7 @@
end
@printer.printXml("</variables>")
end
-
+
def printArrayElements(array)
index = 0
array.each { |e|
@@ -337,25 +341,25 @@
index += 1
}
end
-
+
def printHashElements(hash)
- hash.keys.each { | k |
- if k.class.name == "String"
- name = '\'' + k + '\''
- else
- name = k.to_s
- end
+ hash.keys.each { | k |
+ if k.class.name == "String"
+ name = '\'' + k + '\''
+ else
+ name = k.to_s
+ end
@printer.printVariableValue(name, hash[k], 'instance')
}
end
-
-
+
+
def getConstantsInClass(aClass)
constants = aClass.constants() - Object.constants
return constants.delete_if { |c| ! aClass.const_defined? c }
end
-
-
+
+
def getBinding(pos)
# returns frame info of frame pos, if pos is within bound, nil otherwise
pos = @current_frame unless pos
@@ -371,14 +375,14 @@
@printer.debug("Using frame %s (1-based) for evaluation of variable.", pos + 1)
return @frames[pos][0]
end
-
-
+
+
def debug_variable_info(input, binding)
-
+
case input
when /^\s*g(?:lobal)?$/
var_list(global_variables, binding, 'global')
-
+
when /^\s*l(?:ocal)?\s*(\d+)?$/
@printer.debug("Getting binding for frame #{$1}")
new_binding = getBinding($1)
@@ -397,7 +401,7 @@
@printer.debug("Exception while evaluating local_variables: %s", bang)
var_list([], binding, 'local')
end
-
+
when /^\s*i(?:nstance)?\s*(\d+)?\s+((?:[\\+-]0x)[\dabcdef]+)?/
new_binding = getBinding($1)
if new_binding then
@@ -415,11 +419,11 @@
end
if (obj.class.name == "Array") then
printArrayElements(obj)
- return
+ return
end
if (obj.class.name == "Hash") then
printHashElements(obj)
- return
+ return
end
@printer.debug("%s", obj)
instanceBinding = obj.instance_eval{binding()}
@@ -460,16 +464,16 @@
@printer.printXml("<variables>")
@printer.printVariableValue($', obj, "local")
@printer.printXml("</variables>")
-
+
end
end
-
+
def debug_method_info(input, binding)
case input
when /^i(:?nstance)?\s+/
- obj = debug_eval($', binding);
-
+ obj = debug_eval($', binding); # correct highlighting since RDT editor does not recognize $'
+
len = 0
for v in obj.methods.sort
len += v.size + 1
@@ -480,7 +484,7 @@
stdout.print v, " "
end
stdout.print "\n"
-
+
else
obj = debug_eval(input, binding)
unless obj.kind_of? Module
@@ -499,7 +503,7 @@
end
end
end
-
+
def thnum(thread=Thread.current)
num = DEBUGGER__.instance_eval{@thread_list[thread]}
unless num
@@ -516,7 +520,7 @@
readUserInput(binding, file, line, singleCommand.strip)
}
end
-
+
def readUserInput(binding, binding_file, binding_line, input)
@printer.debug("Processing #{input}, binding=%s", binding)
@@ -524,221 +528,214 @@
frame_pos = 0
previous_line = nil
display_expressions(binding)
-
-
- case input
- when /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
- if defined?( $2 )
- if $1 == 'on'
- set_trace_all true
- else
- set_trace_all false
- end
- elsif defined?( $1 )
- if $1 == 'on'
- set_trace true
- else
- set_trace false
- end
- end
- if trace?
- stdout.print "Trace on.\n"
+
+
+ case input
+ when /^\s*tr(?:ace)?(?:\s+(on|off))?(?:\s+(all))?$/
+ if defined?( $2 )
+ if $1 == 'on'
+ set_trace_all true
else
- stdout.print "Trace off.\n"
+ set_trace_all false
end
-
- when /^\s*b(?:reak)?\s+(?:(add|remove)\s+)?((?:.*?:)?.+)$/
- if $1 then
- mode = $1
+ elsif defined?( $1 )
+ if $1 == 'on'
+ set_trace true
else
- mode = "add"
+ set_trace false
end
- pos = $2
- if pos.index(":")
- file, pos = pos.split(":")
- end
- file = File.basename(file)
- if pos =~ /^\d+$/
- pname = pos
- pos = pos.to_i
- else
- pname = pos = pos.intern.id2name
- end
- if mode == "add" then
- break_points.push [true, 0, file, pos]
- @printer.debug("Set breakpoint %d at %s:%s\n", break_points.size, file, pname )
- else
- break_points_length = break_points.length
- break_points.delete_if {
- | b |
- b[2] == file && b[3] == pos
- }
- if break_points_length == break_points.length then
- @printer.debug("No such breakpoint to remove : %s:%s", file, pname)
- else
- @printer.debug("Removed breakpoint : %s:%s", file, pname)
- end
- end
-
- # when /^\s*wat(?:ch)?\s+(.+)$/
- # exp = $1
- # break_points.push [true, 1, exp]
- # stdout.printf "Set watchpoint %d\n", break_points.size, exp
-
- # when /^\s*b(?:reak)?$/
- # if break_points.find{|b| b[1] == 0}
- # n = 1
- # stdout.print "Breakpoints:\n"
- # for b in break_points
- # if b[0] and b[1] == 0
- # stdout.printf " %d %s:%s\n", n, b[2], b[3]
- # end
- # n += 1
- # end
- # end
- # if break_points.find{|b| b[1] == 1}
- # n = 1
- # stdout.print "\n"
- # stdout.print "Watchpoints:\n"
- # for b in break_points
- # if b[0] and b[1] == 1
- # stdout.printf " %d %s\n", n, b[2]
- # end
- # n += 1
- # end
- # end
- # if break_points.size == 0
- # stdout.print "No breakpoints\n"
- # else
- # stdout.print "\n"
- # end
-
- # when /^\s*del(?:ete)?(?:\s+(\d+))?$/
- # pos = $1
- # unless pos
- # input = readline("Clear all breakpoints? (y/n) ", false)
- # if input == "y"
- # for b in break_points
- # b[0] = false
- # end
- # end
- # else
- # pos = pos.to_i
- # if break_points[pos-1]
- # break_points[pos-1][0] = false
- # else
- # stdout.printf "Breakpoint %d is not defined\n", pos
- # end
- # end
-
- # when /^\s*disp(?:lay)?\s+(.+)$/
- # exp = $1
- # display.push [true, exp]
- # stdout.printf "%d: ", display.size
- # display_expression(exp, binding)
- #
- # when /^\s*disp(?:lay)?$/
- # display_expressions(binding)
- #
- # when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
- # pos = $1
- # unless pos
- # input = readline("Clear all expressions? (y/n) ", false)
- # if input == "y"
- # for d in display
- # d[0] = false
- # end
- # end
- # else
- # pos = pos.to_i
- # if display[pos-1]
- # display[pos-1][0] = false
- # else
- # stdout.printf "Display expression %d is not defined\n", pos
- # end
- # end
-
- when /^\s*c(?:ont)?$/
- @shouldResume = true
-
- when /^\s*s(?:tep)?(?:\s+(\d+))?$/
- if $1
- lev = $1.to_i
- else
- lev = 1
- end
- @stop_next = lev
- @shouldResume = true
-
- when /^\s*n(?:ext)?(?:\s+(\d+))?$/
- if $1
- lev = $1.to_i
- else
- lev = 1
- end
- @stop_next = lev
- @no_step = @frames.size - frame_pos
- @shouldResume = true
-
- when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
- display_frames(frame_pos)
-
- # when /^\s*fin(?:ish)?$/
- # if frame_pos == @frames.size
- # stdout.print "\"finish\" not meaningful in the outermost frame.\n"
- # else
- # @finish_pos = @frames.size - frame_pos
- # frame_pos = 0
- # prompt = false
- # end
- when /^\s*f(?:rame)?\s+(\d+)\s*$/
- @printer.debug("Setting frame to #{$1}")
- @current_frame = $1.to_i
-
-
- when /^\s*cat(?:ch)?(?:\s+(.+))?$/
- # $1 can also be nil
- @catch = $1
- @catch = nil if @catch == 'off'
- if @catch then
- @printer.debug("Catchpoint set to #{@catch}")
- else
- @printer.debug("Catchpoints disabled")
- end
-
-
- when /^\s*v(?:ar)?\s+/
- debug_variable_info($', binding)
-
- when /^\s*m(?:ethod)?\s+/
- debug_method_info($', binding)
-
- when /^\s*th(?:read)?\s+/
- DEBUGGER__.debug_thread_info($', binding)
-
- when /^\s*p\s+/
- stdout.printf "%s\n", debug_eval($', binding).inspect
-
- when /^\s*load\s+/
- @printer.debug("loading file: %s", $')
- begin
- load $'
- @printer.printLoadResult($')
- rescue Exception => error
- @printer.printLoadResult($', error)
- end
-
+ end
+ if trace?
+ stdout.print "Trace on.\n"
else
- @printer.debug("Unknown input : %s", input)
+ stdout.print "Trace off.\n"
end
+ when /^\s*b\s+((?:.*?:)?.+)$/
+ #@printer.debug("S")
+ pos = $1
+ if pos.index(":")
+ file, pos = pos.split(":")
+ end
+ file = File.basename(file)
+ if pos =~ /^\d+$/
+ pname = pos
+ pos = pos.to_i
+ else
+ pname = pos = pos.intern.id2name
+ end
+ # TODO: pname is not used
+ break_points.push [true, 0, file, pos]
+ @printer.printXml("<breakpointAdded no=\"%d\" location=\"%s:%s\"/>\n", break_points.size, file, pos)
+
+ when /^\s*delete\s+(\d+)$/
+ pos = $1.to_i
+ if pos < 1 || pos > break_points.length
+ @printer.printError("Breakpoint number out of bounds: %d. There are currently %d breakpoints defined.", pos, break_points.length )
+ else
+ break_points.delete_at(pos-1)
+ @printer.debug("Removed breakpoint no %d", pos)
+ end
+
+ # when /^\s*wat(?:ch)?\s+(.+)$/
+ # exp = $1
+ # break_points.push [true, 1, exp]
+ # stdout.printf "Set watchpoint %d\n", break_points.size, exp
+
+ # when /^\s*b(?:reak)?$/
+ # if break_points.find{|b| b[1] == 0}
+ # n = 1
+ # stdout.print "Breakpoints:\n"
+ # for b in break_points
+ # if b[0] and b[1] == 0
+ # stdout.printf " %d %s:%s\n", n, b[2], b[3]
+ # end
+ # n += 1
+ # end
+ # end
+ # if break_points.find{|b| b[1] == 1}
+ # n = 1
+ # stdout.print "\n"
+ # stdout.print "Watchpoints:\n"
+ # for b in break_points
+ # if b[0] and b[1] == 1
+ # stdout.printf " %d %s\n", n, b[2]
+ # end
+ # n += 1
+ # end
+ # end
+ # if break_points.size == 0
+ # stdout.print "No breakpoints\n"
+ # else
+ # stdout.print "\n"
+ # end
+
+ # when /^\s*del(?:ete)?(?:\s+(\d+))?$/
+ # pos = $1
+ # unless pos
+ # input = readline("Clear all breakpoints? (y/n) ", false)
+ # if input == "y"
+ # for b in break_points
+ # b[0] = false
+ # end
+ # end
+ # else
+ # pos = pos.to_i
+ # if break_points[pos-1]
+ # break_points[pos-1][0] = false
+ # else
+ # stdout.printf "Breakpoint %d is not defined\n", pos
+ # end
+ # end
+
+ # when /^\s*disp(?:lay)?\s+(.+)$/
+ # exp = $1
+ # display.push [true, exp]
+ # stdout.printf "%d: ", display.size
+ # display_expression(exp, binding)
+ #
+ # when /^\s*disp(?:lay)?$/
+ # display_expressions(binding)
+ #
+ # when /^\s*undisp(?:lay)?(?:\s+(\d+))?$/
+ # pos = $1
+ # unless pos
+ # input = readline("Clear all expressions? (y/n) ", false)
+ # if input == "y"
+ # for d in display
+ # d[0] = false
+ # end
+ # end
+ # else
+ # pos = pos.to_i
+ # if display[pos-1]
+ # display[pos-1][0] = false
+ # else
+ # stdout.printf "Display expression %d is not defined\n", pos
+ # end
+ # end
+
+ when /^\s*c(?:ont)?$/
+ @shouldResume = true
+
+ when /^\s*s(?:tep)?(?:\s+(\d+))?$/
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ @stop_next = lev
+ @shouldResume = true
+
+ when /^\s*n(?:ext)?(?:\s+(\d+))?$/
+ if $1
+ lev = $1.to_i
+ else
+ lev = 1
+ end
+ @stop_next = lev
+ @no_step = @frames.size - frame_pos
+ @shouldResume = true
+
+ when /^\s*w(?:here)?$/, /^\s*f(?:rame)?$/
+ display_frames(frame_pos)
+
+ # when /^\s*fin(?:ish)?$/
+ # if frame_pos == @frames.size
+ # stdout.print "\"finish\" not meaningful in the outermost frame.\n"
+ # else
+ # @finish_pos = @frames.size - frame_pos
+ # frame_pos = 0
+ # prompt = false
+ # end
+ when /^\s*f(?:rame)?\s+(\d+)\s*$/
+ @printer.debug("Setting frame to #{$1}")
+ @current_frame = $1.to_i
+
+
+ when /^\s*cat(?:ch)?(?:\s+(.+))?$/
+ # $1 can also be nil
+ @catch = $1
+ @catch = nil if @catch == 'off'
+ if @catch then
+ @printer.debug("Catchpoint set to #{@catch}")
+ else
+ @printer.debug("Catchpoints disabled")
+ end
+
+
+ when /^\s*v(?:ar)?\s+/
+ debug_variable_info($', binding)
+
+ when /^\s*m(?:ethod)?\s+/
+ debug_method_info($', binding)
+
+ when /^\s*th(?:read)?\s+/
+ DEBUGGER__.debug_thread_info($', binding)
+
+ when /^\s*p\s+/
+ stdout.printf "%s\n", debug_eval($', binding).inspect
+
+ when /^\s*load\s+/
+ @printer.debug("loading file: %s", $')
+ begin
+ load $'
+ @printer.printLoadResult($')
+ rescue Exception => error
+ @printer.printLoadResult($', error)
+ end
+
+ else
+ @printer.debug("Unknown input : %s", input)
+ end
+
end
-
-
-
+
+
+
def display_expressions(binding)
n = 1
for d in display
@@ -749,12 +746,12 @@
n += 1
end
end
-
+
def display_expression(exp, binding)
stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s
end
-
-
+
+
def display_frames(pos)
pos += 1
n = 0
@@ -767,7 +764,7 @@
end
@printer.printXml("</frames>")
end
-
+
def debug_funcname(id)
if id.nil?
"toplevel"
@@ -775,7 +772,7 @@
id.id2name
end
end
-
+
def debug_command(file, line, id, binding)
@printer.debug("debug_command, @stop_next=%s, @frames.size=%s", @stop_next, @frames.size)
if @stop_next == 0 && @frames.size > 0 then
@@ -784,11 +781,11 @@
@printer.printStepEnd(file, line, @frames.size)
end
set_last_thread(Thread.current)
-
+
#readUserInput(binding, file, line )
#Thread.stop
end
-
+
def check_break_points(file, pos, binding, id)
return false if break_points.empty?
file = File.basename(file)
@@ -810,7 +807,7 @@
end
return false
end
-
+
def excn_handle(file, line, id, binding)
if $!.class <= SystemExit
@@ -828,9 +825,9 @@
end
end
-
+
def trace_func(event, file, line, id, binding, klass)
-
+
Tracer.trace_func(event, file, line, id, binding, klass) if trace?
@file = file
@@ -851,7 +848,7 @@
elsif @frames.size < @no_step
@stop_next = 0 # break here before leaving...
end
-
+
if @stop_next == 0 or check_break_points(file, line, binding, id)
if [file, line] == @last
@stop_next = 1
@@ -862,16 +859,16 @@
@last = [file, line]
end
end
-
+
when 'call'
DEBUGGER__.printer().debug("trace call, file=%s, line=%s, method=%s", file, line, id.id2name)
@frames.unshift [binding, file, line, id]
if check_break_points(file, id.id2name, binding, id) or
- check_break_points(klass.to_s, id.id2name, binding, id) then
+ check_break_points(klass.to_s, id.id2name, binding, id) then
stopCurrentThread
debug_command(file, line, id, binding)
end
-
+
when 'c-call'
if @frames[0] then
@frames[0][1] = file
@@ -879,10 +876,10 @@
else
@frames[0] = [binding, file, line, id]
end
-
+
when 'class'
@frames.unshift [binding, file, line, id]
-
+
when 'return', 'end'
DEBUGGER__.printer().debug("trace return and end, file=%s, line=%s", file, line)
if @frames.size == @finish_pos
@@ -890,19 +887,19 @@
@finish_pos = 0
end
@frames.shift
-
+
when 'end'
DEBUGGER__.printer().debug("trace end, file=%s, line=%s", file, line)
@frames.shift
-
+
when 'raise'
excn_handle(file, line, id, binding)
-
+
end
@last_file = file
end
end
-
+
trap("INT") { DEBUGGER__.interrupt }
@last_thread = Thread::main
@max_thread = 1
@@ -911,28 +908,28 @@
@display = []
@waiting = []
@stdout = STDOUT
-
+
class << DEBUGGER__
def stdout
@stdout
end
-
+
def stdout=(s)
@stdout = s
end
-
+
def display
@display
end
-
+
def break_points
@break_points
end
-
+
def waiting
@waiting
end
-
+
def set_trace( arg )
Thread.critical = true
make_thread_list
@@ -941,11 +938,11 @@
end
Thread.critical = false
end
-
+
def set_last_thread(th)
@last_thread = th
end
-
+
def suspend
printer.debug("Suspending all")
Thread.critical = true
@@ -958,12 +955,12 @@
# Schedule other threads to suspend as soon as possible.
Thread.pass
end
-
+
def resume
Thread.critical = true
make_thread_list
for th in @thread_list
- next if th[0] == Thread.current
+ next if th[0] == Thread.current
context(th[0]).clear_suspend
end
waiting.each do |th|
@@ -974,7 +971,7 @@
# Schedule other threads to restart as soon as possible.
Thread.pass
end
-
+
def context(thread=Thread.current)
c = thread[:__debugger_data__]
unless c
@@ -982,7 +979,7 @@
end
c
end
-
+
def findThread(context)
for thread in Thread::list
if context == thread[:__debugger_data__]
@@ -990,11 +987,11 @@
end
end
end
-
+
def interrupt
context(@last_thread).stop_next
end
-
+
def get_thread(num)
th = @thread_list.index(num)
unless th
@@ -1002,17 +999,17 @@
end
th
end
-
+
def get_thread_num(thread=Thread.current)
make_thread_list
@thread_list[thread]
end
-
+
def print_thread(thread)
num = @thread_list[thread]
printer.printThread(num, thread)
end
-
+
def thread_list_all
printer.printXml("<threads>")
for num in @thread_list.values.sort
@@ -1020,7 +1017,7 @@
end
printer.printXml("</threads>")
end
-
+
def make_thread_list
hash = {}
for th in Thread::list
@@ -1034,17 +1031,17 @@
end
@thread_list = hash
end
-
+
def debug_thread_info(input, binding)
case input
when /^l(?:ist)?/
make_thread_list
thread_list_all
-
+
when /^c(?:ur(?:rent)?)?$/
make_thread_list
print_thread()
-
+
when /^(?:sw(?:itch)?\s+)?(\d+)/
make_thread_list
th = get_thread($1.to_i)
@@ -1056,7 +1053,7 @@
th.run
return
end
-
+
when /^stop\s+(\d+)/
make_thread_list
th = get_thread($1.to_i)
@@ -1068,7 +1065,7 @@
print_thread(th)
context(th).suspend
end
-
+
when /^resume\s+(\d+)/
make_thread_list
th = get_thread($1.to_i)
@@ -1080,7 +1077,7 @@
print_thread(th)
th.run
end
-
+
when /^change\s+(\d+)/
make_thread_list
th = get_thread($1.to_i)
@@ -1089,7 +1086,7 @@
end
end
end
-
+
@@socket = nil
@@printer = nil
@@inputReader = nil
@@ -1098,20 +1095,20 @@
def DEBUGGER__.printer
@@printer
end
-
+
def DEBUGGER__.socket
@@socket
end
-
+
def DEBUGGER__.isStarted
@@isStarted
end
-
+
def DEBUGGER__.setStarted
@@isStarted = true
end
-
-
+
+
def DEBUGGER__.inputReader
@@inputReader
end
@@ -1120,12 +1117,12 @@
set_trace_func @@traceProc
Thread.critical = false ;
end
-
+
def DEBUGGER__.traceOff()
Thread.critical = true ;
set_trace_func nil
end
-
+
def DEBUGGER__.readCommandLoop()
sleep(1.0) # workaround for large files with ruby 1.6.8, otherwise parse exceptions
loop do
@@ -1152,14 +1149,14 @@
end
context.processInput(input)
if context.shouldResume then
- threadToResume = DEBUGGER__.findThread(context)
+ threadToResume = DEBUGGER__.findThread(context)
end
DEBUGGER__.traceOn()
next unless threadToResume
threadToResume.run()
end
end
-
+
# use 127.0.0.1 instead of localhost because OSX 10.4
server = TCPServer.new('127.0.0.1', ECLIPSE_LISTEN_PORT)
puts "ruby #{RUBY_VERSION} debugger listens on port #{ECLIPSE_LISTEN_PORT}"
@@ -1177,7 +1174,7 @@
puts error
end
}
-
+
@@traceProc = proc { |event, file, line, id, binding, klass, *rest|
#@@printer.debug("trace %s, %s:%s", event, file, line)
@@ -1190,9 +1187,7 @@
end
DEBUGGER__.context.trace_func event, file, line, id, binding, klass
}
-
+
@@printer.debug("Setting trace func: %s", @@traceProc)
set_trace_func @@traceProc
end
-
-
Added: trunk/org.rubypeople.rdt.launching/ruby/rdebugExtension.rb
===================================================================
--- trunk/org.rubypeople.rdt.launching/ruby/rdebugExtension.rb (rev 0)
+++ trunk/org.rubypeople.rdt.launching/ruby/rdebugExtension.rb 2006-12-30 09:44:19 UTC (rev 1748)
@@ -0,0 +1,57 @@
+module Debugger
+ class XmlPrinter
+
+ def print_inspect(eval_result)
+ print_element("variables") do
+ print_variable("eval_result", eval_result, 'locale')
+ end
+ end
+
+ def print_load_result(file, exception=nil)
+ if exception then
+ print("<loadResult file=\"%s\" exceptionType=\"%s\" exceptionMessage=\"%s\"/>", file, exception.class, CGI.escapeHTML(exception.to_s))
+ else
+ print("<loadResult file=\"%s\" status=\"OK\"/>", file)
+ end
+ end
+
+ end
+
+ class InspectCommand < Command
+ # reference inspection results in order to save them from the GC
+ @@references = []
+ def self.reference_result(result)
+ @@references << result
+ end
+ def self.clear_references
+ @@references = []
+ end
+
+ def regexp
+ /^\s*v(?:ar)?\s+inspect\s+/
+ end
+ #
+ def execute
+ obj = debug_eval(@match.post_match)
+ InspectCommand.reference_result(obj)
+ @printer.print_inspect(obj)
+ end
+ end
+
+ class LoadCommand < Command
+ def regexp
+ /^\s*load\s+/
+ end
+
+ def execute
+ fileName = @match.post_match
+ @printer.print_debug("loading file: %s", fileName)
+ begin
+ load fileName
+ @printer.print_load_result(fileName)
+ rescue Exception => error
+ @printer.print_load_result(fileName, error)
+ end
+ end
+ end
+end
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|