Пример #1
0
        void SuggestBlock()
        {
            TokenType tt;
            var       memberExp = FindMemberExpression(out tt, true);

            // Build block
            var methodCompiler = CreateFunctionCompiler(_methodNode);

            _compiler.BlockBuilder.Build();

            var dte = Parser.ParseExpression(_compiler.Log, _source, memberExp, _context.MetaPropertyNode != null ? ParseContext.MetaProperty : ParseContext.Default);

            if (dte.IsInvalid)
            {
                SuggestForBlock(methodCompiler, memberExp);
            }

            if (_context.MetaPropertyNode != null)
            {
                SuggestForMetaproperty(methodCompiler, memberExp);
            }
        }
Пример #2
0
        void SuggestForApplyBlockItems(AmbientParser.Node c)
        {
            var log = new Log(new StringWriter());
            var dte = Parser.ParseExpression(log,
                                             _source,
                                             c.Name,
                                             ParseContext.MetaProperty);

            if (log.ErrorCount != 0)
            {
                return;
            }
            var b = _context.Compiler.NameResolver.GetBlock(
                _context.TypeOrNamespace as
                ClassType,
                dte);

            if (b != null)
            {
                SuggestBlockItems(b);
            }
        }
Пример #3
0
        void SuggestForMetaproperty(FunctionCompiler methodCompiler, string memberExp)
        {
            var mpn = _context.MetaPropertyNode;

            var mp = mpn.MetaProperty;

            if (mp == null)
            {
                mp = ResolveMetaproperty(methodCompiler, mpn) ?? new MetaProperty(Source.Unknown,
                                                                                  _context.BlockBase,
                                                                                  _context.Compiler.ILFactory.Essentials.Object,
                                                                                  mpn.Name,
                                                                                  0);
            }

            var fc = new FunctionCompiler(_compiler, mp);

            // Parse the member expression
            var dte = Parser.ParseExpression(_compiler.Log, _source, memberExp, ParseContext.MetaProperty);

            if (memberExp == "")
            {
                if (!methodCompiler.Function.IsStatic)
                {
                    SuggestKeywords("this");
                }
                SuggestKeywords("debug_log",
                                "var",
                                "for",
                                "pixel",
                                "prev",
                                "foreach",
                                "case",
                                "default",
                                "break",
                                "if",
                                "while",
                                "do",
                                "switch",
                                "try",
                                "else",
                                "catch",
                                "throw",
                                "draw",
                                "return",
                                "assert");

                // Suggest static members
                foreach (string u in _context.Usings)
                {
                    TrySuggestMembers(methodCompiler,
                                      Parser.ParseExpression(_compiler.Log, _source, u, ParseContext.MetaProperty),
                                      false);
                }
            }

            if (!dte.IsInvalid)
            {
                TrySuggestMembers(fc, dte, true);
                TrySuggestMembers(methodCompiler, dte, true);
            }
            else
            {
                SuggestLocals(methodCompiler);
            }
        }