Beispiel #1
0
 private static void CacheParse(string[] lPaths)
 {
     foreach (var lPath in lPaths)
     {
         bool foundAUTABlock = false;
         var  lLines         = File.ReadAllLines(lPath).ToList();
         for (int index = 0; index < lLines.Count; ++index)
         {
             var lLine = lLines[index];
             if (CommandInterface.ParseAUTALine(lLine))
             {
                 var plugin = mPlugins.FirstOrDefault(x => x.AcceptedLine(lLine));
                 var lBlock = plugin?.ExtractAUTABlock(lLines, index, lPath);
                 if (lBlock == null)
                 {
                     if (plugin != null)
                     {
                         Console.WriteLine("ERROR: No Plugin found to support Command Block : " + lPath + " : " + lLine);
                     }
                     mError = true;
                 }
                 else
                 {
                     foundAUTABlock = true;
                     index          = lBlock.endIndex;
                     plugin.CacheBlock(lBlock);
                 }
             }
         }
         if (foundAUTABlock == true)
         {
             ++filesWithAUTABlocks;
         }
     }
 }
Beispiel #2
0
 public static string[] ProcessExtraCommands(string lLine, List <string> lOutput)
 {
     if (!CommandInterface.IsEmptyExtraCommand(lLine))
     {
         bool FoundCommand = false;
         foreach (var lPlugin in mPlugins)
         {
             if (lPlugin.IsAcceptedExtraCommands(lLine))
             {
                 lOutput      = lPlugin.ProcessExtraCommands(lLine, lOutput).ToList();
                 FoundCommand = true;
             }
         }
         if (FoundCommand == false)
         {
             Console.WriteLine("ERROR: Invalid Extra Command Text : " + lLine);
             mError = true;
         }
     }
     return(lOutput.ToArray());
 }
Beispiel #3
0
        private static void ProcessParse()
        {
            HashSet <string> lImportPaths = new HashSet <string>();

            foreach (var plugin in mPlugins)
            {
                foreach (var lPath in plugin.mProcessPaths)
                {
                    lImportPaths.Add(lPath);
                }
            }

            foreach (var lPath in lImportPaths)
            {
                List <string> lResult = new List <string>();

                var lLines = File.ReadAllLines(lPath).ToList();
                for (int index = 0; index < lLines.Count; ++index)
                {
                    var lLine = lLines[index];
                    if (CommandInterface.ParseAUTALine(lLine))
                    {
                        //Find plugin to handle AUTA command
                        var plugin = mPlugins.FirstOrDefault(x => x.AcceptedLine(lLine));
                        var lBlock = plugin?.ExtractAUTABlock(lLines, index, lPath);
                        if (lBlock == null)
                        {
                            if (plugin != null)
                            {
                                Console.WriteLine("ERROR: No Plugin found to support Command Block : " + lPath + " : " + lLine);
                            }
                            mError = true;
                        }
                        else
                        {
                            var lInsert = plugin.ProcessBlock(lBlock);
                            if (lInsert != null)
                            {
                                //Strip ## commands
                                lInsert = CommandInterface.RemoveConcatination(lInsert.ToList()).ToArray();
                                lResult.Add(lLines[index]);
                                lResult.AddRange(lInsert);
                                lResult.Add(lLines[lBlock.endIndex]);
                            }
                            else
                            {
                                lResult.AddRange(lBlock.lines);
                            }
                            index = lBlock.endIndex;
                        }
                    }
                    else
                    {
                        lResult.Add(lLines[index]);
                    }
                }

                CheckErrors();

                if (mError == false)
                {
                    for (int index = 0; index < lLines.Count; ++index)
                    {
                        if (lResult[index] != lLines[index])
                        {
                            Console.WriteLine("Writing to source file: " + lPath);
                            File.WriteAllLines(lPath, lResult.ToArray());
                            ++changedFiles;
                            break;
                        }
                    }
                }
            }
        }