예제 #1
0
        public static void EnumAllAvailableMembers(ICompletionDataGenerator cdgen, IBlockNode ScopedBlock
                                                   , CodeLocation Caret,
                                                   ParseCacheView CodeCache,
                                                   MemberFilter VisibleMembers,
                                                   ConditionalCompilationFlags compilationEnvironment = null)
        {
            var ctxt = ResolutionContext.Create(CodeCache, compilationEnvironment);

            CodeCompletion.DoTimeoutableCompletionTask(cdgen, ctxt, () =>
            {
                ctxt.Push(ScopedBlock, Caret);
                var en = new MemberCompletionEnumeration(ctxt, cdgen)
                {
                    isVarInst = true
                };
                en.IterateThroughScopeLayers(Caret, VisibleMembers);
            });
        }
예제 #2
0
        /// <summary>
        /// Reparses the given method's fucntion body until the cursor position,
        /// searches the last occurring method call or template instantiation,
        /// counts its already typed arguments
        /// and returns a wrapper containing all the information.
        /// </summary>
        public static ArgumentsResolutionResult ResolveArgumentContext(IEditorData Editor)
        {
            IBlockNode curBlock = null;
            bool       inNonCode;
            var        sr = CodeCompletion.FindCurrentCaretContext(Editor, ref curBlock, out inNonCode);

            IExpression lastParamExpression = null;

            var paramInsightVis = new ParamInsightVisitor();

            if (sr is INode)
            {
                (sr as INode).Accept(paramInsightVis);
            }
            else if (sr is IStatement)
            {
                (sr as IStatement).Accept(paramInsightVis);
            }
            else if (sr is IExpression)
            {
                (sr as IExpression).Accept(paramInsightVis);
            }

            lastParamExpression = paramInsightVis.LastCallExpression;

            /*
             * Then handle the lastly found expression regarding the following points:
             *
             * 1) foo(			-- normal arguments only
             * 2) foo!(...)(	-- normal arguments + template args
             * 3) foo!(		-- template args only
             * 4) new myclass(  -- ctor call
             * 5) new myclass!( -- ditto
             * 6) new myclass!(...)(
             * 7) mystruct(		-- opCall call
             */

            var res = new ArgumentsResolutionResult()
            {
                ParsedExpression = lastParamExpression
            };

            var ctxt = ResolutionContext.Create(Editor, false);

            CodeCompletion.DoTimeoutableCompletionTask(null, ctxt, () =>
            {
                ctxt.Push(Editor);

                ctxt.CurrentContext.ContextDependentOptions |= ResolutionOptions.DontResolveAliases;

                if (lastParamExpression != null)
                {
                    lastParamExpression.Accept(new ParameterInsightResolution(Editor, ctxt, res, curBlock));
                }
            });

            /*
             * alias int function(int a, bool b) myDeleg;
             * alias myDeleg myDeleg2;
             *
             * myDeleg dg;
             *
             * dg( -- it's not needed to have myDeleg but the base type for what it stands for
             *
             * ISSUE:
             * myDeleg( -- not allowed though
             * myDeleg2( -- allowed neither!
             */

            return(res);
        }
예제 #3
0
        /// <summary>
        /// Reparses the given method's fucntion body until the cursor position,
        /// searches the last occurring method call or template instantiation,
        /// counts its already typed arguments
        /// and returns a wrapper containing all the information.
        /// </summary>
        public static ArgumentsResolutionResult ResolveArgumentContext(
            IEditorData Editor,
            ResolutionContext ctxt)
        {
            IBlockNode curBlock = null;
            IStatement stmt;
            bool       inNonCode;
            var        sr = CodeCompletion.FindCurrentCaretContext(Editor, ref curBlock, out stmt, out inNonCode);

            IExpression lastParamExpression = null;

            var paramInsightVis = new ParamInsightVisitor();

            if (sr is INode)
            {
                (sr as INode).Accept(paramInsightVis);
            }
            else if (sr is IStatement)
            {
                (sr as IStatement).Accept(paramInsightVis);
            }
            else if (sr is IExpression)
            {
                (sr as IExpression).Accept(paramInsightVis);
            }

            lastParamExpression = paramInsightVis.LastCallExpression;

            /*
             * Then handle the lastly found expression regarding the following points:
             *
             * 1) foo(			-- normal arguments only
             * 2) foo!(...)(	-- normal arguments + template args
             * 3) foo!(		-- template args only
             * 4) new myclass(  -- ctor call
             * 5) new myclass!( -- ditto
             * 6) new myclass!(...)(
             * 7) mystruct(		-- opCall call
             */

            var res = new ArgumentsResolutionResult()
            {
                ParsedExpression = lastParamExpression
            };

            // 1), 2)
            if (lastParamExpression is PostfixExpression_MethodCall)
            {
                res.IsMethodArguments = true;
                var call = (PostfixExpression_MethodCall)lastParamExpression;

                res.MethodIdentifier       = call.PostfixForeExpression;
                res.ResolvedTypesOrMethods = ExpressionTypeEvaluation.GetUnfilteredMethodOverloads(call.PostfixForeExpression, ctxt, call);

                if (call.Arguments != null)
                {
                    res.CurrentlyTypedArgumentIndex = call.ArgumentCount;
                }
            }
            // 3)
            else if (lastParamExpression is TemplateInstanceExpression)
            {
                HandleTemplateInstance(lastParamExpression as TemplateInstanceExpression, res, Editor, ctxt, curBlock);
            }
            else if (lastParamExpression is NewExpression)
            {
                HandleNewExpression((NewExpression)lastParamExpression, res, Editor, ctxt, curBlock);
            }

            /*
             * alias int function(int a, bool b) myDeleg;
             * alias myDeleg myDeleg2;
             *
             * myDeleg dg;
             *
             * dg( -- it's not needed to have myDeleg but the base type for what it stands for
             *
             * ISSUE:
             * myDeleg( -- not allowed though
             * myDeleg2( -- allowed neither!
             */
            if (res.ResolvedTypesOrMethods != null)
            {
                res.ResolvedTypesOrMethods = DResolver.StripAliasSymbols(res.ResolvedTypesOrMethods);
            }

            return(res);
        }