Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 326776

Summary: AssertionFailedException, when editing
Product: z_Archived Reporter: Jacek Pospychala <jacek.pospychala>
Component: PDTAssignee: PHP UI <php.ui-inbox>
Status: CLOSED FIXED QA Contact: Ilina Stefanova <ilina.s>
Severity: major    
Priority: P3 CC: kalin.a, qiangsheng.w
Version: unspecifiedFlags: zhaozhongwei: review? (ganoro)
qiangsheng.w: review+
jacek.pospychala: review+
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
patch
none
patch none

Description Jacek Pospychala CLA 2010-10-01 09:19:12 EDT
With code from CVS

Remove all text from editor (ex. Ctrl+A and then Ctrl+X).
Note that following exception is thrown and logged:

org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
    at org.eclipse.core.runtime.Assert.isTrue(Assert.java:110)
    at org.eclipse.core.runtime.Assert.isTrue(Assert.java:96)
    at
org.eclipse.jface.text.TextPresentation.<init>(TextPresentation.java:169)
    at
org.eclipse.jface.text.TextPresentation.<init>(TextPresentation.java:182)
    at
org.eclipse.php.internal.ui.editor.configuration.PHPStructuredPresentationReconciler.createPresentation(PHPStructuredPresentationReconciler.java:238)
    at
org.eclipse.wst.sse.ui.internal.provisional.style.StructuredPresentationReconciler.processDamage(StructuredPresentationReconciler.java:862)
    at
org.eclipse.wst.sse.ui.internal.provisional.style.StructuredPresentationReconciler.processRecordedDamages(StructuredPresentationReconciler.java:840)
    at
org.eclipse.wst.sse.ui.internal.provisional.style.StructuredPresentationReconciler$InternalListener.textChanged(StructuredPresentationReconciler.java:414)
    at
org.eclipse.jface.text.TextViewer.updateTextListeners(TextViewer.java:2820)
    at
org.eclipse.jface.text.TextViewer$VisibleDocumentListener.documentChanged(TextViewer.java:401)
    at
org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged2(AbstractDocument.java:769)
    at
org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:736)
    at
org.eclipse.jface.text.AbstractDocument.doFireDocumentChanged(AbstractDocument.java:721)
    at
org.eclipse.jface.text.AbstractDocument.fireDocumentChanged(AbstractDocument.java:796)
    at
org.eclipse.jface.text.projection.ProjectionDocument.fireDocumentChanged(ProjectionDocument.java:777)
    at
org.eclipse.jface.text.projection.ProjectionDocument.masterDocumentChanged(ProjectionDocument.java:746)
    at
org.eclipse.jface.text.projection.ProjectionDocumentManager.fireDocumentEvent(ProjectionDocumentManager.java:123)
    at
org.eclipse.jface.text.projection.ProjectionDocumentManager.documentChanged(ProjectionDocumentManager.java:131)
    at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument._fireDocumentChanged(BasicStructuredDocument.java:460)
    at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.fireStructuredDocumentEvent(BasicStructuredDocument.java:1202)
    at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.internalReplaceText(BasicStructuredDocument.java:1979)
    at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2419)
    at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replaceText(BasicStructuredDocument.java:2404)
    at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.access$2(JobSafeStructuredDocument.java:1)
    at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument$3.run(JobSafeStructuredDocument.java:141)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at
org.eclipse.wst.sse.ui.EditorExecutionContext.execute(EditorExecutionContext.java:149)
    at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replaceText(JobSafeStructuredDocument.java:144)
    at
org.eclipse.wst.sse.core.internal.text.BasicStructuredDocument.replace(BasicStructuredDocument.java:2364)
    at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.access$0(JobSafeStructuredDocument.java:1)
    at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument$1.run(JobSafeStructuredDocument.java:103)
    at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
    at
org.eclipse.wst.sse.ui.EditorExecutionContext.execute(EditorExecutionContext.java:149)
    at
org.eclipse.wst.sse.core.internal.text.JobSafeStructuredDocument.replace(JobSafeStructuredDocument.java:106)
    at
org.eclipse.text.edits.DeleteEdit.performDocumentUpdating(DeleteEdit.java:64)
    at
org.eclipse.text.edits.TextEdit.traverseDocumentUpdating(TextEdit.java:917)
    at
org.eclipse.text.edits.TextEditProcessor.executeDo(TextEditProcessor.java:194)
    at org.eclipse.text.edits.TextEdit.dispatchPerformEdits(TextEdit.java:739)
    at
org.eclipse.text.edits.TextEditProcessor.performEdits(TextEditProcessor.java:156)
    at org.eclipse.text.edits.TextEdit.apply(TextEdit.java:711)
    at
org.eclipse.jface.internal.text.SelectionProcessor.doDelete(SelectionProcessor.java:641)
    at
org.eclipse.jface.text.source.projection.ProjectionViewer.deleteSelection(ProjectionViewer.java:1641)
    at
org.eclipse.jface.text.source.projection.ProjectionViewer.copyToClipboard(ProjectionViewer.java:1625)
    at
org.eclipse.jface.text.source.projection.ProjectionViewer.doOperation(ProjectionViewer.java:1472)
    at
org.eclipse.wst.sse.ui.internal.StructuredTextViewer.doOperation(StructuredTextViewer.java:425)
    at
org.eclipse.php.internal.ui.editor.PHPStructuredTextViewer.doOperation(PHPStructuredTextViewer.java:305)
    at
org.eclipse.ui.texteditor.TextOperationAction$1.run(TextOperationAction.java:131)
    at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
    at
org.eclipse.ui.texteditor.TextOperationAction.run(TextOperationAction.java:129)
    at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
    at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
    at
org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
    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:468)
    at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
    at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
    at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
    at
org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
    at
org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1031)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3775)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1367)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1390)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1375)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1404)
    at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1400)
    at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:416)
    at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:958)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5068)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at
org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:56)
    at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:587)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:4978)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
    at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:1943)
    at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2025)
    at org.eclipse.swt.widgets.Display.windowProc(Display.java:5040)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
    at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4582)
    at org.eclipse.swt.widgets.Display.applicationProc(Display.java:4659)
    at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
    at
org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:115)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3274)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2640)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2604)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2438)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:671)
    at
org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at
org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:664)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at
org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:115)
    at
org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    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:369)
    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:619)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:574)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1407)
    at org.eclipse.equinox.launcher.Main.main(Main.java:1383)
Comment 1 Jacek Pospychala CLA 2010-10-05 10:58:28 EDT
it also happens always when editing between <script> tag in the document.
try editing e.g following doc:
<html>


<?php 


?>

<script type="text/javascript">
// edit here

</script>


</html>
Comment 2 Zhongwei Zhao CLA 2010-10-06 03:59:44 EDT
Created attachment 180299 [details]
patch
Comment 3 Jacek Pospychala CLA 2010-10-06 07:16:14 EDT
Patch looks weird at first look, but works. The sizeHint parameter (where we're passing 0 in some cases) is used to initialize ArrayList. By default TextPresentation uses 50, unless sizeHint is specified, so passing 0 throws an Exception, because "new ArrayList(0)" is invalid. If we're creating TextPresentation for 0 ranges, passing 0 will fail, but 1 as well as any other value  is ok.

Btw it sounds more like an issue with TextPresentation, because ArrayList(capacity) fails only for sizes<0, and works fine with 0.
Comment 4 Jacek Pospychala CLA 2010-10-06 07:22:24 EDT
fyi, out of curiosity I opened bug 327091 with jface folks.. :-)
Comment 5 Q.S. Wang CLA 2010-10-06 23:32:53 EDT
Fro the case of fRanges.size()==0, shall we return a null presentation or do what the patch does now?
Comment 6 Zhongwei Zhao CLA 2010-10-07 00:22:57 EDT
HI QS

thanks for suggestion,I will try it,if everything works fine I think it is better to return null.
Comment 7 Zhongwei Zhao CLA 2010-10-07 01:16:34 EDT
Created attachment 180384 [details]
patch
Comment 8 Zhongwei Zhao CLA 2010-10-07 11:11:42 EDT
fixed
Comment 9 Kalin CLA 2011-07-29 06:48:54 EDT
Verified.
Closing...