コード例 #1
0
        public override object VisitTerminal(ITerminalNode node)
        {
            if (_withLogging)
            {
                _tabs = _tabs + "\t";
                PLogger.Info($"{_tabs}{PascalTokenTypes.Convert(node.Symbol.Type)}");
                _tabs = _tabs.Substring(0, _tabs.Length - 1);
            }

            //Restore whitespaces that ANTLR does not produce
            if (node.Symbol.TokenIndex != -1)
            {
                var toLoop = node.Symbol.TokenIndex - (_prev?.Symbol.TokenIndex ?? -1) - 1;
                while (toLoop > 0)
                {
                    if (!_psiBuilder.Eof())
                    {
                        _psiBuilder.AdvanceLexer();
                    }
                    toLoop--;
                }
            }

            if (!_psiBuilder.Eof())
            {
                _psiBuilder.AdvanceLexer();
            }

            _prev = node;

            return(null);
        }
コード例 #2
0
        public override ISpecificCodeCompletionContext GetCompletionContext(CodeCompletionContext context)
        {
            PLogger.Info("Someone asking PascalCompletionContextProvider for Context");
            var file = context.File as PascalFile;

            if (file == null)
            {
                return(null);
            }

            var reparsedContext = new PascalReparsedCompletionContext(file, context.SelectedTreeRange, "aaa");

            reparsedContext.Init();
            return(GetSpecificContext(context, reparsedContext));
        }
コード例 #3
0
        protected void VisitType(RuleContext context, PascalAntlrNodeType type)
        {
            if (_withLogging)
            {
                _tabs = _tabs + "\t";
                PLogger.Info($"{_tabs}{type}");
            }

            var mark = _psiBuilder.Mark();

            base.VisitChildren(context);
            _psiBuilder.Done(mark, type, context);

            if (_withLogging)
            {
                PLogger.Info($"{_tabs}{type}");
                _tabs = _tabs.Substring(0, _tabs.Length - 1);
            }
        }
コード例 #4
0
 public override bool IsApplicable(CodeCompletionContext context)
 {
     PLogger.Info($"Someone asking if PascalCompletionContextProvider is Applicable, answer {context.File is PascalFile}");
     return(context.File is PascalFile);
 }