Exemplo n.º 1
0
            protected override async Task <List <FileDataValue> > ComputeFileDataValuesAsync(string filePath, CancellationToken cancellationToken)
            {
                Debug.Assert(await this.IsValidFileAsync(filePath), $"{filePath} should be a tsconfig.json file.");

                var tsconfig = await TsConfigJsonFactory.CreateAsync(filePath);

                Debug.Assert(!string.IsNullOrEmpty(tsconfig?.OutFile), "Should have an outfile specified.");

                var tsconfigFolder = Path.GetDirectoryName(filePath);
                var outFile        = Path.Combine(tsconfigFolder, tsconfig.OutFile);

                var launchSettings = new PropertySettings
                {
                    [LaunchConfigurationConstants.NameKey] = $"node {outFile} {NodejsConstants.TsConfigJsonFile}",
                    [LaunchConfigurationConstants.TypeKey] = "default"
                };

                var fileDataValues = new List <FileDataValue>
                {
                    new FileDataValue(
                        DebugLaunchActionContext.ContextTypeGuid,
                        DebugLaunchActionContext.IsDefaultStartupProjectEntry,
                        launchSettings,
                        target: outFile),

                    new FileDataValue(BuildConfigurationContext.ContextTypeGuid, outFile, null,
                                      context: "Debug", target: outFile),

                    new FileDataValue(BuildConfigurationContext.ContextTypeGuid, outFile, null,
                                      context: "Debug", target: null)
                };

                return(fileDataValues);
            }
Exemplo n.º 2
0
            protected override async Task <bool> IsValidFileAsync(string filePath)
            {
                // Only use the tsconfig.json determine the debug target when there is an outfile specified,
                // otherwise each .ts file can (in theory) be the entry point.
                if (TypeScriptHelpers.IsTsJsConfigJsonFile(filePath))
                {
                    var tsconfig = await TsConfigJsonFactory.CreateAsync(filePath);

                    return(!string.IsNullOrEmpty(tsconfig?.OutFile));
                }

                return(false);
            }
Exemplo n.º 3
0
        public static async Task <TsConfigJson> IsContainedByTsConfig(this IWorkspace workspace, string filePath)
        {
            var fileService = workspace.GetFindFilesService();
            var collector   = new FileCollector();
            await fileService.FindFilesAsync("sconfig.json", collector);

            foreach (var configFile in collector.FoundFiles)
            {
                if (TypeScriptHelpers.IsTsJsConfigJsonFile(configFile))
                {
                    var directory = Path.GetDirectoryName(configFile);
                    if (filePath.StartsWith(directory, StringComparison.OrdinalIgnoreCase))
                    {
                        return(await TsConfigJsonFactory.CreateAsync(configFile));
                    }
                }
            }

            return(null);
        }
Exemplo n.º 4
0
            protected override async Task <List <FileReferenceInfo> > ComputeFileReferencesAsync(string filePath, CancellationToken cancellationToken)
            {
                Debug.Assert(await this.IsValidFileAsync(filePath), $"{filePath} should be a tsconfig.json file.");

                var tsconfig = await TsConfigJsonFactory.CreateAsync(filePath);

                Debug.Assert(!string.IsNullOrEmpty(tsconfig?.OutFile), "Should have an outfile specified.");

                var tsconfigFolder = Path.GetDirectoryName(filePath);
                var outFile        = Path.Combine(tsconfigFolder, tsconfig.OutFile);

                var fileReferences = new List <FileReferenceInfo>
                {
                    new FileReferenceInfo(outFile,
                                          context: "Debug",
                                          target: outFile,
                                          referenceType: (int)FileReferenceInfoType.Output)
                };

                return(fileReferences);
            }