Repository: flex-falcon Updated Branches: refs/heads/develop c5a10255f -> 8e7955930
try to get JSON output for ASDoc Project: http://git-wip-us.apache.org/repos/asf/flex-falcon/repo Commit: http://git-wip-us.apache.org/repos/asf/flex-falcon/commit/8e795593 Tree: http://git-wip-us.apache.org/repos/asf/flex-falcon/tree/8e795593 Diff: http://git-wip-us.apache.org/repos/asf/flex-falcon/diff/8e795593 Branch: refs/heads/develop Commit: 8e7955930697c9b4c9385ce0b4ce39227db37aa0 Parents: f938cb7 Author: Alex Harui <aha...@apache.org> Authored: Tue Oct 11 22:32:57 2016 -0700 Committer: Alex Harui <aha...@apache.org> Committed: Tue Oct 11 22:33:11 2016 -0700 ---------------------------------------------------------------------- .../compiler/asdoc/flexjs/ASDocComment.java | 94 ++++- .../codegen/js/flexjs/JSFlexJSASDocEmitter.java | 371 +++++++++++++++---- .../mxml/flexjs/MXMLFlexJSASDocBackend.java | 2 +- .../parsing/as/FlexJSASDocDelegate.java | 27 +- 4 files changed, 389 insertions(+), 105 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8e795593/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java b/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java index 5470f47..e5064b1 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/asdoc/flexjs/ASDocComment.java @@ -19,7 +19,9 @@ package org.apache.flex.compiler.asdoc.flexjs; +import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; import java.util.Map; @@ -64,39 +66,91 @@ public class ASDocComment implements IASDocComment return sb.toString(); } + private String description = null; + private Map<String, List<IASDocTag>> tagMap; + @Override public String getDescription() { - return null; + return description; } @Override public void compile() { + String s = token.getText(); + String[] lines = s.split("\n"); + StringBuilder sb = new StringBuilder(); + int n = lines.length; + if (n == 1) + { + int c = lines[0].indexOf("*/"); + if (c != -1) + lines[0] = lines[0].substring(0, c); + } + // clip off asdoc slash-star-star + sb.append(lines[0].substring(3)); + for (int i = 1; i < n - 1; i++) + { + String line = lines[i]; + int star = line.indexOf("*"); + int at = line.indexOf("@"); + if (at == -1) + { + sb.append(" "); + if (star > -1) + sb.append(line.substring(star + 1)); + } + else + { + if (tagMap == null) + tagMap = new HashMap<String, List<IASDocTag>>(); + + int after = line.indexOf(" ", at + 1); + if (after == -1) + { + tagMap.put(line.substring(at + 1), null); + } + else + { + String tagName = line.substring(at + 1, after); + List<IASDocTag> tags = tagMap.get(tagName); + if (tags == null) + { + tags = new ArrayList<IASDocTag>(); + tagMap.put(tagName, tags); + } + tags.add(new ASDocTag(tagName, line.substring(after + 1))); + } + } + } + description = sb.toString(); } @Override public boolean hasTag(String name) { - return false; + if (tagMap == null) + return false; + return (tagMap.containsKey(name)); } @Override public IASDocTag getTag(String name) { - return null; + return tagMap.get(name).get(0); } @Override public Map<String, List<IASDocTag>> getTags() { - return null; + return tagMap; } @Override public Collection<IASDocTag> getTagsByName(String string) { - return null; + return tagMap.get(string); } @Override @@ -104,4 +158,34 @@ public class ASDocComment implements IASDocComment { } + class ASDocTag implements IASDocTag + { + public ASDocTag(String name, String desc) + { + this.name = name; + this.desc = desc; + } + + private String name; + private String desc; + + @Override + public String getName() { + // TODO Auto-generated method stub + return name; + } + + @Override + public String getDescription() { + // TODO Auto-generated method stub + return desc; + } + + @Override + public boolean hasDescription() { + // TODO Auto-generated method stub + return desc != null; + } + + } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8e795593/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java index bdd15a2..1fffbc1 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/codegen/js/flexjs/JSFlexJSASDocEmitter.java @@ -22,7 +22,10 @@ package org.apache.flex.compiler.internal.codegen.js.flexjs; import java.io.FilterWriter; import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.Set; +import org.apache.flex.compiler.asdoc.IASDocTag; import org.apache.flex.compiler.asdoc.flexjs.ASDocComment; import org.apache.flex.compiler.codegen.js.flexjs.IJSFlexJSEmitter; import org.apache.flex.compiler.codegen.js.goog.IJSGoogDocEmitter; @@ -35,6 +38,9 @@ import org.apache.flex.compiler.definitions.IDefinition; import org.apache.flex.compiler.definitions.INamespaceDefinition; import org.apache.flex.compiler.definitions.IPackageDefinition; import org.apache.flex.compiler.definitions.ITypeDefinition; +import org.apache.flex.compiler.definitions.metadata.IDeprecationInfo; +import org.apache.flex.compiler.definitions.metadata.IMetaTag; +import org.apache.flex.compiler.definitions.references.INamespaceReference; import org.apache.flex.compiler.internal.codegen.as.ASEmitterTokens; import org.apache.flex.compiler.internal.codegen.js.JSSessionModel.ImplicitBindableImplementation; import org.apache.flex.compiler.internal.codegen.js.goog.JSGoogEmitter; @@ -64,6 +70,7 @@ import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSASDocEmit import org.apache.flex.compiler.internal.codegen.mxml.flexjs.MXMLFlexJSEmitter; import org.apache.flex.compiler.internal.definitions.AccessorDefinition; import org.apache.flex.compiler.internal.definitions.FunctionDefinition; +import org.apache.flex.compiler.internal.definitions.GetterDefinition; import org.apache.flex.compiler.internal.projects.FlexJSProject; import org.apache.flex.compiler.internal.projects.FlexProject; import org.apache.flex.compiler.internal.tree.as.BinaryOperatorAsNode; @@ -75,6 +82,7 @@ import org.apache.flex.compiler.internal.tree.as.IdentifierNode; import org.apache.flex.compiler.internal.tree.as.LabeledStatementNode; import org.apache.flex.compiler.internal.tree.as.MemberAccessExpressionNode; import org.apache.flex.compiler.internal.tree.as.NumericLiteralNode; +import org.apache.flex.compiler.internal.tree.as.metadata.EventTagNode; import org.apache.flex.compiler.projects.ICompilerProject; import org.apache.flex.compiler.tree.ASTNodeID; import org.apache.flex.compiler.tree.as.IASNode; @@ -101,6 +109,7 @@ import org.apache.flex.compiler.tree.as.IScopedNode; import org.apache.flex.compiler.tree.as.ISetterNode; import org.apache.flex.compiler.tree.as.IUnaryOperatorNode; import org.apache.flex.compiler.tree.as.IVariableNode; +import org.apache.flex.compiler.tree.metadata.IMetaTagNode; import org.apache.flex.compiler.utils.ASNodeUtils; import com.google.common.base.Joiner; @@ -115,6 +124,8 @@ import org.apache.flex.compiler.utils.NativeUtils; public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmitter { + private boolean wroteSomething = false; + @Override public String postProcess(String output) { @@ -145,16 +156,17 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit public void emitNamespace(INamespaceNode node) { ASDocComment asDoc = (ASDocComment) node.getASDocComment(); - write("<"); + if (asDoc != null && asDoc.commentNoEnd().contains("@private")) + return; + writeNewline("{ \"type\": \"namespace\","); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + writeNewline("}"); } @@ -264,42 +276,96 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit public void emitClass(IClassNode node) { ASDocComment asDoc = (ASDocComment) node.getASDocComment(); - write("<"); + writeNewline("{ \"type\": \"class\","); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); final IDefinitionNode[] members = node.getAllMemberNodes(); + if (members.length > 0) + { + writeNewline(","); + writeNewline("\"members\": ["); + indentPush(); + indentPush(); + } + boolean firstMember = true; for (IDefinitionNode mnode : members) { + if (!firstMember && wroteSomething) + writeNewline(","); + firstMember = false; + wroteSomething = false; getWalker().walk(mnode); } + if (members.length > 0) + { + indentPop(); + indentPop(); + writeNewline("]"); + } + IMetaTagNode[] metas = node.getMetaTagNodesByName("Event"); + if (metas.length > 0) + { + writeNewline(","); + writeNewline("\"events\": ["); + indentPush(); + indentPush(); + } + boolean firstEvent = true; + for (IMetaTagNode mnode : metas) + { + if (!firstEvent && wroteSomething) + writeNewline(","); + firstEvent = false; + wroteSomething = false; + writeEventTagNode(mnode); + } + if (metas.length > 0) + { + indentPop(); + indentPop(); + writeNewline("]"); + } + indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("}"); } @Override public void emitInterface(IInterfaceNode node) { ASDocComment asDoc = (ASDocComment) node.getASDocComment(); - write("<"); + writeNewline("{ \"type\": \"interface\","); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); final IDefinitionNode[] members = node.getAllMemberDefinitionNodes(); + if (members.length > 0) + { + writeNewline(","); + writeNewline("members: ["); + } + boolean firstMember = true; for (IDefinitionNode mnode : members) { + if (!firstMember && wroteSomething) + writeNewline(","); + firstMember = false; + wroteSomething = false; getWalker().walk(mnode); } + if (members.length > 0) + { + writeNewline("]"); + } indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + writeNewline("}"); } private ArrayList<String> accessors = new ArrayList<String>(); @@ -312,28 +378,32 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit String name = node.getName(); if (accessors.contains(name)) return; accessors.add(name); + writeNewline("{ \"type\": \"accessor\","); + IAccessorDefinition def = (IAccessorDefinition)node.getDefinition(); + IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject()); + IAccessorNode otherNode = null; + if (otherDef != null) + { + otherNode = (IAccessorNode)otherDef.getNode(); + writeNewline(" \"access\": \"read-write\","); + } + else + writeNewline(" \"access\": \"read-only\","); ASDocComment asDoc = (ASDocComment) node.getASDocComment(); if (asDoc == null || asDoc.commentNoEnd().contains("@private")) { - IAccessorDefinition def = (IAccessorDefinition)node.getDefinition(); - IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject()); - if (otherDef != null) - { - IAccessorNode otherNode = (IAccessorNode)otherDef.getNode(); - if (otherNode != null) - asDoc = (ASDocComment) otherNode.getASDocComment(); - } + if (otherNode != null) + asDoc = (ASDocComment) otherNode.getASDocComment(); } - write("<"); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); + writeDefinitionAttributes(def); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + write("}"); } @Override @@ -344,28 +414,32 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit String name = node.getName(); if (accessors.contains(name)) return; accessors.add(name); + writeNewline("{ \"type\": \"accessor\","); + IAccessorDefinition def = (IAccessorDefinition)node.getDefinition(); + IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject()); + IAccessorNode otherNode = null; + if (otherDef != null) + { + otherNode = (IAccessorNode)otherDef.getNode(); + writeNewline(" \"access\": \"read-write\","); + } + else + writeNewline(" \"access\": \"read-only\","); ASDocComment asDoc = (ASDocComment) node.getASDocComment(); if (asDoc == null || asDoc.commentNoEnd().contains("@private")) { - IAccessorDefinition def = (IAccessorDefinition)node.getDefinition(); - IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject()); - if (otherDef != null) - { - IAccessorNode otherNode = (IAccessorNode)otherDef.getNode(); - if (otherNode != null) - asDoc = (ASDocComment) otherNode.getASDocComment(); - } + if (otherNode != null) + asDoc = (ASDocComment) otherNode.getASDocComment(); } - write("<"); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); + writeDefinitionAttributes(def); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + write("}"); } @Override @@ -374,16 +448,18 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit if (node.getDefinition().isPrivate()) return; ASDocComment asDoc = (ASDocComment) node.getASDocComment(); - write("<"); + if (asDoc != null && asDoc.commentNoEnd().contains("@private")) + return; + writeNewline("{ \"type\": \"field\","); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); + writeDefinitionAttributes(node.getDefinition()); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + write("}"); } @Override @@ -391,17 +467,19 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit { if (node.getDefinition().isPrivate()) return; - ASDocComment asDoc = (ASDocComment) node.getASDocComment(); - write("<"); + ASDocComment asDoc = (ASDocComment) node.getASDocComment(); + if (asDoc != null && asDoc.commentNoEnd().contains("@private")) + return; + writeNewline("{ \"type\": \"variable\","); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); + writeDefinitionAttributes(node.getDefinition()); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + write("}"); } @Override @@ -412,28 +490,32 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit String name = node.getName(); if (accessors.contains(name)) return; accessors.add(name); + writeNewline("{ \"type\": \"accessor\","); + IAccessorDefinition def = (IAccessorDefinition)node.getDefinition(); + IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject()); + IAccessorNode otherNode = null; + if (otherDef != null) + { + otherNode = (IAccessorNode)otherDef.getNode(); + writeNewline(" \"access\": \"read-write\","); + } + else + writeNewline(" \"access\": \"read-only\","); ASDocComment asDoc = (ASDocComment) node.getASDocComment(); if (asDoc == null || asDoc.commentNoEnd().contains("@private")) { - IAccessorDefinition def = (IAccessorDefinition)node.getDefinition(); - IAccessorDefinition otherDef = (IAccessorDefinition)def.resolveCorrespondingAccessor(getWalker().getProject()); - if (otherDef != null) - { - IAccessorNode otherNode = (IAccessorNode)otherDef.getNode(); - if (otherNode != null) - asDoc = (ASDocComment) otherNode.getASDocComment(); - } + if (otherNode != null) + asDoc = (ASDocComment) otherNode.getASDocComment(); } - write("<"); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); + writeDefinitionAttributes(def); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + write("}"); } @Override @@ -441,16 +523,145 @@ public class JSFlexJSASDocEmitter extends JSGoogEmitter implements IJSFlexJSEmit { if (node.getDefinition().isPrivate()) return; - ASDocComment asDoc = (ASDocComment) node.getASDocComment(); - write("<"); + ASDocComment asDoc = (ASDocComment) node.getASDocComment(); + if (asDoc != null && asDoc.commentNoEnd().contains("@private")) + return; + writeNewline("{ \"type\": \"method\","); + write(" \"qname\": \""); write(formatQualifiedName(node.getQualifiedName())); - write(">"); + writeNewline("\","); + writeDefinitionAttributes(node.getDefinition()); indentPush(); if (asDoc != null) - write(asDoc.commentNoEnd()); + writeASDoc(asDoc); indentPop(); - write("</"); - write(formatQualifiedName(node.getQualifiedName())); - writeNewline(">"); + write("}"); + } + + public void writeASDoc(ASDocComment asDoc) + { + asDoc.compile(); + write(" \"description\": \""); + write(asDoc.getDescription()); + write("\""); + Map<String, List<IASDocTag>> tags = asDoc.getTags(); + if (tags != null) + { + writeNewline(","); + writeNewline("\"tags\": ["); + indentPush(); + indentPush(); + boolean firstTag = true; + Set<String> tagNames = tags.keySet(); + for (String tagName : tagNames) + { + if (!firstTag) + writeNewline(","); + firstTag = false; + write("{ \"tagName\": \""); + write(tagName); + writeNewline("\","); + write(" \"values\": ["); + indentPush(); + indentPush(); + List<IASDocTag> values = tags.get(tagName); + if (values != null) + { + boolean firstOne = true; + for (IASDocTag value : values) + { + if (!firstOne) write(", "); + firstOne = false; + write("\""); + write(value.getDescription()); + write("\""); + } + } + write("]}"); + indentPop(); + indentPop(); + } + write(" ]"); + indentPop(); + indentPop(); + } } + + @Override + public void write(String value) + { + super.write(value); + wroteSomething = true; + } + + public void writeDefinitionAttributes(IDefinition def) + { + write(" \"namespace\": "); + if (def.isProtected()) + writeNewline("\"protected\","); + else if (def.isInternal()) + writeNewline("\"internal\","); + else if (def.isPublic()) + writeNewline("\"public\","); + else + { + INamespaceReference nsRef = def.getNamespaceReference(); + writeNewline("\"" + nsRef.getBaseName() + "\","); + } + if (def.isBindable()) + { + List<String> events = def.getBindableEventNames(); + write(" \"bindable\": ["); + boolean firstEvent = true; + for (String event : events) + { + if (!firstEvent) + write(","); + firstEvent = false; + write("\"" + event + "\""); + } + writeNewline("],"); + } + if (def.isOverride()) + writeNewline(" \"override\": true,"); + if (def.isStatic()) + writeNewline(" \"static\": true,"); + if (def.isDynamic()) + writeNewline(" \"dynamic\": true,"); + if (def.isFinal()) + writeNewline(" \"final\": true,"); + if (def.isDeprecated()) + { + IDeprecationInfo dep = def.getDeprecationInfo(); + writeNewline(" \"deprecated\": {"); + indentPush(); + write(" \"message\": \""); + write(dep.getMessage()); + writeNewline("\","); + write(" \"replacement\": \""); + write(dep.getReplacement()); + writeNewline("\","); + write(" \"since\": \""); + write(dep.getSince()); + writeNewline("\","); + } + } + + public void writeEventTagNode(IMetaTagNode node) + { + EventTagNode evt = (EventTagNode)node; + ASDocComment asDoc = (ASDocComment) evt.getASDocComment(); + if (asDoc != null && asDoc.commentNoEnd().contains("@private")) + return; + write("{ \"qname\": \""); + write(formatQualifiedName(evt.getName())); + writeNewline("\","); + indentPush(); + if (asDoc != null) + writeASDoc(asDoc); + indentPop(); + write("}"); + } + + } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8e795593/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSASDocBackend.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSASDocBackend.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSASDocBackend.java index 4816fd2..44e5c4e 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSASDocBackend.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/driver/mxml/flexjs/MXMLFlexJSASDocBackend.java @@ -134,7 +134,7 @@ public class MXMLFlexJSASDocBackend extends MXMLFlexJSSWCBackend @Override public String getOutputExtension() { - return "txt"; + return "json"; } } http://git-wip-us.apache.org/repos/asf/flex-falcon/blob/8e795593/compiler-jx/src/main/java/org/apache/flex/compiler/internal/parsing/as/FlexJSASDocDelegate.java ---------------------------------------------------------------------- diff --git a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/parsing/as/FlexJSASDocDelegate.java b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/parsing/as/FlexJSASDocDelegate.java index 868e5d7..c1c2368 100644 --- a/compiler-jx/src/main/java/org/apache/flex/compiler/internal/parsing/as/FlexJSASDocDelegate.java +++ b/compiler-jx/src/main/java/org/apache/flex/compiler/internal/parsing/as/FlexJSASDocDelegate.java @@ -73,7 +73,7 @@ public final class FlexJSASDocDelegate implements IASDocDelegate return IPackageDITAParser.NIL_PARSER; } - private static final class ASDelegate implements IASParserASDocDelegate + private static final class ASDelegate implements IASParserASDocDelegate, IMetadataParserASDocDelegate { @SuppressWarnings("unused") static final ASDelegate INSTANCE = new ASDelegate(); @@ -110,24 +110,13 @@ public final class FlexJSASDocDelegate implements IASDocDelegate @Override public IMetadataParserASDocDelegate getMetadataParserASDocDelegate() { - return MetadataDelegate.INSTANCE; - } - - } - - private static final class MetadataDelegate implements IMetadataParserASDocDelegate - { - static final MetadataDelegate INSTANCE = new MetadataDelegate(); - - @Override - public void setCurrentASDocToken(Token asDocToken) - { - } - - @Override - public IASDocComment afterDefinition(IDocumentableDefinitionNode definitionNode) - { - return null; + // ASDelegate is also MetadataDelegate because when metadata like + // event metadata has asdoc, the parser sees the asdoc token before + // seeing the metadata tokens so it tells the ASDelegate about + // the token but then asks the metadata delegate after the + // definition. Sharing the token between the two types of + // delegates seems to fix the problem. + return this; } @Override