Inheritance: AbstractFreezable
コード例 #1
0
		/// <summary>
		/// Creates a new TypeSystemConvertVisitor.
		/// </summary>
		/// <param name="fileName">The file name (used for DomRegions).</param>
		public TypeSystemConvertVisitor(string fileName)
		{
			if (fileName == null)
				throw new ArgumentNullException("fileName");
			this.parsedFile = new CSharpParsedFile(fileName);
			this.usingScope = parsedFile.RootUsingScope;
		}
コード例 #2
0
 public ResolvedUsingScope(CSharpTypeResolveContext context, UsingScope usingScope)
 {
     if (context == null)
     {
         throw new ArgumentNullException("context");
     }
     if (usingScope == null)
     {
         throw new ArgumentNullException("usingScope");
     }
     this.parentContext = context;
     this.usingScope    = usingScope;
     if (usingScope.Parent != null)
     {
         if (context.CurrentUsingScope == null)
         {
             throw new InvalidOperationException();
         }
     }
     else
     {
         if (context.CurrentUsingScope != null)
         {
             throw new InvalidOperationException();
         }
     }
 }
コード例 #3
0
ファイル: FileCodeModel2.cs プロジェクト: Paccc/SharpDevelop
		public static void AddUsings(CodeElementsList<CodeElement> codeElements, UsingScope usingScope, ICompilation compilation)
		{
			var resolvedUsingScope = usingScope.Resolve(compilation);
			foreach (var ns in resolvedUsingScope.Usings) {
				codeElements.Add(new CodeImport(ns.FullName));
			}
		}
コード例 #4
0
		/// <summary>
		/// Creates a new TypeSystemConvertVisitor and initializes it with a given context.
		/// </summary>
		/// <param name="parsedFile">The parsed file to which members should be added.</param>
		/// <param name="currentUsingScope">The current using scope.</param>
		/// <param name="currentTypeDefinition">The current type definition.</param>
		public TypeSystemConvertVisitor(CSharpParsedFile parsedFile, UsingScope currentUsingScope = null, CSharpUnresolvedTypeDefinition currentTypeDefinition = null)
		{
			if (parsedFile == null)
				throw new ArgumentNullException("parsedFile");
			this.parsedFile = parsedFile;
			this.usingScope = currentUsingScope ?? parsedFile.RootUsingScope;
			this.currentTypeDefinition = currentTypeDefinition;
		}
コード例 #5
0
 public CSharpUnresolvedFile(string fileName)
 {
     if (fileName == null)
     {
         throw new ArgumentNullException("fileName");
     }
     this.fileName       = fileName;
     this.rootUsingScope = new UsingScope();
 }
コード例 #6
0
ファイル: UsingScope.cs プロジェクト: 0xd4d/NRefactory
		/// <summary>
		/// Creates a new nested using scope.
		/// </summary>
		/// <param name="parent">The parent using scope.</param>
		/// <param name="shortName">The short namespace name.</param>
		public UsingScope(UsingScope parent, string shortName)
		{
			if (parent == null)
				throw new ArgumentNullException("parent");
			if (shortName == null)
				throw new ArgumentNullException("shortName");
			this.parent = parent;
			this.shortName = shortName;
		}
コード例 #7
0
        public void AddUsings(UsingScope usingScope, ICompilation compilation)
        {
            foreach (KeyValuePair<string, TypeOrNamespaceReference> alias in usingScope.UsingAliases) {
                AddCodeImport(alias.Value.ToString());
            }

            foreach (TypeOrNamespaceReference typeOrNamespace in usingScope.Usings) {
                AddCodeImport(typeOrNamespace.ToString());
            }
        }
コード例 #8
0
 public CSharpParsedFile(string fileName, UsingScope rootUsingScope)
 {
     if (fileName == null)
     {
         throw new ArgumentNullException("fileName");
     }
     if (rootUsingScope == null)
     {
         throw new ArgumentNullException("rootUsingScope");
     }
     this.fileName       = fileName;
     this.rootUsingScope = rootUsingScope;
 }
コード例 #9
0
ファイル: UsingScope.cs プロジェクト: yehia2amer/Alter-Native
 /// <summary>
 /// Creates a new nested using scope.
 /// </summary>
 /// <param name="parent">The parent using scope.</param>
 /// <param name="shortName">The short namespace name.</param>
 public UsingScope(UsingScope parent, string shortName)
 {
     if (parent == null)
     {
         throw new ArgumentNullException("parent");
     }
     if (shortName == null)
     {
         throw new ArgumentNullException("shortName");
     }
     this.parent    = parent;
     this.shortName = shortName;
 }
コード例 #10
0
		public override IUnresolvedEntity VisitNamespaceDeclaration(NamespaceDeclaration namespaceDeclaration, object data)
		{
			DomRegion region = MakeRegion(namespaceDeclaration);
			UsingScope previousUsingScope = usingScope;
			foreach (Identifier ident in namespaceDeclaration.Identifiers) {
				usingScope = new UsingScope(usingScope, ident.Name);
				usingScope.Region = region;
			}
			base.VisitNamespaceDeclaration(namespaceDeclaration, data);
			parsedFile.UsingScopes.Add(usingScope); // add after visiting children so that nested scopes come first
			usingScope = previousUsingScope;
			return null;
		}
コード例 #11
0
 public CSharpUnresolvedTypeDefinition(CSharpUnresolvedTypeDefinition declaringTypeDefinition, string name)
     : base(declaringTypeDefinition, name)
 {
     this.usingScope = declaringTypeDefinition.usingScope;
     this.AddDefaultConstructorIfRequired = true;
 }
コード例 #12
0
 public CSharpUnresolvedTypeDefinition(UsingScope usingScope, string name)
     : base(usingScope.NamespaceName, name)
 {
     this.usingScope = usingScope;
     this.AddDefaultConstructorIfRequired = true;
 }
コード例 #13
0
		internal static IConstantValue ConvertConstantValue(
			ITypeReference targetType, AstNode expression,
			IUnresolvedTypeDefinition parentTypeDefinition, IUnresolvedMethod parentMethodDefinition, UsingScope parentUsingScope)
		{
			ConstantValueBuilder b = new ConstantValueBuilder(false);
			ConstantExpression c = expression.AcceptVisitor(b, null);
			if (c == null)
				return new ErrorConstantValue(targetType);
			PrimitiveConstantExpression pc = c as PrimitiveConstantExpression;
			if (pc != null && pc.Type == targetType) {
				// Save memory by directly using a SimpleConstantValue.
				return new SimpleConstantValue(targetType, pc.Value);
			}
			// cast to the desired type
			return new ConstantCast(targetType, c);
		}
コード例 #14
0
		public CSharpUnresolvedTypeDefinition(CSharpUnresolvedTypeDefinition declaringTypeDefinition, string name)
			: base(declaringTypeDefinition, name)
		{
			this.usingScope = declaringTypeDefinition.usingScope;
			this.AddDefaultConstructorIfRequired = true;
		}
コード例 #15
0
		public CSharpUnresolvedTypeDefinition(UsingScope usingScope, string name)
			: base(usingScope.NamespaceName, name)
		{
			this.usingScope = usingScope;
			this.AddDefaultConstructorIfRequired = true;
		}