Bug 49966 - Assertion failed while creating copy of compilation unit
Summary: Assertion failed while creating copy of compilation unit
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M7   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 49994
Blocks:
  Show dependency tree
 
Reported: 2004-01-14 05:31 EST by Christof Marti CLA
Modified: 2004-02-12 12:06 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Christof Marti CLA 2004-01-14 05:31:10 EST
CreateCopyOfCompilationUnitChange.createChangeManager passed a negative offset
to the constructor of ReplaceEdit. This is reproducible with one specific
compilation unit (a modified AbstractTextEditor, no errors, no warnings):
- start eclipse
- click on AbstractTextEditor in Package Explorer
- Ctrl-C, Ctrl-V
- confirm suggested new name with Enter
-> Error dialog box with undo/abort buttons: "An exception has been caught while
processing the change 'Create file:/test/src/test4/CopyOfAbstractTextEditor'.

Reason:
  Assertion failed:
" - and nothing more apart from the description of the buttons.

From the log:
org.eclipse.jface.text.Assert$AssertionFailedException: Assertion failed: 
	at org.eclipse.jface.text.Assert.isTrue(Assert.java:175)
	at org.eclipse.jface.text.Assert.isTrue(Assert.java:160)
	at org.eclipse.text.edits.TextEdit.<init>(TextEdit.java:137)
	at org.eclipse.text.edits.ReplaceEdit.<init>(ReplaceEdit.java:35)
	at
org.eclipse.jdt.internal.corext.refactoring.reorg.CreateCopyOfCompilationUnitChange.createChangeManager(CreateCopyOfCompilationUnitChange.java:103)
	at
org.eclipse.jdt.internal.corext.refactoring.reorg.CreateCopyOfCompilationUnitChange.getCopiedFileSource(CreateCopyOfCompilationUnitChange.java:81)
	at
org.eclipse.jdt.internal.corext.refactoring.reorg.CreateCopyOfCompilationUnitChange.getOldFile(CreateCopyOfCompilationUnitChange.java:63)
	at
org.eclipse.jdt.internal.corext.refactoring.nls.changes.CreateFileChange.perform(CreateFileChange.java:79)
	at
org.eclipse.jdt.internal.corext.refactoring.CompositeChange.createUndoList(CompositeChange.java:122)
	at
org.eclipse.jdt.internal.corext.refactoring.CompositeChange.perform(CompositeChange.java:149)
	at
org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper$1.run(RefactoringExecutionHelper.java:80)
	at
org.eclipse.jdt.internal.core.BatchOperation.executeOperation(BatchOperation.java:34)
	at
org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:698)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1555)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1574)
	at org.eclipse.jdt.core.JavaCore.run(JavaCore.java:3129)
	at
org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper$Operation.run(RefactoringExecutionHelper.java:78)
	at
org.eclipse.jface.operation.ModalContext.runInCurrentThread(ModalContext.java:302)
	at org.eclipse.jface.operation.ModalContext.run(ModalContext.java:252)
	at
org.eclipse.jface.dialogs.ProgressMonitorDialog.run(ProgressMonitorDialog.java:394)
	at
org.eclipse.jdt.internal.ui.refactoring.RefactoringExecutionHelper.perform(RefactoringExecutionHelper.java:130)
	at
org.eclipse.jdt.internal.ui.refactoring.reorg.ReorgCopyStarter.run(ReorgCopyStarter.java:70)
	at
org.eclipse.jdt.internal.ui.refactoring.reorg.PasteAction$JavaElementAndResourcePaster.paste(PasteAction.java:402)
	at
org.eclipse.jdt.internal.ui.refactoring.reorg.PasteAction.run(PasteAction.java:189)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:212)
	at
org.eclipse.jdt.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:188)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:842)
	at org.eclipse.ui.actions.RetargetAction.runWithEvent(RetargetAction.java:212)
	at org.eclipse.ui.internal.commands.ActionHandler.execute(ActionHandler.java:40)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:390)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:763)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:803)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:486)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$0(WorkbenchKeyboard.java:421)
	at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$1.handleEvent(WorkbenchKeyboard.java:215)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:82)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:692)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:846)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:871)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:856)
	at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1716)
	at org.eclipse.swt.widgets.Control.sendKeyEvent(Control.java:1712)
	at org.eclipse.swt.widgets.Control.WM_CHAR(Control.java:3036)
	at org.eclipse.swt.widgets.Tree.WM_CHAR(Tree.java:1292)
	at org.eclipse.swt.widgets.Control.windowProc(Control.java:2939)
	at org.eclipse.swt.widgets.Display.windowProc(Display.java:2836)
	at org.eclipse.swt.internal.win32.OS.DispatchMessageW(Native Method)
	at org.eclipse.swt.internal.win32.OS.DispatchMessage(OS.java:1369)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:1990)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1506)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1482)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:246)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:139)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:47)
	at
org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:226)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:85)
	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:324)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:279)
	at org.eclipse.core.launcher.Main.run(Main.java:742)
	at org.eclipse.core.launcher.Main.main(Main.java:581)
Comment 1 Markus Keller CLA 2004-01-14 12:16:50 EST
The exception is thrown due to two inexact matches with erroneous start and end.
Temporarily fixed in CreateCopyOfCompilationUnitChange by not considering
inexact matches.
Comment 2 Markus Keller CLA 2004-02-12 12:05:47 EST
Fixed. Not considering inexact matches is in general a gooo idea for refactorings.
Comment 3 Markus Keller CLA 2004-02-12 12:06:29 EST
Verified in 200402120010