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-09-17 20:05:33
|
Revision: 3198
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3198&view=rev
Author: cawilliams
Date: 2007-09-17 13:04:27 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
remove unused import
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubySourceLocator.java
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubySourceLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubySourceLocator.java 2007-09-17 20:04:19 UTC (rev 3197)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/src/org/rubypeople/rdt/internal/debug/ui/TC_RubySourceLocator.java 2007-09-17 20:04:27 UTC (rev 3198)
@@ -24,10 +24,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.CreateFileAction;
import org.rubypeople.rdt.internal.debug.core.model.RubyStackFrame;
-import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiPlugin;
-import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator;
public class TC_RubySourceLocator extends TestCase {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-17 20:05:10
|
Revision: 3196
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3196&view=rev
Author: cawilliams
Date: 2007-09-17 13:04:14 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
fix broken test
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java 2007-09-17 18:16:03 UTC (rev 3195)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java 2007-09-17 20:04:14 UTC (rev 3196)
@@ -132,41 +132,57 @@
}
public boolean isValid(ILaunchConfiguration launchConfig) {
- String projectName = projectSelector.getSelectionText();
- if (projectName.length() == 0) {
- setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidProjectSelectionMessage);
- return false;
- }
+ try {
+ String projectName = launchConfig.getAttribute(IRubyLaunchConfigurationConstants.ATTR_PROJECT_NAME, "");
+ if (projectName.length() == 0) {
+ setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidProjectSelectionMessage);
+ return false;
+ }
- String fileName = fileSelector.getSelectionText();
- if (fileName.length() == 0) {
- setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidFileSelectionMessage);
- return false;
- }
- File test = new File(fileName);
- if (!test.exists()) {
- try {
- String workingDirectory = launchConfig.getAttribute(IRubyLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
- if (workingDirectory != null && !workingDirectory.trim().equals("")) {
- String blah = workingDirectory + fileName;
- test = new File(blah);
- }
- } catch (CoreException e) {
- RdtDebugUiPlugin.log(e);
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (project == null) {
+ setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidProjectSelectionMessage);
+ return false;
}
+ if (!project.exists()) {
+ setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidProjectSelectionMessage);
+ return false;
+ }
+
+ String fileName = launchConfig.getAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, "");
+ if (fileName.length() == 0) {
+ setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidFileSelectionMessage);
+ return false;
+ }
+ File test = new File(fileName);
if (!test.exists()) {
- IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
- if (project != null) {
- test = project.getLocation().append(fileName).toFile();
+ try {
+ String workingDirectory = launchConfig.getAttribute(IRubyLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ if (workingDirectory != null && !workingDirectory.trim().equals("")) {
+ String blah = workingDirectory + fileName;
+ test = new File(blah);
+ }
+ } catch (CoreException e) {
+ RdtDebugUiPlugin.log(e);
}
+ if (!test.exists()) {
+ if (project != null) {
+ test = project.getLocation().append(fileName).toFile();
+ }
+ }
+ if (!test.exists()) {
+ setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidFileSelectionMessage);
+ return false;
+ }
}
- if (!test.exists()) {
- return false;
- }
+
+ setErrorMessage(null);
+ return true;
+ } catch (CoreException e) {
+ setErrorMessage(e.getMessage());
+ RdtDebugUiPlugin.log(e);
}
-
- setErrorMessage(null);
- return true;
+ return false;
}
protected void log(Throwable t) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-17 18:16:07
|
Revision: 3195
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3195&view=rev
Author: cawilliams
Date: 2007-09-17 11:16:03 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
try to avoid error message about being unable to restore perspective (because of removed Ruby Resources view).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-17 18:06:42 UTC (rev 3194)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-17 18:16:03 UTC (rev 3195)
@@ -197,14 +197,14 @@
if (dw != null) {
IWorkbenchPage page = dw.getActivePage();
if (page != null) {
+ IViewPart part = page.findView(RubyUI.ID_RUBY_RESOURCE_VIEW);
+ if (part != null) {
+ page.hideView(part);
+ }
if (page.findView(RubyUI.ID_RUBY_EXPLORER) == null) {
- IViewPart part = page.findView(RubyUI.ID_RUBY_RESOURCE_VIEW);
- if (part != null) {
- page.hideView(part);
- page.showView(RubyUI.ID_RUBY_EXPLORER);
- store.setValue(OPENED_RUBY_EXPLORER, true);
- }
+ page.showView(RubyUI.ID_RUBY_EXPLORER);
}
+ store.setValue(OPENED_RUBY_EXPLORER, true);
}
}
} catch (PartInitException ignored) {}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-17 18:06:48
|
Revision: 3194
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3194&view=rev
Author: cawilliams
Date: 2007-09-17 11:06:42 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
try to avoid error message about being unable to restore perspective (because of removed Ruby Resources view).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/DeprecatedView.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-17 13:52:23 UTC (rev 3193)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-17 18:06:42 UTC (rev 3194)
@@ -386,6 +386,13 @@
id="org.rubypeople.rdt.ui.RubyExplorer">
</view>
<view
+ name="Ruby Resources View"
+ icon="$nl$/icons/full/ctool16/ruby.gif"
+ category="org.rubypeople.rdt.ui.ruby"
+ class="org.rubypeople.rdt.ui.DeprecatedView"
+ id="org.rubypeople.rdt.ui.ViewRubyResources">
+ </view>
+ <view
name="RI"
icon="icons/full/elcl16/help.gif"
category="org.rubypeople.rdt.ui.ruby"
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-17 13:52:23 UTC (rev 3193)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-17 18:06:42 UTC (rev 3194)
@@ -41,6 +41,7 @@
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PartInitException;
@@ -74,6 +75,7 @@
import org.rubypeople.rdt.internal.ui.text.template.contentassist.RubyTemplateAccess;
import org.rubypeople.rdt.internal.ui.viewsupport.ProblemMarkerManager;
import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.RubyUI;
import org.rubypeople.rdt.ui.text.RubyTextTools;
public class RubyPlugin extends AbstractUIPlugin implements IRubyColorConstants {
@@ -82,6 +84,7 @@
private static final String ORG_ECLIPSE_UI_VIEWS_PROBLEM_VIEW = "org.eclipse.ui.views.ProblemView";
protected static RubyPlugin plugin;
public static final String PLUGIN_ID = "org.rubypeople.rdt.ui"; //$NON-NLS-1$
+ private static final String OPENED_RUBY_EXPLORER = PLUGIN_ID + ".opened.ruby.explorer";
protected RubyTextTools textTools;
protected RubyFileMatcher rubyFileMatcher;
@@ -173,7 +176,9 @@
fMembersOrderPreferenceCache.install(store);
listenForNewProjects();
- upgradeOldProjects();
+ upgradeOldProjects();
+ openRubyExplorer();
+
String generateRdocOption = Platform.getDebugOption(RubyPlugin.PLUGIN_ID + "/generaterdoc");
RDocUtility.setDebugging(generateRdocOption == null ? false : generateRdocOption.equalsIgnoreCase("true"));
@@ -181,6 +186,33 @@
getASTProvider();
new InitializeAfterLoadJob().schedule();
}
+
+ private void openRubyExplorer() {
+ final IPreferenceStore store = RubyPlugin.getDefault().getPreferenceStore();
+ if (store.getBoolean(OPENED_RUBY_EXPLORER)) return;
+ WorkbenchJob job = new WorkbenchJob("Show New Ruby Explorer View") {
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ try {
+ IWorkbenchWindow dw = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
+ if (dw != null) {
+ IWorkbenchPage page = dw.getActivePage();
+ if (page != null) {
+ if (page.findView(RubyUI.ID_RUBY_EXPLORER) == null) {
+ IViewPart part = page.findView(RubyUI.ID_RUBY_RESOURCE_VIEW);
+ if (part != null) {
+ page.hideView(part);
+ page.showView(RubyUI.ID_RUBY_EXPLORER);
+ store.setValue(OPENED_RUBY_EXPLORER, true);
+ }
+ }
+ }
+ }
+ } catch (PartInitException ignored) {}
+ return Status.OK_STATUS;
+ }
+ };
+ job.schedule();
+ }
/* package */ static void initializeAfterLoad(IProgressMonitor monitor) {
OpenTypeHistory.getInstance().checkConsistency(monitor);
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/DeprecatedView.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/DeprecatedView.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/DeprecatedView.java 2007-09-17 18:06:42 UTC (rev 3194)
@@ -0,0 +1,20 @@
+package org.rubypeople.rdt.ui;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.ui.part.ViewPart;
+
+public class DeprecatedView extends ViewPart {
+
+ @Override
+ public void createPartControl(Composite parent) {
+ Label label = new Label(parent, SWT.NULL);
+ label.setText("This view has been replaced by the new Ruby Explorer view.");
+ }
+
+ @Override
+ public void setFocus() {
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/DeprecatedView.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-09-17 13:52:23 UTC (rev 3193)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-09-17 18:06:42 UTC (rev 3194)
@@ -150,6 +150,11 @@
public static final String ID_RUBY_EXPLORER= "org.rubypeople.rdt.ui.RubyExplorer"; //$NON-NLS-1$
/**
+ * @deprecated View is going to be removed
+ */
+ public static final String ID_RUBY_RESOURCE_VIEW = "org.rubypeople.rdt.ui.ViewRubyResources"; //$NON-NLS-1$
+
+ /**
* Returns the Ruby element wrapped by the given editor input.
*
* @param editorInput
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-17 13:52:24
|
Revision: 3193
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3193&view=rev
Author: cawilliams
Date: 2007-09-17 06:52:23 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/FileSelector.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/FileSelector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/FileSelector.java 2007-09-17 13:52:09 UTC (rev 3192)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/util/FileSelector.java 2007-09-17 13:52:23 UTC (rev 3193)
@@ -23,19 +23,19 @@
}
}
- String selectedDirectory = dialog.open();
- if (selectedDirectory != null) {
- textField.setText(selectedDirectory);
+ String selectedFile = dialog.open();
+ if (selectedFile != null) {
+ textField.setText(selectedFile);
}
}
@Override
protected String validateResourceSelection() {
- String directory = textField.getText();
- File directoryFile = new File(directory);
+ String file = textField.getText();
+ File directoryFile = new File(file);
if (directoryFile.exists() && directoryFile.isFile())
- return directory;
+ return file;
return EMPTY_STRING;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-17 13:52:11
|
Revision: 3192
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3192&view=rev
Author: cawilliams
Date: 2007-09-17 06:52:09 -0700 (Mon, 17 Sep 2007)
Log Message:
-----------
fix filename handling (before it would add the eclipse directory prefix to relative names which messed everything up!)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java 2007-09-14 21:44:59 UTC (rev 3191)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/launcher/RubyEntryPointTab.java 2007-09-17 13:52:09 UTC (rev 3192)
@@ -4,6 +4,7 @@
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.Path;
import org.eclipse.debug.core.ILaunchConfiguration;
@@ -62,7 +63,7 @@
public void setDefaults(ILaunchConfigurationWorkingCopy configuration) {
- IResource selectedResource = RubyPlugin.getDefault().getSelectedResource() ;
+ IResource selectedResource = RubyPlugin.getDefault().getSelectedResource();
if (!RubyPlugin.getDefault().isRubyFile(selectedResource)) {
return ;
}
@@ -90,8 +91,30 @@
public void performApply(ILaunchConfigurationWorkingCopy configuration) {
configuration.setAttribute(IRubyLaunchConfigurationConstants.ATTR_PROJECT_NAME, projectSelector.getSelectionText());
- File file = fileSelector.getSelection();
- configuration.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, file == null ? "" : file.getAbsolutePath());
+ String text = fileSelector.getSelectionText();
+ File test = new File(text);
+ if (!test.exists()) {
+ try {
+ String workingDirectory = configuration.getAttribute(IRubyLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ if (workingDirectory != null && !workingDirectory.trim().equals("")) {
+ String blah = workingDirectory + text;
+ test = new File(blah);
+ }
+ } catch (CoreException e) {
+ RdtDebugUiPlugin.log(e);
+ }
+ if (!test.exists()) {
+ String projectName = projectSelector.getSelectionText();
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (project != null) {
+ test = project.getLocation().append(text).toFile();
+ }
+ }
+ if (!test.exists()) {
+ text = "";
+ }
+ }
+ configuration.setAttribute(IRubyLaunchConfigurationConstants.ATTR_FILE_NAME, text);
}
protected Composite createPageRoot(Composite parent) {
@@ -120,6 +143,27 @@
setErrorMessage(RdtDebugUiMessages.LaunchConfigurationTab_RubyEntryPoint_invalidFileSelectionMessage);
return false;
}
+ File test = new File(fileName);
+ if (!test.exists()) {
+ try {
+ String workingDirectory = launchConfig.getAttribute(IRubyLaunchConfigurationConstants.ATTR_WORKING_DIRECTORY, (String)null);
+ if (workingDirectory != null && !workingDirectory.trim().equals("")) {
+ String blah = workingDirectory + fileName;
+ test = new File(blah);
+ }
+ } catch (CoreException e) {
+ RdtDebugUiPlugin.log(e);
+ }
+ if (!test.exists()) {
+ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
+ if (project != null) {
+ test = project.getLocation().append(fileName).toFile();
+ }
+ }
+ if (!test.exists()) {
+ return false;
+ }
+ }
setErrorMessage(null);
return true;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:45:07
|
Revision: 3191
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3191&view=rev
Author: cawilliams
Date: 2007-09-14 14:44:59 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
try to pick proper JRuby executable on each platform
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java 2007-09-14 21:42:41 UTC (rev 3190)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java 2007-09-14 21:44:59 UTC (rev 3191)
@@ -164,7 +164,7 @@
for (int i = 0; i < fgCandidateRubyFiles.length; i++) {
for (int j = 0; j < fgCandidateRubyLocations.length; j++) {
File rubyFile = new File(vmInstallLocation, fgCandidateRubyLocations[j] + fgCandidateRubyFiles[i]);
- if (rubyFile.isFile() && isPlatformProper(rubyFile)) { // FIXME Only check for .bat on win32 and others on other platforms
+ if (rubyFile.isFile() && isPlatformProper(rubyFile)) { // Only check for .bat on win32 and others on other platforms
return rubyFile;
}
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-09-14 21:42:41 UTC (rev 3190)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-09-14 21:44:59 UTC (rev 3191)
@@ -173,12 +173,13 @@
string.add(exe.getAbsolutePath());
return string;
}
+ } else {
+ exe = new File(path);
+ if (fileExists(exe)){
+ string.add(exe.getAbsolutePath());
+ return string;
+ }
}
- exe = new File(path);
- if (fileExists(exe)){
- string.add(exe.getAbsolutePath());
- return string;
- }
// not found
abort(MessageFormat.format(LaunchingMessages.StandardVMRunner_Specified_executable__0__does_not_exist_for__1__4, command, fVMInstance.getName()), null, IRubyLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:43:32
|
Revision: 3190
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3190&view=rev
Author: cawilliams
Date: 2007-09-14 14:42:41 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
try to pick proper JRuby executable on each platform
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java 2007-09-14 21:38:32 UTC (rev 3189)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java 2007-09-14 21:42:41 UTC (rev 3190)
@@ -164,7 +164,7 @@
for (int i = 0; i < fgCandidateRubyFiles.length; i++) {
for (int j = 0; j < fgCandidateRubyLocations.length; j++) {
File rubyFile = new File(vmInstallLocation, fgCandidateRubyLocations[j] + fgCandidateRubyFiles[i]);
- if (rubyFile.isFile()) { // FIXME Only check for .bat on win32 and others on other platforms
+ if (rubyFile.isFile() && isPlatformProper(rubyFile)) { // FIXME Only check for .bat on win32 and others on other platforms
return rubyFile;
}
}
@@ -172,6 +172,14 @@
return null;
}
+ private static boolean isPlatformProper(File rubyFile) {
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ return rubyFile.getName().endsWith(".bat");
+ } else {
+ return !rubyFile.getName().endsWith(".bat");
+ }
+ }
+
/**
* Parses the output from 'Standard Ruby VM Install Detector'.
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:38:35
|
Revision: 3189
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3189&view=rev
Author: cawilliams
Date: 2007-09-14 14:38:32 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
only wrap vm args with double quotes when launching .bat
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java 2007-09-14 21:33:08 UTC (rev 3188)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java 2007-09-14 21:38:32 UTC (rev 3189)
@@ -16,9 +16,18 @@
if (args == null) {
return;
}
+ boolean isBatch = false;
+ if (!v.isEmpty()) {
+ String command = v.get(0);
+ if (command.equals("sudo")) {
+ command = v.get(1);
+ }
+ if (command.endsWith(".bat")) isBatch = true;
+ }
+
for (int i= 0; i < args.length; i++) {
- if (isVMArgs && args[i].charAt(0) == '-') {
- v.add("\"" + args[i] + " " + args[++i] + "\""); // FIXME Only do this if we're launching a .bat file?
+ if (isVMArgs && isBatch && args[i].charAt(0) == '-') {
+ v.add("\"" + args[i] + " " + args[++i] + "\""); // Only do this if we're launching a .bat file, and only for VM args (like -e)
} else {
v.add(args[i]);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:33:09
|
Revision: 3188
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3188&view=rev
Author: cawilliams
Date: 2007-09-14 14:33:08 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
fix reference to RubyLaunchableTester
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/plugin.xml
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-09-14 21:31:57 UTC (rev 3187)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-09-14 21:33:08 UTC (rev 3188)
@@ -73,7 +73,7 @@
<extension
point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
- class="org.rubypeople.rdt.launching.PropertyTester2"
+ class="org.rubypeople.rdt.internal.launching.RubyLaunchableTester"
id="org.rubypeople.rdt.launching.RubyLaunchableTester"
namespace="org.rubypeople.rdt.launching"
properties="extendsClass, hasMethod, isContainer, hasProjectNature"
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:31:58
|
Revision: 3187
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3187&view=rev
Author: cawilliams
Date: 2007-09-14 14:31:57 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-09-14 21:30:48 UTC (rev 3186)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-09-14 21:31:57 UTC (rev 3187)
@@ -167,10 +167,12 @@
}
// HACK FIXME This is just to allow for jruby!
String path = installLocation + "bin" + File.separatorChar + "j" + command; //$NON-NLS-1$ //$NON-NLS-2$
- exe = new File(path + ".bat"); //$NON-NLS-1$
- if (fileExists(exe)){
- string.add(exe.getAbsolutePath());
- return string;
+ if (Platform.getOS().equals(Platform.OS_WIN32)) {
+ exe = new File(path + ".bat"); //$NON-NLS-1$
+ if (fileExists(exe)){
+ string.add(exe.getAbsolutePath());
+ return string;
+ }
}
exe = new File(path);
if (fileExists(exe)){
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:30:50
|
Revision: 3186
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3186&view=rev
Author: cawilliams
Date: 2007-09-14 14:30:48 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
add a new JRuby VM Type, fix invocation of jruby.bat with -e args
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/plugin.xml
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMInstallType.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVM.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-09-14 21:30:35 UTC (rev 3185)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-09-14 21:30:48 UTC (rev 3186)
@@ -15,6 +15,9 @@
class="org.rubypeople.rdt.internal.launching.StandardVMType"
id="org.rubypeople.rdt.launching.StandardVMType">
</vmInstallType>
+ <vmInstallType
+ class="org.rubypeople.rdt.internal.launching.JRubyVMType"
+ id="org.rubypeople.rdt.launching.JRubyVMType"/>
</extension>
<extension
point="org.eclipse.debug.core.launchConfigurationTypes">
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVM.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVM.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVM.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -0,0 +1,21 @@
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.debug.core.ILaunchManager;
+import org.rubypeople.rdt.launching.IVMInstallType;
+import org.rubypeople.rdt.launching.IVMRunner;
+
+public class JRubyVM extends StandardVM {
+
+ public JRubyVM(IVMInstallType type, String id) {
+ super(type, id);
+ }
+
+ @Override
+ public IVMRunner getVMRunner(String mode) {
+ if (ILaunchManager.RUN_MODE.equals(mode)) {
+ return new JRubyVMRunner(this);
+ }
+ return super.getVMRunner(mode);
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVM.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -0,0 +1,28 @@
+package org.rubypeople.rdt.internal.launching;
+
+import java.util.List;
+
+import org.rubypeople.rdt.launching.IVMInstall;
+import org.rubypeople.rdt.launching.IVMRunner;
+
+public class JRubyVMRunner extends StandardVMRunner implements IVMRunner {
+
+ public JRubyVMRunner(IVMInstall vmInstance) {
+ super(vmInstance);
+ }
+
+ @Override
+ protected void addArguments(String[] args, List<String> v, boolean isVMArgs) {
+ if (args == null) {
+ return;
+ }
+ for (int i= 0; i < args.length; i++) {
+ if (isVMArgs && args[i].charAt(0) == '-') {
+ v.add("\"" + args[i] + " " + args[++i] + "\""); // FIXME Only do this if we're launching a .bat file?
+ } else {
+ v.add(args[i]);
+ }
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMRunner.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -0,0 +1,352 @@
+package org.rubypeople.rdt.internal.launching;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.IOException;
+import java.io.StringReader;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.Launch;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamsProxy;
+import org.eclipse.osgi.service.environment.Constants;
+import org.rubypeople.rdt.launching.AbstractVMInstallType;
+import org.rubypeople.rdt.launching.IVMInstall;
+
+public class JRubyVMType extends AbstractVMInstallType {
+
+ /**
+ * Map of the install path for which we were unable to generate
+ * the library info during this session.
+ */
+ private static Map<String, LibraryInfo> fgFailedInstallPath= new HashMap<String, LibraryInfo>();
+
+ /**
+ * Convenience handle to the system-specific file separator character
+ */
+ private static final char fgSeparator = File.separatorChar;
+
+ /**
+ * The list of locations in which to look for the ruby executable in candidate
+ * VM install locations, relative to the VM install location.
+ */
+ private static final String[] fgCandidateRubyFiles = {"jrubyw", "jrubyw.bat", "jruby", "jruby.bat"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
+ private static final String[] fgCandidateRubyLocations = {"", "bin" + fgSeparator}; //$NON-NLS-1$ //$NON-NLS-2$
+
+
+ @Override
+ protected IVMInstall doCreateVMInstall(String id) {
+ return new JRubyVM(this, id);
+ }
+
+ public File detectInstallLocation() {
+ File rubyExecutable = null;
+ if (Platform.getOS().equals(Constants.OS_WIN32)) {
+ String winPath = System.getenv("Path"); // iterate through system path and try to find jruby.bat
+ String[] paths = winPath.split(";");
+ for (int i = 0; i < paths.length; i++) {
+ String possibleExecutablePath = paths[i] + File.separator + "jruby.bat";
+ File possible = new File(possibleExecutablePath);
+ if (possible.exists()) {
+ rubyExecutable = possible;
+ break;
+ }
+ }
+ } else { // Mac, Linux - so let's just run 'which jruby' and parse out the result
+ String[] cmdLine = new String[] { "which", "jruby" }; //$NON-NLS-1$ //$NON-NLS-2$
+ Process p = null;
+ try {
+ p = Runtime.getRuntime().exec(cmdLine);
+ IProcess process = DebugPlugin.newProcess(new Launch(null,
+ ILaunchManager.RUN_MODE, null), p,
+ "JRuby VM Install Detection"); //$NON-NLS-1$
+ for (int i = 0; i < 200; i++) {
+ // Wait no more than 10 seconds (200 * 50 mils)
+ if (process.isTerminated()) {
+ break;
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ }
+ rubyExecutable = parseRubyExecutableLocation(process);
+ } catch (IOException ioe) {
+ LaunchingPlugin.log(ioe);
+ } finally {
+ if (p != null) {
+ p.destroy();
+ }
+ }
+ // If we don't find ruby, or we find one at /usr/bin/ruby:
+ // try to see if there's one at /usr/local or /opt/local. If so, then prefer one of those.
+ if (rubyExecutable == null || rubyExecutable.getAbsolutePath().startsWith("/usr/bin")) {
+ File rubyHome = tryLocation(new File("/usr/local/bin/jruby"));
+ if (rubyHome != null) return rubyHome;
+
+ rubyHome = tryLocation(new File("/opt/local/bin/jruby"));
+ if (rubyHome != null) return rubyHome;
+ }
+ }
+ return tryLocation(rubyExecutable);
+ }
+
+ private File tryLocation(File rubyExecutable) {
+ if (rubyExecutable == null) {
+ return null;
+ }
+
+ File bin = rubyExecutable.getParentFile();
+ if (!bin.exists()) return null;
+ File rubyHome = bin.getParentFile();
+ if (!rubyHome.exists()) return null;
+ if (!canDetectDefaultSystemLibraries(rubyHome, rubyExecutable)) {
+ return null;
+ }
+
+ return rubyHome;
+ }
+
+ public IPath[] getDefaultLibraryLocations(File installLocation) {
+ File rubyExecutable = findRubyExecutable(installLocation);
+ LibraryInfo info;
+ if (rubyExecutable == null) {
+ info = getDefaultLibraryInfo(installLocation);
+ } else {
+ info = getLibraryInfo(installLocation, rubyExecutable);
+ }
+ String[] loadpath = info.getBootpath();
+ IPath[] paths = new IPath[loadpath.length];
+ for (int i = 0; i < loadpath.length; i++) {
+ paths[i] = new Path(loadpath[i]);
+ }
+ return paths;
+ }
+
+ public String getName() {
+ return "JRuby VM";
+ }
+
+ public IStatus validateInstallLocation(File rubyHome) {
+ IStatus status = null;
+ File rubyExecutable = findRubyExecutable(rubyHome);
+ if (rubyExecutable == null) {
+ status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_Not_a_JDK_Root__Java_executable_was_not_found_1, null);
+ } else {
+ if (canDetectDefaultSystemLibraries(rubyHome, rubyExecutable)) {
+ status = new Status(IStatus.OK, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_ok_2, null);
+ } else {
+ status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), 0, LaunchingMessages.StandardVMType_Not_a_JDK_root__System_library_was_not_found__1, null);
+ }
+ }
+ return status;
+ }
+
+ /**
+ * Starting in the specified VM install location, attempt to find the 'jruby' executable
+ * file. If found, return the corresponding <code>File</code> object, otherwise return
+ * <code>null</code>.
+ */
+ public static File findRubyExecutable(File vmInstallLocation) {
+ // Try each candidate in order. The first one found wins. Thus, the order
+ // of fgCandidateRubyLocations and fgCandidateRubyFiles is significant.
+ for (int i = 0; i < fgCandidateRubyFiles.length; i++) {
+ for (int j = 0; j < fgCandidateRubyLocations.length; j++) {
+ File rubyFile = new File(vmInstallLocation, fgCandidateRubyLocations[j] + fgCandidateRubyFiles[i]);
+ if (rubyFile.isFile()) { // FIXME Only check for .bat on win32 and others on other platforms
+ return rubyFile;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Parses the output from 'Standard Ruby VM Install Detector'.
+ */
+ protected File parseRubyExecutableLocation(IProcess process) {
+ IStreamsProxy streamsProxy = process.getStreamsProxy();
+ String text = null;
+ if (streamsProxy != null) {
+ text = streamsProxy.getOutputStreamMonitor().getContents();
+ }
+ BufferedReader reader = new BufferedReader(new StringReader(text));
+ List<String> lines = new ArrayList<String>();
+ try {
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ lines.add(line);
+ }
+ } catch (IOException e) {
+ LaunchingPlugin.log(e);
+ }
+ if (lines.size() > 0) {
+ String location = lines.remove(0);
+ File executable = new File(location);
+ if (executable.isFile() && executable.exists()) return executable;
+ }
+ return null;
+ }
+
+ /**
+ * Return <code>true</code> if the appropriate system libraries can be found for the
+ * specified ruby executable, <code>false</code> otherwise.
+ */
+ protected boolean canDetectDefaultSystemLibraries(File rubyHome, File rubyExecutable) {
+ IPath[] locations = getDefaultLibraryLocations(rubyHome);
+ return locations.length > 0;
+ }
+
+ /**
+ * Returns default library info for the given install location.
+ *
+ * @param installLocation
+ * @return LibraryInfo
+ */
+ protected LibraryInfo getDefaultLibraryInfo(File installLocation) {
+ IPath[] dflts = getDefaultSystemLibrary(installLocation);
+ String[] strings = new String[dflts.length];
+ for (int i = 0; i < dflts.length; i++) {
+ strings[i] = dflts[i].toOSString();
+ }
+ return new LibraryInfo("1.8.4", strings); //$NON-NLS-1$
+ }
+
+ /**
+ * Return an <code>IPath</code> corresponding to the single library file containing the
+ * standard Ruby classes for VMs version 1.8.x.
+ */
+ protected IPath[] getDefaultSystemLibrary(File rubyHome) {
+ String stdPath = rubyHome.getAbsolutePath() + fgSeparator + "lib" + fgSeparator + "ruby" + fgSeparator + "1.8";
+ String sitePath = rubyHome.getAbsolutePath() + fgSeparator + "lib" + fgSeparator + "ruby" + fgSeparator + "site_ruby" + fgSeparator + "1.8";
+ IPath[] paths = new IPath[2];
+ paths[0] = new Path(sitePath);
+ paths[1] = new Path(stdPath);
+ return paths;
+ }
+
+ /**
+ * Return library information corresponding to the specified install
+ * location. If the info does not exist, create it using the given Java
+ * executable.
+ */
+ protected synchronized LibraryInfo getLibraryInfo(File rubyHome, File rubyExecutable) {
+ // See if we already know the info for the requested VM. If not, generate it.
+ String installPath = rubyHome.getAbsolutePath();
+ LibraryInfo info = LaunchingPlugin.getLibraryInfo(installPath);
+ if (info == null) {
+ info= fgFailedInstallPath.get(installPath);
+ if (info == null) {
+ info = generateLibraryInfo(rubyHome, rubyExecutable);
+ if (info == null) {
+ info = getDefaultLibraryInfo(rubyHome);
+ fgFailedInstallPath.put(installPath, info);
+ } else {
+ LaunchingPlugin.setLibraryInfo(installPath, info);
+ }
+ }
+ }
+ return info;
+ }
+
+ private LibraryInfo generateLibraryInfo(File rubyHome, File rubyExecutable) {
+ LibraryInfo info = null;
+ //locate the script to grab us our loadpaths
+ File file = LaunchingPlugin.getFileInPlugin(new Path("ruby").append("standard_vm_type").append("loadpath.rb")); //$NON-NLS-1$
+ if (file.exists()) {
+ String rubyExecutablePath = rubyExecutable.getAbsolutePath();
+ String[] cmdLine = new String[] {rubyExecutablePath, file.getAbsolutePath()}; //$NON-NLS-1$
+ Process p = null;
+ try {
+ p = Runtime.getRuntime().exec(cmdLine);
+ IProcess process = DebugPlugin.newProcess(new Launch(null, ILaunchManager.RUN_MODE, null), p, "Library Detection"); //$NON-NLS-1$
+ for (int i= 0; i < 200; i++) {
+ // Wait no more than 10 seconds (200 * 50 mils)
+ if (process.isTerminated()) {
+ break;
+ }
+ try {
+ Thread.sleep(50);
+ } catch (InterruptedException e) {
+ }
+ }
+ info = parseLibraryInfo(process);
+ } catch (IOException ioe) {
+ LaunchingPlugin.log(ioe);
+ } finally {
+ if (p != null) {
+ p.destroy();
+ }
+ }
+ }
+ if (info == null) {
+ // log error that we were unable to generate library info - see bug 70011
+ LaunchingPlugin.log(MessageFormat.format("Failed to retrieve default libraries for {0}", rubyHome.getAbsolutePath())); //$NON-NLS-1$
+ }
+ return info;
+ }
+
+ /**
+ * Parses the output from 'LibraryDetector'.
+ */
+ protected LibraryInfo parseLibraryInfo(IProcess process) {
+ IStreamsProxy streamsProxy = process.getStreamsProxy();
+ String text = null;
+ if (streamsProxy != null) {
+ text = streamsProxy.getOutputStreamMonitor().getContents();
+ }
+ BufferedReader reader = new BufferedReader(new StringReader(text));
+ List<String> lines = new ArrayList<String>();
+ try {
+ String line = null;
+ while ((line = reader.readLine()) != null) {
+ lines.add(line);
+ }
+ } catch (IOException e) {
+ LaunchingPlugin.log(e);
+ }
+ if (lines.size() > 0) {
+ String version = lines.remove(0);
+ removeNotExistingLibs(lines);
+ if (lines.size() > 0) {
+ String[] loadpath = lines.toArray(new String[lines.size()]);
+ return new LibraryInfo(version, loadpath);
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Do not consider libraries which does not exist.
+ * @param libraries
+ */
+ private void removeNotExistingLibs(List<String> libraries) {
+ List<String> toRemove = new ArrayList<String>();
+ for (String path : libraries) {
+ File file = new File(path);
+ if (!file.exists())
+ toRemove.add(path);
+ }
+ libraries.removeAll(toRemove);
+ }
+
+ public File findExecutable(File installLocation) {
+ return findRubyExecutable(installLocation);
+ }
+
+ public String getVMVersion(File installLocation, File executable) {
+ LibraryInfo info = getLibraryInfo(installLocation, executable);
+ return info.getVersion();
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/JRubyVMType.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java 2007-09-14 21:30:35 UTC (rev 3185)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVM.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -18,11 +18,6 @@
public class StandardVM extends AbstractVMInstall {
- /**
- * Convenience handle to the system-specific file separator character
- */
- private static final char fgSeparator = File.separatorChar;
-
public StandardVM(IVMInstallType type, String id) {
super(type, id);
}
@@ -45,10 +40,10 @@
}
public String getRubyVersion() {
- StandardVMType installType = (StandardVMType) getVMInstallType();
+ IVMInstallType installType = getVMInstallType();
File installLocation = getInstallLocation();
if (installLocation != null) {
- File executable = StandardVMType.findRubyExecutable(installLocation);
+ File executable = installType.findExecutable(installLocation);
if (executable != null) {
String vmVersion = installType.getVMVersion(installLocation, executable);
// strip off extra info
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java 2007-09-14 21:30:35 UTC (rev 3185)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMDebugger.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -28,6 +28,8 @@
public class StandardVMDebugger extends StandardVMRunner implements IVMRunner {
+ private boolean isVMArgs = true;
+
public StandardVMDebugger(IVMInstall vmInstance) {
super(vmInstance);
}
@@ -71,7 +73,7 @@
// options like '-client' & '-server' which are required to be the first
// options
String[] allVMArgs = combineVmArgs(config, fVMInstance);
- addArguments(allVMArgs, arguments);
+ addArguments(allVMArgs, arguments, isVMArgs );
String[] cp = config.getLoadPath();
if (cp.length > 0) {
@@ -85,7 +87,7 @@
arguments.addAll(debugArgs(debugTarget));
arguments.add(config.getFileToLaunch());
- addArguments(config.getProgramArguments(), arguments);
+ addArguments(config.getProgramArguments(), arguments, !isVMArgs);
String[] cmdLine = new String[arguments.size()];
arguments.toArray(cmdLine);
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-09-14 21:30:35 UTC (rev 3185)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMRunner.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -39,6 +39,7 @@
protected static final String END_OF_OPTIONS_DELIMITER = "--";
protected IVMInstall fVMInstance;
+ private boolean isVMArgs = true;
public StandardVMRunner(IVMInstall vmInstance) {
fVMInstance= vmInstance;
@@ -84,7 +85,7 @@
return buf.toString();
}
- protected void addArguments(String[] args, List<String> v) {
+ protected void addArguments(String[] args, List<String> v, boolean isVMArgs) {
if (args == null) {
return;
}
@@ -144,7 +145,7 @@
// If no ruby command was specified, use default executable
if (command == null) {
- File exe = StandardVMType.findRubyExecutable(fVMInstance.getInstallLocation());
+ File exe = fVMInstance.getVMInstallType().findExecutable(fVMInstance.getInstallLocation());
if (exe == null) {
abort(MessageFormat.format(LaunchingMessages.StandardVMRunner_Unable_to_locate_executable_for__0__1, fVMInstance.getName()), null, IRubyLaunchConfigurationConstants.ERR_INTERNAL_ERROR);
}
@@ -226,7 +227,7 @@
// VM args are the first thing after the ruby program so that users can specify
// options like '-client' & '-server' which are required to be the first option
String[] allVMArgs = combineVmArgs(config, fVMInstance);
- addArguments(allVMArgs, arguments);
+ addArguments(allVMArgs, arguments, isVMArgs );
String[] lp= config.getLoadPath();
if (lp.length > 0) {
@@ -238,7 +239,7 @@
arguments.add(config.getFileToLaunch());
String[] programArgs= config.getProgramArguments();
- addArguments(programArgs, arguments);
+ addArguments(programArgs, arguments, !isVMArgs);
String[] cmdLine= new String[arguments.size()];
arguments.toArray(cmdLine);
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-09-14 21:30:35 UTC (rev 3185)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/StandardVMType.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -41,7 +41,7 @@
* The list of locations in which to look for the ruby executable in candidate
* VM install locations, relative to the VM install location.
*/
- private static final String[] fgCandidateRubyFiles = {"rubyw", "rubyw.exe", "ruby", "ruby.exe", "jrubyw", "jrubyw.bat", "jruby", "jruby.bat"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$ //$NON-NLS-7$ //$NON-NLS-8$
+ private static final String[] fgCandidateRubyFiles = {"rubyw", "rubyw.exe", "ruby", "ruby.exe"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
private static final String[] fgCandidateRubyLocations = {"", "bin" + fgSeparator}; //$NON-NLS-1$ //$NON-NLS-2$
@@ -351,5 +351,9 @@
}
return null;
}
+
+ public File findExecutable(File installLocation) {
+ return findRubyExecutable(installLocation);
+ }
}
Modified: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMInstallType.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMInstallType.java 2007-09-14 21:30:35 UTC (rev 3185)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/launching/IVMInstallType.java 2007-09-14 21:30:48 UTC (rev 3186)
@@ -107,4 +107,8 @@
*/
public File detectInstallLocation();
+ File findExecutable(File installLocation);
+
+ String getVMVersion(File installLocation, File executable);
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:30:36
|
Revision: 3185
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3185&view=rev
Author: cawilliams
Date: 2007-09-14 14:30:35 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
add a new JRuby VM Type, fix invocation of jruby.bat with -e args
Modified Paths:
--------------
trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
Modified: trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java
===================================================================
--- trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-14 21:30:29 UTC (rev 3184)
+++ trunk/com.aptana.rdt/src/com/aptana/rdt/internal/core/gems/GemManager.java 2007-09-14 21:30:35 UTC (rev 3185)
@@ -309,7 +309,7 @@
List<String> line = new ArrayList<String>();
IVMInstall vm = RubyRuntime.getDefaultVMInstall();
if (vm == null) return "";
- File executable = StandardVMType.findRubyExecutable(vm.getInstallLocation());
+ File executable = vm.getVMInstallType().findExecutable(vm.getInstallLocation());
line.add(executable.getAbsolutePath());
line.add(getGemScriptPath());
for (String command : commands) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 21:30:31
|
Revision: 3184
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3184&view=rev
Author: cawilliams
Date: 2007-09-14 14:30:29 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
add a new JRuby VM Type, fix invocation of jruby.bat with -e args
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-09-14 16:09:55 UTC (rev 3183)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/infoviews/RIView.java 2007-09-14 21:30:29 UTC (rev 3184)
@@ -361,7 +361,7 @@
List<String> line = new ArrayList<String>();
IVMInstall vm = RubyRuntime.getDefaultVMInstall();
if (vm == null) return "";
- File executable = StandardVMType.findRubyExecutable(vm.getInstallLocation());
+ File executable = vm.getVMInstallType().findExecutable(vm.getInstallLocation());
if (executable.getName().contains("rubyw")) {
String name = executable.getName();
name = name.replace("rubyw", "ruby");
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-09-14 16:09:55 UTC (rev 3183)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/hover/RiDocHoverProvider.java 2007-09-14 21:30:29 UTC (rev 3184)
@@ -110,7 +110,7 @@
List<String> line = new ArrayList<String>();
IVMInstall vm = RubyRuntime.getDefaultVMInstall();
if (vm == null) return "";
- File executable = StandardVMType.findRubyExecutable(vm.getInstallLocation());
+ File executable = vm.getVMInstallType().findExecutable(vm.getInstallLocation());
if (executable.getName().contains("rubyw")) {
String name = executable.getName();
name = name.replace("rubyw", "ruby");
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 16:09:57
|
Revision: 3183
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3183&view=rev
Author: cawilliams
Date: 2007-09-14 09:09:55 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
finally! fix #4947 - [Mac OS X | 0.2.8.15171] Debug As Ruby Application menu doesn't appear.
Now Run As and Debug As should appear in right-click context menu in Ruby Explorer!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/plugin.xml
Modified: trunk/org.rubypeople.rdt.debug.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/plugin.xml 2007-09-14 16:09:49 UTC (rev 3182)
+++ trunk/org.rubypeople.rdt.debug.ui/plugin.xml 2007-09-14 16:09:55 UTC (rev 3183)
@@ -371,4 +371,23 @@
visible="false"/>
</perspectiveExtension>
</extension>
+
+ <!-- Adapters for contextual launch -->
+ <extension point="org.eclipse.core.runtime.adapters">
+ <factory
+ class=""
+ adaptableType="org.rubypeople.rdt.core.IRubyElement">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory>
+ <factory
+ class=""
+ adaptableType="org.eclipse.core.resources.IResource">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory>
+<!-- <factory
+ class=""
+ adaptableType="org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptEditorInput">
+ <adapter type="org.eclipse.debug.ui.actions.ILaunchable"/>
+ </factory> -->
+ </extension>
</plugin>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 16:09:50
|
Revision: 3182
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3182&view=rev
Author: cawilliams
Date: 2007-09-14 09:09:49 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
finally! fix #4947 - [Mac OS X | 0.2.8.15171] Debug As Ruby Application menu doesn't appear.
Now Run As and Debug As should appear in right-click context menu in Ruby Explorer!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementAdapterFactory.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
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyElementResourceMapping.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IResourceLocator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/PersistableRubyElementFactory.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ResourceLocator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementContainmentAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementProperties.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyWorkbenchAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyModelProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyResourceMapping.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPageScoreComputer.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-14 15:25:10 UTC (rev 3181)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-14 16:09:49 UTC (rev 3182)
@@ -1359,6 +1359,26 @@
<extension point="org.eclipse.core.runtime.adapters">
<factory
+ class="org.rubypeople.rdt.internal.ui.RubyElementAdapterFactory"
+ adaptableType="org.rubypeople.rdt.core.IRubyElement">
+
+ <adapter type="org.eclipse.core.resources.IResource"/>
+
+ <adapter type="org.eclipse.ui.IPersistableElement"/>
+ <adapter type="org.eclipse.ui.IContributorResourceAdapter"/>
+ <adapter type="org.eclipse.ui.ide.IContributorResourceAdapter2"/>
+ <adapter type="org.eclipse.ui.IContainmentAdapter"/>
+
+ <adapter type="org.eclipse.search.ui.ISearchPageScoreComputer"/>
+
+ <adapter type="org.eclipse.ui.model.IWorkbenchAdapter"/>
+ <adapter type="org.eclipse.ui.views.properties.IPropertySource"/>
+ <adapter type="org.eclipse.ui.views.tasklist.ITaskListResourceAdapter"/>
+
+ <adapter type="org.rubypeople.rdt.internal.ui.IResourceLocator"/>
+ </factory>
+
+ <factory
class="org.rubypeople.rdt.internal.ui.RubyProjectAdapterFactory"
adaptableType="org.rubypeople.rdt.core.IRubyProject">
<adapter type="org.eclipse.core.resources.IProject"/>
@@ -1369,16 +1389,6 @@
adaptableType="org.eclipse.core.resources.IResource">
<adapter type="org.rubypeople.rdt.core.IRubyElement"/>
</factory>
-
- <factory
- class="org.rubypeople.rdt.internal.ui.RubyElementAdapterFactory"
- adaptableType="org.rubypeople.rdt.core.IRubyElement">
-
- <adapter type="org.eclipse.core.resources.IResource"/>
- <adapter type="org.eclipse.ui.IContributorResourceAdapter"/>
-
- <adapter type="org.eclipse.ui.views.tasklist.ITaskListResourceAdapter"/>
- </factory>
</extension>
<extension
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyElementResourceMapping.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyElementResourceMapping.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyElementResourceMapping.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,352 @@
+/*******************************************************************************
+ * 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.corext.util;
+
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.mapping.RemoteResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyModel;
+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;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.model.RubyModelProvider;
+
+/**
+ * An abstract super class to describe mappings from a Ruby element to a
+ * set of resources. The class also provides factory methods to create
+ * resource mappings.
+ *
+ * @since 3.1
+ */
+public abstract class RubyElementResourceMapping extends ResourceMapping {
+
+ protected RubyElementResourceMapping() {
+ }
+
+ public IRubyElement getRubyElement() {
+ Object o= getModelObject();
+ if (o instanceof IRubyElement)
+ return (IRubyElement)o;
+ return null;
+ }
+
+ public boolean equals(Object obj) {
+ if (!(obj instanceof RubyElementResourceMapping))
+ return false;
+ return getRubyElement().equals(((RubyElementResourceMapping)obj).getRubyElement());
+ }
+
+ public int hashCode() {
+ IRubyElement javaElement= getRubyElement();
+ if (javaElement == null)
+ return super.hashCode();
+
+ return javaElement.hashCode();
+ }
+
+ public String getModelProviderId() {
+ return RubyModelProvider.RUBY_MODEL_PROVIDER_ID;
+ }
+
+ public boolean contains(ResourceMapping mapping) {
+ if (mapping instanceof RubyElementResourceMapping) {
+ RubyElementResourceMapping javaMapping = (RubyElementResourceMapping) mapping;
+ IRubyElement element = getRubyElement();
+ IRubyElement other = javaMapping.getRubyElement();
+ if (other != null && element != null)
+ return element.getPath().isPrefixOf(other.getPath());
+ }
+ return false;
+ }
+
+ //---- the factory code ---------------------------------------------------------------
+
+ private static final class RubyModelResourceMapping extends RubyElementResourceMapping {
+ private final IRubyModel fRubyModel;
+ private RubyModelResourceMapping(IRubyModel model) {
+ Assert.isNotNull(model);
+ fRubyModel= model;
+ }
+ public Object getModelObject() {
+ return fRubyModel;
+ }
+ public IProject[] getProjects() {
+ IRubyProject[] projects= null;
+ try {
+ projects= fRubyModel.getRubyProjects();
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ return new IProject[0];
+ }
+ IProject[] result= new IProject[projects.length];
+ for (int i= 0; i < projects.length; i++) {
+ result[i]= projects[i].getProject();
+ }
+ return result;
+ }
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ IRubyProject[] projects= fRubyModel.getRubyProjects();
+ ResourceTraversal[] result= new ResourceTraversal[projects.length];
+ for (int i= 0; i < projects.length; i++) {
+ result[i]= new ResourceTraversal(new IResource[] {projects[i].getProject()}, IResource.DEPTH_INFINITE, 0);
+ }
+ return result;
+ }
+ }
+
+ private static final class RubyProjectResourceMapping extends RubyElementResourceMapping {
+ private final IRubyProject fProject;
+ private RubyProjectResourceMapping(IRubyProject project) {
+ Assert.isNotNull(project);
+ fProject= project;
+ }
+ public Object getModelObject() {
+ return fProject;
+ }
+ public IProject[] getProjects() {
+ return new IProject[] {fProject.getProject() };
+ }
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ return new ResourceTraversal[] {
+ new ResourceTraversal(new IResource[] {fProject.getProject()}, IResource.DEPTH_INFINITE, 0)
+ };
+ }
+ }
+
+ private static final class PackageFragementRootResourceMapping extends RubyElementResourceMapping {
+ private final ISourceFolderRoot fRoot;
+ private PackageFragementRootResourceMapping(ISourceFolderRoot root) {
+ Assert.isNotNull(root);
+ fRoot= root;
+ }
+ public Object getModelObject() {
+ return fRoot;
+ }
+ public IProject[] getProjects() {
+ return new IProject[] {fRoot.getRubyProject().getProject() };
+ }
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ return new ResourceTraversal[] {
+ new ResourceTraversal(new IResource[] {fRoot.getResource()}, IResource.DEPTH_INFINITE, 0)
+ };
+ }
+ }
+
+ private static final class LocalPackageFragementTraversal extends ResourceTraversal {
+ private final ISourceFolder fPack;
+ public LocalPackageFragementTraversal(ISourceFolder pack) throws CoreException {
+ super(new IResource[] {pack.getResource()}, IResource.DEPTH_ONE, 0);
+ fPack= pack;
+ }
+ public void accept(IResourceVisitor visitor) throws CoreException {
+ IFile[] files= getPackageContent(fPack);
+ final IResource resource= fPack.getResource();
+ if (resource != null)
+ visitor.visit(resource);
+ for (int i= 0; i < files.length; i++) {
+ visitor.visit(files[i]);
+ }
+ }
+ }
+
+ private static final class SourceFolderResourceMapping extends RubyElementResourceMapping {
+ private final ISourceFolder fPack;
+ private SourceFolderResourceMapping(ISourceFolder pack) {
+ Assert.isNotNull(pack);
+ fPack= pack;
+ }
+ public Object getModelObject() {
+ return fPack;
+ }
+ public IProject[] getProjects() {
+ return new IProject[] { fPack.getRubyProject().getProject() };
+ }
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ if (context instanceof RemoteResourceMappingContext) {
+ return new ResourceTraversal[] {
+ new ResourceTraversal(new IResource[] {fPack.getResource()}, IResource.DEPTH_ONE, 0)
+ };
+ } else {
+ return new ResourceTraversal[] { new LocalPackageFragementTraversal(fPack) };
+ }
+ }
+ public void accept(ResourceMappingContext context, IResourceVisitor visitor, IProgressMonitor monitor) throws CoreException {
+ if (context instanceof RemoteResourceMappingContext) {
+ super.accept(context, visitor, monitor);
+ } else {
+ // We assume a local context.
+ IFile[] files= getPackageContent(fPack);
+ if (monitor == null)
+ monitor= new NullProgressMonitor();
+ monitor.beginTask("", files.length + 1); //$NON-NLS-1$
+ final IResource resource= fPack.getResource();
+ if (resource != null)
+ visitor.visit(resource);
+ monitor.worked(1);
+ for (int i= 0; i < files.length; i++) {
+ visitor.visit(files[i]);
+ monitor.worked(1);
+ }
+ }
+ }
+ }
+
+ private static IFile[] getPackageContent(ISourceFolder pack) throws CoreException {
+ List result= new ArrayList();
+ IContainer container= (IContainer)pack.getResource();
+ if (container != null) {
+ IResource[] members= container.members();
+ for (int m= 0; m < members.length; m++) {
+ IResource member= members[m];
+ if (member instanceof IFile) {
+ IFile file= (IFile)member;
+ if ("class".equals(file.getFileExtension()) && file.isDerived()) //$NON-NLS-1$
+ continue;
+ result.add(member);
+ }
+ }
+ }
+ return (IFile[])result.toArray(new IFile[result.size()]);
+ }
+
+
+ private static final class RubyScriptResourceMapping extends RubyElementResourceMapping {
+ private final IRubyScript fUnit;
+ private RubyScriptResourceMapping(IRubyScript unit) {
+ Assert.isNotNull(unit);
+ fUnit= unit;
+ }
+ public Object getModelObject() {
+ return fUnit;
+ }
+ public IProject[] getProjects() {
+ return new IProject[] {fUnit.getRubyProject().getProject() };
+ }
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ return new ResourceTraversal[] {
+ new ResourceTraversal(new IResource[] {fUnit.getResource()}, IResource.DEPTH_ONE, 0)
+ };
+ }
+ }
+
+ private static final class LogicalPackageResourceMapping extends ResourceMapping {
+ private final ISourceFolder[] fFragments;
+ private LogicalPackageResourceMapping(ISourceFolder[] fragments) {
+ fFragments= fragments;
+ }
+ public Object getModelObject() {
+ return fFragments;
+ }
+ public IProject[] getProjects() {
+ Set result= new HashSet();
+ for (int i= 0; i < fFragments.length; i++) {
+ result.add(fFragments[i].getRubyProject().getProject());
+ }
+ return (IProject[])result.toArray(new IProject[result.size()]);
+ }
+ public ResourceTraversal[] getTraversals(ResourceMappingContext context, IProgressMonitor monitor) throws CoreException {
+ List result= new ArrayList();
+ if (context instanceof RemoteResourceMappingContext) {
+ for (int i= 0; i < fFragments.length; i++) {
+ result.add(new ResourceTraversal(
+ new IResource[] {fFragments[i].getResource()}, IResource.DEPTH_ONE, 0));
+ }
+ } else {
+ for (int i= 0; i < fFragments.length; i++) {
+ result.add(new LocalPackageFragementTraversal(fFragments[i]));
+ }
+ }
+ return (ResourceTraversal[])result.toArray(new ResourceTraversal[result.size()]);
+ }
+
+ public String getModelProviderId() {
+ return RubyModelProvider.RUBY_MODEL_PROVIDER_ID;
+ }
+ }
+
+ public static ResourceMapping create(IRubyElement element) {
+ switch (element.getElementType()) {
+ case IRubyElement.TYPE:
+ return create((IType)element);
+ case IRubyElement.SCRIPT:
+ return create((IRubyScript)element);
+ case IRubyElement.SOURCE_FOLDER:
+ return create((ISourceFolder)element);
+ case IRubyElement.SOURCE_FOLDER_ROOT:
+ return create((ISourceFolderRoot)element);
+ case IRubyElement.RUBY_PROJECT:
+ return create((IRubyProject)element);
+ case IRubyElement.RUBY_MODEL:
+ return create((IRubyModel)element);
+ default:
+ return null;
+ }
+
+ }
+
+ public static ResourceMapping create(final IRubyModel model) {
+ return new RubyModelResourceMapping(model);
+ }
+
+ public static ResourceMapping create(final IRubyProject project) {
+ return new RubyProjectResourceMapping(project);
+ }
+
+ public static ResourceMapping create(final ISourceFolderRoot root) {
+ if (root.isExternal())
+ return null;
+ return new PackageFragementRootResourceMapping(root);
+ }
+
+ public static ResourceMapping create(final ISourceFolder pack) {
+ // test if in an archive
+ ISourceFolderRoot root= (ISourceFolderRoot)pack.getAncestor(IRubyElement.SOURCE_FOLDER_ROOT);
+ if (!root.isExternal()) {
+ return new SourceFolderResourceMapping(pack);
+ }
+ return null;
+ }
+
+ public static ResourceMapping create(IRubyScript unit) {
+ if (unit == null)
+ return null;
+ return new RubyScriptResourceMapping(unit.getPrimary());
+ }
+
+ public static ResourceMapping create(IType type) {
+ // top level types behave like the CU
+ IRubyElement parent= type.getParent();
+ if (parent instanceof IRubyScript) {
+ return create((IRubyScript)parent);
+ }
+ return null;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/RubyElementResourceMapping.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IResourceLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IResourceLocator.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IResourceLocator.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.RubyModelException;
+
+/**
+ * This interface allows to locate different
+ * resources which are related to an object
+ */
+public interface IResourceLocator {
+ /**
+ * Returns the underlying finest granularity resource that contains
+ * the element, or <code>null</code> if the element is not contained
+ * in a resource (for example, a working copy, or an element contained
+ * in an external archive).
+ *
+ * @param element the element for which the resource is located
+ * @return the underlying resource
+ * @exception RubyModelException if the element does not exist or if an
+ * exception occurs while accessing its underlying resource
+ * @see org.eclipse.jdt.core.IRubyElement#getUnderlyingResource()
+ */
+ IResource getUnderlyingResource(Object element) throws RubyModelException;
+ /**
+ * Returns the resource that corresponds directly to the element,
+ * or <code>null</code> if there is no resource that corresponds to
+ * the element.
+ *
+ * <p>For example, the corresponding resource for an <code>ICompilationUnit</code>
+ * is its underlying <code>IFile</code>. The corresponding resource for
+ * an <code>IPackageFragment</code> that is not contained in an archive
+ * is its underlying <code>IFolder</code>. An <code>IPackageFragment</code>
+ * contained in an archive has no corresponding resource. Similarly, there
+ * are no corresponding resources for <code>IMethods</code>,
+ * <code>IFields</code>, etc.
+ *
+ * @param element the element for which the resource is located
+ * @return the corresponding resource
+ * @exception RubyModelException if the element does not exist or if an
+ * exception occurs while accessing its corresponding resource
+ * @see org.eclipse.jdt.core.IRubyElement#getCorrespondingResource()
+ */
+ IResource getCorrespondingResource(Object element) throws RubyModelException;
+ /**
+ * Returns the resource that contains the element. If the element is not
+ * directly contained by a resource then a helper resource or <code>null</code>
+ * is returned. Clients define the helper resource as needed.
+ *
+ * @param element the element for which the resource is located
+ * @return the containing resource
+ * @exception RubyModelException if the element does not exist or if an
+ * exception occurs while accessing its containing resource
+ */
+ IResource getContainingResource(Object element) throws RubyModelException;
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/IResourceLocator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/PersistableRubyElementFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/PersistableRubyElementFactory.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/PersistableRubyElementFactory.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IElementFactory;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IPersistableElement;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyCore;
+
+/**
+ * The RubyElementFactory is used to save and recreate an IRubyElement object.
+ * As such, it implements the IPersistableElement interface for storage
+ * and the IElementFactory interface for recreation.
+ *
+ * @see IMemento
+ * @see IPersistableElement
+ * @see IElementFactory
+ */
+public class PersistableRubyElementFactory implements IElementFactory, IPersistableElement {
+
+ private static final String KEY= "elementID"; //$NON-NLS-1$
+ private static final String FACTORY_ID= "org.rubypeople.rdt.ui.PersistableRubyElementFactory"; //$NON-NLS-1$
+
+ private IRubyElement fElement;
+
+ /**
+ * Create a RubyElementFactory.
+ */
+ public PersistableRubyElementFactory() {
+ }
+
+ /**
+ * Create a RubyElementFactory. This constructor is typically used
+ * for our IPersistableElement side.
+ */
+ public PersistableRubyElementFactory(IRubyElement element) {
+ fElement= element;
+ }
+
+ /*
+ * @see IElementFactory
+ */
+ public IAdaptable createElement(IMemento memento) {
+
+ String identifier= memento.getString(KEY);
+ if (identifier != null) {
+ return RubyCore.create(identifier);
+ }
+ return null;
+ }
+
+ /*
+ * @see IPersistableElement.
+ */
+ public String getFactoryId() {
+ return FACTORY_ID;
+ }
+ /*
+ * @see IPersistableElement
+ */
+ public void saveState(IMemento memento) {
+ memento.putString(KEY, fElement.getHandleIdentifier());
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/PersistableRubyElementFactory.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ResourceLocator.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ResourceLocator.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ResourceLocator.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.resources.IResource;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+
+/**
+ * This class locates different resources
+ * which are related to an object
+ */
+public class ResourceLocator implements IResourceLocator {
+
+ public IResource getUnderlyingResource(Object element) throws RubyModelException {
+ if (element instanceof IRubyElement)
+ return ((IRubyElement) element).getUnderlyingResource();
+ else
+ return null;
+ }
+
+ public IResource getCorrespondingResource(Object element) throws RubyModelException {
+ if (element instanceof IRubyElement)
+ return ((IRubyElement) element).getCorrespondingResource();
+ else
+ return null;
+ }
+
+ public IResource getContainingResource(Object element) throws RubyModelException {
+ IResource resource= null;
+ if (element instanceof IResource)
+ resource= (IResource) element;
+ if (element instanceof IRubyElement) {
+ resource= ((IRubyElement) element).getResource();
+ if (resource == null)
+ resource= ((IRubyElement) element).getRubyProject().getProject();
+ }
+ return resource;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ResourceLocator.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementAdapterFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementAdapterFactory.java 2007-09-14 15:25:10 UTC (rev 3181)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementAdapterFactory.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -1,96 +1,206 @@
/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
+ * 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/cpl-v10.html
- *
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.rubypeople.rdt.internal.ui;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+import org.eclipse.ui.IContainmentAdapter;
import org.eclipse.ui.IContributorResourceAdapter;
+import org.eclipse.ui.IPersistableElement;
+import org.eclipse.ui.ide.IContributorResourceAdapter2;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.views.properties.FilePropertySource;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.ResourcePropertySource;
import org.eclipse.ui.views.tasklist.ITaskListResourceAdapter;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.ISourceFolder;
import org.rubypeople.rdt.core.ISourceFolderRoot;
-import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
+import org.rubypeople.rdt.internal.corext.util.RubyElementResourceMapping;
+import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptEditorInput;
+import org.rubypeople.rdt.internal.ui.search.RubySearchPageScoreComputer;
+import org.rubypeople.rdt.internal.ui.search.SearchUtil;
/**
- * Implements basic UI support for Ruby elements. Implements handle to
- * persistent support for Ruby elements.
+ * Implements basic UI support for Ruby elements.
+ * Implements handle to persistent support for Ruby elements.
*/
-public class RubyElementAdapterFactory implements IAdapterFactory, IContributorResourceAdapter{
-
- private static Class[] PROPERTIES = new Class[] { IResource.class, IContributorResourceAdapter.class, ITaskListResourceAdapter.class};
-
+public class RubyElementAdapterFactory implements IAdapterFactory, IContributorResourceAdapter, IContributorResourceAdapter2 {
+
+ private static Class[] PROPERTIES= new Class[] {
+ IPropertySource.class,
+ IResource.class,
+ IWorkbenchAdapter.class,
+ IResourceLocator.class,
+ IPersistableElement.class,
+ IContributorResourceAdapter.class,
+ IContributorResourceAdapter2.class,
+ ITaskListResourceAdapter.class,
+ IContainmentAdapter.class
+ };
+
+ /*
+ * Do not use real type since this would cause
+ * the Search plug-in to be loaded.
+ */
+ private Object fSearchPageScoreComputer;
+ private static IResourceLocator fgResourceLocator;
+ private static RubyWorkbenchAdapter fgRubyWorkbenchAdapter;
private static ITaskListResourceAdapter fgTaskListAdapter;
-
+ private static RubyElementContainmentAdapter fgRubyElementContainmentAdapter;
+
public Class[] getAdapterList() {
+ updateLazyLoadedAdapters();
return PROPERTIES;
}
-
+
public Object getAdapter(Object element, Class key) {
- IRubyElement ruby = getRubyElement(element);
-
- if (IResource.class.equals(key)) { return getResource(ruby); }
- if (IContributorResourceAdapter.class.equals(key)) { return this; }
- if (ITaskListResourceAdapter.class.equals(key)) { return getTaskListAdapter(); }
- return null;
+ updateLazyLoadedAdapters();
+ IRubyElement java= getRubyElement(element);
+
+ if (IPropertySource.class.equals(key)) {
+ return getProperties(java);
+ } if (IResource.class.equals(key)) {
+ return getResource(java);
+ } if (fSearchPageScoreComputer != null && ISearchPageScoreComputer.class.equals(key)) {
+ return fSearchPageScoreComputer;
+ } if (IWorkbenchAdapter.class.equals(key)) {
+ return getRubyWorkbenchAdapter();
+ } if (IResourceLocator.class.equals(key)) {
+ return getResourceLocator();
+ } if (IPersistableElement.class.equals(key)) {
+ return new PersistableRubyElementFactory(java);
+ } if (IContributorResourceAdapter.class.equals(key)) {
+ return this;
+ } if (IContributorResourceAdapter2.class.equals(key)) {
+ return this;
+ } if (ITaskListResourceAdapter.class.equals(key)) {
+ return getTaskListAdapter();
+ } if (IContainmentAdapter.class.equals(key)) {
+ return getRubyElementContainmentAdapter();
+ }
+ return null;
}
-
+
private IResource getResource(IRubyElement element) {
- // can't use IRubyElement.getResource directly as we are interrested in
- // the
+ // can't use IRubyElement.getResource directly as we are interested in the
// corresponding resource
switch (element.getElementType()) {
- case IRubyElement.TYPE:
- // top level types behave like the ruby script
- IRubyElement parent = element.getParent();
- if (parent instanceof IRubyScript) { return RubyModelUtil.toOriginal((IRubyScript) parent).getResource(); }
- return null;
- case IRubyElement.SCRIPT:
- return RubyModelUtil.toOriginal((IRubyScript) element).getResource();
- case IRubyElement.SOURCE_FOLDER:
- ISourceFolder folder = (ISourceFolder) element;
- ISourceFolderRoot root= (ISourceFolderRoot) element.getAncestor(IRubyElement.SOURCE_FOLDER_ROOT);
- if (!root.isExternal()) {
+ case IRubyElement.TYPE:
+ // top level types behave like the CU
+ IRubyElement parent= element.getParent();
+ if (parent instanceof IRubyScript) {
+ return ((IRubyScript) parent).getPrimary().getResource();
+ }
+ return null;
+ case IRubyElement.SCRIPT:
+ return ((IRubyScript) element).getPrimary().getResource();
+ case IRubyElement.SOURCE_FOLDER:
+ // test if external
+ ISourceFolderRoot root= (ISourceFolderRoot) element.getAncestor(IRubyElement.SOURCE_FOLDER_ROOT);
+ if (!root.isExternal()) {
+ return element.getResource();
+ }
+ return null;
+ case IRubyElement.SOURCE_FOLDER_ROOT:
+ case IRubyElement.RUBY_PROJECT:
+ case IRubyElement.RUBY_MODEL:
return element.getResource();
- }
- return null;
- case IRubyElement.SOURCE_FOLDER_ROOT:
- root = (ISourceFolderRoot) element;
- if (root.isExternal()) {
+ default:
return null;
- }
- return root.getResource();
- case IRubyElement.RUBY_PROJECT:
- case IRubyElement.RUBY_MODEL:
- return element.getResource();
- default:
- return null;
- }
- }
+ }
+ }
- public IResource getAdaptedResource(IAdaptable adaptable) {
- IRubyElement je = getRubyElement(adaptable);
- if (je != null) return getResource(je);
+ public IResource getAdaptedResource(IAdaptable adaptable) {
+ IRubyElement je= getRubyElement(adaptable);
+ if (je != null)
+ return getResource(je);
- return null;
- }
+ return null;
+ }
+
+ public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) {
+ IRubyElement je= getRubyElement(adaptable);
+ if (je != null)
+ return RubyElementResourceMapping.create(je);
+ return null;
+ }
+
private IRubyElement getRubyElement(Object element) {
- if (element instanceof IRubyElement) return (IRubyElement) element;
+ if (element instanceof IRubyElement)
+ return (IRubyElement)element;
+ if (element instanceof IRubyScriptEditorInput)
+ return ((IRubyScriptEditorInput)element).getRubyScript().getPrimaryElement();
+
return null;
}
+
+ private IPropertySource getProperties(IRubyElement element) {
+ IResource resource= getResource(element);
+ if (resource == null)
+ return new RubyElementProperties(element);
+ if (resource.getType() == IResource.FILE)
+ return new FilePropertySource((IFile) resource);
+ return new ResourcePropertySource(resource);
+ }
+ private void updateLazyLoadedAdapters() {
+ if (fSearchPageScoreComputer == null && SearchUtil.isSearchPlugInActivated())
+ createSearchPageScoreComputer();
+ }
+
+ private void createSearchPageScoreComputer() {
+ fSearchPageScoreComputer= new RubySearchPageScoreComputer();
+ PROPERTIES= new Class[] {
+ IPropertySource.class,
+ IResource.class,
+ ISearchPageScoreComputer.class,
+ IWorkbenchAdapter.class,
+ IResourceLocator.class,
+ IPersistableElement.class,
+ IProject.class,
+ IContributorResourceAdapter.class,
+ IContributorResourceAdapter2.class,
+ ITaskListResourceAdapter.class,
+ IContainmentAdapter.class
+ };
+ }
+
+ private static IResourceLocator getResourceLocator() {
+ if (fgResourceLocator == null)
+ fgResourceLocator= new ResourceLocator();
+ return fgResourceLocator;
+ }
+
+ private static RubyWorkbenchAdapter getRubyWorkbenchAdapter() {
+ if (fgRubyWorkbenchAdapter == null)
+ fgRubyWorkbenchAdapter= new RubyWorkbenchAdapter();
+ return fgRubyWorkbenchAdapter;
+ }
+
private static ITaskListResourceAdapter getTaskListAdapter() {
- if (fgTaskListAdapter == null) fgTaskListAdapter = new RubyTaskListAdapter();
+ if (fgTaskListAdapter == null)
+ fgTaskListAdapter= new RubyTaskListAdapter();
return fgTaskListAdapter;
}
+
+ private static RubyElementContainmentAdapter getRubyElementContainmentAdapter() {
+ if (fgRubyElementContainmentAdapter == null)
+ fgRubyElementContainmentAdapter= new RubyElementContainmentAdapter();
+ return fgRubyElementContainmentAdapter;
+ }
}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementContainmentAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementContainmentAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementContainmentAdapter.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,137 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.ui.IContainmentAdapter;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyModel;
+import org.rubypeople.rdt.core.RubyCore;
+
+public class RubyElementContainmentAdapter implements IContainmentAdapter {
+
+ private IRubyModel fRubyModel= RubyCore.create(ResourcesPlugin.getWorkspace().getRoot());
+
+ public boolean contains(Object workingSetElement, Object element, int flags) {
+ if (!(workingSetElement instanceof IRubyElement) || element == null)
+ return false;
+
+ IRubyElement workingSetRubyElement= (IRubyElement)workingSetElement;
+ IResource resource= null;
+ IRubyElement jElement= null;
+ if (element instanceof IRubyElement) {
+ jElement= (IRubyElement)element;
+ resource= jElement.getResource();
+ } else {
+ if (element instanceof IAdaptable) {
+ resource= (IResource)((IAdaptable)element).getAdapter(IResource.class);
+ if (resource != null) {
+ if (fRubyModel.contains(resource)) {
+ jElement= RubyCore.create(resource);
+ if (jElement != null && !jElement.exists())
+ jElement= null;
+ }
+ }
+ }
+ }
+
+ if (jElement != null) {
+ if (contains(workingSetRubyElement, jElement, flags))
+ return true;
+ if (workingSetRubyElement.getElementType() == IRubyElement.SOURCE_FOLDER &&
+ resource.getType() == IResource.FOLDER && checkIfDescendant(flags))
+ return isChild(workingSetRubyElement, resource);
+ } else if (resource != null) {
+ return contains(workingSetRubyElement, resource, flags);
+ }
+ return false;
+ }
+
+ private boolean contains(IRubyElement workingSetElement, IRubyElement element, int flags) {
+ if (checkContext(flags) && workingSetElement.equals(element)) {
+ return true;
+ }
+ if (checkIfChild(flags) && workingSetElement.equals(element.getParent())) {
+ return true;
+ }
+ if (checkIfDescendant(flags) && check(workingSetElement, element)) {
+ return true;
+ }
+ if (checkIfAncestor(flags) && check(element, workingSetElement)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean check(IRubyElement ancestor, IRubyElement descendent) {
+ descendent= descendent.getParent();
+ while (descendent != null) {
+ if (ancestor.equals(descendent))
+ return true;
+ descendent= descendent.getParent();
+ }
+ return false;
+ }
+
+ private boolean isChild(IRubyElement workingSetElement, IResource element) {
+ IResource resource= workingSetElement.getResource();
+ if (resource == null)
+ return false;
+ return check(element, resource);
+ }
+
+ private boolean contains(IRubyElement workingSetElement, IResource element, int flags) {
+ IResource workingSetResource= workingSetElement.getResource();
+ if (workingSetResource == null)
+ return false;
+ if (checkContext(flags) && workingSetResource.equals(element)) {
+ return true;
+ }
+ if (checkIfChild(flags) && workingSetResource.equals(element.getParent())) {
+ return true;
+ }
+ if (checkIfDescendant(flags) && check(workingSetResource, element)) {
+ return true;
+ }
+ if (checkIfAncestor(flags) && check(element, workingSetResource)) {
+ return true;
+ }
+ return false;
+ }
+
+ private boolean check(IResource ancestor, IResource descendent) {
+ descendent= descendent.getParent();
+ while(descendent != null) {
+ if (ancestor.equals(descendent))
+ return true;
+ descendent= descendent.getParent();
+ }
+ return false;
+ }
+
+ private boolean checkIfDescendant(int flags) {
+ return (flags & CHECK_IF_DESCENDANT) != 0;
+ }
+
+ private boolean checkIfAncestor(int flags) {
+ return (flags & CHECK_IF_ANCESTOR) != 0;
+ }
+
+ private boolean checkIfChild(int flags) {
+ return (flags & CHECK_IF_CHILD) != 0;
+ }
+
+ private boolean checkContext(int flags) {
+ return (flags & CHECK_CONTEXT) != 0;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementContainmentAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementProperties.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementProperties.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementProperties.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * 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.ui;
+
+
+import org.eclipse.jface.viewers.IBasicPropertyConstants;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+import org.rubypeople.rdt.core.IRubyElement;
+
+public class RubyElementProperties implements IPropertySource {
+
+ private IRubyElement fSource;
+
+ // Property Descriptors
+ private static final IPropertyDescriptor[] fgPropertyDescriptors= new IPropertyDescriptor[1];
+ static {
+ PropertyDescriptor descriptor;
+
+ // resource name
+ descriptor= new PropertyDescriptor(IBasicPropertyConstants.P_TEXT, RubyUIMessages.RubyElementProperties_name);
+ descriptor.setAlwaysIncompatible(true);
+ fgPropertyDescriptors[0]= descriptor;
+ }
+
+ public RubyElementProperties(IRubyElement source) {
+ fSource= source;
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ return fgPropertyDescriptors;
+ }
+
+ public Object getPropertyValue(Object name) {
+ if (name.equals(IBasicPropertyConstants.P_TEXT)) {
+ return fSource.getElementName();
+ }
+ return null;
+ }
+
+ public void setPropertyValue(Object name, Object value) {
+ }
+
+ public Object getEditableValue() {
+ return this;
+ }
+
+ public boolean isPropertySet(Object property) {
+ return false;
+ }
+
+ public void resetPropertyValue(Object property) {
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyElementProperties.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: 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.java 2007-09-14 15:25:10 UTC (rev 3181)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -107,6 +107,7 @@
public static String Spelling_ignore_label;
public static String RubyPlugin_initializing_ui;
public static String InitializeAfterLoadJob_starter_job_name;
+ public static String RubyElementProperties_name;
private RubyUIMessages() {
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-14 15:25:10 UTC (rev 3181)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-14 16:09:49 UTC (rev 3182)
@@ -3,6 +3,8 @@
# All Rights Reserved.
#########################################
+RubyElementProperties_name=Name
+
InitializeAfterLoadJob_starter_job_name=Starting Ruby Tooling initialization
RubyPlugin_initializing_ui=Initializing Ruby Tooling
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyWorkbenchAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyWorkbenchAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyWorkbenchAdapter.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.ui;
+
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.rubypeople.rdt.core.IParent;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptEditorInput;
+import org.rubypeople.rdt.internal.ui.viewsupport.RubyElementImageProvider;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+
+/**
+ * An imlementation of the IWorkbenchAdapter for IRubyElements.
+ */
+public class RubyWorkbenchAdapter implements IWorkbenchAdapter {
+
+ protected static final Object[] NO_CHILDREN= new Object[0];
+
+ private RubyElementImageProvider fImageProvider;
+
+ public RubyWorkbenchAdapter() {
+ fImageProvider= new RubyElementImageProvider();
+ }
+
+ public Object[] getChildren(Object element) {
+ IRubyElement je= getRubyElement(element);
+ if (je instanceof IParent) {
+ try {
+ return ((IParent)je).getChildren();
+ } catch(RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ }
+ return NO_CHILDREN;
+ }
+
+ public ImageDescriptor getImageDescriptor(Object element) {
+ IRubyElement je= getRubyElement(element);
+ if (je != null)
+ return fImageProvider.getRubyImageDescriptor(je, RubyElementImageProvider.OVERLAY_ICONS | RubyElementImageProvider.SMALL_ICONS);
+
+ return null;
+
+ }
+
+ public String getLabel(Object element) {
+ return RubyElementLabels.getTextLabel(getRubyElement(element), RubyElementLabels.ALL_DEFAULT);
+ }
+
+ public Object getParent(Object element) {
+ IRubyElement je= getRubyElement(element);
+ return je != null ? je.getParent() : null;
+ }
+
+ private IRubyElement getRubyElement(Object element) {
+ if (element instanceof IRubyElement)
+ return (IRubyElement)element;
+ if (element instanceof IRubyScriptEditorInput)
+ return ((IRubyScriptEditorInput)element).getRubyScript().getPrimaryElement();
+
+ return null;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyWorkbenchAdapter.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyModelProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyModelProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyModelProvider.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,80 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 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.ui.model;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ModelProvider;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.corext.util.RubyElementResourceMapping;
+
+/**
+ * Ruby-aware model provider.
+ *
+ * @since 3.2
+ */
+public final class RubyModelProvider extends ModelProvider {
+
+ /** The model provider id */
+ public static final String RUBY_MODEL_PROVIDER_ID= "org.rubypeople.rdt.ui.modelProvider"; //$NON-NLS-1$
+
+ /**
+ * Returns the resource associated with the corresponding model element.
+ *
+ * @param element
+ * the model element
+ * @return the associated resource, or <code>null</code>
+ */
+ public static IResource getResource(final Object element) {
+ IResource resource= null;
+ if (element instanceof IRubyElement) {
+ resource= ((IRubyElement) element).getResource();
+ } else if (element instanceof IResource) {
+ resource= (IResource) element;
+ } else if (element instanceof IAdaptable) {
+ final IAdaptable adaptable= (IAdaptable) element;
+ final Object adapted= adaptable.getAdapter(IResource.class);
+ if (adapted instanceof IResource)
+ resource= (IResource) adapted;
+ } else {
+ final Object adapted= Platform.getAdapterManager().getAdapter(element, IResource.class);
+ if (adapted instanceof IResource)
+ resource= (IResource) adapted;
+ }
+ return resource;
+ }
+
+ /**
+ * Creates a new java model provider.
+ */
+ public RubyModelProvider() {
+ // Used by the runtime
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ResourceMapping[] getMappings(final IResource resource, final ResourceMappingContext context, final IProgressMonitor monitor) throws CoreException {
+ final IRubyElement element= RubyCore.create(resource);
+ if (element != null)
+ return new ResourceMapping[] { RubyElementResourceMapping.create(element)};
+ final Object adapted= resource.getAdapter(ResourceMapping.class);
+ if (adapted instanceof ResourceMapping)
+ return new ResourceMapping[] { ((ResourceMapping) adapted)};
+ return new ResourceMapping[] { new RubyResourceMapping(resource)};
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyModelProvider.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyResourceMapping.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyResourceMapping.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyResourceMapping.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,69 @@
+/*******************************************************************************
+ * Copyright (c) 2005, 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.ui.model;
+
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.mapping.ResourceMapping;
+import org.eclipse.core.resources.mapping.ResourceMappingContext;
+import org.eclipse.core.resources.mapping.ResourceTraversal;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+/**
+ * Resource mapping for the ruby model provider.
+ *
+ * @since 3.2
+ */
+public final class RubyResourceMapping extends ResourceMapping {
+
+ /** The resource to map */
+ private final IResource fResource;
+
+ /**
+ * Creates a new java resource mapping.
+ *
+ * @param resource
+ * the resource to map
+ */
+ public RubyResourceMapping(final IResource resource) {
+ Assert.isNotNull(resource);
+ fResource= resource;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getModelObject() {
+ return fResource;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getModelProviderId() {
+ return RubyModelProvider.RUBY_MODEL_PROVIDER_ID;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public IProject[] getProjects() {
+ return new IProject[] { fResource.getProject() };
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public ResourceTraversal[] getTraversals(final ResourceMappingContext context, final IProgressMonitor monitor) {
+ return new ResourceTraversal[] { new ResourceTraversal(new IResource[] { fResource }, IResource.DEPTH_INFINITE, IResource.NONE) };
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/model/RubyResourceMapping.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPageScoreComputer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPageScoreComputer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPageScoreComputer.java 2007-09-14 16:09:49 UTC (rev 3182)
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.ui.search;
+
+import org.eclipse.search.ui.ISearchPageScoreComputer;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptEditorInput;
+
+public class RubySearchPageScoreComputer implements ISearchPageScoreComputer {
+
+ public int computeScore(String id, Object element) {
+ if (!RubySearchPage.EXTENSION_POINT_ID.equals(id))
+ // Can't decide
+ return ISearchPageScoreComputer.UNKNOWN;
+
+ if (element instanceof IRubyElement || element instanceof IRubyScriptEditorInput /*|| element instanceof LogicalPackage*/)
+ return 90;
+
+ return ISearchPageScoreComputer.LOWEST;
+ }
+}
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/search/RubySearchPageScoreComputer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 15:25:13
|
Revision: 3181
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3181&view=rev
Author: cawilliams
Date: 2007-09-14 08:25:10 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
try to fix enablement of run as menu in Ruby Explorer!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.launching/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.launching/plugin.xml
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLaunchableTester.java
Modified: trunk/org.rubypeople.rdt.launching/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.launching/META-INF/MANIFEST.MF 2007-09-14 15:25:00 UTC (rev 3180)
+++ trunk/org.rubypeople.rdt.launching/META-INF/MANIFEST.MF 2007-09-14 15:25:10 UTC (rev 3181)
@@ -14,6 +14,7 @@
org.rubypeople.rdt.core,
org.rubypeople.rdt.debug.core,
org.eclipse.core.runtime,
- org.eclipse.core.variables
+ org.eclipse.core.variables,
+ org.eclipse.core.expressions
Eclipse-LazyStart: true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Modified: trunk/org.rubypeople.rdt.launching/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.launching/plugin.xml 2007-09-14 15:25:00 UTC (rev 3180)
+++ trunk/org.rubypeople.rdt.launching/plugin.xml 2007-09-14 15:25:10 UTC (rev 3181)
@@ -26,12 +26,6 @@
name="%LaunchConfigurationTypeRubyApplication.name"
public="true"
sourceLocatorId="org.rubypeople.rdt.debug.ui.rubySourceLocator">
- <fileExtension
- default="true"
- extension="rb"/>
- <fileExtension
- default="true"
- extension="rbw"/>
</launchConfigurationType>
</extension>
<extension
@@ -73,5 +67,14 @@
class="org.rubypeople.rdt.internal.launching.VariableLoadpathEntry">
</runtimeLoadpathEntry>
</extension>
+ <extension
+ point="org.eclipse.core.expressions.propertyTesters">
+ <propertyTester
+ class="org.rubypeople.rdt.launching.PropertyTester2"
+ id="org.rubypeople.rdt.launching.RubyLaunchableTester"
+ namespace="org.rubypeople.rdt.launching"
+ properties="extendsClass, hasMethod, isContainer, hasProjectNature"
+ type="org.eclipse.core.runtime.IAdaptable"/>
+ </extension>
</plugin>
Added: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLaunchableTester.java
===================================================================
--- trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLaunchableTester.java (rev 0)
+++ trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLaunchableTester.java 2007-09-14 15:25:10 UTC (rev 3181)
@@ -0,0 +1,187 @@
+package org.rubypeople.rdt.internal.launching;
+
+import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyModelException;
+
+public class RubyLaunchableTester extends PropertyTester {
+
+ /**
+ * name for the "has method" property
+ */
+ private static final String PROPERTY_HAS_METHOD = "hasMethod"; //$NON-NLS-1$
+
+ /**
+ * name for the "extends class" property
+ */
+ private static final String PROPERTY_EXTENDS_CLASS = "extendsClass"; //$NON-NLS-1$
+
+ /**
+ * "is container" property
+ */
+ private static final String PROPERTY_IS_CONTAINER = "isContainer"; //$NON-NLS-1$
+
+ /**
+ * name for the PROPERTY_PROJECT_NATURE property
+ */
+ private static final String PROPERTY_PROJECT_NATURE = "hasProjectNature"; //$NON-NLS-1$
+
+ @Override
+ public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
+ if (PROPERTY_IS_CONTAINER.equals(property)) {
+ if (receiver instanceof IAdaptable) {
+ IResource resource = (IResource)((IAdaptable)receiver).getAdapter(IResource.class);
+ if (resource != null) {
+ return resource instanceof IContainer;
+ }
+ }
+ return false;
+ }
+ IRubyElement element = null;
+ if (receiver instanceof IAdaptable) {
+ element = (IRubyElement) ((IAdaptable)receiver).getAdapter(IRubyElement.class);
+ if(element != null) {
+ if(!element.exists()) {
+ return false;
+ }
+ }
+ }
+ if (PROPERTY_HAS_METHOD.equals(property)) {
+ return hasMethod(element, args);
+ }
+ if(PROPERTY_EXTENDS_CLASS.equals(property)) {
+ return hasSuperclass(element, (String)args[0]);
+ }
+ if(PROPERTY_PROJECT_NATURE.equals(property)) {
+ return hasProjectNature(element, (String)args[0]);
+ }
+ return false;
+ }
+
+ /**
+ * Determines is the java element contains a specific method.
+ * <p>
+ * The syntax for the property tester is of the form: methodname,
+ * signature, modifiers.
+ * </p>
+ * <ol>
+ * <li>methodname - case sensitive method name, required. For example,
+ * <code>toString</code>.</li>
+ * <li>signature - JLS style method signature, required. For example,
+ * <code>(QString;)V</code>.</li>
+ * <li>modifiers - optional space seperated list of modifiers, for
+ * example, <code>public static</code>.</li>
+ * </ol>
+ * @param element the element to check for the method
+ * @param args first arg is method name, secondary args are parameter types signatures
+ * @return true if the method is found in the element, false otherwise
+ */
+ private boolean hasMethod(IRubyElement element, Object[] args) {
+ try {
+ if (args.length > 1) {
+ IType type = getType(element);
+ if (type != null && type.exists()) {
+ String name = (String) args[0];
+ String signature = (String) args[1];
+ String[] parms = signature.split(",");
+ IMethod candidate = type.getMethod(name, parms);
+ if (candidate.exists()) {
+ // check return type
+ // check modifiers
+ if (args.length > 2) {
+ String modifierText = (String) args[2];
+ String[] modifiers = modifierText.split(" "); //$NON-NLS-1$
+ for (int j = 0; j < modifiers.length; j++) {
+ String modifier = modifiers[j];
+ if (modifier.equals("public") && !candidate.isPublic())
+ return false;
+ else if (modifier.equals("private") && !candidate.isPrivate())
+ return false;
+ else if (modifier.equals("protected") && !candidate.isProtected())
+ return false;
+ else if (modifier.equals("singleton") && !candidate.isSingleton())
+ return false;
+ }
+ return true;
+ }
+ }
+ }
+ }
+ }
+ catch (RubyModelException e) {}
+ return false;
+ }
+
+ /**
+ * Determines if the element has qname as a parent class
+ * @param element the element to check for the parent class definition
+ * @param qname the fully qualified name of the (potential) parent class
+ * @return true if qname is a parent class, false otherwise
+ */
+ private boolean hasSuperclass(IRubyElement element, String qname) {
+ try {
+ IType type = getType(element);
+ if(type != null) {
+ IType[] stypes = type.newSupertypeHierarchy(new NullProgressMonitor()).getAllSuperclasses(type);
+ for(int i = 0; i < stypes.length; i++) {
+ if(stypes[i].getFullyQualifiedName().equals(qname) || stypes[i].getElementName().equals(qname)) {
+ return true;
+ }
+ }
+ }
+ }
+ catch(RubyModelException e) {}
+ return false;
+ }
+
+ /**
+ * determines if the project selected has the specified nature
+ * @param resource the resource to get the project for
+ * @param ntype the specified nature type
+ * @return true if the specified nature matches the project, false otherwise
+ */
+ private boolean hasProjectNature(IRubyElement element, String ntype) {
+ try {
+ if(element != null) {
+ IResource resource = element.getResource();
+ if(resource != null) {
+ IProject proj = resource.getProject();
+ return proj.isAccessible() && proj.hasNature(ntype);
+ }
+ }
+ return false;
+ }
+ catch (CoreException e) {return false;}
+ }
+
+ /**
+ * gets the type of the IRubyElement
+ * @param element the element to inspect
+ * @return the type
+ * @throws RubyModelException
+ */
+ private IType getType(IRubyElement element) throws RubyModelException {
+ IType type = null;
+ if (element instanceof IRubyScript) {
+ type= ((IRubyScript) element).findPrimaryType();
+ }
+ else if (element instanceof IType) {
+ type = (IType) element;
+ }
+ else if (element instanceof IMember) {
+ type = ((IMember)element).getDeclaringType();
+ }
+ return type;
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.launching/src/org/rubypeople/rdt/internal/launching/RubyLaunchableTester.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 15:25:09
|
Revision: 3180
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3180&view=rev
Author: cawilliams
Date: 2007-09-14 08:25:00 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
try to fix enablement of run as menu in Ruby Explorer!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.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/RubyMethod.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java 2007-09-14 15:24:54 UTC (rev 3179)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IMethod.java 2007-09-14 15:25:00 UTC (rev 3180)
@@ -47,4 +47,8 @@
public boolean isPrivate() throws RubyModelException;
+ public boolean isPublic() throws RubyModelException;
+
+ public boolean isProtected() throws RubyModelException;
+
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-09-14 15:24:54 UTC (rev 3179)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/CompletionEngine.java 2007-09-14 15:25:00 UTC (rev 3180)
@@ -892,5 +892,15 @@
return false;
}
+ public boolean isProtected() throws RubyModelException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean isPublic() throws RubyModelException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java 2007-09-14 15:24:54 UTC (rev 3179)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyMethod.java 2007-09-14 15:25:00 UTC (rev 3180)
@@ -164,5 +164,13 @@
public boolean isPrivate() throws RubyModelException {
return getVisibility() == PRIVATE;
}
+
+ public boolean isPublic() throws RubyModelException {
+ return getVisibility() == PUBLIC;
+ }
+
+ public boolean isProtected() throws RubyModelException {
+ return getVisibility() == PROTECTED;
+ }
}
\ 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-09-14 15:25:09
|
Revision: 3179
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3179&view=rev
Author: cawilliams
Date: 2007-09-14 08:24:54 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
try to fix enablement of run as menu in Ruby Explorer!
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/plugin.xml
Modified: trunk/org.rubypeople.rdt.debug.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/plugin.xml 2007-09-14 14:18:49 UTC (rev 3178)
+++ trunk/org.rubypeople.rdt.debug.ui/plugin.xml 2007-09-14 15:24:54 UTC (rev 3179)
@@ -231,6 +231,10 @@
<test
property="org.eclipse.debug.ui.matchesContentType"
value="org.eclipse.ant.core.antBuildFile"/>
+ <and>
+ <test property="org.rubypeople.rdt.launching.isContainer"/>
+ <test property="org.rubypeople.rdt.launching.hasProjectNature" args="org.rubypeople.rdt.core.rubynature"/>
+ </and>
</or>
</iterate>
</with>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 14:18:51
|
Revision: 3178
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3178&view=rev
Author: cawilliams
Date: 2007-09-14 07:18:49 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
initialize indexer and ui in same way JDT does
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.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-09-14 14:18:44 UTC (rev 3177)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/RubyCore.java 2007-09-14 14:18:49 UTC (rev 3178)
@@ -38,21 +38,25 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Plugin;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.rubypeople.rdt.core.search.IRubySearchConstants;
+import org.rubypeople.rdt.core.search.IRubySearchScope;
import org.rubypeople.rdt.core.search.SearchEngine;
import org.rubypeople.rdt.core.search.SearchMatch;
import org.rubypeople.rdt.core.search.SearchParticipant;
import org.rubypeople.rdt.core.search.SearchPattern;
import org.rubypeople.rdt.core.search.SearchRequestor;
+import org.rubypeople.rdt.core.search.TypeNameRequestor;
import org.rubypeople.rdt.internal.core.BatchOperation;
import org.rubypeople.rdt.internal.core.DefaultWorkingCopyOwner;
import org.rubypeople.rdt.internal.core.LoadpathAttribute;
@@ -64,6 +68,7 @@
import org.rubypeople.rdt.internal.core.RubyProject;
import org.rubypeople.rdt.internal.core.SetLoadpathOperation;
import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
+import org.rubypeople.rdt.internal.core.util.Messages;
import org.rubypeople.rdt.internal.core.util.Util;
public class RubyCore extends Plugin {
@@ -375,8 +380,13 @@
public static void log(int severity, String string, Throwable e) {
getPlugin().getLog().log(new Status(severity, PLUGIN_ID, IStatus.OK, string, e));
- System.out.println(string);
- if (e != null) e.printStackTrace();
+ if (severity == Status.ERROR) {
+ // send stack trace to Trac!
+ }
+ if (VERBOSE) {
+ System.out.println(string);
+ if (e != null) e.printStackTrace();
+ }
}
public static String getOSDirectory(Plugin plugin) {
@@ -1449,26 +1459,6 @@
}
}
-
- public static void forceIndexing() {
- SearchEngine engine = new SearchEngine();
- SearchParticipant[] participants = new SearchParticipant[] { SearchEngine.getDefaultSearchParticipant() };
- SearchPattern pattern = SearchPattern.createPattern(IRubyElement.TYPE, "*", IRubySearchConstants.DECLARATIONS, SearchPattern.R_PATTERN_MATCH);
- SearchRequestor requestor = new SearchRequestor() {
-
- @Override
- public void acceptSearchMatch(SearchMatch match) throws CoreException {
- // do nothing
- }
-
- };
- try {
- engine.search(pattern, participants, SearchEngine.createWorkspaceScope(), requestor, null);
- } catch (CoreException e) {
- // ignore
- }
- }
-
/**
* Returns a new empty region.
*
@@ -1491,4 +1481,80 @@
public static String[] getLoadpathVariableNames() {
return RubyModelManager.getRubyModelManager().variableNames();
}
+
+ /**
+ * Initializes RubyCore internal structures to allow subsequent operations (such
+ * as the ones that need a resolved classpath) to run full speed. A client may
+ * choose to call this method in a background thread early after the workspace
+ * has started so that the initialization is transparent to the user.
+ * <p>
+ * However calling this method is optional. Services will lazily perform
+ * initialization when invoked. This is only a way to reduce initialization
+ * overhead on user actions, if it can be performed before at some
+ * appropriate moment.
+ * </p><p>
+ * This initialization runs accross all Ruby projects in the workspace. Thus the
+ * workspace root scheduling rule is used during this operation.
+ * </p><p>
+ * This method may return before the initialization is complete. The
+ * initialization will then continue in a background thread.
+ * </p><p>
+ * This method can be called concurrently.
+ * </p>
+ *
+ * @param monitor a progress monitor, or <code>null</code> if progress
+ * reporting and cancellation are not desired
+ * @exception CoreException if the initialization fails,
+ * the status of the exception indicates the reason of the failure
+ * @since 3.1
+ */
+ public static void initializeAfterLoad(IProgressMonitor monitor) throws CoreException {
+ try {
+ if (monitor != null) monitor.beginTask(Messages.javamodel_initialization, 100);
+ // dummy query for waiting until the indexes are ready and classpath containers/variables are initialized
+ SearchEngine engine = new SearchEngine();
+ IRubySearchScope scope = SearchEngine.createWorkspaceScope(); // initialize all containers and variables
+ try {
+ engine.searchAllTypeNames(
+ null,
+ "!@$#!@".toCharArray(), //$NON-NLS-1$
+ SearchPattern.R_PATTERN_MATCH | SearchPattern.R_CASE_SENSITIVE,
+ IRubySearchConstants.CLASS,
+ scope,
+ new TypeNameRequestor() {
+ public void acceptType(
+ boolean isModule,
+ char[] packageName,
+ char[] simpleTypeName,
+ char[][] enclosingTypeNames,
+ String path) {
+ // no type to accept
+ }
+ },
+ // will not activate index query caches if indexes are not ready, since it would take to long
+ // to wait until indexes are fully rebuild
+ IRubySearchConstants.CANCEL_IF_NOT_READY_TO_SEARCH,
+ monitor == null ? null : new SubProgressMonitor(monitor, 99) // 99% of the time is spent in the dummy search
+ );
+ } catch (RubyModelException e) {
+ // /search failed: ignore
+ } catch (OperationCanceledException e) {
+ if (monitor != null && monitor.isCanceled())
+ throw e;
+ // else indexes were not ready: catch the exception so that jars are still refreshed
+ }
+// final RubyModel model = RubyModelManager.getRubyModelManager().getRubyModel();
+// // ensure external jars are refreshed (see https://bugs.eclipse.org/bugs/show_bug.cgi?id=93668)
+// try {
+// model.refreshExternalArchives(
+// null/*refresh all projects*/,
+// monitor == null ? null : new SubProgressMonitor(monitor, 1) // 1% of the time is spent in jar refresh
+// );
+// } catch (RubyModelException e) {
+// // refreshing failed: ignore
+// }
+ } finally {
+ if (monitor != null) monitor.done();
+ }
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-14 14:18:47
|
Revision: 3177
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3177&view=rev
Author: cawilliams
Date: 2007-09-14 07:18:44 -0700 (Fri, 14 Sep 2007)
Log Message:
-----------
initialize indexer and ui in same way JDT does
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.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
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/InitializeAfterLoadJob.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ForceIndexer.java
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-13 20:26:05 UTC (rev 3176)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2007-09-14 14:18:44 UTC (rev 3177)
@@ -1532,7 +1532,6 @@
<extension
point="org.eclipse.ui.startup">
- <startup class="org.rubypeople.rdt.internal.ui.ForceIndexer"/>
<startup class="org.rubypeople.rdt.internal.ui.RubyInstalledDetector"/>
</extension>
<extension
Deleted: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ForceIndexer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ForceIndexer.java 2007-09-13 20:26:05 UTC (rev 3176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/ForceIndexer.java 2007-09-14 14:18:44 UTC (rev 3177)
@@ -1,12 +0,0 @@
-package org.rubypeople.rdt.internal.ui;
-
-import org.eclipse.ui.IStartup;
-import org.rubypeople.rdt.core.RubyCore;
-
-public class ForceIndexer implements IStartup {
-
- public void earlyStartup() {
- RubyCore.forceIndexing();
- }
-
-}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/InitializeAfterLoadJob.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/InitializeAfterLoadJob.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/InitializeAfterLoadJob.java 2007-09-14 14:18:44 UTC (rev 3177)
@@ -0,0 +1,55 @@
+/*******************************************************************************
+ * 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.ui;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.ui.progress.UIJob;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.ui.RubyUI;
+
+public class InitializeAfterLoadJob extends UIJob {
+
+ private final class RealJob extends Job {
+ public RealJob(String name) {
+ super(name);
+ }
+ protected IStatus run(IProgressMonitor monitor) {
+ monitor.beginTask("", 10); //$NON-NLS-1$
+ try {
+ RubyCore.initializeAfterLoad(new SubProgressMonitor(monitor, 6));
+ RubyPlugin.initializeAfterLoad(new SubProgressMonitor(monitor, 4));
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ return e.getStatus();
+ }
+ return new Status(IStatus.OK, RubyPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ }
+ public boolean belongsTo(Object family) {
+ return RubyUI.ID_PLUGIN.equals(family);
+ }
+ }
+
+ public InitializeAfterLoadJob() {
+ super(RubyUIMessages.InitializeAfterLoadJob_starter_job_name);
+ setSystem(true);
+ }
+ public IStatus runInUIThread(IProgressMonitor monitor) {
+ Job job = new RealJob(RubyUIMessages.RubyPlugin_initializing_ui);
+ job.setPriority(Job.SHORT);
+ job.schedule();
+ return new Status(IStatus.OK, RubyPlugin.getPluginId(), IStatus.OK, "", null); //$NON-NLS-1$
+ }
+}
\ No newline at end of file
Property changes on: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/InitializeAfterLoadJob.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-13 20:26:05 UTC (rev 3176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPlugin.java 2007-09-14 14:18:44 UTC (rev 3177)
@@ -56,6 +56,7 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.WorkingCopyOwner;
+import org.rubypeople.rdt.internal.corext.util.OpenTypeHistory;
import org.rubypeople.rdt.internal.corext.util.TypeFilter;
import org.rubypeople.rdt.internal.formatter.OldCodeFormatter;
import org.rubypeople.rdt.internal.ui.preferences.MembersOrderPreferenceCache;
@@ -175,7 +176,15 @@
upgradeOldProjects();
String generateRdocOption = Platform.getDebugOption(RubyPlugin.PLUGIN_ID + "/generaterdoc");
RDocUtility.setDebugging(generateRdocOption == null ? false : generateRdocOption.equalsIgnoreCase("true"));
+
+ // Initialize AST provider
+ getASTProvider();
+ new InitializeAfterLoadJob().schedule();
}
+
+ /* package */ static void initializeAfterLoad(IProgressMonitor monitor) {
+ OpenTypeHistory.getInstance().checkConsistency(monitor);
+ }
private void listenForNewProjects() {
ResourcesPlugin.getWorkspace().addResourceChangeListener(new ProjectUpgradeListener(this));
Modified: 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.java 2007-09-13 20:26:05 UTC (rev 3176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.java 2007-09-14 14:18:44 UTC (rev 3177)
@@ -105,6 +105,8 @@
public static String Spelling_add_label;
public static String Spelling_ignore_info;
public static String Spelling_ignore_label;
+ public static String RubyPlugin_initializing_ui;
+ public static String InitializeAfterLoadJob_starter_job_name;
private RubyUIMessages() {
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-13 20:26:05 UTC (rev 3176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-09-14 14:18:44 UTC (rev 3177)
@@ -3,6 +3,9 @@
# All Rights Reserved.
#########################################
+InitializeAfterLoadJob_starter_job_name=Starting Ruby Tooling initialization
+RubyPlugin_initializing_ui=Initializing Ruby Tooling
+
#######
## dialogs
#######
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-13 20:26:07
|
Revision: 3176
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3176&view=rev
Author: cawilliams
Date: 2007-09-13 13:26:05 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
fix broken tests (sort of, rip some out because they need to be re-written)
Modified Paths:
--------------
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_CleanRdtCompiler.java
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/TS_InternalCoreBuilder.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamSingleCompiler.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_TaskCompiler.java
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-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtTestCase.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -1,6 +1,5 @@
package org.rubypeople.rdt.internal.core.builder;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -17,7 +16,7 @@
static protected final String REMOVING_MARKERS_SUB_TASK = "Removing Markers...";
protected abstract void assertMarkersRemoved(List expectedFiles);
- abstract AbstractRdtCompiler createCompiler(IMarkerManager markerManager, List singleCompilers);
+ abstract AbstractRdtCompiler createCompiler(IMarkerManager markerManager);
protected ShamMonitor monitor;
protected ShamFile t1;
@@ -26,8 +25,6 @@
protected ShamFolder f1;
protected ShamProject project;
protected ShamMarkerManager markerManager;
- protected ShamSingleCompiler singleCompiler1;
- protected ShamSingleCompiler singleCompiler2;
protected AbstractRdtCompiler compiler;
private ShamFile nonRubyFile;
@@ -40,11 +37,8 @@
project = new ShamProject("test");
markerManager = new ShamMarkerManager();
- singleCompiler1 = new ShamSingleCompiler();
- singleCompiler2 = new ShamSingleCompiler();
- List singleCompilers = ListUtil.create(singleCompiler1, singleCompiler2);
- compiler = createCompiler(markerManager, singleCompilers);
+ compiler = createCompiler(markerManager);
monitor = new ShamMonitor();
}
@@ -102,8 +96,6 @@
t1.getFullPath().toString());
monitor.assertSubTasks(subTasks);
assertMarkersRemoved(ListUtil.create(t1,t2));
- singleCompiler1.assertCompiled(new HashSet(expectedFiles));
- singleCompiler2.assertCompiled(new HashSet(expectedFiles));
}
public void testCompileSkipsNonRubyFiles() throws Exception {
@@ -131,8 +123,6 @@
monitor.assertSubTasks(subTasks);
assertMarkersRemoved(expectedFiles);
- singleCompiler1.assertCompiled(new HashSet(expectedFiles));
- singleCompiler2.assertCompiled(new HashSet(expectedFiles));
}
}
Deleted: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamSingleCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamSingleCompiler.java 2007-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamSingleCompiler.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -1,24 +0,0 @@
-/**
- *
- */
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-class ShamSingleCompiler implements SingleFileCompiler {
-
- private Set compiledFiles = new HashSet();
-
- public void compileFile(IFile file) throws CoreException {
- compiledFiles.add(file);
- }
-
- public void assertCompiled(Set expectedFiles) {
- TC_CleanRdtCompiler.assertEquals(expectedFiles, compiledFiles);
- }
-
-}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_CleanRdtCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_CleanRdtCompiler.java 2007-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_CleanRdtCompiler.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -5,9 +5,8 @@
public class TC_CleanRdtCompiler extends AbstractRdtTestCase {
- AbstractRdtCompiler createCompiler(IMarkerManager markerManager, List singleCompilers) {
- return new CleanRdtCompiler(project,
- markerManager, singleCompilers);
+ AbstractRdtCompiler createCompiler(IMarkerManager markerManager) {
+ return new CleanRdtCompiler(project, markerManager);
}
protected void assertMarkersRemoved(List expectedFiles) {
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-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_IncrementalRdtCompiler.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -1,7 +1,6 @@
package org.rubypeople.rdt.internal.core.builder;
import java.util.Arrays;
-import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
@@ -27,8 +26,6 @@
List subTasks = ListUtil.create(REMOVING_MARKERS_SUB_TASK);
monitor.assertSubTasks(subTasks);
assertMarkersRemoved(ListUtil.create(t1));
- singleCompiler1.assertCompiled(new HashSet());
- singleCompiler2.assertCompiled(new HashSet());
}
protected void assertMarkersRemoved(List expectedFiles) {
@@ -63,10 +60,10 @@
return childDelta;
}
- AbstractRdtCompiler createCompiler(IMarkerManager markerManager, List singleCompilers) {
+ AbstractRdtCompiler createCompiler(IMarkerManager markerManager) {
delta.setResource(project);
return new IncrementalRdtCompiler(project, delta,
- markerManager, singleCompilers);
+ markerManager);
}
}
Deleted: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyCodeAnalyzer.java 2007-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyCodeAnalyzer.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -1,73 +0,0 @@
-/*
- * Author: David Corbin
- *
- * Copyright (c) 2005 RubyPeople.
- *
- * This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
- */
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.jruby.ast.Node;
-import org.jruby.ast.visitor.NodeVisitor;
-import org.jruby.evaluator.Instruction;
-import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.eclipse.shams.resources.ShamFile;
-import org.rubypeople.rdt.internal.core.parser.RdtPosition;
-
-public class TC_RubyCodeAnalyzer extends TestCase {
-
- private static final String FILE_CONTENTS = "file Contents";
- private static final String FILENAME = "testFile.rb";
- private ShamFile file;
- private ShamMarkerManager markerManager;
- private ShamRubyParser parser;
- private RubyCodeAnalyzer compiler;
- private Node rootNode;
-
- public void setUp() {
- file = new ShamFile(FILENAME);
- file.setContents(FILE_CONTENTS);
-
- rootNode = new Node(null, 0) {
- private static final long serialVersionUID = 9089679642764992140L;
-
- public Instruction accept(NodeVisitor visitor) {
- return null;
- }
-
- public List childNodes() {
- return new ArrayList();
- }
- };
- markerManager = new ShamMarkerManager();
- parser = new ShamRubyParser();
- parser.addParseResult(file, rootNode);
- compiler = new RubyCodeAnalyzer(markerManager, parser);
- }
-
- public void testParserInvocation() throws Exception {
- compiler.compileFile(file);
-
- parser.assertParsed(file, FILE_CONTENTS);
- file.assertContentStreamClosed();
- }
-
-
- public void testSyntaxException() throws Exception {
- SyntaxException syntaxException = new SyntaxException(new RdtPosition(1, 0, 10), "");
- parser.setExceptionToThrow(syntaxException);
-
- compiler.compileFile(file);
-
- file.assertContentStreamClosed();
- markerManager.assertWarningAdded(file, "", 1, 0, 10);
- }
-}
Deleted: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_TaskCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_TaskCompiler.java 2007-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_TaskCompiler.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -1,65 +0,0 @@
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.io.IOException;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-
-import junit.framework.TestCase;
-
-import org.rubypeople.eclipse.shams.resources.ShamFile;
-import org.rubypeople.rdt.internal.core.parser.TaskParser;
-import org.rubypeople.rdt.internal.core.parser.TaskTag;
-
-public class TC_TaskCompiler extends TestCase {
-
- private static final TaskTag TASK_TAG = new TaskTag("",0,0,0,0);
- private ShamMarkerManager markerManager;
- private ShamTaskParser taskParser;
- private TaskCompiler taskCompiler;
- private ShamFile file;
- private static class ShamTaskParser extends TaskParser {
-
- private String contents;
- private List tasks = new ArrayList();
-
- public ShamTaskParser() {
- super(new HashMap());
- }
-
- public void parse(Reader reader) throws IOException {
- contents = IoUtils.readAll(reader);
- }
-
- public List getTasks() {
- return tasks;
- }
-
- public void assertFileContents(String expectedContents) {
- assertEquals(expectedContents, contents);
-
- }
-
- public void addTaskToReturn(TaskTag taskTag) {
- tasks.add(taskTag);
- }
- }
-
- public void setUp() {
- markerManager = new ShamMarkerManager();
- taskParser = new ShamTaskParser();
- taskCompiler = new TaskCompiler(markerManager, taskParser);
-
- file = new ShamFile("");
- file.setContents("fileContents");
- }
-
- public void testCompile() throws Exception {
- taskParser.addTaskToReturn(TASK_TAG);
- taskCompiler.compileFile(file);
- taskParser.assertFileContents("fileContents");
- markerManager.assertTasksCreated(file, Collections.singletonList(TASK_TAG));
- }
-}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TS_InternalCoreBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TS_InternalCoreBuilder.java 2007-09-13 20:25:59 UTC (rev 3175)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TS_InternalCoreBuilder.java 2007-09-13 20:26:05 UTC (rev 3176)
@@ -16,9 +16,7 @@
public class TS_InternalCoreBuilder {
public static Test suite() {
- TestSuite suite = new TestSuite("Builder");
- suite.addTestSuite(TC_TaskCompiler.class);
- suite.addTestSuite(TC_RubyCodeAnalyzer.class);
+ TestSuite suite = new TestSuite("Builder");
suite.addTestSuite(TC_CleanRdtCompiler.class);
suite.addTestSuite(TC_IncrementalRdtCompiler.class);
return suite;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-13 20:26:03
|
Revision: 3175
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3175&view=rev
Author: cawilliams
Date: 2007-09-13 13:25:59 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
fix broken tests (sort of, rip some out because they need to be re-written)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java
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-09-13 20:18:08 UTC (rev 3174)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java 2007-09-13 20:25:59 UTC (rev 3175)
@@ -14,8 +14,7 @@
this(project, new MarkerManager());
}
- private CleanRdtCompiler(IProject project,
- MarkerManager markerManager) {
+ public CleanRdtCompiler(IProject project, IMarkerManager markerManager) {
super(project, markerManager);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-13 20:18:10
|
Revision: 3174
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3174&view=rev
Author: cawilliams
Date: 2007-09-13 13:18:08 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
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/RubySourceFileCollectingVisitor.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-09-13 20:06:43 UTC (rev 3173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-09-13 20:18:08 UTC (rev 3174)
@@ -35,9 +35,9 @@
for (int i = 0; i < fParticipants.length; i++) {
fParticipants[i].aboutToBuild(rubyProject);
}
- List<IFile> files = getFilesToCompile();
+ BuildContext[] files = getBuildContexts();
int filesToClear = getFilesToClear().size();
- int taskCount = (filesToClear) + (files.size() * fParticipants.length);
+ int taskCount = (filesToClear) + (files.length * fParticipants.length);
monitor.beginTask("Building " + project.getName() + "...", taskCount);
@@ -51,8 +51,7 @@
monitor.done();
}
- private void compileFiles(List<IFile> list, IProgressMonitor monitor) throws CoreException {
- BuildContext[] contexts = getBuildContexts(list);
+ private void compileFiles(BuildContext[] contexts, IProgressMonitor monitor) throws CoreException {
if (fParticipants != null) {
for (int i = 0; i < fParticipants.length; i++) {
if (monitor.isCanceled())
@@ -69,6 +68,10 @@
}
}
+ private BuildContext[] getBuildContexts() throws CoreException {
+ return getBuildContexts(getFilesToCompile());
+ }
+
private BuildContext[] getBuildContexts(List<IFile> list) {
List<BuildContext> contexts = new ArrayList<BuildContext>();
for (IFile file : list) {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java 2007-09-13 20:06:43 UTC (rev 3173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java 2007-09-13 20:18:08 UTC (rev 3174)
@@ -23,6 +23,7 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
+import org.rubypeople.rdt.core.RubyCore;
public final class RubySourceFileCollectingVisitor implements IResourceProxyVisitor {
@@ -63,8 +64,7 @@
return false;
visitedLinks.add(unique);
} catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
+ RubyCore.log(e);
return false;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-09-13 20:06:46
|
Revision: 3173
http://rubyeclipse.svn.sourceforge.net/rubyeclipse/?rev=3173&view=rev
Author: cawilliams
Date: 2007-09-13 13:06:43 -0700 (Thu, 13 Sep 2007)
Log Message:
-----------
get rid of SingleFileCompiler / MultipleFileCompiler stuff and use the Compilationparticipant extension point
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/plugin.xml
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/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
Removed 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
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
Modified: trunk/org.rubypeople.rdt.core/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.core/plugin.xml 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/plugin.xml 2007-09-13 20:06:43 UTC (rev 3173)
@@ -126,4 +126,19 @@
<error prefKey="org.rubypeople.rdt.core.compiler.problem.emptyStatement" label="Empty Statements"
categoryId="org.rubypeople.rdt.errors.unneccesaryCode"/>
</extension>
+ <extension
+ point="org.rubypeople.rdt.core.compilationParticipant">
+ <compilationParticipant
+ class="org.rubypeople.rdt.internal.core.builder.RubyCodeAnalyzer"
+ createsProblems="true"
+ id="org.rubypeople.rdt.core.compilationParticipant.CodeAnalyzer">
+ <managedMarker markerType="org.rubypeople.rdt.core.problem"/>
+ </compilationParticipant>
+ <compilationParticipant
+ class="org.rubypeople.rdt.internal.core.builder.TaskCompiler"
+ createsProblems="true"
+ id="org.rubypeople.rdt.core.compilationParticipant.TaskParser">
+ <managedMarker markerType="org.rubypeople.rdt.core.task"/>
+ </compilationParticipant>
+ </extension>
</plugin>
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-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/AbstractRdtCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,7 +1,6 @@
package org.rubypeople.rdt.internal.core.builder;
import java.util.ArrayList;
-import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -14,82 +13,57 @@
import org.rubypeople.rdt.core.compiler.CategorizedProblem;
import org.rubypeople.rdt.core.compiler.CompilationParticipant;
import org.rubypeople.rdt.internal.core.RubyModelManager;
-import org.rubypeople.rdt.internal.core.util.ListUtil;
public abstract class AbstractRdtCompiler {
protected final IProject project;
protected final IMarkerManager markerManager;
- protected final List<SingleFileCompiler> singleFileCompilers;
- protected final List<MultipleFileCompiler> multiFileCompilers;
+ protected CompilationParticipant[] fParticipants;
- public AbstractRdtCompiler(IProject project,
- IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers, List<MultipleFileCompiler> multiFileCompilers) {
+ public AbstractRdtCompiler(IProject project, IMarkerManager markerManager) {
this.project = project;
this.markerManager = markerManager;
- this.singleFileCompilers = singleCompilers;
- this.multiFileCompilers = multiFileCompilers;
}
-
- public AbstractRdtCompiler(IProject project,
- IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers) {
- this(project, markerManager, singleCompilers, new ArrayList<MultipleFileCompiler>());
- }
protected abstract void removeMarkers(IMarkerManager markerManager);
- protected abstract List<IFile> getFilesToCompile();
- protected abstract void analyzeFiles() throws CoreException;
+ protected abstract List<IFile> getFilesToCompile() throws CoreException;
+ protected abstract List getFilesToClear() throws CoreException;
- protected static List<SingleFileCompiler> singleFileCompilers(MarkerManager markerManager) {
- return ListUtil.create(new RubyCodeAnalyzer(markerManager),
- new TaskCompiler(markerManager));
- }
-
- public void compile(IProgressMonitor monitor) throws CoreException {
- analyzeFiles();
+ public void compile(IProgressMonitor monitor) throws CoreException {
+ IRubyProject rubyProject = getRubyProject();
+ fParticipants = RubyModelManager.getRubyModelManager().compilationParticipants.getCompilationParticipants(rubyProject);
+ for (int i = 0; i < fParticipants.length; i++) {
+ fParticipants[i].aboutToBuild(rubyProject);
+ }
List<IFile> files = getFilesToCompile();
int filesToClear = getFilesToClear().size();
- int taskCount = (filesToClear) + (files.size() * (singleFileCompilers.size() + multiFileCompilers.size()));
+ int taskCount = (filesToClear) + (files.size() * fParticipants.length);
- monitor.beginTask("Building "+project.getName() + "...", taskCount);
- monitor.subTask("Removing Markers...");
+ monitor.beginTask("Building " + project.getName() + "...", taskCount);
+ monitor.subTask("Removing Markers...");
removeMarkers(markerManager);
monitor.worked(filesToClear);
+ monitor.subTask("Analyzing Files...");
compileFiles(files, monitor);
monitor.done();
- }
-
- protected abstract List getFilesToClear();
+ }
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;
-
- monitor.subTask(file.getFullPath().toString());
- compileFile(file, monitor);
- }
- BuildContext[] contexts = getBuildContexts(list);
- CompilationParticipant[] participants = RubyModelManager.getRubyModelManager().compilationParticipants.getCompilationParticipants(getRubyProject());
- if (participants != null) {
- for (int i = 0; i < participants.length; i++) {
+ BuildContext[] contexts = getBuildContexts(list);
+ if (fParticipants != null) {
+ for (int i = 0; i < fParticipants.length; i++) {
if (monitor.isCanceled())
return;
- participants[i].buildStarting(contexts, true);
+ fParticipants[i].buildStarting(contexts, true);
}
}
for (int i = 0; i < contexts.length; i++) {
CategorizedProblem[] problems = contexts[i].getProblems();
if (problems == null || problems.length == 0) continue;
- for (int j = 0; j < problems.length; j++) {
+ for (int j = 0; j < problems.length; j++) {
markerManager.addProblem(contexts[i].getFile(), problems[j]);
}
}
@@ -106,12 +80,4 @@
private IRubyProject getRubyProject() {
return RubyCore.create(project);
}
-
- private void compileFile(IFile file, IProgressMonitor monitor) throws CoreException {
- 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-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CleanRdtCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -13,30 +13,28 @@
public CleanRdtCompiler(IProject project) {
this(project, new MarkerManager());
}
-
- public CleanRdtCompiler(IProject project,
- IMarkerManager markerManager, List singleCompilers) {
- super(project, markerManager, singleCompilers);
- }
-
+
private CleanRdtCompiler(IProject project,
MarkerManager markerManager) {
- this(project, markerManager, singleFileCompilers(markerManager));
+ super(project, markerManager);
}
protected void removeMarkers(IMarkerManager markerManager) {
markerManager.removeProblemsAndTasksFor(project);
}
- protected List<IFile> getFilesToClear() {
- return projectFiles;
+ protected List<IFile> getFilesToClear() throws CoreException {
+ return getFilesToCompile();
}
- protected List<IFile> getFilesToCompile() {
+ protected List<IFile> getFilesToCompile() throws CoreException {
+ if (projectFiles == null) {
+ analyzeFiles();
+ }
return projectFiles;
}
- protected void analyzeFiles() throws CoreException {
+ private void analyzeFiles() throws CoreException {
ProjectFileFinder finder = new ProjectFileFinder(project);
projectFiles = finder.findFiles();
}
Deleted: 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 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,53 +0,0 @@
-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.parser.RdtPosition;
-import org.rubypeople.rdt.internal.core.parser.Warning;
-import org.rubypeople.rdt.internal.core.pmd.CPD;
-import org.rubypeople.rdt.internal.core.pmd.Match;
-import org.rubypeople.rdt.internal.core.pmd.TokenEntry;
-
-// XXX Either use this in some way, or remove it!
-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()));
- Warning warning = new Warning(new RdtPosition(mark.getBeginLine(), mark.getStartOffset(), mark.getStartOffset() + match.getSourceCodeSlice().length()), message.toString());
- markerManager.addProblem(file, warning);
- }
- }
-
-}
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-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IncrementalRdtCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -19,8 +19,8 @@
private final IResourceDelta rootDelta;
public IncrementalRdtCompiler(IProject project, IResourceDelta delta,
- IMarkerManager markerManager, List<SingleFileCompiler> singleCompilers) {
- super(project, markerManager, singleCompilers);
+ IMarkerManager markerManager) {
+ super(project, markerManager);
this.rootDelta = delta;
}
@@ -28,11 +28,6 @@
this(project, delta, new MarkerManager());
}
- private IncrementalRdtCompiler(IProject project, IResourceDelta delta,
- MarkerManager manager) {
- this(project, delta, manager, singleFileCompilers(manager));
- }
-
protected void removeMarkers(IMarkerManager markerManager) {
for (Iterator iter = filesToClear.iterator(); iter.hasNext();) {
IFile file = (IFile) iter.next();
@@ -40,11 +35,14 @@
}
}
- protected List getFilesToCompile() {
+ protected List getFilesToCompile() throws CoreException {
+ if (filesToCompile == null) {
+ analyzeFiles();
+ }
return filesToCompile;
}
- protected void analyzeFiles() throws CoreException {
+ private void analyzeFiles() throws CoreException {
filesToClear = new ArrayList();
filesToCompile = new ArrayList();
@@ -69,7 +67,10 @@
}
@Override
- protected List getFilesToClear() {
+ protected List getFilesToClear() throws CoreException {
+ if (filesToClear == null) {
+ analyzeFiles();
+ }
return filesToClear;
}
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-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -36,7 +36,7 @@
}
public void addProblem(IFile file, IProblem problem) {
- MarkerUtility.createProblemMarker(file, problem);
+ MarkerUtility.createProblemMarker(file, problem);
}
}
Deleted: 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 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MultipleFileCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,16 +0,0 @@
-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;
-
-/**
- * @deprecated Please use CompilationParticipant infrastructure
- * @author Chris Williams
- *
- */
-public interface MultipleFileCompiler {
- public void compileFile(List<IFile> file, IProgressMonitor monitor) throws CoreException;
-}
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,84 +0,0 @@
-/*
- * Author: David Corbin
- *
- * Copyright (c) 2005 RubyPeople.
- *
- * This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
- */
-
-
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.jruby.ast.Node;
-import org.jruby.ast.visitor.NodeVisitor;
-import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.parser.warnings.DelegatingVisitor;
-import org.rubypeople.rdt.core.parser.warnings.RubyLintVisitor;
-import org.rubypeople.rdt.internal.core.parser.Error;
-import org.rubypeople.rdt.internal.core.parser.ImmediateWarnings;
-import org.rubypeople.rdt.internal.core.parser.RubyParser;
-
-public final class RubyCodeAnalyzer implements SingleFileCompiler {
- private final IMarkerManager markerManager;
- private RubyParser parser;
-
- public RubyCodeAnalyzer(IMarkerManager markerManager) {
- this(markerManager, new RubyParser(new ImmediateWarnings(markerManager)));
- }
-
- public RubyCodeAnalyzer(IMarkerManager markerManager, RubyParser parser) {
- this.markerManager = markerManager;
- this.parser = parser;
- }
-
- public void compileFile(IFile file) throws CoreException {
- Reader reader = null;
- try {
- reader = new InputStreamReader(file.getContents(), file.getCharset());
- } catch (UnsupportedEncodingException e1) {
- RubyCore.log(e1);
- return;
- }
- String contents = readContents(reader);
- markerManager.removeProblemsAndTasksFor(file);
- try {
- Node rootNode = parser.parse(file, new StringReader(contents));
- if (rootNode == null) return;
- List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents); // FIXME How do we hook the warnings/errors up now?!
- NodeVisitor visitor = new DelegatingVisitor(visitors);
- rootNode.accept(visitor);
- } catch (SyntaxException e) {
- markerManager.addProblem(file, new Error(e.getPosition(), e.getMessage()));
- } finally {
- IoUtils.closeQuietly(reader);
- }
- }
-
- private String readContents(Reader reader) {
- try {
- int c = 0;
- StringBuffer str = new StringBuffer();
- while ((c = reader.read()) != -1) {
- str.append((char) c);
- }
- return str.toString();
- } catch (IOException e) {
- e.printStackTrace();
- return "";
- }
- }
-
-}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -0,0 +1,59 @@
+package org.rubypeople.rdt.internal.core.builder;
+
+import java.io.Reader;
+import java.io.StringReader;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.jruby.ast.Node;
+import org.jruby.lexer.yacc.SyntaxException;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.compiler.BuildContext;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.CompilationParticipant;
+import org.rubypeople.rdt.core.compiler.IProblem;
+import org.rubypeople.rdt.core.parser.warnings.DelegatingVisitor;
+import org.rubypeople.rdt.core.parser.warnings.RubyLintVisitor;
+import org.rubypeople.rdt.internal.core.parser.Error;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+
+public class RubyCodeAnalyzer extends CompilationParticipant {
+
+ private RubyParser parser;
+
+ public RubyCodeAnalyzer() {
+ this.parser = new RubyParser();
+ }
+
+ @Override
+ public boolean isActive(IRubyProject project) {
+ return true;
+ }
+
+ @Override
+ public void buildStarting(BuildContext[] files, boolean isBatch) {
+ for (int i = 0; i < files.length; i++) {
+ BuildContext context = files[i];
+
+ IFile file = context.getFile();
+ String contents = new String(context.getContents());
+ Reader reader = new StringReader(contents);
+ try {
+ Node rootNode = parser.parse(file, reader);
+ if (rootNode == null)
+ return;
+ List<RubyLintVisitor> visitors = DelegatingVisitor.createVisitors(contents);
+ DelegatingVisitor visitor = new DelegatingVisitor(visitors);
+ rootNode.accept(visitor);
+
+ List<CategorizedProblem> problems = visitor.getProblems();
+ context.recordNewProblems(problems.toArray(new CategorizedProblem[problems.size()]));
+ } catch (SyntaxException e) {
+ context.recordNewProblems(new CategorizedProblem[] {new Error(e.getPosition(), e.getMessage(), IProblem.Syntax) });
+ } finally {
+ IoUtils.closeQuietly(reader);
+ }
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubyCodeAnalyzer.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/SingleFileCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,25 +0,0 @@
-/*
-?* Author: David Corbin
-?*
-?* Copyright (c) 2005 RubyPeople.
-?*
-?* This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
-?*/
-
-
-package org.rubypeople.rdt.internal.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-
-/**
- * @deprecated Please use CompilationParticipant infrastructure
- * @author Chris Williams
- *
- */
-public interface SingleFileCompiler {
- public void compileFile(IFile file) throws CoreException;
-}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -1,51 +0,0 @@
-/*
-?* Author: David Corbin
-?*
-?* Copyright (c) 2005 RubyPeople.
-?*
-?* This file is part of the Ruby Development Tools (RDT) plugin for eclipse.
- * RDT is subject to the "Common Public License (CPL) v 1.0". You may not use
- * RDT except in compliance with the License. For further information see
- * org.rubypeople.rdt/rdt.license.
-?*/
-
-
-package org.rubypeople.rdt.internal.core.builder;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.parser.TaskParser;
-
-public final class TaskCompiler implements SingleFileCompiler {
- private final TaskParser taskParser;
- private final IMarkerManager markerManager;
-
- public TaskCompiler(IMarkerManager markerManager) {
- this(markerManager, new TaskParser(RubyCore.getOptions()));
- }
-
- public TaskCompiler(IMarkerManager markerManager, TaskParser taskParser) {
- this.taskParser = taskParser;
- this.markerManager = markerManager;
- }
-
- public void compileFile(IFile file) throws CoreException {
- InputStream contents = null;
- try {
- contents = file.getContents();
- taskParser.clear();
- taskParser.parse(new InputStreamReader(contents));
- markerManager.createTasks(file, taskParser.getTasks());
- taskParser.clear();
- } catch (IOException e) {
- RubyCore.log(e);
- } finally {
- IoUtils.closeQuietly(contents);
- }
- }
-}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -0,0 +1,38 @@
+package org.rubypeople.rdt.internal.core.builder;
+
+import java.util.List;
+
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.compiler.BuildContext;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.CompilationParticipant;
+import org.rubypeople.rdt.internal.core.parser.TaskParser;
+import org.rubypeople.rdt.internal.core.parser.TaskTag;
+
+public class TaskCompiler extends CompilationParticipant {
+
+ private TaskParser taskParser;
+
+ @Override
+ public int aboutToBuild(IRubyProject project) {
+ taskParser = new TaskParser(project.getOptions(true));
+ return super.aboutToBuild(project);
+ }
+
+ @Override
+ public boolean isActive(IRubyProject project) {
+ return true;
+ }
+
+ @Override
+ public void buildStarting(BuildContext[] files, boolean isBatch) {
+ for (int i = 0; i < files.length; i++) {
+ BuildContext context = files[i];
+ taskParser.parse(new String(context.getContents()));
+ List<TaskTag> tasks = taskParser.getTasks();
+ context.recordNewProblems(tasks.toArray(new CategorizedProblem[tasks.size()]));
+ taskParser.clear();
+ }
+ }
+
+}
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/TaskCompiler.java
___________________________________________________________________
Name: svn:mime-type
+ text/plain
Name: svn:keywords
+ Author Date Id Revision
Name: svn:eol-style
+ native
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-09-13 17:41:41 UTC (rev 3172)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-09-13 20:06:43 UTC (rev 3173)
@@ -69,6 +69,14 @@
}
public static void createProblemMarker(IResource underlyingResource, IProblem problem) {
+ if (problem.isTask()) {
+ try {
+ createTask(underlyingResource, (TaskTag) problem);
+ } catch (CoreException e) {
+ RubyCore.log(e);
+ }
+ return;
+ }
try {
IMarker marker = markerExists(underlyingResource, problem.getMessage(), problem.getSourceLineNumber(), IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER);
if (marker != null) return;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|