private static void AddAliasSymbolToResult(LookupSymbolsInfo result, AliasSymbol aliasSymbol, LookupConstraints constraints) { var targetSymbol = aliasSymbol.GetAliasTarget(basesBeingResolved: null); if (constraints.OriginalBinder.CanAddLookupSymbolInfo(targetSymbol, result, constraints.WithAccessThroughType(null), aliasSymbol: aliasSymbol)) { result.AddSymbol(aliasSymbol, aliasSymbol.Name, aliasSymbol.Name); } }
// Note: we do not mark nodes when looking up arities or names. This is because these two // types of lookup are only around to make the public // SemanticModel.LookupNames/LookupSymbols work and do not count as usages of the directives // when the actual code is bound. internal void AddLookupSymbolsInfo(LookupSymbolsInfo result, LookupConstraints constraints) { AddLookupSymbolsInfoInAliases(result, constraints); // Add types within namespaces imported through usings, but don't add nested namespaces. LookupOptions usingOptions = (constraints.Options & ~(LookupOptions.NamespaceAliasesOnly | LookupOptions.NamespacesOrTypesOnly)) | LookupOptions.MustNotBeNamespace; AddLookupSymbolsInfoInUsings(this.Usings, result, constraints.WithOptions(usingOptions)); }
internal void AddLookupSymbolsInfoInAliases(LookupSymbolsInfo result, LookupConstraints constraints) { foreach (var(_, usingAlias) in this.UsingAliases) { AddAliasSymbolToResult(result, usingAlias.Alias, constraints); } foreach (var externAlias in this.ExternAliases) { AddAliasSymbolToResult(result, externAlias.Alias, constraints); } }
private static void AddLookupSymbolsInfoInUsings( ImmutableArray <NamespaceOrTypeAndUsingDirective> usings, LookupSymbolsInfo result, LookupConstraints constraints) { if (constraints.OriginalBinder.Flags.Includes(BinderFlags.InScriptUsing)) { return; } Debug.Assert(!constraints.Options.CanConsiderNamespaces()); // look in all using namespaces foreach (var namespaceSymbol in usings) { foreach (var member in namespaceSymbol.NamespaceOrType.GetMembersUnordered()) { if (IsValidLookupCandidateInUsings(member) && constraints.OriginalBinder.CanAddLookupSymbolInfo(member, result, constraints, null)) { result.AddSymbol(member, member.Name, member.MetadataName); } } } }