コード例 #1
0
        private void GetSupportFilesInProject(string message, object callback)
        {
            IEnumerable <string> filesInSearch = FileWatcher.LAST_OPENED_FILES.ToArray().Reverse();
            var fileCachePath = PathManager.GetGoToFileCachePath();

            if (File.Exists(fileCachePath))
            {
                filesInSearch = filesInSearch.Concat(File.ReadAllLines(fileCachePath));
            }
            else
            {
                filesInSearch = filesInSearch.Concat(FileWatcher.ALLOWED_FILES_CACHE);
            }

            // remove duplicate lines
            HashSet <string> uniqueFilesSet = new HashSet <string>();

            foreach (var item in filesInSearch)
            {
                uniqueFilesSet.Add(Path.GetFullPath(item));
            }

            var files = uniqueFilesSet
                        .Where(f => File.Exists(f))
                        .Select(f => string.Format("\"{0}\"", Utility.PathNormalized(f)));
            var filesInJson = string.Format("[{0}]", String.Join(",", files.ToArray()));

            wrap = new CallbackWrapper(callback);
            wrap.Send(filesInJson);
        }
コード例 #2
0
        public static void RefreshAllowedFilesCache()
        {
            var files = Utility.GetAllAllowedFiles(OnLoad.WORKING_DIRECTORY);

            ALLOWED_FILES_CACHE.Clear();

            foreach (var item in files)
            {
                ALLOWED_FILES_CACHE.Add(item);
            }

            File.WriteAllLines(PathManager.GetGoToFileCachePath(), files.ToArray());

            var lastOpenedFilesCache = PathManager.GetLastOpenedFilePath();

            if (File.Exists(lastOpenedFilesCache))
            {
                var filesInCache = File.ReadAllLines(lastOpenedFilesCache);
                LAST_OPENED_FILES = filesInCache.ToList();
            }
        }
コード例 #3
0
        public static void OnPostprocessAllAssets(string[] importedAssets, string[] deletedAssets, string[] movedAssets, string[] movedFromAssetPaths)
        {
            bool hasCSFileChanged     = false;
            bool needRestartOmnisharp = false;

            HandleAction action = (string path, string type, bool hasRemoveAction, string oldFile) =>
            {
                FileChangedWithAllowedCheck(path, type, oldFile);
                if (!hasCSFileChanged)
                {
                    hasCSFileChanged = Utility.IsCSharpScript(path);
                }

                // WORKAROUND: If have rename action for cs file, we need to restart Omnisharp
                // to take the intellisense back.
                if (!string.IsNullOrEmpty(oldFile) && !needRestartOmnisharp)
                {
                    needRestartOmnisharp = Utility.IsCSharpScript(oldFile);
                    if (needRestartOmnisharp)
                    {
                        var lockFile = PathManager.OmnisharpRestartLockFile();
                        if (!File.Exists(lockFile))
                        {
                            File.WriteAllText(PathManager.OmnisharpRestartLockFile(), "");
                        }
                    }
                }

                if (hasRemoveAction)
                {
                    if (Utility.IsFileAllowed(path))
                    {
                        ALLOWED_FILES_CACHE.Add(Path.GetFullPath(path));
                    }

                    if (!string.IsNullOrEmpty(oldFile))
                    {
                        ALLOWED_FILES_CACHE.Remove(Path.GetFullPath(oldFile));
                    }
                }
                else
                {
                    if (Utility.IsFileAllowed(path))
                    {
                        ALLOWED_FILES_CACHE.Add(Path.GetFullPath(path));
                    }
                }
            };

            foreach (string path in deletedAssets)
            {
                Utility.Log("deleting " + path);
                action(path, "delete", true);
            }

            for (int i = 0; i < movedAssets.Length; i++)
            {
                Utility.Log(string.Format("move {0} to {1}", movedFromAssetPaths[i], movedAssets[i]));
                action(movedAssets[i], "rename", true, movedFromAssetPaths[i]);
            }

            foreach (string path in importedAssets)
            {
                Utility.Log("chaning " + path);
                action(path, "change", false);
            }

            Utility.Log("hasCSFileChanged = " + hasCSFileChanged);

            if (hasCSFileChanged)
            {
#if !DISABLE_UCE_ASSOCIATION
                FileWatcher.SyncSolution();
#else
                FileWatcher.SendSyncProjectRequests();
#endif
            }

            File.WriteAllLines(PathManager.GetGoToFileCachePath(), ALLOWED_FILES_CACHE.ToArray());
        }