Bug 10245 - Cannot extract method if message send is used on lhs of assignment
Summary: Cannot extract method if message send is used on lhs of assignment
Status: RESOLVED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: 2.0 M6   Edit
Assignee: Dirk Baeumer CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on: 14217
Blocks:
  Show dependency tree
 
Reported: 2002-02-26 07:21 EST by Jerome Lanneluc CLA
Modified: 2002-05-03 09:10 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jerome Lanneluc CLA 2002-02-26 07:21:48 EST
Build 20020214

In the following method:
public void restore() throws JavaModelException {
	if (!isDestroyed) {
		CompilationUnit original = (CompilationUnit) getOriginalElement
();
		getBuffer().setContents(original.getContents());

		long timeStamp =
			((IFile) original.getUnderlyingResource
()).getModificationStamp();
		if (timeStamp == IResource.NULL_STAMP) {
			throw new JavaModelException(
				new JavaModelStatus
(IJavaModelStatusConstants.INVALID_RESOURCE));
		}
		((CompilationUnitElementInfo) getElementInfo()).fTimestamp = 
timeStamp;
		makeConsistent(null);
	}
}

I selected the code snippet from 'long timeStamp ' to '.fTimestamp = timeStamp;'
and I chose extract method.

I got a dialog saying that the selected statements do not belong to the same 
category. Why this restriction?
Comment 1 Adam Kiezun CLA 2002-02-27 13:06:32 EST
in fact, the problem is different - modified summary

this fails:
public class A {
	A f;
	public A a() {
		/*[*/int y= 0;	
		a().f= a();/*[*/
		return null;
	}
}


as well as this:
public class A {
	A f;
	public A a() {
		/*[*/a().f= a();/*[*/
		return null;
	}
}
Comment 2 Dirk Baeumer CLA 2002-03-11 11:18:49 EST
The problem is a wrong position in the field reference (doesn't include the 
method invocation). Waiting for JCore to fix this.
Comment 3 Dirk Baeumer CLA 2002-05-03 09:10:11 EDT
Got fixed by JDT/Core.