Documentation comment parsing error when nested in single-line comments

Issue #179 resolved
Jon Sten created an issue

I've stumbled upon a interesting case where the commented code causes problems. I originally had the following piece of code:

    /**
     * (non-Javadoc)
     * @see FExp#genDerExp_CAD(Printer, java.io.PrintStream, java.lang.String)
     */
    @Override
    public void FLitExp.genDerExp_CAD(Printer p, PrintStream str, String indent) {
        str.print("AD_WRAP_LITERAL(0)");
    }
    syn boolean FLitExp.inlineVar_CAD() = true;

I then commented out the method genDerExp_CAD by using eclipse ctrl+shift+c which inserts single line comments at the beginning of the row, resulting in the following:

//  /**
//   * (non-Javadoc)
//   * @see FExp#genDerExp_CAD(Printer, java.io.PrintStream, java.lang.String)
//   */
//  @Override
//  public void FLitExp.genDerExp_CAD(Printer p, PrintStream str, String indent) {
//      str.print("AD_WRAP_LITERAL(0)");
//  }
    syn boolean FLitExp.inlineVar_CAD() = true;

I get the following code after compilation through jastAdd:

  /**//  * (non-Javadoc)//   * @see FExp#genDerExp_CAD(Printer, java.io.PrintStream, java.lang.String)//     
   * @attribute syn
   * @aspect CADCodeGen
   * @declaredat ..\\ModelicaCBackEnd\\src\\jastadd\\CADCodeGen.jrag:348
   */
  public boolean inlineVar_CAD() {
    ASTNode$State state = state();
    try {  return true;  }
    finally {
    }
  }

Unfortunately this is not correct Java since combination of the last asterisk in the opening Javadoc tag and the initial forward slash in the comment terminates the comment and the remainder of the comment is interpreted as Java.

No big problem though, easy to work around, simple add a new comment before the syn attribute.

Comments (4)

  1. Log in to comment