コード例 #1
0
        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);
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        // 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);
                }
            }
        }
コード例 #4
0
 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);
     }
 }