Пример #1
0
        private void CreateAdornments(ITextDocument document, IWpfTextView textView)
        {
            string fileName = document.FilePath;

            if (Path.GetFileName(fileName) == Constants.CONFIG_FILENAME)
            {
                LogoAdornment highlighter = new LogoAdornment(textView, _isVisible, _initOpacity);
            }
            else if (Path.IsPathRooted(fileName))
            {
                try
                {
                    var item = WebCompilerPackage._dte.Solution.FindProjectItem(fileName);

                    if (item == null || item.ContainingProject == null)
                    {
                        return;
                    }

                    string configFile = item.ContainingProject.GetConfigFile();

                    if (string.IsNullOrEmpty(configFile))
                    {
                        return;
                    }

                    string extension          = Path.GetExtension(fileName.Replace(".map", ""));
                    string normalizedFilePath = fileName.Replace(".map", "").Replace(".min" + extension, extension);

                    var configs = ConfigHandler.GetConfigs(configFile);

                    foreach (Config config in configs)
                    {
                        if (GlobHelper.IsGlobPattern(config.InputFile))
                        {
                            continue;
                        }

                        if (config.GetAbsoluteOutputFile().FullName.Equals(normalizedFilePath, StringComparison.OrdinalIgnoreCase))
                        {
                            GeneratedAdornment generated = new GeneratedAdornment(textView, _isVisible, _initOpacity);
                            textView.Properties.AddProperty("generated", true);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
        }
Пример #2
0
        private void CreateAdornments(ITextDocument document, IWpfTextView textView)
        {
            string fileName = document.FilePath;

            if (Path.GetFileName(fileName) == Constants.CONFIG_FILENAME)
            {
                LogoAdornment highlighter = new LogoAdornment(textView, _isVisible, _initOpacity);
            }
            else
            {
                try
                {
                    var item = WebCompilerPackage._dte.Solution.FindProjectItem(fileName);

                    if (item == null || item.ContainingProject == null)
                        return;

                    string configFile = item.ContainingProject.GetConfigFile();

                    if (string.IsNullOrEmpty(configFile))
                        return;

                    string extension = Path.GetExtension(fileName.Replace(".map", ""));
                    string normalizedFilePath = fileName.Replace(".map", "").Replace(".min" + extension, extension);

                    var configs = ConfigHandler.GetConfigs(configFile);

                    foreach (Config config in configs)
                    {
                        if (config.GetAbsoluteOutputFile().FullName.Equals(normalizedFilePath, StringComparison.OrdinalIgnoreCase))
                        {
                            GeneratedAdornment generated = new GeneratedAdornment(textView, _isVisible, _initOpacity);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    Logger.Log(ex);
                }
            }
        }