コード例 #1
0
ファイル: LessEngine.cs プロジェクト: victor-mesquita/chirpy
        public static string TransformToCss(string fullFileName, string text, EnvDTE.ProjectItem projectItem)
        {
            string   css      = null;
            Settings settings = Settings.Instance(fullFileName);

            lock (LessParser)
                using (new EnvironmentDirectory(fullFileName)) {
                    try {
                        // The built in static method doesn't throw error messages
                        dotless.Core.Parser.Infrastructure.Env env = new dotless.Core.Parser.Infrastructure.Env();
                        env.Compress = settings.DotLessCompress;
                        css          = LessParser.Parse(text, fullFileName).ToCSS(env);
                    } catch (Exception e) {
                        int   line = 1, column = 1;
                        var   description = e.Message.Trim();
                        Match match;
                        if ((match = regexLineNum.Match(description)).Success)
                        {
                            line = match.Groups[1].Value.ToInt(1);
                        }

                        if ((match = regexColNum.Match(description)).Success)
                        {
                            column = match.Groups[1].Length + 1;
                        }

                        if (TaskList.Instance == null)
                        {
                            Console.WriteLine(string.Format("{0}({1},{2}){3}", fullFileName, line.ToString(), column.ToString(), description));
                        }
                        else
                        {
                            TaskList.Instance.Add(projectItem.ContainingProject, Microsoft.VisualStudio.Shell.TaskErrorCategory.Error, fullFileName, line, column, description);
                        }
                    }
                }

            return(css);
        }
コード例 #2
0
ファイル: LessEngine.cs プロジェクト: cbilson/chirpy
        public static string TransformToCss(string fullFileName, string text, EnvDTE.ProjectItem projectItem)
        {
            string css = null;
              Settings settings = Settings.Instance(fullFileName);

              lock (LessParser)
            using (new EnvironmentDirectory(fullFileName)) {
              try {
            // The built in static method doesn't throw error messages
              dotless.Core.Parser.Infrastructure.Env env=new dotless.Core.Parser.Infrastructure.Env();
              env.Compress = settings.DotLessCompress;
              css = LessParser.Parse(text, fullFileName).ToCSS(env);
              } catch (Exception e) {
            int line = 1, column = 1;
            var description = e.Message.Trim();
            Match match;
            if ((match = regexLineNum.Match(description)).Success) {
              line = match.Groups[1].Value.ToInt(1);
            }

            if ((match = regexColNum.Match(description)).Success) {
              column = match.Groups[1].Length + 1;
            }

            if (TaskList.Instance == null) {
              Console.WriteLine(string.Format("{0}({1},{2}){3}", fullFileName, line.ToString(), column.ToString(), description));
            } else {
              TaskList.Instance.Add(projectItem.ContainingProject, Microsoft.VisualStudio.Shell.TaskErrorCategory.Error, fullFileName, line, column, description);
            }
              }
            }

              return css;
        }