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...> - 2006-12-15 15:27:13
|
Revision: 1697
http://svn.sourceforge.net/rubyeclipse/?rev=1697&view=rev
Author: cawilliams
Date: 2006-12-15 07:27:11 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
remove static references to other projects (eclipse keeps flagging these as markers)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui.tests/.project
Modified: trunk/org.rubypeople.rdt.ui.tests/.project
===================================================================
--- trunk/org.rubypeople.rdt.ui.tests/.project 2006-12-15 15:22:39 UTC (rev 1696)
+++ trunk/org.rubypeople.rdt.ui.tests/.project 2006-12-15 15:27:11 UTC (rev 1697)
@@ -3,12 +3,6 @@
<name>org.rubypeople.rdt.ui.tests</name>
<comment></comment>
<projects>
- <project>org.junit</project>
- <project>org.rubypeople.eclipse.shams</project>
- <project>org.rubypeople.eclipse.testutils</project>
- <project>org.rubypeople.rdt.core</project>
- <project>org.rubypeople.rdt.core.tests</project>
- <project>org.rubypeople.rdt.ui</project>
</projects>
<buildSpec>
<buildCommand>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-15 15:22:40
|
Revision: 1696
http://svn.sourceforge.net/rubyeclipse/?rev=1696&view=rev
Author: cawilliams
Date: 2006-12-15 07:22:39 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Removed Paths:
-------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CompareResultsAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CopyTraceAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CounterPanel.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTab.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTrace.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener2.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener3.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenEditorAtLineAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenLocationAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenSymbolAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/RemoteTestRunnerClient.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/RerunAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ScrollLockAction.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TabFolderLayout.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestHierarchyTab.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestRunInfo.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestRunTab.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestUnitMessages.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestUnitMessages.properties
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestUnitProgressBar.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/TestUnitView.java
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CompareResultsAction.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CompareResultsAction.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CompareResultsAction.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import org.eclipse.jface.action.Action;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
-
-/**
- * Action to enable/disable stack trace filtering.
- */
-public class CompareResultsAction extends Action {
-
-
- public CompareResultsAction(FailureTrace view) {
- super(TestUnitMessages.getString("CompareResultsAction.label")); //$NON-NLS-1$
- setDescription(TestUnitMessages.getString("CompareResultsAction.description")); //$NON-NLS-1$
- setToolTipText(TestUnitMessages.getString("CompareResultsAction.tooltip")); //$NON-NLS-1$
-
- setDisabledImageDescriptor(TestunitPlugin.getImageDescriptor("dlcl16/compare.gif")); //$NON-NLS-1$
- setHoverImageDescriptor(TestunitPlugin.getImageDescriptor("elcl16/compare.gif")); //$NON-NLS-1$
- setImageDescriptor(TestunitPlugin.getImageDescriptor("elcl16/compare.gif")); //$NON-NLS-1$
- }
-
- /*
- * @see Action#actionPerformed
- */
- public void run() {
- // TODO Allow comparison of results
-// CompareResultDialog dialog = new CompareResultDialog(fView.getShell(), fView.getFailedTest());
-// dialog.create();
-// dialog.open();
- }
-}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CopyTraceAction.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CopyTraceAction.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CopyTraceAction.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.StringReader;
-import java.io.StringWriter;
-
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.util.Assert;
-
-/**
- * Copies a test failure stack trace to the clipboard.
- */
-public class CopyTraceAction extends Action {
- private FailureTrace fView;
-
- private final Clipboard fClipboard;
-
- /**
- * Constructor for CopyTraceAction.
- */
- public CopyTraceAction(FailureTrace view, Clipboard clipboard) {
- super(TestUnitMessages.getString("CopyTrace.action.label")); //$NON-NLS-1$
- Assert.isNotNull(clipboard);
- // TODO Show help!
- //WorkbenchHelp.setHelp(this, ITestUnitHelpContextIds.COPYTRACE_ACTION);
- fView= view;
- fClipboard= clipboard;
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- String trace= fView.getTrace();
- if (trace == null)
- trace= ""; //$NON-NLS-1$
-
- TextTransfer plainTextTransfer = TextTransfer.getInstance();
- try{
- fClipboard.setContents(
- new String[]{ convertLineTerminators(trace) },
- new Transfer[]{ plainTextTransfer });
- } catch (SWTError e){
- if (e.code != DND.ERROR_CANNOT_SET_CLIPBOARD)
- throw e;
- if (MessageDialog.openQuestion(fView.getComposite().getShell(), TestUnitMessages.getString("CopyTraceAction.problem"), TestUnitMessages.getString("CopyTraceAction.clipboard_busy"))) //$NON-NLS-1$ //$NON-NLS-2$
- run();
- }
- }
-
- private String convertLineTerminators(String in) {
- StringWriter stringWriter= new StringWriter();
- PrintWriter printWriter= new PrintWriter(stringWriter);
- StringReader stringReader= new StringReader(in);
- BufferedReader bufferedReader= new BufferedReader(stringReader);
- String line;
- try {
- while ((line= bufferedReader.readLine()) != null) {
- printWriter.println(line);
- }
- } catch (IOException e) {
- return in; // return the trace unfiltered
- }
- return stringWriter.toString();
- }
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CounterPanel.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CounterPanel.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/CounterPanel.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,114 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * A panel with counters for the number of Runs, Errors and Failures.
- */
-public class CounterPanel extends Composite {
- protected Text fNumberOfErrors;
- protected Text fNumberOfFailures;
- protected Text fNumberOfRuns;
- protected int fTotal;
-
- private final Image fErrorIcon= TestUnitView.createImage("ovr16/error_ovr.gif"); //$NON-NLS-1$
- private final Image fFailureIcon= TestUnitView.createImage("ovr16/failed_ovr.gif"); //$NON-NLS-1$
-
- public CounterPanel(Composite parent) {
- super(parent, SWT.WRAP);
- GridLayout gridLayout= new GridLayout();
- gridLayout.numColumns= 9;
- gridLayout.makeColumnsEqualWidth= false;
- gridLayout.marginWidth= 0;
- setLayout(gridLayout);
-
- fNumberOfRuns= createLabel(TestUnitMessages.getString("CounterPanel.label.runs"), null, " 0/0 "); //$NON-NLS-1$ //$NON-NLS-2$
- fNumberOfErrors= createLabel(TestUnitMessages.getString("CounterPanel.label.errors"), fErrorIcon, " 0 "); //$NON-NLS-1$ //$NON-NLS-2$
- fNumberOfFailures= createLabel(TestUnitMessages.getString("CounterPanel.label.failures"), fFailureIcon, " 0 "); //$NON-NLS-1$ //$NON-NLS-2$
-
- addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- disposeIcons();
- }
- });
- }
-
- private void disposeIcons() {
- fErrorIcon.dispose();
- fFailureIcon.dispose();
- }
-
- private Text createLabel(String name, Image image, String init) {
- Label label= new Label(this, SWT.NONE);
- if (image != null) {
- image.setBackground(label.getBackground());
- label.setImage(image);
- }
- label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
-
- label= new Label(this, SWT.NONE);
- label.setText(name);
- label.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
- label.setFont(JFaceResources.getBannerFont());
-
- Text value= new Text(this, SWT.READ_ONLY);
- value.setText(init);
- // bug: 39661 Junit test counters do not repaint correctly [JUnit]
- value.setBackground(getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- value.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING));
- return value;
- }
-
- public void reset() {
- setErrorValue(0);
- setFailureValue(0);
- setRunValue(0);
- fTotal= 0;
- }
-
- public void setTotal(int value) {
- fTotal= value;
- }
-
- public int getTotal(){
- return fTotal;
- }
-
- public void setRunValue(int value) {
- String runString= TestUnitMessages.getFormattedString("CounterPanel.runcount", new String[] { Integer.toString(value), Integer.toString(fTotal) }); //$NON-NLS-1$
- fNumberOfRuns.setText(runString);
-
- fNumberOfRuns.redraw();
- redraw();
- }
-
- public void setErrorValue(int value) {
- fNumberOfErrors.setText(Integer.toString(value));
- redraw();
- }
-
- public void setFailureValue(int value) {
- fNumberOfFailures.setText(Integer.toString(value));
- redraw();
- }
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTab.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTab.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTab.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,348 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.CTabFolder;
-import org.eclipse.swt.custom.CTabItem;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.internal.core.symbols.ISymbolFinder;
-import org.rubypeople.rdt.testunit.ITestRunListener;
-
-/**
- * A tab presenting the failed tests in a table.
- */
-public class FailureTab extends TestRunTab implements IMenuListener {
-
- private Table fTable;
- private TestUnitView fRunnerViewPart;
- private boolean fMoveSelection = false;
-
- private final Image fErrorIcon = TestUnitView.createImage("obj16/testerr.gif"); //$NON-NLS-1$
- private final Image fFailureIcon = TestUnitView.createImage("obj16/testfail.gif"); //$NON-NLS-1$
- private final Image fFailureTabIcon = TestUnitView.createImage("obj16/failures.gif"); //$NON-NLS-1$
-
- public FailureTab() {}
-
- public void createTabControl(CTabFolder tabFolder, Clipboard clipboard, TestUnitView runner) {
- fRunnerViewPart = runner;
-
- CTabItem failureTab = new CTabItem(tabFolder, SWT.NONE);
- failureTab.setText(getName());
- failureTab.setImage(fFailureTabIcon);
-
- Composite composite = new Composite(tabFolder, SWT.NONE);
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- composite.setLayout(gridLayout);
-
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
- composite.setLayoutData(gridData);
-
- fTable = new Table(composite, SWT.NONE);
- gridLayout = new GridLayout();
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- fTable.setLayout(gridLayout);
-
- gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL);
- fTable.setLayoutData(gridData);
-
- failureTab.setControl(composite);
- failureTab.setToolTipText(TestUnitMessages.getString("FailureRunView.tab.tooltip")); //$NON-NLS-1$
-
- initMenu();
- addListeners();
- }
-
- private void disposeIcons() {
- fErrorIcon.dispose();
- fFailureIcon.dispose();
- fFailureTabIcon.dispose();
- }
-
- private void initMenu() {
- MenuManager menuMgr = new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(this);
- Menu menu = menuMgr.createContextMenu(fTable);
- fTable.setMenu(menu);
- }
-
- public String getName() {
- return TestUnitMessages.getString("FailureRunView.tab.title"); //$NON-NLS-1$
- }
-
- public String getSelectedTestId() {
- int index = fTable.getSelectionIndex();
- if (index == -1) return null;
- return getTestInfo(fTable.getItem(index)).getTestId();
- }
-
- public String getAllFailedTestNames() {
- StringBuffer trace = new StringBuffer();
- String lineDelim = System.getProperty("line.separator", "\n"); //$NON-NLS-1$//$NON-NLS-2$
- for (int i = 0; i < fTable.getItemCount(); i++) {
- TestRunInfo testInfo = getTestInfo(fTable.getItem(i));
- trace.append(testInfo.getTestName()).append(lineDelim);
- String failureTrace = testInfo.getTrace();
- if (failureTrace != null) {
- StringReader stringReader = new StringReader(failureTrace);
- BufferedReader bufferedReader = new BufferedReader(stringReader);
- String line;
- try {
- while ((line = bufferedReader.readLine()) != null)
- trace.append(line + lineDelim);
- } catch (IOException e) {
- trace.append(lineDelim);
- }
- }
- }
- return trace.toString();
- }
-
- private String getClassName() {
- TableItem item = getSelectedItem();
- TestRunInfo info = getTestInfo(item);
- return info.getClassName();
- }
-
- private String getMethodName() {
- TableItem item = getSelectedItem();
- TestRunInfo info = getTestInfo(item);
- return info.getTestMethodName();
- }
-
- public void menuAboutToShow(IMenuManager manager) {
- if (fTable.getSelectionCount() > 0) {
- String className = getClassName();
- String methodName = getMethodName();
- if (className != null) {
- System.err.println("MethodName: " + methodName);
- manager.add(OpenSymbolAction.forMethod(className, methodName, getSymbolFinder(), getShell()));
- manager.add(new Separator());
- manager.add(new RerunAction(fRunnerViewPart, getSelectedTestId(),
- className, methodName, ILaunchManager.RUN_MODE));
- manager.add(new RerunAction(fRunnerViewPart, getSelectedTestId(),
- className, methodName, ILaunchManager.DEBUG_MODE));
- manager.add(new Separator());
- // TODO Add back the actions!
- //manager.add(new CopyFailureListAction(fRunnerViewPart,
- // FailureTab.this, fClipboard));
- }
- }
- }
-
- private ISymbolFinder getSymbolFinder() {
- return RubyCore.getPlugin().getSymbolFinder();
- }
-
- private TableItem getSelectedItem() {
- int index = fTable.getSelectionIndex();
- if (index == -1) return null;
- return fTable.getItem(index);
- }
-
- public void setSelectedTest(String testId) {
- TableItem[] items = fTable.getItems();
- for (int i = 0; i < items.length; i++) {
- TableItem tableItem = items[i];
- TestRunInfo info = getTestInfo(tableItem);
- if (info.getTestId().equals(testId)) {
- fTable.setSelection(new TableItem[] { tableItem});
- fTable.showItem(tableItem);
- return;
- }
- }
- }
-
- private TestRunInfo getTestInfo(TableItem item) {
- return (TestRunInfo) item.getData();
- }
-
- public void setFocus() {
- fTable.setFocus();
- }
-
- public void endTest(String testId) {
- TestRunInfo testInfo = fRunnerViewPart.getTestInfo(testId);
- if (testInfo == null || testInfo.getStatus() == ITestRunListener.STATUS_OK) return;
-
- TableItem tableItem = new TableItem(fTable, SWT.NONE);
- updateTableItem(testInfo, tableItem);
- fTable.showItem(tableItem);
- }
-
- private void updateTableItem(TestRunInfo testInfo, TableItem tableItem) {
- String label = TestUnitMessages.getFormattedString("FailureRunView.labelfmt", new String[] { testInfo.getTestMethodName(), testInfo.getClassName()}); //$NON-NLS-1$
- tableItem.setText(label);
- if (testInfo.getStatus() == ITestRunListener.STATUS_FAILURE)
- tableItem.setImage(fFailureIcon);
- else
- tableItem.setImage(fErrorIcon);
- tableItem.setData(testInfo);
- }
-
- private TableItem findItem(String testId) {
- TableItem[] items = fTable.getItems();
- for (int i = 0; i < items.length; i++) {
- TestRunInfo info = getTestInfo(items[i]);
- if (info.getTestId().equals(testId)) return items[i];
- }
- return null;
- }
-
- public void activate() {
- fMoveSelection = false;
- testSelected();
- }
-
- public void aboutToStart() {
- fMoveSelection = false;
- fTable.removeAll();
- }
-
- private void testSelected() {
- fRunnerViewPart.handleTestSelected(getSelectedTestId());
- }
-
- private void addListeners() {
- fTable.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {
- activate();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- activate();
- }
- });
-
- fTable.addDisposeListener(new DisposeListener() {
-
- public void widgetDisposed(DisposeEvent e) {
- disposeIcons();
- }
- });
-
- fTable.addMouseListener(new MouseAdapter() {
-
- public void mouseDoubleClick(MouseEvent e) {
- handleDoubleClick(e);
- }
-
- public void mouseDown(MouseEvent e) {
- activate();
- }
-
- public void mouseUp(MouseEvent e) {
- activate();
- }
- });
- }
-
- void handleDoubleClick(MouseEvent e) {
- if (fTable.getSelectionCount() > 0)
- OpenSymbolAction.forMethod(getClassName(), getMethodName(), getSymbolFinder(), getShell()).run();
- }
-
- private Shell getShell() {
- return fTable.getShell();
- }
-
- /*
- * @see ITestRunView#testStatusChanged(TestRunInfo)
- */
- public void testStatusChanged(TestRunInfo info) {
- TableItem item = findItem(info.getTestId());
- if (item != null) {
- if (info.getStatus() == ITestRunListener.STATUS_OK) {
- item.dispose();
- return;
- }
- updateTableItem(info, item);
- }
- if (item == null && info.getStatus() != ITestRunListener.STATUS_OK) {
- item = new TableItem(fTable, SWT.NONE);
- updateTableItem(info, item);
- }
- if (item != null) fTable.showItem(item);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.internal.junit.ui.ITestRunView#selectNext()
- */
- public void selectNext() {
- if (fTable.getItemCount() == 0) return;
-
- int index = fTable.getSelectionIndex();
- if (index == -1) index = 0;
-
- if (fMoveSelection)
- index = Math.min(fTable.getItemCount() - 1, index + 1);
- else
- fMoveSelection = true;
-
- selectTest(index);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jdt.internal.junit.ui.ITestRunView#selectPrevious()
- */
- public void selectPrevious() {
- if (fTable.getItemCount() == 0) return;
-
- int index = fTable.getSelectionIndex();
- if (index == -1) index = fTable.getItemCount() - 1;
-
- if (fMoveSelection)
- index = Math.max(0, index - 1);
- else
- fMoveSelection = true;
-
- selectTest(index);
- }
-
- private void selectTest(int index) {
- TableItem item = fTable.getItem(index);
- TestRunInfo info = getTestInfo(item);
- fRunnerViewPart.showTest(info);
- }
-}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTrace.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTrace.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/FailureTrace.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,262 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sebastian Davids: sd...@gm... bug 37333, 26653
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.StringReader;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.ToolBarManager;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IOpenEventListener;
-import org.eclipse.jface.util.OpenStrategy;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.ToolBar;
-import org.rubypeople.rdt.internal.ui.util.StackTraceLine;
-
-/**
- * A pane that shows a stack trace of a failed test.
- */
-class FailureTrace implements IMenuListener {
- private final Image fStackIcon= TestUnitView.createImage("obj16/stkfrm_obj.gif"); //$NON-NLS-1$
- private final Image fExceptionIcon= TestUnitView.createImage("obj16/exc_catch.gif"); //$NON-NLS-1$
-
- private Table fTable;
- private String fInputTrace;
- private final Clipboard fClipboard;
- private TestRunInfo fFailure;
- private CompareResultsAction fCompareAction;
-
-
- public FailureTrace(Composite parent, Clipboard clipboard, TestUnitView testRunner, ToolBar toolBar) {
- Assert.isNotNull(clipboard);
-
- // fill the failure trace viewer toolbar
- ToolBarManager failureToolBarmanager= new ToolBarManager(toolBar);
- // TODO Add the EnableStackFilterAction back
- //failureToolBarmanager.add(new EnableStackFilterAction(this));
- fCompareAction = new CompareResultsAction(this);
- fCompareAction.setEnabled(false);
- failureToolBarmanager.add(fCompareAction);
- failureToolBarmanager.update(true);
-
- fTable= new Table(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL);
- fClipboard= clipboard;
-
- OpenStrategy handler = new OpenStrategy(fTable);
- handler.addOpenListener(new IOpenEventListener() {
- public void handleOpen(SelectionEvent e) {
- if (fTable.getSelectionIndex() == 0 && fFailure.isComparisonFailure()) {
- (new CompareResultsAction(FailureTrace.this)).run();
- }
- if (fTable.getSelection().length != 0) {
- Action a = createOpenEditorAction(getSelectedText());
- if (a != null)
- a.run();
- }
- }
- });
-
- initMenu();
- fTable.addSelectionListener(new SelectionListener() {
-
- public void widgetSelected(SelectionEvent e) {}
-
- public void widgetDefaultSelected(SelectionEvent e) {
- new StackTraceLine(getSelectedText()).openEditor();
- }
- });
-
- parent.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- disposeIcons();
- }
- });
- }
-
- private void initMenu() {
- MenuManager menuMgr= new MenuManager();
- menuMgr.setRemoveAllWhenShown(true);
- menuMgr.addMenuListener(this);
- Menu menu= menuMgr.createContextMenu(fTable);
- fTable.setMenu(menu);
- }
-
- public void menuAboutToShow(IMenuManager manager) {
- if (fTable.getSelectionCount() > 0) {
- Action a= createOpenEditorAction(getSelectedText());
- if (a != null)
- manager.add(a);
- manager.add(new CopyTraceAction(FailureTrace.this, fClipboard));
- }
- // fix for bug 68058
- if (fFailure != null && fFailure.isComparisonFailure())
- manager.add(new CompareResultsAction(FailureTrace.this));
- }
-
- public String getTrace() {
- return fInputTrace;
- }
-
- private String getSelectedText() {
- return fTable.getSelection()[0].getText();
- }
-
- private Action createOpenEditorAction(String traceLine) {
- return new OpenEditorAction(new StackTraceLine(traceLine));
- }
-
- private void disposeIcons(){
- if (fExceptionIcon != null && !fExceptionIcon.isDisposed())
- fExceptionIcon.dispose();
- if (fStackIcon != null && !fStackIcon.isDisposed())
- fStackIcon.dispose();
- }
-
- /**
- * Returns the composite used to present the trace
- */
- Composite getComposite(){
- return fTable;
- }
-
- /**
- * Refresh the table from the the trace.
- */
- public void refresh() {
- updateTable(fInputTrace);
- }
-
- /**
- * Shows a TestFailure
- * @param failure the failed test
- */
- public void showFailure(TestRunInfo failure) {
- fFailure= failure;
- String trace= ""; //$NON-NLS-1$
- updateEnablement(failure);
- if (failure != null)
- trace= failure.getTrace();
- if (fInputTrace == trace)
- return;
- fInputTrace= trace;
- updateTable(trace);
- }
-
- public void updateEnablement(TestRunInfo failure) {
- fCompareAction.setEnabled(failure != null && failure.isComparisonFailure());
- }
-
- private void updateTable(String trace) {
- if(trace == null || trace.trim().equals("")) { //$NON-NLS-1$
- clear();
- return;
- }
- trace= trace.trim();
- fTable.setRedraw(false);
- fTable.removeAll();
- fillTable(filterStack(trace));
- fTable.setRedraw(true);
- }
-
- private void fillTable(String trace) {
- StringReader stringReader= new StringReader(trace);
- BufferedReader bufferedReader= new BufferedReader(stringReader);
- String line;
-
- try {
- // first line contains the thrown exception
- line= bufferedReader.readLine();
- if (line == null)
- return;
-
- TableItem tableItem= new TableItem(fTable, SWT.NONE);
- String itemLabel= line.replace('\t', ' ');
- tableItem.setText(itemLabel);
- tableItem.setImage(fExceptionIcon);
-
- // the stack frames of the trace
- while ((line= bufferedReader.readLine()) != null) {
- itemLabel= line.replace('\t', ' ');
- tableItem= new TableItem(fTable, SWT.NONE);
- // heuristic for detecting a stack frame - works for JDK
- if ((itemLabel.indexOf(" at ") >= 0)) { //$NON-NLS-1$
- tableItem.setImage(fStackIcon);
- }
- tableItem.setText(itemLabel);
- }
- } catch (IOException e) {
- TableItem tableItem= new TableItem(fTable, SWT.NONE);
- tableItem.setText(trace);
- }
- }
-
- /**
- * Shows other information than a stack trace.
- * @param text the informational message to be shown
- */
- public void setInformation(String text) {
- clear();
- TableItem tableItem= new TableItem(fTable, SWT.NONE);
- tableItem.setText(text);
- }
-
- /**
- * Clears the non-stack trace info
- */
- public void clear() {
- fTable.removeAll();
- fInputTrace= null;
- }
-
- private String filterStack(String stackTrace) {
- return stackTrace;
- // TODO Filter the stack trace
- }
-
-
- public TestRunInfo getFailedTest() {
- return fFailure;
- }
-
- public Shell getShell() {
- return fTable.getShell();
- }
-
- private class OpenEditorAction extends Action {
- private final StackTraceLine trace;
-
- public OpenEditorAction(StackTraceLine trace) {
- super(TestUnitMessages.getString("OpenEditor.action.label"));
- this.trace = trace;
- }
-
- public void run() {
- trace.openEditor();
- }
- }
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener2.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener2.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener2.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import org.rubypeople.rdt.testunit.ITestRunListener;
-
-/**
- * Extends ITestRunListener with a call back to trace the test contents
- */
-public interface ITestRunListener2 extends ITestRunListener {
-
- /**
- * Information about a member of the test suite that is about to be run. The
- * format of the string is:
- *
- * <pre>
- *
- * "testId","testName","isSuite","testcount"
- *
- * testId: a unique id for the test
- * testName: the name of the test
- * isSuite: true or false depending on whether the test is a suite
- * testCount: an integer indicating the number of tests
- *
- * Example: "324968,testPass(junit.tests.MyTest),false,1"
- *
- * </pre>
- *
- * @param description
- * a string describing a tree entry
- */
- public void testTreeEntry(String description);
-}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener3.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener3.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/ITestRunListener3.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,22 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-
-/**
- * Extends ITestRunListener2 with a call back to trace the test contents
- */
-public interface ITestRunListener3 extends ITestRunListener2 {
-
- public void testFailed(int status, String testId, String testName, String trace, String expected, String actual);
-
- public void testReran(String testId, String className, String testName, int statusCode, String trace, String expectedResult, String actualResult);
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenEditorAtLineAction.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenEditorAtLineAction.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenEditorAtLineAction.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Sebastian Davids: sd...@gm... bug 37333 Failure Trace cannot
- * navigate to non-public class in CU throwing Exception
-
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.model.ISourceLocator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyProject;
-import org.rubypeople.rdt.internal.debug.ui.RubySourceLocator;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
-
-/**
- * Open a test in the Ruby editor and reveal a given line
- */
-public class OpenEditorAtLineAction extends Action {
-
- private int fLineNumber;
- private String fileName;
- private TestUnitView fTestRunner;
-
- /**
- * Constructor for OpenEditorAtLineAction.
- */
- public OpenEditorAtLineAction(TestUnitView testRunner, String fileName, int line) {
- super(TestUnitMessages.getString("OpenEditorAction.action.label"));
- // TODO Uncomment and fix!
- // WorkbenchHelp.setHelp(this,
- // IJUnitHelpContextIds.OPENEDITORATLINE_ACTION);
- fLineNumber = line;
- fTestRunner = testRunner;
- this.fileName = fileName;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.rubypeople.rdt.testunit.views.OpenEditorAction#run()
- */
- public void run() {
- try {
- IEditorInput input = getInput();
- if (input == null) {
- if (TestunitPlugin.getDefault().isDebugging()) {
- System.out
- .println("Could not create editor input for stack trace: " + fileName);
- }
- // wrongly detected stack trace
- return;
- }
- IEditorPart editorPart = getEditorPart(input);
- setEditorToLine(editorPart, input);
- } catch (CoreException e) {
- TestunitPlugin.log(new Status(IStatus.ERROR, TestunitPlugin.PLUGIN_ID, 0,
- "Could not open editor or set line in editor." + fileName, e));
- }
- }
-
- /**
- * @param input
- * @return
- * @throws PartInitException
- */
- private IEditorPart getEditorPart(IEditorInput input) throws PartInitException {
- ISourceLocator sourceLocator = getSourceLocator();
- if (!(sourceLocator instanceof RubySourceLocator)) { return null; }
- RubySourceLocator rubySourceLocator = (RubySourceLocator) sourceLocator;
-
- Object sourceElement = rubySourceLocator.getSourceElement(fileName);
- return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(
- input, rubySourceLocator.getEditorId(input, sourceElement));
- }
-
- private void setEditorToLine(IEditorPart pEditorPart, IEditorInput pInput) throws CoreException {
- if (!(pEditorPart instanceof ITextEditor)) { return; }
- // documents start at 0
- if (fLineNumber > 0) {
- fLineNumber--;
- }
- if (fLineNumber == 0) { return; }
- ITextEditor textEditor = (ITextEditor) pEditorPart;
- IDocumentProvider provider = textEditor.getDocumentProvider();
- provider.connect(pInput);
- IDocument document = provider.getDocument(pInput);
- try {
- IRegion line = document.getLineInformation(fLineNumber);
- textEditor.selectAndReveal(line.getOffset(), line.getLength());
- } catch (BadLocationException e) {
- if (TestunitPlugin.getDefault().isDebugging()) {
- System.out.println("Could not set editor to line: " + fLineNumber);
- }
- }
- provider.disconnect(pInput);
- }
-
- protected void reveal(ITextEditor textEditor) {
- if (fLineNumber >= 0) {
- try {
- IDocument document = textEditor.getDocumentProvider().getDocument(
- textEditor.getEditorInput());
- textEditor.selectAndReveal(document.getLineOffset(fLineNumber - 1), document
- .getLineLength(fLineNumber - 1));
- } catch (BadLocationException x) {
- // marker refers to invalid text position -> do nothing
- }
- }
- }
-
- protected IRubyElement findElement(IRubyProject project, String className) throws CoreException {
- return project.findType(className);
- }
-
- public boolean isEnabled() {
- return getInput() != null;
- }
-
- /**
- * @return
- */
- private IEditorInput getInput() {
- ISourceLocator sourceLocator = getSourceLocator();
- if (!(sourceLocator instanceof RubySourceLocator)) { return null; }
- RubySourceLocator rubySourceLocator = (RubySourceLocator) sourceLocator;
-
- Object sourceElement = rubySourceLocator.getSourceElement(fileName);
- IEditorInput input = rubySourceLocator.getEditorInput(sourceElement);
- return input;
- }
-
- /**
- * @return
- */
- private ISourceLocator getSourceLocator() {
- ILaunch launch = fTestRunner.getLastLaunch();
- if (launch == null) { return null; }
- return launch.getSourceLocator();
- }
-
- protected Shell getShell() {
- return fTestRunner.getSite().getShell();
- }
-
- protected IRubyProject getLaunchedProject() {
- return fTestRunner.getLaunchedProject();
- }
-
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenLocationAction.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenLocationAction.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenLocationAction.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,23 +0,0 @@
-package org.rubypeople.rdt.testunit.views;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.rubypeople.rdt.internal.core.symbols.Location;
-import org.rubypeople.rdt.internal.ui.util.PositionBasedEditorOpener;
-
-
-public class OpenLocationAction extends Action implements IAction {
-
- private final Location location;
-
- public OpenLocationAction(Location location) {
- super(location.getFilename());
- this.location = location;
- }
-
- public void run() {
- new PositionBasedEditorOpener(location.getFilename(), location.getPosition()).open();
- }
-
-
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenSymbolAction.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenSymbolAction.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/OpenSymbolAction.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,99 +0,0 @@
-package org.rubypeople.rdt.testunit.views;
-
-import java.util.Set;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Shell;
-import org.rubypeople.rdt.internal.core.symbols.ClassSymbol;
-import org.rubypeople.rdt.internal.core.symbols.ISymbolFinder;
-import org.rubypeople.rdt.internal.core.symbols.Location;
-import org.rubypeople.rdt.internal.core.symbols.MethodSymbol;
-import org.rubypeople.rdt.internal.core.symbols.Symbol;
-import org.rubypeople.rdt.internal.ui.RubyPluginImages;
-import org.rubypeople.rdt.internal.ui.dialogs.ElementListSelectionDialog;
-import org.rubypeople.rdt.internal.ui.util.PositionBasedEditorOpener;
-
-public class OpenSymbolAction extends Action implements IAction {
-
- private final Symbol symbol;
- private final ISymbolFinder finder;
- private final Shell shell;
- private String dialogTitle;
-
- public static IAction forClass(String className, ISymbolFinder finder, Shell shell) {
- return new OpenSymbolAction(new ClassSymbol(className), finder, shell, "Open Class");
- }
-
- public static IAction forMethod(String className, String testMethod,
- ISymbolFinder finder, Shell shell) {
- return new OpenSymbolAction(new MethodSymbol(className, testMethod), finder, shell, "Open Method");
- }
-
- public OpenSymbolAction(Symbol symbol, ISymbolFinder finder, Shell shell, String title) {
- super(TestUnitMessages.getString("OpenEditor.action.label"));
- this.shell = shell;
- this.symbol = symbol;
- this.finder = finder;
- this.dialogTitle = title;
- }
-
-
- public void run() {
- Set locations = finder.find(symbol);
- if (locations.size() == 0)
- return;
-
- Location location;
- if (locations.size() == 1) {
- location = (Location) locations.iterator().next();
- } else {
- ElementListSelectionDialog selectionDialog
- = new ElementListSelectionDialog(shell, new LocationLabel());
- selectionDialog.setElements(locations.toArray());
- selectionDialog.setMessage("Select a location");
- selectionDialog.setTitle(dialogTitle);
- selectionDialog.open();
- if (selectionDialog.getReturnCode() == SWT.CANCEL)
- return;
- location= (Location) selectionDialog.getResult()[0];
- }
- PositionBasedEditorOpener editorOpener
- = new PositionBasedEditorOpener(location.getFilename(),
- location.getPosition());
- editorOpener.open();
- }
-
-
- private final class LocationLabel implements ILabelProvider {
- public Image getImage(Object element) {
- return RubyPluginImages.get(RubyPluginImages.IMG_CTOOLS_RUBY_PAGE);
- }
-
- public String getText(Object element) {
- Location location = (Location) element;
- IFile sourceFile = location.getSourceFile();
- return sourceFile.getName() + ":" + location.getPosition().getStartLine() + " - " + sourceFile.getFullPath().removeLastSegments(1);
- }
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
- }
-
-
-}
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/RemoteTestRunnerClient.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/RemoteTestRunnerClient.java 2006-12-15 15:22:22 UTC (rev 1695)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/views/RemoteTestRunnerClient.java 2006-12-15 15:22:39 UTC (rev 1696)
@@ -1,535 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Julien Ruaux: jr...@oc...
- * Vincent Massol: vm...@oc...
- ******************************************************************************/
-package org.rubypeople.rdt.testunit.views;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
-import java.net.ServerSocket;
-import java.net.Socket;
-import java.net.SocketException;
-
-import org.eclipse.core.runtime.ISafeRunnable;
-import org.eclipse.core.runtime.SafeRunner;
-import org.rubypeople.rdt.testunit.ITestRunListener;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
-import org.rubypeople.rdt.testunit.runner.MessageIds;
-
-/**
- * The client side of the RemoteTestRunner. Handles the marshaling of the
- * different messages.
- */
-public class RemoteTestRunnerClient {
-
- public abstract class ListenerSafeRunnable implements ISafeRunnable {
-
- public void handleException(Throwable exception) {
- TestunitPlugin.log(exception);
- }
- }
-
- /**
- * A simple state machine to process requests from the RemoteTestRunner
- */
- abstract class ProcessingState {
-
- abstract ProcessingState readMessage(String message);
- }
-
- class DefaultProcessingState extends ProcessingState {
-
- ProcessingState readMessage(String message) {
- if (message.startsWith(MessageIds.TRACE_START)) {
- fFailedTrace = ""; //$NON-NLS-1$
- return fTraceState;
- }
- if (message.startsWith(MessageIds.EXPECTED_START)) {
- fExpectedResult = null;
- return fExpectedState;
- }
- if (message.startsWith(MessageIds.ACTUAL_START)) {
- fActualResult = null;
- return fActualState;
- }
- if (message.startsWith(MessageIds.RTRACE_START)) {
- fFailedRerunTrace = ""; //$NON-NLS-1$
- return fRerunState;
- }
- String arg = message.substring(MessageIds.MSG_HEADER_LENGTH);
- if (message.startsWith(MessageIds.TEST_RUN_START)) {
- // version < 2 format: count
- // version >= 2 format: count+" "+version
- int count = 0;
- int v = arg.indexOf(' ');
- if (v == -1) {
- fVersion = "v1"; //$NON-NLS-1$
- count = Integer.parseInt(arg);
- } else {
- fVersion = arg.substring(v + 1);
- String sc = arg.substring(0, v);
- count = Integer.parseInt(sc);
- }
- notifyTestRunStarted(count);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_START)) {
- notifyTestStarted(arg);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_END)) {
- notifyTestEnded(arg);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_ERROR)) {
- extractFailure(arg, ITestRunListener.STATUS_ERROR);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_FAILED)) {
- extractFailure(arg, ITestRunListener.STATUS_FAILURE);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_RUN_END)) {
- long elapsedTime = Long.parseLong(arg);
- testRunEnded(elapsedTime);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_STOPPED)) {
- long elapsedTime = Long.parseLong(arg);
- notifyTestRunStopped(elapsedTime);
- shutDown();
- return this;
- }
- if (message.startsWith(MessageIds.TEST_TREE)) {
- notifyTestTreeEntry(arg);
- return this;
- }
- if (message.startsWith(MessageIds.TEST_RERAN)) {
- if (hasTestId())
- scanReranMessage(arg);
- else
- scanOldReranMessage(arg);
- return this;
- }
- return this;
- }
- }
-
- class TraceProcessingState extends ProcessingState {
-
- ProcessingState readMessage(String message) {
- if (message.startsWith(MessageIds.TRACE_END)) {
- notifyTestFailed();
- fFailedTrace = ""; //$NON-NLS-1$
- fExpectedResult = null;
- fActualResult = null;
- return fDefaultState;
- }
- fFailedTrace += message + '\n';
- return this;
- }
- }
-
- class ExpectedProcessingState extends ProcessingState {
-
- ProcessingState readMessage(String message) {
- if (message.startsWith(MessageIds.EXPECTED_END)) return fDefaultState;
- if (fExpectedResult == null)
- fExpectedResult = message + '\n';
- else
- fExpectedResult += message + '\n';
- return this;
- }
- }
-
- class ActualProcessingState extends ProcessingState {
-
- ProcessingState readMessage(String message) {
- if (message.startsWith(MessageIds.ACTUAL_END)) return fDefaultState;
- if (fActualResult == null)
- fActualResult = message + '\n';
- else
- fActualResult += message + '\n';
- return this;
- }
- }
-
- class RerunTraceProcessingState extends ProcessingState {
-
- ProcessingState readMessage(String message) {
- if (message.startsWith(MessageIds.RTRACE_END)) return fDefaultState;
- fFailedRerunTrace += message + '\n';
- return this;
- }
- }
-
- ProcessingState fDefaultState = new DefaultProcessingState();
- ProcessingState fTraceState = new TraceProcessingState();
- ProcessingState fExpectedState = new ExpectedProcessingState();
- ProcessingState fActualState = new ActualProcessingState();
- ProcessingState fRerunState = new RerunTraceProcessingState();
- ProcessingState fCurrentState = fDefaultState;
-
- /**
- * An array of listeners that are informed about test events.
- */
- private ITestRunListener[] fListeners;
-
- /**
- * The server socket
- */
- private ServerSocket fServerSocket;
- private Socket fSocket;
- private int fPort = -1;
- private PrintWriter fWriter;
- private BufferedReader fBufferedReader;
- /**
- * The protocol version
- */
- private String fVersion;
- /**
- * The failed test that is currently reported from the RemoteTestRunner
- */
- private String fFailedTest;
- /**
- * The Id of the failed test
- */
- private String fFailedTestId;
- /**
- * The failed trace that is currently reported from the RemoteTestRunner
- */
- private String fFailedTrace;
- /**
- * The expected test result
- */
- private String fExpectedResult;
- /**
- * The actual test result
- */
- private String fActualResult;
- /**
- * The failed trace of a reran test
- */
- private String fFailedRerunTrace;
- /**
- * The kind of failure of the test that is currently reported as failed
- */
- private int fFailureKind;
-
- private boolean fDebug = false;
-
- /**
- * Reads the message stream from the RemoteTestRunner
- */
- private class ServerConnection extends Thread {
-
- int fServerPort;
-
- public ServerConnection(int port) {
- super("ServerConnection"); //$NON-NLS-1$
- fServerPort = port;
- }
-
- public void run() {
- try {
- if (fDebug) System.out.println("Creating server socket " + fServerPort); //$NON-NLS-1$
- fServerSocket = new ServerSocket(fServerPort);
- fSocket = fServerSocket.accept();
- try {
- fBufferedReader = new BufferedReader(new InputStreamReader(fSocket.getInputStream(), "UTF-8")); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e) {
- fBufferedReader = new BufferedReader(new InputStreamReader(fSocket.getInputStream()));
- }
- try {
- fWriter = new PrintWriter(new OutputStreamWriter(fSocket.getOutputStream(), "UTF-8"), true); //$NON-NLS-1$
- } catch (UnsupportedEncodingException e1) {
- fWriter = new PrintWriter(new OutputStreamWriter(fSocket.getOutputStream()), true);
- }
- String message;
- while (fBufferedReader != null && (message = readMessage(fBufferedReader)) != null)
- receiveMessage(message);
- } catch (SocketException e) {
- notifyTestRunTerminated();
- } catch (IOException e) {
- System.out.println(e);
- // fall through
- }
- shutDown();
- }
- }
-
- /**
- * Start listening to a test run. Start a server connection that the
- * RemoteTestRunner can connect to.
- */
- public synchronized void startListening(ITestRunListener[] listeners, int port) {
- fListeners = listeners;
- fPort = port;
- ServerConnection connection = new ServerConnection(port);
- connection.start();
- }
-
- /**
- * Requests to stop the remote test run.
- */
- public synchronized void stopTest() {
- if (isRunning()) {
- fWriter.println(MessageIds.TEST_STOP);
- fWriter.flush();
- }
- }
-
- private synchronized void shutDown() {
- if (fDebug) System.out.println("shutdown " + fPort); //$NON-NLS-1$
-
- if (fWriter != null) {
- fWriter.close();
- fWriter = null;
- }
- try {
- if (fBufferedReader != null) {
- fBufferedReader.close();
- fBufferedReader = null;
- }
- } catch (IOException e) {}
- try {
- if (fSocket != null) {
- fSocket.close();
- fSocket = null;
- }
- } catch (IOException e) {}
- try {
- if (fServerSocket != null) {
- fServerSocket.close();
- fServerSocket = null;
- }
- } catch (IOException e) {}
- }
-
- public boolean isRunning() {
- return fSocket != null;
- }
-
- private String readMessage(BufferedReader in) throws IOException {
- return in.readLine();
- }
-
- private void receiveMessage(String message) {
- fCurrentState = fCurrentState.readMessage(message);
- }
-
- private void scanOldReranMessage(String arg) {
- // OLD V1 format
- // format: className" "testName" "status
- // status: FAILURE, ERROR, OK
- int c = arg.indexOf(" "); //$NON-NLS-1$
- int t = arg.indexOf(" ", c + 1); //$NON-NLS-1$
- String className = arg.substring(0, c);
- String testName = arg.substring(c + 1, t);
- String status = arg.substring(t + 1);
- int statusCode = ITestRunListener.STATUS_OK;
- if (status.equals("FAILURE")) //$NON-NLS-1$
- statusCode = ITestRunListener.STATUS_FAILURE;
- else if (status.equals("ERROR")) //$NON-NLS-1$
- statusCode = ITestRunListener.STATUS_ERROR;
-
- String trace = ""; //$NON-NLS-1$
- if (statusCode != ITestRunListener.STATUS_OK) trace = fFailedRerunTrace;
- // assumption a rerun trace was sent before
- notifyTestReran(className + testName, className, testName, statusCode, trace);
- }
-
- private void scanReranMessage(String arg) {
- // format: testId" "className" "testName" "status
- // status: FAILURE, ERROR, OK
- int i = arg.indexOf(' ');
- int c = arg.indexOf(' ', i + 1); //$NON-NLS-1$
- int t = arg.indexOf(' ', c + 1); //$NON-NLS-1$
- String testId = arg.substring(0, i);
- String className = arg.substring(i + 1, c);
- String testName = arg.substring(c + 1, t);
- String status = arg.substring(t + 1);
- int statusCode = ITestRunListener.STATUS_OK;
- if (status.equals("FAILURE")) //$NON-NLS-1$
- statusCode = ITestRunListener.STATUS_FAILURE;
- else if (status.equals("ERROR")) //$NON-NLS-1$
- statusCode = ITestRunListener.STATUS_ERROR;
-
- String trace = ""; //$NON-NLS-1$
- if (statusCode != ITestRunListener.STATUS_OK) trace = fFailedRerunTrace;
- // assumption a rerun trace was sent before
- notifyTestReran(testId, className, testName, statusCode, trace);
- }
-
- private void extractFailure(String arg, int status) {
- String s[] = extractTestId(arg);
- fFailedTestId = s[0];
- fFailedTest = s[1];
- fFailureKind = status;
- }
-
- /**
- * Returns an array with two elements. The first one is the testId, the
- * second one the testName.
- */
- String[] extractTestId(String arg) {
- String[] result = new String[2];
- if (!hasTestId()) {
- result[0] = arg; // use the test name as the test Id
- result[1] = arg;
- return result;
- }
- int i = arg.indexOf(',');
- result[0] = arg.substring(0, i);
- result[1] = arg.substring(i + 1, arg.length());
- return result;
- }
-
- private boolean hasTestId() {
- if (fVersion == null) // TODO fix me
- return true;
- return fVersion.equals("v2"); //$NON-NLS-1$
- }
-
- private void notifyTestReran(final String testId, final String className, final String testName, final int statusCode, final String trace) {
- for (int i = 0; i < fListeners.length; i++) {
- final ITestRunListener listener = fListeners[i];
- SafeRunner.run(new ListenerSafeRunnable() {
-
- public void run() {
- if (listener instanceof ITestRunListener3)
- ((ITestRunListener3) listener).testReran(testId, className, testName, statusCode, trace, fExpectedResult, fActualResult);
- else
- listener.testReran(testId, className, testName, s...
[truncated message content] |
|
From: <caw...@us...> - 2006-12-15 15:22:23
|
Revision: 1695
http://svn.sourceforge.net/rubyeclipse/?rev=1695&view=rev
Author: cawilliams
Date: 2006-12-15 07:22:22 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Added Paths:
-----------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/LayoutUtil.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/TestUnitStatus.java
Added: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/LayoutUtil.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/LayoutUtil.java (rev 0)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/LayoutUtil.java 2006-12-15 15:22:22 UTC (rev 1695)
@@ -0,0 +1,169 @@
+/*******************************************************************************
+ * 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.testunit.util;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.rubypeople.rdt.internal.testunit.wizards.MethodStubsSelectionButtonGroup;
+import org.rubypeople.rdt.internal.ui.util.PixelConverter;
+
+
+public class LayoutUtil {
+
+ /*
+ * Calculates the number of columns needed by field editors
+ */
+ public static int getNumberOfColumns(MethodStubsSelectionButtonGroup[] editors) {
+ int columnCount= 0;
+ for (int i= 0; i < editors.length; i++) {
+ columnCount= Math.max(editors[i].getNumberOfControls(), columnCount);
+ }
+ return columnCount;
+ }
+
+ /*
+ * Creates a composite and fills in the given editors.
+ * @param labelOnTop Defines if the label of all fields should be on top of the fields
+ */
+ public static void doDefaultLayout(Composite parent, MethodStubsSelectionButtonGroup[] editors, boolean labelOnTop) {
+ doDefaultLayout(parent, editors, labelOnTop, 0, 0, 0, 0);
+ }
+
+ /*
+ * Creates a composite and fills in the given editors.
+ * @param labelOnTop Defines if the label of all fields should be on top of the fields
+ * @param minWidth The minimal width of the composite
+ * @param minHeight The minimal height of the composite
+ */
+ public static void doDefaultLayout(Composite parent, MethodStubsSelectionButtonGroup[] editors, boolean labelOnTop, int minWidth, int minHeight) {
+ doDefaultLayout(parent, editors, labelOnTop, minWidth, minHeight, 0, 0);
+ }
+
+ public static void doDefaultLayout(Composite parent, MethodStubsSelectionButtonGroup[] editors, boolean labelOnTop, int minWidth, int minHeight, int marginWidth, int marginHeight) {
+ int nCulumns= getNumberOfColumns(editors);
+ Control[][] controls= new Control[editors.length][];
+ for (int i= 0; i < editors.length; i++) {
+ controls[i]= editors[i].doFillIntoGrid(parent, nCulumns);
+ }
+ if (labelOnTop) {
+ nCulumns--;
+ modifyLabelSpans(controls, nCulumns);
+ }
+ GridLayout layout= new GridLayout();
+ if (marginWidth != SWT.DEFAULT) {
+ layout.marginWidth= marginWidth;
+ }
+ if (marginHeight != SWT.DEFAULT) {
+ layout.marginHeight= marginHeight;
+ }
+// layout.minimumWidth= minWidth;
+// layout.minimumHeight= minHeight;
+ layout.numColumns= nCulumns;
+ parent.setLayout(layout);
+ }
+
+ private static void modifyLabelSpans(Control[][] controls, int nCulumns) {
+ for (int i= 0; i < controls.length; i++) {
+ setHorizontalSpan(controls[i][0], nCulumns);
+ }
+ }
+
+ /*
+ * Sets the span of a control. Assumes that MGridData is used.
+ */
+ public static void setHorizontalSpan(Control control, int span) {
+ Object ld= control.getLayoutData();
+ if (ld instanceof GridData) {
+ ((GridData)ld).horizontalSpan= span;
+ } else if (span != 1) {
+ GridData gd= new GridData();
+ gd.horizontalSpan= span;
+ control.setLayoutData(gd);
+ }
+ }
+
+ /*
+ * Sets the width hint of a control. Assumes that MGridData is used.
+ */
+ public static void setWidthHint(Control control, int widthHint) {
+ Object ld= control.getLayoutData();
+ if (ld instanceof GridData) {
+ ((GridData)ld).widthHint= widthHint;
+ }
+ }
+
+ /*
+ * Sets the horizontal indent of a control. Assumes that MGridData is used.
+ */
+ public static void setHorizontalIndent(Control control, int horizontalIndent) {
+ Object ld= control.getLayoutData();
+ if (ld instanceof GridData) {
+ ((GridData)ld).horizontalIndent= horizontalIndent;
+ }
+ }
+
+ /*
+ * Creates a spacer control with the given span.
+ * The composite is assumed to have <code>MGridLayout</code> as
+ * layout.
+ * @param parent The parent composite
+ */
+ public static Control createEmptySpace(Composite parent, int span) {
+ Label label= new Label(parent, SWT.LEFT);
+ GridData gd= new GridData();
+ gd.horizontalAlignment= GridData.BEGINNING;
+ gd.grabExcessHorizontalSpace= false;
+ gd.horizontalSpan= span;
+ gd.horizontalIndent= 0;
+ gd.widthHint= 0;
+ gd.heightHint= 0;
+ label.setLayoutData(gd);
+ return label;
+ }
+
+
+ /**
+ * Returns a width hint for a button control.
+ * @param button the button for which to set the dimension hint
+ * @return the width hint
+ */
+ public static int getButtonWidthHint(Button button) {
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter= new PixelConverter(button);
+ int widthHint= converter.convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x);
+ }
+
+ /**
+ * Sets width and height hint for the button control.
+ * <b>Note:</b> This is a NOP if the button's layout data is not
+ * an instance of <code>GridData</code>.
+ *
+ * @param button the button for which to set the dimension hint
+ */
+ public static void setButtonDimensionHint(Button button) {
+ Assert.isNotNull(button);
+ Object gd= button.getLayoutData();
+ if (gd instanceof GridData) {
+ ((GridData)gd).widthHint= getButtonWidthHint(button);
+ ((GridData)gd).horizontalAlignment = GridData.FILL;
+ }
+ }
+
+}
Added: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/TestUnitStatus.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/TestUnitStatus.java (rev 0)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/util/TestUnitStatus.java 2006-12-15 15:22:22 UTC (rev 1695)
@@ -0,0 +1,182 @@
+/*******************************************************************************
+ * 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.testunit.util;
+
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.IStatus;
+import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
+
+/**
+ * An implemention of IStatus.
+ * TO DO: Why is it duplicated, it should leverage the Status base class???
+ */
+public class TestUnitStatus implements IStatus {
+ private String fStatusMessage;
+ private int fSeverity;
+
+ /**
+ * Creates a status set to OK (no message)
+ */
+ public TestUnitStatus() {
+ this(OK, null);
+ }
+
+ /**
+ * Creates a status .
+ * @param severity The status severity: ERROR, WARNING, INFO and OK.
+ * @param message The message of the status. Applies only for ERROR,
+ * WARNING and INFO.
+ */
+ public TestUnitStatus(int severity, String message) {
+ fStatusMessage= message;
+ fSeverity= severity;
+ }
+
+ public static IStatus createError(String message) {
+ return new TestUnitStatus(IStatus.ERROR, message);
+ }
+
+ public static IStatus createWarning(String message) {
+ return new TestUnitStatus(IStatus.WARNING, message);
+ }
+
+ public static IStatus createInfo(String message) {
+ return new TestUnitStatus(IStatus.INFO, message);
+ }
+
+ /**
+ * Returns if the status' severity is OK.
+ */
+ public boolean isOK() {
+ return fSeverity == IStatus.OK;
+ }
+
+ /**
+ * Returns if the status' severity is WARNING.
+ */
+ public boolean isWarning() {
+ return fSeverity == IStatus.WARNING;
+ }
+
+ /**
+ * Returns if the status' severity is INFO.
+ */
+ public boolean isInfo() {
+ return fSeverity == IStatus.INFO;
+ }
+
+ /**
+ * Returns if the status' severity is ERROR.
+ */
+ public boolean isError() {
+ return fSeverity == IStatus.ERROR;
+ }
+
+ /**
+ * @see IStatus#getMessage()
+ */
+ public String getMessage() {
+ return fStatusMessage;
+ }
+
+ /**
+ * Sets the status to ERROR.
+ * @param errorMessage the error message (can be empty, but not null)
+ */
+ public void setError(String errorMessage) {
+ Assert.isNotNull(errorMessage);
+ fStatusMessage= errorMessage;
+ fSeverity= IStatus.ERROR;
+ }
+
+ /**
+ * Sets the status to WARNING.
+ * @param warningMessage the warning message (can be empty, but not null)
+ */
+ public void setWarning(String warningMessage) {
+ Assert.isNotNull(warningMessage);
+ fStatusMessage= warningMessage;
+ fSeverity= IStatus.WARNING;
+ }
+
+ /**
+ * Sets the status to INFO.
+ * @param infoMessage the info message (can be empty, but not null)
+ */
+ public void setInfo(String infoMessage) {
+ Assert.isNotNull(infoMessage);
+ fStatusMessage= infoMessage;
+ fSeverity= IStatus.INFO;
+ }
+
+ /**
+ * Sets the status to OK.
+ */
+ public void setOK() {
+ fStatusMessage= null;
+ fSeverity= IStatus.OK;
+ }
+
+ /*
+ * @see IStatus#matches(int)
+ */
+ public boolean matches(int severityMask) {
+ return (fSeverity & severityMask) != 0;
+ }
+
+ /**
+ * Returns always <code>false</code>.
+ * @see IStatus#isMultiStatus()
+ */
+ public boolean isMultiStatus() {
+ return false;
+ }
+
+ /*
+ * @see IStatus#getSeverity()
+ */
+ public int getSeverity() {
+ return fSeverity;
+ }
+
+ /*
+ * @see IStatus#getPlugin()
+ */
+ public String getPlugin() {
+ return TestunitPlugin.PLUGIN_ID;
+ }
+
+ /**
+ * Returns always <code>null</code>.
+ * @see IStatus#getException()
+ */
+ public Throwable getException() {
+ return null;
+ }
+
+ /**
+ * Returns always the error severity.
+ * @see IStatus#getCode()
+ */
+ public int getCode() {
+ return fSeverity;
+ }
+
+ /**
+ * Returns always <code>null</code>.
+ * @see IStatus#getChildren()
+ */
+ public IStatus[] getChildren() {
+ return new IStatus[0];
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-15 15:22:05
|
Revision: 1694
http://svn.sourceforge.net/rubyeclipse/?rev=1694&view=rev
Author: cawilliams
Date: 2006-12-15 07:22:04 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF
Modified: trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF 2006-12-15 15:20:34 UTC (rev 1693)
+++ trunk/org.rubypeople.rdt.testunit/META-INF/MANIFEST.MF 2006-12-15 15:22:04 UTC (rev 1694)
@@ -4,10 +4,11 @@
Bundle-SymbolicName: org.rubypeople.rdt.testunit; singleton:=true
Bundle-Version: 0.0.0
Bundle-ClassPath: testunit.jar
-Bundle-Activator: org.rubypeople.rdt.testunit.TestunitPlugin
+Bundle-Activator: org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin
Bundle-Vendor: %providerName
Bundle-Localization: plugin
-Export-Package: org.rubypeople.rdt.testunit.views
+Export-Package: org.rubypeople.rdt.testunit.launcher,
+ org.rubypeople.rdt.testunit.wizards
Require-Bundle: org.eclipse.ui,
org.eclipse.core.runtime,
org.eclipse.debug.core,
@@ -19,5 +20,6 @@
org.rubypeople.rdt.debug.ui,
org.eclipse.ui.workbench.texteditor,
org.eclipse.text,
- org.jruby
+ org.jruby,
+ org.eclipse.ui.ide
Eclipse-LazyStart: true
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-15 15:20:36
|
Revision: 1693
http://svn.sourceforge.net/rubyeclipse/?rev=1693&view=rev
Author: cawilliams
Date: 2006-12-15 07:20:34 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Removed Paths:
-------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/TestunitPlugin.java
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/TestunitPlugin.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/TestunitPlugin.java 2006-12-15 15:20:19 UTC (rev 1692)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/TestunitPlugin.java 2006-12-15 15:20:34 UTC (rev 1693)
@@ -1,285 +0,0 @@
-package org.rubypeople.rdt.testunit;
-
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.AbstractSet;
-import java.util.HashSet;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.ILaunch;
-import org.eclipse.debug.core.ILaunchConfiguration;
-import org.eclipse.debug.core.ILaunchListener;
-import org.eclipse.debug.core.ILaunchManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.osgi.framework.BundleContext;
-import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.testunit.launcher.TestUnitLaunchConfigurationDelegate;
-import org.rubypeople.rdt.testunit.views.TestUnitView;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class TestunitPlugin extends AbstractUIPlugin implements ILaunchListener {
-
- public static final String PLUGIN_ID = "org.rubypeople.rdt.testunit"; //$NON-NLS-1$
- public static final String TESTUNIT_PORT_ATTR = "org.rubypeople.rdt.testunit.port"; //$NON-NLS-1$
- //The shared instance.
- private static TestunitPlugin plugin;
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * Use to track new launches. We need to do this so that we only attach a
- * TestRunner once to a launch. Once a test runner is connected it is
- * removed from the set.
- */
- private AbstractSet fTrackedLaunches = new HashSet(20);
-
- private static URL fgIconBaseURL;
-
- /**
- * The constructor.
- */
- public TestunitPlugin() {
- super();
- plugin = this;
- String pathSuffix = "icons/full/"; //$NON-NLS-1$
- try {
- fgIconBaseURL = new URL(Platform.getBundle(PLUGIN_ID).getEntry("/"), pathSuffix); //$NON-NLS-1$
- } catch (MalformedURLException e) {
- // do nothing
- }
- try {
- resourceBundle = ResourceBundle.getBundle("org.rubypeople.rdt.testunit.TestunitPluginResources");
- } catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- public static URL makeIconFileURL(String name) throws MalformedURLException {
- if (TestunitPlugin.fgIconBaseURL == null) throw new MalformedURLException();
- return new URL(TestunitPlugin.fgIconBaseURL, name);
- }
-
- public static ImageDescriptor getImageDescriptor(String relativePath) {
- try {
- return ImageDescriptor.createFromURL(makeIconFileURL(relativePath));
- } catch (MalformedURLException e) {
- // should not happen
- return ImageDescriptor.getMissingImageDescriptor();
- }
- }
-
- /**
- * This method is called upon plug-in activation
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager();
- launchManager.addLaunchListener(this);
- }
-
- /**
- * This method is called when the plug-in is stopped
- */
- public void stop(BundleContext context) throws Exception {
- super.stop(context);
- }
-
- /**
- * Returns the shared instance.
- */
- public static TestunitPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle, or 'key' if not
- * found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = TestunitPlugin.getDefault().getResourceBundle();
- try {
- return (bundle != null) ? bundle.getString(key) : key;
- } catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-
- public static String getPluginId() {
- return PLUGIN_ID;
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, getPluginId(), IStatus.ERROR, "Error", e)); //$NON-NLS-1$
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static Shell getActiveWorkbenchShell() {
- IWorkbenchWindow workBenchWindow = getActiveWorkbenchWindow();
- if (workBenchWindow == null) return null;
- return workBenchWindow.getShell();
- }
-
- /**
- * Returns the active workbench window
- *
- * @return the active workbench window
- */
- public static IWorkbenchWindow getActiveWorkbenchWindow() {
- if (plugin == null) return null;
- IWorkbench workBench = plugin.getWorkbench();
- if (workBench == null) return null;
- return workBench.getActiveWorkbenchWindow();
- }
-
- public static IWorkspace getWorkspace() {
- return RubyCore.getWorkspace();
- }
-
- public static Display getDisplay() {
- Display display = Display.getCurrent();
- if (display == null) {
- display = Display.getDefault();
- }
- return display;
- }
-
- public static IWorkbenchPage getActivePage() {
- IWorkbenchWindow activeWorkbenchWindow = getActiveWorkbenchWindow();
- if (activeWorkbenchWindow == null) return null;
- return activeWorkbenchWindow.getActivePage();
- }
-
- public void connectTestRunner(ILaunch launch, IType finalType, int port) {
- TestUnitView testRunnerViewPart = showTestUnitViewInActivePage(findTestUnitViewInActivePage());
- if (testRunnerViewPart != null) testRunnerViewPart.startTestRunListening(port, finalType, launch);
- }
-
- private TestUnitView showTestUnitViewInActivePage(TestUnitView testRunner) {
- IWorkbenchPart activePart = null;
- IWorkbenchPage page = null;
- try {
- // TODO: have to force the creation of view part contents
- // otherwise the UI will not be updated
- if (testRunner != null && testRunner.isCreated()) return testRunner;
- page = getActivePage();
- if (page == null) return null;
- activePart = page.getActivePart();
- // show the result view if it isn't shown yet
- return (TestUnitView) page.showView(TestUnitView.NAME);
- } catch (PartInitException pie) {
- log(pie);
- return null;
- } finally {
- //restore focus stolen by the creation of the result view
- if (page != null && activePart != null) page.activate(activePart);
- }
- }
-
- private TestUnitView findTestUnitViewInActivePage() {
- IWorkbenchPage page = getActivePage();
- if (page == null) return null;
- return (TestUnitView) page.findView(TestUnitView.NAME);
- }
-
- /**
- * @param string
- */
- public static void log(String string) {
- log(new Throwable(string));
- }
-
- /*
- * @see ILaunchListener#launchRemoved(ILaunch)
- */
- public void launchRemoved(final ILaunch launch) {
- fTrackedLaunches.remove(launch);
- getDisplay().asyncExec(new Runnable() {
-
- public void run() {
- TestUnitView testRunnerViewPart = findTestRunnerViewPartInActivePage();
- if (testRunnerViewPart != null && testRunnerViewPart.isCreated() && launch.equals(testRunnerViewPart.getLastLaunch())) testRunnerViewPart.reset();
- }
- });
- }
-
- private TestUnitView findTestRunnerViewPartInActivePage() {
- IWorkbenchPage page = getActivePage();
- if (page == null) return null;
- return (TestUnitView) page.findView(TestUnitView.NAME);
- }
-
- /*
- * @see ILaunchListener#launchChanged(ILaunch)
- */
- public void launchChanged(final ILaunch launch) {
- if (!fTrackedLaunches.contains(launch)) return;
-
- ILaunchConfiguration config = launch.getLaunchConfiguration();
- IType launchedType= null;
- if (config != null) {
-
- String typeStr = launch.getAttribute(TestUnitLaunchConfigurationDelegate.TESTTYPE_ATTR);
- // String fileName= launch.getAttribute(TestUnitLaunchConfigurationDelegate.LAUNCH_CONTAINER_ATTR);
-
- if (typeStr != null) {
- // FIXME Get the handle on the test type from the model somehow!
- // IFile script = RubyCore.find(fileName);
- // if (element instanceof IRubyType)
- // launchedType= (IRubyType) element;
- }
-
- }
- fTrackedLaunches.remove(launch);
-
- final IType finalType= launchedType;
- final int finalPort = Integer.parseInt(launch.getAttribute(TESTUNIT_PORT_ATTR)) ;
- getDisplay().asyncExec(new Runnable() {
- public void run() {
- connectTestRunner(launch, finalType, finalPort);
- }
- });
-
- }
-
- /*
- * @see ILaunchListener#launchAdded(ILaunch)
- */
- public void launchAdded(ILaunch launch) {
- try {
- if (launch.getLaunchConfiguration().getType().getDelegate(launch.getLaunchMode()).getClass() != TestUnitLaunchConfigurationDelegate.class) {
- return;
- }
- fTrackedLaunches.add(launch);
- } catch (CoreException ex) {
- log(ex);
- }
- }
-}
\ 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...> - 2006-12-15 15:20:20
|
Revision: 1692
http://svn.sourceforge.net/rubyeclipse/?rev=1692&view=rev
Author: cawilliams
Date: 2006-12-15 07:20:19 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Removed Paths:
-------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/runner/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-15 15:19:50
|
Revision: 1691
http://svn.sourceforge.net/rubyeclipse/?rev=1691&view=rev
Author: cawilliams
Date: 2006-12-15 07:19:46 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/RubyClassSelector.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitMainTab.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitTabGroup.java
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/RubyClassSelector.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/RubyClassSelector.java 2006-12-15 15:19:12 UTC (rev 1690)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/RubyClassSelector.java 2006-12-15 15:19:46 UTC (rev 1691)
@@ -45,9 +45,9 @@
import org.eclipse.ui.dialogs.ElementListSelectionDialog;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.testunit.ui.TestUnitMessages;
import org.rubypeople.rdt.internal.ui.util.RubyFileSelector;
import org.rubypeople.rdt.internal.ui.util.RubyProjectSelector;
-import org.rubypeople.rdt.testunit.views.TestUnitMessages;
import org.rubypeople.rdt.ui.RubyElementLabelProvider;
/**
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java 2006-12-15 15:19:12 UTC (rev 1690)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchConfigurationDelegate.java 2006-12-15 15:19:46 UTC (rev 1691)
@@ -4,7 +4,7 @@
import org.eclipse.debug.core.ILaunchConfiguration;
import org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration;
import org.rubypeople.rdt.internal.launching.RubyApplicationLaunchConfigurationDelegate;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
+import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
public class TestUnitLaunchConfigurationDelegate extends RubyApplicationLaunchConfigurationDelegate {
/**
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java 2006-12-15 15:19:12 UTC (rev 1690)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitLaunchShortcut.java 2006-12-15 15:19:46 UTC (rev 1691)
@@ -33,9 +33,9 @@
import org.rubypeople.rdt.internal.debug.ui.launcher.RubyApplicationShortcut;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
import org.rubypeople.rdt.internal.launching.RubyRuntime;
+import org.rubypeople.rdt.internal.testunit.ui.TestUnitMessages;
+import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
-import org.rubypeople.rdt.testunit.views.TestUnitMessages;
public class TestUnitLaunchShortcut extends RubyApplicationShortcut {
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitMainTab.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitMainTab.java 2006-12-15 15:19:12 UTC (rev 1690)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitMainTab.java 2006-12-15 15:19:46 UTC (rev 1691)
@@ -48,11 +48,11 @@
import org.rubypeople.rdt.internal.debug.ui.RdtDebugUiMessages;
import org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration;
import org.rubypeople.rdt.internal.launching.RubyLaunchConfigurationAttribute;
+import org.rubypeople.rdt.internal.testunit.ui.TestUnitMessages;
+import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.util.RubyFileSelector;
import org.rubypeople.rdt.internal.ui.util.RubyProjectSelector;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
-import org.rubypeople.rdt.testunit.views.TestUnitMessages;
/**
* @author Chris
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java 2006-12-15 15:19:12 UTC (rev 1690)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java 2006-12-15 15:19:46 UTC (rev 1691)
@@ -10,7 +10,7 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.SocketUtil;
import org.rubypeople.rdt.internal.launching.InterpreterRunnerConfiguration;
-import org.rubypeople.rdt.testunit.TestunitPlugin;
+import org.rubypeople.rdt.internal.testunit.ui.TestunitPlugin;
public class TestUnitRunnerConfiguration extends InterpreterRunnerConfiguration {
private int port = -1 ;
Deleted: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitTabGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitTabGroup.java 2006-12-15 15:19:12 UTC (rev 1690)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitTabGroup.java 2006-12-15 15:19:46 UTC (rev 1691)
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * 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
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.testunit.launcher;
-
-import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
-import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup;
-import org.eclipse.debug.ui.CommonTab;
-import org.eclipse.debug.ui.ILaunchConfigurationDialog;
-import org.eclipse.debug.ui.ILaunchConfigurationTab;
-import org.eclipse.debug.ui.ILaunchConfigurationTabGroup;
-import org.rubypeople.rdt.internal.debug.ui.launcher.RubyEnvironmentTab;
-
-public class TestUnitTabGroup extends AbstractLaunchConfigurationTabGroup {
-
- /**
- * @see ILaunchConfigurationTabGroup#createTabs(ILaunchConfigurationDialog,
- * String)
- */
- public void createTabs(ILaunchConfigurationDialog dialog, String mode) {
- ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { new TestUnitMainTab(), new RubyEnvironmentTab(), new CommonTab()};
- setTabs(tabs);
- }
-
- /**
- * @see ILaunchConfigurationTabGroup#setDefaults(ILaunchConfigurationWorkingCopy)
- */
- public void setDefaults(ILaunchConfigurationWorkingCopy config) {
- super.setDefaults(config);
- }
-}
\ 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...> - 2006-12-15 15:19:18
|
Revision: 1690
http://svn.sourceforge.net/rubyeclipse/?rev=1690&view=rev
Author: cawilliams
Date: 2006-12-15 07:19:12 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
add the schema for test unit tabs
Added Paths:
-----------
trunk/org.rubypeople.rdt.testunit/schema/
trunk/org.rubypeople.rdt.testunit/schema/internal_testRunTabs.exsd
Added: trunk/org.rubypeople.rdt.testunit/schema/internal_testRunTabs.exsd
===================================================================
--- trunk/org.rubypeople.rdt.testunit/schema/internal_testRunTabs.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.testunit/schema/internal_testRunTabs.exsd 2006-12-15 15:19:12 UTC (rev 1690)
@@ -0,0 +1,105 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.testunit">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.testunit" id="internalTestRunTabs" name="%testRunTabs.name"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="testRunTab"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="testRunTab">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="ruby" basedOn="org.rubypeople.rdt.internal.testunit.ui.TestRunTab"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
\ 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...> - 2006-12-15 15:16:48
|
Revision: 1689
http://svn.sourceforge.net/rubyeclipse/?rev=1689&view=rev
Author: cawilliams
Date: 2006-12-15 07:16:45 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Added Paths:
-----------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-15 15:16:38
|
Revision: 1688
http://svn.sourceforge.net/rubyeclipse/?rev=1688&view=rev
Author: cawilliams
Date: 2006-12-15 07:16:35 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
move things around so most suff is internal (and looks like the JDT's package structure)
Added Paths:
-----------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-15 15:13:35
|
Revision: 1687
http://svn.sourceforge.net/rubyeclipse/?rev=1687&view=rev
Author: cawilliams
Date: 2006-12-15 07:13:33 -0800 (Fri, 15 Dec 2006)
Log Message:
-----------
remove static references to other projects (eclipse keeps flagging these as markers)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/.project
trunk/org.rubypeople.rdt.debug.ui/.project
trunk/org.rubypeople.rdt.debug.ui.tests/.project
trunk/org.rubypeople.rdt.launching/.project
trunk/org.rubypeople.rdt.launching.tests/.project
trunk/org.rubypeople.rdt.tests.all/.project
Modified: trunk/org.rubypeople.rdt.debug.core/.project
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/.project 2006-12-11 18:00:14 UTC (rev 1686)
+++ trunk/org.rubypeople.rdt.debug.core/.project 2006-12-15 15:13:33 UTC (rev 1687)
@@ -3,8 +3,6 @@
<name>org.rubypeople.rdt.debug.core</name>
<comment></comment>
<projects>
- <project>org.kxml2</project>
- <project>org.rubypeople.rdt.core</project>
</projects>
<buildSpec>
<buildCommand>
Modified: trunk/org.rubypeople.rdt.debug.ui/.project
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.debug.ui.tests/.project
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui.tests/.project 2006-12-11 18:00:14 UTC (rev 1686)
+++ trunk/org.rubypeople.rdt.debug.ui.tests/.project 2006-12-15 15:13:33 UTC (rev 1687)
@@ -3,14 +3,6 @@
<name>org.rubypeople.rdt.debug.ui.tests</name>
<comment></comment>
<projects>
- <project>org.junit</project>
- <project>org.rubypeople.eclipse.shams</project>
- <project>org.rubypeople.eclipse.testutils</project>
- <project>org.rubypeople.rdt.core</project>
- <project>org.rubypeople.rdt.debug.core</project>
- <project>org.rubypeople.rdt.debug.ui</project>
- <project>org.rubypeople.rdt.launching</project>
- <project>org.rubypeople.rdt.ui</project>
</projects>
<buildSpec>
<buildCommand>
Modified: trunk/org.rubypeople.rdt.launching/.project
===================================================================
(Binary files differ)
Modified: trunk/org.rubypeople.rdt.launching.tests/.project
===================================================================
--- trunk/org.rubypeople.rdt.launching.tests/.project 2006-12-11 18:00:14 UTC (rev 1686)
+++ trunk/org.rubypeople.rdt.launching.tests/.project 2006-12-15 15:13:33 UTC (rev 1687)
@@ -3,11 +3,6 @@
<name>org.rubypeople.rdt.launching.tests</name>
<comment></comment>
<projects>
- <project>org.apache.xerces</project>
- <project>org.junit</project>
- <project>org.rubypeople.eclipse.shams</project>
- <project>org.rubypeople.eclipse.testutils</project>
- <project>org.rubypeople.rdt.launching</project>
</projects>
<buildSpec>
<buildCommand>
Modified: trunk/org.rubypeople.rdt.tests.all/.project
===================================================================
--- trunk/org.rubypeople.rdt.tests.all/.project 2006-12-11 18:00:14 UTC (rev 1686)
+++ trunk/org.rubypeople.rdt.tests.all/.project 2006-12-15 15:13:33 UTC (rev 1687)
@@ -3,12 +3,6 @@
<name>org.rubypeople.rdt.tests.all</name>
<comment></comment>
<projects>
- <project>org.junit</project>
- <project>org.rubypeople.rdt.core.tests</project>
- <project>org.rubypeople.rdt.debug.core.tests</project>
- <project>org.rubypeople.rdt.debug.ui.tests</project>
- <project>org.rubypeople.rdt.launching.tests</project>
- <project>org.rubypeople.rdt.ui.tests</project>
</projects>
<buildSpec>
<buildCommand>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-11 18:00:20
|
Revision: 1686
http://svn.sourceforge.net/rubyeclipse/?rev=1686&view=rev
Author: cawilliams
Date: 2006-12-11 10:00:14 -0800 (Mon, 11 Dec 2006)
Log Message:
-----------
handle case where args to include are in a SplatNode. Include string representations of NilNode, FalseNode, TrueNode - these shwo up in method signatures on the outline view...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2006-12-09 09:51:50 UTC (rev 1685)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptStructureBuilder.java 2006-12-11 18:00:14 UTC (rev 1686)
@@ -830,6 +830,12 @@
return "{}";
if (node instanceof SelfNode)
return "self";
+ if (node instanceof NilNode)
+ return "nil";
+ if (node instanceof TrueNode)
+ return "true";
+ if (node instanceof FalseNode)
+ return "false";
if (node instanceof ConstNode)
return ((ConstNode)node).getName();
if (node instanceof ZArrayNode)
@@ -1008,9 +1014,18 @@
// Collect included mixins
if ( functionName.equals("include") ) {
- List<String> mixins = new LinkedList<String>();;
- ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
- for (Iterator iter = arrayNode.iterator(); iter.hasNext();) {
+ List<String> mixins = new LinkedList<String>();
+ Node argsNode = iVisited.getArgsNode();
+ Iterator iter = null;
+ if (argsNode instanceof SplatNode) {
+ SplatNode splat = (SplatNode) argsNode;
+ iter = splat.childNodes().iterator();
+ }
+ else if (argsNode instanceof ArrayNode) {
+ ArrayNode arrayNode = (ArrayNode) iVisited.getArgsNode();
+ iter = arrayNode.iterator();
+ }
+ for (; iter.hasNext();) {
Node mixinNameNode = (Node) iter.next();
if ( mixinNameNode instanceof StrNode ) {
mixins.add( ((StrNode)mixinNameNode).getValue() );
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-12-09 09:51:52
|
Revision: 1685
http://svn.sourceforge.net/rubyeclipse/?rev=1685&view=rev
Author: mbarchfe
Date: 2006-12-09 01:51:50 -0800 (Sat, 09 Dec 2006)
Log Message:
-----------
removed @Override annotation for getDocumentPartitioning
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java 2006-12-08 21:40:38 UTC (rev 1684)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java 2006-12-09 09:51:50 UTC (rev 1685)
@@ -61,7 +61,6 @@
return RubyPlugin.getDefault().getRubyTextTools().createDocumentPartitioner();
}
- @Override
protected String getDocumentPartitioning() {
return IRubyPartitions.RUBY_PARTITIONING;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mba...@us...> - 2006-12-08 21:40:42
|
Revision: 1684
http://svn.sourceforge.net/rubyeclipse/?rev=1684&view=rev
Author: mbarchfe
Date: 2006-12-08 13:40:38 -0800 (Fri, 08 Dec 2006)
Log Message:
-----------
implemented inspection with ruby-debug, still buggy since it can hang eclipse
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebugCommandFactory.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java
trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem
Removed Paths:
-------------
trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem
Modified: trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebugCommandFactory.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebugCommandFactory.java 2006-12-07 15:01:53 UTC (rev 1683)
+++ trunk/org.rubypeople.rdt.debug.core/src/org/rubypeople/rdt/internal/debug/core/RubyDebugCommandFactory.java 2006-12-08 21:40:38 UTC (rev 1684)
@@ -41,7 +41,7 @@
}
public String createInspect(RubyStackFrame frame, String expression) {
- return "th " + ((RubyThread) frame.getThread()).getId() + " ; v inspect " + frame.getIndex() + " " + expression;
+ return "frame " + frame.getIndex() + " ; v inspect " + expression.replaceAll(";", "\\;");
}
public String createResume(RubyThread thread) {
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java 2006-12-07 15:01:53 UTC (rev 1683)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_AbstractDebuggerCommunicationTest.java 2006-12-08 21:40:38 UTC (rev 1684)
@@ -516,6 +516,12 @@
variables = getVariableReader().readVariables(
createStackFrame());
assertEquals(0, variables.length);
+ // escaped semicolon
+ sendRuby("v inspect a=1\\;a+1");
+ variables = getVariableReader().readVariables(
+ createStackFrame());
+ assertEquals("Handled escaded semicolon", 1, variables.length);
+ assertEquals("2", variables[0].getValue().getValueString());
sendRuby("cont");
}
@@ -842,25 +848,70 @@
"test.calc(a)" });
runToLine(4);
// test variable value in stack 1 (top stack frame)
- sendRuby("v inspect 1 a*2");
+ sendRuby("frame 1 ; v inspect a*2");
RubyVariable[] variables = getVariableReader().readVariables(
createStackFrame());
assertEquals("There is one variable returned.", 1, variables.length);
- assertEquals("Result is 12", "12", variables[0].getValue()
+ assertEquals("Result in frame 1 is 12", "12", variables[0].getValue()
.getValueString());
// test variable value in stack 2 (caller stack)
- sendRuby("v inspect 2 a*4");
+ sendRuby("frame 2 ; v inspect a*2");
variables = getVariableReader().readVariables(createStackFrame());
assertEquals("There is one variable returned.", 1, variables.length);
- assertEquals("Result is 12", "12", variables[0].getValue()
+ assertEquals("Result in frame 2 is 6", "6", variables[0].getValue()
.getValueString());
// test more complex expression
- sendRuby("v inspect 1 Test.new().calc(5)");
+ sendRuby("frame 1 ; v inspect Test.new().calc(5)");
variables = getVariableReader().readVariables(createStackFrame());
assertEquals("There is one variable returned.", 1, variables.length);
assertEquals("Result is 10", "10", variables[0].getValue()
.getValueString());
}
+
+ public void testInspectTemporaryArray() throws Exception {
+ createSocket(new String[] { "a=0", "puts a=2" });
+ runToLine(2);
+ sendRuby("v inspect %w[a b c]");
+ // this inspection will create a new temporary arrray object
+ RubyVariable[] variables = getVariableReader().readVariables(
+ createStackFrame());
+ assertEquals("There is one variable returned which contains the array.", 1, variables.length);
+ // the following two commands starts the garbage collector. This test
+ // is somehow implementation aware. It makes sure that the objects which are
+ // created as a result of an expression are referenced so that they will not be
+ // swept away from the GC
+ // TODO: actually garbage_collect does nothing, also the GC can not be enabled with GC.enable()
+ sendRuby("v inspect ObjectSpace.garbage_collect\\;sleep(2)");
+ RubyVariable[] gcResult = getVariableReader().readVariables(
+ createStackFrame());
+ assertEquals("There is one variable returned as result of running the GC", 1, gcResult.length);
+ sendRuby("v i " + variables[0].getObjectId());
+ RubyVariable[] elements = getVariableReader().readVariables(
+ variables[0]);
+ assertEquals("The array contains 3 elements", 3, elements.length);
+
+ }
+
+ public void testInspectNil() throws Exception {
+ createSocket(new String[] { "puts 'dummy'", "puts 'dummy'" });
+ runToLine(2);
+ sendRuby("v inspect nil");
+ RubyVariable[] variables = getVariableReader().readVariables(
+ createStackFrame());
+ assertEquals("There is one variable returned which contains the array.", 1, variables.length);
+ assertEquals("nil", variables[0].getValue().getValueString()) ;
+
+ }
+
+ public void testSendCommandWithSpecialCharacters() throws Exception {
+ // the inspect command can contain arbitrary characters
+ // a %w for example can raise an error when it is directly given to printf
+ sendRuby("v inspect %w[a b]");
+ RubyVariable[] variables = getVariableReader().readVariables(
+ createStackFrame());
+ assertEquals(1, variables.length) ;
+ // just do not fail
+ }
public void testInspectError() throws Exception {
createSocket(new String[] { "puts 'test'" });
Modified: trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java 2006-12-07 15:01:53 UTC (rev 1683)
+++ trunk/org.rubypeople.rdt.debug.core.tests/src/org/rubypeople/rdt/debug/core/tests/FTC_RubyDebugCommunicationTest.java 2006-12-08 21:40:38 UTC (rev 1684)
@@ -9,9 +9,12 @@
junit.framework.TestSuite suite = new junit.framework.TestSuite();
- suite.addTest(new FTC_RubyDebugCommunicationTest("testCommandList"));
+ suite.addTest(new FTC_RubyDebugCommunicationTest("testCommandList"));
suite.addTest(new FTC_RubyDebugCommunicationTest("testInspect"));
+ suite.addTest(new FTC_RubyDebugCommunicationTest("testInspectTemporaryArray"));
+ suite.addTest(new FTC_RubyDebugCommunicationTest("testInspectNil"));
+
suite.addTest(new FTC_RubyDebugCommunicationTest("testFrames"));
suite.addTest(new FTC_RubyDebugCommunicationTest("testStepOver"));
Deleted: trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem
===================================================================
--- trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem 2006-12-07 15:01:53 UTC (rev 1683)
+++ trunk/org.rubypeople.rdt.launching/ruby-debug-0.5.gem 2006-12-08 21:40:38 UTC (rev 1684)
@@ -1,212 +0,0 @@
-data.tar.gz |
|
From: <caw...@us...> - 2006-12-07 15:01:56
|
Revision: 1683
http://svn.sourceforge.net/rubyeclipse/?rev=1683&view=rev
Author: cawilliams
Date: 2006-12-07 07:01:53 -0800 (Thu, 07 Dec 2006)
Log Message:
-----------
handle case where file doesn't exist, also comment out logging of syntax exceptions that get caught - they get to be annoying in development and are quite common.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java 2006-12-07 14:57:45 UTC (rev 1682)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java 2006-12-07 15:01:53 UTC (rev 1683)
@@ -57,14 +57,16 @@
}
private void processFile(IFile file) {
+ if (!file.exists()) return;
try {
Node node = parser.parse(file);
updater.update(file, node, false);
} catch (CoreException e) {
RubyCore.log(e);
} catch (SyntaxException se) {
- RubyCore.log("Explicit catch of SyntaxError in MassIndexUpdater (jpm)");
- RubyCore.log(se);
+ // Just eat the exception!
+// RubyCore.log("Explicit catch of SyntaxError in MassIndexUpdater (jpm)");
+// RubyCore.log(se);
} catch (Exception ex) {
// e.g: the parser currently throws a ClassCastExcpetion when parsing xmldecl.rb
RubyCore.log(ex);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-07 14:57:49
|
Revision: 1682
http://svn.sourceforge.net/rubyeclipse/?rev=1682&view=rev
Author: cawilliams
Date: 2006-12-07 06:57:45 -0800 (Thu, 07 Dec 2006)
Log Message:
-----------
fix for Ticket #141
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java 2006-12-07 14:44:00 UTC (rev 1681)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/testunit/launcher/TestUnitRunnerConfiguration.java 2006-12-07 14:57:45 UTC (rev 1682)
@@ -81,7 +81,7 @@
throw new RuntimeException("Could not get necessary attributes from the launch configuration.") ;
}
- return fileName + " " + this.getPort() + " " + keepAlive + " " + testClass + " " + testMethod;
+ return "\"" + fileName + "\" " + this.getPort() + " " + keepAlive + " " + testClass + " " + testMethod;
}
public List renderLoadPath() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-07 14:44:07
|
Revision: 1681
http://svn.sourceforge.net/rubyeclipse/?rev=1681&view=rev
Author: cawilliams
Date: 2006-12-07 06:44:00 -0800 (Thu, 07 Dec 2006)
Log Message:
-----------
fix text on how to add update sites as per ticket #212
Modified Paths:
--------------
trunk/org.rubypeople.rdt.webpage/htdocs/download.php
Modified: trunk/org.rubypeople.rdt.webpage/htdocs/download.php
===================================================================
(Binary files differ)
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-06 15:37:01
|
Revision: 1680
http://svn.sourceforge.net/rubyeclipse/?rev=1680&view=rev
Author: cawilliams
Date: 2006-12-06 07:36:59 -0800 (Wed, 06 Dec 2006)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt/Changelog.txt
Modified: trunk/org.rubypeople.rdt/Changelog.txt
===================================================================
--- trunk/org.rubypeople.rdt/Changelog.txt 2006-12-06 15:31:27 UTC (rev 1679)
+++ trunk/org.rubypeople.rdt/Changelog.txt 2006-12-06 15:36:59 UTC (rev 1680)
@@ -8,6 +8,7 @@
* Integration with latest JRuby parser
* positioning fixes
* improved speed
+* Syntax coloring of the Merge/compare view
Release 0.8.0:
* Compatible with Eclipse 3.1 and 3.2
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-06 15:31:30
|
Revision: 1679
http://svn.sourceforge.net/rubyeclipse/?rev=1679&view=rev
Author: cawilliams
Date: 2006-12-06 07:31:27 -0800 (Wed, 06 Dec 2006)
Log Message:
-----------
a new RDT merge/compare feature (based off of Mirko's patch and the JDT's implementation). We now do coloring of syntax in the diff view for checking in/out.
Next logical step would be to create a structure view and structure diff (so we can compare high-level changes like adding/removing methods)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.ui/plugin.xml
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/EclipsePreferencesAdapter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyCompareUtilities.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewCreator.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyNode.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewer.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewerCreator.java
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2006-12-06 15:01:06 UTC (rev 1678)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2006-12-06 15:31:27 UTC (rev 1679)
@@ -50,5 +50,6 @@
org.eclipse.ui.forms,
org.rubypeople.rdt.launching,
org.eclipse.search,
- org.jruby
+ org.jruby,
+ org.eclipse.compare
Eclipse-LazyStart: true
Modified: trunk/org.rubypeople.rdt.ui/plugin.xml
===================================================================
--- trunk/org.rubypeople.rdt.ui/plugin.xml 2006-12-06 15:01:06 UTC (rev 1678)
+++ trunk/org.rubypeople.rdt.ui/plugin.xml 2006-12-06 15:31:27 UTC (rev 1679)
@@ -6,7 +6,7 @@
<extension-point id="foldingStructureProviders" name="%foldingStructureProviders" schema="schema/foldingStructureProviders.exsd"/>
<extension-point id="editorPopupExtender" name="%editorPopupExtender" schema="schema/org.rubypeople.rdt.ui.editorPopupExtender.exsd"/>
<extension-point id="rubyTemplateProvider" name="Ruby template provider" schema="schema/rubyTemplateProvider.exsd"/>
-
+
<extension
point="org.eclipse.ui.preferencePages">
<page
@@ -919,5 +919,26 @@
</description>
</fontDefinition>
</extension>
-
+
+ <extension
+ point="org.eclipse.compare.contentViewers">
+ <viewer
+ class="org.rubypeople.rdt.internal.ui.compare.RubyTextViewerCreator"
+ id="org.rubypeople.rdt.internal.ui.compare.RubyTextViewerCreator">
+ </viewer>
+ <contentTypeBinding
+ contentTypeId="org.rubypeople.rdt.core.rubySource"
+ contentViewerId="org.rubypeoplee.rdt.internal.ui.compare.RubyTextViewerCreator">
+ </contentTypeBinding>
+ </extension>
+ <extension
+ point="org.eclipse.compare.contentMergeViewers">
+ <viewer
+ class="org.rubypeople.rdt.internal.ui.compare.RubyMergeViewCreator"
+ id="org.rubypeople.rdt.internal.ui.RubyMergeViewer"/>
+ <contentTypeBinding
+ contentMergeViewerId="org.rubypeople.rdt.internal.ui.RubyMergeViewer"
+ contentTypeId="org.rubypeople.rdt.core.rubySource"/>
+ </extension>
+
</plugin>
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2006-12-06 15:01:06 UTC (rev 1678)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -3,12 +3,14 @@
import java.net.MalformedURLException;
import java.net.URL;
+import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.ImageRegistry;
import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
public class RubyPluginImages {
@@ -230,4 +232,22 @@
buffer.append(name);
return new URL(iconBaseURL, buffer.toString());
}
+
+ /*
+ * Creates an image descriptor for the given path in a bundle. The path can contain variables
+ * like $NL$.
+ * If no image could be found, <code>useMissingImageDescriptor</code> decides if either
+ * the 'missing image descriptor' is returned or <code>null</code>.
+ * Added for 3.1.1.
+ */
+ public static ImageDescriptor createImageDescriptor(Bundle bundle, IPath path, boolean useMissingImageDescriptor) {
+ URL url= FileLocator.find(bundle, path, null);
+ if (url != null) {
+ return ImageDescriptor.createFromURL(url);
+ }
+ if (useMissingImageDescriptor) {
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+ return null;
+ }
}
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,19 @@
+package org.rubypeople.rdt.internal.ui.compare;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CompareMessages extends NLS {
+ private static final String BUNDLE_NAME= "org.rubypeople.rdt.internal.ui.compare.CompareMessages";//$NON-NLS-1$
+
+ private CompareMessages() {
+ // Do not instantiate
+ }
+
+ public static String RubyNode_importDeclarations;
+ public static String RubyNode_script;
+ public static String RubyMergeViewer_title;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/CompareMessages.properties 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,19 @@
+###############################################################################
+# 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
+###############################################################################
+
+
+#
+# Title of Ruby source compare viewer
+#
+RubyMergeViewer_title= Ruby Source Compare
+
+RubyNode_script= Ruby Script
+RubyNode_importDeclarations= Import Declarations
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/EclipsePreferencesAdapter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/EclipsePreferencesAdapter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/EclipsePreferencesAdapter.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,319 @@
+/*******************************************************************************
+ * 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.compare;
+
+import org.eclipse.core.runtime.ListenerList;
+import org.eclipse.core.runtime.preferences.IEclipsePreferences;
+import org.eclipse.core.runtime.preferences.IScopeContext;
+
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Display;
+import org.osgi.service.prefs.BackingStoreException;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+
+/**
+ * Adapts an options {@link IEclipsePreferences} to {@link org.eclipse.jface.preference.IPreferenceStore}.
+ * <p>
+ * This preference store is read-only i.e. write access
+ * throws an {@link java.lang.UnsupportedOperationException}.
+ * </p>
+ *
+ * @since 3.1
+ */
+class EclipsePreferencesAdapter implements IPreferenceStore {
+
+ /**
+ * Preference change listener. Listens for events preferences
+ * fires a {@link org.eclipse.jface.util.PropertyChangeEvent}
+ * on this adapter with arguments from the received event.
+ */
+ private class PreferenceChangeListener implements IEclipsePreferences.IPreferenceChangeListener {
+
+ /**
+ * {@inheritDoc}
+ */
+ public void preferenceChange(final IEclipsePreferences.PreferenceChangeEvent event) {
+ if (Display.getCurrent() == null) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
+ }
+ });
+ } else {
+ firePropertyChangeEvent(event.getKey(), event.getOldValue(), event.getNewValue());
+ }
+ }
+ }
+
+ /** Listeners on on this adapter */
+ private ListenerList fListeners= new ListenerList(ListenerList.IDENTITY);
+
+ /** Listener on the node */
+ private IEclipsePreferences.IPreferenceChangeListener fListener= new PreferenceChangeListener();
+
+ /** wrapped node */
+ private final IScopeContext fContext;
+ private final String fQualifier;
+
+ /**
+ * Initialize with the node to wrap
+ *
+ * @param context The context to access
+ */
+ public EclipsePreferencesAdapter(IScopeContext context, String qualifier) {
+ fContext= context;
+ fQualifier= qualifier;
+ }
+
+ private IEclipsePreferences getNode() {
+ return fContext.getNode(fQualifier);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void addPropertyChangeListener(IPropertyChangeListener listener) {
+ if (fListeners.size() == 0)
+ getNode().addPreferenceChangeListener(fListener);
+ fListeners.add(listener);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void removePropertyChangeListener(IPropertyChangeListener listener) {
+ fListeners.remove(listener);
+ if (fListeners.size() == 0) {
+ getNode().removePreferenceChangeListener(fListener);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean contains(String name) {
+ return getNode().get(name, null) != null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
+ PropertyChangeEvent event= new PropertyChangeEvent(this, name, oldValue, newValue);
+ Object[] listeners= fListeners.getListeners();
+ for (int i= 0; i < listeners.length; i++)
+ ((IPropertyChangeListener) listeners[i]).propertyChange(event);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean getBoolean(String name) {
+ return getNode().getBoolean(name, BOOLEAN_DEFAULT_DEFAULT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean getDefaultBoolean(String name) {
+ return BOOLEAN_DEFAULT_DEFAULT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public double getDefaultDouble(String name) {
+ return DOUBLE_DEFAULT_DEFAULT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public float getDefaultFloat(String name) {
+ return FLOAT_DEFAULT_DEFAULT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getDefaultInt(String name) {
+ return INT_DEFAULT_DEFAULT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getDefaultLong(String name) {
+ return LONG_DEFAULT_DEFAULT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getDefaultString(String name) {
+ return STRING_DEFAULT_DEFAULT;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public double getDouble(String name) {
+ return getNode().getDouble(name, DOUBLE_DEFAULT_DEFAULT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public float getFloat(String name) {
+ return getNode().getFloat(name, FLOAT_DEFAULT_DEFAULT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public int getInt(String name) {
+ return getNode().getInt(name, INT_DEFAULT_DEFAULT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public long getLong(String name) {
+ return getNode().getLong(name, LONG_DEFAULT_DEFAULT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public String getString(String name) {
+ return getNode().get(name, STRING_DEFAULT_DEFAULT);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean isDefault(String name) {
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean needsSaving() {
+ try {
+ return getNode().keys().length > 0;
+ } catch (BackingStoreException e) {
+ // ignore
+ }
+ return true;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void putValue(String name, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefault(String name, double value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefault(String name, float value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefault(String name, int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefault(String name, long value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefault(String name, String defaultObject) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setDefault(String name, boolean value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setToDefault(String name) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setValue(String name, double value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setValue(String name, float value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setValue(String name, int value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setValue(String name, long value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setValue(String name, String value) {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setValue(String name, boolean value) {
+ throw new UnsupportedOperationException();
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyCompareUtilities.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyCompareUtilities.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyCompareUtilities.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,415 @@
+/*******************************************************************************
+ * 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.ui.compare;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IEncodedStreamContentAccessor;
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.swt.graphics.Image;
+import org.rubypeople.rdt.core.IMember;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+import org.rubypeople.rdt.ui.RubyElementLabels;
+import org.rubypeople.rdt.ui.text.RubyTextTools;
+
+class RubyCompareUtilities {
+
+ private static final char IMPORTDECLARATION= '#';
+ private static final char IMPORT_CONTAINER= '<';
+ private static final char FIELD= '^';
+ private static final char METHOD= '~';
+ private static final char SCRIPT= '{';
+ private static final char TYPE= '[';
+
+ static String getString(ResourceBundle bundle, String key, String dfltValue) {
+
+ if (bundle != null) {
+ try {
+ return bundle.getString(key);
+ } catch (MissingResourceException x) {
+ // NeedWork
+ }
+ }
+ return dfltValue;
+ }
+
+ static String getString(ResourceBundle bundle, String key) {
+ return getString(bundle, key, key);
+ }
+
+ static int getInteger(ResourceBundle bundle, String key, int dfltValue) {
+
+ if (bundle != null) {
+ try {
+ String s= bundle.getString(key);
+ if (s != null)
+ return Integer.parseInt(s);
+ } catch (NumberFormatException x) {
+ // NeedWork
+ } catch (MissingResourceException x) {
+ // NeedWork
+ }
+ }
+ return dfltValue;
+ }
+
+ static ImageDescriptor getImageDescriptor(int type) {
+ switch (type) {
+ case IRubyElement.METHOD:
+ return getImageDescriptor("obj16/compare_method.gif"); //$NON-NLS-1$
+ case IRubyElement.FIELD:
+ return getImageDescriptor("obj16/compare_field.gif"); //$NON-NLS-1$
+ case IRubyElement.IMPORT_DECLARATION:
+ return RubyPluginImages.DESC_OBJS_IMPDECL;
+ case IRubyElement.IMPORT_CONTAINER:
+ return RubyPluginImages.DESC_OBJS_IMPCONT;
+ case IRubyElement.SCRIPT:
+ return RubyPluginImages.DESC_OBJS_SCRIPT;
+ }
+ return ImageDescriptor.getMissingImageDescriptor();
+ }
+
+ static ImageDescriptor getTypeImageDescriptor(boolean isClass) {
+ if (isClass)
+ return RubyPluginImages.DESC_OBJS_CLASS;
+ return RubyPluginImages.DESC_OBJS_MODULE;
+ }
+
+ static ImageDescriptor getImageDescriptor(IMember element) {
+ int t= element.getElementType();
+ if (t == IRubyElement.TYPE) {
+ IType type= (IType) element;
+ return getTypeImageDescriptor(type.isClass());
+ }
+ return getImageDescriptor(t);
+ }
+
+ /**
+ * Returns a name for the given Ruby element that uses the same conventions
+ * as the RubyNode name of a corresponding element.
+ */
+ static String getRubyElementID(IRubyElement je) {
+
+ StringBuffer sb= new StringBuffer();
+
+ switch (je.getElementType()) {
+ case IRubyElement.SCRIPT:
+ sb.append(SCRIPT);
+ break;
+ case IRubyElement.TYPE:
+ sb.append(TYPE);
+ sb.append(je.getElementName());
+ break;
+ case IRubyElement.FIELD:
+ sb.append(FIELD);
+ sb.append(je.getElementName());
+ break;
+ case IRubyElement.METHOD:
+ sb.append(METHOD);
+ sb.append(RubyElementLabels.getElementLabel(je, RubyElementLabels.M_PARAMETER_NAMES));
+ break;
+ case IRubyElement.IMPORT_CONTAINER:
+ sb.append(IMPORT_CONTAINER);
+ break;
+ case IRubyElement.IMPORT_DECLARATION:
+ sb.append(IMPORTDECLARATION);
+ sb.append(je.getElementName());
+ break;
+ default:
+ return null;
+ }
+ return sb.toString();
+ }
+
+ /**
+ * Returns a name which identifies the given typed name.
+ * The type is encoded as a single character at the beginning of the string.
+ */
+ static String buildID(int type, String name) {
+ StringBuffer sb= new StringBuffer();
+ switch (type) {
+ case RubyNode.SCRIPT:
+ sb.append(SCRIPT);
+ break;
+ case RubyNode.CLASS:
+ case RubyNode.MODULE:
+ sb.append(TYPE);
+ sb.append(name);
+ break;
+ case RubyNode.FIELD:
+ sb.append(FIELD);
+ sb.append(name);
+ break;
+ case RubyNode.CONSTRUCTOR:
+ case RubyNode.METHOD:
+ sb.append(METHOD);
+ sb.append(name);
+ break;
+ case RubyNode.IMPORT:
+ sb.append(IMPORTDECLARATION);
+ sb.append(name);
+ break;
+ case RubyNode.IMPORT_CONTAINER:
+ sb.append(IMPORT_CONTAINER);
+ break;
+ default:
+ Assert.isTrue(false);
+ break;
+ }
+ return sb.toString();
+ }
+
+ static ImageDescriptor getImageDescriptor(String relativePath) {
+ IPath path= RubyPluginImages.ICONS_PATH.append(relativePath);
+ return RubyPluginImages.createImageDescriptor(RubyPlugin.getDefault().getBundle(), path, true);
+ }
+
+ static boolean getBoolean(CompareConfiguration cc, String key, boolean dflt) {
+ if (cc != null) {
+ Object value= cc.getProperty(key);
+ if (value instanceof Boolean)
+ return ((Boolean) value).booleanValue();
+ }
+ return dflt;
+ }
+
+ static Image getImage(IMember member) {
+ ImageDescriptor id= getImageDescriptor(member);
+ return id.createImage();
+ }
+
+ static RubyTextTools getRubyTextTools() {
+ RubyPlugin plugin= RubyPlugin.getDefault();
+ if (plugin != null)
+ return plugin.getRubyTextTools();
+ return null;
+ }
+
+ static IDocumentPartitioner createRubyPartitioner() {
+ RubyTextTools tools= getRubyTextTools();
+ if (tools != null)
+ return tools.createDocumentPartitioner();
+ return null;
+ }
+
+ static void setupDocument(IDocument document) {
+ RubyTextTools tools= getRubyTextTools();
+ if (tools != null)
+ tools.setupRubyDocumentPartitioner(document, IRubyPartitions.RUBY_PARTITIONING);
+ }
+
+ /**
+ * Reads the contents of the given input stream into a string.
+ * The function assumes that the input stream uses the platform's default encoding
+ * (<code>ResourcesPlugin.getEncoding()</code>).
+ * Returns null if an error occurred.
+ */
+ private static String readString(InputStream is, String encoding) {
+ if (is == null)
+ return null;
+ BufferedReader reader= null;
+ try {
+ StringBuffer buffer= new StringBuffer();
+ char[] part= new char[2048];
+ int read= 0;
+ reader= new BufferedReader(new InputStreamReader(is, encoding));
+
+ while ((read= reader.read(part)) != -1)
+ buffer.append(part, 0, read);
+
+ return buffer.toString();
+
+ } catch (IOException ex) {
+ // NeedWork
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ // silently ignored
+ }
+ }
+ }
+ return null;
+ }
+
+ public static String readString(IStreamContentAccessor sa) throws CoreException {
+ InputStream is= sa.getContents();
+ if (is != null) {
+ String encoding= null;
+ if (sa instanceof IEncodedStreamContentAccessor) {
+ try {
+ encoding= ((IEncodedStreamContentAccessor) sa).getCharset();
+ } catch (Exception e) {
+ }
+ }
+ if (encoding == null)
+ encoding= ResourcesPlugin.getEncoding();
+ return readString(is, encoding);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the contents of the given string as an array of bytes
+ * in the platform's default encoding.
+ */
+ static byte[] getBytes(String s, String encoding) {
+ try {
+ return s.getBytes(encoding);
+ } catch (UnsupportedEncodingException e) {
+ return s.getBytes();
+ }
+ }
+
+ /**
+ * Breaks the contents of the given input stream into an array of strings.
+ * The function assumes that the input stream uses the platform's default encoding
+ * (<code>ResourcesPlugin.getEncoding()</code>).
+ * Returns null if an error occurred.
+ */
+ static String[] readLines(InputStream is2, String encoding) {
+
+ BufferedReader reader= null;
+ try {
+ reader= new BufferedReader(new InputStreamReader(is2, encoding));
+ StringBuffer sb= new StringBuffer();
+ List list= new ArrayList();
+ while (true) {
+ int c= reader.read();
+ if (c == -1)
+ break;
+ sb.append((char)c);
+ if (c == '\r') { // single CR or a CR followed by LF
+ c= reader.read();
+ if (c == -1)
+ break;
+ sb.append((char)c);
+ if (c == '\n') {
+ list.add(sb.toString());
+ sb= new StringBuffer();
+ }
+ } else if (c == '\n') { // a single LF
+ list.add(sb.toString());
+ sb= new StringBuffer();
+ }
+ }
+ if (sb.length() > 0)
+ list.add(sb.toString());
+ return (String[]) list.toArray(new String[list.size()]);
+
+ } catch (IOException ex) {
+ return null;
+
+ } finally {
+ if (reader != null) {
+ try {
+ reader.close();
+ } catch (IOException ex) {
+ // silently ignored
+ }
+ }
+ }
+ }
+
+ /*
+ * Initialize the given Action from a ResourceBundle.
+ */
+ static void initAction(IAction a, ResourceBundle bundle, String prefix) {
+
+ String labelKey= "label"; //$NON-NLS-1$
+ String tooltipKey= "tooltip"; //$NON-NLS-1$
+ String imageKey= "image"; //$NON-NLS-1$
+ String descriptionKey= "description"; //$NON-NLS-1$
+
+ if (prefix != null && prefix.length() > 0) {
+ labelKey= prefix + labelKey;
+ tooltipKey= prefix + tooltipKey;
+ imageKey= prefix + imageKey;
+ descriptionKey= prefix + descriptionKey;
+ }
+
+ a.setText(getString(bundle, labelKey, labelKey));
+ a.setToolTipText(getString(bundle, tooltipKey, null));
+ a.setDescription(getString(bundle, descriptionKey, null));
+
+ String relPath= getString(bundle, imageKey, null);
+ if (relPath != null && relPath.trim().length() > 0) {
+
+ String dPath;
+ String ePath;
+
+ if (relPath.indexOf("/") >= 0) { //$NON-NLS-1$
+ String path= relPath.substring(1);
+ dPath= 'd' + path;
+ ePath= 'e' + path;
+ } else {
+ dPath= "dlcl16/" + relPath; //$NON-NLS-1$
+ ePath= "elcl16/" + relPath; //$NON-NLS-1$
+ }
+
+ ImageDescriptor id= RubyCompareUtilities.getImageDescriptor(dPath); // we set the disabled image first (see PR 1GDDE87)
+ if (id != null)
+ a.setDisabledImageDescriptor(id);
+ id= RubyCompareUtilities.getImageDescriptor(ePath);
+ if (id != null) {
+ a.setImageDescriptor(id);
+ a.setHoverImageDescriptor(id);
+ }
+ }
+ }
+
+ static void initToggleAction(IAction a, ResourceBundle bundle, String prefix, boolean checked) {
+
+ String tooltip= null;
+ if (checked)
+ tooltip= getString(bundle, prefix + "tooltip.checked", null); //$NON-NLS-1$
+ else
+ tooltip= getString(bundle, prefix + "tooltip.unchecked", null); //$NON-NLS-1$
+ if (tooltip == null)
+ tooltip= getString(bundle, prefix + "tooltip", null); //$NON-NLS-1$
+
+ if (tooltip != null)
+ a.setToolTipText(tooltip);
+
+ String description= null;
+ if (checked)
+ description= getString(bundle, prefix + "description.checked", null); //$NON-NLS-1$
+ else
+ description= getString(bundle, prefix + "description.unchecked", null); //$NON-NLS-1$
+ if (description == null)
+ description= getString(bundle, prefix + "description", null); //$NON-NLS-1$
+
+ if (description != null)
+ a.setDescription(description);
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewCreator.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewCreator.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewCreator.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,16 @@
+package org.rubypeople.rdt.internal.ui.compare;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+
+public class RubyMergeViewCreator implements IViewerCreator {
+
+ public Viewer createViewer(Composite parent, CompareConfiguration config) {
+ return new RubyMergeViewer(parent, SWT.NULL, config);
+ }
+
+}
+
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyMergeViewer.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,248 @@
+package org.rubypeople.rdt.internal.ui.compare;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IResourceProvider;
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.contentmergeviewer.TextMergeViewer;
+import org.eclipse.compare.structuremergeviewer.ICompareInput;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ProjectScope;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.DisposeEvent;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.editors.text.EditorsUI;
+import org.eclipse.ui.texteditor.AbstractTextEditor;
+import org.eclipse.ui.texteditor.ChainedPreferenceStore;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+import org.rubypeople.rdt.internal.ui.text.PreferencesAdapter;
+import org.rubypeople.rdt.ui.text.RubySourceViewerConfiguration;
+import org.rubypeople.rdt.ui.text.RubyTextTools;
+
+public class RubyMergeViewer extends TextMergeViewer {
+
+ private IPropertyChangeListener fPreferenceChangeListener;
+ private IPreferenceStore fPreferenceStore;
+ private boolean fUseSystemColors;
+ private RubySourceViewerConfiguration fSourceViewerConfiguration;
+ private ArrayList fSourceViewer;
+
+ public RubyMergeViewer(Composite parent, int styles, CompareConfiguration mp) {
+ super(parent, styles | SWT.LEFT_TO_RIGHT, mp);
+
+ getPreferenceStore();
+
+ fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+ if (! fUseSystemColors) {
+ RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+ setBackgroundColor(bg);
+ RGB fg= createColor(fPreferenceStore, IRubyColorConstants.RUBY_DEFAULT);
+ setForegroundColor(fg);
+ }
+ }
+
+ @Override
+ protected IDocumentPartitioner getDocumentPartitioner() {
+ return RubyPlugin.getDefault().getRubyTextTools().createDocumentPartitioner();
+ }
+
+ @Override
+ protected String getDocumentPartitioning() {
+ return IRubyPartitions.RUBY_PARTITIONING;
+ }
+
+ @Override
+ public void setInput(Object input) {
+ if (input instanceof ICompareInput) {
+ IRubyProject project= getRubyProject((ICompareInput)input);
+ if (project != null) {
+ setPreferenceStore(createChainedPreferenceStore(project));
+ if (fSourceViewer != null) {
+ Iterator iterator= fSourceViewer.iterator();
+ while (iterator.hasNext()) {
+ SourceViewer sourceViewer= (SourceViewer) iterator.next();
+ sourceViewer.unconfigure();
+ sourceViewer.configure(getSourceViewerConfiguration());
+ }
+ }
+ }
+ }
+
+ super.setInput(input);
+ }
+
+ public String getTitle() {
+ return CompareMessages.RubyMergeViewer_title;
+ }
+
+ public IRubyProject getRubyProject(ICompareInput input) {
+
+ if (input == null)
+ return null;
+
+ IResourceProvider rp= null;
+ ITypedElement te= input.getLeft();
+ if (te instanceof IResourceProvider)
+ rp= (IResourceProvider) te;
+ if (rp == null) {
+ te= input.getRight();
+ if (te instanceof IResourceProvider)
+ rp= (IResourceProvider) te;
+ }
+ if (rp == null) {
+ te= input.getAncestor();
+ if (te instanceof IResourceProvider)
+ rp= (IResourceProvider) te;
+ }
+ if (rp != null) {
+ IResource resource= rp.getResource();
+ if (resource != null) {
+ IRubyElement element= RubyCore.create(resource);
+ if (element != null)
+ return element.getRubyProject();
+ }
+ }
+ return null;
+ }
+
+ private ChainedPreferenceStore createChainedPreferenceStore(IRubyProject project) {
+ ArrayList stores= new ArrayList(4);
+ if (project != null)
+ stores.add(new EclipsePreferencesAdapter(new ProjectScope(project.getProject()), RubyCore.PLUGIN_ID));
+ stores.add(RubyPlugin.getDefault().getPreferenceStore());
+ stores.add(new PreferencesAdapter(RubyCore.getPlugin().getPluginPreferences()));
+ stores.add(EditorsUI.getPreferenceStore());
+ return new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
+ }
+
+ private RubySourceViewerConfiguration getSourceViewerConfiguration() {
+ if (fSourceViewerConfiguration == null)
+ getPreferenceStore();
+ return fSourceViewerConfiguration;
+ }
+
+ private IPreferenceStore getPreferenceStore() {
+ if (fPreferenceStore == null)
+ setPreferenceStore(createChainedPreferenceStore(null));
+ return fPreferenceStore;
+ }
+
+ private void setPreferenceStore(IPreferenceStore ps) {
+ if (fPreferenceChangeListener != null) {
+ if (fPreferenceStore != null)
+ fPreferenceStore.removePropertyChangeListener(fPreferenceChangeListener);
+ fPreferenceChangeListener= null;
+ }
+ fPreferenceStore= ps;
+ if (fPreferenceStore != null) {
+ RubyTextTools tools= RubyCompareUtilities.getRubyTextTools();
+ fSourceViewerConfiguration= new RubySourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, getDocumentPartitioning());
+ fPreferenceChangeListener= new IPropertyChangeListener() {
+ public void propertyChange(PropertyChangeEvent event) {
+ handlePropertyChange(event);
+ }
+ };
+ fPreferenceStore.addPropertyChangeListener(fPreferenceChangeListener);
+ }
+ }
+
+ private void handlePropertyChange(PropertyChangeEvent event) {
+
+ String key= event.getProperty();
+
+ if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND)) {
+
+ if (!fUseSystemColors) {
+ RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+ setBackgroundColor(bg);
+ }
+
+ } else if (key.equals(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
+
+ fUseSystemColors= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT);
+ if (fUseSystemColors) {
+ setBackgroundColor(null);
+ setForegroundColor(null);
+ } else {
+ RGB bg= createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND);
+ setBackgroundColor(bg);
+ RGB fg= createColor(fPreferenceStore, IRubyColorConstants.RUBY_DEFAULT);
+ setForegroundColor(fg);
+ }
+ } else if (key.equals(IRubyColorConstants.RUBY_DEFAULT)) {
+
+ if (!fUseSystemColors) {
+ RGB fg= createColor(fPreferenceStore, IRubyColorConstants.RUBY_DEFAULT);
+ setForegroundColor(fg);
+ }
+ }
+
+ if (fSourceViewerConfiguration != null && fSourceViewerConfiguration.affectsTextPresentation(event)) {
+ fSourceViewerConfiguration.handlePropertyChangeEvent(event);
+ invalidateTextPresentation();
+ }
+ }
+
+ /**
+ * Creates a color from the information stored in the given preference store.
+ * Returns <code>null</code> if there is no such information available.
+ */
+ private static RGB createColor(IPreferenceStore store, String key) {
+ if (!store.contains(key))
+ return null;
+ if (store.isDefault(key))
+ return PreferenceConverter.getDefaultColor(store, key);
+ return PreferenceConverter.getColor(store, key);
+ }
+
+ @Override
+ protected void configureTextViewer(TextViewer textViewer) {
+ if (textViewer instanceof SourceViewer) {
+ if (fSourceViewer == null)
+ fSourceViewer= new ArrayList();
+ fSourceViewer.add(textViewer);
+ RubyTextTools tools= RubyCompareUtilities.getRubyTextTools();
+ if (tools != null)
+ ((SourceViewer)textViewer).configure(getSourceViewerConfiguration());
+ }
+// if (textViewer instanceof SourceViewer) {
+//
+// SourceViewer sourceViewer = ((SourceViewer) textViewer);
+//
+// RubyTextTools tools = RubyPlugin.getDefault().getRubyTextTools();
+// Document doc = new Document();
+// tools.setupRubyDocumentPartitioner(doc, IRubyPartitions.RUBY_PARTITIONING);
+//
+// IPreferenceStore[] chain = { RubyPlugin.getDefault().getCombinedPreferenceStore() };
+// ChainedPreferenceStore preferenceStore = new ChainedPreferenceStore(chain);
+//
+// SimpleRubySourceViewerConfiguration viewerConfiguration = new SimpleRubySourceViewerConfiguration(tools
+// .getColorManager(), preferenceStore, null, IRubyPartitions.RUBY_PARTITIONING, true);
+// sourceViewer.configure(viewerConfiguration);
+//
+// } else {
+// super.configureTextViewer(textViewer);
+// }
+ }
+
+ protected void handleDispose(DisposeEvent event) {
+ setPreferenceStore(null);
+ fSourceViewer= null;
+ super.handleDispose(event);
+ }
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyNode.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyNode.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyNode.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,176 @@
+/*******************************************************************************
+ * 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.compare;
+
+import org.eclipse.compare.ITypedElement;
+import org.eclipse.compare.structuremergeviewer.DocumentRangeNode;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.graphics.Image;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+/**
+ * Comparable Ruby elements are represented as RubyNodes.
+ * Extends the DocumentRangeNode with method signature information.
+ */
+class RubyNode extends DocumentRangeNode implements ITypedElement {
+
+ public static final int SCRIPT= 0;
+ public static final int IMPORT_CONTAINER= 2;
+ public static final int IMPORT= 3;
+ public static final int MODULE= 4;
+ public static final int CLASS= 5;
+ public static final int FIELD= 8;
+ public static final int CONSTRUCTOR= 10;
+ public static final int METHOD= 11;
+
+ private int fInitializerCount= 1;
+ private boolean fIsEditable;
+ private RubyNode fParent;
+
+
+ /**
+ * Creates a RubyNode under the given parent.
+ * @param type the Ruby elements type. Legal values are from the range CU to METHOD of this class.
+ * @param name the name of the Ruby element
+ * @param start the starting position of the java element in the underlying document
+ * @param length the number of characters of the java element in the underlying document
+ */
+ public RubyNode(RubyNode parent, int type, String name, int start, int length) {
+ super(type, RubyCompareUtilities.buildID(type, name), parent.getDocument(), start, length);
+ fParent= parent;
+ if (parent != null) {
+ parent.addChild(this);
+ fIsEditable= parent.isEditable();
+ }
+ }
+
+ /**
+ * Creates a RubyNode for a CU. It represents the root of a
+ * RubyNode tree, so its parent is null.
+ * @param document the document which contains the Ruby element
+ * @param editable whether the document can be modified
+ */
+ public RubyNode(IDocument document, boolean editable) {
+ super(SCRIPT, RubyCompareUtilities.buildID(SCRIPT, "root"), document, 0, document.getLength()); //$NON-NLS-1$
+ fIsEditable= editable;
+ }
+
+ public String getInitializerCount() {
+ return Integer.toString(fInitializerCount++);
+ }
+
+ /**
+ * Extracts the method name from the signature.
+ * Used for smart matching.
+ */
+ public String extractMethodName() {
+ String id= getId();
+ int pos= id.indexOf('(');
+ if (pos > 0)
+ return id.substring(1, pos);
+ return id.substring(1);
+ }
+
+ /**
+ * Extracts the method's arguments name the signature.
+ * Used for smart matching.
+ */
+ public String extractArgumentList() {
+ String id= getId();
+ int pos= id.indexOf('(');
+ if (pos >= 0)
+ return id.substring(pos+1);
+ return id.substring(1);
+ }
+
+ /**
+ * Returns a name which is presented in the UI.
+ * @see ITypedElement#getName()
+ */
+ public String getName() {
+
+ switch (getTypeCode()) {
+ case IMPORT_CONTAINER:
+ return CompareMessages.RubyNode_importDeclarations;
+ case SCRIPT:
+ return CompareMessages.RubyNode_script;
+ }
+ return getId().substring(1); // we strip away the type character
+ }
+
+ /*
+ * @see ITypedElement#getType()
+ */
+ public String getType() {
+ return "java2"; //$NON-NLS-1$
+ }
+
+ /* (non Rubydoc)
+ * see IEditableContent.isEditable
+ */
+ public boolean isEditable() {
+ return fIsEditable;
+ }
+
+ /**
+ * Returns a shared image for this Ruby element.
+ *
+ * see ITypedInput.getImage
+ */
+ public Image getImage() {
+
+ ImageDescriptor id= null;
+
+ switch (getTypeCode()) {
+ case SCRIPT:
+ id= RubyCompareUtilities.getImageDescriptor(IRubyElement.SCRIPT);
+ break;
+ case IMPORT:
+ id= RubyCompareUtilities.getImageDescriptor(IRubyElement.IMPORT_DECLARATION);
+ break;
+ case IMPORT_CONTAINER:
+ id= RubyCompareUtilities.getImageDescriptor(IRubyElement.IMPORT_CONTAINER);
+ break;
+ case CLASS:
+ id= RubyCompareUtilities.getTypeImageDescriptor(true);
+ break;
+ case MODULE:
+ id= RubyCompareUtilities.getTypeImageDescriptor(false);
+ break;
+ case CONSTRUCTOR:
+ case METHOD:
+ id= RubyCompareUtilities.getImageDescriptor(IRubyElement.METHOD);
+ break;
+ case FIELD:
+ id= RubyCompareUtilities.getImageDescriptor(IRubyElement.FIELD);
+ break;
+ }
+ return RubyPlugin.getImageDescriptorRegistry().get(id);
+ }
+
+ public void setContent(byte[] content) {
+ super.setContent(content);
+ nodeChanged(this);
+ }
+
+ public ITypedElement replace(ITypedElement child, ITypedElement other) {
+ nodeChanged(this);
+ return child;
+ }
+
+ void nodeChanged(RubyNode node) {
+ if (fParent != null)
+ fParent.nodeChanged(node);
+ }
+}
+
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewer.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewer.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewer.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.ui.compare;
+
+import org.eclipse.compare.IStreamContentAccessor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+import org.rubypeople.rdt.ui.text.RubySourceViewerConfiguration;
+import org.rubypeople.rdt.ui.text.RubyTextTools;
+
+
+public class RubyTextViewer extends Viewer {
+
+ private SourceViewer fSourceViewer;
+ private Object fInput;
+
+
+ RubyTextViewer(Composite parent) {
+ fSourceViewer= new SourceViewer(parent, null, SWT.LEFT_TO_RIGHT | SWT.H_SCROLL | SWT.V_SCROLL);
+ RubyTextTools tools= RubyCompareUtilities.getRubyTextTools();
+ if (tools != null) {
+ IPreferenceStore store= RubyPlugin.getDefault().getCombinedPreferenceStore();
+ fSourceViewer.configure(new RubySourceViewerConfiguration(tools.getColorManager(), store, null, IRubyPartitions.RUBY_PARTITIONING));
+ }
+
+ fSourceViewer.setEditable(false);
+
+ String symbolicFontName= RubyMergeViewer.class.getName();
+ Font font= JFaceResources.getFont(symbolicFontName);
+ if (font != null)
+ fSourceViewer.getTextWidget().setFont(font);
+
+ }
+
+ public Control getControl() {
+ return fSourceViewer.getControl();
+ }
+
+ public void setInput(Object input) {
+ if (input instanceof IStreamContentAccessor) {
+ Document document= new Document(getString(input));
+ RubyCompareUtilities.setupDocument(document);
+ fSourceViewer.setDocument(document);
+ }
+ fInput= input;
+ }
+
+ public Object getInput() {
+ return fInput;
+ }
+
+ public ISelection getSelection() {
+ return null;
+ }
+
+ public void setSelection(ISelection s, boolean reveal) {
+ }
+
+ public void refresh() {
+ }
+
+ /**
+ * A helper method to retrieve the contents of the given object
+ * if it implements the IStreamContentAccessor interface.
+ */
+ private static String getString(Object input) {
+
+ if (input instanceof IStreamContentAccessor) {
+ IStreamContentAccessor sca= (IStreamContentAccessor) input;
+ try {
+ return RubyCompareUtilities.readString(sca);
+ } catch (CoreException ex) {
+ RubyPlugin.log(ex);
+ }
+ }
+ return ""; //$NON-NLS-1$
+ }
+}
+
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewerCreator.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewerCreator.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/compare/RubyTextViewerCreator.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * 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.compare;
+
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.jface.viewers.Viewer;
+
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.IViewerCreator;
+
+
+/**
+ * A factory object for the <code>RubyTextViewer</code>.
+ * This indirection is necessary because only objects with a default
+ * constructor can be created via an extension point
+ * (this precludes Viewers).
+ */
+public class RubyTextViewerCreator implements IViewerCreator {
+
+ public Viewer createViewer(Composite parent, CompareConfiguration mp) {
+ return new RubyTextViewer(parent);
+ }
+}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2006-12-06 15:01:06 UTC (rev 1678)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2006-12-06 15:31:27 UTC (rev 1679)
@@ -30,6 +30,7 @@
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.editors.text.EditorsUI;
import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.ITextEditor;
@@ -138,9 +139,22 @@
}
@Override
- public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
- ITextEditor editor = getEditor();
- return new IHyperlinkDetector[]{new RubyHyperLinkDetector(editor.getEditorInput())};
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ if (!fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINKS_ENABLED))
+ return null;
+
+ IHyperlinkDetector[] inheritedDetectors= super.getHyperlinkDetectors(sourceViewer);
+
+ if (fTextEditor == null)
+ return inheritedDetectors;
+
+ int inheritedDetectorsLength= inheritedDetectors != null ? inheritedDetectors.length : 0;
+ IHyperlinkDetector[] detectors= new IHyperlinkDetector[inheritedDetectorsLength + 1];
+ detectors[0]= new RubyHyperLinkDetector(fTextEditor.getEditorInput());
+ for (int i= 0; i < inheritedDetectorsLength; i++)
+ detectors[i+1]= inheritedDetectors[i];
+
+ return detectors;
}
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-06 15:01:12
|
Revision: 1678
http://svn.sourceforge.net/rubyeclipse/?rev=1678&view=rev
Author: cawilliams
Date: 2006-12-06 07:01:06 -0800 (Wed, 06 Dec 2006)
Log Message:
-----------
don't print to system err about catching syntax error, use RubyCore.log
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java 2006-12-01 05:09:13 UTC (rev 1677)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MassIndexUpdater.java 2006-12-06 15:01:06 UTC (rev 1678)
@@ -63,7 +63,7 @@
} catch (CoreException e) {
RubyCore.log(e);
} catch (SyntaxException se) {
- System.err.println("Explicit catch of SyntaxError in MassIndexUpdater (jpm)");
+ RubyCore.log("Explicit catch of SyntaxError in MassIndexUpdater (jpm)");
RubyCore.log(se);
} catch (Exception ex) {
// e.g: the parser currently throws a ClassCastExcpetion when parsing xmldecl.rb
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-01 05:09:15
|
Revision: 1677
http://svn.sourceforge.net/rubyeclipse/?rev=1677&view=rev
Author: cawilliams
Date: 2006-11-30 21:09:13 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
add code to avoid falling into an infinite loop because of recursive symlinks when traversing for ruby files
Modified Paths:
--------------
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/RubySourceFileCollectingVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java 2006-12-01 00:55:02 UTC (rev 1676)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/RubySourceFileCollectingVisitor.java 2006-12-01 05:09:13 UTC (rev 1677)
@@ -11,6 +11,8 @@
package org.rubypeople.rdt.internal.core.builder;
+import java.io.IOException;
+import java.util.HashSet;
import java.util.List;
import org.eclipse.core.resources.IFile;
@@ -18,6 +20,7 @@
import org.eclipse.core.resources.IResourceProxy;
import org.eclipse.core.resources.IResourceProxyVisitor;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
@@ -25,9 +28,11 @@
private static final String RUBY_SOURCE_CONTENT_TYPE_ID = "org.rubypeople.rdt.core.rubySource";
private final List files;
+ private HashSet<String> visitedLinks;
public RubySourceFileCollectingVisitor(List files) {
this.files = files;
+ this.visitedLinks = new HashSet<String>();
}
public boolean visit(IResourceProxy proxy) throws CoreException {
@@ -50,6 +55,18 @@
files.add(resource);
}
return false;
+ case IResource.FOLDER:
+ try { // Avoid recursive symlinks!
+ IPath path = proxy.requestResource().getLocation();
+ String unique = path.toFile().getCanonicalPath();
+ if (visitedLinks.contains(unique))
+ return false;
+ visitedLinks.add(unique);
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return false;
+ }
}
return true;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-01 00:55:03
|
Revision: 1676
http://svn.sourceforge.net/rubyeclipse/?rev=1676&view=rev
Author: cawilliams
Date: 2006-11-30 16:55:02 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt/Changelog.txt
Modified: trunk/org.rubypeople.rdt/Changelog.txt
===================================================================
--- trunk/org.rubypeople.rdt/Changelog.txt 2006-12-01 00:52:58 UTC (rev 1675)
+++ trunk/org.rubypeople.rdt/Changelog.txt 2006-12-01 00:55:02 UTC (rev 1676)
@@ -3,7 +3,8 @@
* Integration of type inferrencing work done by Jason morrison for Google Summer of Code
* Improved code completion
* Initial version of Mark occurences support
- * Preliminary Goto Declaration(F3) support
+* Preliminary Goto Declaration(F3) support
+* Preliminary hyperlink navigation in source code - similar to F3 - Go To Declaration. Hold Ctrl (or Apple key on macs) and hover over source. Click a link to be taken to it's source.
* Integration with latest JRuby parser
* positioning fixes
* improved speed
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-12-01 00:53:00
|
Revision: 1675
http://svn.sourceforge.net/rubyeclipse/?rev=1675&view=rev
Author: cawilliams
Date: 2006-11-30 16:52:58 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
remove some code duplication and use SelectionEngine to resolve the selection (now it also works for more than just Types)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java 2006-11-30 21:46:26 UTC (rev 1674)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java 2006-12-01 00:52:58 UTC (rev 1675)
@@ -1,15 +1,8 @@
package org.rubypeople.rdt.ui.text.hyperlinks;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IRegion;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.hyperlink.IHyperlink;
@@ -20,15 +13,12 @@
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
-import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IMember;
import org.rubypeople.rdt.core.IRubyElement;
-import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.ISourceRange;
-import org.rubypeople.rdt.core.IType;
-import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.internal.core.RubyType;
+import org.rubypeople.rdt.internal.codeassist.SelectionEngine;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.text.RubyWordFinder;
import org.rubypeople.rdt.ui.IWorkingCopyManager;
@@ -40,14 +30,10 @@
public class RubyHyperlink implements IHyperlink {
private IRegion fRegion;
- private final String fSymbol;
private final IEditorInput fEditorInput;
- public RubyHyperlink(IEditorInput editorInput, IRegion region,
- String symbol) {
+ public RubyHyperlink(IEditorInput editorInput, IRegion region) {
this.fEditorInput = editorInput;
- this.fSymbol = symbol;
- // fRegion = new Region(region.getOffset(), 5);
fRegion = region;
}
@@ -65,128 +51,36 @@
return null;
}
- public void open() {
- String symbol = fSymbol;
- // IProject[] rubyProjects = RubyCore.getRubyProjects();
- IProject proj = null;
- // for (int i = 0; i < rubyProjects.length; i++) {
- // IProject project = rubyProjects[i];
- // if(project.getName().equals("RubyFormatter")){
- // try {
- // project.open(null);
- // } catch (CoreException e) {
- // // TODO Auto-generated catch block
- // e.printStackTrace();
- // }
- // proj = project;
- // break;
- // }
- // }
- if (fEditorInput instanceof IFileEditorInput) {
- IFileEditorInput fileInput = (IFileEditorInput) fEditorInput;
- proj = fileInput.getFile().getProject();
- }
-
- if (proj != null) {
- try {
- proj.open(null);
- } catch (CoreException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
+ public void open() {
+ try {
+ SelectionEngine engine = new SelectionEngine();
+ IWorkingCopyManager manager = RubyPlugin.getDefault().getWorkingCopyManager();
+ IRubyScript script = manager.getWorkingCopy(fEditorInput);
+ IRubyElement[] elements = engine.select(script, fRegion.getOffset(), fRegion.getOffset() + fRegion.getLength());
+ // FIXME Check for first element which is an instanceof of IMember, don't just try to access the first element!
+ ISourceRange sourceRange = ((IMember) elements[0]).getSourceRange();
+ IFile file = null;
+ if (fEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput fileInput = (IFileEditorInput) fEditorInput;
+ file = fileInput.getFile();
}
- IRubyProject rproject = RubyCore.create(proj);
- IType type;
- try {
- type = rproject.findType(symbol);
- if (type != null) {
- IResource resource = type.getResource();
- // TODO: use getSource to do a source view hover!
- ISourceRange sourceRange = type.getSourceRange();
- IFile file = proj.getFile(resource
- .getProjectRelativePath());
- openFileAndLocation(sourceRange, file);
- } else {
- // choose a method
- // get the types in the file
- IWorkingCopyManager manager = RubyPlugin.getDefault()
- .getWorkingCopyManager();
- IRubyScript rubyscript = manager
- .getWorkingCopy(fEditorInput);
- IType[] types = rubyscript.getTypes();
-
- List theTypes = assembleTypesAroundOffset(types);
- // Look for the methods with the name fSymbol
- // Primitive: this'll take the first one it finds ->
- // proof of concept, needs refinement;
- for (Iterator iterator = theTypes.iterator(); iterator
- .hasNext();) {
- RubyType currType = (RubyType) iterator.next();
- IMethod[] methods = currType.getMethods();
- for (int i = 0; i < methods.length; i++) {
- IMethod method = methods[i];
- if (method.getElementName().equals(fSymbol)) {
- ISourceRange sourceRange = method
- .getSourceRange();
- if (fEditorInput instanceof IFileEditorInput) {
- IFileEditorInput fileInput = (IFileEditorInput) fEditorInput;
- IFile file = fileInput.getFile();
- openFileAndLocation(sourceRange, file);
- }
- break;
- }
- }
- }
- }
- } catch (RubyModelException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (PartInitException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- } catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // System.out.println("Hyperlink!!!");
-
- }
+ openFileAndLocation(sourceRange, file);
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (RubyModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
}
-
- private List assembleTypesAroundOffset(IType[] types)
- throws RubyModelException {
- List retValue = new ArrayList();
- for (int i = 0; i < types.length; i++) {
- IType currType = types[i];
- if (fRegion.getOffset() >= currType.getSourceRange()
- .getOffset()) {
- if (fRegion.getOffset() + fRegion.getLength() <= currType
- .getSourceRange().getOffset()
- + currType.getSourceRange().getLength()) {
- retValue.add(currType);
- if (currType.isModule()) {
- IRubyElement[] children = currType.getChildren();
- // ITypes newTypes =
- List newTypes = new ArrayList();
- for (int j = 0; j < children.length; j++) {
- IRubyElement element = children[j];
- if (element instanceof RubyType) {
- newTypes.add(element);
- }
- }
- retValue
- .addAll(assembleTypesAroundOffset((IType[]) newTypes
- .toArray(new IType[newTypes.size()])));
- } else {
- retValue.add(currType);
- }
- }
- }
- }
- return retValue;
- }
-
+
private void openFileAndLocation(ISourceRange sourceRange, IFile file)
throws PartInitException, CoreException {
+ if (file == null) return;
+ if (sourceRange == null) return;
IEditorPart editorPart = IDE.openEditor(PlatformUI.getWorkbench()
.getActiveWorkbenchWindow().getActivePage(), file, true);
@@ -208,20 +102,10 @@
public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
IRegion region, boolean canShowMultipleHyperlinks) {
- String symbol = "";
IRegion newRegion = region;
newRegion = RubyWordFinder.findWord(textViewer.getDocument(), region
.getOffset());
- try {
- symbol = textViewer.getDocument().get(newRegion.getOffset(),
- newRegion.getLength());
- } catch (BadLocationException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- // System.out.println("Symbol:" + symbol);
- return new IHyperlink[] { new RubyHyperlink(fEditorInput, newRegion,
- symbol) };
+ return new IHyperlink[] { new RubyHyperlink(fEditorInput, newRegion) };
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-11-30 21:46:29
|
Revision: 1674
http://svn.sourceforge.net/rubyeclipse/?rev=1674&view=rev
Author: cawilliams
Date: 2006-11-30 13:46:26 -0800 (Thu, 30 Nov 2006)
Log Message:
-----------
add murphee's patch for hyperlinks (hold down Ctrl and click on an item in source and it performs like F3 - Go to declaration).
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2006-11-29 21:08:08 UTC (rev 1673)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2006-11-30 21:46:26 UTC (rev 1674)
@@ -15,6 +15,7 @@
import org.eclipse.jface.text.contentassist.IContentAssistant;
import org.eclipse.jface.text.formatter.IContentFormatter;
import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.reconciler.IReconciler;
@@ -59,6 +60,7 @@
import org.rubypeople.rdt.internal.ui.text.ruby.RubyReconcilingStrategy;
import org.rubypeople.rdt.internal.ui.text.ruby.SingleTokenRubyCodeScanner;
import org.rubypeople.rdt.internal.ui.text.ruby.hover.RubyCodeTextHover;
+import org.rubypeople.rdt.ui.text.hyperlinks.RubyHyperLinkDetector;
public class RubySourceViewerConfiguration extends TextSourceViewerConfiguration {
@@ -134,6 +136,12 @@
return formatter;
}
+
+ @Override
+ public IHyperlinkDetector[] getHyperlinkDetectors(ISourceViewer sourceViewer) {
+ ITextEditor editor = getEditor();
+ return new IHyperlinkDetector[]{new RubyHyperLinkDetector(editor.getEditorInput())};
+ }
/**
* Determines whether the preference change encoded by the given event
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/hyperlinks/RubyHyperLinkDetector.java 2006-11-30 21:46:26 UTC (rev 1674)
@@ -0,0 +1,227 @@
+package org.rubypeople.rdt.ui.text.hyperlinks;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.hyperlink.IHyperlink;
+import org.eclipse.jface.text.hyperlink.IHyperlinkDetector;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.rubypeople.rdt.core.IMethod;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.ISourceRange;
+import org.rubypeople.rdt.core.IType;
+import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.RubyType;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.RubyWordFinder;
+import org.rubypeople.rdt.ui.IWorkingCopyManager;
+
+public class RubyHyperLinkDetector implements IHyperlinkDetector {
+
+ private final IEditorInput fEditorInput;
+
+ public class RubyHyperlink implements IHyperlink {
+
+ private IRegion fRegion;
+ private final String fSymbol;
+ private final IEditorInput fEditorInput;
+
+ public RubyHyperlink(IEditorInput editorInput, IRegion region,
+ String symbol) {
+ this.fEditorInput = editorInput;
+ this.fSymbol = symbol;
+ // fRegion = new Region(region.getOffset(), 5);
+ fRegion = region;
+ }
+
+ public IRegion getHyperlinkRegion() {
+ return fRegion;
+ }
+
+ public String getHyperlinkText() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public String getTypeLabel() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void open() {
+ String symbol = fSymbol;
+ // IProject[] rubyProjects = RubyCore.getRubyProjects();
+ IProject proj = null;
+ // for (int i = 0; i < rubyProjects.length; i++) {
+ // IProject project = rubyProjects[i];
+ // if(project.getName().equals("RubyFormatter")){
+ // try {
+ // project.open(null);
+ // } catch (CoreException e) {
+ // // TODO Auto-generated catch block
+ // e.printStackTrace();
+ // }
+ // proj = project;
+ // break;
+ // }
+ // }
+ if (fEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput fileInput = (IFileEditorInput) fEditorInput;
+ proj = fileInput.getFile().getProject();
+ }
+
+ if (proj != null) {
+ try {
+ proj.open(null);
+ } catch (CoreException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+ IRubyProject rproject = RubyCore.create(proj);
+ IType type;
+ try {
+ type = rproject.findType(symbol);
+ if (type != null) {
+ IResource resource = type.getResource();
+ // TODO: use getSource to do a source view hover!
+ ISourceRange sourceRange = type.getSourceRange();
+ IFile file = proj.getFile(resource
+ .getProjectRelativePath());
+ openFileAndLocation(sourceRange, file);
+ } else {
+ // choose a method
+ // get the types in the file
+ IWorkingCopyManager manager = RubyPlugin.getDefault()
+ .getWorkingCopyManager();
+ IRubyScript rubyscript = manager
+ .getWorkingCopy(fEditorInput);
+ IType[] types = rubyscript.getTypes();
+
+ List theTypes = assembleTypesAroundOffset(types);
+ // Look for the methods with the name fSymbol
+ // Primitive: this'll take the first one it finds ->
+ // proof of concept, needs refinement;
+ for (Iterator iterator = theTypes.iterator(); iterator
+ .hasNext();) {
+ RubyType currType = (RubyType) iterator.next();
+ IMethod[] methods = currType.getMethods();
+ for (int i = 0; i < methods.length; i++) {
+ IMethod method = methods[i];
+ if (method.getElementName().equals(fSymbol)) {
+ ISourceRange sourceRange = method
+ .getSourceRange();
+ if (fEditorInput instanceof IFileEditorInput) {
+ IFileEditorInput fileInput = (IFileEditorInput) fEditorInput;
+ IFile file = fileInput.getFile();
+ openFileAndLocation(sourceRange, file);
+ }
+ break;
+ }
+ }
+ }
+ }
+ } catch (RubyModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (PartInitException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (CoreException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // System.out.println("Hyperlink!!!");
+
+ }
+ }
+
+ private List assembleTypesAroundOffset(IType[] types)
+ throws RubyModelException {
+ List retValue = new ArrayList();
+ for (int i = 0; i < types.length; i++) {
+ IType currType = types[i];
+ if (fRegion.getOffset() >= currType.getSourceRange()
+ .getOffset()) {
+ if (fRegion.getOffset() + fRegion.getLength() <= currType
+ .getSourceRange().getOffset()
+ + currType.getSourceRange().getLength()) {
+ retValue.add(currType);
+ if (currType.isModule()) {
+ IRubyElement[] children = currType.getChildren();
+ // ITypes newTypes =
+ List newTypes = new ArrayList();
+ for (int j = 0; j < children.length; j++) {
+ IRubyElement element = children[j];
+ if (element instanceof RubyType) {
+ newTypes.add(element);
+ }
+ }
+ retValue
+ .addAll(assembleTypesAroundOffset((IType[]) newTypes
+ .toArray(new IType[newTypes.size()])));
+ } else {
+ retValue.add(currType);
+ }
+ }
+ }
+ }
+ return retValue;
+ }
+
+ private void openFileAndLocation(ISourceRange sourceRange, IFile file)
+ throws PartInitException, CoreException {
+ IEditorPart editorPart = IDE.openEditor(PlatformUI.getWorkbench()
+ .getActiveWorkbenchWindow().getActivePage(), file, true);
+
+ IMarker mark = file.createMarker(IMarker.TEXT);
+ mark.setAttribute(IMarker.CHAR_START, sourceRange.getOffset());
+ mark.setAttribute(IMarker.CHAR_END, sourceRange.getOffset()
+ + sourceRange.getLength());
+ IDE.gotoMarker(editorPart, mark);
+ mark.delete();
+ IDE.gotoMarker(editorPart, mark);
+ }
+
+ }
+
+ public RubyHyperLinkDetector(IEditorInput editorInput) {
+ this.fEditorInput = editorInput;
+
+ }
+
+ public IHyperlink[] detectHyperlinks(ITextViewer textViewer,
+ IRegion region, boolean canShowMultipleHyperlinks) {
+ String symbol = "";
+ IRegion newRegion = region;
+ newRegion = RubyWordFinder.findWord(textViewer.getDocument(), region
+ .getOffset());
+ try {
+ symbol = textViewer.getDocument().get(newRegion.getOffset(),
+ newRegion.getLength());
+ } catch (BadLocationException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ // System.out.println("Symbol:" + symbol);
+ return new IHyperlink[] { new RubyHyperlink(fEditorInput, newRegion,
+ symbol) };
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2006-11-29 21:08:09
|
Revision: 1673
http://svn.sourceforge.net/rubyeclipse/?rev=1673&view=rev
Author: cawilliams
Date: 2006-11-29 13:08:08 -0800 (Wed, 29 Nov 2006)
Log Message:
-----------
tweak how we search for constants/types declaration a little (and add todo to fix way we search for local vars!)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2006-11-29 20:53:53 UTC (rev 1672)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/codeassist/SelectionEngine.java 2006-11-29 21:08:08 UTC (rev 1673)
@@ -41,8 +41,19 @@
if (selected instanceof ConstNode) {
ConstNode constNode = (ConstNode) selected;
String name = constNode.getName();
- // TODO Find constants too (not just types)
+ // Try to find a matching constant in this script
+ IRubyElement element = findChild(name, IRubyElement.CONSTANT, script);
+ if (element != null) {
+ return new IRubyElement[] { element };
+ }
+ // Now search for a type in this script
+ element = findChild(name, IRubyElement.TYPE, script);
+ if (element != null) {
+ return new IRubyElement[] { element };
+ }
+ // TODO Search the required/loaded files first!
// TODO Search scopes outward!
+ // Now search across project for type
IRubyProject[] projects = new IRubyProject[1];
projects[0] = script.getRubyProject();
RubyElementRequestor completer = new RubyElementRequestor(projects);
@@ -50,6 +61,7 @@
return new IRubyElement[] { type };
}
if (isLocalVarRef(selected)) {
+ // TODO Try the local namespace first!
List<IRubyElement> possible = getChildrenWithName(script
.getChildren(), IRubyElement.LOCAL_VARIABLE,
getName(selected));
@@ -74,6 +86,26 @@
return new IRubyElement[0];
}
+ private IRubyElement findChild(String name, int type,
+ IParent parent) {
+ try {
+ IRubyElement[] children = parent.getChildren();
+ for (int j = 0; j < children.length; j++) {
+ IRubyElement child = children[j];
+ if (child.getElementName().equals(name) && child.isType(type))
+ return child;
+ if (child instanceof IParent) {
+ IRubyElement found = findChild(name, type, (IParent) child);
+ if (found != null) return found;
+ }
+ }
+ } catch (RubyModelException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+ return null;
+ }
+
private boolean isMethodCall(Node selected) {
return (selected instanceof VCallNode) || (selected instanceof FCallNode);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|