com.st.p2012.mind.comments.CommentProcessor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mindoc Show documentation
Show all versions of mindoc Show documentation
Document generator for MIND
The newest version!
/**
\file com/st/p2012/mind/comments/CommentProcessor.java
\brief Process comments of ADL nodes and replace tags.
\n
This file is part of the Platform 2012 program,
a cooperation between STMicroelectronics and CEA.\n
Redistribution of this file to outside parties is
strictly prohibited without the written consent
of the module owner indicated below.\n
\par Module owner: [email protected]
\par Copyright (C) 2009 STMicroelectronics
\par Authors: [email protected]
\par Id: $Id$
\par Date: $Date$
\par Revision: $Rev$
*/
package com.st.p2012.mind.comments;
import static com.st.p2012.mind.ast.CommentDecoration.setComment;
import static com.st.p2012.mind.ast.CommentDecoration.setShortComment;
import java.util.regex.Matcher;
import org.objectweb.fractal.adl.Definition;
import org.objectweb.fractal.adl.Node;
import org.objectweb.fractal.mind.idl.ast.IDL;
import com.st.p2012.mind.HTMLDocumentationHelper.SourceKind;
import com.st.p2012.mind.ast.CommentDecoration;
public class CommentProcessor {
private final String rootName;
private CommentProcessor(final String rootName) {
this.rootName = rootName;
}
public static void process(final Definition definition) {
final CommentProcessor processor = new CommentProcessor(definition.getName());
processor.internalProcess(definition, SourceKind.COMPONENT);
}
public static void process(final IDL definition) {
final CommentProcessor processor = new CommentProcessor(definition.getName());
processor.internalProcess(definition, SourceKind.INTERFACE);
}
private void internalProcess(final Node n, final SourceKind sourceKind) {
final String comment = (String)n.astGetDecoration(CommentDecoration.COMMENT_DECORATION);
if(comment != null) {
final CommentTagProcessor tagProcessor = new CommentTagProcessor(rootName, comment, sourceKind);
setShortComment(n, tagProcessor.replaceTagsInShortComment());
setComment(n, tagProcessor.replaceTagsInComment());
}
for (final String nodeType : n.astGetNodeTypes()) {
for (final Node subNode : n.astGetNodes(nodeType)) {
if(subNode != null)
internalProcess(subNode, sourceKind);
}
}
}
@SuppressWarnings("unused")
private static void printGroups(final Matcher m) {
System.out.print("-------- ");
int i;
for (i = 1; i < m.groupCount(); i++) {
System.out.print("group#" + i + " = " + m.group(i) + ", ");
}
System.out.print("group#" + i + " = " + m.group(m.groupCount()));
System.out.println();
}
}