本文介绍了为什么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 说

和JavaDoc for项目描述调用将返回路径。


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

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

The getLocation() call will return a path.

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

11-02 15:26