Why does IResource.getRawLocation() return null for IProject

坚强是说给别人听的谎言 提交于 2020-01-11 09:15:13

问题


I need the absolute location of a project folder, so I tried

project.getRawLocation()

but this returns null (at least in my case in which I have imported the project manually using Import ... Existing projects into workspace and I have checked the Copy projects into workspace checkbox).

The thing is that

project.getParent().getRawLocation() 

returns /work/Projekte/runtime-MyProduct.product which is correct

and

project.members()[0].getRawLocation()

returns /work/Projekte/runtime-MyProduct.product/Test/.cproject which is correct as well.

Consequently, I'd expect that

project.getRawLocation() 

would return /work/Projekte/runtime-MyProduct.product/Test, but it returns null.

Can anyone explain and/or show me where I'm wrong?


回答1:


The JavaDoc for getRawLocation() says

If this resource is an existing project, the returned path will be equal to the location path in the project description.

and the JavaDoc for the project description IProjectDescription.getLocation() says:

null is returned if the default location should be used

The getLocation() call will return a path.



来源:https://stackoverflow.com/questions/20493654/why-does-iresource-getrawlocation-return-null-for-iproject

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!