public static ProjectFileModel FromDtoToModel(ProjectFileDto dto)
 {
     var model = new ProjectFileModel();
     CopyIProjectItemModelMembers(model, dto);
     model.Content = dto.Content;
     return model;
 }
 public static ProjectFileDto FromModelToDto(ProjectFileModel model)
 {
     var dto = new ProjectFileDto();
     CopyIProjectItemModelMembers(dto, model);
     dto.Content = model.Content;
     return dto;
 }
Exemple #3
0
        public static ProjectFileModel FromDtoToModel(ProjectFileDto dto)
        {
            var model = new ProjectFileModel();

            CopyIProjectItemModelMembers(model, dto);
            model.Content = dto.Content;
            return(model);
        }
Exemple #4
0
        public static ProjectFileDto FromModelToDto(ProjectFileModel model)
        {
            var dto = new ProjectFileDto();

            CopyIProjectItemModelMembers(dto, model);
            dto.Content = model.Content;
            return(dto);
        }
        public static FileParseResult[] ParseFile(ProjectFileModel fileModel)
        {
            var parser = new CSharpParser();
            SyntaxTree syntaxTree = parser.Parse(fileModel.Content, fileModel.Name);

            var results = parser.ErrorsAndWarnings
                .Select(x => new FileParseResult()
                {
                    FileId = fileModel.Id,
                    FileName = fileModel.Name,
                    Line = x.Region.BeginLine,
                    Column = x.Region.BeginColumn,
                    Type = x.ErrorType,
                    Message = x.Message
                }).ToArray();

            return results;
        }
        public static void IntegrateFileModel(ProjectModel projectModel, ProjectFileModel fileModel)
        {
            // Parse C# code file => SyntaxTree
            // NOTE:  The NRefactory Test project uses a somewhat "cleaner"/more "sanitized" version of the 
            // file content for creating the AST.  Why?  I can't be certain, but I suspect that this is to 
            // simplify testing by eliminating stuff that contribute to errors... but maybe there's something 
            // more to it.  Doing some more routine tests on our end should prove whether omitting this step 
            // actually makes any difference.
            fileModel.Parser = new CSharpParser();
            fileModel.SyntaxTree = fileModel.Parser.Parse(fileModel.Content, fileModel.Name);
            fileModel.SyntaxTree.Freeze();
            
            // Convert syntax tree into parsed file that can be stored in the type system.
            fileModel.UnresolvedFile = fileModel.SyntaxTree.ToTypeSystem();

            // Add specified file to the project content.  
            // If a file with the same name already exists, this will update the existing file.
            projectModel.ProjectContent = projectModel.ProjectContent.AddOrUpdateFiles(fileModel.UnresolvedFile);
        }