////////////////////////////////////////////////////////////////////////// public bool ExtractProjectStrings(string ProjectFilename, string ScriptMasks, string DefMasks) { this.ScriptMasks = ScriptMasks.Split(new char[] { ';' }); this.DefMasks = DefMasks.Split(new char[] { ';' }); Strings = new List <StringLocation>(); WmeProject Project = new WmeProject(ProjectFilename); if (Project.Packages.Length == 0) { AddLog(LogSeverity.Warning, "No packages found in project"); return(true); } // count files NumFiles = 0; ReportProgress(0, "Scanning project..."); foreach (ProjectPackage Package in Project.Packages) { CountFiles(Package.FullPath, ref NumFiles); } // scan files int CurrentFile = 0; foreach (ProjectPackage Package in Project.Packages) { ScanDirectory(Package.FullPath, ref CurrentFile); } ReportProgress(0, "Done"); return(true); }
////////////////////////////////////////////////////////////////////////// public bool ExtractProjectStrings(string ProjectFilename, string ScriptMasks, string DefMasks) { this.ScriptMasks = ScriptMasks.Split(new char[] { ';' }); this.DefMasks = DefMasks.Split(new char[] { ';' }); Strings = new List<StringLocation>(); WmeProject Project = new WmeProject(ProjectFilename); if (Project.Packages.Length == 0) { AddLog(LogSeverity.Warning, "No packages found in project"); return true; } // count files NumFiles = 0; ReportProgress(0, "Scanning project..."); foreach (ProjectPackage Package in Project.Packages) { CountFiles(Package.FullPath, ref NumFiles); } // scan files int CurrentFile = 0; foreach(ProjectPackage Package in Project.Packages) { ScanDirectory(Package.FullPath, ref CurrentFile); } ReportProgress(0, "Done"); return true; }
////////////////////////////////////////////////////////////////////////// private void ClassifyStrings() { AddLog("Classifying strings...", false); IgnoredStrings = new List <StringItem>(); int CurrentIndex = 0; foreach (StringItem Item in ProjectStrings) { CurrentIndex++; ReportProgress(CurrentIndex, ProjectStrings.Count, Item.Value); Item.Ignored = false; // remove strings already present in the string table if (Item.ID != string.Empty && IsIDInTable(Item.ID)) { Item.Ignored = true; Item.IgnoreReason = IgnoreReason.AlreadyInTable; continue; } // keep strings with ID if (Item.ID != string.Empty) { continue; } // keep non-script strings if (!Item.IsScriptItem) { continue; } // remove strings in ignore list if (IsStringIgnored(Item.Value)) { Item.Ignored = true; Item.IgnoreReason = IgnoreReason.InIgnoreList; continue; } // remove filenames WmeProject Project = new WmeProject(this.ProjectFile); if (Project.ContainsFile(Item.Value)) { Item.Ignored = true; Item.IgnoreReason = IgnoreReason.IsFilename; continue; } // check one-word terms against well known code patterns if (Item.Value.IndexOf(' ') < 0 && IsWellKnownPattern(Item)) { Item.Ignored = true; Item.IgnoreReason = IgnoreReason.KnownCodePattern; continue; } } for (int i = 0; i < ProjectStrings.Count; i++) { StringItem Item = ProjectStrings[i]; if (Item.Ignored) { IgnoredStrings.Add(Item); ProjectStrings.RemoveAt(i); i--; } } ReportProgress(0, 0, ""); AddLog(IgnoredStrings.Count.ToString() + " strings automatically ignored"); }