/// <summary> /// Parses a file. /// Remarks : it doesn't parse the document against known words since this is only useful for /// the CURRENT document and not for the others /// </summary> private static ParserVisitor ParseFile(string filePath, ParsedScopeBlock scopeItem) { ParserVisitor parserVisitor; // did we already parsed this file in a previous parse session? (if we are in CodeExplorerDisplayExternalItems mode we need to parse it again anyway) if (SavedPersistent.ContainsKey(filePath)) { parserVisitor = SavedPersistent[filePath]; } else { // Parse it var ablParser = new Parse.Parser(Utils.ReadAllText(filePath), filePath, scopeItem, false); parserVisitor = new ParserVisitor(false); ablParser.Accept(parserVisitor); } return(parserVisitor); }
/// <summary> /// Parses given file and load its function + procedures has persistent so they are /// accessible from the autocompletion list /// Set runPersistentIsInFile = false (default) to add items only to the completion list, /// set to true to also display proc/func in the code explorer tree if asked /// </summary> private void LoadProcPersistent(string fileName, ParsedScopeBlock scopeItem) { ParserVisitor parserVisitor = ParseFile(fileName, scopeItem); // add info to the completion list var listToAdd = parserVisitor.ParsedCompletionItemsList.Where(data => data is FunctionCompletionItem || data is ProcedureCompletionItem).ToList(); foreach (var completionData in listToAdd) { completionData.Flags = completionData.Flags | ParseFlag.Persistent; } _parsedCompletionItemsList.AddRange(listToAdd); // add info to the code explorer if (Config.Instance.CodeExplorerDisplayPersistentItems) { foreach (var codeExplorerItem in parserVisitor.ParsedExplorerItemsList.SelectMany(item => item.Children ?? new List <FilteredTypeTreeListItem>()).Cast <CodeItem>().Where(item => item is FunctionCodeItem || item is ProcedureCodeItem)) { codeExplorerItem.Flags = codeExplorerItem.Flags | ParseFlag.Persistent; PushToCodeExplorer(codeExplorerItem is FunctionCodeItem ? GetExplorerListNode("Functions", CodeExplorerIconType.Function) : GetExplorerListNode("Procedures", CodeExplorerIconType.Procedure), codeExplorerItem); } } }