You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(41) |
Apr
(9) |
May
|
Jun
|
Jul
(39) |
Aug
(38) |
Sep
(135) |
Oct
(220) |
Nov
(75) |
Dec
(74) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2006 |
Jan
(44) |
Feb
(160) |
Mar
(49) |
Apr
(69) |
May
(40) |
Jun
(52) |
Jul
(47) |
Aug
(51) |
Sep
(19) |
Oct
(22) |
Nov
(36) |
Dec
(76) |
| 2007 |
Jan
(154) |
Feb
(165) |
Mar
(186) |
Apr
(143) |
May
(175) |
Jun
(133) |
Jul
(203) |
Aug
(177) |
Sep
(136) |
Oct
|
Nov
|
Dec
|
|
From: <caw...@us...> - 2007-03-16 19:44:49
|
Revision: 2197
http://svn.sourceforge.net/rubyeclipse/?rev=2197&view=rev
Author: cawilliams
Date: 2007-03-16 12:44:25 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
avoid null pointer exceptions
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java 2007-03-16 14:11:00 UTC (rev 2196)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyElementDeltaBuilder.java 2007-03-16 19:44:25 UTC (rev 2197)
@@ -233,12 +233,14 @@
if (oldInfo instanceof RubyTypeElementInfo && newInfo instanceof RubyTypeElementInfo) {
RubyTypeElementInfo oldSourceTypeInfo = (RubyTypeElementInfo) oldInfo;
RubyTypeElementInfo newSourceTypeInfo = (RubyTypeElementInfo) newInfo;
+ if (oldSourceTypeInfo.getSuperclassName() != null && newSourceTypeInfo.getSuperclassName() != null) {
if (!oldSourceTypeInfo.getSuperclassName().equals(newSourceTypeInfo
.getSuperclassName())
|| !CharOperation.equals(oldSourceTypeInfo.getIncludedModuleNames(),
newSourceTypeInfo.getIncludedModuleNames())) {
this.delta.changed(newElement, IRubyElementDelta.F_SUPER_TYPES);
}
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <mir...@us...> - 2007-03-16 14:11:02
|
Revision: 2196
http://svn.sourceforge.net/rubyeclipse/?rev=2196&view=rev
Author: mirkostocker
Date: 2007-03-16 07:11:00 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Enable horizontal/vertical/automatic layout of the TestUnit view
Modified Paths:
--------------
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.java
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.properties
trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_automatic.gif
trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_horizontal.gif
trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_vertical.gif
Added: trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_automatic.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_automatic.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_horizontal.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_horizontal.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_vertical.gif
===================================================================
(Binary files differ)
Property changes on: trunk/org.rubypeople.rdt.testunit/icons/full/elcl16/th_vertical.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.java 2007-03-16 14:05:30 UTC (rev 2195)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.java 2007-03-16 14:11:00 UTC (rev 2196)
@@ -67,6 +67,10 @@
public static String CompareResultDialog_actualLabel;
public static String CompareResultDialog_labelOK;
public static String CompareResultDialog_title;
+ public static String TestRunnerViewPart_toggle_horizontal_label;
+ public static String TestRunnerViewPart_toggle_vertical_label;
+ public static String TestRunnerViewPart_toggle_automatic_label;
+ public static String TestRunnerViewPart_layout_menu;
static {
NLS.initializeMessages(BUNDLE_NAME, TestUnitMessages.class);
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.properties 2007-03-16 14:05:30 UTC (rev 2195)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitMessages.properties 2007-03-16 14:11:00 UTC (rev 2196)
@@ -79,6 +79,7 @@
TestRunnerViewPart_title= JUnit ({0})
TestRunnerViewPart_title_no_type=JUnit
TestRunnerViewPart_configName=Rerun {0}
+TestRunnerViewPart_layout_menu=Layout
TestRunnerViewPart_toggle_vertical_label=&Vertical View Orientation
TestRunnerViewPart_toggle_horizontal_label=&Horizontal View Orientation
TestRunnerViewPart_toggle_automatic_label=&Automatic View Orientation
Modified: trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java
===================================================================
--- trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java 2007-03-16 14:05:30 UTC (rev 2195)
+++ trunk/org.rubypeople.rdt.testunit/src/org/rubypeople/rdt/internal/testunit/ui/TestUnitView.java 2007-03-16 14:11:00 UTC (rev 2196)
@@ -23,8 +23,10 @@
import org.eclipse.debug.core.ILaunchManager;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.MessageDialog;
@@ -35,9 +37,12 @@
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ViewForm;
import org.eclipse.swt.dnd.Clipboard;
+import org.eclipse.swt.events.ControlEvent;
+import org.eclipse.swt.events.ControlListener;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
@@ -68,11 +73,14 @@
static final int REFRESH_INTERVAL = 200;
public static final String ID_EXTENSION_POINT_TESTRUN_TABS = TestunitPlugin.PLUGIN_ID + "." + "internalTestRunTabs"; //$NON-NLS-1$ //$NON-NLS-2$
+
+ static enum VIEW_ORIENTATION {VERTICAL, HORIZONTAL, AUTOMATIC};
+
+ private VIEW_ORIENTATION fOrientation= VIEW_ORIENTATION.AUTOMATIC;
+
+ private VIEW_ORIENTATION fCurrentOrientation;
- //orientations
- static final int VIEW_ORIENTATION_VERTICAL = 0;
- static final int VIEW_ORIENTATION_HORIZONTAL = 1;
- static final int VIEW_ORIENTATION_AUTOMATIC = 2;
+ private ToggleOrientationAction[] fToggleOrientationActions;
final Image fStackViewIcon = TestUnitView.createImage("eview16/stackframe.gif");//$NON-NLS-1$
@@ -138,8 +146,8 @@
private CounterPanel fCounterPanel;
private TestUnitProgressBar fProgressBar;
- private int fCurrentOrientation;
private Composite fCounterComposite;
+ private Composite fParent;
private SashForm fSashForm;
private CTabFolder fTabFolder;
private FailureTrace fFailureTrace;
@@ -177,6 +185,9 @@
* it.
*/
public void createPartControl(Composite parent) {
+ fParent = parent;
+ addResizeListener(parent);
+
fClipboard = new Clipboard(parent.getDisplay());
GridLayout gridLayout = new GridLayout();
@@ -191,12 +202,43 @@
SashForm sashForm = createSashForm(parent);
sashForm.setLayoutData(new GridData(GridData.FILL_BOTH));
}
+
+ private class ToggleOrientationAction extends Action {
+ private final VIEW_ORIENTATION fActionOrientation;
+
+ public ToggleOrientationAction(TestUnitView v, VIEW_ORIENTATION orientation) {
+ super("", AS_RADIO_BUTTON); //$NON-NLS-1$
+ if (orientation == VIEW_ORIENTATION.HORIZONTAL) {
+ setText(TestUnitMessages.TestRunnerViewPart_toggle_horizontal_label);
+ setImageDescriptor(TestunitPlugin.getImageDescriptor("elcl16/th_horizontal.gif")); //$NON-NLS-1$
+ } else if (orientation == VIEW_ORIENTATION.VERTICAL) {
+ setText(TestUnitMessages.TestRunnerViewPart_toggle_vertical_label);
+ setImageDescriptor(TestunitPlugin.getImageDescriptor("elcl16/th_vertical.gif")); //$NON-NLS-1$
+ } else if (orientation == VIEW_ORIENTATION.AUTOMATIC) {
+ setText(TestUnitMessages.TestRunnerViewPart_toggle_automatic_label);
+ setImageDescriptor(TestunitPlugin.getImageDescriptor("elcl16/th_automatic.gif")); //$NON-NLS-1$
+ }
+ fActionOrientation= orientation;
+ }
+
+ public VIEW_ORIENTATION getOrientation() {
+ return fActionOrientation;
+ }
+
+ public void run() {
+ if (isChecked()) {
+ fOrientation= fActionOrientation;
+ computeOrientation();
+ }
+ }
+ }
+
private void configureToolBar() {
IActionBars actionBars = getViewSite().getActionBars();
IToolBarManager toolBar = actionBars.getToolBarManager();
- // TODO Uncomment when other actions and orientation are available
- //IMenuManager viewMenu = actionBars.getMenuManager();
+ // TODO Uncomment when other actions are available
+ IMenuManager viewMenu = actionBars.getMenuManager();
fRerunLastTestAction = new RerunLastAction();
fScrollLockAction = new ScrollLockAction(this);
//fNextAction= new ShowNextFailureAction(this);
@@ -216,10 +258,19 @@
toolBar.add(new Separator());
toolBar.add(fRerunLastTestAction);
toolBar.add(fScrollLockAction);
+
+ fToggleOrientationActions =
+ new ToggleOrientationAction[] {
+ new ToggleOrientationAction(this, VIEW_ORIENTATION.VERTICAL),
+ new ToggleOrientationAction(this, VIEW_ORIENTATION.HORIZONTAL),
+ new ToggleOrientationAction(this, VIEW_ORIENTATION.AUTOMATIC)};
- //for (int i = 0; i < fToggleOrientationActions.length; ++i)
- // viewMenu.add(fToggleOrientationActions[i]);
-
+ MenuManager layoutSubMenu= new MenuManager(TestUnitMessages.TestRunnerViewPart_layout_menu);
+ for (int i = 0; i < fToggleOrientationActions.length; ++i) {
+ layoutSubMenu.add(fToggleOrientationActions[i]);
+ }
+ viewMenu.add(layoutSubMenu);
+
fScrollLockAction.setChecked(!fAutoScroll);
actionBars.updateActionBars();
@@ -309,7 +360,7 @@
}
private void setCounterColumns(GridLayout layout) {
- if (fCurrentOrientation == VIEW_ORIENTATION_HORIZONTAL)
+ if (fCurrentOrientation == VIEW_ORIENTATION.HORIZONTAL)
layout.numColumns = 2;
else
layout.numColumns = 1;
@@ -936,6 +987,45 @@
}
}
+ private void addResizeListener(Composite parent) {
+ parent.addControlListener(new ControlListener() {
+ public void controlMoved(ControlEvent e) {
+ }
+ public void controlResized(ControlEvent e) {
+ computeOrientation();
+ }
+ });
+ }
+
+ void computeOrientation() {
+ if (fOrientation != VIEW_ORIENTATION.AUTOMATIC) {
+ fCurrentOrientation= fOrientation;
+ setOrientation(fCurrentOrientation);
+ }
+ else {
+ Point size= fParent.getSize();
+ if (size.x != 0 && size.y != 0) {
+ if (size.x > size.y)
+ setOrientation(VIEW_ORIENTATION.HORIZONTAL);
+ else
+ setOrientation(VIEW_ORIENTATION.VERTICAL);
+ }
+ }
+ }
+
+ private void setOrientation(VIEW_ORIENTATION orientation) {
+ if ((fSashForm == null) || fSashForm.isDisposed())
+ return;
+ boolean horizontal = orientation == VIEW_ORIENTATION.HORIZONTAL;
+ fSashForm.setOrientation(horizontal ? SWT.HORIZONTAL : SWT.VERTICAL);
+ for (int i = 0; i < fToggleOrientationActions.length; ++i)
+ fToggleOrientationActions[i].setChecked(fOrientation == fToggleOrientationActions[i].getOrientation());
+ fCurrentOrientation = orientation;
+ GridLayout layout= (GridLayout) fCounterComposite.getLayout();
+ setCounterColumns(layout);
+ fParent.layout();
+ }
+
public IRubyProject getLaunchedProject() {
return fTestProject;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 14:05:32
|
Revision: 2195
http://svn.sourceforge.net/rubyeclipse/?rev=2195&view=rev
Author: cawilliams
Date: 2007-03-16 07:05:30 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/UndoRubyScriptChange.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/UndoRubyScriptChange.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/UndoRubyScriptChange.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/UndoRubyScriptChange.java 2007-03-16 14:05:30 UTC (rev 2195)
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * 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.corext.refactoring.changes;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ContentStamp;
+import org.eclipse.ltk.core.refactoring.UndoTextFileChange;
+import org.eclipse.text.edits.UndoEdit;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.core.util.Messages;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+/* package */ class UndoRubyScriptChange extends UndoTextFileChange {
+
+ private IRubyScript fCUnit;
+
+ public UndoRubyScriptChange(String name, IRubyScript unit, UndoEdit undo, ContentStamp stampToRestore, int saveMode) throws CoreException {
+ super(name, getFile(unit), undo, stampToRestore, saveMode);
+ fCUnit= unit;
+ }
+
+ private static IFile getFile(IRubyScript cunit) throws CoreException {
+ IFile file= (IFile)cunit.getResource();
+ if (file == null)
+ throw new CoreException(new Status(
+ IStatus.ERROR,
+ RubyPlugin.getPluginId(),
+ IStatus.ERROR,
+ Messages.format(
+ RefactoringCoreMessages.UndoRubyScriptChange_no_resource,
+ cunit.getElementName()),
+ null)
+ );
+ return file;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getModifiedElement() {
+ return fCUnit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) throws CoreException {
+ return new UndoRubyScriptChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Change perform(IProgressMonitor pm) throws CoreException {
+ pm.beginTask("", 2); //$NON-NLS-1$
+ fCUnit.becomeWorkingCopy(null, new SubProgressMonitor(pm,1));
+ try {
+ return super.perform(new SubProgressMonitor(pm,1));
+ } finally {
+ fCUnit.discardWorkingCopy();
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 14:02:31
|
Revision: 2194
http://svn.sourceforge.net/rubyeclipse/?rev=2194&view=rev
Author: cawilliams
Date: 2007-03-16 07:02:27 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.java 2007-03-16 14:02:27 UTC (rev 2194)
@@ -0,0 +1,15 @@
+package org.rubypeople.rdt.internal.corext.refactoring.changes;
+
+import org.eclipse.osgi.util.NLS;
+
+public class RefactoringCoreMessages extends NLS {
+
+ private static final String BUNDLE_NAME = RefactoringCoreMessages.class.getName();
+
+ public static String UndoRubyScriptChange_no_resource;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, RefactoringCoreMessages.class);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RefactoringCoreMessages.properties 2007-03-16 14:02:27 UTC (rev 2194)
@@ -0,0 +1 @@
+UndoRubyScriptChange_no_resource= Ruby Script ''{0}'' does not have an underlying file.
\ No newline at end of file
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/refactoring/changes/RubyScriptChange.java 2007-03-16 14:02:27 UTC (rev 2194)
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.internal.corext.refactoring.changes;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.Assert;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.ContentStamp;
+import org.eclipse.ltk.core.refactoring.TextFileChange;
+import org.eclipse.text.edits.UndoEdit;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.corext.util.RubyModelUtil;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+
+public class RubyScriptChange extends TextFileChange {
+
+ private IRubyScript fCUnit;
+
+ /**
+ * Creates a new <code>RubyScriptChange</code>.
+ *
+ * @param name the change's name mainly used to render the change in the UI
+ * @param cunit the compilation unit this text change works on
+ */
+ public RubyScriptChange(String name, IRubyScript cunit) {
+ super(name, getFile(cunit));
+ Assert.isNotNull(cunit);
+ fCUnit= cunit;
+ setTextType("ruby"); //$NON-NLS-1$
+ }
+
+ private static IFile getFile(IRubyScript cunit) {
+ return (IFile) cunit.getResource();
+ }
+
+ /* non java-doc
+ * Method declared in IChange.
+ */
+ public Object getModifiedElement(){
+ return fCUnit;
+ }
+
+ /**
+ * Returns the compilation unit this change works on.
+ *
+ * @return the compilation unit this change works on
+ */
+ public IRubyScript getRubyScript() {
+ return fCUnit;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected IDocument acquireDocument(IProgressMonitor pm) throws CoreException {
+ pm.beginTask("", 2); //$NON-NLS-1$
+ fCUnit.becomeWorkingCopy(null, new SubProgressMonitor(pm, 1));
+ return super.acquireDocument(new SubProgressMonitor(pm, 1));
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected void releaseDocument(IDocument document, IProgressMonitor pm) throws CoreException {
+ super.releaseDocument(document, pm);
+ try {
+ fCUnit.discardWorkingCopy();
+ } finally {
+ if (!isDocumentAcquired()) {
+ if (fCUnit.isWorkingCopy())
+ RubyModelUtil.reconcile(fCUnit);
+ else
+ fCUnit.makeConsistent(pm);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ protected Change createUndoChange(UndoEdit edit, ContentStamp stampToRestore) {
+ try {
+ return new UndoRubyScriptChange(getName(), fCUnit, edit, stampToRestore, getSaveMode());
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ return null;
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object getAdapter(Class adapter) {
+ if (IRubyScript.class.equals(adapter))
+ return fCUnit;
+ return super.getAdapter(adapter);
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:49:21
|
Revision: 2193
http://svn.sourceforge.net/rubyeclipse/?rev=2193&view=rev
Author: cawilliams
Date: 2007-03-16 06:49:20 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Strings.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Strings.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Strings.java 2007-03-16 13:39:20 UTC (rev 2192)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/util/Strings.java 2007-03-16 13:49:20 UTC (rev 2193)
@@ -82,4 +82,23 @@
return ch == '\n' || ch == '\r';
}
+ /**
+ * Returns <code>true</code> if the given string only consists of
+ * white spaces according to Ruby. If the string is empty, <code>true
+ * </code> is returned.
+ *
+ * @return <code>true</code> if the string only consists of white
+ * spaces; otherwise <code>false</code> is returned
+ *
+ * @see java.lang.Character#isWhitespace(char)
+ */
+ public static boolean containsOnlyWhitespaces(String s) {
+ int size= s.length();
+ for (int i= 0; i < size; i++) {
+ if (!Character.isWhitespace(s.charAt(i)))
+ 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...> - 2007-03-16 13:39:24
|
Revision: 2192
http://svn.sourceforge.net/rubyeclipse/?rev=2192&view=rev
Author: cawilliams
Date: 2007-03-16 06:39:20 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java 2007-03-16 13:34:20 UTC (rev 2191)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IOpenable.java 2007-03-16 13:39:20 UTC (rev 2192)
@@ -170,4 +170,18 @@
* </ul>
*/
public void save(IProgressMonitor progress, boolean force) throws RubyModelException;
+
+ /**
+ * Finds and returns the recommended line separator for this element.
+ * The element's buffer is first searched and the first line separator in this buffer is returned if any.
+ * Otherwise the preference {@link org.eclipse.core.runtime.Platform#PREF_LINE_SEPARATOR}
+ * on this element's project or workspace is returned.
+ * Finally if no such preference is set, the system line separator is returned.
+ *
+ * @return the recommended line separator for this element
+ * @exception RubyModelException if this element does not exist or if an
+ * exception occurs while accessing its corresponding resource.
+ * @since 0.9.0
+ */
+ public String findRecommendedLineSeparator() throws RubyModelException;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java 2007-03-16 13:34:20 UTC (rev 2191)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/Openable.java 2007-03-16 13:39:20 UTC (rev 2192)
@@ -25,6 +25,7 @@
import org.rubypeople.rdt.core.WorkingCopyOwner;
import org.rubypeople.rdt.internal.codeassist.SelectionEngine;
import org.rubypeople.rdt.internal.core.buffer.BufferManager;
+import org.rubypeople.rdt.internal.core.util.Util;
/**
* @author cawilliams
@@ -379,4 +380,10 @@
SelectionEngine engine = new SelectionEngine();
return engine.select(cu, offset, offset + length - 1);
}
+
+ public String findRecommendedLineSeparator() throws RubyModelException {
+ IBuffer buffer = getBuffer();
+ String source = buffer == null ? null : buffer.getContents();
+ return Util.getLineSeparator(source, getRubyProject());
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java 2007-03-16 13:34:20 UTC (rev 2191)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/corext/codemanipulation/StubUtility.java 2007-03-16 13:39:20 UTC (rev 2192)
@@ -5,7 +5,10 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.preferences.IScopeContext;
import org.eclipse.core.runtime.preferences.InstanceScope;
+import org.rubypeople.rdt.core.IOpenable;
+import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.RubyModelException;
public class StubUtility {
@@ -45,4 +48,21 @@
String platformDefault= System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
return Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, platformDefault, scopeContext);
}
+
+ /**
+ * Examines a string and returns the first line delimiter found.
+ */
+ public static String getLineDelimiterUsed(IRubyElement elem) {
+ while (elem != null && !(elem instanceof IOpenable)) {
+ elem= elem.getParent();
+ }
+ if (elem != null) {
+ try {
+ return ((IOpenable) elem).findRecommendedLineSeparator();
+ } catch (RubyModelException exception) {
+ // Use project setting
+ }
+ }
+ return getProjectLineDelimiter(null);
+ }
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-03-16 13:34:20 UTC (rev 2191)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/EditorUtility.java 2007-03-16 13:39:20 UTC (rev 2192)
@@ -262,4 +262,27 @@
return rProject;
}
+ /**
+ * Tests if a CU is currently shown in an editor
+ * @return the IEditorPart if shown, null if element is not open in an editor
+ */
+ public static IEditorPart isOpenInEditor(Object inputElement) {
+ IEditorInput input= null;
+
+ try {
+ input= getEditorInput(inputElement);
+ } catch (RubyModelException x) {
+ RubyPlugin.log(x.getStatus());
+ }
+
+ if (input != null) {
+ IWorkbenchPage p= RubyPlugin.getActivePage();
+ if (p != null) {
+ return p.findEditor(input);
+ }
+ }
+
+ return null;
+ }
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:34:22
|
Revision: 2191
http://svn.sourceforge.net/rubyeclipse/?rev=2191&view=rev
Author: cawilliams
Date: 2007-03-16 06:34:20 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
peg to a newer revision
Modified Paths:
--------------
trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties
Modified: trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties
===================================================================
--- trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties 2007-03-16 13:26:35 UTC (rev 2190)
+++ trunk/org.rubypeople.rdt.pluginbuilder/releases/0.9.0RC1.properties 2007-03-16 13:34:20 UTC (rev 2191)
@@ -2,6 +2,6 @@
#Mon Mar 05 11:38:44 EST 2007
buildType=S
version=0.9.0
-version.qualifier=200703121154
-fetchTag=2136
+version.qualifier=200703160933
+fetchTag=2190
buildTypePresentation=RC1
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:26:36
|
Revision: 2190
http://svn.sourceforge.net/rubyeclipse/?rev=2190&view=rev
Author: cawilliams
Date: 2007-03-16 06:26:35 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
apply marcin naglik's patch for Ticket #239 (Evaluation Expressions settings not persisted)
Modified Paths:
--------------
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpression.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpressionReaderWriter.java
trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EvaluationExpressionsPreferencePage.java
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpression.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpression.java 2007-03-16 13:23:28 UTC (rev 2189)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpression.java 2007-03-16 13:26:35 UTC (rev 2190)
@@ -17,11 +17,13 @@
private String name ;
private String description;
private String expression;
-
- public EvaluationExpression(String name, String description, String expression) {
+ private boolean enabled;
+
+ public EvaluationExpression(String name, String description, String expression, boolean enabled) {
this.name = name ;
this.description = description ;
this.expression = expression ;
+ this.enabled = enabled ;
}
public String getDescription() {
return description;
@@ -45,13 +47,17 @@
public String substitute(String value) {
return this.expression.replaceAll(VARIABLE_TOKEN, value) ;
}
-
- public boolean hasVariable() {
+ public boolean isEnabled() {
+ return enabled;
+ }
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+ public boolean hasVariable() {
return this.expression.indexOf(VARIABLE_TOKEN) != -1 ;
}
public Object clone() throws CloneNotSupportedException {
- return new EvaluationExpression(this.getName(), this.getDescription(), this.getExpression()) ;
+ return new EvaluationExpression(this.getName(), this.getDescription(), this.getExpression(), this.enabled) ;
}
-
}
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpressionReaderWriter.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpressionReaderWriter.java 2007-03-16 13:23:28 UTC (rev 2189)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/evaluation/EvaluationExpressionReaderWriter.java 2007-03-16 13:26:35 UTC (rev 2190)
@@ -68,6 +68,7 @@
private static final String TEMPLATE_ELEMENT = "expression"; //$NON-NLS-1$
private static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
private static final String DESCRIPTION_ATTRIBUTE = "description"; //$NON-NLS-1$
+ private static final String ENABLED_ATTRIBUTE = "enabled"; //$NON-NLS-1$
/**
* Create a new instance.
@@ -134,13 +135,15 @@
String description = getStringValue(attributes, DESCRIPTION_ATTRIBUTE, ""); //$NON-NLS-1$
description = translateString(description, bundle);
+ String enabled = getStringValue(attributes, ENABLED_ATTRIBUTE, "false"); //$NON-NLS-1$
+
StringBuffer buffer = new StringBuffer();
NodeList children = node.getChildNodes();
for (int j = 0; j != children.getLength(); j++) {
String value = children.item(j).getNodeValue();
if (value != null) buffer.append(value);
}
- expressions.add(new EvaluationExpression(name, description, buffer.toString()));
+ expressions.add(new EvaluationExpression(name, description, buffer.toString(), new Boolean(enabled)));
}
return (EvaluationExpression[]) expressions.toArray(new EvaluationExpression[expressions.size()]);
@@ -221,6 +224,10 @@
description.setValue(evaluationExpression.getDescription());
attributes.setNamedItem(description);
+ Attr enabled = document.createAttribute(ENABLED_ATTRIBUTE);
+ enabled.setValue(String.valueOf(evaluationExpression.isEnabled()));
+ attributes.setNamedItem(enabled);
+
Text pattern = document.createTextNode(evaluationExpression.getExpression());
node.appendChild(pattern);
Modified: trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EvaluationExpressionsPreferencePage.java
===================================================================
--- trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EvaluationExpressionsPreferencePage.java 2007-03-16 13:23:28 UTC (rev 2189)
+++ trunk/org.rubypeople.rdt.debug.ui/src/org/rubypeople/rdt/internal/debug/ui/preferences/EvaluationExpressionsPreferencePage.java 2007-03-16 13:26:35 UTC (rev 2190)
@@ -41,7 +41,10 @@
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.PreferencePage;
import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter;
+import org.eclipse.jface.viewers.CheckStateChangedEvent;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.ICheckStateListener;
import org.eclipse.jface.viewers.IDoubleClickListener;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredContentProvider;
@@ -51,7 +54,6 @@
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
@@ -203,7 +205,7 @@
}
- private TableViewer fTableViewer;
+ private CheckboxTableViewer fTableViewer;
/* buttons */
private Button fAddButton;
@@ -267,7 +269,7 @@
TableColumn column2 = new TableColumn(table, SWT.NONE);
column2.setText(RdtDebugUiMessages.EvaluationExpressionsPreferencePage_column_description);
- fTableViewer = new TableViewer(table);
+ fTableViewer = new CheckboxTableViewer(table);
fTableViewer.setLabelProvider(new EvaluationExpressionLabelProvider());
fTableViewer.setContentProvider(new EvaluationExpressionContentProvider());
@@ -285,6 +287,13 @@
}
});
+ fTableViewer.addCheckStateListener(new ICheckStateListener(){
+
+ public void checkStateChanged(CheckStateChangedEvent event) {
+ ((EvaluationExpression) event.getElement()).setEnabled(event.getChecked());
+ }
+ });
+
Composite buttons = new Composite(innerParent, SWT.NONE);
buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
layout = new GridLayout();
@@ -345,7 +354,7 @@
});
fTableViewer.setInput(fModel);
-
+ setEnabledExpresions(fTableViewer);
updateButtons();
configureTableResizing(innerParent, buttons, table, column1, column2);
@@ -354,6 +363,18 @@
}
/**
+ * Sets the list checkboxes to proper state
+ *
+ * @param viewer checkbox viewer
+ */
+ private void setEnabledExpresions(CheckboxTableViewer viewer) {
+ for(Object o : fModel.getExpressionsAsArray()) {
+ EvaluationExpression expr = (EvaluationExpression)o;
+ viewer.setChecked(o, expr.isEnabled());
+ }
+ }
+
+ /**
* Creates a separator between buttons
*
* @param parent
@@ -438,7 +459,7 @@
private void add() {
- EvaluationExpression evalExpression = new EvaluationExpression("", "", "");
+ EvaluationExpression evalExpression = new EvaluationExpression("", "", "", false);
String title = RdtDebugUiMessages.EditEvaluationExpressionDialog_add;
Dialog dialog = new EditEvaluationExpressionDialog(getShell(), title, evalExpression);
if (dialog.open() == Window.OK) {
@@ -512,7 +533,7 @@
File file = new File(path);
if (file.isHidden()) {
- String title = RdtDebugUiMessages.EvaluationExpressionsPreferencePage_export_error_title;
+ String title = RdtDebugUiMessages.EvaluationExpressionsPreferencePage_export_error_title;
String message = RdtDebugUiMessages.getFormattedString(RdtDebugUiMessages.EvaluationExpressionsPreferencePage_export_error_hidden, file.getAbsolutePath());
MessageDialog.openError(getShell(), title, message);
return;
@@ -582,7 +603,7 @@
return super.performCancel();
}
- protected TableViewer getTableViewer() {
+ protected CheckboxTableViewer getTableViewer() {
return fTableViewer;
}
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:23:32
|
Revision: 2189
http://svn.sourceforge.net/rubyeclipse/?rev=2189&view=rev
Author: cawilliams
Date: 2007-03-16 06:23:28 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
implement some of the quick fix infrastructure
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.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/text/correction/AssistContext.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ChangeCorrectionProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionCommandHandler.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ICommandAccess.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/IStatusLineProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/MarkerResolutionProposal.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionAssistant.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/ruby/IQuickAssistProcessor.java
Modified: trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-03-16 13:21:44 UTC (rev 2188)
+++ trunk/org.rubypeople.rdt.ui/META-INF/MANIFEST.MF 2007-03-16 13:23:28 UTC (rev 2189)
@@ -55,5 +55,6 @@
org.eclipse.search,
org.jruby,
org.eclipse.compare,
- org.eclipse.core.expressions
+ org.eclipse.core.expressions,
+ org.eclipse.ltk.core.refactoring
Eclipse-LazyStart: true
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 2007-03-16 13:21:44 UTC (rev 2188)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyPluginImages.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -133,9 +133,10 @@
public static final ImageDescriptor DESC_MISC_PRIVATE= createManagedFromKey(T_OBJ, IMG_MISC_PRIVATE);
public static final ImageDescriptor DESC_OBJS_UNKNOWN= createManagedFromKey(T_OBJ, IMG_OBJS_UNKNOWN);
-
+ public static final String IMG_CORRECTION_CHANGE= NAME_PREFIX + "correction_change.gif"; //$NON-NLS-1$
static {
+ createManagedFromKey(T_OBJ, IMG_CORRECTION_CHANGE);
createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_ERROR);
createManagedFromKey(T_OBJ, IMG_OBJS_FIXABLE_PROBLEM);
createManagedFromKey(T_OBJ, IMG_OBJS_ERROR);
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java 2007-03-16 13:21:44 UTC (rev 2188)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyAbstractEditor.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -11,6 +11,7 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
@@ -94,6 +95,8 @@
public abstract class RubyAbstractEditor extends TextEditor {
+ private static final boolean CODE_ASSIST_DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.rubypeople.rdt.ui/debug/ResultCollector")); //$NON-NLS-1$//$NON-NLS-2$
+
protected RubyTextTools textTools;
private ISourceReference reference;
@@ -1092,7 +1095,47 @@
return false;
return super.requestWidgetToken(requester, priority);
}
+
+ /*
+ * @see ITextOperationTarget#doOperation(int)
+ */
+ public void doOperation(int operation) {
+ if (getTextWidget() == null)
+ return;
+
+ switch (operation) {
+ case CONTENTASSIST_PROPOSALS:
+ long time= CODE_ASSIST_DEBUG ? System.currentTimeMillis() : 0;
+ String msg= fContentAssistant.showPossibleCompletions();
+ if (CODE_ASSIST_DEBUG) {
+ long delta= System.currentTimeMillis() - time;
+ System.err.println("Code Assist (total): " + delta); //$NON-NLS-1$
+ }
+ setStatusLineErrorMessage(msg);
+ return;
+ case QUICK_ASSIST:
+ /*
+ * XXX: We can get rid of this once the SourceViewer has a way to update the status line
+ * https://bugs.eclipse.org/bugs/show_bug.cgi?id=133787
+ */
+ msg= fQuickAssistAssistant.showPossibleQuickAssists();
+ setStatusLineErrorMessage(msg);
+ return;
+ case UNDO:
+ fIgnoreTextConverters= true;
+ super.doOperation(operation);
+ fIgnoreTextConverters= false;
+ return;
+ case REDO:
+ fIgnoreTextConverters= true;
+ super.doOperation(operation);
+ fIgnoreTextConverters= false;
+ return;
+ }
+
+ super.doOperation(operation);
+ }
}
/**
* Internal activation listener.
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java 2007-03-16 13:21:44 UTC (rev 2188)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -8,6 +8,7 @@
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -22,6 +23,7 @@
protected RetargetTextEditorAction contentAssistProposal;
private RetargetTextEditorAction fGotoMatchingBracket;
+ private RetargetTextEditorAction fQuickAssistAction;
public RubyEditorActionContributor() {
super();
@@ -32,6 +34,9 @@
fGotoMatchingBracket = new RetargetTextEditorAction(b, "GotoMatchingBracket."); //$NON-NLS-1$
fGotoMatchingBracket
.setActionDefinitionId(IRubyEditorActionDefinitionIds.GOTO_MATCHING_BRACKET);
+
+ fQuickAssistAction= new RetargetTextEditorAction(RubyEditorMessages.getBundleForConstructedKeys(), "CorrectionAssistProposal."); //$NON-NLS-1$
+ fQuickAssistAction.setActionDefinitionId(ITextEditorActionDefinitionIds.QUICK_ASSIST);
}
@@ -40,6 +45,7 @@
if (editMenu != null) {
editMenu.add(new Separator());
editMenu.add(contentAssistProposal);
+ editMenu.add(fQuickAssistAction);
}
IMenuManager gotoMenu= menuManager.findMenuUsingPath("navigate/goTo"); //$NON-NLS-1$
@@ -47,6 +53,8 @@
gotoMenu.add(new Separator("additions2")); //$NON-NLS-1$
gotoMenu.appendToGroup("additions2", fGotoMatchingBracket); //$NON-NLS-1$
}
+
+
}
public void setActiveEditor(IEditorPart part) {
@@ -58,6 +66,7 @@
contentAssistProposal.setAction(getAction(textEditor, "ContentAssistProposal"));
fGotoMatchingBracket.setAction(getAction(textEditor,
GotoMatchingBracketAction.GOTO_MATCHING_BRACKET));
+ fQuickAssistAction.setAction(getAction(textEditor, ITextEditorActionConstants.QUICK_ASSIST));
if (part instanceof RubyEditor) {
@@ -84,5 +93,9 @@
actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION,
action);
actionBars.setGlobalActionHandler(ITextEditorActionConstants.PREVIOUS, action);
+
+
+ actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
+ actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
}
}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/AssistContext.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/AssistContext.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/AssistContext.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.core.RubyModelException;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.core.util.DOMFinder;
+import org.rubypeople.rdt.internal.ti.util.OffsetNodeLocator;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
+
+/**
+ */
+public class AssistContext implements IInvocationContext {
+
+ private IRubyScript fRubyScript;
+ private int fOffset;
+ private int fLength;
+
+ private RootNode fASTRoot;
+
+ /*
+ * Constructor for CorrectionContext.
+ */
+ public AssistContext(IRubyScript cu, int offset, int length) {
+ fRubyScript= cu;
+ fOffset= offset;
+ fLength= length;
+
+ fASTRoot= null;
+ }
+
+ /**
+ * Returns the compilation unit.
+ * @return Returns a IRubyScript
+ */
+ public IRubyScript getRubyScript() {
+ return fRubyScript;
+ }
+
+ /**
+ * Returns the length.
+ * @return int
+ */
+ public int getSelectionLength() {
+ return fLength;
+ }
+
+ /**
+ * Returns the offset.
+ * @return int
+ */
+ public int getSelectionOffset() {
+ return fOffset;
+ }
+
+ public RootNode getASTRoot() {
+ if (fASTRoot == null) {
+ try {
+ RubyParser parser = new RubyParser();
+ fASTRoot= (RootNode) parser.parse(fRubyScript.getSource());
+ } catch (RubyModelException e) {
+ RubyPlugin.log(e);
+ }
+ }
+ return fASTRoot;
+ }
+
+
+ /**
+ * @param root The ASTRoot to set.
+ */
+ public void setASTRoot(RootNode root) {
+ fASTRoot= root;
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.jdt.ui.text.java.IInvocationContext#getCoveringNode()
+ */
+ public Node getCoveringNode() {
+ return OffsetNodeLocator.Instance().getNodeAtOffset(getASTRoot(), fOffset);
+ }
+
+ /*(non-Javadoc)
+ * @see org.eclipse.jdt.ui.text.java.IInvocationContext#getCoveredNode()
+ */
+ public Node getCoveredNode() {
+ // FIXME Figure out what the difference is between these two!
+ return getCoveringNode();
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ChangeCorrectionProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ChangeCorrectionProposal.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ChangeCorrectionProposal.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,261 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRewriteTarget;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.link.LinkedModeModel;
+import org.eclipse.ltk.core.refactoring.Change;
+import org.eclipse.ltk.core.refactoring.NullChange;
+import org.eclipse.ltk.core.refactoring.RefactoringStatus;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IEditorPart;
+import org.rubypeople.rdt.internal.core.util.Messages;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.util.ExceptionHandler;
+import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
+
+/**
+ * Implementation of a Ruby completion proposal to be used for quick fix and quick assist
+ * proposals that invoke a {@link Change}. The proposal offers a proposal information but no context
+ * information.
+ *
+ * @since 3.2
+ */
+public class ChangeCorrectionProposal implements IRubyCompletionProposal, ICommandAccess {
+
+ private Change fChange;
+ private String fName;
+ private int fRelevance;
+ private Image fImage;
+ private String fCommandId;
+
+ /**
+ * Constructs a change correction proposal.
+ *
+ * @param name The name that is displayed in the proposal selection dialog.
+ * @param change The change that is executed when the proposal is applied or <code>null</code>
+ * if the change will be created by implementors of {@link #createChange()}.
+ * @param relevance The relevance of this proposal.
+ * @param image The image that is displayed for this proposal or <code>null</code> if no
+ * image is desired.
+ */
+ public ChangeCorrectionProposal(String name, Change change, int relevance, Image image) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
+ }
+ fName= name;
+ fChange= change;
+ fRelevance= relevance;
+ fImage= image;
+ fCommandId= null;
+ }
+
+ /*
+ * @see ICompletionProposal#apply(IDocument)
+ */
+ public void apply(IDocument document) {
+ try {
+ performChange(RubyPlugin.getActivePage().getActiveEditor(), document);
+ } catch (CoreException e) {
+ ExceptionHandler.handle(e, CorrectionMessages.ChangeCorrectionProposal_error_title, CorrectionMessages.ChangeCorrectionProposal_error_message);
+ }
+ }
+
+ /**
+ * Performs the change associated with this proposal.
+ *
+ * @param activeEditor The editor currently active or <code>null</code> if no
+ * editor is active.
+ * @param document The document of the editor currently active or <code>null</code> if
+ * no editor is visible.
+ * @throws CoreException Thrown when the invocation of the change failed.
+ */
+ protected void performChange(IEditorPart activeEditor, IDocument document) throws CoreException {
+ Change change= null;
+ IRewriteTarget rewriteTarget= null;
+ try {
+ change= getChange();
+ if (change != null) {
+ if (document != null) {
+ LinkedModeModel.closeAllModels(document);
+ }
+ if (activeEditor != null) {
+ rewriteTarget= (IRewriteTarget) activeEditor.getAdapter(IRewriteTarget.class);
+ if (rewriteTarget != null) {
+ rewriteTarget.beginCompoundChange();
+ }
+ }
+
+ change.initializeValidationData(new NullProgressMonitor());
+ RefactoringStatus valid= change.isValid(new NullProgressMonitor());
+ if (valid.hasFatalError()) {
+ IStatus status= new Status(IStatus.ERROR, RubyPlugin.getPluginId(), IStatus.ERROR,
+ valid.getMessageMatchingSeverity(RefactoringStatus.FATAL), null);
+ throw new CoreException(status);
+ } else {
+ change.perform(new NullProgressMonitor());
+ }
+ }
+ } finally {
+ if (rewriteTarget != null) {
+ rewriteTarget.endCompoundChange();
+ }
+
+ if (change != null) {
+ change.dispose();
+ }
+ }
+ }
+
+ /*
+ * @see ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ StringBuffer buf= new StringBuffer();
+ buf.append("<p>"); //$NON-NLS-1$
+ try {
+ Change change= getChange();
+ if (change != null) {
+ String name= change.getName();
+ if (name.length() == 0) {
+ return null;
+ }
+ buf.append(name);
+ } else {
+ return null;
+ }
+ } catch (CoreException e) {
+ buf.append("Unexpected error when accessing this proposal:<p><pre>"); //$NON-NLS-1$
+ buf.append(e.getLocalizedMessage());
+ buf.append("</pre>"); //$NON-NLS-1$
+ }
+ buf.append("</p>"); //$NON-NLS-1$
+ return buf.toString();
+ }
+
+ /*
+ * @see ICompletionProposal#getContextInformation()
+ */
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+ /*
+ * @see ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ String shortCutString= CorrectionCommandHandler.getShortCutString(getCommandId());
+ if (shortCutString != null) {
+ return Messages.format(CorrectionMessages.ChangeCorrectionProposal_name_with_shortcut, new String[] { fName, shortCutString });
+ }
+ return fName;
+ }
+
+ /*
+ * @see ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ return fImage;
+ }
+
+ /*
+ * @see ICompletionProposal#getSelection(IDocument)
+ */
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+ /**
+ * Sets the proposal's image or <code>null</code> if no image is desired.
+ *
+ * @param image the desired image.
+ */
+ public void setImage(Image image) {
+ fImage= image;
+ }
+
+ /**
+ * Returns the change that will be executed when the proposal is applied.
+ *
+ * @return returns the change for this proposal.
+ */
+ public final Change getChange() throws CoreException {
+ if (fChange == null) {
+ fChange= createChange();
+ }
+ return fChange;
+ }
+
+ /**
+ * Creates the text change for this proposal.
+ * This method is only called once and only when no text change has been passed in
+ * {@link #ChangeCorrectionProposal(String, Change, int, Image)}.
+ *
+ * @return returns the created change.
+ * @throws CoreException thrown if the creation of the change failed.
+ */
+ protected Change createChange() throws CoreException {
+ return new NullChange();
+ }
+
+ /**
+ * Sets the display name.
+ *
+ * @param name the name to set
+ */
+ public void setDisplayName(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Name must not be null"); //$NON-NLS-1$
+ }
+ fName= name;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.ui.text.java.IRubyCompletionProposal#getRelevance()
+ */
+ public int getRelevance() {
+ return fRelevance;
+ }
+
+ /**
+ * Sets the relevance.
+ * @param relevance the relevance to set
+ */
+ public void setRelevance(int relevance) {
+ fRelevance= relevance;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IShortcutProposal#getProposalId()
+ */
+ public String getCommandId() {
+ return fCommandId;
+ }
+
+ /**
+ * Set the proposal id to allow assigning a shortcut to the correction proposal.
+ *
+ * @param commandId The proposal id for this proposal or <code>null</code> if no command
+ * should be assigned to this proposal.
+ */
+ public void setCommandId(String commandId) {
+ fCommandId= commandId;
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionCommandHandler.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionCommandHandler.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionCommandHandler.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,160 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
+
+import org.eclipse.core.commands.AbstractHandler;
+import org.eclipse.core.commands.ExecutionEvent;
+import org.eclipse.core.commands.ExecutionException;
+import org.eclipse.jface.bindings.TriggerSequence;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
+import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.keys.IBindingService;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyEditor;
+import org.rubypeople.rdt.ui.RubyUI;
+import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
+
+
+/**
+ * Handler to be used to run a quick fix or assist by keyboard shortcut
+ */
+public class CorrectionCommandHandler extends AbstractHandler {
+
+ private final ITextEditor fEditor;
+ private final String fId;
+ private final boolean fIsAssist;
+
+ public CorrectionCommandHandler(ITextEditor editor, String id, boolean isAssist) {
+ fEditor= editor;
+ fId= id;
+ fIsAssist= isAssist;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.core.commands.IHandler#execute(org.eclipse.core.commands.ExecutionEvent)
+ */
+ public Object execute(ExecutionEvent event) throws ExecutionException {
+ ISelection selection= fEditor.getSelectionProvider().getSelection();
+ IRubyScript cu= RubyUI.getWorkingCopyManager().getWorkingCopy(fEditor.getEditorInput());
+ IAnnotationModel model= RubyUI.getDocumentProvider().getAnnotationModel(fEditor.getEditorInput());
+ if (selection instanceof ITextSelection && cu != null && model != null) {
+ ICompletionProposal proposal= findCorrection(fId, fIsAssist, (ITextSelection) selection, cu, model);
+ if (proposal != null) {
+ invokeProposal(proposal, ((ITextSelection) selection).getOffset());
+ }
+ }
+ return null;
+ }
+
+ private ICompletionProposal findCorrection(String id, boolean isAssist, ITextSelection selection, IRubyScript cu, IAnnotationModel model) {
+ AssistContext context= new AssistContext(cu, selection.getOffset(), selection.getLength());
+ Collection proposals= new ArrayList(10);
+ if (isAssist) {
+// if (id.equals(LinkedNamesAssistProposal.ASSIST_ID)) {
+// return getLocalRenameProposal(context); // shortcut for local rename
+// }
+ RubyCorrectionProcessor.collectAssists(context, new ProblemLocation[0], proposals);
+ } else {
+ try {
+ boolean goToClosest= selection.getLength() == 0;
+ Annotation[] annotations= getAnnotations(selection.getOffset(), goToClosest);
+ RubyCorrectionProcessor.collectProposals(context, model, annotations, true, false, proposals);
+ } catch (BadLocationException e) {
+ return null;
+ }
+ }
+ for (Iterator iter= proposals.iterator(); iter.hasNext();) {
+ Object curr= iter.next();
+ if (curr instanceof ICommandAccess) {
+ if (id.equals(((ICommandAccess) curr).getCommandId())) {
+ return (ICompletionProposal) curr;
+ }
+ }
+ }
+ return null;
+ }
+
+ private Annotation[] getAnnotations(int offset, boolean goToClosest) throws BadLocationException {
+ ArrayList resultingAnnotations= new ArrayList();
+ RubyCorrectionAssistant.collectQuickFixableAnnotations(fEditor, offset, goToClosest, resultingAnnotations);
+ return (Annotation[]) resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+ }
+
+ private ICompletionProposal getLocalRenameProposal(IInvocationContext context) {
+ Node node= context.getCoveringNode();
+// if (node instanceof SimpleName) { FIXME What do we do here?
+// return new LinkedNamesAssistProposal(context.getRubyScript(), (SimpleName) node);
+// }
+ return null;
+ }
+
+ private ITextViewer getTextViewer() {
+ if (fEditor instanceof RubyEditor) {
+ return ((RubyEditor) fEditor).getViewer();
+ }
+ return null;
+ }
+
+ private IDocument getDocument() {
+ return RubyUI.getDocumentProvider().getDocument(fEditor.getEditorInput());
+ }
+
+
+ private void invokeProposal(ICompletionProposal proposal, int offset) {
+ if (proposal instanceof ICompletionProposalExtension2) {
+ ITextViewer viewer= getTextViewer();
+ if (viewer != null) {
+ ((ICompletionProposalExtension2) proposal).apply(viewer, (char) 0, 0, offset);
+ return;
+ }
+ } else if (proposal instanceof ICompletionProposalExtension) {
+ IDocument document= getDocument();
+ if (document != null) {
+ ((ICompletionProposalExtension) proposal).apply(document, (char) 0, offset);
+ return;
+ }
+ }
+ IDocument document= getDocument();
+ if (document != null) {
+ proposal.apply(document);
+ }
+ }
+
+ public static String getShortCutString(String proposalId) {
+ if (proposalId != null) {
+ IBindingService bindingService= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class);
+ if (bindingService != null) {
+ TriggerSequence[] activeBindingsFor= bindingService.getActiveBindingsFor(proposalId);
+ if (activeBindingsFor.length > 0) {
+ return activeBindingsFor[0].format();
+ }
+ }
+ }
+ return null;
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java 2007-03-16 13:21:44 UTC (rev 2188)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -7,6 +7,11 @@
private static final String BUNDLE_NAME = CorrectionMessages.class.getName();
public static String RubyCorrectionProcessor_error_status;
+ public static String RubyCorrectionProcessor_error_quickfix_message;
+ public static String MarkerResolutionProposal_additionaldesc;
+ public static String ChangeCorrectionProposal_error_title;
+ public static String ChangeCorrectionProposal_error_message;
+ public static String ChangeCorrectionProposal_name_with_shortcut;
static {
NLS.initializeMessages(BUNDLE_NAME, CorrectionMessages.class);
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ICommandAccess.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ICommandAccess.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ICommandAccess.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,26 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+/**
+ * Correction proposals implement this interface to by invokable by a command.
+ * (e.g. keyboard shortcut)
+ */
+public interface ICommandAccess {
+
+ /**
+ * Returns the id of the command that should invoke this correction proposal
+ * @return the id of the command. This id must start with {@link CorrectionCommandInstaller#COMMAND_PREFIX}
+ * to be recognixes as correction command.
+ */
+ String getCommandId();
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/IStatusLineProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/IStatusLineProposal.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/IStatusLineProposal.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+/**
+ * A proposal which is able to show a message
+ * on the status line of the content assistant
+ * in which this proposal is shown.
+ *
+ * @see org.eclipse.jface.text.contentassist.IContentAssistantExtension2
+ */
+public interface IStatusLineProposal {
+
+ /**
+ * The message to show when this proposal is
+ * selected by the user in the content assistant.
+ *
+ * @return The message to show, or null for no message.
+ */
+ public String getStatusMessage();
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/MarkerResolutionProposal.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/MarkerResolutionProposal.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/MarkerResolutionProposal.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.ui.IMarkerResolution;
+import org.eclipse.ui.IMarkerResolution2;
+import org.rubypeople.rdt.internal.core.util.Messages;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.RubyPluginImages;
+import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
+
+/**
+ */
+public class MarkerResolutionProposal implements IRubyCompletionProposal {
+
+ private IMarkerResolution fResolution;
+ private IMarker fMarker;
+
+ /**
+ * Constructor for MarkerResolutionProposal.
+ */
+ public MarkerResolutionProposal(IMarkerResolution resolution, IMarker marker) {
+ fResolution= resolution;
+ fMarker= marker;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
+ */
+ public void apply(IDocument document) {
+ fResolution.run(fMarker);
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
+ */
+ public String getAdditionalProposalInfo() {
+ if (fResolution instanceof IMarkerResolution2) {
+ return ((IMarkerResolution2) fResolution).getDescription();
+ }
+ try {
+ String problemDesc= (String) fMarker.getAttribute(IMarker.MESSAGE);
+ return Messages.format(CorrectionMessages.MarkerResolutionProposal_additionaldesc, problemDesc);
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ }
+ return null;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
+ */
+ public IContextInformation getContextInformation() {
+ return null;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
+ */
+ public String getDisplayString() {
+ return fResolution.getLabel();
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
+ */
+ public Image getImage() {
+ if (fResolution instanceof IMarkerResolution2) {
+ return ((IMarkerResolution2) fResolution).getImage();
+ }
+ return RubyPluginImages.get(RubyPluginImages.IMG_CORRECTION_CHANGE);
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.java.IRubyCompletionProposal#getRelevance()
+ */
+ public int getRelevance() {
+// if (fResolution instanceof IRubyMarkerResolutionExtension) {
+// return ((IRubyMarkerResolutionExtension) fResolution).getRelevance();
+// }
+ return 10;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
+ */
+ public Point getSelection(IDocument document) {
+ return null;
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ProblemLocation.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,168 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+import org.rubypeople.rdt.core.IRubyModelMarker;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
+import org.rubypeople.rdt.internal.ti.util.OffsetNodeLocator;
+import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyAnnotation;
+import org.rubypeople.rdt.internal.ui.rubyeditor.RubyMarkerAnnotation;
+import org.rubypeople.rdt.ui.text.ruby.IProblemLocation;
+
+/**
+ *
+ */
+public class ProblemLocation implements IProblemLocation {
+
+ private final int fId;
+// private final String[] fArguments;
+ private final int fOffset;
+ private final int fLength;
+ private final boolean fIsError;
+ private final String fMarkerType;
+
+ public ProblemLocation(int offset, int length, IRubyAnnotation annotation) {
+ fId= annotation.getId();
+// fArguments= annotation.getArguments();
+ fOffset= offset;
+ fLength= length;
+ fIsError= RubyMarkerAnnotation.ERROR_ANNOTATION_TYPE.equals(annotation.getType());
+
+ String markerType= annotation.getMarkerType();
+ fMarkerType= markerType != null ? markerType : IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER;
+ }
+
+ public ProblemLocation(int offset, int length, int id, String[] arguments, boolean isError, String markerType) {
+ fId= id;
+// fArguments= arguments;
+ fOffset= offset;
+ fLength= length;
+ fIsError= isError;
+ fMarkerType= markerType;
+ }
+
+ public ProblemLocation(IProblem problem) {
+ fId= problem.getID();
+// fArguments= problem.getArguments();
+ fOffset= problem.getSourceStart();
+ fLength= problem.getSourceEnd() - fOffset + 1;
+ fIsError= problem.isError();
+ fMarkerType= problem instanceof CategorizedProblem ? ((CategorizedProblem) problem).getMarkerType() : IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER;
+ }
+
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getProblemId()
+ */
+ public int getProblemId() {
+ return fId;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getProblemArguments()
+ */
+ public String[] getProblemArguments() {
+// return fArguments;
+ return new String[0];
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getLength()
+ */
+ public int getLength() {
+ return fLength;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getOffset()
+ */
+ public int getOffset() {
+ return fOffset;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.ui.text.java.IProblemLocation#isError()
+ */
+ public boolean isError() {
+ return fIsError;
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jdt.ui.text.java.IProblemLocation#getMarkerType()
+ */
+ public String getMarkerType() {
+ return fMarkerType;
+ }
+
+ /*
+ * (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getCoveringNode(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public Node getCoveringNode(RootNode astRoot) {
+ return OffsetNodeLocator.Instance().getNodeAtOffset(astRoot, fOffset);
+ }
+
+ /*
+ * (non-Rubydoc)
+ * @see org.eclipse.jdt.internal.ui.text.correction.IProblemLocation#getCoveredNode(org.eclipse.jdt.core.dom.CompilationUnit)
+ */
+ public Node getCoveredNode(RootNode astRoot) {
+ return OffsetNodeLocator.Instance().getNodeAtOffset(astRoot, fOffset);
+ }
+
+ public String toString() {
+ StringBuffer buf= new StringBuffer();
+ buf.append("Id: ").append(getErrorCode(fId)).append('\n'); //$NON-NLS-1$
+ buf.append('[').append(fOffset).append(", ").append(fLength).append(']').append('\n'); //$NON-NLS-1$
+// String[] arg= fArguments;
+// if (arg != null) {
+// for (int i= 0; i < arg.length; i++) {
+// buf.append(arg[i]);
+// buf.append('\n');
+// }
+// }
+ return buf.toString();
+ }
+
+ private String getErrorCode(int code) {
+ StringBuffer buf= new StringBuffer();
+
+ if ((code & IProblem.TypeRelated) != 0) {
+ buf.append("TypeRelated + "); //$NON-NLS-1$
+ }
+ if ((code & IProblem.FieldRelated) != 0) {
+ buf.append("FieldRelated + "); //$NON-NLS-1$
+ }
+ if ((code & IProblem.ConstructorRelated) != 0) {
+ buf.append("ConstructorRelated + "); //$NON-NLS-1$
+ }
+ if ((code & IProblem.MethodRelated) != 0) {
+ buf.append("MethodRelated + "); //$NON-NLS-1$
+ }
+ if ((code & IProblem.ImportRelated) != 0) {
+ buf.append("ImportRelated + "); //$NON-NLS-1$
+ }
+ if ((code & IProblem.Internal) != 0) {
+ buf.append("Internal + "); //$NON-NLS-1$
+ }
+ if ((code & IProblem.Syntax) != 0) {
+ buf.append("Syntax + "); //$NON-NLS-1$
+ }
+ buf.append(code & IProblem.IgnoreCategoriesMask);
+
+ return buf.toString();
+ }
+
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionAssistant.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionAssistant.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionAssistant.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -0,0 +1,329 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultInformationControl;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IInformationControl;
+import org.eclipse.jface.text.IInformationControlCreator;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.quickassist.IQuickAssistAssistant;
+import org.eclipse.jface.text.quickassist.QuickAssistAssistant;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditor;
+import org.rubypeople.rdt.core.IRubyElement;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.HTMLTextPresenter;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+import org.rubypeople.rdt.ui.RubyUI;
+import org.rubypeople.rdt.ui.text.IColorManager;
+import org.rubypeople.rdt.ui.text.RubyTextTools;
+
+
+public class RubyCorrectionAssistant extends QuickAssistAssistant {
+
+ private ITextViewer fViewer;
+ private ITextEditor fEditor;
+ private Position fPosition;
+ private Annotation[] fCurrentAnnotations;
+
+// private QuickAssistLightBulbUpdater fLightBulbUpdater;
+
+
+ /**
+ * Constructor for RubyCorrectionAssistant.
+ */
+ public RubyCorrectionAssistant(ITextEditor editor) {
+ super();
+ Assert.isNotNull(editor);
+ fEditor= editor;
+
+ RubyCorrectionProcessor processor= new RubyCorrectionProcessor(this);
+
+ setQuickAssistProcessor(processor);
+
+ setInformationControlCreator(getInformationControlCreator());
+
+ RubyTextTools textTools= RubyPlugin.getDefault().getRubyTextTools();
+ IColorManager manager= textTools.getColorManager();
+
+ IPreferenceStore store= RubyPlugin.getDefault().getPreferenceStore();
+
+ Color c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_FOREGROUND, manager);
+ setProposalSelectorForeground(c);
+
+ c= getColor(store, PreferenceConstants.CODEASSIST_PROPOSALS_BACKGROUND, manager);
+ setProposalSelectorBackground(c);
+ }
+
+ public IEditorPart getEditor() {
+ return fEditor;
+ }
+
+
+ private IInformationControlCreator getInformationControlCreator() {
+ return new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell parent) {
+ return new DefaultInformationControl(parent, new HTMLTextPresenter());
+ }
+ };
+ }
+
+ private static Color getColor(IPreferenceStore store, String key, IColorManager manager) {
+ RGB rgb= PreferenceConverter.getColor(store, key);
+ return manager.getColor(rgb);
+ }
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.IContentAssistant#install(org.eclipse.jface.text.ITextViewer)
+ */
+ public void install(ISourceViewer sourceViewer) {
+ super.install(sourceViewer);
+ fViewer= sourceViewer;
+
+// fLightBulbUpdater= new QuickAssistLightBulbUpdater(fEditor, sourceViewer);
+// fLightBulbUpdater.install();
+ }
+
+
+
+ /* (non-Rubydoc)
+ * @see org.eclipse.jface.text.contentassist.ContentAssistant#uninstall()
+ */
+ public void uninstall() {
+// if (fLightBulbUpdater != null) {
+// fLightBulbUpdater.uninstall();
+// fLightBulbUpdater= null;
+// }
+ super.uninstall();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.quickassist.QuickAssistAssistant#showPossibleQuickAssists()
+ * @since 3.2
+ */
+
+ /**
+ * Show completions at caret position. If current
+ * position does not contain quick fixes look for
+ * next quick fix on same line by moving from left
+ * to right and restarting at end of line if the
+ * beginning of the line is reached.
+ *
+ * @see IQuickAssistAssistant#showPossibleQuickAssists()
+ */
+ public String showPossibleQuickAssists() {
+ fPosition= null;
+ fCurrentAnnotations= null;
+
+ if (fViewer == null || fViewer.getDocument() == null)
+ // Let superclass deal with this
+ return super.showPossibleQuickAssists();
+
+
+ ArrayList resultingAnnotations= new ArrayList(20);
+ try {
+ Point selectedRange= fViewer.getSelectedRange();
+ int currOffset= selectedRange.x;
+ int currLength= selectedRange.y;
+ boolean goToClosest= (currLength == 0);
+
+ int newOffset= collectQuickFixableAnnotations(fEditor, currOffset, goToClosest, resultingAnnotations);
+ if (newOffset != currOffset) {
+ storePosition(currOffset, currLength);
+ fViewer.setSelectedRange(newOffset, 0);
+ fViewer.revealRange(newOffset, 0);
+ }
+ } catch (BadLocationException e) {
+ RubyPlugin.log(e);
+ }
+ fCurrentAnnotations= (Annotation[]) resultingAnnotations.toArray(new Annotation[resultingAnnotations.size()]);
+
+ return super.showPossibleQuickAssists();
+ }
+
+
+ private static IRegion getRegionOfInterest(ITextEditor editor, int invocationLocation) throws BadLocationException {
+ IDocumentProvider documentProvider= editor.getDocumentProvider();
+ if (documentProvider == null) {
+ return null;
+ }
+ IDocument document= documentProvider.getDocument(editor.getEditorInput());
+ if (document == null) {
+ return null;
+ }
+ return document.getLineInformationOfOffset(invocationLocation);
+ }
+
+ public static int collectQuickFixableAnnotations(ITextEditor editor, int invocationLocation, boolean goToClosest, ArrayList resultingAnnotations) throws BadLocationException {
+ IAnnotationModel model= RubyUI.getDocumentProvider().getAnnotationModel(editor.getEditorInput());
+ if (model == null) {
+ return invocationLocation;
+ }
+
+ ensureUpdatedAnnotations(editor);
+
+ Iterator iter= model.getAnnotationIterator();
+ if (goToClosest) {
+ IRegion lineInfo= getRegionOfInterest(editor, invocationLocation);
+ if (lineInfo == null) {
+ return invocationLocation;
+ }
+ int rangeStart= lineInfo.getOffset();
+ int rangeEnd= rangeStart + lineInfo.getLength();
+
+ ArrayList allAnnotations= new ArrayList();
+ ArrayList allPositions= new ArrayList();
+ int bestOffset= Integer.MAX_VALUE;
+ while (iter.hasNext()) {
+ Annotation annot= (Annotation) iter.next();
+ if (RubyCorrectionProcessor.isQuickFixableType(annot)) {
+ Position pos= model.getPosition(annot);
+ if (pos != null && isInside(pos.offset, rangeStart, rangeEnd)) { // inside our range?
+ allAnnotations.add(annot);
+ allPositions.add(pos);
+ bestOffset= processAnnotation(annot, pos, invocationLocation, bestOffset);
+ }
+ }
+ }
+ if (bestOffset == Integer.MAX_VALUE) {
+ return invocationLocation;
+ }
+ for (int i= 0; i < allPositions.size(); i++) {
+ Position pos= (Position) allPositions.get(i);
+ if (isInside(bestOffset, pos.offset, pos.offset + pos.length)) {
+ resultingAnnotations.add(allAnnotations.get(i));
+ }
+ }
+ return bestOffset;
+ } else {
+ while (iter.hasNext()) {
+ Annotation annot= (Annotation) iter.next();
+ if (RubyCorrectionProcessor.isQuickFixableType(annot)) {
+ Position pos= model.getPosition(annot);
+ if (pos != null && isInside(invocationLocation, pos.offset, pos.offset + pos.length)) {
+ resultingAnnotations.add(annot);
+ }
+ }
+ }
+ return invocationLocation;
+ }
+ }
+
+ private static void ensureUpdatedAnnotations(ITextEditor editor) {
+ Object inputElement= editor.getEditorInput().getAdapter(IRubyElement.class);
+ if (inputElement instanceof IRubyScript) {
+// RubyPlugin.getDefault().getASTProvider().getAST((IRubyScript) inputElement, ASTProvider.WAIT_ACTIVE_ONLY, null);
+ }
+ }
+
+ private static int processAnnotation(Annotation annot, Position pos, int invocationLocation, int bestOffset) {
+ int posBegin= pos.offset;
+ int posEnd= posBegin + pos.length;
+ if (isInside(invocationLocation, posBegin, posEnd)) { // covers invocation location?
+ return invocationLocation;
+ } else if (bestOffset != invocationLocation) {
+ int newClosestPosition= computeBestOffset(posBegin, invocationLocation, bestOffset);
+ if (newClosestPosition != -1) {
+ if (newClosestPosition != bestOffset) { // new best
+ if (RubyCorrectionProcessor.hasCorrections(annot)) { // only jump to it if there are proposals
+ return newClosestPosition;
+ }
+ }
+ }
+ }
+ return bestOffset;
+ }
+
+
+ private static boolean isInside(int offset, int start, int end) {
+ return offset == start || (offset > start && offset < end); // make sure to handle 0-length ranges
+ }
+
+ /**
+ * Computes and returns the invocation offset given a new
+ * position, the initial offset and the best invocation offset
+ * found so far.
+ * <p>
+ * The closest offset to the left of the initial offset is the
+ * best. If there is no offset on the left, the closest on the
+ * right is the best.</p>
+ * @return -1 is returned if the given offset is not closer or the new best offset
+ */
+ private static int computeBestOffset(int newOffset, int invocationLocation, int bestOffset) {
+ if (newOffset <= invocationLocation) {
+ if (bestOffset > invocationLocation) {
+ return newOffset; // closest was on the right, prefer on the left
+ } else if (bestOffset <= newOffset) {
+ return newOffset; // we are closer or equal
+ }
+ return -1; // further away
+ }
+
+ if (newOffset <= bestOffset)
+ return newOffset; // we are closer or equal
+
+ return -1; // further away
+ }
+
+ /*
+ * @see org.eclipse.jface.text.contentassist.ContentAssistant#possibleCompletionsClosed()
+ */
+ protected void possibleCompletionsClosed() {
+ super.possibleCompletionsClosed();
+ restorePosition();
+ }
+
+ private void storePosition(int currOffset, int currLength) {
+ fPosition= new Position(currOffset, currLength);
+ }
+
+ private void restorePosition() {
+ if (fPosition != null && !fPosition.isDeleted() && fViewer.getDocument() != null) {
+ fViewer.setSelectedRange(fPosition.offset, fPosition.length);
+ fViewer.revealRange(fPosition.offset, fPosition.length);
+ }
+ fPosition= null;
+ }
+
+ /**
+ * Returns true if the last invoked completion was called with an updated offset.
+ */
+ public boolean isUpdatedOffset() {
+ return fPosition != null;
+ }
+
+ /**
+ * Returns the annotations at the current offset
+ */
+ public Annotation[] getAnnotationsAtOffset() {
+ return fCurrentAnnotations;
+ }
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java 2007-03-16 13:21:44 UTC (rev 2188)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java 2007-03-16 13:23:28 UTC (rev 2189)
@@ -1,6 +1,7 @@
package org.rubypeople.rdt.internal.ui.text.correction;
import java.util.ArrayList;
+import java.util.Collection;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.runtime.IConfigurationElement;
@@ -10,26 +11,71 @@
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.SafeRunner;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.contentassist.ContentAssistEvent;
+import org.eclipse.jface.text.contentassist.ICompletionListener;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IMarkerHelpRegistry;
+import org.eclipse.ui.IMarkerResolution;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyAnnotation;
import org.rubypeople.rdt.ui.RubyUI;
+import org.rubypeople.rdt.ui.text.ruby.IInvocationContext;
+import org.rubypeople.rdt.ui.text.ruby.IProblemLocation;
+import org.rubypeople.rdt.ui.text.ruby.IQuickAssistProcessor;
import org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor;
+import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
public class RubyCorrectionProcessor implements org.eclipse.jface.text.quickassist.IQuickAssistProcessor {
private static final String QUICKFIX_PROCESSOR_CONTRIBUTION_ID= "quickFixProcessors"; //$NON-NLS-1$
+ private static final String QUICKASSIST_PROCESSOR_CONTRIBUTION_ID= "quickAssistProcessors"; //$NON-NLS-1$
+ private static ContributedProcessorDescriptor[] fContributedAssistProcessors= null;
private static ContributedProcessorDescriptor[] fContributedCorrectionProcessors= null;
private String fErrorMessage;
+ private RubyCorrectionAssistant fAssistant;
+ /*
+ * Constructor for RubyCorrectionProcessor.
+ */
+ public RubyCorrectionProcessor(RubyCorrectionAssistant assistant) {
+ fAssistant= assistant;
+ fAssistant.addCompletionListener(new ICompletionListener() {
+
+ public void assistSessionEnded(ContentAssistEvent event) {
+ fAssistant.setStatusLineVisible(false);
+ }
+
+ public void assistSessionStarted(ContentAssistEvent event) {
+ fAssistant.setStatusLineVisible(true);
+ }
+
+ public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
+ if (proposal instanceof IStatusLineProposal) {
+ IStatusLineProposal statusLineProposal= (IStatusLineProposal)proposal;
+ String message= statusLineProposal.getStatusMessage();
+ if (message != null) {
+ fAssistant.setStatusMessage(message);
+ } else {
+ fAssistant.setStatusMessage(""); //$NON-NLS-1$
+ }
+ } else {
+ fAssistant.setStatusMessage(""); //$NON-NLS-1$
+ }
+ }
+ });
+ }
+
public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
// TODO Auto-generated method stub
return false;
@@ -39,10 +85,149 @@
return hasCorrections(annotation);
}
- public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
- // TODO Auto-generated method stub
- return new ICompletionProposal[0];
+ public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext quickAssistContext) {
+ ITextViewer viewer= quickAssistContext.getSourceViewer();
+ int documentOffset= quickAssistContext.getOffset();
+
+ IEditorPart part= fAssistant.getEditor();
+
+ IRubyScript cu= RubyUI.getWorkingCopyManager().getWorkingCopy(part.getEditorInput());
+ IAnnotationModel model= RubyUI.getDocumentProvider().getAnnotationModel(part.getEditorInput());
+
+ int length= viewer != null ? viewer.getSelectedRange().y : 0;
+ AssistContext context= new AssistContext(cu, documentOffset, length);
+
+ Annotation[] annotations= fAssistant.getAnnotationsAtOffset();
+
+ fErrorMessage= null;
+
+ ICompletionProposal[] res= null;
+ if (model != null && annotations != null) {
+ ArrayList proposals= new ArrayList(10);
+ IStatus status= collectProposals(context, model, annotations, true, !fAssistant.isUpdatedOffset(), proposals);
+ res= (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
+ if (!status.isOK()) {
+ fErrorMessage= status.getMessage();
+ RubyPlugin.log(status);
+ }
+ }
+
+ if (res == null || res.length == 0) {
+ return new ICompletionProposal[0];
+ }
+// if (res.length > 1) {
+// Arrays.sort(res, new CompletionProposalComparator());
+// }
+ return res;
}
+
+ public static IStatus collectProposals(IInvocationContext context, IAnnotationModel model, Annotation[] annotations, boolean addQuickFixes, boolean addQuickAssists, Collection proposals) {
+ ArrayList problems= new ArrayList();
+
+ // collect problem locations and corrections from marker annotations
+ for (int i= 0; i < annotations.length; i++) {
+ Annotation curr= annotations[i];
+ if (curr instanceof IRubyAnnotation) {
+ ProblemLocation problemLocation= getProblemLocation((IRubyAnnotation) curr, model);
+ if (problemLocation != null) {
+ problems.add(problemLocation);
+ }
+ } else if (addQuickFixes && curr instanceof SimpleMarkerAnnotation) {
+ // don't collect if annotation is already a java annotation
+ collectMarkerProposals((SimpleMarkerAnnotation) curr, proposals);
+ }
+ }
+ MultiStatus resStatus= null;
+
+ IProblemLocation[] problemLocations= (IProblemLocation[]) problems.toArray(new IProblemLocation[problems.size()]);
+ if (addQuickFixes) {
+ IStatus status= collectCorrections(context, problemLocations, proposals);
+ if (!status.isOK()) {
+ resStatus= new MultiStatus(RubyUI.ID_PLUGIN, IStatus.ERROR, CorrectionMessages.RubyCorrectionProcessor_error_quickfix_message, null);
+ resStatus.add(status);
+ }
+ }
+// if (addQuickAssists) {
+// IStatus status= collectAssists(context, problemLocations, proposals);
+// if (!status.isOK()) {
+// if (resStatus == null) {
+// resStatus= new MultiStatus(RubyUI.ID_PLUGIN, IStatus.ERROR, CorrectionMessages.JavaCorrectionProcessor_error_quickassist_message, null);
+// }
+// resStatus.add(status);
+// }
+// }
+ if (resStatus != null) {
+ return resStatus;
+ }
+ return Status.OK_STATUS;
+ }
+
+ public static IStatus collectCorrections(IInvocationContext context, IProblemLocation[] locations, Collection proposals) {
+ ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
+ SafeCorrectionCollector collector= new SafeCorrectionCollector(context, proposals);
+ for (int i= 0...
[truncated message content] |
|
From: <caw...@us...> - 2007-03-16 13:21:47
|
Revision: 2188
http://svn.sourceforge.net/rubyeclipse/?rev=2188&view=rev
Author: cawilliams
Date: 2007-03-16 06:21:44 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
oops fix name
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/schema/quickFixProcessors.exsd
Removed Paths:
-------------
trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd
Deleted: trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd
===================================================================
--- trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd 2007-03-16 13:21:29 UTC (rev 2187)
+++ trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd 2007-03-16 13:21:44 UTC (rev 2188)
@@ -1,192 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.rubypeople.rdt.ui">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.rubypeople.rdt.ui" id="quickFixProcessors" name="Quick Fix Processor"/>
- </appInfo>
- <documentation>
- This extension point allows to add a Quick Fix processor to offer new Quick Fixes on Ruby problems.
-<p>
-An extension can specify which problem marker types it can handle. It will only get problems of these types to process.
-If no handled marker type are specified, the processor will only get problems of types org.rubypeople.rdt.core.problem, org.rubypeople.rdt.core.buildpath_problem and org.rubypeople.rdt.core.task.
-</p>
-<p>
-This extension point supports the <code>enablement</code> tag. Properties to test on are:
-<dl>
-<li>rubyScript: type IRubyScript; the compilation unit the quick assist is applied on</li>
-<li>projectNatures: type Collection; all project natures of the current project</li>
-</dl>
-</p>
- </documentation>
- </annotation>
-
- <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="quickFixProcessor" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- a fully qualified identifier of the target extension point
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- an optional identifier of the extension instance
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- an optional name of the extension instance
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="quickFixProcessor">
- <complexType>
- <sequence>
- <element ref="enablement"/>
- <element ref="handledMarkerTypes" minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- Unique identifier for the Quick Fix processor
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- Localized name of the Quick Fix processor.
- </documentation>
- <appInfo>
- <meta.attribute translatable="true"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- the name of the class that implements this Quick Fix processor. The
-class must be public and implement
-<samp>org.eclipse.jdt.ui.text.java.IQuickFixProcessor</samp>
-with a public 0-argument constructor.
- </documentation>
- <appInfo>
- <meta.attribute kind="java" basedOn="org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor"/>
- </appInfo>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="handledMarkerTypes">
- <annotation>
- <documentation>
- Specifies the marker types of the problems this quick fix processor can handle.
-If no handled marker type are specified, the processor will get problems of types org.eclipse.jdt.core.problem, org.eclipse.jdt.core.buildpath_problem and org.eclipse.jdt.core.task.
- </documentation>
- </annotation>
- <complexType>
- <sequence>
- <element ref="markerType" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
-
- <element name="markerType">
- <complexType>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- The marker type id of the marker that can be handled by this processor
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example of a Quick Fix processor contribution:
-
-<p>
-<pre>
- <extension point="org.rubypeople.rdt.ui.quickFixProcessors">
- <quickFixProcessor
- id="AdvancedQuickFixProcessor"
- name="Advanced Quick Fix Processor"
- requiredSourceLevel="1.5"
- class="com.example.AdvancedQuickFixProcessor">
- <handledMarkerTypes>
- <markerType id="org.eclipse.myplugin.audits"/>
- </handledMarkerTypes>
- <enablement>
- <with variable="projectNatures">
- <iterate operator="or">
- <equals value="org.eclipse.jdt.core.javanature"/>
- </iterate>
- </with>
- </enablement>
- </quickFixProcessor>
- </extension>
-</pre>
-</p>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- Extension point since 3.0. Element <code>handledMarkerTypes</code> since 3.2.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- The contributed class must implement <code>org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor</code>
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- Copyright (c) 2001, 2006 IBM Corporation and others.<br>
-All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
- </documentation>
- </annotation>
-
-</schema>
Copied: trunk/org.rubypeople.rdt.ui/schema/quickFixProcessors.exsd (from rev 2171, trunk/org.rubypeople.rdt.ui/schema/quickFixProcessor.exsd)
===================================================================
--- trunk/org.rubypeople.rdt.ui/schema/quickFixProcessors.exsd (rev 0)
+++ trunk/org.rubypeople.rdt.ui/schema/quickFixProcessors.exsd 2007-03-16 13:21:44 UTC (rev 2188)
@@ -0,0 +1,192 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.rubypeople.rdt.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.rubypeople.rdt.ui" id="quickFixProcessors" name="Quick Fix Processor"/>
+ </appInfo>
+ <documentation>
+ This extension point allows to add a Quick Fix processor to offer new Quick Fixes on Ruby problems.
+<p>
+An extension can specify which problem marker types it can handle. It will only get problems of these types to process.
+If no handled marker type are specified, the processor will only get problems of types org.rubypeople.rdt.core.problem, org.rubypeople.rdt.core.buildpath_problem and org.rubypeople.rdt.core.task.
+</p>
+<p>
+This extension point supports the <code>enablement</code> tag. Properties to test on are:
+<dl>
+<li>rubyScript: type IRubyScript; the compilation unit the quick assist is applied on</li>
+<li>projectNatures: type Collection; all project natures of the current project</li>
+</dl>
+</p>
+ </documentation>
+ </annotation>
+
+ <include schemaLocation="schema://org.eclipse.core.expressions/schema/expressionLanguage.exsd"/>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="quickFixProcessor" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="quickFixProcessor">
+ <complexType>
+ <sequence>
+ <element ref="enablement"/>
+ <element ref="handledMarkerTypes" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ Unique identifier for the Quick Fix processor
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ Localized name of the Quick Fix processor.
+ </documentation>
+ <appInfo>
+ <meta.attribute translatable="true"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the name of the class that implements this Quick Fix processor. The
+class must be public and implement
+<samp>org.eclipse.jdt.ui.text.java.IQuickFixProcessor</samp>
+with a public 0-argument constructor.
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="handledMarkerTypes">
+ <annotation>
+ <documentation>
+ Specifies the marker types of the problems this quick fix processor can handle.
+If no handled marker type are specified, the processor will get problems of types org.eclipse.jdt.core.problem, org.eclipse.jdt.core.buildpath_problem and org.eclipse.jdt.core.task.
+ </documentation>
+ </annotation>
+ <complexType>
+ <sequence>
+ <element ref="markerType" minOccurs="1" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+
+ <element name="markerType">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ The marker type id of the marker that can be handled by this processor
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ The following is an example of a Quick Fix processor contribution:
+
+<p>
+<pre>
+ <extension point="org.rubypeople.rdt.ui.quickFixProcessors">
+ <quickFixProcessor
+ id="AdvancedQuickFixProcessor"
+ name="Advanced Quick Fix Processor"
+ requiredSourceLevel="1.5"
+ class="com.example.AdvancedQuickFixProcessor">
+ <handledMarkerTypes>
+ <markerType id="org.eclipse.myplugin.audits"/>
+ </handledMarkerTypes>
+ <enablement>
+ <with variable="projectNatures">
+ <iterate operator="or">
+ <equals value="org.eclipse.jdt.core.javanature"/>
+ </iterate>
+ </with>
+ </enablement>
+ </quickFixProcessor>
+ </extension>
+</pre>
+</p>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ Extension point since 3.0. Element <code>handledMarkerTypes</code> since 3.2.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ The contributed class must implement <code>org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor</code>
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ Copyright (c) 2001, 2006 IBM Corporation and others.<br>
+All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at <a href="http://www.eclipse.org/legal/epl-v10.html">http://www.eclipse.org/legal/epl-v10.html</a>
+ </documentation>
+ </annotation>
+
+</schema>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:21:34
|
Revision: 2187
http://svn.sourceforge.net/rubyeclipse/?rev=2187&view=rev
Author: cawilliams
Date: 2007-03-16 06:21:29 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-03-16 13:21:06 UTC (rev 2186)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/RubyUI.java 2007-03-16 13:21:29 UTC (rev 2187)
@@ -12,6 +12,7 @@
import org.eclipse.jface.util.Assert;
import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.texteditor.IDocumentProvider;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.SharedImages;
@@ -126,4 +127,15 @@
public static IWorkingCopyManager getWorkingCopyManager() {
return RubyPlugin.getDefault().getWorkingCopyManager();
}
+ /**
+ * Returns the DocumentProvider used for Ruby compilation units.
+ *
+ * @return the DocumentProvider for Ruby compilation units.
+ *
+ * @see IDocumentProvider
+ * @since 2.0
+ */
+ public static IDocumentProvider getDocumentProvider() {
+ return RubyPlugin.getDefault().getRubyDocumentProvider();
+ }
}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:21:07
|
Revision: 2186
http://svn.sourceforge.net/rubyeclipse/?rev=2186&view=rev
Author: cawilliams
Date: 2007-03-16 06:21:06 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
fix a missing set of strings
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-03-16 13:19:35 UTC (rev 2185)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/RubyUIMessages.properties 2007-03-16 13:21:06 UTC (rev 2186)
@@ -99,4 +99,8 @@
CoreUtility_buildall_taskname=Build all...
CoreUtility_buildproject_taskname=Build project ''{0}''...
-RubyElementLabels_default_package=(default)
\ No newline at end of file
+RubyElementLabels_default_package=(default)
+
+ContentAssistProposal.label=Co&ntent Assist
+ContentAssistProposal.tooltip=Content Assist
+ContentAssistProposal.description=Content Assist
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-16 13:19:43
|
Revision: 2185
http://svn.sourceforge.net/rubyeclipse/?rev=2185&view=rev
Author: cawilliams
Date: 2007-03-16 06:19:35 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
start moving us towards categorized problems that contain a unique id - useful for quick fixes.
Also, change the IMarkerManager API, it should really just take an IResource and an IProblem, otherwise we drop useful info contained in the IProblem in some cases by decosnturcting it and then reconstructing without the ID for example.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IMarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/ImmediateWarnings.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamMarkerManager.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -60,6 +60,14 @@
*/
int IgnoreCategoriesMask = 0xFFFFFF;
+ int UndocumentedEmptyBlock = Internal + 460;
+ int UnusedPrivateField = Internal + FieldRelated + 77;
+ int LocalVariableIsNeverUsed = Internal + 61;
+ int ArgumentIsNeverUsed = Internal + 62;
+ int UnusedPrivateMethod = Internal + MethodRelated + 118;
+
+ int Task = Internal + 450;
+
/**
* Returns the problem id
*
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/CodeDuplicationDetector.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -9,6 +9,8 @@
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.rubypeople.rdt.core.RubyCore;
+import org.rubypeople.rdt.internal.core.parser.RdtPosition;
+import org.rubypeople.rdt.internal.core.parser.Warning;
import org.rubypeople.rdt.internal.core.pmd.CPD;
import org.rubypeople.rdt.internal.core.pmd.Match;
import org.rubypeople.rdt.internal.core.pmd.TokenEntry;
@@ -42,7 +44,8 @@
TokenEntry mark = (TokenEntry) occurrences.next();
// FIXME Make TokenEntry hold an IFile pointer to source file?
IFile file = RubyCore.getWorkspace().getRoot().getFileForLocation(Path.fromOSString(mark.getTokenSrcID()));
- markerManager.addWarning(file, message.toString(), mark.getBeginLine(), mark.getStartOffset(), mark.getStartOffset() + match.getSourceCodeSlice().length());
+ Warning warning = new Warning(new RdtPosition(mark.getBeginLine(), mark.getStartOffset(), mark.getStartOffset() + match.getSourceCodeSlice().length()), message.toString());
+ markerManager.addProblem(file, warning);
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IMarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IMarkerManager.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/IMarkerManager.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -17,13 +17,26 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.jruby.lexer.yacc.SyntaxException;
+import org.rubypeople.rdt.core.compiler.IProblem;
+import org.rubypeople.rdt.internal.core.parser.TaskTag;
public interface IMarkerManager {
- public void removeProblemsAndTasksFor(IResource resource);
+
+ public void removeProblemsAndTasksFor(IResource resource);
+
+ /**
+ * @deprecated Use addProblem
+ * @param file
+ * @param e
+ */
public void createSyntaxError(IFile file, SyntaxException e);
- public void createError(IFile file, String message, int startLine, int startOffset, int endOffset);
- public void createTasks(IFile file, List tasks) throws CoreException;
- public void addWarning(IFile file, String message);
- public void addWarning(IFile file, String message, int startLine, int startOffset, int endOffset);
+ /**
+ * @param file
+ * @param tasks
+ * @throws CoreException
+ */
+ public void createTasks(IFile file, List<TaskTag> tasks) throws CoreException;
+
+ public void addProblem(IFile file, IProblem problem);
}
\ No newline at end of file
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/MarkerManager.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -17,10 +17,9 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.jruby.lexer.yacc.SyntaxException;
-import org.rubypeople.rdt.internal.core.parser.Error;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.core.parser.MarkerUtility;
-import org.rubypeople.rdt.internal.core.parser.RdtPosition;
-import org.rubypeople.rdt.internal.core.parser.Warning;
+import org.rubypeople.rdt.internal.core.parser.TaskTag;
class MarkerManager implements IMarkerManager {
@@ -32,21 +31,12 @@
MarkerUtility.createSyntaxError(file, e);
}
- public void createTasks(IFile file, List tasks) throws CoreException {
+ public void createTasks(IFile file, List<TaskTag> tasks) throws CoreException {
MarkerUtility.createTasks(file, tasks);
}
-
- public void addWarning(IFile file, String message) {
- addWarning(file,message, 1, 0, 0);
- }
-
- public void addWarning(IFile file, String message, int startLine, int startOffset, int endOffset) {
- MarkerUtility.createProblemMarker(file, new Warning(new RdtPosition(startLine, startOffset, endOffset), message));
- }
-
- public void createError(IFile file, String message, int startLine, int startOffset, int endOffset) {
- MarkerUtility.createProblemMarker(file, new Error(new RdtPosition(startLine, startOffset, endOffset), message));
-
+
+ public void addProblem(IFile file, IProblem problem) {
+ MarkerUtility.createProblemMarker(file, problem);
}
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -26,16 +26,10 @@
public void acceptProblem(IProblem problem) {
// TODO Use active flag by calling begin and end reporting
// if (!isActive()) return;
- if (problem.isWarning()) {
- markerManager.addWarning(file, problem.getMessage(), problem.getSourceLineNumber(), problem.getSourceStart(), problem.getSourceEnd());
+ if (problem.isWarning() || problem.isError()) {
+ markerManager.addProblem(file, problem);
return;
}
- if (problem.isError()) {
- markerManager.createError(file, problem.getMessage(),
- problem.getSourceLineNumber(), problem
- .getSourceStart(), problem.getSourceEnd());
- return;
- }
if (problem.isTask()) {
List tasks = new ArrayList();
TaskTag task = (TaskTag) problem;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -5,7 +5,6 @@
import org.jruby.lexer.yacc.ISourcePosition;
import org.rubypeople.rdt.core.compiler.CategorizedProblem;
-import org.rubypeople.rdt.core.compiler.IProblem;
/**
* @author Chris
@@ -23,11 +22,12 @@
/**
* @param position
* @param message
+ * @param problemID
*/
- public DefaultProblem(ISourcePosition position, String message) {
+ public DefaultProblem(ISourcePosition position, String message, int problemID) {
this.position = position;
this.message = message;
- id = IProblem.Uncategorized;
+ id = problemID;
}
/**
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Error.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -13,9 +13,13 @@
public class Error extends DefaultProblem {
public Error(ISourcePosition position, String message) {
- super(position, message);
+ this(position, message, -1);
}
+ public Error(ISourcePosition position, String message, int problemID) {
+ super(position, message, problemID);
+ }
+
public boolean isError() {
return true;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/ImmediateWarnings.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/ImmediateWarnings.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/ImmediateWarnings.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -25,11 +25,12 @@
if (message.startsWith("Useless")) {
return ;
}
- markerManager.addWarning(file, message, position.getStartLine(), position.getStartOffset(), position.getEndOffset());
+ Warning warning = new Warning(position, message);
+ markerManager.addProblem(file, warning);
}
public void warn(String message) {
- markerManager.addWarning(file, message);
+ warning(message);
}
public boolean isVerbose() {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -40,6 +40,7 @@
map.put(IMarker.LINE_NUMBER, new Integer(pos.getStartLine()));
map.put(IMarker.CHAR_START, new Integer(pos.getStartOffset()));
map.put(IMarker.CHAR_END, new Integer(pos.getEndOffset()));
+ map.put(IRubyModelMarker.ID, IProblem.Syntax);
marker.setAttributes(map);
} catch (CoreException e) {
RubyCore.log(e);
@@ -81,13 +82,14 @@
map.put(IMarker.LINE_NUMBER, new Integer(problem.getSourceLineNumber()));
map.put(IMarker.CHAR_START, new Integer(problem.getSourceStart()));
map.put(IMarker.CHAR_END, new Integer(problem.getSourceEnd()));
+ map.put(IRubyModelMarker.ID, problem.getID());
marker.setAttributes(map);
} catch (CoreException e) {
RubyCore.log(e);
}
}
- public static void createTasks(IResource underlyingResource, List tasks) throws CoreException {
+ public static void createTasks(IResource underlyingResource, List<TaskTag> tasks) throws CoreException {
for (Iterator iter = tasks.iterator(); iter.hasNext();) {
createTask(underlyingResource, (TaskTag) iter.next());
}
@@ -112,6 +114,7 @@
map.put(IMarker.TRANSIENT, new Boolean(false));
map.put(IMarker.CHAR_START, new Integer(task.getSourceStart()));
map.put(IMarker.CHAR_END, new Integer(task.getSourceEnd()));
+ map.put(IRubyModelMarker.ID, task.getID());
marker = resource.createMarker(IRubyModelMarker.TASK_MARKER);
marker.setAttributes(map);
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -14,7 +14,7 @@
private int priority;
public TaskTag(String message, int priority, int lineNumber, int start, int end) {
- super(new RdtPosition(lineNumber, start, end), message);
+ super(new RdtPosition(lineNumber, start, end), message, IProblem.Task);
this.priority = priority;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/Warning.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -13,9 +13,13 @@
public class Warning extends DefaultProblem {
public Warning(ISourcePosition position, String message) {
- super(position, message);
+ this(position, message, -1);
}
+ public Warning(ISourcePosition position, String message, int problemID) {
+ super(position, message, problemID);
+ }
+
public boolean isWarning() {
return true;
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -31,9 +31,9 @@
return;
IProblem problem;
if (value != null && value.equals(RubyCore.ERROR))
- problem = new Error(position, message);
+ problem = new Error(position, message, getProblemID());
else
- problem = new Warning(position, message);
+ problem = new Warning(position, message, getProblemID());
problemRequestor.acceptProblem(problem);
}
@@ -48,4 +48,8 @@
*/
abstract protected String getOptionKey();
+ protected int getProblemID() {
+ return IProblem.Uncategorized;
+ }
+
}
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamMarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamMarkerManager.java 2007-03-16 12:23:45 UTC (rev 2184)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/ShamMarkerManager.java 2007-03-16 13:19:35 UTC (rev 2185)
@@ -14,7 +14,9 @@
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.eclipse.shams.resources.ShamFile;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.core.parser.RdtPosition;
+import org.rubypeople.rdt.internal.core.parser.TaskTag;
import org.rubypeople.rdt.internal.core.util.ListUtil;
public class ShamMarkerManager implements IMarkerManager {
@@ -51,7 +53,7 @@
Assert.assertEquals("syntaxException", expectedSyntaxException, syntaxExceptionArg);
}
- public void createTasks(IFile file, List tasks) throws CoreException {
+ public void createTasks(IFile file, List<TaskTag> tasks) throws CoreException {
fileArg = file;
tasksArg = tasks;
}
@@ -94,5 +96,11 @@
syntaxExceptionArg = e;
}
-
+ public void addProblem(IFile file, IProblem problem) {
+ fileArg = file;
+ messageArg = problem.getMessage();
+ lineArg = problem.getSourceLineNumber();
+ startOffsetArg = problem.getSourceStart();
+ endOffsetArg = problem.getSourceEnd();
+ }
}
\ 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: <mir...@us...> - 2007-03-16 12:23:47
|
Revision: 2184
http://svn.sourceforge.net/rubyeclipse/?rev=2184&view=rev
Author: mirkostocker
Date: 2007-03-16 05:23:45 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
rename temp to local again.. I hope this were the last ones
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/InlineTempAction.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinetemp/TempInlinerTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinetemp/conditionchecks/InlineTempConditionTester.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertLocalToFieldRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineLocalRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalValueReplaceProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalVariableInliner.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertLocalToFieldPage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/SplitLocalPage.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineTempPage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/SplitTempPage.java
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -28,12 +28,12 @@
package org.rubypeople.rdt.refactoring.action;
-import org.rubypeople.rdt.refactoring.core.convertlocaltofield.ConvertTempToFieldRefactoring;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.ConvertLocalToFieldRefactoring;
public class ConvertTempToFieldAction extends WorkbenchWindowActionDelegate {
@Override
public void run() {
- run(ConvertTempToFieldRefactoring.class, ConvertTempToFieldRefactoring.NAME);
+ run(ConvertLocalToFieldRefactoring.class, ConvertLocalToFieldRefactoring.NAME);
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/InlineTempAction.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/InlineTempAction.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/InlineTempAction.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -30,13 +30,13 @@
package org.rubypeople.rdt.refactoring.action;
-import org.rubypeople.rdt.refactoring.core.inlinelocal.InlineTempRefactoring;
+import org.rubypeople.rdt.refactoring.core.inlinelocal.InlineLocalRefactoring;
public class InlineTempAction extends WorkbenchWindowActionDelegate {
@Override
public void run() {
- run(InlineTempRefactoring.class, InlineTempRefactoring.NAME);
+ run(InlineLocalRefactoring.class, InlineLocalRefactoring.NAME);
}
}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -33,13 +33,13 @@
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.actions.ActionGroup;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.core.convertlocaltofield.ConvertTempToFieldRefactoring;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.ConvertLocalToFieldRefactoring;
import org.rubypeople.rdt.refactoring.core.encapsulatefield.EncapsulateFieldRefactoring;
import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodRefactoring;
import org.rubypeople.rdt.refactoring.core.generateaccessors.GenerateAccessorsRefactoring;
import org.rubypeople.rdt.refactoring.core.generateconstructor.GenerateConstructorRefactoring;
import org.rubypeople.rdt.refactoring.core.inlineclass.InlineClassRefactoring;
-import org.rubypeople.rdt.refactoring.core.inlinelocal.InlineTempRefactoring;
+import org.rubypeople.rdt.refactoring.core.inlinelocal.InlineLocalRefactoring;
import org.rubypeople.rdt.refactoring.core.inlinemethod.InlineMethodRefactoring;
import org.rubypeople.rdt.refactoring.core.mergeclasspartsinfile.MergeClassPartsInFileRefactoring;
import org.rubypeople.rdt.refactoring.core.mergewithexternalclassparts.MergeWithExternalClassPartsRefactoring;
@@ -64,11 +64,11 @@
private IMenuManager getRefactorMenu(TextSelectionProvider selectionProvider) {
IMenuManager submenu = new MenuManager(Messages.RefactoringActionGroup);
- submenu.add(new RefactoringAction(ConvertTempToFieldRefactoring.class, ConvertTempToFieldRefactoring.NAME, selectionProvider));
+ submenu.add(new RefactoringAction(ConvertLocalToFieldRefactoring.class, ConvertLocalToFieldRefactoring.NAME, selectionProvider));
submenu.add(new RefactoringAction(EncapsulateFieldRefactoring.class, EncapsulateFieldRefactoring.NAME, selectionProvider));
submenu.add(new RefactoringAction(ExtractMethodRefactoring.class, ExtractMethodRefactoring.NAME, selectionProvider));
submenu.add(new RefactoringAction(InlineClassRefactoring.class, InlineClassRefactoring.NAME, selectionProvider));
- submenu.add(new RefactoringAction(InlineTempRefactoring.class, InlineTempRefactoring.NAME, selectionProvider));
+ submenu.add(new RefactoringAction(InlineLocalRefactoring.class, InlineLocalRefactoring.NAME, selectionProvider));
submenu.add(new RefactoringAction(InlineMethodRefactoring.class, InlineMethodRefactoring.NAME, selectionProvider));
submenu.add(new RefactoringAction(MergeClassPartsInFileRefactoring.class, MergeClassPartsInFileRefactoring.NAME, selectionProvider));
submenu.add(new RefactoringAction(MergeWithExternalClassPartsRefactoring.class, MergeWithExternalClassPartsRefactoring.NAME, selectionProvider));
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertLocalToFieldRefactoring.java (from rev 2183, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertLocalToFieldRefactoring.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertLocalToFieldRefactoring.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -0,0 +1,71 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
+
+import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
+import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
+import org.rubypeople.rdt.refactoring.ui.pages.ConvertLocalToFieldPage;
+import org.rubypeople.rdt.refactoring.ui.pages.ConverterPageParameters;
+
+public class ConvertLocalToFieldRefactoring extends RubyRefactoring {
+
+ public static final String NAME = Messages.ConvertLocalToFieldRefactoring_Name;
+
+ public ConvertLocalToFieldRefactoring(TextSelectionProvider selectionProvider) {
+ super(NAME);
+
+ LocalToFieldConfig config = new LocalToFieldConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
+ LocalToFieldConditionChecker checker = new LocalToFieldConditionChecker(config);
+
+ setRefactoringConditionChecker(checker);
+
+ if(checker.shouldPerform()) {
+ LocalToFieldConverter tempToFieldConverter = new LocalToFieldConverter(config);
+ setEditProvider(tempToFieldConverter);
+ ConverterPageParameters pageParameters = createPageParameters(tempToFieldConverter);
+ ConvertLocalToFieldPage page = new ConvertLocalToFieldPage(tempToFieldConverter, pageParameters);
+ pages.add(page);
+ }
+ }
+
+ private ConverterPageParameters createPageParameters(LocalToFieldConverter tempToFieldConverter) {
+ ConverterPageParameters pageParameters = new ConverterPageParameters();
+
+ if (tempToFieldConverter.isVariableInConstructor()) {
+ pageParameters.setInClassConstructorRadioEnabled(false);
+ }
+
+ if (!tempToFieldConverter.isInitializationExternalizable()) {
+ pageParameters.setInClassConstructorRadioEnabled(false);
+
+ }
+
+ return pageParameters;
+ }
+}
\ No newline at end of file
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -1,71 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
-
-import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
-import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.ui.pages.ConvertTempToFieldPage;
-import org.rubypeople.rdt.refactoring.ui.pages.ConverterPageParameters;
-
-public class ConvertTempToFieldRefactoring extends RubyRefactoring {
-
- public static final String NAME = Messages.ConvertLocalToFieldRefactoring_Name;
-
- public ConvertTempToFieldRefactoring(TextSelectionProvider selectionProvider) {
- super(NAME);
-
- LocalToFieldConfig config = new LocalToFieldConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
- LocalToFieldConditionChecker checker = new LocalToFieldConditionChecker(config);
-
- setRefactoringConditionChecker(checker);
-
- if(checker.shouldPerform()) {
- LocalToFieldConverter tempToFieldConverter = new LocalToFieldConverter(config);
- setEditProvider(tempToFieldConverter);
- ConverterPageParameters pageParameters = createPageParameters(tempToFieldConverter);
- ConvertTempToFieldPage page = new ConvertTempToFieldPage(tempToFieldConverter, pageParameters);
- pages.add(page);
- }
- }
-
- private ConverterPageParameters createPageParameters(LocalToFieldConverter tempToFieldConverter) {
- ConverterPageParameters pageParameters = new ConverterPageParameters();
-
- if (tempToFieldConverter.isVariableInConstructor()) {
- pageParameters.setInClassConstructorRadioEnabled(false);
- }
-
- if (!tempToFieldConverter.isInitializationExternalizable()) {
- pageParameters.setInClassConstructorRadioEnabled(false);
-
- }
-
- return pageParameters;
- }
-}
\ No newline at end of file
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineLocalRefactoring.java (from rev 2183, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempRefactoring.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineLocalRefactoring.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineLocalRefactoring.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -0,0 +1,56 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.inlinelocal;
+
+import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
+import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
+import org.rubypeople.rdt.refactoring.ui.pages.InlineLocalPage;
+
+public class InlineLocalRefactoring extends RubyRefactoring {
+
+ public static final String NAME = Messages.InlineLocalRefactoring_Name;
+
+ private LocalVariableInliner tempInliner;
+
+ public InlineLocalRefactoring(TextSelectionProvider selectionProvider) {
+ super(NAME);
+
+ InlineLocalConfig config = new InlineLocalConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
+ InlineLocalConditionChecker checker = new InlineLocalConditionChecker(config);
+ setRefactoringConditionChecker(checker);
+
+ if(checker.shouldPerform()) {
+ tempInliner = new LocalVariableInliner(config);
+ setEditProvider(tempInliner);
+ pages.add(new InlineLocalPage(config, tempInliner.getOccurrencesCount(), tempInliner.getSelectedItemName()));
+ }
+ }
+}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempRefactoring.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempRefactoring.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -1,56 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinelocal;
-
-import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
-import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.ui.pages.InlineTempPage;
-
-public class InlineTempRefactoring extends RubyRefactoring {
-
- public static final String NAME = Messages.InlineLocalRefactoring_Name;
-
- private TempInliner tempInliner;
-
- public InlineTempRefactoring(TextSelectionProvider selectionProvider) {
- super(NAME);
-
- InlineLocalConfig config = new InlineLocalConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
- InlineLocalConditionChecker checker = new InlineLocalConditionChecker(config);
- setRefactoringConditionChecker(checker);
-
- if(checker.shouldPerform()) {
- tempInliner = new TempInliner(config);
- setEditProvider(tempInliner);
- pages.add(new InlineTempPage(config, tempInliner.getOccurrencesCount(), tempInliner.getSelectedItemName()));
- }
- }
-}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalValueReplaceProvider.java (from rev 2183, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalValueReplaceProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalValueReplaceProvider.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -0,0 +1,118 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.inlinelocal;
+
+
+import org.jruby.ast.CallNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.visitor.rewriter.DefaultFormatHelper;
+import org.jruby.ast.visitor.rewriter.FormatHelper;
+import org.jruby.lexer.yacc.ISourcePosition;
+import org.rubypeople.rdt.refactoring.core.NodeProvider;
+import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
+
+public class LocalValueReplaceProvider extends ReplaceEditProvider {
+
+ private LocalNodeWrapper targetNode;
+
+ private LocalNodeWrapper inlinedNode;
+
+ private boolean addBrackets;
+
+ private InlineLocalConfig config;
+
+ public LocalValueReplaceProvider(LocalNodeWrapper targetNode, InlineLocalConfig config, boolean addBrackets) {
+ super(false);
+ this.config = config;
+ this.inlinedNode = config.getDefinitionNode();
+ this.targetNode = targetNode;
+ this.addBrackets = addBrackets;
+ }
+
+ @Override
+ protected int getOffsetLength() {
+ ISourcePosition replacePos = targetNode.getWrappedNode().getPosition();
+ return replacePos.getEndOffset() - replacePos.getStartOffset();
+ }
+
+ @Override
+ protected Node getEditNode(int offset, String document) {
+ return inlinedNode.getValueNode();
+ }
+
+ @Override
+ protected int getOffset(String document) {
+ return targetNode.getWrappedNode().getPosition().getStartOffset();
+ }
+
+ protected String getFormatedNode(String document) {
+ if(addBrackets) {
+ return '(' + super.getFormatedNode(document) + ')';
+ }
+ return super.getFormatedNode(document);
+ }
+
+ @Override
+ protected FormatHelper getFormatHelper() {
+ if(callNeedsBrackets()) {
+ return new DefaultFormatHelper() {
+
+ @Override
+ public String afterCallArguments() {
+ return ")";
+ }
+
+ @Override
+ public String beforeCallArguments() {
+ return "(";
+ }};
+ } else {
+ return super.getFormatHelper();
+ }
+ }
+
+ private boolean callNeedsBrackets() {
+ Node targetEnclosingNode = NodeProvider.findParentNode(config.getDocumentProvider().getActiveFileRootNode(), targetNode.getWrappedNode());
+ boolean isTargetEnclosingNodeCallNode = NodeUtil.nodeAssignableFrom(targetEnclosingNode, MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
+ if(NodeUtil.nodeAssignableFrom(targetEnclosingNode, CallNode.class)) {
+ isTargetEnclosingNodeCallNode &= !JRubyRefactoringUtils.isMathematicalExpression(targetEnclosingNode);
+ }
+ boolean isInlinedNodeCallNode = NodeUtil.nodeAssignableFrom(inlinedNode.getValueNode(), MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
+ if(NodeUtil.nodeAssignableFrom(inlinedNode.getValueNode(), CallNode.class)) {
+ isInlinedNodeCallNode &= !JRubyRefactoringUtils.isMathematicalExpression(inlinedNode.getValueNode());
+ }
+ return isTargetEnclosingNodeCallNode && isInlinedNodeCallNode;
+ }
+}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalVariableInliner.java (from rev 2183, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalVariableInliner.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/LocalVariableInliner.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -0,0 +1,112 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.inlinelocal;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.rubypeople.rdt.refactoring.core.SelectionInformation;
+import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodConditionChecker;
+import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodConfig;
+import org.rubypeople.rdt.refactoring.core.extractmethod.MethodExtractor;
+import org.rubypeople.rdt.refactoring.editprovider.DeleteEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.EditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.MultiEditProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
+
+public class LocalVariableInliner extends MultiEditProvider {
+
+ private InlineLocalConfig config;
+
+ private ExtractMethodConfig extractConfig;
+
+ public LocalVariableInliner(InlineLocalConfig config) {
+ this.config = config;
+ }
+
+ @Override
+ protected Collection<EditProvider> getEditProviders() {
+ ArrayList<EditProvider> editProviders = new ArrayList<EditProvider>();
+ editProviders.add(createDeleteEdit());
+
+ if (config.isReplaceTempWithQuery()) {
+ editProviders.add(extractMethodProvider());
+ for (LocalNodeWrapper currentLocalNode : config.getLocalOccurrences()) {
+ editProviders.add(replaceWithMethodCallProvider(currentLocalNode));
+ }
+ } else {
+ for (LocalNodeWrapper currentLocalNode : config.getLocalOccurrences()) {
+ editProviders.add(replaceWithValueProvider(currentLocalNode));
+ }
+ }
+ return editProviders;
+ }
+
+ private EditProvider replaceWithMethodCallProvider(LocalNodeWrapper targetNode) {
+ return new MethodCallReplaceProvider(targetNode, extractConfig.getHelper().getMethodCallNode());
+ }
+
+ private EditProvider replaceWithValueProvider(LocalNodeWrapper targetNode) {
+
+ boolean addBrackets = JRubyRefactoringUtils.isMathematicalExpression(config.getDefinitionNode().getValueNode());
+ return new LocalValueReplaceProvider(targetNode, config, addBrackets);
+ }
+
+ private EditProvider extractMethodProvider() {
+
+ int startPos = config.getDefinitionNode().getValueNode().getPosition().getStartOffset();
+ int endPos = config.getDefinitionNode().getValueNode().getPosition().getEndOffset();
+
+ extractConfig = new ExtractMethodConfig(config.getDocumentProvider(), new SelectionInformation(startPos, endPos, "")); //$NON-NLS-1$
+ new ExtractMethodConditionChecker(extractConfig);
+ MethodExtractor methodExtractor = new MethodExtractor(extractConfig);
+ extractConfig.getHelper().setMethodName(config.getNewMethodName());
+
+ return methodExtractor.getDefEdit();
+ }
+
+ private EditProvider createDeleteEdit() {
+ return new DeleteEditProvider(config.getDefinitionNode().getWrappedNode());
+ }
+
+ public int getOccurrencesCount() {
+ return config.getLocalOccurrences() == null ? 0 : config.getLocalOccurrences().size();
+ }
+
+ public String getSelectedItemName() {
+ return config.getSelectedItemName();
+ }
+
+ public InlineLocalConfig getConfig() {
+ return config;
+ }
+}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -1,112 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinelocal;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.rubypeople.rdt.refactoring.core.SelectionInformation;
-import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodConditionChecker;
-import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodConfig;
-import org.rubypeople.rdt.refactoring.core.extractmethod.MethodExtractor;
-import org.rubypeople.rdt.refactoring.editprovider.DeleteEditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.EditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.MultiEditProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
-
-public class TempInliner extends MultiEditProvider {
-
- private InlineLocalConfig config;
-
- private ExtractMethodConfig extractConfig;
-
- public TempInliner(InlineLocalConfig config) {
- this.config = config;
- }
-
- @Override
- protected Collection<EditProvider> getEditProviders() {
- ArrayList<EditProvider> editProviders = new ArrayList<EditProvider>();
- editProviders.add(createDeleteEdit());
-
- if (config.isReplaceTempWithQuery()) {
- editProviders.add(extractMethodProvider());
- for (LocalNodeWrapper currentLocalNode : config.getLocalOccurrences()) {
- editProviders.add(replaceWithMethodCallProvider(currentLocalNode));
- }
- } else {
- for (LocalNodeWrapper currentLocalNode : config.getLocalOccurrences()) {
- editProviders.add(replaceWithValueProvider(currentLocalNode));
- }
- }
- return editProviders;
- }
-
- private EditProvider replaceWithMethodCallProvider(LocalNodeWrapper targetNode) {
- return new MethodCallReplaceProvider(targetNode, extractConfig.getHelper().getMethodCallNode());
- }
-
- private EditProvider replaceWithValueProvider(LocalNodeWrapper targetNode) {
-
- boolean addBrackets = JRubyRefactoringUtils.isMathematicalExpression(config.getDefinitionNode().getValueNode());
- return new TempValueReplaceProvider(targetNode, config, addBrackets);
- }
-
- private EditProvider extractMethodProvider() {
-
- int startPos = config.getDefinitionNode().getValueNode().getPosition().getStartOffset();
- int endPos = config.getDefinitionNode().getValueNode().getPosition().getEndOffset();
-
- extractConfig = new ExtractMethodConfig(config.getDocumentProvider(), new SelectionInformation(startPos, endPos, "")); //$NON-NLS-1$
- new ExtractMethodConditionChecker(extractConfig);
- MethodExtractor methodExtractor = new MethodExtractor(extractConfig);
- extractConfig.getHelper().setMethodName(config.getNewMethodName());
-
- return methodExtractor.getDefEdit();
- }
-
- private EditProvider createDeleteEdit() {
- return new DeleteEditProvider(config.getDefinitionNode().getWrappedNode());
- }
-
- public int getOccurrencesCount() {
- return config.getLocalOccurrences() == null ? 0 : config.getLocalOccurrences().size();
- }
-
- public String getSelectedItemName() {
- return config.getSelectedItemName();
- }
-
- public InlineLocalConfig getConfig() {
- return config;
- }
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -1,118 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.inlinelocal;
-
-
-import org.jruby.ast.CallNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.visitor.rewriter.DefaultFormatHelper;
-import org.jruby.ast.visitor.rewriter.FormatHelper;
-import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.refactoring.core.NodeProvider;
-import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.MethodCallNodeWrapper;
-import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
-import org.rubypeople.rdt.refactoring.util.NodeUtil;
-
-public class TempValueReplaceProvider extends ReplaceEditProvider {
-
- private LocalNodeWrapper targetNode;
-
- private LocalNodeWrapper inlinedNode;
-
- private boolean addBrackets;
-
- private InlineLocalConfig config;
-
- public TempValueReplaceProvider(LocalNodeWrapper targetNode, InlineLocalConfig config, boolean addBrackets) {
- super(false);
- this.config = config;
- this.inlinedNode = config.getDefinitionNode();
- this.targetNode = targetNode;
- this.addBrackets = addBrackets;
- }
-
- @Override
- protected int getOffsetLength() {
- ISourcePosition replacePos = targetNode.getWrappedNode().getPosition();
- return replacePos.getEndOffset() - replacePos.getStartOffset();
- }
-
- @Override
- protected Node getEditNode(int offset, String document) {
- return inlinedNode.getValueNode();
- }
-
- @Override
- protected int getOffset(String document) {
- return targetNode.getWrappedNode().getPosition().getStartOffset();
- }
-
- protected String getFormatedNode(String document) {
- if(addBrackets) {
- return '(' + super.getFormatedNode(document) + ')';
- }
- return super.getFormatedNode(document);
- }
-
- @Override
- protected FormatHelper getFormatHelper() {
- if(callNeedsBrackets()) {
- return new DefaultFormatHelper() {
-
- @Override
- public String afterCallArguments() {
- return ")";
- }
-
- @Override
- public String beforeCallArguments() {
- return "(";
- }};
- } else {
- return super.getFormatHelper();
- }
- }
-
- private boolean callNeedsBrackets() {
- Node targetEnclosingNode = NodeProvider.findParentNode(config.getDocumentProvider().getActiveFileRootNode(), targetNode.getWrappedNode());
- boolean isTargetEnclosingNodeCallNode = NodeUtil.nodeAssignableFrom(targetEnclosingNode, MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
- if(NodeUtil.nodeAssignableFrom(targetEnclosingNode, CallNode.class)) {
- isTargetEnclosingNodeCallNode &= !JRubyRefactoringUtils.isMathematicalExpression(targetEnclosingNode);
- }
- boolean isInlinedNodeCallNode = NodeUtil.nodeAssignableFrom(inlinedNode.getValueNode(), MethodCallNodeWrapper.METHOD_CALL_NODE_CLASSES());
- if(NodeUtil.nodeAssignableFrom(inlinedNode.getValueNode(), CallNode.class)) {
- isInlinedNodeCallNode &= !JRubyRefactoringUtils.isMathematicalExpression(inlinedNode.getValueNode());
- }
- return isTargetEnclosingNodeCallNode && isInlinedNodeCallNode;
- }
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -30,7 +30,7 @@
import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.ui.pages.SplitTempPage;
+import org.rubypeople.rdt.refactoring.ui.pages.SplitLocalPage;
public class SplitTempRefactoring extends RubyRefactoring {
@@ -46,7 +46,7 @@
if(checker.shouldPerform()) {
SplitTempEditProvider splitTempEditProvider = new SplitTempEditProvider(config);
setEditProvider(splitTempEditProvider);
- pages.add(new SplitTempPage(splitTempEditProvider.getLocalUsages(), config.getDocumentProvider().getActiveFileContent(), splitTempEditProvider));
+ pages.add(new SplitLocalPage(splitTempEditProvider.getLocalUsages(), config.getDocumentProvider().getActiveFileContent(), splitTempEditProvider));
}
}
}
\ No newline at end of file
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertLocalToFieldPage.java (from rev 2183, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertLocalToFieldPage.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertLocalToFieldPage.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -0,0 +1,143 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.ui.pages;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.layout.RowLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.LocalToFieldConverter;
+import org.rubypeople.rdt.refactoring.ui.LabeledTextField;
+import org.rubypeople.rdt.refactoring.util.NameValidator;
+
+public class ConvertLocalToFieldPage extends RefactoringWizardPage {
+
+ private static final String TITLE = Messages.ConvertTempToFieldPage_ConvertLocalVariableToField;
+
+ private LocalToFieldConverter converter;
+
+ private ConverterPageParameters pageParameters;
+
+ public ConvertLocalToFieldPage(LocalToFieldConverter converter, ConverterPageParameters parameters) {
+ super(TITLE);
+ this.converter = converter;
+ this.pageParameters = parameters;
+ }
+
+ public void createControl(Composite parent) {
+
+ Composite control = new Composite(parent, SWT.None);
+ setControl(control);
+ GridLayout layout = new GridLayout();
+ layout.numColumns = 1;
+ layout.verticalSpacing = 8;
+ control.setLayout(layout);
+
+ final LabeledTextField labeledText = new LabeledTextField(control, Messages.ConvertTempToFieldPage_FieldName, converter.getLocalVarName());
+ GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
+ labeledText.setLayoutData(layoutData);
+ labeledText.getText().addModifyListener(new ModifyListener() {
+
+ public void modifyText(ModifyEvent e) {
+ String newName = labeledText.getText().getText();
+ converter.setNewName(newName);
+ checkInput(newName);
+ }
+
+ private void checkInput(String newName) {
+ if (NameValidator.isValidLocalVariableName(newName)) {
+ ConvertLocalToFieldPage.this.setMessage(null);
+ ConvertLocalToFieldPage.this.setPageComplete(true);
+ } else {
+ ConvertLocalToFieldPage.this.setMessage("'" + newName + Messages.ConvertTempToFieldPage_IsNotValid, ConvertLocalToFieldPage.ERROR); //$NON-NLS-1$
+ ConvertLocalToFieldPage.this.setPageComplete(false);
+ }
+
+ }
+ });
+
+ initInitializeRadioGroup(control);
+
+ final Button declareClassField = new Button(control, SWT.CHECK);
+ GridData checkData = new GridData();
+ declareClassField.setLayoutData(checkData);
+ declareClassField.setText(Messages.ConvertTempToFieldPage_DeclareAsClassField);
+ declareClassField.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ converter.setIsClassField(declareClassField.getSelection());
+ }
+ });
+ }
+
+ private void initInitializeRadioGroup(Composite control) {
+ Group initializeInGroup = new Group(control, SWT.NONE);
+ RowLayout radioGroupLayout = new RowLayout(SWT.VERTICAL);
+ initializeInGroup.setLayout(radioGroupLayout);
+ initializeInGroup.setText(Messages.ConvertTempToFieldPage_InitializeIn);
+
+ Button inCurrentMethod = new Button(initializeInGroup, SWT.RADIO);
+ inCurrentMethod.setText(Messages.ConvertTempToFieldPage_CurrentMethod);
+ inCurrentMethod.setEnabled(pageParameters.isInCurrentMethodRadioEnabled());
+ addRadioListener(inCurrentMethod, LocalToFieldConverter.INIT_IN_METHOD);
+ inCurrentMethod.setSelection(true);
+
+ Button inClassConstructor = new Button(initializeInGroup, SWT.RADIO);
+ inClassConstructor.setText(Messages.ConvertTempToFieldPage_ClassConstructor);
+ inClassConstructor.setEnabled(pageParameters.isInClassConstructorRadioEnabled());
+ addRadioListener(inClassConstructor, LocalToFieldConverter.INIT_IN_CONSTRUCTOR);
+
+ GridData groupData = new GridData(GridData.FILL_HORIZONTAL);
+ initializeInGroup.setLayoutData(groupData);
+ }
+
+ private void addRadioListener(Button button, final int initPlace) {
+ button.addSelectionListener(new SelectionListener() {
+
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+
+ public void widgetSelected(SelectionEvent e) {
+ converter.setInitPlace(initPlace);
+ }
+ });
+ }
+}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java 2007-03-16 12:18:37 UTC (rev 2183)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -1,143 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.ui.pages;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.layout.RowLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.rubypeople.rdt.refactoring.core.convertlocaltofield.LocalToFieldConverter;
-import org.rubypeople.rdt.refactoring.ui.LabeledTextField;
-import org.rubypeople.rdt.refactoring.util.NameValidator;
-
-public class ConvertTempToFieldPage extends RefactoringWizardPage {
-
- private static final String TITLE = Messages.ConvertTempToFieldPage_ConvertLocalVariableToField;
-
- private LocalToFieldConverter converter;
-
- private ConverterPageParameters pageParameters;
-
- public ConvertTempToFieldPage(LocalToFieldConverter converter, ConverterPageParameters parameters) {
- super(TITLE);
- this.converter = converter;
- this.pageParameters = parameters;
- }
-
- public void createControl(Composite parent) {
-
- Composite control = new Composite(parent, SWT.None);
- setControl(control);
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.verticalSpacing = 8;
- control.setLayout(layout);
-
- final LabeledTextField labeledText = new LabeledTextField(control, Messages.ConvertTempToFieldPage_FieldName, converter.getLocalVarName());
- GridData layoutData = new GridData(GridData.FILL_HORIZONTAL);
- labeledText.setLayoutData(layoutData);
- labeledText.getText().addModifyListener(new ModifyListener() {
-
- public void modifyText(ModifyEvent e) {
- String newName = labeledText.getText().getText();
- converter.setNewName(newName);
- checkInput(newName);
- }
-
- private void checkInput(String newName) {
- if (NameValidator.isValidLocalVariableName(newName)) {
- ConvertTempToFieldPage.this.setMessage(null);
- ConvertTempToFieldPage.this.setPageComplete(true);
- } else {
- ConvertTempToFieldPage.this.setMessage("'" + newName + Messages.ConvertTempToFieldPage_IsNotValid, ConvertTempToFieldPage.ERROR); //$NON-NLS-1$
- ConvertTempToFieldPage.this.setPageComplete(false);
- }
-
- }
- });
-
- initInitializeRadioGroup(control);
-
- final Button declareClassField = new Button(control, SWT.CHECK);
- GridData checkData = new GridData();
- declareClassField.setLayoutData(checkData);
- declareClassField.setText(Messages.ConvertTempToFieldPage_DeclareAsClassField);
- declareClassField.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- converter.setIsClassField(declareClassField.getSelection());
- }
- });
- }
-
- private void initInitializeRadioGroup(Composite control) {
- Group initializeInGroup = new Group(control, SWT.NONE);
- RowLayout radioGroupLayout = new RowLayout(SWT.VERTICAL);
- initializeInGroup.setLayout(radioGroupLayout);
- initializeInGroup.setText(Messages.ConvertTempToFieldPage_InitializeIn);
-
- Button inCurrentMethod = new Button(initializeInGroup, SWT.RADIO);
- inCurrentMethod.setText(Messages.ConvertTempToFieldPage_CurrentMethod);
- inCurrentMethod.setEnabled(pageParameters.isInCurrentMethodRadioEnabled());
- addRadioListener(inCurrentMethod, LocalToFieldConverter.INIT_IN_METHOD);
- inCurrentMethod.setSelection(true);
-
- Button inClassConstructor = new Button(initializeInGroup, SWT.RADIO);
- inClassConstructor.setText(Messages.ConvertTempToFieldPage_ClassConstructor);
- inClassConstructor.setEnabled(pageParameters.isInClassConstructorRadioEnabled());
- addRadioListener(inClassConstructor, LocalToFieldConverter.INIT_IN_CONSTRUCTOR);
-
- GridData groupData = new GridData(GridData.FILL_HORIZONTAL);
- initializeInGroup.setLayoutData(groupData);
- }
-
- private void addRadioListener(Button button, final int initPlace) {
- button.addSelectionListener(new SelectionListener() {
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- converter.setInitPlace(initPlace);
- }
- });
- }
-}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java (from rev 2183, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineTempPage.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineLocalPage.java 2007-03-16 12:23:45 UTC (rev 2184)
@@ -0,0 +1,158 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.ui.pages;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+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.Group;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.rubypeople.rdt.refactoring.core.inlinelocal.InlineLocalConfig;
+import org.rubypeople.rdt.refactoring.core.inlinelocal.InlineLocalRefactoring;
+import org.rubypeople.rdt.refac...
[truncated message content] |
|
From: <mir...@us...> - 2007-03-16 12:18:38
|
Revision: 2183
http://svn.sourceforge.net/rubyeclipse/?rev=2183&view=rev
Author: mirkostocker
Date: 2007-03-16 05:18:37 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
rename temp to local continued
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/messages.properties
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempInliner.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/TempValueReplaceProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/Messages.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/InlineTempPage.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/TempToFieldTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/conditionchecks/TempToFieldConditionTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinetemp/TempInlinerTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/inlinetemp/conditionchecks/InlineTempConditionTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/SplitTempTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/conditionchecks/SplitTempConditionTester.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConverter.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineLocalConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineLocalConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitLocalConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitLocalConfig.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/inlinelocal/InlineTempConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConfig.java
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -1,81 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
-
-import java.util.ArrayList;
-import java.util.Collection;
-
-import org.jruby.ast.Node;
-import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-
-public class Conversion extends ReplaceEditProvider {
-
- private LocalNodeWrapper localNode;
-
- public Conversion(LocalNodeWrapper localNode, String newName, boolean isClassField) {
- super(false);
- this.localNode = localNode;
- newName = ((isClassField) ? "@@" : "@") + newName; //$NON-NLS-1$ //$NON-NLS-2$
- Collection<LocalNodeWrapper> allLocalNodes = new ArrayList<LocalNodeWrapper>();
- allLocalNodes.add(localNode);
- allLocalNodes.addAll(LocalNodeWrapper.gatherLocalNodes(localNode.getWrappedNode()));
- replaceAllNames(allLocalNodes, LocalNodeWrapper.getLocalNodeName(localNode), newName);
- }
-
- private void replaceAllNames(Collection<LocalNodeWrapper> allLocalNodes, String orgName, String newName) {
- for (LocalNodeWrapper aktNode : allLocalNodes) {
- String aktNodeName = LocalNodeWrapper.getLocalNodeName(aktNode);
- if (aktNodeName.equals(orgName)) {
- setNodeName(aktNode, newName);
- }
- }
- }
-
- private void setNodeName(LocalNodeWrapper localNode, String newName) {
- localNode.setName(newName);
- }
-
- @Override
- protected int getOffsetLength() {
- return localNode.getWrappedNode().getPosition().getEndOffset() - getOffset(null);
- }
-
- @Override
- protected Node getEditNode(int offset, String document) {
- return localNode.getWrappedNode();
- }
-
- @Override
- protected int getOffset(String document) {
- return localNode.getWrappedNode().getPosition().getStartOffset();
- }
-}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -35,18 +35,18 @@
public class ConvertTempToFieldRefactoring extends RubyRefactoring {
- public static final String NAME = Messages.ConvertTempToFieldRefactoring_Name;
+ public static final String NAME = Messages.ConvertLocalToFieldRefactoring_Name;
public ConvertTempToFieldRefactoring(TextSelectionProvider selectionProvider) {
super(NAME);
- TempToFieldConfig config = new TempToFieldConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
- TempToFieldConditionChecker checker = new TempToFieldConditionChecker(config);
+ LocalToFieldConfig config = new LocalToFieldConfig(getDocumentProvider(), selectionProvider.getCarretPosition());
+ LocalToFieldConditionChecker checker = new LocalToFieldConditionChecker(config);
setRefactoringConditionChecker(checker);
if(checker.shouldPerform()) {
- TempToFieldConverter tempToFieldConverter = new TempToFieldConverter(config);
+ LocalToFieldConverter tempToFieldConverter = new LocalToFieldConverter(config);
setEditProvider(tempToFieldConverter);
ConverterPageParameters pageParameters = createPageParameters(tempToFieldConverter);
ConvertTempToFieldPage page = new ConvertTempToFieldPage(tempToFieldConverter, pageParameters);
@@ -54,7 +54,7 @@
}
}
- private ConverterPageParameters createPageParameters(TempToFieldConverter tempToFieldConverter) {
+ private ConverterPageParameters createPageParameters(LocalToFieldConverter tempToFieldConverter) {
ConverterPageParameters pageParameters = new ConverterPageParameters();
if (tempToFieldConverter.isVariableInConstructor()) {
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -1,80 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
-
-import org.jruby.ast.BlockNode;
-import org.jruby.ast.DefnNode;
-import org.jruby.ast.NewlineNode;
-import org.jruby.ast.Node;
-import org.rubypeople.rdt.refactoring.core.NodeFactory;
-import org.rubypeople.rdt.refactoring.editprovider.InsertEditProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-import org.rubypeople.rdt.refactoring.offsetprovider.AfterLastNodeInMethodOffsetProvider;
-import org.rubypeople.rdt.refactoring.offsetprovider.ConstructorOffsetProvider;
-import org.rubypeople.rdt.refactoring.offsetprovider.OffsetProvider;
-
-public class InitInConstructorConversion extends InsertEditProvider {
-
- private ClassNodeWrapper enclosingClassNode;
-
- private Node insertNode;
-
- public InitInConstructorConversion(LocalNodeWrapper originalNode, TempToFieldConfig config) {
- super(true);
- Conversion conversion = new Conversion(originalNode, config.getNewName(), config.isClassField());
- insertNode = conversion.getEditNode(0, null);
- enclosingClassNode = config.getEnclosingClassNode();
- }
-
- @Override
- protected int getOffset(String document) {
- OffsetProvider offsetProvider;
- if (enclosingClassNode.hasConstructor()) {
- offsetProvider = new AfterLastNodeInMethodOffsetProvider(enclosingClassNode.getConstructorNode(), document);
- } else {
- offsetProvider = new ConstructorOffsetProvider(enclosingClassNode, document);
- }
- return offsetProvider.getOffset();
-
- }
-
- @Override
- protected Node getInsertNode(int offset, String document) {
- BlockNode blockNode = NodeFactory.createBlockNode(true, !isNextLineEmpty(offset, document), insertNode);
- if (!enclosingClassNode.hasConstructor()) {
- DefnNode constructorNode = NodeFactory.createConstructor(blockNode);
- NewlineNode newlineNode = NodeFactory.createNewLineNode(constructorNode);
- blockNode = NodeFactory.createBlockNode(true, !isNextLineEmpty(offset, document), newlineNode);
- }
- return blockNode;
- }
-}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorEditProvider.java (from rev 2182, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorEditProvider.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -0,0 +1,80 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
+
+import org.jruby.ast.BlockNode;
+import org.jruby.ast.DefnNode;
+import org.jruby.ast.NewlineNode;
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.core.NodeFactory;
+import org.rubypeople.rdt.refactoring.editprovider.InsertEditProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.offsetprovider.AfterLastNodeInMethodOffsetProvider;
+import org.rubypeople.rdt.refactoring.offsetprovider.ConstructorOffsetProvider;
+import org.rubypeople.rdt.refactoring.offsetprovider.OffsetProvider;
+
+public class InitInConstructorEditProvider extends InsertEditProvider {
+
+ private ClassNodeWrapper enclosingClassNode;
+
+ private Node insertNode;
+
+ public InitInConstructorEditProvider(LocalNodeWrapper originalNode, LocalToFieldConfig config) {
+ super(true);
+ LocalToFieldEditProvider conversion = new LocalToFieldEditProvider(originalNode, config.getNewName(), config.isClassField());
+ insertNode = conversion.getEditNode(0, null);
+ enclosingClassNode = config.getEnclosingClassNode();
+ }
+
+ @Override
+ protected int getOffset(String document) {
+ OffsetProvider offsetProvider;
+ if (enclosingClassNode.hasConstructor()) {
+ offsetProvider = new AfterLastNodeInMethodOffsetProvider(enclosingClassNode.getConstructorNode(), document);
+ } else {
+ offsetProvider = new ConstructorOffsetProvider(enclosingClassNode, document);
+ }
+ return offsetProvider.getOffset();
+
+ }
+
+ @Override
+ protected Node getInsertNode(int offset, String document) {
+ BlockNode blockNode = NodeFactory.createBlockNode(true, !isNextLineEmpty(offset, document), insertNode);
+ if (!enclosingClassNode.hasConstructor()) {
+ DefnNode constructorNode = NodeFactory.createConstructor(blockNode);
+ NewlineNode newlineNode = NodeFactory.createNewLineNode(constructorNode);
+ blockNode = NodeFactory.createBlockNode(true, !isNextLineEmpty(offset, document), newlineNode);
+ }
+ return blockNode;
+ }
+}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConditionChecker.java (from rev 2182, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConditionChecker.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConditionChecker.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -0,0 +1,143 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
+
+import java.util.Collection;
+
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.DVarNode;
+import org.jruby.ast.IterNode;
+import org.jruby.ast.LocalAsgnNode;
+import org.jruby.ast.LocalVarNode;
+import org.jruby.ast.MethodDefNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.RootNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
+import org.rubypeople.rdt.refactoring.core.NodeProvider;
+import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
+import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
+import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.FieldNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
+
+public class LocalToFieldConditionChecker extends RefactoringConditionChecker {
+
+ private LocalToFieldConfig config;
+ private RootNode rootNode;
+
+ public LocalToFieldConditionChecker(LocalToFieldConfig config) {
+ super(config);
+ }
+
+ public void init(IRefactoringConfig configObj) {
+ config = (LocalToFieldConfig) configObj;
+ rootNode = config.getDocumentProvider().getActiveFileRootNode();
+ Node selectedNode = findSelectedNode(LocalAsgnNode.class, LocalVarNode.class, DVarNode.class, DAsgnNode.class);
+ if (selectedNode != null) {
+ config.setSelectedNode(new LocalNodeWrapper(selectedNode));
+ config.setEnclosingMethod((MethodDefNode) findSelectedNode(MethodDefNode.class));
+ config.setEnclosingClassNode(getClassNode());
+ }
+ }
+
+ private Node findSelectedNode(Class<?>... filterNodes) {
+ return SelectionNodeProvider.getSelectedNodeOfType(rootNode.getBodyNode(), config.getCaretPosition(), filterNodes);
+ }
+
+ private ClassNodeWrapper getClassNode() {
+ try {
+ return SelectionNodeProvider.getSelectedClassNode(rootNode, config.getCaretPosition());
+ } catch (NoClassNodeException e) {
+ return null;
+ }
+ }
+
+ @Override
+ public void checkFinalConditions() {
+ String fieldTypeName = (config.isClassField()) ? "Class" : "Instance"; //$NON-NLS-1$ //$NON-NLS-2$
+ for(FieldNodeWrapper aktField : config.getEnclosingClassNode().getFields()) {
+ if(checkFieldName(config.getNewName(), aktField.getNameWithoutAts(), fieldTypeName)) {
+ return;
+ }
+ }
+ }
+
+ private boolean checkFieldName(String newName, String aktNodeName, String fieldTypeName) {
+ if (newName.equals(aktNodeName)) {
+ addError(fieldTypeName + Messages.TempToFieldConditionChecker_FieldWithName + newName + Messages.TempToFieldConditionChecker_AlreadyExists);
+ return true;
+ }
+ return false;
+ }
+
+ @Override
+ public void checkInitialConditions() {
+
+ if (config.getSelectedNode() == null) {
+ addError(Messages.TempToFieldConditionChecker_NoLocalVarAtpos);
+ } else if (config.getEnclosingClassNode() == null) {
+ addError(Messages.TempToFieldConditionChecker_NoEnclosingClassToInsert);
+ } else if (config.getEnclosingMethod() == null) {
+ addError(Messages.TempToFieldConditionChecker_CannotConvertNonlocalVars);
+ } else if (JRubyRefactoringUtils.isParameter(LocalNodeWrapper.getLocalNodeName(config.getSelectedNode()), config.getEnclosingMethod())) {
+ addError(Messages.TempToFieldConditionChecker_CannotConvertMethodParameters);
+ } else if (isIterParameter()) {
+ addError(Messages.TempToFieldConditionChecker_CannotConvertBlockParameters);
+ }
+ }
+
+ private boolean isIterParameter() {
+ Collection<Node> allIterNodes = NodeProvider.getSubNodes(config.getEnclosingMethod(), IterNode.class);
+ for (Node aktNode : allIterNodes) {
+ IterNode aktIterNode = (IterNode) aktNode;
+ if (iterNodeContainsAsArg(aktIterNode, config.getSelectedNode())) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private boolean iterNodeContainsAsArg(IterNode iterNode, LocalNodeWrapper localNode) {
+ if (iterNode.getVarNode() == null) {
+ return false;
+ }
+ String localNodeName = LocalNodeWrapper.getLocalNodeName(localNode);
+ for (LocalNodeWrapper aktIterArg : LocalNodeWrapper.gatherLocalNodes(iterNode.getVarNode())) {
+ String aktIterArgName = LocalNodeWrapper.getLocalNodeName(aktIterArg);
+ if (aktIterArgName.equals(localNodeName)) {
+ return true;
+ }
+ }
+ return false;
+ }
+}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConfig.java (from rev 2182, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConfig.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConfig.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -0,0 +1,105 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
+
+import org.jruby.ast.MethodDefNode;
+import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
+import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+
+public class LocalToFieldConfig implements IRefactoringConfig {
+
+ private IDocumentProvider docProvider;
+ private int caretPosition;
+ private LocalNodeWrapper selectedNode;
+ private ClassNodeWrapper enclosingClassNode;
+ private MethodDefNode enclosingMethod;
+ private boolean classField;
+ private String newName;
+
+ public LocalToFieldConfig(IDocumentProvider docProvider, int caretPosition) {
+ this.docProvider = docProvider;
+ this.caretPosition = caretPosition;
+ }
+
+ public boolean isClassField() {
+ return classField;
+ }
+
+ public void setClassField(boolean classField) {
+ this.classField = classField;
+ }
+
+ public String getNewName() {
+ return newName;
+ }
+
+ public void setNewName(String newName) {
+ this.newName = newName;
+ }
+
+ public int getCaretPosition() {
+ return caretPosition;
+ }
+
+ public ClassNodeWrapper getEnclosingClassNode() {
+ return enclosingClassNode;
+ }
+
+ public void setEnclosingClassNode(ClassNodeWrapper enclosingClassNode) {
+ this.enclosingClassNode = enclosingClassNode;
+ }
+
+ public MethodDefNode getEnclosingMethod() {
+ return enclosingMethod;
+ }
+
+ public void setEnclosingMethod(MethodDefNode enclosingMethod) {
+ this.enclosingMethod = enclosingMethod;
+ }
+
+ public LocalNodeWrapper getSelectedNode() {
+ return selectedNode;
+ }
+
+ public void setSelectedNode(LocalNodeWrapper selectedItem) {
+ this.selectedNode = selectedItem;
+ }
+
+ public IDocumentProvider getDocumentProvider() {
+ return docProvider;
+ }
+
+ public void setDocumentProvider(IDocumentProvider doc) {
+ this.docProvider = doc;
+ }
+}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConverter.java (from rev 2182, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConverter.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldConverter.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -0,0 +1,204 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.jruby.ast.ClassVarNode;
+import org.jruby.ast.DAsgnNode;
+import org.jruby.ast.FixnumNode;
+import org.jruby.ast.InstVarNode;
+import org.jruby.ast.LocalAsgnNode;
+import org.jruby.ast.MethodDefNode;
+import org.jruby.ast.MultipleAsgnNode;
+import org.jruby.ast.Node;
+import org.jruby.ast.StrNode;
+import org.jruby.ast.VCallNode;
+import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
+import org.rubypeople.rdt.refactoring.editprovider.DeleteEditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.EditProvider;
+import org.rubypeople.rdt.refactoring.editprovider.MultiEditProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+import org.rubypeople.rdt.refactoring.util.Constants;
+import org.rubypeople.rdt.refactoring.util.NodeUtil;
+
+public class LocalToFieldConverter extends MultiEditProvider {
+
+ public static final int INIT_IN_METHOD = 1;
+
+ public static final int INIT_IN_CONSTRUCTOR = 2;
+
+ private int initPlace;
+
+ private Collection<LocalNodeWrapper> localNodes;
+
+ private LocalToFieldConfig config;
+
+ public LocalToFieldConverter(LocalToFieldConfig config) {
+ this.config = config;
+ config.setNewName(getLocalVarName());
+ localNodes = gatherLocalNodes();
+ }
+
+ private Collection<LocalNodeWrapper> gatherLocalNodes() {
+
+ Collection<Node> allNodes = gatherLocalNodes(NodeUtil.getBody(config.getEnclosingMethod()));
+ Collection<LocalNodeWrapper> allLocalNodes = LocalNodeWrapper.createLocalNodes(allNodes);
+
+ Collection<LocalNodeWrapper> affectedLocalNodes = new ArrayList<LocalNodeWrapper>();
+ String selectedNodeName = LocalNodeWrapper.getLocalNodeName(config.getSelectedNode());
+ for (LocalNodeWrapper aktLokalNode : allLocalNodes) {
+ String aktLokalNodeName = LocalNodeWrapper.getLocalNodeName(aktLokalNode);
+ if (selectedNodeName.equals(aktLokalNodeName)) {
+ affectedLocalNodes.add(aktLokalNode);
+ }
+ }
+ return affectedLocalNodes;
+ }
+
+ private Collection<Node> gatherLocalNodes(Node baseNode) {
+ ArrayList<Node> candidates = new ArrayList<Node>();
+
+ if (baseNode == null || baseNode instanceof MethodDefNode) {
+ return candidates;
+ }
+
+ for (Object o : baseNode.childNodes()) {
+ Node n = (Node) o;
+ if (NodeUtil.nodeAssignableFrom(n, LocalNodeWrapper.LOCAL_NODES_CLASSES)) {
+ candidates.add(n);
+ }
+ if (!NodeUtil.nodeAssignableFrom(n, DAsgnNode.class, LocalAsgnNode.class)) {
+ candidates.addAll(gatherLocalNodes(n));
+ }
+ }
+ return candidates;
+ }
+
+ @Override
+ protected Collection<EditProvider> getEditProviders() {
+ return getConversions(localNodes);
+ }
+
+ private Collection<EditProvider> getConversions(Collection<LocalNodeWrapper> localNodes) {
+ Map<LocalNodeWrapper, EditProvider> editProviderMap = new LinkedHashMap<LocalNodeWrapper, EditProvider>();
+ LocalNodeWrapper firstLocalNode = localNodes.toArray(new LocalNodeWrapper[localNodes.size()])[0];
+
+ for (LocalNodeWrapper aktLocalNode : localNodes) {
+ LocalToFieldEditProvider conversion = new LocalToFieldEditProvider(aktLocalNode, config.getNewName(), config.isClassField());
+ editProviderMap.put(aktLocalNode, conversion);
+ }
+ if (initPlace == INIT_IN_CONSTRUCTOR) {
+ editProviderMap.remove(firstLocalNode);
+ }
+ Collection<EditProvider> editProviders = new ArrayList<EditProvider>(editProviderMap.values());
+
+ if (initPlace == INIT_IN_CONSTRUCTOR) {
+ editProviders.add(new InitInConstructorEditProvider(firstLocalNode, config));
+ editProviders.add(new DeleteEditProvider(firstLocalNode.getWrappedNode()));
+ }
+
+ return editProviders;
+ }
+
+ public void setNewName(String newName) {
+ config.setNewName(newName);
+ }
+
+ public void setInitPlace(int initPlace) {
+ this.initPlace = initPlace;
+ }
+
+ public void setIsClassField(boolean isClassField) {
+ config.setClassField(isClassField);
+ }
+
+ public String getLocalVarName() {
+ return LocalNodeWrapper.getLocalNodeName(config.getSelectedNode());
+ }
+
+ private Node findSelectedNode(Class<?>... filterNodes) {
+ return SelectionNodeProvider.getSelectedNodeOfType(config.getDocumentProvider().getActiveFileRootNode(), config.getCaretPosition(), filterNodes);
+ }
+
+ boolean isInitializationExternalizable() {
+
+ if (config.getEnclosingMethod() == null) {
+ return false;
+ }
+
+ LocalNodeWrapper firstNodeInAST = getFirstLocalNodeWrapper();
+ if (firstNodeInAST == null) {
+ return false;
+ }
+
+ if (findSelectedNode(MultipleAsgnNode.class) != null) {
+ return false;
+ }
+
+ if (firstNodeInAST.getWrappedNode() instanceof LocalAsgnNode) {
+ LocalAsgnNode firstAssignment = (LocalAsgnNode) firstNodeInAST.getWrappedNode();
+ Node assignmentValue = firstAssignment.getValueNode();
+
+ return hasSameClass(assignmentValue, FixnumNode.class, StrNode.class, VCallNode.class, InstVarNode.class, ClassVarNode.class);
+ }
+ return false;
+ }
+
+ private boolean hasSameClass(Node assignmentValue, Class<?>... klasses) {
+
+ for (Class klass : klasses) {
+ if (assignmentValue.getClass().equals(klass)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ private LocalNodeWrapper getFirstLocalNodeWrapper() {
+
+ if (localNodes == null || localNodes.isEmpty()) {
+ return null;
+ }
+
+ return localNodes.toArray(new LocalNodeWrapper[localNodes.size()])[0];
+ }
+
+ boolean isVariableInConstructor() {
+ if (config.getEnclosingMethod() == null) {
+ return false;
+ }
+ return config.getEnclosingMethod().getName().equals(Constants.CONSTRUCTOR_NAME);
+ }
+}
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldEditProvider.java (from rev 2182, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java)
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldEditProvider.java (rev 0)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/LocalToFieldEditProvider.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -0,0 +1,81 @@
+/***** BEGIN LICENSE BLOCK *****
+ * Version: CPL 1.0/GPL 2.0/LGPL 2.1
+ *
+ * The contents of this file are subject to the Common Public
+ * License Version 1.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.eclipse.org/legal/cpl-v10.html
+ *
+ * Software distributed under the License is distributed on an "AS
+ * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
+ * implied. See the License for the specific language governing
+ * rights and limitations under the License.
+ *
+ * Copyright (C) 2006 Lukas Felber <lf...@hs...>
+ * Copyright (C) 2006 Mirko Stocker <me...@mi...>
+ * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
+ *
+ * Alternatively, the contents of this file may be used under the terms of
+ * either of the GNU General Public License Version 2 or later (the "GPL"),
+ * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+ * in which case the provisions of the GPL or the LGPL are applicable instead
+ * of those above. If you wish to allow use of your version of this file only
+ * under the terms of either the GPL or the LGPL, and not to allow others to
+ * use your version of this file under the terms of the CPL, indicate your
+ * decision by deleting the provisions above and replace them with the notice
+ * and other provisions required by the GPL or the LGPL. If you do not delete
+ * the provisions above, a recipient may use your version of this file under
+ * the terms of any one of the CPL, the GPL or the LGPL.
+ ***** END LICENSE BLOCK *****/
+
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.jruby.ast.Node;
+import org.rubypeople.rdt.refactoring.editprovider.ReplaceEditProvider;
+import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
+
+public class LocalToFieldEditProvider extends ReplaceEditProvider {
+
+ private LocalNodeWrapper localNode;
+
+ public LocalToFieldEditProvider(LocalNodeWrapper localNode, String newName, boolean isClassField) {
+ super(false);
+ this.localNode = localNode;
+ newName = ((isClassField) ? "@@" : "@") + newName; //$NON-NLS-1$ //$NON-NLS-2$
+ Collection<LocalNodeWrapper> allLocalNodes = new ArrayList<LocalNodeWrapper>();
+ allLocalNodes.add(localNode);
+ allLocalNodes.addAll(LocalNodeWrapper.gatherLocalNodes(localNode.getWrappedNode()));
+ replaceAllNames(allLocalNodes, LocalNodeWrapper.getLocalNodeName(localNode), newName);
+ }
+
+ private void replaceAllNames(Collection<LocalNodeWrapper> allLocalNodes, String orgName, String newName) {
+ for (LocalNodeWrapper aktNode : allLocalNodes) {
+ String aktNodeName = LocalNodeWrapper.getLocalNodeName(aktNode);
+ if (aktNodeName.equals(orgName)) {
+ setNodeName(aktNode, newName);
+ }
+ }
+ }
+
+ private void setNodeName(LocalNodeWrapper localNode, String newName) {
+ localNode.setName(newName);
+ }
+
+ @Override
+ protected int getOffsetLength() {
+ return localNode.getWrappedNode().getPosition().getEndOffset() - getOffset(null);
+ }
+
+ @Override
+ protected Node getEditNode(int offset, String document) {
+ return localNode.getWrappedNode();
+ }
+
+ @Override
+ protected int getOffset(String document) {
+ return localNode.getWrappedNode().getPosition().getStartOffset();
+ }
+}
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -3,9 +3,9 @@
import org.eclipse.osgi.util.NLS;
public class Messages extends NLS {
- private static final String BUNDLE_NAME = "org.rubypeople.rdt.refactoring.core.converttemptofield.messages"; //$NON-NLS-1$
+ private static final String BUNDLE_NAME = "org.rubypeople.rdt.refactoring.core.convertlocaltofield.messages"; //$NON-NLS-1$
- public static String ConvertTempToFieldRefactoring_Name;
+ public static String ConvertLocalToFieldRefactoring_Name;
public static String TempToFieldConditionChecker_AlreadyExists;
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -1,143 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
-
-import java.util.Collection;
-
-import org.jruby.ast.DAsgnNode;
-import org.jruby.ast.DVarNode;
-import org.jruby.ast.IterNode;
-import org.jruby.ast.LocalAsgnNode;
-import org.jruby.ast.LocalVarNode;
-import org.jruby.ast.MethodDefNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.RootNode;
-import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
-import org.rubypeople.rdt.refactoring.core.NodeProvider;
-import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
-import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
-import org.rubypeople.rdt.refactoring.exception.NoClassNodeException;
-import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.FieldNodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-import org.rubypeople.rdt.refactoring.util.JRubyRefactoringUtils;
-
-public class TempToFieldConditionChecker extends RefactoringConditionChecker {
-
- private TempToFieldConfig config;
- private RootNode rootNode;
-
- public TempToFieldConditionChecker(TempToFieldConfig config) {
- super(config);
- }
-
- public void init(IRefactoringConfig configObj) {
- config = (TempToFieldConfig) configObj;
- rootNode = config.getDocumentProvider().getActiveFileRootNode();
- Node selectedNode = findSelectedNode(LocalAsgnNode.class, LocalVarNode.class, DVarNode.class, DAsgnNode.class);
- if (selectedNode != null) {
- config.setSelectedNode(new LocalNodeWrapper(selectedNode));
- config.setEnclosingMethod((MethodDefNode) findSelectedNode(MethodDefNode.class));
- config.setEnclosingClassNode(getClassNode());
- }
- }
-
- private Node findSelectedNode(Class<?>... filterNodes) {
- return SelectionNodeProvider.getSelectedNodeOfType(rootNode.getBodyNode(), config.getCaretPosition(), filterNodes);
- }
-
- private ClassNodeWrapper getClassNode() {
- try {
- return SelectionNodeProvider.getSelectedClassNode(rootNode, config.getCaretPosition());
- } catch (NoClassNodeException e) {
- return null;
- }
- }
-
- @Override
- public void checkFinalConditions() {
- String fieldTypeName = (config.isClassField()) ? "Class" : "Instance"; //$NON-NLS-1$ //$NON-NLS-2$
- for(FieldNodeWrapper aktField : config.getEnclosingClassNode().getFields()) {
- if(checkFieldName(config.getNewName(), aktField.getNameWithoutAts(), fieldTypeName)) {
- return;
- }
- }
- }
-
- private boolean checkFieldName(String newName, String aktNodeName, String fieldTypeName) {
- if (newName.equals(aktNodeName)) {
- addError(fieldTypeName + Messages.TempToFieldConditionChecker_FieldWithName + newName + Messages.TempToFieldConditionChecker_AlreadyExists);
- return true;
- }
- return false;
- }
-
- @Override
- public void checkInitialConditions() {
-
- if (config.getSelectedNode() == null) {
- addError(Messages.TempToFieldConditionChecker_NoLocalVarAtpos);
- } else if (config.getEnclosingClassNode() == null) {
- addError(Messages.TempToFieldConditionChecker_NoEnclosingClassToInsert);
- } else if (config.getEnclosingMethod() == null) {
- addError(Messages.TempToFieldConditionChecker_CannotConvertNonlocalVars);
- } else if (JRubyRefactoringUtils.isParameter(LocalNodeWrapper.getLocalNodeName(config.getSelectedNode()), config.getEnclosingMethod())) {
- addError(Messages.TempToFieldConditionChecker_CannotConvertMethodParameters);
- } else if (isIterParameter()) {
- addError(Messages.TempToFieldConditionChecker_CannotConvertBlockParameters);
- }
- }
-
- private boolean isIterParameter() {
- Collection<Node> allIterNodes = NodeProvider.getSubNodes(config.getEnclosingMethod(), IterNode.class);
- for (Node aktNode : allIterNodes) {
- IterNode aktIterNode = (IterNode) aktNode;
- if (iterNodeContainsAsArg(aktIterNode, config.getSelectedNode())) {
- return true;
- }
- }
- return false;
- }
-
- private boolean iterNodeContainsAsArg(IterNode iterNode, LocalNodeWrapper localNode) {
- if (iterNode.getVarNode() == null) {
- return false;
- }
- String localNodeName = LocalNodeWrapper.getLocalNodeName(localNode);
- for (LocalNodeWrapper aktIterArg : LocalNodeWrapper.gatherLocalNodes(iterNode.getVarNode())) {
- String aktIterArgName = LocalNodeWrapper.getLocalNodeName(aktIterArg);
- if (aktIterArgName.equals(localNodeName)) {
- return true;
- }
- }
- return false;
- }
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -1,105 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
-
-import org.jruby.ast.MethodDefNode;
-import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
-import org.rubypeople.rdt.refactoring.documentprovider.IDocumentProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.ClassNodeWrapper;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-
-public class TempToFieldConfig implements IRefactoringConfig {
-
- private IDocumentProvider docProvider;
- private int caretPosition;
- private LocalNodeWrapper selectedNode;
- private ClassNodeWrapper enclosingClassNode;
- private MethodDefNode enclosingMethod;
- private boolean classField;
- private String newName;
-
- public TempToFieldConfig(IDocumentProvider docProvider, int caretPosition) {
- this.docProvider = docProvider;
- this.caretPosition = caretPosition;
- }
-
- public boolean isClassField() {
- return classField;
- }
-
- public void setClassField(boolean classField) {
- this.classField = classField;
- }
-
- public String getNewName() {
- return newName;
- }
-
- public void setNewName(String newName) {
- this.newName = newName;
- }
-
- public int getCaretPosition() {
- return caretPosition;
- }
-
- public ClassNodeWrapper getEnclosingClassNode() {
- return enclosingClassNode;
- }
-
- public void setEnclosingClassNode(ClassNodeWrapper enclosingClassNode) {
- this.enclosingClassNode = enclosingClassNode;
- }
-
- public MethodDefNode getEnclosingMethod() {
- return enclosingMethod;
- }
-
- public void setEnclosingMethod(MethodDefNode enclosingMethod) {
- this.enclosingMethod = enclosingMethod;
- }
-
- public LocalNodeWrapper getSelectedNode() {
- return selectedNode;
- }
-
- public void setSelectedNode(LocalNodeWrapper selectedItem) {
- this.selectedNode = selectedItem;
- }
-
- public IDocumentProvider getDocumentProvider() {
- return docProvider;
- }
-
- public void setDocumentProvider(IDocumentProvider doc) {
- this.docProvider = doc;
- }
-}
Deleted: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java 2007-03-16 12:11:02 UTC (rev 2182)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java 2007-03-16 12:18:37 UTC (rev 2183)
@@ -1,204 +0,0 @@
-/***** BEGIN LICENSE BLOCK *****
- * Version: CPL 1.0/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Common Public
- * License Version 1.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of
- * the License at http://www.eclipse.org/legal/cpl-v10.html
- *
- * Software distributed under the License is distributed on an "AS
- * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
- * implied. See the License for the specific language governing
- * rights and limitations under the License.
- *
- * Copyright (C) 2006 Lukas Felber <lf...@hs...>
- * Copyright (C) 2006 Mirko Stocker <me...@mi...>
- * Copyright (C) 2006 Thomas Corbat <tc...@hs...>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either of the GNU General Public License Version 2 or later (the "GPL"),
- * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the CPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the CPL, the GPL or the LGPL.
- ***** END LICENSE BLOCK *****/
-
-package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedHashMap;
-import java.util.Map;
-
-import org.jruby.ast.ClassVarNode;
-import org.jruby.ast.DAsgnNode;
-import org.jruby.ast.FixnumNode;
-import org.jruby.ast.InstVarNode;
-import org.jruby.ast.LocalAsgnNode;
-import org.jruby.ast.MethodDefNode;
-import org.jruby.ast.MultipleAsgnNode;
-import org.jruby.ast.Node;
-import org.jruby.ast.StrNode;
-import org.jruby.ast.VCallNode;
-import org.rubypeople.rdt.refactoring.core.SelectionNodeProvider;
-import org.rubypeople.rdt.refactoring.editprovider.DeleteEditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.EditProvider;
-import org.rubypeople.rdt.refactoring.editprovider.MultiEditProvider;
-import org.rubypeople.rdt.refactoring.nodewrapper.LocalNodeWrapper;
-import org.rubypeople.rdt.refactoring.util.Constants;
-import org.rubypeople.rdt.refactoring.util.NodeUtil;
-
-public class TempToFieldConverter extends MultiEditProvider {
-
- public static final int INIT_IN_METHOD = 1;
-
- public static final int INIT_IN_CONSTRUCTOR = 2;
-
- private int initPlace;
-
- private Collection<LocalNodeWrapper> localNodes;
-
- private TempToFieldConfig config;
-
- public TempToFieldConverter(TempToFieldConfig config) {
- this.config = config;
- config.setNewName(getLocalVarName());
- localNodes = gatherLocalNodes();
- }
-
- private Collection<LocalNodeWrapper> gatherLocalNodes() {
-
- Collection<Node> allNodes = gatherLocalNodes(NodeUtil.getBody(config.getEnclosingMethod()));
- Collection<LocalNodeWrapper> allLocalNodes = LocalNodeWrapper.createLocalNodes(allNodes);
-
- Collection<LocalNodeWrapper> affectedLocalNodes = new ArrayList<LocalNodeWrapper>();
- String selectedNodeName = LocalNodeWrapper.getLocalNodeName(config.getSelectedNode());
- for (LocalNodeWrapper aktLokalNode : allLocalNodes) {
- String aktLokalNodeName = LocalNodeWrapper.getLocalNodeName(aktLokalNode);
- if (selectedNodeName.equals(aktLokalNodeName)) {
- affectedLocalNodes.add(aktLokalNode);
- }
- }
- return affectedLocalNodes;
- }
-
- private Collection<Node> gatherLocalNodes(Node baseNode) {
- ArrayList<Node> candidates = new ArrayList<Node>();
-
- if (baseNode == null || baseNode instanceof MethodDefNode) {
- return candidates;
- }
-
- for (Object o : baseNode.childNodes()) {
- Node n = (Node) o;
- if (NodeUtil.nodeAssignableFrom(n, LocalNodeWrapper.LOCAL_NODES_CLASSES)) {
- candidates.add(n);
- }
- if (!NodeUtil.nodeAssignableFrom(n, DAsgnNode.class, LocalAsgnNode.class)) {
- candidates.addAll(gatherLocalNodes(n));
- }
- }
- return candidates;
- }
-
- @Override
- protected Collection<EditProvider> getEditProviders() {
- return getConversions(localNodes);
- }
-
- private Collection<EditProvider> getConversions(Collection<LocalNodeWrapper> localNodes) {
- Map<LocalNodeWrapper, EditProvider> editProviderMap = new LinkedHashMap<LocalNodeWrapper, EditProvider>();
- LocalNodeWrapper firstLocalNode = localNodes.toArray(new LocalNodeWrapper[localNodes.size()])[0];
-
- for (LocalNodeWrapper aktLocalNode : localNodes) {
- Conversion conversion = new Conversion(aktLocalNode, config.getNewName(), config.isClassField());
- editProviderMap.put(aktLocalNode, conversion);
- }
- if (initPlace == INIT_IN_CONSTRUCTOR) {
- editProviderMap.remove(firstLocalNode);
- }
- Collection<EditProvider> editProviders = new ArrayList<EditProvider>(editProviderMap.values());
-
- if (initPlace == INIT_IN_CONSTRUCTOR) {
- editProviders.add(new InitInConstructorConversion(firstLocalNode, config));
- editProviders.add(new DeleteEditProvider(firstLocalNode.getWrappedNode()));
- }
-
- return editProviders;
- }
-
- public void setNewName(String newName) {
- config.setNewName(newName);
- }
-
- public void setInitPlace(int initPlace) {
- this.initPlace = initPlace;
- }
-
- public void setIsClassField(boolean isClassField) {
- config.setClassField(isClassField);
- }
-
- public String getLocalVarName() {
- return LocalNodeWrapper.getLocalNodeName(config.getSelectedNode());
- }
-
- private Node findSelectedNode(Class<?>... filterN...
[truncated message content] |
|
From: <mir...@us...> - 2007-03-16 12:11:05
|
Revision: 2182
http://svn.sourceforge.net/rubyeclipse/?rev=2182&view=rev
Author: mirkostocker
Date: 2007-03-16 05:11:02 -0700 (Fri, 16 Mar 2007)
Log Message:
-----------
rename temp to local
Modified Paths:
--------------
trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/SplitTempAction.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ILocalVarFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ISplittedNamesReceiver.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ISplittedVariableRenamer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/LocalVarFinder.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/LocalVarUsage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/Messages.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConditionChecker.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConfig.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempEditProvider.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplittedVariableRenamer.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/SplitTempPage.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/TempToFieldTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/conditionchecks/TempToFieldConditionTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/SplitTempTester.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_LocalVarFinder.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_SplittedVariableRenamer.java
trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/conditionchecks/SplitTempConditionTester.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/
Removed Paths:
-------------
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/
trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/
Modified: trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/META-INF/MANIFEST.MF 2007-03-16 12:11:02 UTC (rev 2182)
@@ -10,7 +10,7 @@
org.rubypeople.rdt.refactoring.action,
org.rubypeople.rdt.refactoring.classnodeprovider,
org.rubypeople.rdt.refactoring.core,
- org.rubypeople.rdt.refactoring.core.converttemptofield,
+ org.rubypeople.rdt.refactoring.core.convertlocaltofield,
org.rubypeople.rdt.refactoring.core.encapsulatefield,
org.rubypeople.rdt.refactoring.core.extractmethod,
org.rubypeople.rdt.refactoring.core.formatsource,
@@ -32,7 +32,7 @@
org.rubypeople.rdt.refactoring.core.renamelocal,
org.rubypeople.rdt.refactoring.core.renamemethod,
org.rubypeople.rdt.refactoring.core.renamemethod.methoditems,
- org.rubypeople.rdt.refactoring.core.splittemp,
+ org.rubypeople.rdt.refactoring.core.splitlocal,
org.rubypeople.rdt.refactoring.documentprovider,
org.rubypeople.rdt.refactoring.editprovider,
org.rubypeople.rdt.refactoring.exception,
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/ConvertTempToFieldAction.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -28,7 +28,7 @@
package org.rubypeople.rdt.refactoring.action;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.ConvertTempToFieldRefactoring;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.ConvertTempToFieldRefactoring;
public class ConvertTempToFieldAction extends WorkbenchWindowActionDelegate {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/RefactoringActionGroup.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -33,7 +33,7 @@
import org.eclipse.jface.action.Separator;
import org.eclipse.ui.actions.ActionGroup;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.ConvertTempToFieldRefactoring;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.ConvertTempToFieldRefactoring;
import org.rubypeople.rdt.refactoring.core.encapsulatefield.EncapsulateFieldRefactoring;
import org.rubypeople.rdt.refactoring.core.extractmethod.ExtractMethodRefactoring;
import org.rubypeople.rdt.refactoring.core.generateaccessors.GenerateAccessorsRefactoring;
@@ -48,7 +48,7 @@
import org.rubypeople.rdt.refactoring.core.overridemethod.OverrideMethodRefactoring;
import org.rubypeople.rdt.refactoring.core.pushdown.PushDownRefactoring;
import org.rubypeople.rdt.refactoring.core.rename.RenameRefactoring;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempRefactoring;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempRefactoring;
public class RefactoringActionGroup extends ActionGroup {
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/SplitTempAction.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/SplitTempAction.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/action/SplitTempAction.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -30,7 +30,7 @@
package org.rubypeople.rdt.refactoring.action;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempRefactoring;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempRefactoring;
public class SplitTempAction extends WorkbenchWindowActionDelegate {
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield (from rev 2181, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield)
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/Conversion.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Conversion.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -28,7 +28,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import java.util.ArrayList;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/ConvertTempToFieldRefactoring.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/ConvertTempToFieldRefactoring.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/InitInConstructorConversion.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/InitInConstructorConversion.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -28,7 +28,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import org.jruby.ast.BlockNode;
import org.jruby.ast.DefnNode;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/Messages.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/Messages.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -1,4 +1,4 @@
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import org.eclipse.osgi.util.NLS;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConditionChecker.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConditionChecker.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -28,7 +28,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConfig.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConfig.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -28,7 +28,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import org.jruby.ast.MethodDefNode;
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/converttemptofield/TempToFieldConverter.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/convertlocaltofield/TempToFieldConverter.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -28,7 +28,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.converttemptofield;
+package org.rubypeople.rdt.refactoring.core.convertlocaltofield;
import java.util.ArrayList;
import java.util.Collection;
Copied: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal (from rev 2181, trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp)
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ILocalVarFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/ILocalVarFinder.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ILocalVarFinder.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ISplittedNamesReceiver.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/ISplittedNamesReceiver.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ISplittedNamesReceiver.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
public interface ISplittedNamesReceiver {
public void setNewNames(String[] names);
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ISplittedVariableRenamer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/ISplittedVariableRenamer.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/ISplittedVariableRenamer.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/LocalVarFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/LocalVarFinder.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/LocalVarFinder.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import java.util.ArrayList;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/LocalVarUsage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/LocalVarUsage.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/LocalVarUsage.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import org.jruby.ast.AssignableNode;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/Messages.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/Messages.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/Messages.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -1,4 +1,4 @@
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import org.eclipse.osgi.util.NLS;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConditionChecker.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConditionChecker.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConditionChecker.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import org.rubypeople.rdt.refactoring.core.IRefactoringConfig;
import org.rubypeople.rdt.refactoring.core.RefactoringConditionChecker;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConfig.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempConfig.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempConfig.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempEditProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempEditProvider.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempEditProvider.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplitTempRefactoring.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplitTempRefactoring.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import org.rubypeople.rdt.refactoring.core.RubyRefactoring;
import org.rubypeople.rdt.refactoring.core.TextSelectionProvider;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplittedVariableRenamer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splittemp/SplittedVariableRenamer.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/core/splitlocal/SplittedVariableRenamer.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -26,7 +26,7 @@
* the terms of any one of the CPL, the GPL or the LGPL.
***** END LICENSE BLOCK *****/
-package org.rubypeople.rdt.refactoring.core.splittemp;
+package org.rubypeople.rdt.refactoring.core.splitlocal;
import java.util.ArrayList;
import java.util.Collection;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/ConvertTempToFieldPage.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -41,7 +41,7 @@
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConverter;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConverter;
import org.rubypeople.rdt.refactoring.ui.LabeledTextField;
import org.rubypeople.rdt.refactoring.util.NameValidator;
Modified: trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/SplitTempPage.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/SplitTempPage.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring/src/org/rubypeople/rdt/refactoring/ui/pages/SplitTempPage.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -43,9 +43,9 @@
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
-import org.rubypeople.rdt.refactoring.core.splittemp.ISplittedNamesReceiver;
-import org.rubypeople.rdt.refactoring.core.splittemp.LocalVarUsage;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempRefactoring;
+import org.rubypeople.rdt.refactoring.core.splitlocal.ISplittedNamesReceiver;
+import org.rubypeople.rdt.refactoring.core.splitlocal.LocalVarUsage;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempRefactoring;
import org.rubypeople.rdt.refactoring.ui.RdtCodeViewer;
import org.rubypeople.rdt.refactoring.util.NameValidator;
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/TempToFieldTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/TempToFieldTester.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/TempToFieldTester.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -34,9 +34,9 @@
import java.io.IOException;
import org.eclipse.jface.text.BadLocationException;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConditionChecker;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConfig;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConverter;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConditionChecker;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConfig;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConverter;
import org.rubypeople.rdt.refactoring.tests.FilePropertyData;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
import org.rubypeople.rdt.refactoring.tests.RefactoringTestCase;
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/conditionchecks/TempToFieldConditionTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/conditionchecks/TempToFieldConditionTester.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/converttemptofield/conditionchecks/TempToFieldConditionTester.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -33,9 +33,9 @@
import java.io.FileNotFoundException;
import java.io.IOException;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConditionChecker;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConfig;
-import org.rubypeople.rdt.refactoring.core.converttemptofield.TempToFieldConverter;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConditionChecker;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConfig;
+import org.rubypeople.rdt.refactoring.core.convertlocaltofield.TempToFieldConverter;
import org.rubypeople.rdt.refactoring.tests.FilePropertyData;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
import org.rubypeople.rdt.refactoring.tests.RefactoringConditionTestCase;
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/SplitTempTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/SplitTempTester.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/SplitTempTester.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -32,9 +32,9 @@
import java.io.IOException;
import org.eclipse.jface.text.BadLocationException;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempConditionChecker;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempConfig;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempEditProvider;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempConditionChecker;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempConfig;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempEditProvider;
import org.rubypeople.rdt.refactoring.tests.FileTestCase;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_LocalVarFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_LocalVarFinder.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_LocalVarFinder.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -34,8 +34,8 @@
import junit.framework.TestCase;
-import org.rubypeople.rdt.refactoring.core.splittemp.LocalVarFinder;
-import org.rubypeople.rdt.refactoring.core.splittemp.LocalVarUsage;
+import org.rubypeople.rdt.refactoring.core.splitlocal.LocalVarFinder;
+import org.rubypeople.rdt.refactoring.core.splitlocal.LocalVarUsage;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
public class TC_LocalVarFinder extends TestCase {
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_SplittedVariableRenamer.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_SplittedVariableRenamer.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/TC_SplittedVariableRenamer.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -39,9 +39,9 @@
import org.jruby.ast.LocalAsgnNode;
import org.jruby.ast.LocalVarNode;
import org.rubypeople.rdt.refactoring.core.renamelocal.SingleLocalVariableEdit;
-import org.rubypeople.rdt.refactoring.core.splittemp.LocalVarFinder;
-import org.rubypeople.rdt.refactoring.core.splittemp.LocalVarUsage;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplittedVariableRenamer;
+import org.rubypeople.rdt.refactoring.core.splitlocal.LocalVarFinder;
+import org.rubypeople.rdt.refactoring.core.splitlocal.LocalVarUsage;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplittedVariableRenamer;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
public class TC_SplittedVariableRenamer extends TestCase {
Modified: trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/conditionchecks/SplitTempConditionTester.java
===================================================================
--- trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/conditionchecks/SplitTempConditionTester.java 2007-03-15 16:01:31 UTC (rev 2181)
+++ trunk/org.rubypeople.rdt.refactoring.tests/src/org/rubypeople/rdt/refactoring/tests/core/splittemp/conditionchecks/SplitTempConditionTester.java 2007-03-16 12:11:02 UTC (rev 2182)
@@ -31,9 +31,9 @@
import java.io.FileNotFoundException;
import java.io.IOException;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempConditionChecker;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempConfig;
-import org.rubypeople.rdt.refactoring.core.splittemp.SplitTempEditProvider;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempConditionChecker;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempConfig;
+import org.rubypeople.rdt.refactoring.core.splitlocal.SplitTempEditProvider;
import org.rubypeople.rdt.refactoring.tests.FilePropertyData;
import org.rubypeople.rdt.refactoring.tests.FileTestData;
import org.rubypeople.rdt.refactoring.tests.RefactoringConditionTestCase;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-15 16:01:35
|
Revision: 2181
http://svn.sourceforge.net/rubyeclipse/?rev=2181&view=rev
Author: cawilliams
Date: 2007-03-15 09:01:31 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
handle comment hits eof
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-15 15:50:40 UTC (rev 2180)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-15 16:01:31 UTC (rev 2181)
@@ -116,8 +116,13 @@
}
fSavedToken = returnValue;
fSavedOffset = oldOffset + tokenLength;
- if (!isEOF) fSavedLength = getOffset() - fSavedOffset;
- else fSavedLength = 0;
+ if (!isEOF) {
+ fSavedLength = getOffset() - fSavedOffset;
+ } else {
+ fSavedOffset--;
+ tokenLength -= 2;
+ fSavedLength = 0;
+ }
lastWasComment = true;
return getToken(IRubyColorConstants.RUBY_SINGLE_LINE_COMMENT);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-15 15:51:01
|
Revision: 2180
http://svn.sourceforge.net/rubyeclipse/?rev=2180&view=rev
Author: cawilliams
Date: 2007-03-15 08:50:40 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
handle syntax coloring for symbols better now...
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-15 14:41:39 UTC (rev 2179)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyTokenScanner.java 2007-03-15 15:50:40 UTC (rev 2180)
@@ -43,6 +43,7 @@
private int oldOffset;
private boolean isInRegexp;
private boolean isInString;
+ private boolean isInSymbol;
private RubyParserResult result;
private int origOffset;
private int origLength;
@@ -51,7 +52,6 @@
private IToken fSavedToken = null;
private int fSavedLength = -1;
private int fSavedOffset = -1;
-
private boolean lastWasComment;
public RubyTokenScanner(IColorManager manager, IPreferenceStore store) {
@@ -112,11 +112,8 @@
CommentNode comment;
while (!comments.isEmpty()) {
comment = (CommentNode) comments.remove(0);
- // Grab comment and add it's length to our running tally
tokenLength += comment.getContent().length() + 1;
}
- // FIXME What if we have two lines of comments in a row?
-// tokenLength = comment.getContent().length() + 1;
fSavedToken = returnValue;
fSavedOffset = oldOffset + tokenLength;
if (!isEOF) fSavedLength = getOffset() - fSavedOffset;
@@ -145,6 +142,8 @@
@Override
public Token getToken(String key) {
+ if (isInSymbol)
+ return super.getToken(IRubyColorConstants.RUBY_SYMBOL);
if (isInRegexp)
return super.getToken(IRubyColorConstants.RUBY_REGEXP);
if (isInString)
@@ -153,10 +152,26 @@
}
private IToken token(int i) {
+ if (isInSymbol) {
+ if ((i == Tokens.tAREF) || (i == Tokens.tASET) || (i == Tokens.tIDENTIFIER)
+ || (i == Tokens.tIVAR) || (i == Tokens.tCVAR) || (i == Tokens.tMINUS)
+ || (i == Tokens.tPLUS) || (i == Tokens.tPIPE) || (i == Tokens.tCARET)
+ || (i == Tokens.tLT) || (i == Tokens.tGT) || (i == Tokens.tAMPER)
+ || (i == Tokens.tSTAR2) || (i == Tokens.tDIVIDE) || (i == Tokens.tPERCENT)
+ || (i == Tokens.tBACK_REF2) || (i == Tokens.tTILDE)) {
+ isInSymbol = false;
+ return getToken(IRubyColorConstants.RUBY_SYMBOL);
+ }
+ if (i == Tokens.tASSOC || i == 44 /* ',' */) {
+ isInSymbol = false;
+ return getToken(IRubyColorConstants.RUBY_DEFAULT);
+ }
+ }
if (i >= 257 && i <= 303)
return getToken(IRubyColorConstants.RUBY_KEYWORD);
switch (i) {
case Tokens.tSYMBEG:
+ isInSymbol = true;
return getToken(IRubyColorConstants.RUBY_SYMBOL);
case Tokens.tGVAR:
return getToken(IRubyColorConstants.RUBY_GLOBAL);
@@ -199,6 +214,7 @@
if (offset == 0) {
isInRegexp = false;
isInString = false;
+ isInSymbol = false;
}
try {
contents = document.get(offset, length);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-15 14:41:40
|
Revision: 2179
http://svn.sourceforge.net/rubyeclipse/?rev=2179&view=rev
Author: cawilliams
Date: 2007-03-15 07:41:39 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-03-15 14:00:55 UTC (rev 2178)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-03-15 14:41:39 UTC (rev 2179)
@@ -34,6 +34,31 @@
public interface IProblem {
int Uncategorized = 0;
+
+ /**
+ * Problem Categories
+ * The high bits of a problem ID contains information about the category of a problem.
+ * For example, (problemID & TypeRelated) != 0, indicates that this problem is type related.
+ *
+ * A problem category can help to implement custom problem filters. Indeed, when numerous problems
+ * are listed, focusing on import related problems first might be relevant.
+ *
+ * When a problem is tagged as Internal, it means that no change other than a local source code change
+ * can fix the corresponding problem. A type related problem could be addressed by changing the type
+ * involved in it.
+ */
+ int TypeRelated = 0x01000000;
+ int FieldRelated = 0x02000000;
+ int MethodRelated = 0x04000000;
+ int ConstructorRelated = 0x08000000;
+ int ImportRelated = 0x10000000;
+ int Internal = 0x20000000;
+ int Syntax = 0x40000000;
+
+ /**
+ * Mask to use in order to filter out the category portion of the problem ID.
+ */
+ int IgnoreCategoriesMask = 0xFFFFFF;
/**
* Returns the problem id
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-15 14:00:56
|
Revision: 2178
http://svn.sourceforge.net/rubyeclipse/?rev=2178&view=rev
Author: cawilliams
Date: 2007-03-15 07:00:55 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
apply Mirko's tweak to my solution with a little twist, use a StringBuffer rathe rthan create a new document, manipulate it and then grab it's contents.
Now method definitions should get closed when they're outside a class/module.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-03-15 12:46:53 UTC (rev 2177)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-03-15 14:00:55 UTC (rev 2178)
@@ -133,12 +133,21 @@
RubyPlugin.log(e1);
}
+ RubyParser parser = new RubyParser();
try {
- RubyParser parser = new RubyParser();
parser.parse(d.get());
} catch (SyntaxException e) {
String msg = e.getMessage();
- return msg.contains("expecting") && (msg.contains("kEND") || msg.contains("kTHEN"));
+ if (msg.contains("expecting") && (msg.contains("kEND") || msg.contains("kTHEN")))
+ return true;
+ try {
+ StringBuffer buffer = new StringBuffer(d.get());
+ buffer.insert(offset, "\n" + BLOCK_CLOSER);
+ parser.parse(buffer.toString());
+ } catch (SyntaxException syntaxException) {
+ return false;
+ }
+ return true;
}
return false;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-15 12:47:29
|
Revision: 2177
http://svn.sourceforge.net/rubyeclipse/?rev=2177&view=rev
Author: cawilliams
Date: 2007-03-15 05:46:53 -0700 (Thu, 15 Mar 2007)
Log Message:
-----------
Revert some of Mirko's changes and merge some into my own solution for closing blocks. Block closing
(and auto-indenting) are now handled by RubyAutoIndentStrategy, which is set in RubySourceViewerConfiguration.
There's a way to toggle turning it on and off in the preferences Ui for "Ruby -> Typing".
By default it is turned on.
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.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/text/RubyIndenter.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-03-14 20:52:14 UTC (rev 2176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java 2007-03-15 12:46:53 UTC (rev 2177)
@@ -127,8 +127,6 @@
private final static String CLOSE_BRACKETS= PreferenceConstants.EDITOR_CLOSE_BRACKETS;
/** Preference key for automatically closing braces */
private final static String CLOSE_BRACES= PreferenceConstants.EDITOR_CLOSE_BRACES;
- /** Preference key for automatically 'end'ing statements */
- private final static String END_STATEMENTS= PreferenceConstants.EDITOR_END_STATEMENTS;
/** Preference key for code formatter tab size */
private final static String CODE_FORMATTER_TAB_SIZE= DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE;
/** Preference key for inserting spaces rather than tabs */
@@ -178,7 +176,6 @@
private FoldingActionGroup fFoldingGroup;
private BracketInserter fBracketInserter = new BracketInserter();
- private EndInserter fEndInserter = new EndInserter();
private CompositeActionGroup fActionGroups;
private CompositeActionGroup fContextMenuGroup;
@@ -312,13 +309,10 @@
boolean closeBrackets= preferenceStore.getBoolean(CLOSE_BRACKETS);
boolean closeBraces= preferenceStore.getBoolean(CLOSE_BRACES);
boolean closeStrings= preferenceStore.getBoolean(CLOSE_STRINGS);
- boolean endStatements= preferenceStore.getBoolean(END_STATEMENTS);
fBracketInserter.setCloseBracketsEnabled(closeBrackets);
fBracketInserter.setCloseBracesEnabled(closeBraces);
fBracketInserter.setCloseStringsEnabled(closeStrings);
- fEndInserter.setEndStatementsEnabled(endStatements);
((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fBracketInserter);
- ((ITextViewerExtension) sourceViewer).prependVerifyKeyListener(fEndInserter);
}
}
@@ -626,7 +620,6 @@
ISourceViewer sourceViewer= getSourceViewer();
if (sourceViewer instanceof ITextViewerExtension) {
((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fBracketInserter);
- ((ITextViewerExtension) sourceViewer).removeVerifyKeyListener(fEndInserter);
}
if (fProjectionModelUpdater != null) {
@@ -769,12 +762,7 @@
if (CLOSE_STRINGS.equals(property)) {
fBracketInserter.setCloseStringsEnabled(getPreferenceStore().getBoolean(property));
return;
- }
-
- if (END_STATEMENTS.equals(property)) {
- fEndInserter.setEndStatementsEnabled(getPreferenceStore().getBoolean(property));
- return;
- }
+ }
AdaptedSourceViewer sourceViewer= (AdaptedSourceViewer) getSourceViewer();
if (sourceViewer == null)
@@ -1057,68 +1045,6 @@
}
}
-
- private class EndInserter implements VerifyKeyListener {
-
- /** Pattern to match lines with statements that can be completed with 'end' */
- private final Pattern openBlockPattern =
- Pattern.compile("(\\s*)" + // Capture the space before the statement, we need it to indent 'end'
- "((def|class|module)\\s.*" + // Either we look for one of these statements
- "|.*[\\S].*do[\\w|\\s]*)" + // or for an iterator, which needs at least one none-space character and 'do' with optional arguments.
- "[^(end)]"); // And it should not contain end already.
-
- private boolean endStatements;
-
- public void verifyKey(VerifyEvent event) {
- if (!event.doit || !endStatements) return;
-
- switch (event.character) {
- case '\n':
- case '\r':
- break;
- default:
- return;
- }
-
- final IDocument document = getSourceViewer().getDocument();
- final int offset = getSourceViewer().getSelectedRange().x;
- final int length = getSourceViewer().getSelectedRange().y;
- try {
- IRegion startLine = document.getLineInformationOfOffset(offset);
- String lineContent = document.get(startLine.getOffset(), startLine.getLength());
- Matcher matched = openBlockPattern.matcher(lineContent);
- if(matched.matches()) {
- String baseIndentation = matched.group(1); // 1 marks the spaces in front of the statement
- String bodyIndentation = addOneIndentationLevel(baseIndentation);
-
- String lineDelimiter = Platform.getPreferencesService().getString(Platform.PI_RUNTIME, Platform.PREF_LINE_SEPARATOR, null, null);
-
- String body = event.character + bodyIndentation + lineDelimiter + baseIndentation + "end";
- document.replace(offset, length, body);
- getSourceViewer().setSelectedRange(offset + bodyIndentation.length() + 1 /*for the newline char*/, 0);
- event.doit = false;
- }
- } catch (BadLocationException e) {
- RubyPlugin.log(e);
- }
- }
-
- private String addOneIndentationLevel(String indentation) {
- if(RubyCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_CHAR).equals(RubyCore.SPACE)) {
- for(int i = 0; i < Integer.parseInt(RubyCore.getOption(DefaultCodeFormatterConstants.FORMATTER_TAB_SIZE)); i++) {
- indentation += ' ';
- }
- } else {
- indentation += '\t';
- }
- return indentation;
- }
-
- public void setEndStatementsEnabled(boolean endStatements) {
- this.endStatements = endStatements;
- }
- }
-
private class BracketInserter implements VerifyKeyListener, ILinkedModeListener {
private boolean fCloseBrackets = true;
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyIndenter.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyIndenter.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/RubyIndenter.java 2007-03-15 12:46:53 UTC (rev 2177)
@@ -0,0 +1,53 @@
+package org.rubypeople.rdt.internal.ui.text;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.rubypeople.rdt.core.IRubyProject;
+
+public class RubyIndenter {
+
+ private IDocument fDocument;
+ private IRubyProject fProject;
+ private RubyHeuristicScanner fScanner;
+
+ public RubyIndenter(IDocument d, RubyHeuristicScanner scanner, IRubyProject project) {
+ fDocument = d;
+ fScanner = scanner;
+ fProject = project;
+ }
+
+ public StringBuffer computeIndentation(int offset) {
+ StringBuffer buf = getLeadingWhitespace(offset);
+ // TODO Convert the whitespaces into units?
+ return buf;
+// return CodeFormatterUtil.createIndentString(indentationUnits, fProject);
+ }
+
+ /**
+ * Returns the indentation of the line at <code>offset</code> as a
+ * <code>StringBuffer</code>. If the offset is not valid, the empty string
+ * is returned.
+ *
+ * @param offset the offset in the document
+ * @return the indentation (leading whitespace) of the line in which
+ * <code>offset</code> is located
+ */
+ private StringBuffer getLeadingWhitespace(int offset) {
+ StringBuffer indent= new StringBuffer();
+ try {
+ IRegion line= fDocument.getLineInformationOfOffset(offset);
+ int lineOffset= line.getOffset();
+ int nonWS= fScanner.findNonWhitespaceForwardInAnyPartition(lineOffset, lineOffset + line.getLength());
+ if (nonWS == -1) {
+ indent.append(fDocument.get(lineOffset, line.getLength()));
+ return indent;
+ }
+ indent.append(fDocument.get(lineOffset, nonWS - lineOffset));
+ return indent;
+ } catch (BadLocationException e) {
+ return indent;
+ }
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyAutoIndentStrategy.java 2007-03-15 12:46:53 UTC (rev 2177)
@@ -0,0 +1,158 @@
+package org.rubypeople.rdt.internal.ui.text.ruby;
+
+import java.util.regex.Pattern;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.DefaultIndentLineAutoEditStrategy;
+import org.eclipse.jface.text.DocumentCommand;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.ITypedRegion;
+import org.eclipse.jface.text.TextUtilities;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.jruby.lexer.yacc.SyntaxException;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.internal.core.parser.RubyParser;
+import org.rubypeople.rdt.internal.corext.util.CodeFormatterUtil;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.text.IRubyPartitions;
+import org.rubypeople.rdt.internal.ui.text.RubyHeuristicScanner;
+import org.rubypeople.rdt.internal.ui.text.RubyIndenter;
+import org.rubypeople.rdt.ui.PreferenceConstants;
+
+public class RubyAutoIndentStrategy extends DefaultIndentLineAutoEditStrategy implements IPropertyChangeListener {
+
+ /** Preference key for automatically 'end'ing statements */
+ private final static String END_STATEMENTS= PreferenceConstants.EDITOR_END_STATEMENTS;
+
+ private final Pattern openBlockPattern = Pattern.compile(".*[\\S].*do[\\w|\\s]*");
+
+ private static final String BLOCK_CLOSER = "end";
+ private String fPartitioning;
+ private final IRubyProject fProject;
+ private boolean endStatements;
+ private IPreferenceStore fPreferenceStore;
+
+ /**
+ * Creates a new Ruby auto indent strategy for the given document partitioning.
+ *
+ * @param partitioning the document partitioning
+ * @param project the project to get formatting preferences from, or null to use default preferences
+ */
+ public RubyAutoIndentStrategy(String partitioning, IRubyProject project) {
+ fPartitioning= partitioning;
+ fProject= project;
+ fPreferenceStore = RubyPlugin.getDefault().getPreferenceStore();
+ endStatements= fPreferenceStore.getBoolean(END_STATEMENTS);
+ fPreferenceStore.addPropertyChangeListener(this);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.IAutoIndentStrategy#customizeDocumentCommand(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.DocumentCommand)
+ */
+ public void customizeDocumentCommand(IDocument d, DocumentCommand c) {
+ if (c.doit == false)
+ return;
+ if (c.length == 0 && c.text != null && isLineDelimiter(d, c.text))
+ smartIndentAfterNewLine(d, c);
+ }
+
+ private boolean isLineDelimiter(IDocument document, String text) {
+ String[] delimiters= document.getLegalLineDelimiters();
+ if (delimiters != null)
+ return TextUtilities.equals(delimiters, text) > -1;
+ return false;
+ }
+
+ private void smartIndentAfterNewLine(IDocument d, DocumentCommand c) {
+ RubyHeuristicScanner scanner= new RubyHeuristicScanner(d);
+ RubyIndenter indenter= new RubyIndenter(d, scanner, fProject);
+ StringBuffer indent= indenter.computeIndentation(c.offset);
+ if (indent == null)
+ indent= new StringBuffer();
+
+ int docLength= d.getLength();
+ if (c.offset == -1 || docLength == 0)
+ return;
+
+ try {
+ int p= (c.offset == docLength ? c.offset - 1 : c.offset);
+ int line= d.getLineOfOffset(p);
+
+ StringBuffer buf= new StringBuffer(c.text + indent);
+
+
+ IRegion reg= d.getLineInformation(line);
+ int lineEnd= reg.getOffset() + reg.getLength();
+
+ int contentStart= findEndOfWhiteSpace(d, c.offset, lineEnd);
+ c.length= Math.max(contentStart - c.offset, 0);
+
+ int start= reg.getOffset();
+ ITypedRegion region= TextUtilities.getPartition(d, fPartitioning, start, true);
+ if (IRubyPartitions.RUBY_DOC.equals(region.getType()))
+ start= d.getLineInformationOfOffset(region.getOffset()).getOffset();
+
+ // insert closing "end" on new line after an unclosed block
+ if (closeBlock() && unclosedBlock(d, start, c.offset)) {
+ buf.append(CodeFormatterUtil.createIndentString(1, fProject));
+ c.caretOffset= c.offset + buf.length();
+ c.shiftsCaret= false;
+
+ // copy old content of line behind insertion point to new line
+ if (c.offset == 0) {
+ if (lineEnd - contentStart > 0) {
+ c.length= lineEnd - c.offset;
+ buf.append(d.get(contentStart, lineEnd - contentStart).toCharArray());
+ }
+ }
+
+ buf.append(TextUtilities.getDefaultLineDelimiter(d));
+ buf.append(indent);
+ buf.append(BLOCK_CLOSER);
+ }
+ c.text= buf.toString();
+
+ } catch (BadLocationException e) {
+ RubyPlugin.log(e);
+ }
+ }
+
+ private boolean unclosedBlock(IDocument d, int start, int offset) {
+ // FIXME wow is this ugly! There has to be an easier way to tell if there's an unclosed block besides parsing and catching a syntaxError!
+ try {
+ String line = d.get(start, offset - start);
+ line = line.trim();
+ if (!line.startsWith("class ") && !line.startsWith("if ") && !line.startsWith("module ") && !line.startsWith("unless ")
+ && !line.startsWith("def ") && !line.equals("begin") && !openBlockPattern.matcher(line).matches()) {
+ return false;
+ }
+ } catch (BadLocationException e1) {
+ RubyPlugin.log(e1);
+ }
+
+ try {
+ RubyParser parser = new RubyParser();
+ parser.parse(d.get());
+ } catch (SyntaxException e) {
+ String msg = e.getMessage();
+ return msg.contains("expecting") && (msg.contains("kEND") || msg.contains("kTHEN"));
+ }
+ return false;
+ }
+
+ private boolean closeBlock() {
+ return endStatements;
+ }
+
+ public void propertyChange(PropertyChangeEvent event) {
+ String property = event.getProperty();
+ if (END_STATEMENTS.equals(property)) {
+ endStatements = fPreferenceStore.getBoolean(property);
+ return;
+ }
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-03-14 20:52:14 UTC (rev 2176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/PreferenceConstants.java 2007-03-15 12:46:53 UTC (rev 2177)
@@ -789,6 +789,7 @@
store.setDefault(PreferenceConstants.EDITOR_CLOSE_STRINGS, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACKETS, true);
store.setDefault(PreferenceConstants.EDITOR_CLOSE_BRACES, true);
+ store.setDefault(PreferenceConstants.EDITOR_END_STATEMENTS, true);
// mark occurrences
store.setDefault(PreferenceConstants.EDITOR_MARK_OCCURRENCES, true);
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 2007-03-14 20:52:14 UTC (rev 2176)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/ui/text/RubySourceViewerConfiguration.java 2007-03-15 12:46:53 UTC (rev 2177)
@@ -42,7 +42,6 @@
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyScriptDocumentProvider;
import org.rubypeople.rdt.internal.ui.rubyeditor.RubyAbstractEditor;
-import org.rubypeople.rdt.internal.ui.rubyeditor.RubyAutoEditStrategy;
import org.rubypeople.rdt.internal.ui.text.ContentAssistPreference;
import org.rubypeople.rdt.internal.ui.text.HTMLTextPresenter;
import org.rubypeople.rdt.internal.ui.text.IRubyColorConstants;
@@ -58,6 +57,7 @@
import org.rubypeople.rdt.internal.ui.text.hyperlinks.RubyHyperLinkDetector;
import org.rubypeople.rdt.internal.ui.text.ruby.AbstractRubyScanner;
import org.rubypeople.rdt.internal.ui.text.ruby.AbstractRubyTokenScanner;
+import org.rubypeople.rdt.internal.ui.text.ruby.RubyAutoIndentStrategy;
import org.rubypeople.rdt.internal.ui.text.ruby.RubyCompletionProcessor;
import org.rubypeople.rdt.internal.ui.text.ruby.RubyFormattingStrategy;
import org.rubypeople.rdt.internal.ui.text.ruby.RubyReconcilingStrategy;
@@ -321,27 +321,19 @@
}
public IAutoEditStrategy[] getAutoEditStrategies(
- ISourceViewer sourceViewer, String contentType) {
- String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
- if (IRubyPartitions.RUBY_SINGLE_LINE_COMMENT.equals(contentType)) {
- return new IAutoEditStrategy[] { new RubyCommentAutoIndentStrategy(
- partitioning) };
- } else if (IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) {
- IAutoEditStrategy[] strategies = super.getAutoEditStrategies(
- sourceViewer, contentType);
- IAutoEditStrategy[] newStrategies = new IAutoEditStrategy[strategies.length + 1];
- System
- .arraycopy(strategies, 0, newStrategies, 0,
- strategies.length);
- newStrategies[newStrategies.length - 1] = new RubyAutoEditStrategy(
- partitioning, sourceViewer, fRubyCp);
- strategies = newStrategies;
- return strategies;
- } else {
- return super.getAutoEditStrategies(sourceViewer, contentType);
- }
- }
+ ISourceViewer sourceViewer, String contentType) {
+ String partitioning = getConfiguredDocumentPartitioning(sourceViewer);
+ if (IRubyPartitions.RUBY_SINGLE_LINE_COMMENT.equals(contentType)) {
+ return new IAutoEditStrategy[] { new RubyCommentAutoIndentStrategy(
+ partitioning) };
+ } else if ( IDocument.DEFAULT_CONTENT_TYPE.equals(contentType)) {
+ return new IAutoEditStrategy[] { new RubyAutoIndentStrategy(partitioning, getProject()) };
+ } else {
+ return super.getAutoEditStrategies (sourceViewer, contentType);
+ }
+ }
+
/*
* @see SourceViewerConfiguration#getInformationControlCreator(ISourceViewer)
* @since 2.0
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:52:16
|
Revision: 2176
http://svn.sourceforge.net/rubyeclipse/?rev=2176&view=rev
Author: cawilliams
Date: 2007-03-14 13:52:14 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
start working towards more infrastructure for quick fixes
Modified Paths:
--------------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyMarkerAnnotation.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java 2007-03-14 20:51:49 UTC (rev 2175)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/IRubyAnnotation.java 2007-03-14 20:52:14 UTC (rev 2176)
@@ -97,4 +97,20 @@
*/
IRubyScript getRubyScript();
+ /**
+ * Returns the problem id or <code>-1</code> if no problem id can be evaluated.
+ *
+ * @return returns the problem id or <code>-1</code>
+ */
+ int getId();
+
+ /**
+ * Returns the marker type associated to this problem or <code>null<code> if no marker type
+ * can be evaluated.
+ *
+ * @return the type of the marker which would be associated to the problem or
+ * <code>null<code> if no marker type can be evaluated.
+ */
+ String getMarkerType();
+
}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java 2007-03-14 20:51:49 UTC (rev 2175)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyDocumentProvider.java 2007-03-14 20:52:14 UTC (rev 2176)
@@ -9,7 +9,6 @@
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.util.ListenerList;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -30,6 +29,7 @@
import org.eclipse.jface.text.source.IAnnotationPresentation;
import org.eclipse.jface.text.source.ImageUtilities;
import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.ListenerList;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
@@ -51,7 +51,8 @@
import org.rubypeople.rdt.core.IRubyScript;
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.internal.ui.RubyPluginImages;
import org.rubypeople.rdt.internal.ui.text.ruby.IProblemRequestorExtension;
@@ -635,6 +636,16 @@
public IRubyScript getRubyScript() {
return fRubyScript;
}
+
+ public int getId() {
+ return fProblem.getID();
+ }
+
+ public String getMarkerType() {
+ if (fProblem instanceof CategorizedProblem)
+ return ((CategorizedProblem) fProblem).getMarkerType();
+ return null;
+ }
}
/**
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyMarkerAnnotation.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyMarkerAnnotation.java 2007-03-14 20:51:49 UTC (rev 2175)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyMarkerAnnotation.java 2007-03-14 20:52:14 UTC (rev 2176)
@@ -14,8 +14,8 @@
import java.util.Iterator;
import org.eclipse.core.resources.IMarker;
-
import org.eclipse.ui.texteditor.MarkerAnnotation;
+import org.eclipse.ui.texteditor.MarkerUtilities;
import org.rubypeople.rdt.core.IRubyElement;
import org.rubypeople.rdt.core.IRubyModelMarker;
import org.rubypeople.rdt.core.IRubyScript;
@@ -131,4 +131,12 @@
}
return null;
}
+
+ public String getMarkerType() {
+ IMarker marker= getMarker();
+ if (marker == null || !marker.exists())
+ return null;
+
+ return MarkerUtilities.getMarkerType(getMarker());
+ }
}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/CorrectionMessages.java 2007-03-14 20:52:14 UTC (rev 2176)
@@ -0,0 +1,15 @@
+package org.rubypeople.rdt.internal.ui.text.correction;
+
+import org.eclipse.osgi.util.NLS;
+
+public class CorrectionMessages extends NLS {
+
+ private static final String BUNDLE_NAME = CorrectionMessages.class.getName();
+
+ public static String RubyCorrectionProcessor_error_status;
+
+ static {
+ NLS.initializeMessages(BUNDLE_NAME, CorrectionMessages.class);
+ }
+
+}
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/RubyCorrectionProcessor.java 2007-03-14 20:52:14 UTC (rev 2176)
@@ -0,0 +1,174 @@
+package org.rubypeople.rdt.internal.ui.text.correction;
+
+import java.util.ArrayList;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.ISafeRunnable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.SafeRunner;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.ui.IMarkerHelpRegistry;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.texteditor.SimpleMarkerAnnotation;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.rubyeditor.IRubyAnnotation;
+import org.rubypeople.rdt.ui.RubyUI;
+import org.rubypeople.rdt.ui.text.ruby.IQuickFixProcessor;
+
+public class RubyCorrectionProcessor implements org.eclipse.jface.text.quickassist.IQuickAssistProcessor {
+
+ private static final String QUICKFIX_PROCESSOR_CONTRIBUTION_ID= "quickFixProcessors"; //$NON-NLS-1$
+
+ private static ContributedProcessorDescriptor[] fContributedCorrectionProcessors= null;
+
+ private String fErrorMessage;
+
+ public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public boolean canFix(Annotation annotation) {
+ return hasCorrections(annotation);
+ }
+
+ public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
+ // TODO Auto-generated method stub
+ return new ICompletionProposal[0];
+ }
+
+ public String getErrorMessage() {
+ return fErrorMessage;
+ }
+
+ public static boolean hasCorrections(Annotation annotation) {
+ if (annotation instanceof IRubyAnnotation) {
+ IRubyAnnotation rubyAnnotation= (IRubyAnnotation) annotation;
+ int problemId= rubyAnnotation.getId();
+ if (problemId != -1) {
+ IRubyScript cu= rubyAnnotation.getRubyScript();
+ if (cu != null) {
+ return hasCorrections(cu, problemId, rubyAnnotation.getMarkerType());
+ }
+ }
+ }
+ if (annotation instanceof SimpleMarkerAnnotation) {
+ return hasCorrections(((SimpleMarkerAnnotation) annotation).getMarker());
+ }
+ return false;
+ }
+
+ private static boolean hasCorrections(IMarker marker) {
+ if (marker == null || !marker.exists())
+ return false;
+
+ IMarkerHelpRegistry registry= IDE.getMarkerHelpRegistry();
+ return registry != null && registry.hasResolutions(marker);
+ }
+
+ public static boolean hasCorrections(IRubyScript cu, int problemId, String markerType) {
+ ContributedProcessorDescriptor[] processors= getCorrectionProcessors();
+ SafeHasCorrections collector= new SafeHasCorrections(cu, problemId);
+ for (int i= 0; i < processors.length; i++) {
+ if (processors[i].canHandleMarkerType(markerType)) {
+ collector.process(processors[i]);
+ if (collector.hasCorrections()) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ private static ContributedProcessorDescriptor[] getCorrectionProcessors() {
+ if (fContributedCorrectionProcessors == null) {
+ fContributedCorrectionProcessors= getProcessorDescriptors(QUICKFIX_PROCESSOR_CONTRIBUTION_ID, true);
+ }
+ return fContributedCorrectionProcessors;
+ }
+
+ private static ContributedProcessorDescriptor[] getProcessorDescriptors(String contributionId, boolean testMarkerTypes) {
+ IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(RubyUI.ID_PLUGIN, contributionId);
+ ArrayList res= new ArrayList(elements.length);
+
+ for (int i= 0; i < elements.length; i++) {
+ ContributedProcessorDescriptor desc= new ContributedProcessorDescriptor(elements[i], testMarkerTypes);
+ IStatus status= desc.checkSyntax();
+ if (status.isOK()) {
+ res.add(desc);
+ } else {
+ RubyPlugin.log(status);
+ }
+ }
+ return (ContributedProcessorDescriptor[]) res.toArray(new ContributedProcessorDescriptor[res.size()]);
+ }
+
+ private static class SafeHasCorrections extends SafeCorrectionProcessorAccess {
+ private final IRubyScript fCu;
+ private final int fProblemId;
+ private boolean fHasCorrections;
+
+ public SafeHasCorrections(IRubyScript cu, int problemId) {
+ fCu= cu;
+ fProblemId= problemId;
+ fHasCorrections= false;
+ }
+
+ public boolean hasCorrections() {
+ return fHasCorrections;
+ }
+
+ public void safeRun(ContributedProcessorDescriptor desc) throws Exception {
+ IQuickFixProcessor processor= (IQuickFixProcessor) desc.getProcessor(fCu);
+ if (processor != null && processor.hasCorrections(fCu, fProblemId)) {
+ fHasCorrections= true;
+ }
+ }
+ }
+
+ private static abstract class SafeCorrectionProcessorAccess implements ISafeRunnable {
+ private MultiStatus fMulti= null;
+ private ContributedProcessorDescriptor fDescriptor;
+
+ public void process(ContributedProcessorDescriptor[] desc) {
+ for (int i= 0; i < desc.length; i++) {
+ fDescriptor= desc[i];
+ SafeRunner.run(this);
+ }
+ }
+
+ public void process(ContributedProcessorDescriptor desc) {
+ fDescriptor= desc;
+ SafeRunner.run(this);
+ }
+
+ public void run() throws Exception {
+ safeRun(fDescriptor);
+ }
+
+ protected abstract void safeRun(ContributedProcessorDescriptor processor) throws Exception;
+
+ public void handleException(Throwable exception) {
+ if (fMulti == null) {
+ fMulti= new MultiStatus(RubyUI.ID_PLUGIN, IStatus.OK, CorrectionMessages.RubyCorrectionProcessor_error_status, null);
+ }
+ fMulti.merge(new Status(IStatus.ERROR, RubyUI.ID_PLUGIN, IStatus.ERROR, CorrectionMessages.RubyCorrectionProcessor_error_status, exception));
+ }
+
+ public IStatus getStatus() {
+ if (fMulti == null) {
+ return Status.OK_STATUS;
+ }
+ return fMulti;
+ }
+
+ }
+
+}
Modified: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java 2007-03-14 20:51:49 UTC (rev 2175)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/ruby/RubyScriptCompletion.java 2007-03-14 20:52:14 UTC (rev 2176)
@@ -15,7 +15,7 @@
import org.rubypeople.rdt.core.CompletionRequestor;
import org.rubypeople.rdt.core.IRubyProject;
import org.rubypeople.rdt.core.IRubyScript;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.ui.RubyPlugin;
import org.rubypeople.rdt.ui.text.ruby.IRubyCompletionProposal;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:51:50
|
Revision: 2175
http://svn.sourceforge.net/rubyeclipse/?rev=2175&view=rev
Author: cawilliams
Date: 2007-03-14 13:51:49 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java
Modified: trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java 2007-03-14 20:51:35 UTC (rev 2174)
+++ trunk/org.rubypeople.rdt.core.tests/src/org/rubypeople/rdt/internal/core/builder/TC_RubyLintVisitor.java 2007-03-14 20:51:49 UTC (rev 2175)
@@ -10,7 +10,7 @@
import org.jruby.ast.visitor.NodeVisitor;
import org.rubypeople.eclipse.shams.resources.ShamFile;
import org.rubypeople.rdt.core.IProblemRequestor;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.parser.warnings.DelegatingVisitor;
import org.rubypeople.rdt.internal.core.parser.warnings.RubyLintVisitor;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:51:46
|
Revision: 2174
http://svn.sourceforge.net/rubyeclipse/?rev=2174&view=rev
Author: cawilliams
Date: 2007-03-14 13:51:35 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Modified Paths:
--------------
trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
Added Paths:
-----------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
Removed Paths:
-------------
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/
trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java
Modified: trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF
===================================================================
--- trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/META-INF/MANIFEST.MF 2007-03-14 20:51:35 UTC (rev 2174)
@@ -9,8 +9,9 @@
Bundle-Localization: plugin
Export-Package: .,
org.rubypeople.rdt.core,
+ org.rubypeople.rdt.core.compiler,
org.rubypeople.rdt.core.formatter,
- org.rubypeople.rdt.core.parser,
+ org.rubypeople.rdt.internal.compiler,
org.rubypeople.rdt.internal.core,
org.rubypeople.rdt.internal.core.buffer,
org.rubypeople.rdt.internal.core.builder,
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/CompletionRequestor.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.core;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* Abstract base class for a completion requestor which is passed completion
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/IProblemRequestor.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -10,7 +10,7 @@
*******************************************************************************/
package org.rubypeople.rdt.core;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* A callback interface for receiving ruby problem as they are discovered
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java (from rev 2160, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/CategorizedProblem.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.rubypeople.rdt.core.compiler;
+
+import org.rubypeople.rdt.internal.core.util.CharOperation;
+
+
+/**
+ * Richer description of a Ruby problem, as detected by the compiler or some of the underlying
+ * technology reusing the compiler. With the introduction of <code>CompilationParticipant</code>,
+ * the simpler problem interface <code>IProblem</code> did not carry enough information to better
+ * separate and categorize Java problems. In order to minimize impact on existing API, Java problems
+ * are still passed around as <code>IProblem</code>, though actual implementations should explicitly
+ * extend <code>CategorizedProblem</code>. Participants can produce their own problem definitions,
+ * and given these are categorized problems, they can be better handled by clients (such as user
+ * interface).
+ *
+ * A categorized problem provides access to:
+ * <ul>
+ * <li> its location (originating source file name, source position, line number), </li>
+ * <li> its message description and a predicate to check its severity (warning or error). </li>
+ * <li> its ID : a number identifying the very nature of this problem. All possible IDs for standard Java
+ * problems are listed as constants on <code>IProblem</code>, </li>
+ * <li> its marker type : a string identfying the problem creator. It corresponds to the marker type
+ * chosen if this problem was to be persisted. Standard Java problems are associated to marker
+ * type "org.eclipse.jdt.core.problem"), </li>
+ * <li> its category ID : a number identifying the category this problem belongs to. All possible IDs for
+ * standard Java problem categories are listed in this class. </li>
+ * </ul>
+ *
+ * Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder
+ * so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected
+ * when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular
+ * their ID (attribute "id") is set to one of the IDs defined on this interface.
+ *
+ * Note: Standard Java problems produced by Java default tooling will be subclasses of this class. Technically, most
+ * API methods dealing with problems are referring to <code>IProblem</code> for backward compatibility reason.
+ * It is intended that <code>CategorizedProblem</code> will be subclassed for custom problem implementation when
+ * participating in compilation operations, so as to allow participant to contribute their own marker types, and thus
+ * defining their own domain specific problem/category IDs.
+ *
+ * @since 3.2
+ */
+public abstract class CategorizedProblem implements IProblem {
+
+ /**
+ * List of standard category IDs used by Ruby problems, more categories will be added
+ * in the future.
+ */
+ public static final int CAT_UNSPECIFIED = 0;
+ /** Category for problems related to buildpath */
+ public static final int CAT_BUILDPATH = 10;
+ /** Category for fatal problems related to syntax */
+ public static final int CAT_SYNTAX = 20;
+ /** Category for fatal problems in import statements */
+ public static final int CAT_IMPORT = 30;
+ /** Category for fatal problems related to types, could be addressed by some type change */
+ public static final int CAT_TYPE = 40;
+ /** Category for fatal problems related to type members, could be addressed by some field or method change */
+ public static final int CAT_MEMBER = 50;
+ /** Category for fatal problems which could not be addressed by external changes, but require an edit to be addressed */
+ public static final int CAT_INTERNAL = 60;
+ /** Category for optional problems in Javadoc */
+ public static final int CAT_JAVADOC = 70;
+ /** Category for optional problems related to coding style practices */
+ public static final int CAT_CODE_STYLE = 80;
+ /** Category for optional problems related to potential programming flaws */
+ public static final int CAT_POTENTIAL_PROGRAMMING_PROBLEM = 90;
+ /** Category for optional problems related to naming conflicts */
+ public static final int CAT_NAME_SHADOWING_CONFLICT = 100;
+ /** Category for optional problems related to deprecation */
+ public static final int CAT_DEPRECATION = 110;
+ /** Category for optional problems related to unnecessary code */
+ public static final int CAT_UNNECESSARY_CODE = 120;
+ /** Category for optional problems related to type safety in generics */
+ public static final int CAT_UNCHECKED_RAW = 130;
+ /** Category for optional problems related to internationalization of String literals */
+ public static final int CAT_NLS = 140;
+ /** Category for optional problems related to access restrictions */
+ public static final int CAT_RESTRICTION = 150;
+
+/**
+ * Returns an integer identifying the category of this problem. Categories, like problem IDs are
+ * defined in the context of some marker type. Custom implementations of <code>CategorizedProblem</code>
+ * may choose arbitrary values for problem/category IDs, as long as they are associated with a different
+ * marker type.
+ * Standard Java problem markers (i.e. marker type is "org.eclipse.jdt.core.problem") carry an
+ * attribute "categoryId" persisting the originating problem category ID as defined by this method).
+ * @return id - an integer identifying the category of this problem
+ */
+//public abstract int getCategoryID(); FIXME Uncomment when we're ready to do categorization...
+
+/**
+ * Returns the marker type associated to this problem, if it gets persisted into a marker by the JavaBuilder
+ * Standard Java problems are associated to marker type "org.eclipse.jdt.core.problem").
+ * Note: problem markers are expected to extend "org.eclipse.core.resources.problemmarker" marker type.
+ * @return the type of the marker which would be associated to the problem
+ */
+public abstract String getMarkerType();
+
+/**
+ * Returns the names of the extra marker attributes associated to this problem when persisted into a marker
+ * by the JavaBuilder. Extra attributes are only optional, and are allowing client customization of generated
+ * markers. By default, no EXTRA attributes is persisted, and a categorized problem only persists the following attributes:
+ * <ul>
+ * <li> <code>IMarker#MESSAGE</code> -> {@link IProblem#getMessage()}</li>
+ * <li> <code>IMarker#SEVERITY</code> -> <code> IMarker#SEVERITY_ERROR</code> or
+ * <code>IMarker#SEVERITY_WARNING</code> depending on {@link IProblem#isError()} or {@link IProblem#isWarning()}</li>
+ * <li> <code>IJavaModelMarker#ID</code> -> {@link IProblem#getID()}</li>
+ * <li> <code>IMarker#CHAR_START</code> -> {@link IProblem#getSourceStart()}</li>
+ * <li> <code>IMarker#CHAR_END</code> -> {@link IProblem#getSourceEnd()}</li>
+ * <li> <code>IMarker#LINE_NUMBER</code> -> {@link IProblem#getSourceLineNumber()}</li>
+ * <li> <code>IJavaModelMarker#ARGUMENTS</code> -> some <code>String[]</code> used to compute quickfixes </li>
+ * </ul>
+ * The names must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>,
+ * and there must be as many names as values according to {@link #getExtraMarkerAttributeValues()}.
+ * Note that extra marker attributes will be inserted after default ones (as described in {@link CategorizedProblem#getMarkerType()},
+ * and thus could be used to override defaults.
+ * @return the names of the corresponding marker attributes
+ */
+public String[] getExtraMarkerAttributeNames() {
+ return CharOperation.NO_STRINGS;
+}
+
+/**
+ * Returns the respective values for the extra marker attributes associated to this problem when persisted into
+ * a marker by the JavaBuilder. Each value must correspond to a matching attribute name, as defined by
+ * {@link #getExtraMarkerAttributeNames()}.
+ * The values must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>.
+ * @return the values of the corresponding extra marker attributes
+ */
+public Object[] getExtraMarkerAttributeValues() {
+ return new Object[] {};
+}
+}
Copied: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java (from rev 2160, trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/parser/IProblem.java)
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java (rev 0)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -0,0 +1,105 @@
+/*******************************************************************************
+ * 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.core.compiler;
+
+/**
+ * Description of a Ruby problem, as detected by the compiler or some of the
+ * underlying technology reusing the compiler. A problem provides access to:
+ * <ul>
+ * <li> its location (originating source file name, source position, line
+ * number), </li>
+ * <li> its message description and a predicate to check its severity (warning
+ * or error). </li>
+ * <li> its ID : an number identifying the very nature of this problem. All
+ * possible IDs are listed as constants on this interface. </li>
+ * </ul>
+ *
+ * Note: the compiler produces IProblems internally, which are turned into
+ * markers by the RubyBuilder so as to persist problem descriptions. This
+ * explains why there is no API allowing to reach IProblem detected when
+ * compiling. However, the Ruby problem markers carry equivalent information to
+ * IProblem, in particular their ID (attribute "id") is set to one of the IDs
+ * defined on this interface.
+ *
+ * @since 2.0
+ */
+public interface IProblem {
+
+ int Uncategorized = 0;
+
+ /**
+ * Returns the problem id
+ *
+ * @return the problem id
+ */
+ int getID();
+
+ /**
+ * Answer a localized, human-readable message string which describes the
+ * problem.
+ *
+ * @return a localized, human-readable message string which describes the
+ * problem
+ */
+ String getMessage();
+
+ /**
+ * Answer the file name in which the problem was found.
+ *
+ * @return the file name in which the problem was found
+ */
+ char[] getOriginatingFileName();
+
+ /**
+ * Answer the end position of the problem (inclusive), or -1 if unknown.
+ *
+ * @return the end position of the problem (inclusive), or -1 if unknown
+ */
+ int getSourceEnd();
+
+ /**
+ * Answer the line number in source where the problem begins.
+ *
+ * @return the line number in source where the problem begins
+ */
+ int getSourceLineNumber();
+
+ /**
+ * Answer the start position of the problem (inclusive), or -1 if unknown.
+ *
+ * @return the start position of the problem (inclusive), or -1 if unknown
+ */
+ int getSourceStart();
+
+ /**
+ * Checks the severity to see if the Error bit is set.
+ *
+ * @return true if the Error bit is set for the severity, false otherwise
+ */
+ boolean isError();
+
+ /**
+ * Checks the severity to see if the Warning bit is not set.
+ *
+ * @return true if the Warning bit is not set for the severity, false
+ * otherwise
+ */
+ boolean isWarning();
+
+ /**
+ * Checks the severity to see if the Task bit is not set.
+ *
+ * @return true if the Task bit is not set for the severity, false
+ * otherwise
+ */
+ boolean isTask();
+
+}
\ No newline at end of file
Property changes on: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/core/compiler/IProblem.java
___________________________________________________________________
Name: svn:eol-style
+ native
Deleted: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/compiler/CategorizedProblem.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -1,145 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.rubypeople.rdt.internal.compiler;
-
-import org.rubypeople.rdt.core.parser.IProblem;
-import org.rubypeople.rdt.internal.core.util.CharOperation;
-
-
-/**
- * Richer description of a Java problem, as detected by the compiler or some of the underlying
- * technology reusing the compiler. With the introduction of <code>CompilationParticipant</code>,
- * the simpler problem interface <code>IProblem</code> did not carry enough information to better
- * separate and categorize Java problems. In order to minimize impact on existing API, Java problems
- * are still passed around as <code>IProblem</code>, though actual implementations should explicitly
- * extend <code>CategorizedProblem</code>. Participants can produce their own problem definitions,
- * and given these are categorized problems, they can be better handled by clients (such as user
- * interface).
- *
- * A categorized problem provides access to:
- * <ul>
- * <li> its location (originating source file name, source position, line number), </li>
- * <li> its message description and a predicate to check its severity (warning or error). </li>
- * <li> its ID : a number identifying the very nature of this problem. All possible IDs for standard Java
- * problems are listed as constants on <code>IProblem</code>, </li>
- * <li> its marker type : a string identfying the problem creator. It corresponds to the marker type
- * chosen if this problem was to be persisted. Standard Java problems are associated to marker
- * type "org.eclipse.jdt.core.problem"), </li>
- * <li> its category ID : a number identifying the category this problem belongs to. All possible IDs for
- * standard Java problem categories are listed in this class. </li>
- * </ul>
- *
- * Note: the compiler produces IProblems internally, which are turned into markers by the JavaBuilder
- * so as to persist problem descriptions. This explains why there is no API allowing to reach IProblem detected
- * when compiling. However, the Java problem markers carry equivalent information to IProblem, in particular
- * their ID (attribute "id") is set to one of the IDs defined on this interface.
- *
- * Note: Standard Java problems produced by Java default tooling will be subclasses of this class. Technically, most
- * API methods dealing with problems are referring to <code>IProblem</code> for backward compatibility reason.
- * It is intended that <code>CategorizedProblem</code> will be subclassed for custom problem implementation when
- * participating in compilation operations, so as to allow participant to contribute their own marker types, and thus
- * defining their own domain specific problem/category IDs.
- *
- * @since 3.2
- */
-public abstract class CategorizedProblem implements IProblem {
-
- /**
- * List of standard category IDs used by Java problems, more categories will be added
- * in the future.
- */
- public static final int CAT_UNSPECIFIED = 0;
- /** Category for problems related to buildpath */
- public static final int CAT_BUILDPATH = 10;
- /** Category for fatal problems related to syntax */
- public static final int CAT_SYNTAX = 20;
- /** Category for fatal problems in import statements */
- public static final int CAT_IMPORT = 30;
- /** Category for fatal problems related to types, could be addressed by some type change */
- public static final int CAT_TYPE = 40;
- /** Category for fatal problems related to type members, could be addressed by some field or method change */
- public static final int CAT_MEMBER = 50;
- /** Category for fatal problems which could not be addressed by external changes, but require an edit to be addressed */
- public static final int CAT_INTERNAL = 60;
- /** Category for optional problems in Javadoc */
- public static final int CAT_JAVADOC = 70;
- /** Category for optional problems related to coding style practices */
- public static final int CAT_CODE_STYLE = 80;
- /** Category for optional problems related to potential programming flaws */
- public static final int CAT_POTENTIAL_PROGRAMMING_PROBLEM = 90;
- /** Category for optional problems related to naming conflicts */
- public static final int CAT_NAME_SHADOWING_CONFLICT = 100;
- /** Category for optional problems related to deprecation */
- public static final int CAT_DEPRECATION = 110;
- /** Category for optional problems related to unnecessary code */
- public static final int CAT_UNNECESSARY_CODE = 120;
- /** Category for optional problems related to type safety in generics */
- public static final int CAT_UNCHECKED_RAW = 130;
- /** Category for optional problems related to internationalization of String literals */
- public static final int CAT_NLS = 140;
- /** Category for optional problems related to access restrictions */
- public static final int CAT_RESTRICTION = 150;
-
-/**
- * Returns an integer identifying the category of this problem. Categories, like problem IDs are
- * defined in the context of some marker type. Custom implementations of <code>CategorizedProblem</code>
- * may choose arbitrary values for problem/category IDs, as long as they are associated with a different
- * marker type.
- * Standard Java problem markers (i.e. marker type is "org.eclipse.jdt.core.problem") carry an
- * attribute "categoryId" persisting the originating problem category ID as defined by this method).
- * @return id - an integer identifying the category of this problem
- */
-public abstract int getCategoryID();
-
-/**
- * Returns the marker type associated to this problem, if it gets persisted into a marker by the JavaBuilder
- * Standard Java problems are associated to marker type "org.eclipse.jdt.core.problem").
- * Note: problem markers are expected to extend "org.eclipse.core.resources.problemmarker" marker type.
- * @return the type of the marker which would be associated to the problem
- */
-public abstract String getMarkerType();
-
-/**
- * Returns the names of the extra marker attributes associated to this problem when persisted into a marker
- * by the JavaBuilder. Extra attributes are only optional, and are allowing client customization of generated
- * markers. By default, no EXTRA attributes is persisted, and a categorized problem only persists the following attributes:
- * <ul>
- * <li> <code>IMarker#MESSAGE</code> -> {@link IProblem#getMessage()}</li>
- * <li> <code>IMarker#SEVERITY</code> -> <code> IMarker#SEVERITY_ERROR</code> or
- * <code>IMarker#SEVERITY_WARNING</code> depending on {@link IProblem#isError()} or {@link IProblem#isWarning()}</li>
- * <li> <code>IJavaModelMarker#ID</code> -> {@link IProblem#getID()}</li>
- * <li> <code>IMarker#CHAR_START</code> -> {@link IProblem#getSourceStart()}</li>
- * <li> <code>IMarker#CHAR_END</code> -> {@link IProblem#getSourceEnd()}</li>
- * <li> <code>IMarker#LINE_NUMBER</code> -> {@link IProblem#getSourceLineNumber()}</li>
- * <li> <code>IJavaModelMarker#ARGUMENTS</code> -> some <code>String[]</code> used to compute quickfixes </li>
- * <li> <code>IJavaModelMarker#CATEGORY_ID</code> -> {@link CategorizedProblem#getCategoryID()}</li>
- * </ul>
- * The names must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>,
- * and there must be as many names as values according to {@link #getExtraMarkerAttributeValues()}.
- * Note that extra marker attributes will be inserted after default ones (as described in {@link CategorizedProblem#getMarkerType()},
- * and thus could be used to override defaults.
- * @return the names of the corresponding marker attributes
- */
-public String[] getExtraMarkerAttributeNames() {
- return CharOperation.NO_STRINGS;
-}
-
-/**
- * Returns the respective values for the extra marker attributes associated to this problem when persisted into
- * a marker by the JavaBuilder. Each value must correspond to a matching attribute name, as defined by
- * {@link #getExtraMarkerAttributeNames()}.
- * The values must be eligible for marker creation, as defined by <code>IMarker#setAttributes(String[], Object[])</code>.
- * @return the values of the corresponding extra marker attributes
- */
-public Object[] getExtraMarkerAttributeValues() {
- return new Object[] {};
-}
-}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyModelManager.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -77,7 +77,7 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.compiler.util.HashtableOfObjectToInt;
import org.rubypeople.rdt.internal.core.buffer.BufferManager;
import org.rubypeople.rdt.internal.core.builder.RubyBuilder;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyProject.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -58,7 +58,7 @@
import org.rubypeople.rdt.core.RubyCore;
import org.rubypeople.rdt.core.RubyModelException;
import org.rubypeople.rdt.core.WorkingCopyOwner;
-import org.rubypeople.rdt.internal.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
import org.rubypeople.rdt.internal.compiler.util.ObjectVector;
import org.rubypeople.rdt.internal.core.util.MementoTokenizer;
import org.rubypeople.rdt.internal.core.util.Messages;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/RubyScriptProblemFinder.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -15,7 +15,7 @@
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.RubyModelException;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.core.parser.RdtWarnings;
import org.rubypeople.rdt.internal.core.parser.RubyParser;
import org.rubypeople.rdt.internal.core.parser.TaskParser;
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/builder/ProblemRequestorMarkerManager.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -6,7 +6,7 @@
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.rubypeople.rdt.core.IProblemRequestor;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.core.parser.TaskTag;
public class ProblemRequestorMarkerManager implements IProblemRequestor {
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/DefaultProblem.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -4,15 +4,21 @@
package org.rubypeople.rdt.internal.core.parser;
import org.jruby.lexer.yacc.ISourcePosition;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.CategorizedProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* @author Chris
*/
-abstract class DefaultProblem implements IProblem {
+abstract class DefaultProblem extends CategorizedProblem {
private ISourcePosition position;
private String message;
+ private int id;
+
+// cannot directly point to IRubyModelMarker constants from within batch compiler
+ private static final String MARKER_TYPE_PROBLEM = "org.rubypeople.rdt.core.problem"; //$NON-NLS-1$
+ private static final String MARKER_TYPE_TASK = "org.rubypeople.rdt.core.task"; //$NON-NLS-1$
/**
* @param position
@@ -21,6 +27,7 @@
public DefaultProblem(ISourcePosition position, String message) {
this.position = position;
this.message = message;
+ id = IProblem.Uncategorized;
}
/**
@@ -49,4 +56,13 @@
public String toString() {
return position.toString() + " => " + message;
}
+
+ public int getID() {
+ return this.id;
+ }
+
+ @Override
+ public String getMarkerType() {
+ return isTask() ? MARKER_TYPE_TASK : MARKER_TYPE_PROBLEM;
+ }
}
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/MarkerUtility.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -16,7 +16,7 @@
import org.jruby.lexer.yacc.SyntaxException;
import org.rubypeople.rdt.core.IRubyModelMarker;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* @author Chris
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/TaskTag.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -3,7 +3,7 @@
*/
package org.rubypeople.rdt.internal.core.parser;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
/**
* @author Chris
Modified: trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java
===================================================================
--- trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-03-14 20:24:18 UTC (rev 2173)
+++ trunk/org.rubypeople.rdt.core/src/org/rubypeople/rdt/internal/core/parser/warnings/RubyLintVisitor.java 2007-03-14 20:51:35 UTC (rev 2174)
@@ -6,7 +6,7 @@
import org.jruby.lexer.yacc.ISourcePosition;
import org.rubypeople.rdt.core.IProblemRequestor;
import org.rubypeople.rdt.core.RubyCore;
-import org.rubypeople.rdt.core.parser.IProblem;
+import org.rubypeople.rdt.core.compiler.IProblem;
import org.rubypeople.rdt.internal.core.parser.Error;
import org.rubypeople.rdt.internal.core.parser.NodeUtil;
import org.rubypeople.rdt.internal.core.parser.Warning;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <caw...@us...> - 2007-03-14 20:24:25
|
Revision: 2173
http://svn.sourceforge.net/rubyeclipse/?rev=2173&view=rev
Author: cawilliams
Date: 2007-03-14 13:24:18 -0700 (Wed, 14 Mar 2007)
Log Message:
-----------
Added Paths:
-----------
trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
Added: trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ContributedProcessorDescriptor.java
===================================================================
--- trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ContributedProcessorDescriptor.java (rev 0)
+++ trunk/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/text/correction/ContributedProcessorDescriptor.java 2007-03-14 20:24:18 UTC (rev 2173)
@@ -0,0 +1,123 @@
+/*******************************************************************************
+ * 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.text.correction;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.core.expressions.EvaluationContext;
+import org.eclipse.core.expressions.EvaluationResult;
+import org.eclipse.core.expressions.Expression;
+import org.eclipse.core.expressions.ExpressionConverter;
+import org.eclipse.core.expressions.ExpressionTagNames;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IStatus;
+import org.rubypeople.rdt.core.IRubyModelMarker;
+import org.rubypeople.rdt.core.IRubyProject;
+import org.rubypeople.rdt.core.IRubyScript;
+import org.rubypeople.rdt.internal.ui.RubyPlugin;
+import org.rubypeople.rdt.internal.ui.dialogs.StatusInfo;
+
+public final class ContributedProcessorDescriptor {
+
+ private final IConfigurationElement fConfigurationElement;
+ private Object fProcessorInstance;
+ private Boolean fStatus;
+ private boolean fLastResult;
+ private final Set fHandledMarkerTypes;
+
+ private static final String ID= "id"; //$NON-NLS-1$
+ private static final String CLASS= "class"; //$NON-NLS-1$
+
+ private static final String HANDLED_MARKER_TYPES= "handledMarkerTypes"; //$NON-NLS-1$
+ private static final String MARKER_TYPE= "markerType"; //$NON-NLS-1$
+
+ public ContributedProcessorDescriptor(IConfigurationElement element, boolean testMarkerTypes) {
+ fConfigurationElement= element;
+ fProcessorInstance= null;
+ fStatus= null; // undefined
+ if (fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT).length == 0) {
+ fStatus= Boolean.TRUE;
+ }
+ fHandledMarkerTypes= testMarkerTypes ? getHandledMarkerTypes(element) : null;
+ }
+
+ private Set getHandledMarkerTypes(IConfigurationElement element) {
+ HashSet map= new HashSet(7);
+ IConfigurationElement[] children= element.getChildren(HANDLED_MARKER_TYPES);
+ for (int i= 0; i < children.length; i++) {
+ IConfigurationElement[] types= children[i].getChildren(MARKER_TYPE);
+ for (int k= 0; k < types.length; k++) {
+ String attribute= types[k].getAttribute(ID);
+ if (attribute != null) {
+ map.add(attribute);
+ }
+ }
+ }
+ if (map.isEmpty()) {
+ map.add(IRubyModelMarker.RUBY_MODEL_PROBLEM_MARKER);
+ map.add(IRubyModelMarker.BUILDPATH_PROBLEM_MARKER);
+ map.add(IRubyModelMarker.TASK_MARKER);
+ }
+ return map;
+ }
+
+ public IStatus checkSyntax() {
+ IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
+ if (children.length > 1) {
+ String id= fConfigurationElement.getAttribute(ID);
+ return new StatusInfo(IStatus.ERROR, "Only one < enablement > element allowed. Disabling " + id); //$NON-NLS-1$
+ }
+ return new StatusInfo(IStatus.OK, "Syntactically correct quick assist/fix processor"); //$NON-NLS-1$
+ }
+
+ private boolean matches(IRubyScript cunit) {
+ if (fStatus != null) {
+ return fStatus.booleanValue();
+ }
+
+ IConfigurationElement[] children= fConfigurationElement.getChildren(ExpressionTagNames.ENABLEMENT);
+ if (children.length == 1) {
+ try {
+ ExpressionConverter parser= ExpressionConverter.getDefault();
+ Expression expression= parser.perform(children[0]);
+ EvaluationContext evalContext= new EvaluationContext(null, cunit);
+ evalContext.addVariable("rubyScript", cunit); //$NON-NLS-1$
+ IRubyProject javaProject= cunit.getRubyProject();
+ String[] natures= javaProject.getProject().getDescription().getNatureIds();
+ evalContext.addVariable("projectNatures", Arrays.asList(natures)); //$NON-NLS-1$
+ fLastResult= !(expression.evaluate(evalContext) != EvaluationResult.TRUE);
+ return fLastResult;
+ } catch (CoreException e) {
+ RubyPlugin.log(e);
+ }
+ }
+ fStatus= Boolean.FALSE;
+ return false;
+ }
+
+ public Object getProcessor(IRubyScript cunit) throws CoreException {
+ if (matches(cunit)) {
+ if (fProcessorInstance == null) {
+ fProcessorInstance= fConfigurationElement.createExecutableExtension(CLASS);
+ }
+ return fProcessorInstance;
+ }
+ return null;
+ }
+
+ public boolean canHandleMarkerType(String markerType) {
+ return fHandledMarkerTypes == null || fHandledMarkerTypes.contains(markerType);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|