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

Bug 161397

Summary: Closing a PHP editor window causes a NPE
Product: z_Archived Reporter: Craig Daniels <craig.daniels>
Component: PDTAssignee: Guy Gurfinkel <guy.g>
Status: CLOSED FIXED QA Contact: Yossi Luson <yossi.l>
Severity: normal    
Priority: P2 CC: bask8625, georg.sendt, jason.belich, rsgemignani
Version: unspecifiedKeywords: plan
Target Milestone: ---   
Hardware: Macintosh   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:
Attachments:
Description Flags
example patch for .project files none

Description Craig Daniels CLA 2006-10-18 08:39:43 EDT
With Eclipse 3.2.1 and PHP IDE 0.2.5 running on OS X 10.4.8 (8L2127), I get an error when I close a PHP editor window.  Happens every time.

!ENTRY org.eclipse.ui.workbench 4 2 2006-10-18 08:27:09.725
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.php.core.phpModel.parser.PHPWorkspaceModelManager.addFileToModel(Unknown Source)
	at org.eclipse.php.ui.editor.PHPStructuredEditor$2.perspectiveChanged(Unknown Source)
	at org.eclipse.ui.internal.PerspectiveListenerList$5.run(PerspectiveListenerList.java:151)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:843)
	at org.eclipse.ui.internal.PerspectiveListenerList.fireEvent(PerspectiveListenerList.java:58)
	at org.eclipse.ui.internal.PerspectiveListenerList.firePerspectiveChanged(PerspectiveListenerList.java:149)
	at org.eclipse.ui.internal.WorkbenchWindow.firePerspectiveChanged(WorkbenchWindow.java:1273)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1248)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1333)
	at org.eclipse.ui.internal.CloseEditorAction.run(CloseEditorAction.java:40)
	at org.eclipse.jface.action.Action.runWithEvent(Action.java:499)
	at org.eclipse.jface.commands.ActionHandler.execute(ActionHandler.java:119)
	at org.eclipse.core.commands.Command.executeWithChecks(Command.java:461)
	at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:424)
	at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:160)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:466)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:799)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:846)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:564)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:506)
	at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:122)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1109)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1495)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1505)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1557)
	at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1552)
	at org.eclipse.swt.widgets.Control.kEventUnicodeKeyPressed(Control.java:1820)
	at org.eclipse.swt.widgets.Composite.kEventUnicodeKeyPressed(Composite.java:583)
	at org.eclipse.swt.widgets.Control.kEventTextInputUnicodeForKeyEvent(Control.java:1812)
	at org.eclipse.swt.widgets.Widget.textInputProc(Widget.java:2000)
	at org.eclipse.swt.widgets.Display.textInputProc(Display.java:3838)
	at org.eclipse.swt.internal.carbon.OS.SendEventToEventTarget(Native Method)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2910)
	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(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	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)
Comment 1 Charlie Surface CLA 2006-11-02 10:02:33 EST
I'm also seeing this on Windows XP running the IBM JDK 1.5.0_02.  My Eclipse version is 3.2.0 M20060609-1217 with PHP IDE 0.2.5.  The problem also occurs during close all (Ctrl + Shift + F4).
Comment 2 Eden Klein CLA 2006-11-05 04:00:42 EST
Please install the new version 0.7.0.v20061017 (try the all-in-one)
and see if you are able to recreate the problem.
Comment 3 Craig Daniels CLA 2006-11-06 09:12:04 EST
Using phpide-all-in-one-I20061017-macosx-carbon pointed at the same workspace, I get this error closing an editor tab:

!ENTRY org.eclipse.ui.workbench 4 2 2006-11-06 09:10:21.170
!MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.ui.workbench".
!STACK 0
java.lang.NullPointerException
	at org.eclipse.php.core.phpModel.parser.PHPWorkspaceModelManager.addFileToModel(Unknown Source)
	at org.eclipse.php.ui.editor.PHPStructuredEditor$2.perspectiveChanged(Unknown Source)
	at org.eclipse.ui.internal.PerspectiveListenerList$5.run(PerspectiveListenerList.java:151)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:37)
	at org.eclipse.core.runtime.Platform.run(Platform.java:843)
	at org.eclipse.ui.internal.PerspectiveListenerList.fireEvent(PerspectiveListenerList.java:58)
	at org.eclipse.ui.internal.PerspectiveListenerList.firePerspectiveChanged(PerspectiveListenerList.java:149)
	at org.eclipse.ui.internal.WorkbenchWindow.firePerspectiveChanged(WorkbenchWindow.java:1273)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditors(WorkbenchPage.java:1248)
	at org.eclipse.ui.internal.WorkbenchPage.closeEditor(WorkbenchPage.java:1324)
	at org.eclipse.ui.internal.EditorPane.doHide(EditorPane.java:54)
	at org.eclipse.ui.internal.PartStack.close(PartStack.java:499)
	at org.eclipse.ui.internal.EditorStack.close(EditorStack.java:205)
	at org.eclipse.ui.internal.PartStack$1.close(PartStack.java:106)
	at org.eclipse.ui.internal.presentations.util.TabbedStackPresentation$1.handleEvent(TabbedStackPresentation.java:81)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:267)
	at org.eclipse.ui.internal.presentations.util.AbstractTabFolder.fireEvent(AbstractTabFolder.java:276)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder.access$1(DefaultTabFolder.java:1)
	at org.eclipse.ui.internal.presentations.defaultpresentation.DefaultTabFolder$1.closeButtonPressed(DefaultTabFolder.java:67)
	at org.eclipse.ui.internal.presentations.PaneFolder.notifyCloseListeners(PaneFolder.java:580)
	at org.eclipse.ui.internal.presentations.PaneFolder$3.close(PaneFolder.java:187)
	at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:2107)
	at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:292)
	at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:66)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1496)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1520)
	at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1505)
	at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1279)
	at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3312)
	at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:2941)
	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(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:585)
	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)

Launching Eclipse had this error:
!ENTRY org.eclipse.core.resources 2 1 2006-11-06 08:59:34.119
!MESSAGE Skipping builder net.sourceforge.phpeclipse.parserbuilder for project mystore. Either the builder is missing from the install, or it belongs to a project nature that is missing or disabled.


I'm not sure if it's related or not.
Comment 4 Gadi Goldbarg CLA 2006-11-06 10:07:15 EST
Craig, i can't recreate the problem.
There is a newer version than the one i told you to try: 20061026
Please try with a new and clean workspace and see if you still get the same problem. If you do get the problem, please attach your workspace as a zip
Thanks
Comment 5 Craig Daniels CLA 2006-11-06 10:43:42 EST
I do not have the problem using phpide-all-in-one-S20061026-M3-macosx-carbon with a new workspace.  Looks like something in my project/workspace setup is causing the problem.
Comment 6 Eden Klein CLA 2006-11-06 11:38:23 EST
Thanks. I am closing the bug.
Can you recognize the problem in the old workspace or send it to us?
(it could help prevent future bugs..)
Comment 7 Charlie Surface CLA 2006-11-06 16:34:40 EST
It's still occurring for me on phpide-all-in-one-I20061017-win32.zip Windows XP using a brand new workspace.  It sounds like there's a newer version of the all in one though, so I'll try it and report back.
Comment 8 Charlie Surface CLA 2006-11-06 17:45:09 EST
The problem is also occurring on 0.7.0.v20061026.  The scenario is easily reproducible for me.  I cleaned out my workspace directory before launching the new version of the workbench.  Then I installed Subclipse 1.0.3 and connected to my repository.  After install and restart, I open my repository and select a folder for Checkout.  I choose the "Check out as a project in the workspace" option and leave the directory name as the project name.  Then I do "Next", leave the current workspace as the location, and "Finish".  Once the project is created, I open the PHP perspective and then open a few .php files from the project.  Then pressing Ctrl+Shift+F4 causes the error every time.

I'll try to come up with a simpler test case, because I can't post the exact files I'm using.
Comment 9 Charlie Surface CLA 2006-11-06 17:47:14 EST
Please note that the folder I checkout from SVN does not contain a .project file.
Comment 10 Charlie Surface CLA 2006-11-06 18:07:52 EST
After playing around with the .project file, I got the scenario to work by adding the proper buildCommand and nature elements from another PHP project.  So I'm partially to blame here for not converting the project correctly.  However, I still don't like seeing error messages like this, so please consider reopening the bug and getting rid of the NPE.  If I get a chance, I'll take a look at the source and suggest a fix.

Additionally, it would be nice if there were an option to do the project conversion manually.    If you've ever seen the CDT plugin, they offer an option under the New Project wizard to convert an existing project to a CDT project.  
Comment 11 Charlie Surface CLA 2006-11-07 10:04:04 EST
The model being returned for files in a non-PHP project is null.  This value seems reasonable since the call to getModelForProject() sets forceCreation to false, meaning that the model won't get created if it doesn't already exist.  So a null check on line 478 of PHPWorkspaceModelManager.java should fix the issue, unless there's some reason to add these files to the model.
Comment 12 Guy Gurfinkel CLA 2006-11-15 04:30:08 EST
Changed, Thanks.
Comment 13 Guy Gurfinkel CLA 2006-11-22 10:38:08 EST
*** Bug 164551 has been marked as a duplicate of this bug. ***
Comment 14 Guy Gurfinkel CLA 2006-11-22 10:39:33 EST
*** Bug 162205 has been marked as a duplicate of this bug. ***
Comment 15 Jason Belich CLA 2006-11-22 10:49:29 EST
IF this is an issue of .project files or 'PHP project' vs other type of project. Just how does one fix the situation?

I just downloaded the latest release and i'm still getting this problem.
Comment 16 Jason Belich CLA 2006-11-22 11:07:43 EST
Created attachment 54343 [details]
example patch for .project files
Comment 17 Jason Belich CLA 2006-11-22 11:08:12 EST
Okay, this needs to be automatic, or a simple 'convert to PHP project' menu item added. For future reference, I've attached a patch for an example .project file
Comment 18 Guy Gurfinkel CLA 2006-11-23 03:37:23 EST
when you are checking out a project which is not a php project you need to use 
the "Check out as project configured using the New Project Wizard".

There are no conversions between projects in Eclipse, (and I'm not sure there 
is a need)
Comment 19 Charlie Surface CLA 2006-11-25 10:47:53 EST
There is a problem with this approach.  The "Check out as project configured using the New Project Wizard" option is not available if the .project file exists (at least for CVS repositories).  This can occur in a mixed language environment (Java project with PHP files).  It's not reasonable to assume that PHP is the only language in use.  Presumably this is the reason that the CDT tooling has the ability to add CDT builders to a non-CDT project.

Further, what happens when you add the first PHP file to a non-PHP project?  In this situation, the repository checkout process cannot help.

Comment 20 Guy Gurfinkel CLA 2006-12-11 02:42:49 EST
you have a point here, we'll investigate this, thanks for the feedback
Comment 21 Stefano Rosanelli CLA 2007-03-03 08:34:10 EST
(In reply to comment #20)
> you have a point here, we'll investigate this, thanks for the feedback

I had the same problem but after the last update using:

 * Eclipse SDK 3.2.2 - Build M20070212-1330
 * PDT SDK 0.7.0.v20070221

It doesn't happen anymore, I believe it's fixed now
 
Comment 22 Stefano Rosanelli CLA 2007-03-03 08:34:22 EST
(In reply to comment #20)
> you have a point here, we'll investigate this, thanks for the feedback

I had the same problem but after the last update using:

 * Eclipse SDK 3.2.2 - Build M20070212-1330
 * PDT SDK 0.7.0.v20070221

It doesn't happen anymore, I believe it's fixed now
 
Comment 23 Gadi Goldbarg CLA 2007-04-26 09:04:13 EDT
as meantion at last comment - this bug seem to be fix by now