private void handle(Change file) { if (file == null) { return; } var extension = Path.GetExtension(file.Path).ToLower(); if (extension == null) { return; } try { _eventDispatcher.Send( "codemodel filesystem-change-" + file.Type.ToString().ToLower() + " \"" + file.Path + "\""); _plugins.ForEach(x => { if (x.Supports(extension) && !x.FilesToHandle.Contains(file.Path)) { x.FilesToHandle.Add(file.Path); } }); _eventDispatcher.Send("codemodel file-crawled \"" + file.Path + "\""); } catch (Exception ex) { Logger.Write("Failed while handling file system changes. CodeModel may be out of sync"); Logger.Write(ex); } }
private void handle(Change file) { if (file == null) { return; } var extension = Path.GetExtension(file.Path).ToLower(); if (extension == null) { return; } _eventDispatcher.Send( "codemodel filesystem-change-" + file.Type.ToString().ToLower() + " \"" + file.Path + "\""); _plugins.ForEach(x => { if (x.Supports(extension) && !x.FilesToHandle.Contains(file.Path)) { x.FilesToHandle.Add(file.Path); } }); _eventDispatcher.Send("codemodel file-crawled \"" + file.Path + "\""); }
public void Start( string path, ICacheBuilder cache, ICrawlResult crawlReader, PluginLocator pluginLocator, EventEndpoint eventDispatcher, string[] ignoreDirectories) { _cache = cache; _crawlReader = crawlReader; _eventDispatcher = eventDispatcher; Logger.Write("Setting up file trackers"); Logger.Write("Setting up token file trackers"); _tracker = new FileChangeTracker((x) => { if (x.Path.StartsWith(Path.Combine(path, ".OpenIDE"))) { return; } _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Setting up local file trackers"); _localTracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Setting up global file trackers"); _globalTracker = new FileChangeTracker((x) => { _eventDispatcher.Send( "codemodel raw-filesystem-change-" + x.Type.ToString().ToLower() + " \"" + x.Path + "\""); }); Logger.Write("Adding plugins to cache"); var plugins = pluginLocator.Locate().ToList(); foreach (var x in plugins) { var plugin = new PluginPattern(x); _plugins.Add(plugin); _cache.Plugins.Add( new CachedPlugin(x.GetLanguage(), plugin.Patterns)); Logger.Write("Added plugin " + x.GetLanguage()); } var locator = new ProfileLocator(path); var profilePath = locator.GetLocalProfilePath(locator.GetActiveLocalProfile()); if (Directory.Exists(profilePath)) { Logger.Write("Starting tracker for {0}", path); _tracker.Start(path, getFilter(), handleChanges, ignoreDirectories); } else { Logger.Write("No local configuration point so not starting file tracker"); } if (Environment.OSVersion.Platform == PlatformID.Unix || Environment.OSVersion.Platform == PlatformID.MacOSX) { if (Directory.Exists(profilePath)) { Logger.Write("Starting tracker for {0}", profilePath); _localTracker.Start(profilePath, getFilter(), handleChanges, ignoreDirectories); } } var globalPath = locator.GetGlobalProfilePath(locator.GetActiveGlobalProfile()); if (Directory.Exists(globalPath)) { Logger.Write("Starting tracker for {0}", globalPath); _globalTracker.Start(globalPath, getFilter(), handleChanges, ignoreDirectories); } }