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

Bug 318586

Summary: ClassCastException when opening PHP file from within the code
Product: z_Archived Reporter: Jacek Jaroczynski <jacek.jaroczynski>
Component: PDTAssignee: PHP Core <php.core-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: silviya, zhaozhongwei
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Jacek Jaroczynski CLA 2010-07-01 08:00:50 EDT
Build Identifier: version 2.2 on Eclipse 3.6

I use following code to open local PHP file:

PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().openEditor(
new MyIEditorInputImplementation(), "org.eclipse.php.editor");

and I get following error:

java.lang.ClassCastException: org.eclipse.jface.text.Document cannot be cast to org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.computeHeaderComment(StructuredTextFoldingProviderPHP.java:1484)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.computeProjectionRanges(StructuredTextFoldingProviderPHP.java:1449)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.computeFoldingStructure(StructuredTextFoldingProviderPHP.java:1377)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.computeFoldingStructure(StructuredTextFoldingProviderPHP.java:1318)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.computeFoldingStructure(StructuredTextFoldingProviderPHP.java:1308)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.update(StructuredTextFoldingProviderPHP.java:1222)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.initialize(StructuredTextFoldingProviderPHP.java:1022)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.handleProjectionEnabled(StructuredTextFoldingProviderPHP.java:916)
	at org.eclipse.php.internal.ui.folding.StructuredTextFoldingProviderPHP.projectionEnabled(StructuredTextFoldingProviderPHP.java:1917)
	at org.eclipse.php.internal.ui.folding.PHPFoldingStructureProviderProxy.projectionEnabled(PHPFoldingStructureProviderProxy.java:43)
	at org.eclipse.php.internal.ui.editor.PHPStructuredEditor.installProjectionSupport(PHPStructuredEditor.java:2238)
	at org.eclipse.php.internal.ui.editor.PHPStructuredEditor.createPartControl(PHPStructuredEditor.java:2247)
	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:2674)
	at com.atlassian.connector.eclipse.internal.crucible.ui.operations.OpenVirtualFileJob$FileContentFetchingFromCrucibleOperation$1.run(OpenVirtualFileJob.java:293)
	at org.eclipse.swt.widgets.RunnableLock.run(RunnableLock.java:35)
	at org.eclipse.swt.widgets.Synchronizer.runAsyncMessages(Synchronizer.java:134)
	at org.eclipse.swt.widgets.Display.runAsyncMessages(Display.java:4041)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3660)
	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(Unknown Source)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.lang.reflect.Method.invoke(Unknown Source)
	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)


Reproducible: Always
Comment 1 Zhongwei Zhao CLA 2010-07-01 08:14:44 EDT
Hi
I think you develop plugin based on pdt,I have added a judgement:
		if (!(ctx.getDocument() instanceof IStructuredDocument)) {
			return null;
		}

so,if I am right,can you check out the latest code from cvs head to verify this bug,because our QA and I could not verify this bug fixed or not,thanks!

Now I marked as fixed,please feel free to reopen it if this bug could still be reproduced.
Comment 2 Jacek Jaroczynski CLA 2010-07-02 05:00:16 EDT
I checked the head from CVS and it works without CCE now. Thank you!!!
However the editor is open without PHP highlighting. It says that content type is not set while it is (no stacktrace unfortunately). I will check that and perhaps open next ticket.
Comment 3 Zhongwei Zhao CLA 2010-07-02 05:04:48 EDT
OK,thanks,but php highlighting is based on wtp sse,so I am not sure if it could work for your plugin:)
Comment 4 Jacek Jaroczynski CLA 2010-07-02 05:11:43 EDT
Hmm. It works for PHP files opened from ProjectExplorer so why it could not work when open from within the code?
Moreover it works fine in both cases (code and explorer) for Java files.
Comment 5 Zhongwei Zhao CLA 2010-07-02 06:09:08 EDT
(In reply to comment #4)
> Hmm. It works for PHP files opened from ProjectExplorer so why it could not
> work when open from within the code?
> Moreover it works fine in both cases (code and explorer) for Java files.

if it works when open from ProjectExplorer ,it should work when open from within the code:)
Comment 6 Jacek Jaroczynski CLA 2010-07-05 02:18:58 EDT
Nevertheless it does not work for files from outside the workspace. It looks like it is a deeper problem. I need to debug it more. 

Thank you once again for quick fix.
Comment 7 Sylvia Tancheva CLA 2010-09-02 04:39:43 EDT
Hi
Can we close this issue if the original problem is fixed?
Thanks
Comment 8 Zhongwei Zhao CLA 2010-09-02 04:51:46 EDT
Hi Silviya

You can close it now:)
Comment 9 Sylvia Tancheva CLA 2010-09-02 04:55:34 EDT
Thanks. Closing