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

Bug 209497

Summary: [EditorMgmt] Contradicting Javadoc in org.eclipse.ui.IElementFactory.createElement(IMemento)
Product: [Eclipse Project] Platform Reporter: Dani Megert <daniel_megert>
Component: UIAssignee: Boris Bokowski <bokowski>
Status: VERIFIED FIXED QA Contact:
Severity: normal    
Priority: P3    
Version: 3.4   
Target Milestone: 3.4 M5   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Bug Depends on:    
Bug Blocks: 186977    

Description Dani Megert CLA 2007-11-12 09:28:32 EST
3.4 M3

The Javadoc in org.eclipse.ui.IElementFactory.createElement(IMemento) is contradicting:

In the Javadoc it says:
     * should not return <code>null</code>.

but the @return tag says:
    @return an object, or <code>null</code> if the element could not be created
Comment 1 Dani Megert CLA 2007-11-12 09:40:19 EST
See also bug 186977.
Comment 2 Boris Bokowski CLA 2007-11-13 14:19:11 EST
The full text is:

Under normal circumstances, the resulting object can be expected to be persistable; that is, 

 result.getAdapter(org.eclipse.ui.IPersistableElement.class)
 
should not return null.

I don't see a contradiction. The result can be null, but any non-null result should be adaptable to IPersistableElement.
Comment 3 Boris Bokowski CLA 2007-11-13 14:19:38 EST
forgot to change the resolution
Comment 4 Dani Megert CLA 2007-11-14 02:27:06 EST
Sorry to be a pain ;-)

"Under normal circumstances" == "could not be created"?

The API gives no clue what "normal circumstances" are i.e. is it abnormal and hence OK to return 'null'
- when the file no longer exists?
- when a exception happens?
- when it snows in summer?
Comment 5 Boris Bokowski CLA 2008-02-03 17:33:15 EST
Changed the Javadoc to:
	 * <p>
	 * If the result is not null, it should be persistable; that is,
	 * <pre>
	 * result.getAdapter(org.eclipse.ui.IPersistableElement.class)
	 * </pre>
	 * should not return <code>null</code>.
	 * </p>

Is this better?
Comment 6 Dani Megert CLA 2008-02-04 05:20:46 EST
Yes.
Comment 7 Boris Bokowski CLA 2008-02-05 13:44:09 EST
Verified by code inspection on Windows XP using I20080205-0010.