コード例 #1
0
 public IProject GetProjectFromRootPath(FullPathName projectRootPath)
 {
     var name = projectRootPath;
       lock (_lock) {
     return _knownProjectRootDirectories.Get(name);
       }
 }
コード例 #2
0
 private static IEnumerable<FullPathName> EnumerateParents(FullPathName path)
 {
     var directory = path.Parent;
       for (var parent = directory; parent != default(FullPathName); parent = parent.Parent) {
     yield return parent;
       }
 }
コード例 #3
0
 /// <summary>
 /// Returns the absolute path of the project containing |filename|.
 /// Returns |null| if |filename| is not located within a local project directory.
 /// </summary>
 public static FullPathName GetProjectPath(this IProjectDiscovery projectDiscovery, FullPathName filename)
 {
     var project = projectDiscovery.GetProject(filename);
       if (project == null)
     return default(FullPathName);
       return project.RootPath;
 }
コード例 #4
0
 public ProjectFileProject(IConfigurationSectionProvider configurationSectionProvider, FullPathName rootPath)
 {
     _rootPath = rootPath;
       _directoryFilter = new DirectoryFilter(configurationSectionProvider);
       _fileFilter = new FileFilter(configurationSectionProvider);
       _searchableFilesFilter = new SearchableFilesFilter(configurationSectionProvider);
 }
コード例 #5
0
 public IProject GetProject(FullPathName filename)
 {
     return _providers
     .Select(t => t.GetProject(filename))
     .Where(project => project != null)
     .OrderByDescending(p => p.RootPath.FullName.Length)
     .FirstOrDefault();
 }
コード例 #6
0
        public DirectorySnapshot FindRootDirectory(FullPathName rootPath)
        {
            var index = SortedArray.BinarySearch(_snapshot.ProjectRoots, rootPath, ProjectRootComparer);
              if (index >= 0)
            return _snapshot.ProjectRoots[index].Directory;

              return null;
        }
コード例 #7
0
        public DirectoryName CreateAbsoluteDirectoryName(FullPathName rootPath)
        {
            var rootdirectory = FindRootDirectory(rootPath);
              if (rootdirectory != null)
            return rootdirectory.DirectoryName;

              return _previous.CreateAbsoluteDirectoryName(rootPath);
        }
コード例 #8
0
        public bool ApplyCodingStyle(string filename)
        {
            var path = new FullPathName(filename);
              var root = _chromiumDiscoveryProvider.GetEnlistmentRootFromFilename(path, x => x);
              if (root == default(FullPathName))
            return false;

              return _applyCodingStyleResults.GetOrAdd(filename, (key) => ApplyCodingStyleWorker(root, key));
        }
コード例 #9
0
        public FullPathName GetEnlistmentRoot(FullPathName filename)
        {
            var directory = filename.Parent;
              if (!directory.DirectoryExists)
            return default(FullPathName);

              return EnumerateParents(filename)
            .FirstOrDefault(x => IsChromiumSourceDirectory(x, _chromiumEnlistmentPatterns));
        }
コード例 #10
0
 public static bool IsChromiumSourceDirectory(FullPathName path, IPathPatternsFile chromiumEnlistmentPatterns)
 {
     // We need to ensure that all pattern lines are covered by at least one file/directory of |path|.
       IList<string> directories;
       IList<string> files;
       NativeFile.GetDirectoryEntries(path.FullName, out directories, out files);
       return chromiumEnlistmentPatterns.GetPathMatcherLines()
     .All(item => MatchFileOrDirectory(item, directories, files));
 }
コード例 #11
0
        private bool ApplyCodingStyleWorker(FullPathName root, string filename)
        {
            var relativePath = filename.Substring(root.FullName.Length);
              if (relativePath.Length == 0)
            return false;

              if (relativePath[0] == Path.DirectorySeparatorChar)
            relativePath = relativePath.Substring(1);

              if (relativePath.Length == 0)
            return false;

              return !_chromiumCodingStylePatterns.GetPathMatcher().MatchFileName(relativePath, SystemPathComparer.Instance);
        }
コード例 #12
0
        public InstallationData(string exePath, InstallationLevel level, int iconIndex, string name, string version)
        {
            string location = Path.GetDirectoryName(exePath);

              Distribution = DistributionType.Canary;
              Architecture = ProcessUtility.GetMachineType(exePath);
              Level = level;
              InstallationPath = new FullPathName(location);
              if (InstallationPath.HasComponent("Chrome SxS"))
            Distribution = DistributionType.Canary;
              else if (InstallationPath.HasComponent("Chrome"))
            Distribution = DistributionType.Chrome;
              else
            Distribution = DistributionType.Chromium;

              IconIndex = iconIndex;
              Name = name;
              Version = version;
        }
コード例 #13
0
        public IProject GetProject(FullPathName filename)
        {
            var name = filename;
              lock (_lock) {
            // Cache hit?
            var root = _knownProjectRootDirectories
              .Where(x => name.StartsWith(x.Key))
              .OrderByDescending(x => x.Key.FullName.Length)
              .FirstOrDefault();
            if (root.Key != default(FullPathName)) {
              return root.Value;
            }

            // Negative cache hit?
            if (_knownNonProjectDirectories.Contains(name.Parent)) {
              return null;
            }

            // Nope: compute all the way...
            return GetProjectWorker(name);
              }
        }
コード例 #14
0
        private bool PathIsExcluded(FullPathName path)
        {
            var project = _projectDiscovery.GetProject(path);
              if (project == null)
            return true;

              var rootPath = project.RootPath;

              // If path is root itself, it is never excluded.
              if (rootPath.FullName.Length == path.FullName.Length)
            return false;

              var rootLength = rootPath.FullName.Length + 1; // Move past '\\' character.
              if (rootPath.FullName.Last() == Path.DirectorySeparatorChar)
            rootLength--;

              var relativePath = path.FullName.Substring(rootLength);
              var items = relativePath.Split(new char[] {
            Path.DirectorySeparatorChar
              });
              var pathToItem = "";
              foreach (var item in items) {
            var relativePathToItem = Path.Combine(pathToItem, item);

            if (!project.DirectoryFilter.Include(relativePathToItem))
              return true;

            // For the last component, we don't know if it is a file or directory.
            // Be conservative and try both.
            if (item == items.Last()) {
              if (!project.FileFilter.Include(relativePathToItem))
            return true;
            }

            pathToItem = relativePathToItem;
              }
              return false;
        }
コード例 #15
0
        public new int CompareTo(object obj)
        {
            if (obj == null)
            {
                return(1);
            }

            CSFileInfo otherFileInfo = obj as CSFileInfo;

            if (otherFileInfo != null)
            {
                if (this.hasMainMethod && !otherFileInfo.hasMainMethod)
                {
                    return(-1);
                }
                else if (!this.hasMainMethod && otherFileInfo.hasMainMethod)
                {
                    return(1);
                }
                else
                {
                    if (Name.Equals(otherFileInfo.Name))
                    {
                        return(FullPathName.CompareTo(otherFileInfo.FullPathName));
                    }
                    else
                    {
                        return(Name.CompareTo(otherFileInfo.Name));
                    }
                }
            }
            else
            {
                throw new ArgumentException("Object is not a CSFileInfo");
            }
        }
コード例 #16
0
 private static void MergePathChange(Dictionary<FullPathName, PathChangeKind> changes, FullPathName path, PathChangeKind kind)
 {
     PathChangeKind currentChangeKind;
       if (!changes.TryGetValue(path, out currentChangeKind)) {
     currentChangeKind = PathChangeKind.None;
       }
       changes[path] = CombineChangeKinds(currentChangeKind, kind);
 }
コード例 #17
0
 private void EnqueueChangeEvent(FullPathName path, PathChangeKind changeKind)
 {
     lock (_changedPathsLock) {
         MergePathChange(_changedPaths, path, changeKind);
     }
 }
コード例 #18
0
        private IProject GetProjectWorker(FullPathName filepath)
        {
            var directory = filepath.Parent;
              if (directory.DirectoryExists) {
            var projectPath = EnumerateParents(filepath).FirstOrDefault(x => ContainsProjectFile(x));
            if (projectPath != default(FullPathName)) {
              var project = CreateProject(projectPath);
              _knownProjectRootDirectories.Add(projectPath, project);
              return project;
            }
              }

              // No one in the parent chain is a Chromium directory.
              EnumerateParents(filepath).ForAll(x => _knownNonProjectDirectories.Add(x, null));
              return null;
        }
コード例 #19
0
 private void EnqueueChangeEvent(FullPathName path, PathChangeKind changeKind)
 {
     lock (_changedPathsLock) {
     MergePathChange(_changedPaths, path, changeKind);
       }
 }
コード例 #20
0
 private ChromiumProject CreateProject(FullPathName rootPath)
 {
     return(new ChromiumProject(_configurationSectionProvider, rootPath));
 }
コード例 #21
0
 private ChromiumProject CreateProject(FullPathName rootPath)
 {
     return new ChromiumProject(_configurationSectionProvider, rootPath);
 }
コード例 #22
0
 private Tuple <IProject, FileName> GetProjectFileName(FullPathName path)
 {
     return(FileSystemNameFactoryExtensions.GetProjectFileName(_fileSystemNameFactory, _projectDiscovery, path));
 }
コード例 #23
0
 public static InstallationData Create(NtProcess proc)
 {
     InstallationEnumerator enumerator = new InstallationEnumerator();
       foreach (InstallationData data in enumerator) {
     FullPathName fullPath = new FullPathName(proc.Win32ProcessImagePath);
     if (fullPath.StartsWith(data.InstallationPath))
       return data;
       }
       return new InstallationData(
       proc.Win32ProcessImagePath,
       InstallationLevel.Developer,
       0,
       "Developer Chrome",
       String.Empty);
 }
コード例 #24
0
 public static void GetFileSystemEntries(FullPathName rootPath, RelativePathName path, out IList<string> directories, out IList<string> files)
 {
     NativeFile.GetDirectoryEntries(PathHelpers.PathCombine(rootPath.FullName, path.RelativeName), out directories, out files);
 }
コード例 #25
0
        /// <summary>
        /// Return the |FileName| instance corresponding to the full path |path|. Returns |null| if |path|
        /// is invalid or not part of a project.
        /// </summary>
        public static Tuple <IProject, FileName> GetProjectFileName(IFileSystemNameFactory fileSystemNameFactory, IProjectDiscovery projectDiscovery, FullPathName path)
        {
            var project = projectDiscovery.GetProject(path);

            if (project == null)
            {
                return(null);
            }

            var rootPath   = project.RootPath;
            var rootLength = rootPath.FullName.Length + 1;

            if (rootPath.FullName.Last() == Path.DirectorySeparatorChar)
            {
                rootLength--;
            }

            var directoryName = fileSystemNameFactory.CreateAbsoluteDirectoryName(rootPath);
            var relativePath  = path.FullName.Substring(rootLength);
            var items         = relativePath.Split(new char[] {
                Path.DirectorySeparatorChar
            });

            foreach (var item in items)
            {
                if (item == items.Last())
                {
                    return(Tuple.Create(project, fileSystemNameFactory.CreateFileName(directoryName, item)));
                }

                directoryName = fileSystemNameFactory.CreateDirectoryName(directoryName, item);
            }
            return(null);
        }
コード例 #26
0
        public void LoadProcesses()
        {
            _processes.Clear();
              List<ChromiumProcess> chromes = new List<ChromiumProcess>();
              HashSet<int> chromePids = new HashSet<int>();
              foreach (Process p in Process.GetProcesses()) {
            // System.Diagnostics.Process uses a naive implementation that is unable to deal with many
            // types of processes (such as those already under a debugger, or those with a high
            // privilege level), so use NtProcess instead.
            NtProcess ntproc = new NtProcess(p.Id);
            if (!ntproc.IsValid)
              continue;

            FullPathName processPath = new FullPathName(ntproc.Win32ProcessImagePath);
            if (processPath.StartsWith(_installationData.InstallationPath)) {
              chromes.Add(new ChromiumProcess(ntproc, _installationData));
              chromePids.Add(p.Id);
            }
              }

              foreach (ChromiumProcess chrome in chromes) {
            // Only insert root processes at this level, child processes will be children of one of
            // these processes.
            if (!chromePids.Contains(chrome.ParentPid)) {
              ChromeProcessViewModel viewModel = new ChromeProcessViewModel(_root, chrome);
              viewModel.LoadProcesses(chromes.ToArray());
              _processes.Add(viewModel);
            }
              }
        }
コード例 #27
0
 public AbsoluteDirectoryName(FullPathName path)
 {
     _path = path;
 }
コード例 #28
0
 public IProject GetProject(FullPathName filename)
 {
     return(_chromiumDiscovery.GetEnlistmentRootFromFilename(filename, CreateProject));
 }
コード例 #29
0
 public IProject GetProject(FullPathName filename)
 {
     return _chromiumDiscovery.GetEnlistmentRootFromFilename(filename, CreateProject);
 }
コード例 #30
0
        private void RemoveFileTask(string filename)
        {
            var path = new FullPathName(filename);
              bool recompute = ValidateKnownFiles();

              lock (_lock) {
            var known = _addedFiles.Contains(path);
            if (known) {
              var projectPaths1 = GetKnownProjectPaths(_addedFiles);
              _addedFiles.Remove(path);
              var projectPaths2 = GetKnownProjectPaths(_addedFiles);
              if (!projectPaths1.SequenceEqual(projectPaths2)) {
            recompute = true;
              }
            }
              }

              if (recompute)
            RecomputeGraph();
        }
コード例 #31
0
ファイル: SlimFileInfo.cs プロジェクト: lineCode/vs-chromium
 public SlimFileInfo(FullPathName path)
 {
     _path = path;
 }
コード例 #32
0
 public static bool ContainsProjectFile(FullPathName path)
 {
     return(path.Combine(ConfigurationFilenames.ProjectFileNameDetection).FileExists);
 }
コード例 #33
0
 public AbsoluteDirectoryName(FullPathName path)
 {
     _path = path;
 }
コード例 #34
0
 public IProject GetProjectFromRootPath(FullPathName projectRootPath)
 {
     return _chromiumDiscovery.GetEnlistmentRootFromRootpath(projectRootPath, CreateProject);
 }
コード例 #35
0
 public T GetEnlistmentRootFromRootpath(FullPathName root, Func <FullPathName, T> factory)
 {
     lock (_lock) {
         return(_chromiumRootDirectories.Get(root));
     }
 }
コード例 #36
0
 public static bool ContainsProjectFile(FullPathName path)
 {
     return path.Combine(ConfigurationFilenames.ProjectFileNameDetection).FileExists;
 }
コード例 #37
0
 public IProject GetProjectFromRootPath(FullPathName projectRootPath)
 {
     return(_providers
            .Select(t => t.GetProjectFromRootPath(projectRootPath))
            .FirstOrDefault(project => project != null));
 }
コード例 #38
0
 public IProject GetProjectFromRootPath(FullPathName projectRootPath)
 {
     return _providers
     .Select(t => t.GetProjectFromRootPath(projectRootPath))
     .FirstOrDefault(project => project != null);
 }
コード例 #39
0
 public ProjectFileProject(IConfigurationSectionProvider configurationSectionProvider, FullPathName rootPath)
 {
     _rootPath              = rootPath;
     _directoryFilter       = new DirectoryFilter(configurationSectionProvider);
     _fileFilter            = new FileFilter(configurationSectionProvider);
     _searchableFilesFilter = new SearchableFilesFilter(configurationSectionProvider);
 }
コード例 #40
0
 private IProject CreateProject(FullPathName rootPath)
 {
     var fileWithSections = new FileWithSections(rootPath.Combine(ConfigurationFilenames.ProjectFileNameDetection).FullName);
       var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections);
       return new ProjectFileProject(configurationProvider, rootPath);
 }
コード例 #41
0
 public FileContents GetFileContents(FullPathName path)
 {
     return(ReadFile(path));
 }
コード例 #42
0
 public SlimFileInfo(FullPathName path)
 {
     _path = path;
 }
コード例 #43
0
 public PathChangeEntry(FullPathName path, PathChangeKind kind)
 {
     _path = path;
     _kind = kind;
 }
コード例 #44
0
        private static void MergePathChange(Dictionary <FullPathName, PathChangeKind> changes, FullPathName path, PathChangeKind kind)
        {
            PathChangeKind currentChangeKind;

            if (!changes.TryGetValue(path, out currentChangeKind))
            {
                currentChangeKind = PathChangeKind.None;
            }
            changes[path] = CombineChangeKinds(currentChangeKind, kind);
        }
コード例 #45
0
 public PathChangeEntry(FullPathName path, PathChangeKind kind)
 {
     _path = path;
       _kind = kind;
 }
コード例 #46
0
 public DirectoryName CreateAbsoluteDirectoryName(FullPathName path)
 {
     return new AbsoluteDirectoryName(path);
 }
コード例 #47
0
 public IProject GetProjectFromRootPath(FullPathName projectRootPath)
 {
     return(_chromiumDiscovery.GetEnlistmentRootFromRootpath(projectRootPath, CreateProject));
 }
コード例 #48
0
        /// <summary>
        /// Returns the absolute path of the project containing |filename|.
        /// Returns |null| if |filename| is not located within a local project directory.
        /// </summary>
        public static FullPathName GetProjectPath(this IProjectDiscovery projectDiscovery, FullPathName filename)
        {
            var project = projectDiscovery.GetProject(filename);

            if (project == null)
            {
                return(default(FullPathName));
            }
            return(project.RootPath);
        }
コード例 #49
0
 public DirectoryName CreateAbsoluteDirectoryName(FullPathName path)
 {
     return(new AbsoluteDirectoryName(path));
 }