Exemplo n.º 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);
            });
        }
Exemplo n.º 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);
        }