为什么IResource.getRawLocation()为IProject返回null [英] Why does IResource.getRawLocation() return null for IProject

查看:123
本文介绍了为什么IResource.getRawLocation()为IProject返回null的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要项目文件夹的绝对位置,所以我试过

  project.getRawLocation()

但这返回 null (至少在我的情况下,已使用导入...将现有项目导入到工作空间手动导入项目,并且已经将复制项目复制到工作区中复选框)。



事情是

  project.getParent()。getRawLocation()

返回 /work/Projekte/runtime-MyProduct.product 这是正确的

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

返回 /work/Projekte/runtime-MyProduct.product/Test/。 cproject 这是正确的。



因此,我希望

  project.getRawLocation()

将返回 /工作/ Projekte / runti me-MyProduct.product / Test ,但它返回 null



解释和/或告诉我我错了什么?

解决方案

JavaDoc for getRawLocation()


如果这个资源是现有项目中,返回的路径将为
等于项目描述中的位置路径。


和JavaDoc for项目描述



getLocation() 调用将返回路径。


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?

解决方案

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.

这篇关于为什么IResource.getRawLocation()为IProject返回null的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆