2017-04-04 305 views
0

我有一個包含我想與速度生成類的描述的XML,在這種形式:意外錯誤

<Class name="name"> 
    <Attribute name="name" type="typeName"/> 
    ... 
    <Method name="name" type="typeName"/> 
</Class> 

模板的代碼是:

public class $class.Name implements NodeIface { 

#foreach($att in $class.Attributes) 
    private $att.Type $att.name; 

    public $att.Type get$utility.firstToUpperCase($att.Name)() { 
    return this.$att.Name; 
    } 

    public void set$utility.firstToUpperCase($att.Name)($att.Type $att.Name) { 
    this.$att.Name = $att.Name; 
    } 
#end 

#foreach($mtd in $class.Methods) 
    if($class.Name == "name") { 
    public $mtd.Name() { 
     this.$att.Name = new $att.Type(Constants.SERVER_PORT, classNameHandler.class); //here lies the error 
    } 

    @Override 
     public $mtd.Type $mtd.Name() throws TException { 
     TSocket $att.Name = new TSocket("localhost", Constants.SERVER_PORT); 
     TBinaryProtocol $att.Name = new TBinaryProtocol($att.Name); 
     managementClient = new ManagementService.Client($att.Name); 
     this.setDispatcher(new OperationDispatcher($att.Name)); 
     arithmeticServerTransport.open(); 
     $att.Name.start(); 
       $att.Name = new $att.Type($att.Name); 
     PortNegotiator negotiator = new PortNegotiator($att.Name); 
     negotiator.negotiate($att.Type, $att.Name); 
    } 

    @Override 
    public $mtd.Type $mtd.Name() { 
     $att.Name.stop(); 
    } 
    } 
    else if ($class.Name == "GreetingsNode") { 
    public $mtd.Name(); 
     this.$att.Name = new $att.Type((Constants.SERVER_PORT, GreetingsServiceHandler.class)); 
    } 

    #Override 
    public $mtd.Type $mtd.Name() throws TException { 
     TSocket $att.Name = new TSocekt("localhost", Constants.SERVER_PORT); 
     TBinaryProtocol $att.Name = new TBinaryProtocol($att.Name); 
     $att.Name = new ManagementService.Client($att.Name); 
     this.SetUser(new User($att.Name); 
     this.setMessenger(new MessageDispatcher($att.Name)); 
     $att.Name.open() 

     $att.Name = new $att.Type($att.Name); 
     PortNegotiator negotiator = new PortNegotiator($att.Name); 
     negotiator.negotiate($att.Type, $att.Name); 
    } 

    @Override 
    public $mtd.Type $mtd.Name() { 
     $att.Name.stop(); 
    } 

#End 

Eclipse的速度文本編輯器告訴我這條消息有錯誤:「Encountered」); \ r \ n \ t \ t} \ r \ n \ t \ t \ r \ n \ t \ t @ Override \ r \ n't \ tpublic「在Class.vm [第23行,第86列] 期待以下之一: 」[「... 」 ,「... 」)「... ...」

這是什麼意思?

+0

你有一個if語句中的方法和一個無所謂的覆蓋 –

+0

剛剛添加了代碼的其餘部分,對不起 – Gaspare79

回答

1

這就是你需要使用的情況下formal reference notation

 this.$att.Name = new ${att.Type}(Constants.SERVER_PORT, classNameHandler.class); 

否則速度解析器會認爲你試圖調用$att.Type對象的方法。

+0

謝謝,它修復了它。我應該更仔細地閱讀wiki – Gaspare79