Esempio n. 1
0
        /// <summary>
        /// To be executed before the visit starts
        /// </summary>
        public void PreVisit(Parse.Parser parser)
        {
            _parser = parser;

            // if this document is in the Saved parsed visitors, we remove it now and we will add it back when it is parsed
            if (_isBaseFile)
            {
                if (SavedPersistent.ContainsKey(_parser.FilePathBeingParsed))
                {
                    SavedPersistent.Remove(_parser.FilePathBeingParsed);
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// To be executed after the visit ends
        /// </summary>
        public void PostVisit()
        {
            // save the info for uses in an another file, where this file is run in persistent
            if (!SavedPersistent.ContainsKey(_parser.FilePathBeingParsed))
            {
                SavedPersistent.Add(_parser.FilePathBeingParsed, this);
            }
            else
            {
                SavedPersistent[_parser.FilePathBeingParsed] = this;
            }

            // lose parser reference
            _parser = null;
        }
Esempio n. 3
0
        /// <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);
        }