Closed fdodino closed 7 years ago
Maybe related to https://github.com/eclipse/xtext-xtend/issues/166 (fixed in... 2.12)
I thought that I could add a subclass to DefaultRenameStrategy for applyDeclarationChange, but debugging show no breakpoint.
Problem occurs only when you keep open files of project renamed in editor. If you close them and reopen everything works fine
So... after debugging for 1 hour, I came with this conclusion:
You rename a project, a file... so, you change context. Let's say you have a class A. Its parent is class Object. So cache resource triggers a linking process from editor. But, Object (element 5 in lang.wlk) fails when trying to get that URI in a deprecated project. If you had "project1" and you rename it to "project2", context still points to "project1":
JdtClasspathUriResolver class
@Override
public URI resolve(Object context, URI classpathUri) {
if (!(context instanceof IJavaElement)) {
throw new IllegalArgumentException("Context must implement IResource");
}
javaElement = (IJavaElement) context; (1)
try {
if (ClasspathUriUtil.isClasspathUri(classpathUri)) {
IJavaProject javaProject = javaElement.getJavaProject();
URI result = findResourceInWorkspace(javaProject, classpathUri); (2)
if (classpathUri.fragment() != null)
result = result.appendFragment(classpathUri.fragment());
return result;
}
}
catch (Exception exc) {
throw new ClasspathUriResolutionException(exc);
}
return classpathUri;
}
So, that's why context is a java element (1), but you can't find resource in workspace any more (2). So you get the same uri as result, and caller fails subsequently:
XtextResourceSet class
if (ClasspathUriUtil.isClasspathUri(uri)) {
URI result = XtextResourceSet.this.resolveClasspathURI(uri);
if (ClasspathUriUtil.isClasspathUri(result))
throw new ClasspathUriResolutionException(result);
What do you think @Juancete @npasserini @tesonep ?
I think this could be a good clue: http://koehnlein.blogspot.com.ar/2011/06/rename-refactoring-in-xtext-20.html
Update: no, it is useful but for refactoring issues.
Currently the problem is in Rename resources, so Refactoring rename is not triggered. But a dev called Stephane has a good point here: https://www.eclipse.org/forums/index.php/t/1080002/
If you rename a project, change display resolution, and sometimes when you rename a method, you get
It happens apparently if you need to copy or refresh a wollok library, that is cached now.