1

プロジェクト内のすべてのデフォルト スコープ、別名パッケージ スコープのクラス メンバーを検索したいと考えています。(キーワード public/protected/private を検索できるため、他のスコープは問題ありませんが、この場合は検索するキーワードがありません。)

この種の検索を実行できるEclipseプラグインまたは何かがありますか?

public class Foo {
    private int a;   // these are easy
    protected int b; // to find,
    public int c;    // thanks to keywords

    int d; // but ones like this?
}
4

2 に答える 2

1

javap を見たいと思うかもしれません:

http://docs.oracle.com/javase/1.5.0/docs/tooldocs/windows/javap.html

これは主にクラスを逆アセンブルすることを目的としていますが、異なるスコープ (プライベートとパブリックなど) のクラス メンバーを含める/除外することもできます。

于 2012-06-05T22:47:31.273 に答える
0

javap は適切なソリューションではないようであり、適切なプラグインも知らないため、独自のプラグインを作成する必要がある場合があります。

Feed it a list of classes.
for each class
    Use Class.forName(className) to get the class object
    use getDeclared{Classes,Fields,Methods,Constructors} to get the members.
    for each member
        Use java.lang.reflect.Modifiers.is{Public,Private,Protected}(member.getModifiers())
        It is default if all three are false
        If default report that member
        You decide whether and how to recurse into inner classes.

メソッド内にネストされたクラスでは、その解決策は機能しないと思います。(javap も javadoc も、メソッド内にネストされたクラスを解決しません。) コードにメソッド内にネストされたクラスがないと断言できれば、物事ははるかに簡単になります。

于 2012-06-06T02:28:07.657 に答える