Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 342244 - [rename] rename refactoring fails on qualified local references
Summary: [rename] rename refactoring fails on qualified local references
Status: CLOSED FIXED
Alias: None
Product: TMF
Classification: Modeling
Component: Xtext (show other bugs)
Version: 2.0.0   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: M7   Edit
Assignee: Jan Koehnlein CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-08 04:34 EDT by Knut Wannheden CLA
Modified: 2017-09-19 17:49 EDT (History)
3 users (show)

See Also:
sven.efftinge: indigo+


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Knut Wannheden CLA 2011-04-08 04:34:17 EDT
Given the following Domainmodel example:

package foo {
	entity Foo {
		name : foo.Foo
	}
}

Trying to rename the entity foo.Foo doesn't do anything and logs the following error:

1 [Thread-1] ERROR org.eclipse.xtext.ui.refactoring.impl.LinkedModelCalculator  - First position: 'Foo' at 22, this position: 'foo' at 37
org.eclipse.jface.text.BadLocationException: First position: 'Foo' at 22, this position: 'foo' at 37
	at org.eclipse.jface.text.link.LinkedPositionGroup.enforceEqualContent(LinkedPositionGroup.java:132)
	at org.eclipse.jface.text.link.LinkedPositionGroup.addPosition(LinkedPositionGroup.java:113)
	at org.eclipse.xtext.ui.refactoring.impl.LinkedModelCalculator.internalGetLinkedPositionGroup(LinkedModelCalculator.java:160)
	at org.eclipse.xtext.ui.refactoring.impl.LinkedModelCalculator$1.run(LinkedModelCalculator.java:118)
	at org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:464)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:372)
	at org.eclipse.jface.window.ApplicationWindow$1.run(ApplicationWindow.java:759)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.jface.window.ApplicationWindow.run(ApplicationWindow.java:756)
	at org.eclipse.ui.internal.WorkbenchWindow.run(WorkbenchWindow.java:2579)
	at org.eclipse.xtext.ui.refactoring.impl.LinkedModelCalculator.getLinkedPositionGroup(LinkedModelCalculator.java:116)
	at org.eclipse.xtext.ui.refactoring.ui.RenameLinkedMode.start(RenameLinkedMode.java:101)
	at org.eclipse.xtext.ui.refactoring.ui.RenameElementHandler$RenameElementOperation.execute(RenameElementHandler.java:92)
	at org.eclipse.xtext.ui.refactoring.ui.RenameElementHandler.execute(RenameElementHandler.java:67)
	at org.eclipse.ui.internal.handlers.HandlerProxy.execute(HandlerProxy.java:294)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:470)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:824)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:880)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:569)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:510)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:125)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:965)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3542)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1250)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1273)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1258)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1287)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1283)
	at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:433)
	at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:523)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4655)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:202)
	at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:1753)
	at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:1825)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:4713)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
	at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4285)
	at org.eclipse.swt.widgets.Display.applicationProc(Display.java:4352)
	at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
	at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:101)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3097)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2405)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2369)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2221)
	at org.eclipse.ui.internal.Workbench$5.run(Workbench.java:500)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:493)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:113)
	at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:194)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:368)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:559)
	at org.eclipse.equinox.launcher.Main.basicRun(Main.java:514)
	at org.eclipse.equinox.launcher.Main.run(Main.java:1311)
	at org.eclipse.equinox.launcher.Main.main(Main.java:1287)

I traced the error to line 143 in LinkedModelCalculator#internalGetLinkedPositionGroup():

	String textToReplace = edit.getText();

ReplaceEdit#getText() returns the replacement text and not the original text. Instead I think this should read something like:

	String textToReplace = getDocument().get(edit.getOffset(), edit.getLength());

With this change the rename succeeds.
Comment 1 Jan Koehnlein CLA 2011-04-08 10:09:31 EDT
Pushed to master.

Note: As we calculate the replacement text for a cross-reference using the ICrossReferenceSerializer, the qualified name will be replaced with the local version if the scopes are configured correctly.
Comment 2 Karsten Thoms CLA 2017-09-19 17:38:36 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 3 Karsten Thoms CLA 2017-09-19 17:49:47 EDT
Closing all bugs that were set to RESOLVED before Neon.0