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

Bug 338695

Summary: [typesystem.emf.ui] ProjectAnalyzer causes ResourceExceptions for linked folders
Product: [Modeling] M2T Reporter: Karsten Thoms <karsten.thoms>
Component: XpandAssignee: Karsten Thoms <karsten.thoms>
Status: CLOSED FIXED QA Contact:
Severity: minor    
Priority: P3 CC: benedikt.niehues, gontsaru
Version: 1.0.1Flags: karsten.thoms: kepler+
Target Milestone: M4   
Hardware: PC   
OS: Mac OS X - Carbon (unsup.)   
Whiteboard:

Description Karsten Thoms CLA 2011-03-02 10:58:22 EST
In ProjectAnalyzer#loadMetamodelsForProject an ResourceException can occur when the resource is a linked folder. This happens for example when running a runtime workbench and having a plugin opened in the development workbench.

Stack:
org.eclipse.core.internal.resources.ResourceException: Resource '/.org.eclipse.jdt.core.external.folders/.link1' does not exist.
	at org.eclipse.core.internal.resources.Resource.checkExists(Resource.java:326)
	at org.eclipse.core.internal.resources.Resource.checkAccessible(Resource.java:200)
	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:53)
	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:110)
	at org.eclipse.core.internal.resources.Resource.accept(Resource.java:94)
	at org.eclipse.xtend.typesystem.emf.ui.ProjectAnalyzer.loadMetamodelsForProject(ProjectAnalyzer.java:128)
	at org.eclipse.xtend.typesystem.emf.ui.ProjectAnalyzer.run(ProjectAnalyzer.java:90)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:54)
Comment 1 Benedikt Niehues CLA 2011-10-06 02:15:07 EDT
there seems to be a general problem with linked resources... not only when loading metamodels.
You will run into a similar problem when you use extensions in your runtime-workbench templates which are distributed by plugins in your development workbench
Comment 2 Vitali Gontsharuk CLA 2011-11-17 08:21:09 EST
It seems that I'm experiencing the same error on a Windows machine. Here is a link to the corresponding Eclipse Forum thread: 
http://www.eclipse.org/forums/index.php/m/757280/
Comment 3 Karsten Thoms CLA 2012-11-19 08:45:25 EST
Came across this bug again and think that I finally could nail it down.

JDT creates this external folders project through class ExternalModelManager. This project creates links for all managed external folders. But this project does not have a Java nature, thus any method on IJavaProject will fail.

I think that this project should have the Java nature enabled, so I raised Bug#394568. Until this is fixed the XtendXpandBuilder might fix the situation.
Comment 4 Karsten Thoms CLA 2012-11-20 02:31:18 EST
Turned out that this is no JDT bug. The problem is as follows:
1) The JDTStorageFinder searches the IStorage for an Xtend file, which is on a linked folder
Folder might be e.g.
     F/.org.eclipse.jdt.core.external.folders/.link1
2) IFolder#findMember() resolves this to its original location, e.g. 
     L/.org.eclipse.jdt.core.external.folders/.link1/<path-to-xtend-file>
3) XtendXpandProject#loadXtendXpandResource() gets this IStorage and asks the XtendResourceParser to load the Resource
   ResourceContributor#create(storage,fqn)
4) XtendResourceParser#parse() retrieves the wrong (!) project through IResource#getProject. It points to the External Folders project!
5) The PluginExtensionFactory is instantiated with this non-Java project. This fails subsequently to retrieve Java types from it. The PluginExtensionFactory must be instantiated with the IJavaProject from which the request originates.

The ResourceContributor interface does not allow to pass the project to the parser. This is required as additional argument to the create() method. Therefore an interface extension ResourceContributor2 is required.
Comment 5 Karsten Thoms CLA 2013-02-04 02:53:18 EST
Forgot to close it. Fixed with 979f50390e5c8308b974c71bae5c2176c32967f9 on 2012-11-26.
Comment 6 Eclipse Webmaster CLA 2017-10-31 11:07:32 EDT
Requested via bug 522520.

-M.
Comment 7 Eclipse Webmaster CLA 2017-10-31 11:18:59 EDT
Requested via bug 522520.

-M.