从 String 标识的内部类中检索外部类作为 IFile

发布于 2024-12-20 07:23:20 字数 589 浏览 3 评论 0原文

如何从 IFile 对象的内部类(由类名标识)检索外部类?

对于“普通”.java 类,我得到如下内容:

IFile file = project.getFile("src" + System.getProperty("file.separator")
                        + packageName
                        + System.getProperty("file.separator") + simpleClassName
                        + ".java");

这显然仅适用于 .java 类,不适用于内部类。

示例:

public class House {

LinkedList<Room> rooms;

    public House() {
       rooms.add(new Room());
    }

   class Room {

   }

}

现在我想搜索“Room”并检索 House.java。

有什么想法吗?

How can I retrieve the outer class from an inner class (identified by class name) for an IFile Object?

For "normal" .java classes i got something like this:

IFile file = project.getFile("src" + System.getProperty("file.separator")
                        + packageName
                        + System.getProperty("file.separator") + simpleClassName
                        + ".java");

This works obviously only for .java classes, not for inner classes.

Example:

public class House {

LinkedList<Room> rooms;

    public House() {
       rooms.add(new Room());
    }

   class Room {

   }

}

Now i want to search for "Room" and retrieve House.java.

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

完美的未来在梦里 2024-12-27 07:23:20

您应该使用 Eclipse Java 开发工具使用 Java 搜索引擎 Eclipse 帮助中的页面似乎是一个不错的起点。使用 JDT 意味着您的类位于 Java 项目中。

You should use Eclipse Java Development Tools. Using the Java search engine page in Eclipse help seems to be good place to start. Using JDT implies that you have your classes in a Java project.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文