Skip to content
Snippets Groups Projects
Commit bd69693c authored by Jesper's avatar Jesper
Browse files

Keep doc comments for aspect-declared types

An error in an if-condition (|| instead of &&) lead to all documentation
comments being discarded for aspect-declared types.

fixes #284 (bitbucket)
parent e75f2001
No related branches found
No related tags found
No related merge requests found
2018-02-02 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Documentation comments are now kept for aspect-declared types (classes,
interfaces, enums) and included in the generated code.
2017-08-29 Jesper Öqvist <jesper.oqvist@cs.lth.se>
* Added the --concurrent option to generate thread-safe attribute evaluation code.
......
......@@ -41,7 +41,7 @@ aspect Lookup {
public TypeDecl Grammar.findClassDecl(String name, String comment,
String fileName, int beginLine, String enclosingAspect) {
comment = comment.trim();
if (!comment.startsWith("//") || !comment.startsWith("/*")) {
if (!comment.startsWith("//") && !comment.startsWith("/*")) {
comment = "";
}
TypeDecl t = lookup(name);
......@@ -58,7 +58,7 @@ aspect Lookup {
public TypeDecl Grammar.findInterfaceDecl(String name, String comment,
String fileName, int beginLine, String enclosingAspect) {
comment = comment.trim();
if (!comment.startsWith("//") || !comment.startsWith("/*")) {
if (!comment.startsWith("//") && !comment.startsWith("/*")) {
comment = "";
}
TypeDecl t = lookup(name);
......@@ -74,7 +74,7 @@ aspect Lookup {
public TypeDecl Grammar.findEnumDecl(String name, String comment,
String fileName, int beginLine, String enclosingAspect) {
comment = comment.trim();
if (!comment.startsWith("//") || !comment.startsWith("/*")) {
if (!comment.startsWith("//") && !comment.startsWith("/*")) {
comment = "";
}
TypeDecl t = lookup(name);
......
......@@ -28,12 +28,18 @@
aspect Comments {
/**
* Helper class for documentation comment handling.
*/
class JavaDocParser {
private static final String NL = System.getProperty("line.separator", "\n");
int i;
char[] javadoc;
StringBuilder out;
/**
* Strips comment syntax, returning only the raw comment text.
*/
String parse(String comments) {
if (comments == null)
return "";
......
......@@ -120,7 +120,7 @@ aspect JaddCodeGen {
}
/**
* Emits the (nta) child initialization method
* Emits the (nta) child initialization method.
*/
public void ASTDecl.emitChildInitMethod(PrintWriter out) {
TemplateContext tt = templateContext();
......@@ -162,7 +162,7 @@ aspect JaddCodeGen {
}
/**
* Emits the constructor body for tree building constructors
* Emits the constructor body for tree building constructors.
*/
public void ASTDecl.emitBuildingConstructorBody(PrintWriter out) {
TemplateContext tt = templateContext();
......@@ -200,7 +200,8 @@ aspect JaddCodeGen {
/**
* Emits annotation on the constructor with information about the arguments.
* Three arrays are generated for the constructor, one with the name of the
*
* <p>Three arrays are generated for the constructor, one with the name of the
* children, one with the type and one with the kind(Child, List, Opt or Token).
*/
private void ASTDecl.emitConstructorAnnotation(PrintWriter out){
......@@ -248,7 +249,7 @@ aspect JaddCodeGen {
}
/**
* Constructor to build trees bottom up
* Constructor to build trees bottom up.
*/
public void ASTDecl.emitBuildingConstructor(PrintWriter out) {
if (components().isEmpty()) {
......@@ -259,8 +260,6 @@ aspect JaddCodeGen {
emitConstructorAnnotation(out);
}
out.print(config().indent + "public " + name() + "." + name() + "(");
int paramIndex = 0;
for (Component c : components()) {
......@@ -327,10 +326,9 @@ aspect JaddCodeGen {
* List nodes use the minimum list size as the initial child
* array size.
*/
syn String ASTDecl.initialChildArraySize() {
return String.format("(i + 1 > %d || !(this instanceof %s)) ? i + 1 : %d",
syn String ASTDecl.initialChildArraySize() =
String.format("(i + 1 > %d || !(this instanceof %s)) ? i + 1 : %d",
config().minListSize(), config().listType(), config().minListSize());
}
/**
* Checks that ASTNode.state can be evaluated.
......@@ -627,7 +625,7 @@ aspect JaddCodeGen {
jp.root = grammar();
// The file name is not meaningful, as the component is completely generated
// from a node type specification
// from a node type specification.
jp.setFileName("");
try {
......
......@@ -281,7 +281,7 @@ aspect JastAddCodeGen {
stream.println("}");
stream.close();
} catch (FileNotFoundException f) {
System.err.format("Could not create file %s in %s%n", file.getName(), file.getParent());
System.err.format("Could not create file %s in %s.%n", file.getName(), file.getParent());
System.exit(1);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment