Changeset 836

Show
Ignore:
Timestamp:
09/04/10 13:04:29 (17 months ago)
Author:
stefan
Message:

quick hack to fix bug #55: \newcommand template throws an exception after skipping the optional parameters

Location:
trunk/src/sce/codehelper
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/sce/codehelper/CHCommandArgument.java

    r791 r836  
    1313  private String name = null; 
    1414  private boolean optional = false; 
     15  private boolean secondOptional = false; 
    1516  // the hint 
    1617  private String hint = null; 
     
    3334  } 
    3435 
    35   /** 
     36  /** 
     37   * Creates a command argument. 
     38   * 
     39   * @param name the name 
     40   * @param optional whether the argument is optional 
     41   * @param secondOptional whether the argument is second optional 
     42   */ 
     43  public CHCommandArgument(String name, boolean optional, boolean secondOptional) { 
     44    this.name = name; 
     45    this.optional = optional; 
     46    this.secondOptional = secondOptional; 
     47  } 
     48 
     49  /** 
    3650   * Returns the name of the argument. 
    3751   * 
     
    5165  } 
    5266 
    53   /** 
     67  /** 
     68   * Returns true if the argument is second optional. 
     69   * 
     70   * @return true if second optional 
     71   */ 
     72  public boolean isSecondOptional() { 
     73    return secondOptional; 
     74  } 
     75 
     76  /** 
    5477   * Returns the hint for this argument. 
    5578   * 
  • trunk/src/sce/codehelper/StaticCommandsCodeHelper.java

    r771 r836  
    134134      if (commandUsage.substring(argumentEnd).trim().startsWith("]")) optional = true; 
    135135 
     136      boolean secondOptional = false; 
     137      if (optional) { 
     138        if (commandUsage.substring(0, argumentStart-1).trim().endsWith("]")) { 
     139          secondOptional = true; 
     140          command.setUsage(commandUsage.replaceAll("\\[@" + argumentName + "@\\]", "")); 
     141          continue; 
     142        } 
     143      } 
     144 
    136145      // create the argument 
    137       CHCommandArgument argument = new CHCommandArgument(argumentName, optional); 
     146      CHCommandArgument argument = new CHCommandArgument(argumentName, optional, secondOptional); 
    138147      argument.setHint(argumentXML.getAttribute("hint")); 
    139148