/// <summary> /// Filter documents. /// </summary> /// <param name="docs">All documents.</param> /// <param name="excludedTypes">The exclude types.</param> /// <returns>Avaiable documents.</returns> private List <Document> FilterDocuments(List <Document> docs, List <string> excludedTypes) { if (excludedTypes.Count == 0) { return(docs); } List <Document> usedDocs = new List <Document>(); foreach (Document doc in docs) { bool isExcluded = DocumentUtil.GetTypeNames(doc).TrueForAll(n => excludedTypes.Contains(n)); if (!isExcluded) { usedDocs.Add(doc); } } return(usedDocs); }
/// <summary> /// Prints lost nodes. /// </summary> /// <param name="tsDocs"></param> private void PrintLostNodes(List <Document> tsDocs) { List <string> hasPrint = new List <string>(); foreach (var doc in tsDocs) { var lostNodes = DocumentUtil.GetLostNodes(doc).Where((item) => hasPrint.IndexOf(item.Key) == -1).ToList(); if (lostNodes.Count == 0) { continue; } this.Log(doc.Path, false); foreach (var item in lostNodes) { hasPrint.Add(item.Key); this.Log(string.Format(" {0,-20} {1}", item.Key, item.Value), false); } } }
/// <summary> /// Search lost and unsupport syntax node. /// </summary> /// <param name="tsDocs">The ast documents.</param> /// <returns></returns> private bool ConfirmConvert(List <Document> tsDocs) { DateTime startTime = DateTime.Now; this.Log(string.Format("Starting search lost nodes and not implement node types.")); this.PrintLostNodes(tsDocs); List <string> unSupportedNodes = DocumentUtil.GetNotImplementNodeTypes(tsDocs); this.Log(string.Format("Finished after {0}s", (DateTime.Now - startTime).TotalSeconds.ToString("0.00"))); // if (unSupportedNodes.Count > 0) { this.Log("Find unsupported node kinds: " + string.Join(",", unSupportedNodes) + ". Do you want continue to convert? (yes|no) "); string confirm = Console.ReadLine().ToLower(); if (confirm != "y" && confirm != "yes") { return(false); } } return(true); }