예제 #1
0
        void execTh(object p)
        {
            CanAbort = true;
            try
            {
                var tup  = p as Tuple <ISyntaxRegion, ResolutionContext>;
                var sr   = tup.Item1;
                var ctxt = tup.Item2;

                object        result = null;
                VariableValue vv;

                if (sr is MixinStatement)
                {
                    result = MixinAnalysis.ParseMixinDeclaration(sr as MixinStatement, ctxt, out vv);
                }
                else if (sr is TemplateMixin)
                {
                    result = D_Parser.Resolver.ASTScanner.AbstractVisitor.GetTemplateMixinContent(ctxt, sr as TemplateMixin);
                }

                var o = ExpressionEvaluationPad.BuildObjectString(result);
                DispatchService.GuiDispatch(() => outputEditor.Text = o);
            }
            finally
            {
                CanAbort = false;
            }
        }
예제 #2
0
        /// <summary>
        /// Evaluates the literal given as expression and tries to parse it as a string.
        /// Important: Assumes all its compilation conditions to be checked already!
        /// </summary>
        bool HandleMixin(MixinStatement mx, bool parseDeclDefs, MemberFilter vis)
        {
            if (CompletionOptions.Instance.DisableMixinAnalysis)
            {
                return(false);
            }

            // If in a class/module block => MixinDeclaration
            if (parseDeclDefs)
            {
                var ast = MixinAnalysis.ParseMixinDeclaration(mx, ctxt);

                if (ast == null)
                {
                    return(false);
                }

                // take ast.Endlocation because the cursor must be beyond the actual mixin expression
                // - and therewith _after_ each declaration
                if (ctxt.ScopedBlock == mx.ParentNode.NodeRoot)
                {
                    return(ScanBlockUpward(ast, ast.EndLocation, vis));
                }
                else
                {
                    return(scanChildren(ast, vis, isMixinAst: true));
                }
            }
            else             // => MixinStatement
            {
                var bs = MixinAnalysis.ParseMixinStatement(mx, ctxt);

                // As above, disregard the caret position because 1) caret and parsed code do not match
                // and 2) the caret must be located somewhere after the mixin statement's end
                if (bs != null)
                {
                    return(ScanStatementHierarchy(bs, CodeLocation.Empty, vis));
                }
            }

            return(false);
        }