private void ReadPrologCustoms(ASDocItem doc, string terminationNode) { if (IsEmptyElement) { return; } string asdocKey; string asdocVal; string eon = terminationNode; ReadStartElement(); while (!(Name == eon && NodeType == XmlNodeType.EndElement)) { asdocKey = this.Name; /* * if (asdocKey == "maelexample") * { * asdocVal = this.ReadValue(); * Read(); * } * else * { */ asdocVal = this.ReadInnerXml(); // } doc.ExtraAsDocs.Add(new KeyValuePair <string, string>(asdocKey, asdocVal)); } }
private void ReadReturnsDesc(ASDocItem doc) { if (IsEmptyElement) { return; } string eon = Name; ReadStartElement(); while (Name != eon) { switch (this.Name) { case "apiDesc": doc.Returns = ReadValue(); break; case "apiType": ReadApiType(doc); break; case "apiValueClassifier": case "apiOperationClassifier": ReadApiTypeAsClassifier(doc); break; } Read(); } }
//--------------------------- // apiException //--------------------------- private void ReadApiException(ASDocItem doc) { if (IsEmptyElement) { return; } string apiDesc = ""; string apiItemName = ""; string apiOperationClassifier = ""; string eon = Name; ReadStartElement(); while (Name != eon) { switch (Name) { case "apiDesc": apiDesc = ReadValue(); break; case "apiItemName": apiItemName = ReadValue(); break; case "apiOperationClassifier": apiOperationClassifier = ReadValue(); break; } Read(); } doc.ExtraAsDocs.Add(new KeyValuePair <string, string>("throws", apiItemName + " " + apiDesc)); }
private static void applyTypeComment(ASDocItem doc, MemberModel model) { if (doc == null || model == null) { return; } ASFileParserUtils.ParseTypeDefinitionInto(doc.ApiType, model, true, true); }
private void ReadEventMeta(ASDocItem doc) { if (IsEmptyElement) { return; } ASMetaData meta = new ASMetaData("Event"); meta.Kind = ASMetaKind.Event; meta.Comments = ""; string eName = null; string eType = null; string eFullType = null; string eon = Name; ReadStartElement(); while (Name != eon) { if (NodeType == XmlNodeType.Element) { switch (Name) { case "shortdesc": meta.Comments = ReadValue() ?? ""; break; case "apiDesc": if (meta.Comments == "") { meta.Comments = ReadValue() ?? ""; } break; case "apiName": eName = ReadValue(); break; case "adobeApiEventClassifier": eType = ReadValue().Replace(':', '.'); break; case "apiEventType": eFullType = ReadValue(); break; } } Read(); } if (doc.Meta == null) { doc.Meta = new List <ASMetaData>(); } meta.Params = new Dictionary <string, string>(); meta.Params["name"] = eName; meta.Params["type"] = eType; if (eFullType != null) { meta.Comments = meta.Comments.Trim() + "\n@eventType\t" + eFullType.Replace(':', '.'); } meta.RawParams = String.Format("name=\"{0}\", type=\"{1}\"", eName, eType); doc.Meta.Add(meta); }
private void ProcessDeclarationNodes(ASDocItem doc) { if (NodeType != XmlNodeType.Element) { return; } switch (Name) { case "apiName": break; // TODO validate event name case "apiInheritDoc": break; // TODO link inherited doc? case "apiDetail": case "related-links": SkipContents(); break; case "apiClassifierDetail": ReadApiClassifierDetail(doc); break; case "apiClassifier": case "apiValue": case "apiOperation": case "apiConstructor": ReadDeclaration(); break; case "shortdesc": doc.ShortDesc = ReadValue(); break; case "prolog": ReadProlog(doc); break; case "apiDesc": doc.LongDesc = ReadValue(); break; case "apiData": doc.Value = ReadValue(); break; case "style": ReadStyleMeta(doc); break; case "Exclude": ReadExcludeMeta(doc); break; case "adobeApiEvent": ReadEventMeta(doc); break; case "apiFinal": doc.IsFinal = true; SkipContents(); break; case "apiParam": ReadParamDesc(doc); break; case "apiReturn": ReadReturnsDesc(doc); break; case "apiException": ReadApiException(doc); break; // TODO link inherited doc? case "apiType": ReadApiType(doc); break; case "apiValueClassifier": case "apiOperationClassifier": ReadApiTypeAsClassifier(doc); break; } }
private void ReadStyleMeta(ASDocItem doc) { if (IsEmptyElement || !HasAttributes) { return; } ASMetaData meta = new ASMetaData("Style"); meta.Kind = ASMetaKind.Style; meta.Comments = ""; string sName = GetAttribute("name"); string sType = GetAttribute("type"); //string sInherit = GetAttribute("inherit"); //string sFormat = GetAttribute("format"); string sEnum = GetAttribute("enumeration"); string sDefault = null; string eon = Name; ReadStartElement(); while (Name != eon) { if (NodeType == XmlNodeType.Element) { switch (Name) { case "description": meta.Comments = ReadValue() ?? ""; break; case "default": sDefault = ReadValue(); break; } } Read(); } if (doc.Meta == null) { doc.Meta = new List <ASMetaData>(); } if (sDefault != null) { meta.Comments = meta.Comments.Trim() + "\n@default\t" + sDefault; } meta.Params = new Dictionary <string, string>(); meta.Params["name"] = sName; meta.Params["type"] = sType; meta.RawParams = String.Format("name=\"{0}\", type=\"{1}\"", sName, sType); if (sEnum != null) { meta.Params["enumeration"] = sEnum; meta.RawParams += ", enumeration=\"" + sEnum + "\""; } doc.Meta.Add(meta); }
public void Parse(Dictionary <string, ASDocItem> packageDocs) { docs = packageDocs; ASDocItem doc = new ASDocItem(); MoveToContent(); while (Read()) { ProcessDeclarationNodes(doc); } docs = null; }
private void ReadPrologMetadataApiVersion(ASDocItem doc) { if (IsEmptyElement) { return; } string asdocKey; string asdocVal; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiLanguage") { string sVers = GetAttribute("version"); asdocKey = "langversion"; asdocVal = sVers; doc.ExtraAsDocs.Add(new KeyValuePair <string, string>(asdocKey, asdocVal)); } else if (Name == "apiPlatform") { string sDesc = GetAttribute("description"); string sName = GetAttribute("name"); string sVers = GetAttribute("version"); asdocKey = "playerversion"; asdocVal = sName + " " + sVers + " " + sDesc; doc.ExtraAsDocs.Add(new KeyValuePair <string, string>(asdocKey, asdocVal)); } else if (Name == "apiTool") { string sDesc = GetAttribute("description"); string sName = GetAttribute("name"); string sVers = GetAttribute("version"); asdocKey = "productversion"; asdocVal = sName + " " + sVers + " " + sDesc; doc.ExtraAsDocs.Add(new KeyValuePair <string, string>(asdocKey, asdocVal)); } Read(); } }
//--------------------------- // apiOperationDetail //--------------------------- private void ReadParamDesc(ASDocItem doc) { if (IsEmptyElement) { return; } string name = null; string desc = null; string type = null; string eon = Name; ReadStartElement(); while (Name != eon) { if (NodeType == XmlNodeType.Element) { switch (Name) { case "apiItemName": name = ReadValue(); break; case "apiDesc": desc = ReadValue(); break; case "apiType": type = GetAttribute("value"); break; } } Read(); } if (name != null) { if (desc != null) { doc.Params[name] = desc; } if (type != null) { doc.ParamTypes[name] = type; } } }
private static void applyTypeCommentToParams(ASDocItem doc, MemberModel model) { if (doc == null || model == null || model.Parameters == null) { return; } foreach (MemberModel param in model.Parameters) { if (doc.ParamTypes != null && doc.ParamTypes.ContainsKey(param.Name)) { ASFileParserUtils.ParseTypeDefinitionInto(doc.ParamTypes[param.Name], param, true, true); } } }
private void ReadPrologMetadata(ASDocItem doc) { if (IsEmptyElement) { return; } string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiVersion") { ReadPrologMetadataApiVersion(doc); } Read(); } }
/// <summary> /// old name: setDoc() /// </summary> private static void applyASDoc(ASDocItem doc, MemberModel model) { model.Comments = doc.LongDesc; if (doc.IsFinal) { model.Flags |= FlagType.Final; } if (doc.IsDynamic && (model is ClassModel)) { model.Flags |= FlagType.Dynamic; } if (doc.Value != null) { model.Value = doc.Value; } // TODO Extract features in comments applyTypeComment(doc, model); applyTypeCommentToParams(doc, model); }
//--------------------------- // Meta tags //--------------------------- private void ReadExcludeMeta(ASDocItem doc) { if (!HasAttributes) { return; } ASMetaData meta = new ASMetaData("Style"); meta.Kind = ASMetaKind.Exclude; string sKind = GetAttribute("kind"); string sName = GetAttribute("name"); if (doc.Meta == null) { doc.Meta = new List <ASMetaData>(); } meta.Params = new Dictionary <string, string>(); meta.Params["kind"] = sKind; meta.Params["name"] = sName; meta.RawParams = String.Format("kind=\"{0}\", name=\"{1}\"", sKind, sName); doc.Meta.Add(meta); }
//--------------------------- // apiClassifierDetail //--------------------------- private void ReadApiClassifierDetail(ASDocItem doc) { doc.LongDesc = ""; if (IsEmptyElement) { return; } string eon = Name; Read(); while (Name != eon) { switch (Name) { case "apiClassifierDef": ReadApiClassifierDef(doc); Read(); break; case "apiDesc": doc.LongDesc += this.ReadInnerXml() + "\n"; // Read(); break; case "example": doc.LongDesc += "\nEXAMPLE: \n\n" + this.ReadInnerXml() + "\n"; // Read(); break; default: this.ReadInnerXml(); break; } } }
private void ReadApiClassifierDef(ASDocItem doc) { if (IsEmptyElement) { return; } string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiFinal") { doc.IsFinal = true; } else if (Name == "apiDynamic") { doc.IsDynamic = true; } Read(); } }
//--------------------------- // prolog //--------------------------- /// <summary> /// --- /// Example: /// <prolog> /// <asMetadata> /// <apiVersion> /// <apiLanguage version="3.0" /> /// <apiPlatform description="" name="Flash" version="10" /> /// <apiPlatform description="" name="AIR" version="1.5" /> /// <apiTool description="" name="Flex" version="3" /> /// </apiVersion> /// </asMetadata> /// <asCustoms> /// <customAsDoc> /// <type c="String" /> /// </customAsDoc> /// </asCustoms> /// </prolog> /// --- /// </summary> /// <param name="doc"></param> private void ReadProlog(ASDocItem doc) { if (IsEmptyElement) { return; } string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "asMetadata") { ReadPrologMetadata(doc); } else if (Name == "asCustoms") { ReadPrologCustoms(doc, Name); } Read(); } }
//--------------------------- // apiType //--------------------------- private void ReadApiType(ASDocItem doc) { SetApiType(doc, GetAttribute("value")); }
private void ReadApiTypeAsClassifier(ASDocItem doc) { SetApiType(doc, ReadValue()); }
//--------------------------- // apiException //--------------------------- private void ReadApiException(ASDocItem doc) { if (IsEmptyElement) return; string apiDesc = ""; string apiItemName = ""; string apiOperationClassifier = ""; string eon = Name; ReadStartElement(); while (Name != eon) { switch (Name) { case "apiDesc": apiDesc = ReadValue(); break; case "apiItemName": apiItemName = ReadValue(); break; case "apiOperationClassifier": apiOperationClassifier = ReadValue(); break; } Read(); } doc.ExtraAsDocs.Add(new KeyValuePair<string, string>("throws", apiItemName + " " + apiDesc)); }
private void ReadReturnsDesc(ASDocItem doc) { if (IsEmptyElement) return; string eon = Name; ReadStartElement(); while (Name != eon) { switch (this.Name) { case "apiDesc": doc.Returns = ReadValue(); break; case "apiType": ReadApiType(doc); break; case "apiValueClassifier": case "apiOperationClassifier": ReadApiTypeAsClassifier(doc); break; } Read(); } }
public void Parse(Dictionary<string, ASDocItem> packageDocs) { docs = packageDocs; ASDocItem doc = new ASDocItem(); MoveToContent(); while (Read()) ProcessDeclarationNodes(doc); docs = null; }
//--------------------------- // apiClassifierDetail //--------------------------- private void ReadApiClassifierDetail(ASDocItem doc) { doc.LongDesc = ""; if (IsEmptyElement) return; string eon = Name; Read(); while (Name != eon) { switch (Name) { case "apiClassifierDef": ReadApiClassifierDef(doc); Read(); break; case "apiDesc": doc.LongDesc += this.ReadInnerXml() +"\n"; // Read(); break; case "example": doc.LongDesc += "\nEXAMPLE: \n\n" + this.ReadInnerXml() +"\n"; // Read(); break; default: this.ReadInnerXml(); break; } } }
//--------------------------- // PRIMARY //--------------------------- private void ReadDeclaration() { if (IsEmptyElement) return; if (this.ExcludedASDocs == null) this.ExcludedASDocs = new List<string>(); ASDocItem doc = new ASDocItem(); string id = GetAttribute("id"); if (id != null) { // type doubled in doc: "flash.utils:IDataOutput:flash.utils:IDataOutput:writeDouble" int colon = id.IndexOf(':') + 1; if (colon > 0) { int dup = id.IndexOf(id.Substring(0, colon), colon); if (dup > 0) id = id.Substring(dup); } doc.ApiType = id; } string eon = Name; ReadStartElement(); while (Name != eon) { ProcessDeclarationNodes(doc); Read(); } if (id != null) { if (doc.ApiType == "String" && doc.Value != null && !doc.Value.StartsWith("\"")) doc.Value = "\"" + doc.Value + "\""; if (doc.LongDesc == null) doc.LongDesc = ""; if (doc.ShortDesc == null) doc.ShortDesc = doc.LongDesc; else doc.LongDesc = doc.LongDesc.Trim(); if (doc.LongDesc.Length == 0 && doc.ShortDesc.Length > 0) doc.LongDesc = doc.ShortDesc; if (!this.ExcludedASDocs.Contains("param") && doc.Params != null) foreach (string name in doc.Params.Keys) doc.LongDesc += "\n@param\t" + name + "\t" + doc.Params[name].Trim(); if (!this.ExcludedASDocs.Contains("return") && doc.Returns != null) doc.LongDesc += "\n@return\t" + doc.Returns.Trim(); if (doc.ExtraAsDocs != null) foreach (KeyValuePair<string, string> extraASDoc in doc.ExtraAsDocs) if (!this.ExcludedASDocs.Contains(extraASDoc.Key)) doc.LongDesc += "\n@" + extraASDoc.Key + "\t" + extraASDoc.Value; if (doc.ShortDesc.Length > 0 || doc.LongDesc.Length > 0) docs[id] = doc; } }
private void SetApiType(ASDocItem doc, string apiType) { doc.ApiType = apiType == "any" ? "*" : apiType; }
private void ReadStyleMeta(ASDocItem doc) { if (IsEmptyElement || !HasAttributes) return; ASMetaData meta = new ASMetaData("Style"); meta.Kind = ASMetaKind.Style; meta.Comments = ""; string sName = GetAttribute("name"); string sType = GetAttribute("type"); //string sInherit = GetAttribute("inherit"); //string sFormat = GetAttribute("format"); string sEnum = GetAttribute("enumeration"); string sDefault = null; string eon = Name; ReadStartElement(); while (Name != eon) { if (NodeType == XmlNodeType.Element) switch (Name) { case "description": meta.Comments = ReadValue() ?? ""; break; case "default": sDefault = ReadValue(); break; } Read(); } if (doc.Meta == null) doc.Meta = new List<ASMetaData>(); if (sDefault != null) meta.Comments = meta.Comments.Trim() + "\n@default\t" + sDefault; meta.Params = new Dictionary<string, string>(); meta.Params["name"] = sName; meta.Params["type"] = sType; meta.RawParams = String.Format("name=\"{0}\", type=\"{1}\"", sName, sType); if (sEnum != null) { meta.Params["enumeration"] = sEnum; meta.RawParams += ", enumeration=\"" + sEnum + "\""; } doc.Meta.Add(meta); }
private void ReadPrologMetadata(ASDocItem doc) { if (IsEmptyElement) return; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiVersion") ReadPrologMetadataApiVersion(doc); else if (Name == "styles") ReadPrologMetadataStyles(doc); else if (Name == "DefaultProperty") ReadPrologMetadataDefaultProperty(doc); Read(); } }
private void ReadEventMeta(ASDocItem doc) { if (IsEmptyElement) return; ASMetaData meta = new ASMetaData("Event"); meta.Kind = ASMetaKind.Event; meta.Comments = ""; string eName = null; string eType = null; string eFullType = null; string eon = Name; ReadStartElement(); while (Name != eon) { if (NodeType == XmlNodeType.Element) switch (Name) { case "shortdesc": meta.Comments = ReadValue() ?? ""; break; case "apiDesc": if (meta.Comments == "") meta.Comments = ReadValue() ?? ""; break; case "apiName": eName = ReadValue(); break; case "adobeApiEventClassifier": eType = ReadValue().Replace(':', '.'); break; case "apiEventType": eFullType = ReadValue(); break; } Read(); } if (doc.Meta == null) doc.Meta = new List<ASMetaData>(); meta.Params = new Dictionary<string, string>(); meta.Params["name"] = eName; meta.Params["type"] = eType; if (eFullType != null) meta.Comments = meta.Comments.Trim() + "\n@eventType\t" + eFullType.Replace(':', '.'); meta.RawParams = String.Format("name=\"{0}\", type=\"{1}\"", eName, eType); doc.Meta.Add(meta); }
/// <summary> /// old name: setDoc() /// </summary> private static void applyASDoc(ASDocItem doc, MemberModel model) { model.Comments = doc.LongDesc; if (doc.IsFinal) model.Flags |= FlagType.Final; if (doc.IsDynamic && (model is ClassModel)) model.Flags |= FlagType.Dynamic; if (doc.Value != null) model.Value = doc.Value; // TODO Extract features in comments applyTypeComment(doc, model); applyTypeCommentToParams(doc, model); }
private void ReadApiClassifierDef(ASDocItem doc) { if (IsEmptyElement) return; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiFinal") doc.IsFinal = true; else if (Name == "apiDynamic") doc.IsDynamic = true; Read(); } }
private void ReadPrologMetadataStyles(ASDocItem doc) { if (IsEmptyElement) return; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "style") ReadStyleMeta(doc); Read(); } }
//--------------------------- // apiOperationDetail //--------------------------- private void ReadParamDesc(ASDocItem doc) { if (IsEmptyElement) return; string name = null; string desc = null; string type = null; string eon = Name; ReadStartElement(); while (Name != eon) { if (NodeType == XmlNodeType.Element) { switch (Name) { case "apiItemName": name = ReadValue(); break; case "apiDesc": desc = ReadValue(); break; case "apiType": type = GetAttribute("value"); break; } } Read(); } if (name != null) { if (desc != null) doc.Params[name] = desc; if (type != null) doc.ParamTypes[name] = type; } }
private static void applyTypeCommentToParams(ASDocItem doc, MemberModel model) { if (doc == null || model == null || model.Parameters == null) return; foreach (MemberModel param in model.Parameters) if (doc.ParamTypes != null && doc.ParamTypes.ContainsKey(param.Name)) ASFileParserUtils.ParseTypeDefinitionInto(doc.ParamTypes[param.Name], param, true, true); }
//--------------------------- // Meta tags //--------------------------- private void ReadExcludeMeta(ASDocItem doc) { if (!HasAttributes) return; ASMetaData meta = new ASMetaData("Style"); meta.Kind = ASMetaKind.Exclude; string sKind = GetAttribute("kind"); string sName = GetAttribute("name"); if (doc.Meta == null) doc.Meta = new List<ASMetaData>(); meta.Params = new Dictionary<string, string>(); meta.Params["kind"] = sKind; meta.Params["name"] = sName; meta.RawParams = String.Format("kind=\"{0}\", name=\"{1}\"", sKind, sName); doc.Meta.Add(meta); }
private void ProcessDeclarationNodes(ASDocItem doc) { if (NodeType != XmlNodeType.Element) return; switch (Name) { case "apiName": break; // TODO validate event name case "apiInheritDoc": break; // TODO link inherited doc? case "apiDetail": case "related-links": SkipContents(); break; case "apiClassifierDetail": ReadApiClassifierDetail(doc); break; case "apiClassifier": case "apiValue": case "apiOperation": case "apiConstructor": ReadDeclaration(); break; case "shortdesc": doc.ShortDesc = ReadValue(); break; case "prolog": ReadProlog(doc); break; case "apiDesc": doc.LongDesc = ReadValue(); break; case "apiData": doc.Value = ReadValue(); break; case "style": ReadStyleMeta(doc); break; case "Exclude": ReadExcludeMeta(doc); break; case "adobeApiEvent": ReadEventMeta(doc); break; case "apiFinal": doc.IsFinal = true; SkipContents(); break; case "apiParam": ReadParamDesc(doc); break; case "apiReturn": ReadReturnsDesc(doc); break; case "apiException": ReadApiException(doc); break; // TODO link inherited doc? case "apiType": ReadApiType(doc); break; case "apiValueClassifier": case "apiOperationClassifier": ReadApiTypeAsClassifier(doc); break; } }
//--------------------------- // prolog //--------------------------- /// <summary> /// --- /// Example: /// <prolog> /// <asMetadata> /// <apiVersion> /// <apiLanguage version="3.0" /> /// <apiPlatform description="" name="Flash" version="10" /> /// <apiPlatform description="" name="AIR" version="1.5" /> /// <apiTool description="" name="Flex" version="3" /> /// </apiVersion> /// </asMetadata> /// <asCustoms> /// <customAsDoc> /// <type c="String" /> /// </customAsDoc> /// </asCustoms> /// </prolog> /// --- /// </summary> /// <param name="doc"></param> private void ReadProlog(ASDocItem doc) { if (IsEmptyElement) return; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "asMetadata") ReadPrologMetadata(doc); else if (Name == "asCustoms") ReadPrologCustoms(doc, Name); Read(); } }
private static void applyTypeComment(ASDocItem doc, MemberModel model) { if (doc == null || model ==null) return; ASFileParserUtils.ParseTypeDefinitionInto(doc.ApiType, model, true, true); }
private void ReadPrologMetadata(ASDocItem doc) { if (IsEmptyElement) return; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiVersion") ReadPrologMetadataApiVersion(doc); Read(); } }
private void ReadPrologMetadataApiVersion(ASDocItem doc) { if (IsEmptyElement) return; string asdocKey; string asdocVal; string eon = Name; ReadStartElement(); while (Name != eon) { if (Name == "apiLanguage") { string sVers = GetAttribute("version"); asdocKey = "langversion"; asdocVal = sVers; doc.ExtraAsDocs.Add(new KeyValuePair<string, string>(asdocKey, asdocVal)); } else if (Name == "apiPlatform") { string sDesc = GetAttribute("description"); string sName = GetAttribute("name"); string sVers = GetAttribute("version"); asdocKey = "playerversion"; asdocVal = sName + " " + sVers + " " + sDesc; doc.ExtraAsDocs.Add(new KeyValuePair<string, string>(asdocKey, asdocVal)); } else if (Name == "apiTool") { string sDesc = GetAttribute("description"); string sName = GetAttribute("name"); string sVers = GetAttribute("version"); asdocKey = "productversion"; asdocVal = sName + " " + sVers + " " + sDesc; doc.ExtraAsDocs.Add(new KeyValuePair<string, string>(asdocKey, asdocVal)); } Read(); } }
//--------------------------- // PRIMARY //--------------------------- private void ReadDeclaration() { if (IsEmptyElement) { return; } if (this.ExcludedASDocs == null) { this.ExcludedASDocs = new List <string>(); } ASDocItem doc = new ASDocItem(); string id = GetAttribute("id"); if (id != null) { // type doubled in doc: "flash.utils:IDataOutput:flash.utils:IDataOutput:writeDouble" int colon = id.IndexOf(':') + 1; if (colon > 0) { int dup = id.IndexOf(id.Substring(0, colon), colon); if (dup > 0) { id = id.Substring(dup); } } doc.ApiType = id; } string eon = Name; ReadStartElement(); while (Name != eon) { ProcessDeclarationNodes(doc); Read(); } if (id != null) { if (doc.ApiType == "String" && doc.Value != null && !doc.Value.StartsWith("\"")) { doc.Value = "\"" + doc.Value + "\""; } if (doc.LongDesc == null) { doc.LongDesc = ""; } if (doc.ShortDesc == null) { doc.ShortDesc = doc.LongDesc; } else { doc.LongDesc = doc.LongDesc.Trim(); } if (doc.LongDesc.Length == 0 && doc.ShortDesc.Length > 0) { doc.LongDesc = doc.ShortDesc; } if (!this.ExcludedASDocs.Contains("param") && doc.Params != null) { foreach (string name in doc.Params.Keys) { doc.LongDesc += "\n@param\t" + name + "\t" + doc.Params[name].Trim(); } } if (!this.ExcludedASDocs.Contains("return") && doc.Returns != null) { doc.LongDesc += "\n@return\t" + doc.Returns.Trim(); } if (doc.ExtraAsDocs != null) { foreach (KeyValuePair <string, string> extraASDoc in doc.ExtraAsDocs) { if (!this.ExcludedASDocs.Contains(extraASDoc.Key)) { doc.LongDesc += "\n@" + extraASDoc.Key + "\t" + extraASDoc.Value; } } } if (doc.ShortDesc.Length > 0 || doc.LongDesc.Length > 0) { docs[id] = doc; } } }
private void ReadPrologCustoms(ASDocItem doc, string terminationNode) { if (IsEmptyElement) return; string asdocKey; string asdocVal; string eon = terminationNode; ReadStartElement(); while (!(Name == eon && NodeType == XmlNodeType.EndElement)) { asdocKey = this.Name; /* if (asdocKey == "maelexample") { asdocVal = this.ReadValue(); Read(); } else { */ asdocVal = this.ReadInnerXml(); // } doc.ExtraAsDocs.Add(new KeyValuePair<string, string>(asdocKey, asdocVal)); } }
/// <summary> /// Create virtual FileModel objects from Abc bytecode /// </summary> /// <param name="abcs"></param> /// <param name="path"></param> /// <param name="context"></param> public static void Convert(ContentParser parser, PathModel path, IASContext context) { inSWF = Path.GetExtension(path.Path).ToLower() == ".swf"; // extract documentation ParseDocumentation(parser); // extract models Dictionary <string, FileModel> models = new Dictionary <string, FileModel>(); FileModel privateClasses = new FileModel(Path.Combine(path.Path, "__Private.as")); privateClasses.Version = 3; privateClasses.Package = "private"; genericTypes = new Dictionary <string, FileModel>(); imports = new Dictionary <string, string>(); conflicts = new Dictionary <string, string>(); foreach (Abc abc in parser.Abcs) { // types foreach (Traits trait in abc.classes) { Traits instance = trait.itraits; if (instance == null) { continue; } imports.Clear(); conflicts.Clear(); FileModel model = new FileModel(""); model.Context = context; model.Package = reSafeChars.Replace(instance.name.uri, "_"); model.HasPackage = true; string filename = reSafeChars.Replace(trait.name.ToString(), "_").TrimEnd('$'); filename = Path.Combine(model.Package.Replace('.', Path.DirectorySeparatorChar), filename); model.FileName = Path.Combine(path.Path, filename); model.Version = 3; ClassModel type = new ClassModel(); model.Classes = new List <ClassModel>(); model.Classes.Add(type); type.InFile = model; type.Type = instance.name.ToTypeString(); type.Name = instance.name.localName; type.Flags = FlagType.Class; conflicts.Add(type.Name, type.QualifiedName); if (instance.flags == TraitMember.Function) { type.Flags |= FlagType.Interface; } thisDocs = GetDocs(model.Package); if (thisDocs != null) { docPath = (model.Package.Length > 0 ? model.Package + ":" : "globalClassifier:") + type.Name; if (thisDocs.ContainsKey(docPath)) { ASDocItem doc = thisDocs[docPath]; applyASDoc(doc, type); if (doc.Meta != null) { model.MetaDatas = doc.Meta; } } if (model.Package.Length == 0) { docPath = type.Name; } } if (instance.baseName.uri == model.Package) { type.ExtendsType = ImportType(instance.baseName.localName); } else { type.ExtendsType = ImportType(instance.baseName); } if (instance.interfaces != null && instance.interfaces.Length > 0) { type.Implements = new List <string>(); foreach (QName name in instance.interfaces) { type.Implements.Add(ImportType(name)); } } if (model.Package == "private") { model.Package = ""; type.Access = Visibility.Private; type.Namespace = "private"; } else if (model.Package == "__AS3__.vec") { model.Package = ""; type.Access = Visibility.Private; type.Namespace = "private"; string genType = type.Name; if (type.Name.IndexOf("$") > 0) { string[] itype = type.Name.Split('$'); genType = itype[0]; type.Name = itype[0] + "$" + itype[1]; type.IndexType = itype[1]; } if (genericTypes.ContainsKey(genType)) { model.Classes.Clear(); type.InFile = genericTypes[genType]; genericTypes[genType].Classes.Add(type); } else { genericTypes[genType] = model; } } else if (type.Name.StartsWith("_")) { type.Access = Visibility.Private; type.Namespace = "private"; } else { type.Access = Visibility.Public; type.Namespace = "public"; } type.Members = GetMembers(trait.members, FlagType.Static, instance.name); type.Members.Add(GetMembers(instance.members, FlagType.Dynamic, instance.name)); if ((type.Flags & FlagType.Interface) > 0) { // TODO properly support interface multiple inheritance type.ExtendsType = null; if (type.Implements != null && type.Implements.Count > 0) { type.ExtendsType = type.Implements[0]; type.Implements.RemoveAt(0); if (type.Implements.Count == 0) { type.Implements = null; } } foreach (MemberModel member in type.Members) { member.Access = Visibility.Public; member.Namespace = ""; } } // constructor if (instance.init != null && (type.Flags & FlagType.Interface) == 0) { List <MemberInfo> temp = new List <MemberInfo>(new MemberInfo[] { instance.init }); MemberList result = GetMembers(temp, 0, instance.name); if (result.Count > 0) { MemberModel ctor = result[0]; ctor.Flags |= FlagType.Constructor; ctor.Access = Visibility.Public; ctor.Type = type.Type; ctor.Namespace = "public"; type.Members.Merge(result); type.Constructor = ctor.Name; } result = null; temp = null; } else { type.Constructor = type.Name; } if (type.Access == Visibility.Private) { model = privateClasses; type.InFile = model; } if (model.Classes.Count > 0 || model.Members.Count > 0) { AddImports(model, imports); models[model.FileName] = model; } } // packages if (abc.scripts == null) { continue; } foreach (Traits trait in abc.scripts) { FileModel model = null; foreach (MemberInfo info in trait.members) { if (info.kind == TraitMember.Class) { continue; } MemberModel member = GetMember(info, 0); if (member == null) { continue; } if (model == null || model.Package != info.name.uri) { AddImports(model, imports); string package = info.name.uri ?? ""; string filename = package.Length > 0 ? "package.as" : "toplevel.as"; filename = Path.Combine(package.Replace('.', Path.DirectorySeparatorChar), filename); filename = Path.Combine(path.Path, filename); if (models.ContainsKey(filename)) { model = models[filename]; } else { model = new FileModel(""); model.Context = context; model.Package = package; model.HasPackage = true; model.FileName = filename; model.Version = 3; models[filename] = model; } } thisDocs = GetDocs(model.Package); if (thisDocs != null) { docPath = "globalOperation:" + (model.Package.Length > 0 ? model.Package + ":" : "") + member.Name; if (member.Access == Visibility.Public && !String.IsNullOrEmpty(member.Namespace) && member.Namespace != "public") { docPath += member.Namespace + ":"; } if ((member.Flags & FlagType.Setter) > 0) { docPath += ":set"; } else if ((member.Flags & FlagType.Getter) > 0) { docPath += ":get"; } if (thisDocs.ContainsKey(docPath)) { applyASDoc(thisDocs[docPath], member); } } member.InFile = model; member.IsPackageLevel = true; model.Members.Add(member); } AddImports(model, imports); } } if (privateClasses.Classes.Count > 0) { models[privateClasses.FileName] = privateClasses; } // some SWCs need manual fixes CustomFixes(path.Path, models); // fake SWC (like 'playerglobal_rb.swc', only provides documentation) if (models.Keys.Count == 1) { foreach (FileModel model in models.Values) { if (model.GetPublicClass().QualifiedName == "Empty") { models.Clear(); break; } } } path.SetFiles(models); }
private void ReadPrologMetadataDefaultProperty(ASDocItem doc) { ASMetaData meta = new ASMetaData("DefaultProperty"); meta.Kind = ASMetaKind.DefaultProperty; meta.Comments = ""; meta.Params = new Dictionary<string, string>(); string defValue = GetAttribute("name"); meta.Params["default"] = defValue; meta.RawParams = string.Format("\"{0}\"", defValue); if (doc.Meta == null) doc.Meta = new List<ASMetaData>(); doc.Meta.Add(meta); }