15

A_CONSTANTからの文字列を のコメントの一部にしたいClassB:

package my.stuff;

public class ClassA {
    /** Shows the string just fine: {@value} */
    public static final String A_CONSTANT = "show this in comments";
}

package my.stuff;

/**
 * Does not give me the string: {@value my.stuff.ClassA#A_CONSTANT}
 * Neither does this: {@value ClassA#A_CONSTANT}
 * 
 * @see my.stuff.ClassA#A_CONSTANT
 */
public class ClassB {

}

定数の名前にカーソルを合わせると、文字列の内容が表示さ{@value}れます。ClassAそれはいいです。

また、@seeタグは にClassBリンクすることでその役割を果たしA_CONSTANTます。

しかし、2 つの{@value ...}試みは失敗ClassBしました。{@value ...}A_CONSTANTClassB

ドキュメントには、私が行ったと思われる次の表記法を使用するように指示されています: {@value package.class#field}.

この質問への回答でも、上記の表記法を使用することをお勧めします。

これは基本的に私の質問と同じですが、答えられませんでした。

定数の文字列の内容を他のクラスのコメントに表示するにはどうすればよいですか?

Windows 7 x86 で Eclipse Juno を使用しています。

前もって感謝します。

編集:

プロジェクトで javadoc.exe を実行{@value my.stuff.ClassA#A_CONSTANT}すると、正しい文字列に解決されます。

これが、質問を少し変更した理由です。

javadoc.exeには問題がないのに、Eclipseがマウスオーバー時に定数の文字列を表示しないのはなぜですか?

Eclipse でマウス オーバー: 定数の文字列が表示されない

4

2 に答える 2

9

これは Eclipse のバグのようです。docsから例を少し変更します:

public class TestClass {
  /**
   * The value of this constant is {@value}.
   */
  // In Eclipse this shows: The value of this constant is "<script>".
  public static final String SCRIPT_START = "<script>";
  /**
   * Evaluates the script starting with {@value TestClass#SCRIPT_START}.
   */
  // In Eclipse this shows: Evaluates the script starting with {@value TestClass#SCRIPT_START}.
  public void test1() {
  /**
   * Evaluates the script starting with {@value #SCRIPT_START}.
   */
  // In Eclipse this shows: Evaluates the script starting with "<script>".
  public void test2() {
  }
}

このため、eclipse でバグが作成されました。

于 2016-03-23T08:23:49.960 に答える