示例#1
0
        public static TerminalNodeImpl Find(int index, Document document)
        {
            ParsingResults pd        = ParsingResultsFactory.Create(document);
            var            workspace = document.Workspace;

            if (pd.ParseTree == null)
            {
                new Module().Compile(workspace);
            }

            foreach (IParseTree node in DFSVisitor.DFS(pd.ParseTree as ParserRuleContext))
            {
                if (node as TerminalNodeImpl == null)
                {
                    continue;
                }

                TerminalNodeImpl leaf = node as TerminalNodeImpl;
                if (leaf.Symbol.StartIndex <= index && index <= leaf.Symbol.StopIndex)
                {
                    return(leaf);
                }
            }
            return(null);
        }
示例#2
0
        public virtual void Parse()
        {
            Workspaces.Document item = Item;
            string code        = item.Code;
            string ffn         = item.FullPath;
            bool   has_changed = item.Changed;

            item.Changed = false;
            if (!has_changed)
            {
                return;
            }

            IGrammarDescription gd = GrammarDescriptionFactory.Create(ffn);

            if (gd == null)
            {
                throw new Exception();
            }

            gd.Parse(this);

            AllNodes   = DFSVisitor.DFS(ParseTree as ParserRuleContext);
            Comments   = gd.ExtractComments(code);
            Defs       = new Dictionary <TerminalNodeImpl, int>();
            Refs       = new Dictionary <TerminalNodeImpl, int>();
            Tags       = new Dictionary <TerminalNodeImpl, int>();
            Errors     = new HashSet <IParseTree>();
            Imports    = new HashSet <string>();
            Attributes = new Dictionary <IParseTree, IList <CombinedScopeSymbol> >();
            Cleanup();
        }
示例#3
0
        public virtual void Parse()
        {
            Workspaces.Document document = Item;
            string code        = document.Code;
            string ffn         = document.FullPath;
            bool   has_changed = document.Changed;

            document.Changed = false;
            if (!has_changed)
            {
                return;
            }

            var gd = ParserDescriptionFactory.Create(document);

            if (gd == null)
            {
                throw new Exception();
            }

            bool bail = QuietAfter == 0;

            gd.Parse(this, bail);

            AllNodes      = DFSVisitor.DFS(ParseTree as ParserRuleContext);
            Comments      = gd.ExtractComments(code);
            Defs          = new Dictionary <TerminalNodeImpl, int>();
            Refs          = new Dictionary <TerminalNodeImpl, int>();
            PopupList     = new Dictionary <TerminalNodeImpl, int>();
            Errors        = new HashSet <IParseTree>();
            Imports       = new HashSet <string>();
            Attributes    = new Dictionary <IParseTree, IList <CombinedScopeSymbol> >();
            ColorizedList = new Dictionary <Antlr4.Runtime.IToken, int>();
            Cleanup();
        }
示例#4
0
        public static IParseTree Find(int index, Document document)
        {
            var pd = ParserDetailsFactory.Create(document);

            if (pd.ParseTree == null)
            {
                return(null);
            }
            foreach (var node in DFSVisitor.DFS(pd.ParseTree as ParserRuleContext))
            {
                if (node as TerminalNodeImpl == null)
                {
                    continue;
                }
                var leaf = node as TerminalNodeImpl;
                if (leaf.Symbol.StartIndex <= index && index <= leaf.Symbol.StopIndex)
                {
                    return(leaf);
                }
            }
            return(null);
        }
示例#5
0
        public static IParseTree Find(int index, Document document)
        {
            ParserDetails pd = ParserDetailsFactory.Create(document);

            if (pd.ParseTree == null)
            {
                LanguageServer.Module.Compile();
            }

            foreach (IParseTree node in DFSVisitor.DFS(pd.ParseTree as ParserRuleContext))
            {
                if (node as TerminalNodeImpl == null)
                {
                    continue;
                }

                TerminalNodeImpl leaf = node as TerminalNodeImpl;
                if (leaf.Symbol.StartIndex <= index && index <= leaf.Symbol.StopIndex)
                {
                    return(leaf);
                }
            }
            return(null);
        }