2012-02-26 69 views
1

我有一個相當複雜的類型層次結構,有時會遇到難以調試的類型錯誤。我想知道是否有某種工具來查詢是否符合類型要求。是否有一個Eclipse交互式調試工具來評估類型屬性?

舉例來說,如果我有以下幾種類型:

class ShapeTypeDebugging { 
    interface Shape {} 
    interface CanRoll {} 
    interface ShapeRoller<T extends CanRoll & Shape> { 
     void Roll(T t); 
    } 
    interface Circle extends Shape, CanRoll {} 
    interface HasThreeDimensions {} 
    interface ThreeDimensionalShape extends Shape, HasThreeDimensions {} 
    interface Sphere extends ThreeDimensionalShape {} // Oops, forgot Spheres CanRoll 
    interface SphereRoller extends ShapeRoller<Sphere> { 
     @Override void Roll(Sphere sphere); 
    } 
} 

SphereRoller界面會導致編譯器錯誤: Bound mismatch: The type Sphere is not a valid substitute for the bounded parameter <T extends CanRoll & Shape> of the type ShapeRoller<T>

如果能打聽樣球體instanceof CanSpin類型的屬性,它會幫我實現我忘了將CanSpin屬性添加到Sphere。

這大概是可以在調試器的表情查看一旦應用程序建立和正確執行,但在此之前的類型錯誤都已經得到解決。

是否有任何工具或插件的Eclipse,讓我做的編譯時類型查詢這個樣子?與選定看到參與整個類型層次所需要的類型 - (「開放式層次結構中導航」)

回答

1

你可以打F4。如果我做對了,你不需要運行時評估來實現目標。

+0

這是一個很大的幫助,謝謝!我之前注意到類型瀏覽器的存在,但從未嘗試過。按照你的建議玩它之後,我發現我不能像我想要的那樣直接測試類型屬性,儘管它仍然比沒有好。在接受答案之前,我會稍微等一下,以防有人提出其他問題,讓我在構建時更直接地評估類型表達式。 – 2012-02-26 19:19:38

相關問題