Exemple #1
0
        public void Test_CreateTypeChecker()
        {
            var host    = new TypeCheckerHostFake();
            var checker = Checker.CreateTypeChecker(host, true, degreeOfParallelism: 1);

            Assert.NotNull(checker);
        }
        /// <summary>
        /// Analyze all source files.
        /// </summary>
        public static List <ISourceFile> Analyze(
            out ITypeChecker checker,
            bool useCachedVersion         = false,
            ParsingOptions parsingOptions = null, bool implicitReferenceModule = false, params TestFile[] tsInputFiles)
        {
            LazyInitializer.EnsureInitialized(ref s_libFile, () => File.ReadAllText("Libs/lib.core.d.ts"));

            // Need to parse lib.d.ts file each time, because checker mutates ISourcefile
            // var parsedLibFile = s_parsedSourceFile;//threadLocalSource.Value;
            var parsedLibFile = LazyInitializer.EnsureInitialized(ref s_parsedLibFile, ParseLib);

            if (!useCachedVersion)
            {
                // See comment in StringBasedCheckerTests.CheckAnalysisOrderIssue for more details!
                parsedLibFile = ParsingHelper.ParsePotentiallyBrokenSourceFile(s_libFile, "lib.core.d.ts", parsingOptions);
            }

            var sourceFiles =
                tsInputFiles.Select(
                    tsInputFile =>
                    ParsingHelper.ParsePotentiallyBrokenSourceFile(tsInputFile.Content, tsInputFile.UnitName, parsingOptions)).ToList();

            var sourceFilesWithLib = new List <ISourceFile>(sourceFiles)
            {
                parsedLibFile
            };

            // Need to parse lib.d.ts file every time, because checker mutates it and this could lead to failure
            // when multiple checking processes are running in parallel.
            // var parsedLibFile = ParseOrDeserialize(s_libFile);// ParsingHelper.ParseSourceFile(s_libFile, "lib.d.ts");
            ModuleName?fakeModule = new ModuleName("fakeModule", implicitReferenceModule);
            var        host       = new TypeCheckerHostFake(fakeModule, sourceFilesWithLib.ToArray());

            checker = Checker.CreateTypeChecker(host, true, degreeOfParallelism: 1);

            return(sourceFiles);
        }
Exemple #3
0
        private static ITypeChecker CreateTypeChecker(ISourceFile sourceFile)
        {
            var host = new TypeCheckerHostFake(sourceFile);

            return(Checker.CreateTypeChecker(host, true, degreeOfParallelism: 1));
        }