/// <summary> /// Used to re-cache latest parse tree when the tree is active in a buffer. and the file is in the cached due to being inherited by other files. /// </summary> /// <param name="filepath">This is the filename of the file, and is used as the key for cashing the parse result</param> /// <param name="newTree">The updated parsetree</param> /// <remarks>The tree will not be updated if the existing tree does not have errors</remarks> public static void ReCache(string filepath, ParseTree newTree) { if (Inherits.ContainsKey(filepath) /*&& Inherits[filepath].Tree.ParserMessages.Where(error => error.Level == ParserErrorLevel.Error).Count() > 0*/) { Inherits[filepath] = new ParseCache(DateTime.Now, newTree); } }
public VDServer() { _parseCacheList = new ParseCacheList(); _parseCache = new ParseCache(); _parseCacheList.Add(_parseCache); // MessageBox.Show("VDServer()"); }
public static void UpdateParseCacheAsync(ParseCache Cache) { if (Cache == null || Cache.ParsedDirectories == null || Cache.ParsedDirectories.Count < 1) { return; } Cache.BeginParse(); }
public void Write(ParseCache cache) { sw.WriteLine("Parser error log"); sw.WriteLine(); Write(cache.Root); if(!hadErrors) sw.WriteLine("No errors found."); sw.WriteLine(); sw.Flush(); }
public static void Write(ParseCache cache, string outputLog) { var ms = new MemoryStream(32000); var pl = new ParseLog(ms); pl.Write(cache); if (File.Exists(outputLog)) File.Delete(outputLog); File.WriteAllBytes(outputLog, ms.ToArray()); ms.Close(); }
public void Write(ParseCache cache) { sw.WriteLine("Журнал ошибок парсера"); sw.WriteLine(); Write(cache.Root); if (!hadErrors) { sw.WriteLine("Ошибок не найдено."); } sw.WriteLine(); sw.Flush(); }
public static void Write(ParseCache cache, string outputLog) { var ms = new MemoryStream(32000); var pl = new ParseLog(ms); pl.Write(cache); if (File.Exists(outputLog)) { File.Delete(outputLog); } File.WriteAllBytes(outputLog, ms.ToArray()); ms.Close(); }
internal void LoadFile(string path, ScopedNode node, ParsingContext context, IDictionary <string, string> refDepends = null) { string curExt = context.CurrentParseTree.FileName == "<Source>" ? null : Path.GetExtension(context.CurrentParseTree.FileName); string fullpath = curExt == null ? null : Utils.FindFile(string.Format("{0}.{1}", path, curExt), context.CurrentParseTree.FileName) ?? Utils.FindFile(path, context.CurrentParseTree.FileName) ?? Utils.FindFile(string.Format("{0}.uosl", path), context.CurrentParseTree.FileName) ?? Utils.FindFile(string.Format("{0}.uosl.q", path), context.CurrentParseTree.FileName); if (fullpath != null) { fullpath = (new FileInfo(fullpath)).FullName; FileInfo fi = new FileInfo(fullpath); ParseCache cache; if (!Inherits.TryGetValue(fullpath, out cache) || fi.LastWriteTime > cache.FileDate) { Inherits[fullpath] = cache = new ParseCache(fi.LastWriteTime); LanguageOption options = Utils.DetermineFileLanguage(fullpath, this.Options); ParsingContext subcontext = new ParsingContext(new Parser(options == this.Options ? this : GetGrammar(options))); using (StreamReader reader = new StreamReader(fullpath)) { Inherits[fullpath] = cache = new ParseCache(fi.LastWriteTime, subcontext.Parser.Parse(reader.ReadToEnd(), fullpath)); } } if (refDepends != null) { refDepends.Add(path, fullpath); } if (cache.Tree != null) { if (cache.Tree.HasErrors()) { foreach (ParserMessage error in cache.Tree.ParserMessages) { if (error is ExternalErrorMessage) { context.AddParserMessage(error); } else { context.AddParserMessage(new ExternalErrorMessage(fullpath, error.Level, error.Location, error.Message, error.ParserState)); } } } if (cache.Tree.Root != null && cache.Tree.Root.AstNode != null) { if (((ScopedNode)cache.Tree.Root.AstNode).ScopeVars != null) { foreach (Field field in ((ScopedNode)cache.Tree.Root.AstNode).ScopeVars) { node.AddVar(field, context); } } if (((ScopedNode)cache.Tree.Root.AstNode).TreeFuncs != null) { foreach (Method method in ((ScopedNode)cache.Tree.Root.AstNode).TreeFuncs) { AddFunc(method, context); } } if (refDepends != null && cache.Tree.Root.FirstChild.AstNode is DeclarationsNode) { foreach (var kvp in ((DeclarationsNode)cache.Tree.Root.FirstChild.AstNode).Depends) { if (refDepends.ContainsKey(kvp.Key)) { context.AddParserMessage(ParserErrorLevel.Error, node.Span, "A recursion of inheritance detected occurred when parsing {0}.", kvp.Key); } else { refDepends.Add(kvp.Key, kvp.Value); } } } } } } else { context.AddParserError("{0} Dependancy not found.", path); } }
public VDServer() { _parseCache = new ParseCache(); // MessageBox.Show("VDServer()"); }
public static void UpdateParseCacheSync(ParseCache Cache) { UpdateParseCacheAsync(Cache); Cache.WaitForParserFinish(); }
public static void UpdateParseCacheAsync(ParseCache Cache) { if (Cache == null || Cache.ParsedDirectories == null || Cache.ParsedDirectories.Count < 1) return; Cache.BeginParse(); }
/// <summary> /// Returns false if cache is already updating. /// </summary> public bool Update(ParseCacheList pcList, ParseCache subCacheToUpdate = null) { if (IsProcessing) return false; try { IsProcessing = true; var ctxt = new ResolverContextStack(pcList, new ResolverContext()) { ContextIndependentOptions = ResolutionOptions.StopAfterFirstOverloads }; queue.Clear(); // Prepare queue if (subCacheToUpdate != null) foreach (var module in subCacheToUpdate) PrepareQueue(module); else foreach (var pc in pcList) foreach (var module in pc) PrepareQueue(module); var sw = new Stopwatch(); sw.Start(); var threads = new Thread[ThreadedDirectoryParser.numThreads]; for (int i = 0; i < ThreadedDirectoryParser.numThreads; i++) { var th = threads[i] = new Thread(parseThread) { IsBackground = true, Priority = ThreadPriority.Lowest, Name = "UFCS Analysis thread #" + i }; th.Start(pcList); } for (int i = 0; i < ThreadedDirectoryParser.numThreads; i++) if (threads[i].IsAlive) threads[i].Join(10000); sw.Stop(); CachingDuration = sw.Elapsed; } finally { IsProcessing = false; } return true; }
/// <summary> /// Returns false if cache is already updating. /// </summary> public bool Update(ParseCacheList pcList, ParseCache subCacheToUpdate = null) { if (IsProcessing) { return(false); } try { IsProcessing = true; var ctxt = new ResolverContextStack(pcList, new ResolverContext()) { ContextIndependentOptions = ResolutionOptions.StopAfterFirstOverloads }; queue.Clear(); // Prepare queue if (subCacheToUpdate != null) { foreach (var module in subCacheToUpdate) { PrepareQueue(module); } } else { foreach (var pc in pcList) { foreach (var module in pc) { PrepareQueue(module); } } } var sw = new Stopwatch(); sw.Start(); var threads = new Thread[ThreadedDirectoryParser.numThreads]; for (int i = 0; i < ThreadedDirectoryParser.numThreads; i++) { var th = threads[i] = new Thread(parseThread) { IsBackground = true, Priority = ThreadPriority.Lowest, Name = "UFCS Analysis thread #" + i }; th.Start(pcList); } for (int i = 0; i < ThreadedDirectoryParser.numThreads; i++) { if (threads[i].IsAlive) { threads[i].Join(10000); } } sw.Stop(); CachingDuration = sw.Elapsed; } finally { IsProcessing = false; } return(true); }