[ phpeclipse-Bugs-1622108 ] IllegalArgumentException on using CDATA

"SourceForge.net" <[email protected]> Thu, 10 May 2007 22:25:51 -0700
Newsgroups gmane.comp.ide.eclipse.phpeclipse.devel
Message-ID <[email protected]>
Bugs item #1622108, was opened at 2006-12-25 14:22
Message generated for change (Comment added) made by emann
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=484801&aid=1622108&group_id=57621

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: PHP Editor
Group: 1.1.9.CVS-20060920
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Stefan Schulz (d2o)
Assigned to: Nobody/Anonymous (nobody)
Summary: IllegalArgumentException on using CDATA

Initial Comment:
I just encountered an Exception when trying to edit some PHP file from the Mediawiki distribution. I reduced it to the following line:

<![CDATA[ <?php ?> ]]>

If this is included in a PHP file, trying to open it in PHPeclipse editor results in the following exception:

java.lang.IllegalArgumentException: Argument not valid
	at org.eclipse.swt.SWT.error(SWT.java:3358)
	at org.eclipse.swt.SWT.error(SWT.java:3297)
	at org.eclipse.swt.SWT.error(SWT.java:3268)
	at org.eclipse.swt.custom.StyledText.setStyleRanges(StyledText.java:7695)
	at org.eclipse.swt.custom.StyledText.setStyleRanges(StyledText.java:7791)
	at org.eclipse.jface.text.TextViewer.applyTextPresentation(TextViewer.java:4235)
	at org.eclipse.jface.text.TextViewer.changeTextPresentation(TextViewer.java:4287)
	at org.eclipse.jface.text.presentation.PresentationReconciler.applyTextRegionCollection(PresentationReconciler.java:573)
	at org.eclipse.jface.text.presentation.PresentationReconciler.processDamage(PresentationReconciler.java:562)
	at org.eclipse.jface.text.presentation.PresentationReconciler.access$3(PresentationReconciler.java:558)
	at org.eclipse.jface.text.presentation.PresentationReconciler$InternalListener.inputDocumentChanged(PresentationReconciler.java:118)
	at org.eclipse.jface.text.TextViewer.fireInputDocumentChanged(TextViewer.java:2458)
	at org.eclipse.jface.text.TextViewer.setDocument(TextViewer.java:2507)
	at org.eclipse.jface.text.source.SourceViewer.setDocument(SourceViewer.java:521)
	at org.eclipse.jface.text.source.projection.ProjectionViewer.setDocument(ProjectionViewer.java:370)
	at org.eclipse.jface.text.source.SourceViewer.setDocument(SourceViewer.java:467)
	at org.eclipse.ui.texteditor.AbstractTextEditor.initializeSourceViewer(AbstractTextEditor.java:2937)
	at org.eclipse.ui.texteditor.AbstractTextEditor.createPartControl(AbstractTextEditor.java:2684)
	at org.eclipse.ui.texteditor.StatusTextEditor.createPartControl(StatusTextEditor.java:53)
	at org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.createPartControl(AbstractDecoratedTextEditor.java:367)
	at net.sourceforge.phpeclipse.phpeditor.PHPEditor.createPartControl(PHPEditor.java:3230)
	at net.sourceforge.phpeclipse.phpeditor.PHPUnitEditor.createPartControl(PHPUnitEditor.java:1603)
	at org.eclipse.ui.internal.EditorReference.createPartHelper(EditorReference.java:596)
	at org.eclipse.ui.internal.EditorReference.createPart(EditorReference.java:372)
	at org.eclipse.ui.internal.WorkbenchPartReference.getPart(WorkbenchPartReference.java:566)
	at org.eclipse.ui.internal.EditorReference.getEditor(EditorReference.java:214)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditorBatched(WorkbenchPage.java:2595)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:2528)
	at org.eclipse.ui.internal.WorkbenchPage.access$10(WorkbenchPage.java:2520)
	at org.eclipse.ui.internal.WorkbenchPage$9.run(WorkbenchPage.java:2505)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:2500)
	at org.eclipse.ui.actions.OpenWithMenu.openEditor(OpenWithMenu.java:288)
	at org.eclipse.ui.actions.OpenWithMenu.access$0(OpenWithMenu.java:280)
	at org.eclipse.ui.actions.OpenWithMenu$2.handleEvent(OpenWithMenu.java:184)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:928)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3348)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2968)
	at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:1914)
	at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:1878)
	at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:419)
	at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
	at org.eclipse.ui.internal.ide.IDEApplication.run(IDEApplication.java:95)
	at org.eclipse.core.internal.runtime.PlatformActivator$1.run(PlatformActivator.java:78)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:92)
	at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:68)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:400)
	at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:177)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	at org.eclipse.core.launcher.Main.invokeFramework(Main.java:336)
	at org.eclipse.core.launcher.Main.basicRun(Main.java:280)
	at org.eclipse.core.launcher.Main.run(Main.java:977)
	at org.eclipse.core.launcher.Main.main(Main.java:952)


Eclipse platform used:
Version: 3.2.1.r321_v20060921-b_XVA-INSQSyMtx
Build id: M20060921-0945

WST:
Version: 1.5.2.v200610140800--AXrVWXbElCl05G
Build id: 200610261841

----------------------------------------------------------------------

>Comment By: Edward Mann (emann)
Date: 2007-05-11 00:25

Message:
Logged In: YES 
user_id=430467
Originator: NO

This is working now in 1.1.9 CVS
Closing issue.

File Added: 1622108_sample_code.php

----------------------------------------------------------------------

Comment By: Toshihiro (toshihiro)
Date: 2007-04-05 03:09

Message:
Logged In: YES 
user_id=1527096
Originator: NO

Fixed in CVS.


----------------------------------------------------------------------

Comment By: Toshihiro (toshihiro)
Date: 2007-03-05 02:34

Message:
Logged In: YES 
user_id=1527096
Originator: NO

PTF.

net.sourceforge.phpeclipse.xml.ui.internal.text
XMLCDATAScanner.java

    public IToken nextToken() {
        offset += length;

        if (position == begin) {
//-         position += 3; // <![

            try {
//-             if (document.get(position, 6).equals("CDATA[")) {
//-                 position += 6;
//-             }
                if (document.get(position, 9).equals("<![CDATA[")) {
                    position += 9;
                }
            } catch (BadLocationException e) {
            }

XMLCDATAScanner assumes code block such as "<![CDATA[ ... ]]>".
However, actually code pieces such as "<![CDATA[ ..." or "... ]]>" is
given. Inside php block is given to PHPCodeScanner.
"position += 3" makes bad if " ]]>" is given.
(If "]]>" is given, position will point the end immediately. As a result,
it doesn't cause a problem.)


----------------------------------------------------------------------

Comment By: Muchte-C (muchte-c)
Date: 2007-02-27 04:14

Message:
Logged In: YES 
user_id=1730186
Originator: NO

Without spaces it works.
edit
<![CDATA[ <?php ?> ]]>
to
<![CDATA[<?php ?>]]>


----------------------------------------------------------------------

Comment By: Omry Yadan (omry_y)
Date: 2007-02-18 14:30

Message:
Logged In: YES 
user_id=126268
Originator: NO

just bumped into the same problem.
my php page contains some javascript code inside a cdata section, and when
I try to edit that everything gets crazy:

<script type="text/javascript">
//<![CDATA[
     EDITING HERE CAUSE EXCEPTIONS
//]]>
</script>


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=484801&aid=1622108&group_id=57621

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/