static void Validate(CompilerFrontEnd cfe) { ValidationBuilder v = new ValidationBuilder(cfe.Options, global, paramSetScriptExt, paramBasePath, paramMainPath); List <ValidationBuilder.ModuleInfo> files = new List <ValidationBuilder.ModuleInfo>(); ValidationBuilder.ModuleInfo moduleInfo = new ValidationBuilder.ModuleInfo(); while (v.NextFile(ref moduleInfo)) { if (moduleInfo.Paths == null) { WriteLine(ConCol.Error, "Path error for {0}, path difference bug!", moduleInfo.Name); continue; } files.Add(moduleInfo); } int Successes = 0; foreach (var mi in files.AsIndexable()) { if (ProcessFile(cfe, mi.Value.Info, mi.Total, mi.Index)) { ++Successes; cfe.UserDefinedDOM.FullPath = mi.Value.Info.FullName; v.Ca.AddNewModule(cfe.UserDefinedDOM, mi.Value.Paths); } } if (v.Ca.FinalAnalyze()) //TODO: Does root CM even become resolved? { WriteLine(ConCol.Success, "All symbols are resolved."); } if (paramValidationLog == null) { WriteLine(ConCol.Warning, v.BuildMessageStats()); WriteLine(ConCol.Warning, "Warnings ({0} Total):".Fmt(v.Ca.Warnings.Count)); foreach (var m in v.Ca.Warnings.AsIndexable()) { if (m.Index < 100) { WriteLine(ConCol.Warning, "{0}) {1}", m.Index + 1, m.Value.ToString()); } else { WriteLine(ConCol.Info, "Number of warnings exceed 100. To view all of them, compile with a validation log."); break; } } WriteLine(ConCol.Error, "Errors ({0} Total):".Fmt(v.Ca.Errors.Count)); foreach (var m in v.Ca.Errors.AsIndexable()) { if (m.Index < 100) { WriteLine(ConCol.Error, "{0}) {1}", m.Index + 1, m.Value.ToString()); } else { WriteLine(ConCol.Info, "Number of errors exceed 100. To view all of them, compile with a validation log."); break; } } if (v.Ca.Errors.Count > 0) { ExecuteOnError(v.Ca.Errors[0].Module.DOM.FullPath, v.Ca.Errors[0].Target.Location); } } else if (!paramPackLog) { WriteLine(ConCol.Info, "No Warning/Error Messages will be shown here, all messages will be written to {0}", paramValidationLog); using (var sw = new StreamWriter(paramValidationLog)) { sw.WriteLine(v.BuildMessageStats()); sw.WriteLine("Warnings ({0}):".Fmt(v.Ca.Warnings.Count)); sw.WriteLine(); sw.WriteLine(); foreach (var m in v.Ca.Warnings) { sw.WriteLine("{0:D3}) {1}", m.MsgType, m.ToString()); } sw.WriteLine("Errors ({0}):".Fmt(v.Ca.Errors.Count)); sw.WriteLine(); sw.WriteLine(); foreach (var m in v.Ca.Errors) { sw.WriteLine("{0:D3}) {1}", m.MsgType, m.ToString()); } } } else { using (var sw = new StreamWriter(paramValidationLog)) { XmlSerializer xs = new XmlSerializer(typeof(GameScriptCompiler.ContextAnalyzation.MessageObject[])); xs.Serialize(sw, v.GetMessageObjects()); } } if (paramStubOut != null) { if (StubGen.CheckUnSpecifics(v.Ca.Errors)) { using (var sw = new StreamWriter(paramStubOut)) { StubGen.StubOut(sw, v.Ca.Errors, cfe.Options); WriteLine(ConCol.Info, "Wrote function stubs [{0}]", paramStubOut); } } else { WriteLine(ConCol.Warning, "Cannot write stubs with these particular errors."); } } if (Successes == files.Count) { WriteLine(ConCol.Success, "Succussfully syntaxed all files!"); } else { WriteLine(ConCol.Warning, "Completed with warnings/errrors."); } }