public ResolveExpr(ITargetDatabase db, CsGlobalNamespace globals, ResolveName nameResolver) { m_globals = globals; m_nameResolver = nameResolver; m_typeResolver = new ResolveType(db); m_memberResolver = new ResolveMembers(db); }
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; }
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; }
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 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(); }
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; }