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

Bug 322217

Summary: IllegalArgumentException instead of PHP Editor after changing syntax highlighting preferences
Product: z_Archived Reporter: Jacek Pospychala <jacek.pospychala>
Component: PDTAssignee: PHP UI <php.ui-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P1 CC: silviya, zhaozhongwei
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
sample
none
workaround
none
patch none

Description Jacek Pospychala CLA 2010-08-10 07:07:01 EDT
After changing syntax highlighting preferences, opening almost any php files ends with unusable PHP editor only with stack trace of an error:

java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:4064)
	at org.eclipse.swt.SWT.error(SWT.java:3998)
	at org.eclipse.swt.SWT.error(SWT.java:3969)
	at org.eclipse.swt.custom.StyledText.setStyleRanges(StyledText.java:9670)
	at org.eclipse.swt.custom.StyledText.replaceStyleRanges(StyledText.java:7701)
	at org.eclipse.jface.text.TextViewer.addPresentation(TextViewer.java:4803)
	at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4882)
	at org.eclipse.wst.sse.ui.internal.provisional.style.StructuredPresentationReconciler.applyTextRegionCollection(StructuredPresentationReconciler.java:893)
	at org.eclipse.wst.sse.ui.internal.provisional.style.StructuredPresentationReconciler.processDamage(StructuredPresentationReconciler.java:868)
	at org.eclipse.wst.sse.ui.internal.provisional.style.StructuredPresentationReconciler$InternalListener.textChanged(StructuredPresentationReconciler.java:420)
	at org.eclipse.jface.text.TextViewer.updateTextListeners(TextViewer.java:2820)
	at org.eclipse.jface.text.TextViewer.invalidateTextPresentation(TextViewer.java:3463)
	at org.eclipse.jface.text.source.AnnotationPainter.invalidateTextPresentation(AnnotationPainter.java:962)
	at org.eclipse.jface.text.source.AnnotationPainter.updatePainting(AnnotationPainter.java:944)
	at org.eclipse.jface.text.source.AnnotationPainter.paint(AnnotationPainter.java:1635)
	at org.eclipse.ui.texteditor.SourceViewerDecorationSupport.updateAnnotationPainter(SourceViewerDecorationSupport.java:837)
	at org.eclipse.ui.texteditor.SourceViewerDecorationSupport.updateTextDecorations(SourceViewerDecorationSupport.java:322)
	at org.eclipse.ui.texteditor.SourceViewerDecorationSupport.install(SourceViewerDecorationSupport.java:285)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.createPartControl(AbstractDecoratedTextEditor.java:434)
	at org.eclipse.wst.sse.ui.StructuredTextEditor.createPartControl(StructuredTextEditor.java:1451)
	at org.eclipse.php.internal.ui.editor.PHPStructuredEditor.createPartControl(PHPStructuredEditor.java:2243)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:670)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:465)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:595)
	at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:289)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2863)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2768)
	at org.eclipse.ui.internal.WorkbenchPage.access$11(WorkbenchPage.java:2760)
	at org.eclipse.ui.internal.WorkbenchPage$10.run(WorkbenchPage.java:2711)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2707)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2691)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2682)
	at org.eclipse.dltk.internal.ui.editor.EditorUtility.openInEditor(EditorUtility.java:405)
	at org.eclipse.dltk.internal.ui.editor.EditorUtility.openInEditor(EditorUtility.java:166)
	at org.eclipse.php.internal.ui.actions.OpenActionUtil.open(OpenActionUtil.java:54)
	at org.eclipse.php.internal.ui.actions.OpenAction.run(OpenAction.java:177)
	at org.eclipse.php.internal.ui.actions.OpenAction.run(OpenAction.java:151)
	at org.eclipse.php.internal.ui.actions.SelectionDispatchAction.dispatchRun(SelectionDispatchAction.java:190)
	at org.eclipse.php.internal.ui.actions.SelectionDispatchAction.run(SelectionDispatchAction.java:168)
	at org.eclipse.php.internal.ui.actions.PHPExplorerActionGroup.handleOpen(PHPExplorerActionGroup.java:144)
	at org.eclipse.dltk.internal.ui.scriptview.ScriptExplorerPart$4.open(ScriptExplorerPart.java:667)
	at org.eclipse.jface.viewers.StructuredViewer$2.run(StructuredViewer.java:845)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.ui.internal.JFaceUtil$1.run(JFaceUtil.java:49)
	at org.eclipse.jface.util.SafeRunnable.run(SafeRunnable.java:175)
	at org.eclipse.jface.viewers.StructuredViewer.fireOpen(StructuredViewer.java:843)
	at org.eclipse.jface.viewers.StructuredViewer.handleOpen(StructuredViewer.java:1131)
	at org.eclipse.jface.viewers.StructuredViewer$6.handleOpen(StructuredViewer.java:1235)
	at org.eclipse.jface.util.OpenStrategy.fireOpenEvent(OpenStrategy.java:264)
	at org.eclipse.jface.util.OpenStrategy.access$2(OpenStrategy.java:258)
	at org.eclipse.jface.util.OpenStrategy$1.handleEvent(OpenStrategy.java:298)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
	at org.eclipse.swt.widgets.Display.sendEvent(Display.java:3776)
	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.notifyListeners(Widget.java:1187)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3622)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3277)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2629)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2593)
	at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2427)
	at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:670)
	at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:663)
	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-08-10 07:12:51 EDT
Created attachment 176223 [details]
sample

sample php file
Comment 2 Jacek Pospychala CLA 2010-08-10 07:26:34 EDT
Unfortunately, I can't narrow down the exact set of preferences that cause this issue, but I can provide a sample preferences file which causes the issue. (email me)
Comment 3 Jacek Pospychala CLA 2010-08-10 07:28:03 EDT
Created attachment 176225 [details]
workaround

a simple workaround is to guard against zero or negative length StyleRanges.
Comment 4 Jacek Pospychala CLA 2010-08-10 07:29:06 EDT
I'm upping priority, because this issue makes php editor unusable at all after switching some preferences settings.
Comment 5 Zhongwei Zhao CLA 2010-08-10 07:38:37 EDT
the patch seems ok for me:)
Comment 6 Jacek Pospychala CLA 2010-08-10 10:20:02 EDT
this workaround makes sense only in short term, e.g. for the branch.

As a final solution, we should understand why empty/negative length StyleRanges are created. Maybe there's something wrong with calculating lengths. This could result in some styles being incorrect, or invisible - something that I'm not able to verify, but might be happening, until we understand why StyleRanges are generated incorrectly.
Comment 7 Zhongwei Zhao CLA 2010-08-10 19:22:49 EDT
OK,and I will have a look at it later:)
Comment 8 Jacek Pospychala CLA 2010-08-11 03:04:40 EDT
fyi, I committed the workaround to the branch, but leave the bug OPEN for proper solution.
Comment 9 Zhongwei Zhao CLA 2010-08-12 01:40:32 EDT
Created attachment 176436 [details]
patch
Comment 10 Jacek Pospychala CLA 2010-08-30 02:35:22 EDT
Zhao,
your patch looks good.
I'll mark this bug as fixed, because I believe this patch is already in branch and head.

Thanks!
Comment 11 Sylvia Tancheva CLA 2010-09-03 08:51:07 EDT
Verified with assistance from Jacek. Thanks
Closing