GetNamingContext() public static method

Create naming context.
public static GetNamingContext ( NamespaceDecl ns, SourceUnit unit ) : NamingContext
ns NamespaceDecl Current namespace declaration. In case it is null, context for global code is created.
unit SourceUnit Global code used when is null.
return NamingContext
Exemplo n.º 1
0
        /// <summary>
        /// Creates type context for a method within given type, determines naming, type context.
        /// </summary>
        public static TypeRefContext /*!*/ CreateTypeRefContext(SourceNamedTypeSymbol /*!*/ containingType)
        {
            Contract.ThrowIfNull(containingType);

            var typeDecl = containingType.Syntax;

            return(new TypeRefContext(NameUtils.GetNamingContext(typeDecl), typeDecl.SourceUnit, containingType));
        }
Exemplo n.º 2
0
 /// <summary>
 /// Enqueues initializers of a class fields and constants.
 /// </summary>
 void EnqueueFieldsInitializer(SourceTypeSymbol type)
 {
     type.GetDeclaredMembers().OfType <SourceFieldSymbol>().Foreach(f =>
     {
         if (f.Initializer != null)
         {
             EnqueueExpression(
                 f.Initializer,
                 TypeRefFactory.CreateTypeRefContext(type), //the context will be lost, analysis resolves constant values only and types are temporary
                 NameUtils.GetNamingContext(type.Syntax));
         }
     });
 }
Exemplo n.º 3
0
 /// <summary>
 /// Enqueues initializers of a class fields and constants.
 /// </summary>
 void EnqueueFieldsInitializer(SourceTypeSymbol type)
 {
     type.GetDeclaredMembers().OfType <SourceFieldSymbol>().ForEach(f =>
     {
         if (f.Initializer != null)
         {
             EnqueueExpression(
                 f.Initializer,
                 f.EnsureTypeRefContext(),
                 NameUtils.GetNamingContext(type.Syntax));
         }
     });
 }