Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Groovy-Eclipse breaks java refactoring (extract to local var) #253

Closed
aclement opened this issue Jan 5, 2017 · 7 comments
Closed

Groovy-Eclipse breaks java refactoring (extract to local var) #253

aclement opened this issue Jan 5, 2017 · 7 comments

Comments

@aclement
Copy link
Contributor

aclement commented Jan 5, 2017

According to this spring-ide issue: spring-attic/spring-ide#89

Installing groovy-eclipse breaks the extract to local variable refactoring. Eric are you aware of anything changed recently that might have done that?

@eric-milles
Copy link
Member

eric-milles commented Jan 5, 2017

There was a change in ASTConverter related to end angle bracket position. Here is the edit. I'll see if the linked issue is fixed by reverting.

// GROOVY edit - avoid IllegalArgumentException in setSourceRange below
//end = type2 != null ? type2.getStartPosition() + type2.getLength() - 1 : end;
if (type2 != null) {
	if (type2.getLength() > 0) {
		end = type2.getStartPosition() + type2.getLength() - 1;
	} else if (type2.isSimpleType()) {
		Name name = ((SimpleType) type2).getName();
		// TODO: If there are previous type args, use their positional info or lengths...
		end += name.toString().length() + 1; // ballpark it
		System.err.println("SimpleType with no position info"); //$NON-NLS-1$
	} else {
		System.err.println("Type with no position info"); //$NON-NLS-1$
	}
}
// GROOVY end

@aclement
Copy link
Contributor Author

aclement commented Jan 5, 2017

Thanks. That could be it. All the position fiddling is very sensitive to change. Strictly speaking we should run all the JDT tests against patched JDT and it would catch these things but never got around to that.

@eric-milles
Copy link
Member

When I got started with this I tried to fix the JDT tests that are in the compiler.tests and builder.tests, but there were so many failures and it was very time consuming. Would be nice to be able to just import the JDT test plug-ins and run those tests.

@eric-milles
Copy link
Member

I am able to recreate the issue locally, so I should be able to fix here shortly.

@eric-milles
Copy link
Member

Sorry, it appears to be this edit in same file:

// GROOVY edit - end can be -1
end = retrieveClosingAngleBracketPosition(/*end + 1*/ sourceStart + simpleName.getLength());
type.setSourceRange(sourceStart, end - sourceStart + 1);

@eric-milles
Copy link
Member

Could you have the original submitter try again? This should be fixed now.

@aclement
Copy link
Contributor Author

aclement commented Jan 7, 2017

They confirmed it is fixed, thanks so much for the fast turnaround Eric. Do we have enough test coverage around these changes? I didn't see any new tests in your fix commit. I'm just aware, as I say, that the positions stuff is so sensitive, very easy to break. Thanks again!

@aclement aclement closed this as completed Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants