private bool DoGetTheTarget(string text, int offset, MockTargetDatabase database)
        {
            var parser = new CsParser.Parser();
            CsGlobalNamespace globals = parser.Parse(text);

            var locals = new CsParser.LocalsParser();
            CsMember context = AutoComplete.FindDeclaration(globals, offset) as CsMember;
            var nameResolver = new ResolveName(context, database, locals, text, offset, globals);
            var resolver = new ResolveExpr(database, globals, nameResolver);

            m_target = resolver.Resolve(context, text, offset);
            return m_target != null;
        }
Beispiel #2
0
        private bool DoCompleteMethodDot(ITextEditor editor, NSTextView view, NSRange range)
        {
            bool handled = false;

            Parse parse = m_parses.TryParse(editor.Key);
            CsGlobalNamespace globals = parse != null ? parse.Globals : null;
            if (globals != null)
            {
                var context = FindDeclaration(globals, range.location) as CsMember;

                Boss boss = ObjectModel.Create("CsParser");
                var locals = boss.Get<ICsLocalsParser>();
                var nameResolver = new ResolveName(context, m_database, locals, m_text.Text, range.location, globals);
                var exprResolver = new ResolveExpr(m_database, globals, nameResolver);

                Item[] items = null;
                string type = null;
                bool isInstance = false;
                bool isStatic = false;

                Log.WriteLine(TraceLevel.Verbose, "AutoComplete", "DoCompleteMethodDot is resolving an expression");
                ResolvedTarget target = exprResolver.Resolve(context, m_text.Text, range.location);
                if (target != null)
                {
                    type = target.TypeName;
                    items = m_members.Resolve(context, target, globals);
                    isInstance = target.IsInstance;
                    isStatic = target.IsStatic;
                }

                if (type != "System.Void")
                {
                    if (items != null && items.Length > 0)
                    {
                        if (m_controller == null)
                            m_controller = new CompletionsController();

                        string label = type;
                        if (isInstance && !isStatic)
                            label += " Members";
                        else if (isInstance)
                            label += " Instance Members";
                        else if (isStatic)
                            label += " Static Members";

                        m_controller.Show(m_boss.Get<ITextEditor>(), view, label, items, null, isInstance, isStatic);
                        handled = true;
                    }
                }
                else
                    Functions.NSBeep();
            }

            return handled;
        }