Пример #1
0
 public void Close()
 {
     if (m_controller != null)
     {
         m_controller.window().release();
         m_controller.release();
         m_controller = null;
     }
 }
Пример #2
0
        private bool DoCompleteNamespaceDot(NSTextView view, string stem)
        {
            stem = stem.Substring(stem.IndexOf(' ') + 1);
            Log.WriteLine(TraceLevel.Verbose, "AutoComplete", "DoCompleteNamespaceDot is checking for namespaces using {0}", stem);
            Item[] namespaces = DoGetNamespacesNamed(stem);

            if (namespaces.Length > 0)
            {
                if (m_controller == null)
                    m_controller = new CompletionsController();

                string label = stem + " Namespaces";
                m_controller.Show(m_boss.Get<ITextEditor>(), view, label, namespaces, null, false, false);
            }

            return namespaces.Length > 0;
        }
Пример #3
0
        private bool DoCompleteStem(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)
            {
                string stem = DoGetTargetStem(range, -2);
                if (stem.Length > 0)
                {
                    string label = string.Empty;
                    var items = new List<Item>();
                    bool isInstance = false, isStatic = false;

                    if (stem.StartsWith("new "))
                    {
                        stem = stem.Substring(stem.IndexOf(' ') + 1);
                        string oldStem = stem;

                        Log.WriteLine(TraceLevel.Verbose, "AutoComplete", "DoCompleteStem is getting ctors");
                        label = "Constructors";
                        items.AddRange(DoGetConstructorsNamed(globals, ref stem));

                        if (oldStem == stem)
                        {
                            items.AddRange(DoGetAliasedConstructorsNamed(globals, stem));
                        }
                    }
                    else
                    {
                        Log.WriteLine(TraceLevel.Verbose, "AutoComplete", "DoCompleteStem is getting names");
                        label = "Names";
                        items.AddRange(DoGetNames(globals, range.location - 1, stem, ref isInstance, ref isStatic));
                    }

                    if (items.Count > 0)
                    {
                        if (m_controller == null)
                            m_controller = new CompletionsController();

                        m_controller.Show(m_boss.Get<ITextEditor>(), view, label, items.ToArray(), stem, isInstance, isStatic);
                    }

                    handled = true;			// if it was recognized as a double tab then we never want to add the second tab
                }
            }

            return handled;
        }
Пример #4
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;
        }