public IProject GetProjectFromRootPath(FullPathName projectRootPath) { var name = projectRootPath; lock (_lock) { return _knownProjectRootDirectories.Get(name); } }
private static IEnumerable<FullPathName> EnumerateParents(FullPathName path) { var directory = path.Parent; for (var parent = directory; parent != default(FullPathName); parent = parent.Parent) { yield return parent; } }
/// <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; }
public ProjectFileProject(IConfigurationSectionProvider configurationSectionProvider, FullPathName rootPath) { _rootPath = rootPath; _directoryFilter = new DirectoryFilter(configurationSectionProvider); _fileFilter = new FileFilter(configurationSectionProvider); _searchableFilesFilter = new SearchableFilesFilter(configurationSectionProvider); }
public IProject GetProject(FullPathName filename) { return _providers .Select(t => t.GetProject(filename)) .Where(project => project != null) .OrderByDescending(p => p.RootPath.FullName.Length) .FirstOrDefault(); }
public DirectorySnapshot FindRootDirectory(FullPathName rootPath) { var index = SortedArray.BinarySearch(_snapshot.ProjectRoots, rootPath, ProjectRootComparer); if (index >= 0) return _snapshot.ProjectRoots[index].Directory; return null; }
public DirectoryName CreateAbsoluteDirectoryName(FullPathName rootPath) { var rootdirectory = FindRootDirectory(rootPath); if (rootdirectory != null) return rootdirectory.DirectoryName; return _previous.CreateAbsoluteDirectoryName(rootPath); }
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)); }
public FullPathName GetEnlistmentRoot(FullPathName filename) { var directory = filename.Parent; if (!directory.DirectoryExists) return default(FullPathName); return EnumerateParents(filename) .FirstOrDefault(x => IsChromiumSourceDirectory(x, _chromiumEnlistmentPatterns)); }
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)); }
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); }
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; }
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); } }
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; }
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"); } }
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); }
private void EnqueueChangeEvent(FullPathName path, PathChangeKind changeKind) { lock (_changedPathsLock) { MergePathChange(_changedPaths, path, changeKind); } }
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; }
private ChromiumProject CreateProject(FullPathName rootPath) { return(new ChromiumProject(_configurationSectionProvider, rootPath)); }
private ChromiumProject CreateProject(FullPathName rootPath) { return new ChromiumProject(_configurationSectionProvider, rootPath); }
private Tuple <IProject, FileName> GetProjectFileName(FullPathName path) { return(FileSystemNameFactoryExtensions.GetProjectFileName(_fileSystemNameFactory, _projectDiscovery, path)); }
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); }
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); }
/// <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); }
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); } } }
public AbsoluteDirectoryName(FullPathName path) { _path = path; }
public IProject GetProject(FullPathName filename) { return(_chromiumDiscovery.GetEnlistmentRootFromFilename(filename, CreateProject)); }
public IProject GetProject(FullPathName filename) { return _chromiumDiscovery.GetEnlistmentRootFromFilename(filename, CreateProject); }
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(); }
public SlimFileInfo(FullPathName path) { _path = path; }
public static bool ContainsProjectFile(FullPathName path) { return(path.Combine(ConfigurationFilenames.ProjectFileNameDetection).FileExists); }
public IProject GetProjectFromRootPath(FullPathName projectRootPath) { return _chromiumDiscovery.GetEnlistmentRootFromRootpath(projectRootPath, CreateProject); }
public T GetEnlistmentRootFromRootpath(FullPathName root, Func <FullPathName, T> factory) { lock (_lock) { return(_chromiumRootDirectories.Get(root)); } }
public static bool ContainsProjectFile(FullPathName path) { return path.Combine(ConfigurationFilenames.ProjectFileNameDetection).FileExists; }
public IProject GetProjectFromRootPath(FullPathName projectRootPath) { return(_providers .Select(t => t.GetProjectFromRootPath(projectRootPath)) .FirstOrDefault(project => project != null)); }
public IProject GetProjectFromRootPath(FullPathName projectRootPath) { return _providers .Select(t => t.GetProjectFromRootPath(projectRootPath)) .FirstOrDefault(project => project != null); }
private IProject CreateProject(FullPathName rootPath) { var fileWithSections = new FileWithSections(rootPath.Combine(ConfigurationFilenames.ProjectFileNameDetection).FullName); var configurationProvider = new FileWithSectionConfigurationProvider(fileWithSections); return new ProjectFileProject(configurationProvider, rootPath); }
public FileContents GetFileContents(FullPathName path) { return(ReadFile(path)); }
public PathChangeEntry(FullPathName path, PathChangeKind kind) { _path = path; _kind = kind; }
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); }
public DirectoryName CreateAbsoluteDirectoryName(FullPathName path) { return new AbsoluteDirectoryName(path); }
public IProject GetProjectFromRootPath(FullPathName projectRootPath) { return(_chromiumDiscovery.GetEnlistmentRootFromRootpath(projectRootPath, CreateProject)); }
/// <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); }
public DirectoryName CreateAbsoluteDirectoryName(FullPathName path) { return(new AbsoluteDirectoryName(path)); }