public static Tsconfig FindFromProjectItem(string projectItemFullPath) { DirectoryInfo folder = Directory.GetParent(projectItemFullPath); while (folder != null) { foreach (FileInfo fileInfo in folder.EnumerateFiles()) { if (LintableFiles.IsLintableTsconfig(fileInfo.FullName)) { return(new Tsconfig(fileInfo.FullName)); } } folder = folder.Parent; } return(null); }
private static void FindTsConfigsInProjectItem(ProjectItem projectItem, HashSet <string> result) { string itemPath = projectItem.GetFullPath(); if (LintableFiles.IsLintableTsconfig(itemPath) && !result.Contains(itemPath)) { result.Add(itemPath); } // A project item can be a folder or a nested file, so we may need to continue searching down the tree if (projectItem.ProjectItems == null || LintableFiles.ContainsIgnorePattern(itemPath)) { return; } foreach (ProjectItem subProjectItem in projectItem.ProjectItems) { FindTsConfigsInProjectItem(subProjectItem, result); } }
// Different from FindFromProjectItem: here we are searching a project or solution // for any tsconfig that's included: we don't mess around looking up the folder structure // to see if any are at a higher level that we can use to lint this item private static IEnumerable <Tsconfig> FindInProjectItem(ProjectItem projectItem) { string itemPath = projectItem.GetFullPath(); if (LintableFiles.IsLintableTsconfig(itemPath)) { yield return(new Tsconfig(itemPath)); } // Checking the ignore pattern here is an optimization that prevents us iterating ignored folders if (projectItem.ProjectItems == null || LintableFiles.ContainsIgnorePattern(itemPath)) { yield break; } foreach (ProjectItem subProjectItem in projectItem.ProjectItems) { foreach (var item in FindInProjectItem(subProjectItem)) { yield return(item); } } }
private static void FindTsconfigsFromSelectedProjectItem(string projectItemPath, ProjectItem item, HashSet <string> result, Dictionary <string, string> fileToProjectMap) { if (LintableFiles.IsLintableTsTsxJsJsxFile(projectItemPath)) { if (!fileToProjectMap.ContainsKey(projectItemPath)) { fileToProjectMap.Add(projectItemPath, item.ContainingProject.Name); } string tsconfig = FindParentTsconfig(projectItemPath); if (tsconfig != null && !result.Contains(tsconfig)) { result.Add(tsconfig); } } else if (item.Kind == EnvDTE.Constants.vsProjectItemKindPhysicalFolder || LintableFiles.IsLintableTsconfig(projectItemPath)) { FindTsConfigsInProjectItem(item, result); } }