private bool DoGetTarget(string text, string name, int offset, MockTargetDatabase database)
        {
            //Console.WriteLine("------------------------------------");
            //Console.WriteLine(name);
            //Console.WriteLine(text);

            var parser = new CsParser.Parser();
            CsGlobalNamespace globals = parser.Parse(text);

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

            m_target = resolver.Resolve(name);
            return m_target != null;
        }
        private bool DoGetTarget(string text, string target, int offset, MockTargetDatabase database)
        {
            Log.WriteLine("AutoComplete", "{0} {1} {2}", new string('*', 10), new StackTrace().GetFrame(1).GetMethod().Name, new string('*', 10));

            var parser = new CsParser.Parser();
            CsGlobalNamespace globals = parser.Parse(text);

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

            m_target = resolver.Resolve(target);
            return m_target != null;
        }
Exemple #3
0
        private Item[] DoGetNames(CsGlobalNamespace globals, int location, string stem, ref bool isInstance, ref bool isStatic)
        {
            Profile.Start("AutoComplete::DoGetNames");
            var result = new List<Item>();

            var context = FindDeclaration(globals, location) as CsMember;
            var nameResolver = new ResolveName(context, m_database, m_locals, m_text.Text, location, globals);
            ResolvedTarget target = nameResolver.Resolve("<this>");
            if (target != null)
            {
                var items = new List<Item>(m_members.Resolve(context, target, globals));
                foreach (Variable v in nameResolver.Variables)
                {
                    items.AddIfMissing(new NameItem(v.Name, v.Type + ' ' + v.Name, v.Filter, v.Type));
                }

                if (stem.Length > 0)
                    items.RemoveAll(m => !m.Text.StartsWith(stem));

                result = items;
                isInstance = target.IsInstance;
                isStatic = target.IsStatic;
            }

            if (stem.Length > 0)
            {
                DoAddAliasedTypes(result, stem);
                DoAddRealTypes(result, globals, stem);
            }

            Profile.Stop("AutoComplete::DoGetNames");
            return result.ToArray();
        }