Exemplo n.º 1
0
        public TestVm(string testPath, int id, ITestTreeNode parent)
            : base(parent, testPath)
        {
            _testFolder = parent as TestFolderVm;
            TestPath    = testPath;
            TestSuite   = _testFolder == null ? (TestSuiteVm)parent : _testFolder.TestSuite;

            if (_testFolder != null)
            {
                Statistics     = null;
                FileStatistics = new FileStatistics(
                    _testFolder.ParsingStatistics.ReplaceSingleSubtask(Name),
                    _testFolder.ParseTreeStatistics.ReplaceSingleSubtask(Name),
                    _testFolder.AstStatistics.ReplaceSingleSubtask(Name),
                    _testFolder.DependPropsStatistics);
                _file = new TestFile(this, TestSuite.Language, id, _testFolder.Project, FileStatistics);
            }
            else
            {
                Statistics     = new StatisticsTask.Container("Total");
                FileStatistics = new FileStatistics(
                    Statistics.ReplaceSingleSubtask("Parsing"),
                    Statistics.ReplaceSingleSubtask("ParseTree"),
                    Statistics.ReplaceSingleSubtask("Ast", "AST Creation"),
                    Statistics.ReplaceContainerSubtask("DependProps", "Dependent properties"));
                var solution = new FsSolution <IAst>();
                var project  = new FsProject <IAst>(solution, Path.GetDirectoryName(testPath), TestSuite.Libs);
                _file = new TestFile(this, TestSuite.Language, id, project, FileStatistics);
            }

            if (TestSuite.TestState == TestState.Ignored)
            {
                TestState = TestState.Ignored;
            }
        }
Exemplo n.º 2
0
        public CompilationResult Compile(CompilationRequest request)
        {
            if (request.NeedTypeReloading || _typeCache == null)
            {
                _typeCache = _platform.ProvideTypes();
            }

            var files = request.Sources.OfType <FileSource>()
                        .Select((fs, index) => new InputFile(index, fs.Path, AmmyLanguage.Instance))
                        .ToArray();

            if (files.Length > 0)
            {
                var cts        = new CancellationTokenSource();
                var references = request.ReferenceAssemblyPaths.Select(path => new FileLibReference(path));
                var project    = new FsProject <Start>(new FsSolution <Start>(), request.ProjectDir, files, references)
                {
                    Data = request.Data
                };

                var projectSupport = files.Select(f => f.Ast)
                                     .OfType <IProjectSupport>()
                                     .FirstOrDefault();

                if (projectSupport == null)
                {
                    throw new Exception("IProjectSupport not found");
                }

                if (!(projectSupport is Start))
                {
                    throw new Exception("IProjectSupport should have AST type Start");
                }

                var start = (Start)projectSupport;

                start.Platform = _platform;

                var data = projectSupport.RefreshReferences(cts.Token, project);

                var fileEvals = files.Select(fs => fs.GetEvalPropertiesData())
                                .ToImmutableArray();

                projectSupport.RefreshProject(cts.Token, fileEvals, request.Data ?? data);

                var compilerMessages = fileEvals.SelectMany(f => f.GetCompilerMessage())
                                       .Select(ToBackendCompilerMessage)
                                       .ToArray();

                var hasError    = compilerMessages.FirstOrDefault(msg => msg.Type == CompilerMessageType.Error) != null;
                var outputFiles = files.SelectMany(ToOutputFile).ToArray();

                return(new CompilationResult("", !hasError, compilerMessages, outputFiles));
            }

            return(new CompilationResult("", true, new CompilerMessage[0], new OutputFile[0]));
        }
Exemplo n.º 3
0
 public TestFile([NotNull] TestVm test, Language language, FsProject <IAst> project, FileStatistics statistics)
     : base(test.TestPath, language, project, statistics)
 {
     if (test == null)
     {
         throw new ArgumentNullException("test");
     }
     _test = test;
 }
Exemplo n.º 4
0
        public AmmyProject(IReadOnlyList <string> referenceAssemblies, IReadOnlyList <AmmyFileMeta> ammyFiles, CSharpProject csharpProject, object compilationData, string projectDir, string outputPath, string rootNamespace, string assemblyName, string targetPath)
        {
            _cts          = new CancellationTokenSource();
            CSharpProject = csharpProject;
            TargetPath    = targetPath;

            References = referenceAssemblies.Distinct()
                         .SelectMany(path => new[] { new FileLibReference(path) })
                         .ToList();

            FsProject = new FsProject <Top>(new FsSolution <Top>(), projectDir, References)
            {
                Data = compilationData
            };
            Files = ammyFiles.SelectMany((meta, index) => {
                if (!System.IO.File.Exists(meta.Filename))
                {
                    MissingFiles.Add(meta.Filename);
                    return(new AmmyFile <Top> [0]);
                }

                // If file is not cached by VS extension create new
                if (meta.File == null)
                {
                    meta.File = new AmmyFile <Top>(index, meta, AmmyLanguage, projectDir, FsProject);
                }
                else
                {
                    FsProject.FsFiles.Add(meta.File);
                }

                return(new[] { meta.File });
            }).ToList();

            OutputPath    = outputPath;
            RootNamespace = rootNamespace;
            AssemblyName  = assemblyName;

            ProjectSupport = (Start)FsProject.GetProjectSupport();

            if (ProjectSupport != null)
            {
                Platform = ProjectSupport.Platform = GetCompatiblePlatform();
            }
        }
Exemplo n.º 5
0
 public CSharpFile(int id, string filePath, Nitra.Language language, FsProject <CompilationUnit> fsProject = null, FileStatistics statistics = null) : base(filePath, language, fsProject, statistics)
 {
     Id = id;
 }
Exemplo n.º 6
0
        public AmmyFile(int id, AmmyFileMeta meta, Nitra.Language language, string projectDir, FsProject <T> fsProject = null, FileStatistics statistics = null)
            : base(meta.Filename, language, fsProject, statistics)
        {
            Id   = id;
            Meta = meta;

            var filename = Path.ChangeExtension(Meta.Filename, ".xaml");

            if (Path.IsPathRooted(filename))
            {
                OutputFilename = filename;
            }
            else
            {
                OutputFilename = Path.Combine(projectDir, filename);
            }

            LastWriteTime = new FileInfo(FilePath).LastWriteTime;

            EvalPropertiesData = GetEvalPropertiesData();
        }
Exemplo n.º 7
0
 public InputFile(int id, string filePath, Nitra.Language language, FsProject <Start> fsProject = null, FileStatistics statistics = null) : base(filePath, language, fsProject, statistics)
 {
     Id = id;
 }