Ejemplo n.º 1
0
        public CSharpFile(CSharpProject project, string fileName)
        {
            this.Project  = project;
            this.FileName = fileName;

            CSharpParser p = new CSharpParser(project.CompilerSettings);

//			using (var stream = File.OpenRead(fileName)) {
//				this.CompilationUnit = p.Parse(stream, fileName);
//			}

            // Keep the original text around; we might use it for a refactoring later
            this.OriginalText = File.ReadAllText(fileName);
            this.SyntaxTree   = p.Parse(this.OriginalText, fileName);
            this.SyntaxTree.Freeze();             // the various tests shouldn't modify the AST shared by all tests

            if (p.HasErrors)
            {
                Console.WriteLine("Error parsing " + fileName + ":");
                foreach (var error in p.ErrorsAndWarnings)
                {
                    Console.WriteLine("  " + error.Region + " " + error.Message);
                }
            }
            this.UnresolvedTypeSystemForFile = this.SyntaxTree.ToTypeSystem();
        }
Ejemplo n.º 2
0
 public CSharpFile(CSharpProject project, FileName fileName)
 {
     this.Project = project;
     this.FileName = fileName;
     this.OriginalText = File.ReadAllText(fileName);
     CSharpParser p = new CSharpParser(project.CompilerSettings);
     this.SyntaxTree = p.Parse(this.OriginalText, fileName);
     this.UnresolvedTypeSystemForFile = SD.ParserService.GetExistingUnresolvedFile(fileName, null, project.IProject) as CSharpUnresolvedFile;
     if (this.UnresolvedTypeSystemForFile == null)
         throw new InvalidOperationException("LoadSolutionProjectsThread not yet finished?");
 }
Ejemplo n.º 3
0
        public CSharpFile(CSharpProject project, FileName fileName)
        {
            this.Project      = project;
            this.FileName     = fileName;
            this.OriginalText = File.ReadAllText(fileName);
            CSharpParser p = new CSharpParser(project.CompilerSettings);

            this.SyntaxTree = p.Parse(this.OriginalText, fileName);
            this.UnresolvedTypeSystemForFile = SD.ParserService.GetExistingUnresolvedFile(fileName, null, project.IProject) as CSharpUnresolvedFile;
            if (this.UnresolvedTypeSystemForFile == null)
            {
                throw new InvalidOperationException("LoadSolutionProjectsThread not yet finished?");
            }
        }
Ejemplo n.º 4
0
        public CSharpFile(CSharpProject project, string fileName)
        {
            this.Project     = project;
            this.FileName    = fileName;
            this.Content     = new StringTextSource(File.ReadAllText(FileName));
            this.LinesOfCode = 1 + this.Content.Text.Count(c => c == '\n');

            CSharpParser p = project.CreateParser();

            this.CompilationUnit = p.Parse(Content.CreateReader(), fileName);
            if (p.HasErrors)
            {
                Console.WriteLine("Error parsing " + fileName + ":");
                foreach (var error in p.ErrorPrinter.Errors)
                {
                    Console.WriteLine("  " + error.Region + " " + error.Message);
                }
            }
            this.ParsedFile = this.CompilationUnit.ToTypeSystem();
        }
Ejemplo n.º 5
0
		public CSharpFile(CSharpProject project, string fileName)
		{
			this.Project = project;
			this.FileName = fileName;
			
			CSharpParser p = new CSharpParser(project.CompilerSettings);
//			using (var stream = File.OpenRead(fileName)) {
//				this.CompilationUnit = p.Parse(stream, fileName);
//			}
			
			// Keep the original text around; we might use it for a refactoring later
			this.OriginalText = File.ReadAllText(fileName);
			this.SyntaxTree = p.Parse(this.OriginalText, fileName);
			
			if (p.HasErrors) {
				Console.WriteLine("Error parsing " + fileName + ":");
				foreach (var error in p.ErrorsAndWarnings) {
					Console.WriteLine("  " + error.Region + " " + error.Message);
				}
			}
			this.UnresolvedTypeSystemForFile = this.SyntaxTree.ToTypeSystem();
		}
Ejemplo n.º 6
0
		public CSharpFile(CSharpProject project, string fileName)
		{
			this.Project = project;
			this.FileName = fileName;
			this.Content = new StringTextSource(File.ReadAllText(FileName));
			this.LinesOfCode = 1 + this.Content.Text.Count(c => c == '\n');
			
			CSharpParser p = new CSharpParser(project.CompilerSettings);
			this.CompilationUnit = p.Parse(Content.CreateReader(), fileName);
			if (p.HasErrors) {
				Console.WriteLine("Error parsing " + fileName + ":");
				foreach (var error in p.ErrorsAndWarnings) {
					Console.WriteLine("  " + error.Region + " " + error.Message);
				}
			}
			this.ParsedFile = this.CompilationUnit.ToTypeSystem();
		}