Esempio n. 1
0
        public List <LspFile> FindReferencingFiles(LspFile thisfile)
        {
            var recuse = new List <LspFile>();

            lock (LockRoot)
                recuse.AddRange(Files.Where(f => f.References.Contains(thisfile.FullPath, new Paths.FilePathEqualityComparer())).ToArray());

            return(recuse);
        }
Esempio n. 2
0
 public static void FileRenamed(string oldFilename, LspFile file)
 {
     _invoke(() => {
         lock (m.lstWatching) {
             m.lstWatching.Items.Remove(Path.GetFileName(Paths.NormalizePath(oldFilename)));
             m.lstWatching.Items.Add(file.FileName);
         }
         AddLog("Watcher", $"File `{Path.GetFileName(oldFilename)}` has renamed to `{file.FileName}`");
     });
 }
Esempio n. 3
0
        private void ManagerOnBeganWatchingFile(LspFile lspFile, DateTime dateTime)
        {
            GUI.AddListeningTo(lspFile.FileName);
            lock (Config) {
                LspFile[] tmp;
                lock (Manager.LockRoot)
                    tmp = Manager.Files.ToArray();

                Config.Files = tmp.Select(ls => ls.FullPath).ToArray();
                Config.Save();
            }
        }
Esempio n. 4
0
        public bool Remove(LspFile f)
        {
            if (f == null)
            {
                return(false);
            }
            Files.Remove(f);
            var any = FindLspFileByDir(f.FolderPath).Any();

            if (any == false)
            {
                var watcher = Watchers[f.FolderPath];
                Watchers.Remove(f.FolderPath);
                watcher.Dispose();
            }
            StoppedWatchingFile?.Invoke(f, DateTime.Now);
            return(true);
        }
Esempio n. 5
0
        public LspFile Watch(string file)
        {
            if (file == null)
            {
                throw new ArgumentNullException(nameof(file));
            }
            if (!File.Exists(file))
            {
                throw new FileNotFoundException("Cant start watching cuz file not found: " + file);
            }

            file = Paths.NormalizePath(file);
            LspFile f = new LspFile(file, this);

            lock (LockRoot) {
                Watch(f);
            }
            return(f);
        }
Esempio n. 6
0
 public void Watch(LspFile lsfile)
 {
     if (lsfile == null)
     {
         throw new ArgumentNullException(nameof(lsfile));
     }
     lock (LockRoot) {
         Files.Add(lsfile);
         var folder = lsfile.FolderPath;
         if (Watchers.ContainsKey(folder) == false)
         {
             var watcher = Watchers[folder] ?? (Watchers[folder] = new LspFileWatcher(folder));
             watcher.FileAdded   += FileAddedHandler;
             watcher.FileChanged += FileChangedHandler;
             watcher.FileDeleted += FileDeletedHandler;
             watcher.FileRenamed += FileRenamedHandler;
         }
     }
     BeganWatchingFile?.Invoke(lsfile, DateTime.Now);
 }
Esempio n. 7
0
        public LspFile FindLspFile(string filename, DateTime?when = null)
        {
            LspFile t = null;

            lock (LockRoot) {
                if (filename.Replace('\\', '/').Contains("/"))
                {
                    t = Files.FirstOrDefault(lsfile => Paths.CompareTo(lsfile.FullPath, filename));
                }
                else
                {
                    t = Files.FirstOrDefault(lsfile => Paths.CompareTo(lsfile.FileName, filename));
                }
            }

            if (t == null)
            {
                Error?.Invoke(new ThrowlessException("Couldn't find file inside LspFiles\n" + filename, Environment.StackTrace), when ?? DateTime.Now);
            }
            return(t);
        }
Esempio n. 8
0
 private void ManagerOnFileRenamed(string oldFilename, LspFile file, DateTime _)
 {
     GUI.FileRenamed(oldFilename, file);
 }
Esempio n. 9
0
 private void ManagerOnFileDeleted(LspFile file, DateTime dateTime)
 {
     GUI.RemoveListeningTo(file.FileName);
 }
Esempio n. 10
0
 private void ManagerOnFileChanged(LspFile file, DateTime dateTime)
 {
     GUI.HasReloaded(file.FileName);
     file.Reload(true);
 }