Bug 6678 - Incorrect output after Add Unimplemented Method
Summary: Incorrect output after Add Unimplemented Method
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P1 normal (vote)
Target Milestone: 2.0 M3   Edit
Assignee: Olivier Thomann CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2001-12-07 12:06 EST by Erich Gamma CLA
Modified: 2002-02-12 06:20 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Erich Gamma CLA 2001-12-07 12:06:31 EST
In the following CU:
----
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFileModificationValidator;
import org.eclipse.core.runtime.IStatus;

public class MyClass implements IFileModificationValidator {
----
Do an Add unimplemented method and you get the code below

import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFileModificationValidator;
import org.eclipse.core.runtime.IStatus;

public class MyClass implements IFileModificationValidator 	/*
	 * @see IFileModificationValidator#validateEdit(IFile[], Object)
	 */
	public IStatus validateEdit(IFile[] files, Object context) {
		return null;
	}

	/*
	 * @see IFileModificationValidator#validateSave(IFile)
	 */
	public IStatus validateSave(IFile file) {
		return null;
	}

{
Comment 1 Martin Aeschlimann CLA 2001-12-07 12:28:53 EST
Could reproduce: Problem is the missing close bracket of MyClass.

using IType.createMethod()
-> moving to JCore
Comment 2 Olivier Thomann CLA 2001-12-11 11:24:36 EST
If you add a cariage return after the opening brace, the problem is gone. I will 
check the positions of the beginning of the body of the class.
Comment 3 Olivier Thomann CLA 2001-12-11 11:46:36 EST
This is a bug in the actual CreateElementInCUOperation class. When the '{' is 
the last character of the CU the new element is added at the position of this 
character instead of this position + 1. This is why the opening brace ends up at 
the end of the CU and the new unimplemented methods between the implements 
clause and the '{'. I will try to see how to fix it.

Comment 4 Olivier Thomann CLA 2001-12-11 12:50:44 EST
There is no check to know if the insertPosition was equal to the buffer length. 
If true, the right operation on the buffer is an append and not an insertion.
I will release as soon as the stream is reopen.
Comment 5 Olivier Thomann CLA 2001-12-12 14:55:05 EST
Released in HEAD. All tests are green.
Comment 6 Olivier Thomann CLA 2002-01-07 15:49:13 EST
The fix was enough. Adding getters/setters won't work as expected anymore. An 
append is the right operation only if the last character is an open brace, 
otherwise the replace was the right solution.
Comment 7 Olivier Thomann CLA 2002-01-07 16:39:43 EST
I release a fix in order to restore the getter/setters feature. There is no test 
that is checking this feature. This is scary. We should have found this bug 
earlier. All tests are green.
Comment 8 Olivier Thomann CLA 2002-01-07 16:53:44 EST
This feature seems to be gone. How do I use it in a 1218 build?
Comment 9 Erich Gamma CLA 2002-01-08 09:27:11 EST
The action is now called "Override Methods" and is available on types in the 
outline or packages viwe.
Comment 10 Olivier Thomann CLA 2002-01-15 12:38:06 EST
This requires a complete rework on the normalize methods in the JDOM world. It 
will wait for the new DOM node.
Comment 11 Olivier Thomann CLA 2002-02-11 11:26:00 EST
Fixed and released in HEAD.