Ejemplo n.º 1
0
        public StylerService(IStylerOptions options)
        {
            this.xmlEscapingService          = new XmlEscapingService();
            this.documentManipulationService = new DocumentManipulationService(options);

            var indentService            = new IndentService(options);
            var markupExtensionFormatter = new MarkupExtensionFormatter(options.NoNewLineMarkupExtensions.ToList());
            var attributeInfoFactory     = new AttributeInfoFactory(new MarkupExtensionParser(), new AttributeOrderRules(options));
            var attributeInfoFormatter   = new AttributeInfoFormatter(markupExtensionFormatter, indentService);

            this.documentProcessors = new Dictionary <XmlNodeType, IDocumentProcessor>
            {
                // { XmlNodeType.None, null },
                { XmlNodeType.Element, new ElementDocumentProcessor(options, attributeInfoFactory, attributeInfoFormatter, indentService) },
                // { XmlNodeType.Attribute, null },
                { XmlNodeType.Text, new TextDocumentProcessor(indentService) },
                { XmlNodeType.CDATA, new CDATADocumentProcessor(indentService) },
                // { XmlNodeType.EntityReference, null },
                // { XmlNodeType.Entity, null },
                { XmlNodeType.ProcessingInstruction, new ProcessInstructionDocumentProcessor(indentService) },
                { XmlNodeType.Comment, new CommentDocumentProcessor(options, indentService) },
                // { XmlNodeType.Document, null },
                // { XmlNodeType.DocumentType, null },
                // { XmlNodeType.DocumentFragment, null },
                // { XmlNodeType.Notation, null },
                { XmlNodeType.Whitespace, new WhitespaceDocumentProcessor() },
                { XmlNodeType.SignificantWhitespace, new SignificantWhitespaceDocumentProcessor() },
                { XmlNodeType.EndElement, new EndElementDocumentProcessor(options, indentService) },
                // { XmlNodeType.EndEntity, null },
                // ignoring xml declarations for Xamarin support
                { XmlNodeType.XmlDeclaration, new XmlDeclarationDocumentProcessor() }
            };
        }
Ejemplo n.º 2
0
        public AttributeOrderRules(IStylerOptions options)
        {
            this.rules = new List <AttributeOrderRule>();

            var groupIndex = 1;

            foreach (var @group in options.AttributeOrderingRuleGroups)
            {
                if (!string.IsNullOrWhiteSpace(@group))
                {
                    int priority = 1;

                    string[] names = @group.Split(',')
                                     .Where(_ => !String.IsNullOrWhiteSpace(_))
                                     .Select(_ => _.Trim())
                                     .ToArray();

                    foreach (var name in names)
                    {
                        this.rules.Add(new AttributeOrderRule(name, groupIndex, priority));
                        priority++;
                    }
                }

                groupIndex++;
            }

            // Add catch all group at the end ensuring we always get a match;
            this.rules.Add(new AttributeOrderRule("*", groupIndex, 0));
        }
Ejemplo n.º 3
0
        public StylerService(IStylerOptions options)
        {
            _xmlEscapingService = new XmlEscapingService();
            _documentManipulationService = new DocumentManipulationService(options);

            var indentService = new IndentService(options.IndentWithTabs, options.IndentSize);
            var markupExtensionFormatter = new MarkupExtensionFormatter(options.NoNewLineMarkupExtensions.ToList());
            var attributeInfoFactory = new AttributeInfoFactory(new MarkupExtensionParser(), new AttributeOrderRules(options));
            var attributeInfoFormatter = new AttributeInfoFormatter(markupExtensionFormatter,indentService);

            _documentProcessors = new Dictionary<XmlNodeType, IDocumentProcessor>
            {
                //{XmlNodeType.None, null},
                {XmlNodeType.Element, new ElementDocumentProcessor(options, attributeInfoFactory, attributeInfoFormatter, indentService)},
                //{XmlNodeType.Attribute, null},
                {XmlNodeType.Text, new TextDocumentProcessor(indentService)},
                {XmlNodeType.CDATA, new CDATADocumentProcessor(indentService)},
                //{XmlNodeType.EntityReference, null},
                //{XmlNodeType.Entity, null},
                {XmlNodeType.ProcessingInstruction, new ProcessInstructionDocumentProcessor(indentService)},
                {XmlNodeType.Comment, new CommentDocumentProcessor(options, indentService)},
                //{XmlNodeType.Document, null},
                //{XmlNodeType.DocumentType, null},
                //{XmlNodeType.DocumentFragment, null},
                //{XmlNodeType.Notation, null},
                {XmlNodeType.Whitespace, new WhitespaceDocumentProcessor()},
                {XmlNodeType.SignificantWhitespace, new SignificantWhitespaceDocumentProcessor()},
                {XmlNodeType.EndElement, new EndElementDocumentProcessor(options,indentService)},
                //{XmlNodeType.EndEntity, null},
                //ignoring xml declarations for Xamarin support
                {XmlNodeType.XmlDeclaration, new XmlDeclarationDocumentProcessor()}
            };
        }
Ejemplo n.º 4
0
 public StylerService(IStylerOptions options, XamlLanguageOptions xamlLanguageOptions)
 {
     this.xmlEscapingService          = new XmlEscapingService();
     this.documentManipulationService = new DocumentManipulationService(options);
     this.options             = options;
     this.xamlLanguageOptions = xamlLanguageOptions;
 }
Ejemplo n.º 5
0
        public AttributeOrderRules(IStylerOptions options)
        {
            this.Rules = new List<AttributeOrderRule>();

            var groupIndex = 1;
            foreach (var @group in options.AttributeOrderingRuleGroups)
            {
                if (!String.IsNullOrWhiteSpace(@group))
                {
                    int priority = 1;

                    string[] names = @group.Split(',')
                        .Where(_ => !String.IsNullOrWhiteSpace(_))
                        .Select(_ => _.Trim())
                        .ToArray();

                    foreach (var name in names)
                    {
                        this.Rules.Add(new AttributeOrderRule(name, groupIndex, priority));
                        priority++;
                    }
                }
                groupIndex++;
            }

            // Add catch all group at the end ensuring we always get a match;
            this.Rules.Add(new AttributeOrderRule("*", groupIndex, 0));
        }
Ejemplo n.º 6
0
        public IStylerOptions GetDocumentStylerOptions(Document document)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            Properties     xamlEditorProps = this.package.IDE.Properties["TextEditor", "XAML"];
            IStylerOptions stylerOptions   = this.GetGlobalStylerOptions();

            string solutionPath = String.IsNullOrEmpty(this.package.IDE.Solution?.FullName)
                ? String.Empty
                : (stylerOptions.SearchToDriveRoot ? Path.GetPathRoot(this.package.IDE.Solution.FullName) : Path.GetDirectoryName(this.package.IDE.Solution.FullName));

            Project project    = document.ProjectItem?.ContainingProject;
            string  configPath = GetConfigPathForItem(document.Path, solutionPath, project);

            if (configPath != null)
            {
                stylerOptions            = ((StylerOptions)stylerOptions).Clone();
                stylerOptions.ConfigPath = configPath;
            }

            if (stylerOptions.UseVisualStudioIndentSize)
            {
                if (Int32.TryParse(xamlEditorProps.Item("IndentSize").Value.ToString(), out int outIndentSize) &&
                    (outIndentSize > 0))
                {
                    stylerOptions.IndentSize = outIndentSize;
                }
            }

            if (stylerOptions.UseVisualStudioIndentWithTabs)
            {
                stylerOptions.IndentWithTabs = (bool)xamlEditorProps.Item("InsertTabs").Value;
            }

            return(stylerOptions);
        }
Ejemplo n.º 7
0
        private static Func <Action> SetupExecuteContinuation(Document document, IStylerOptions stylerOptions)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            var textDocument = (TextDocument)document.Object("TextDocument");

            EditPoint startPoint = textDocument.StartPoint.CreateEditPoint();
            EditPoint endPoint   = textDocument.EndPoint.CreateEditPoint();

            string xamlSource = startPoint.GetText(endPoint);

            return(() =>
            {
                // this part can be executed in parallel.
                StylerService styler = new StylerService(stylerOptions);
                xamlSource = styler.StyleDocument(xamlSource);

                return () =>
                {
                    // this part should be executed sequentially.
                    ThreadHelper.ThrowIfNotOnUIThread();
                    const int vsEPReplaceTextKeepMarkers = 1;
                    startPoint.ReplaceText(endPoint, xamlSource, vsEPReplaceTextKeepMarkers);
                };
            });
        }
        private IStylerOptions ParseOptionsOrDefault(string optionsFilePath, IStylerOptions defaultOptions, JsonConverter deserializeConverter = null)
        {
            try
            {
                optionsFilePath = PathUtils.ToAbsolutePath(optionsFilePath);
                if (string.IsNullOrEmpty(optionsFilePath) || !File.Exists(optionsFilePath))
                {
                    return(defaultOptions);
                }

                var optionsString = File.ReadAllText(optionsFilePath);
                var converters    = deserializeConverter is null ? new JsonConverter[0] : new[] { deserializeConverter };
                var options       = JsonConvert.DeserializeObject <StylerOptions>(optionsString, converters);
                if (options.IndentSize == -1)
                {
                    // TODO Check info about IndentSize, is it necessary
                    options.IndentSize = 4;
                }

                // TODO Remove it when we will handle Indent from Visual Studio preferences
                options.IndentWithTabs |= defaultOptions.IndentWithTabs;

                return(options);
            }
            catch (Exception ex)
            {
                LoggingService.LogError("Failed to get Global XamlStyler options", ex);
                File.Delete(GlobalOptionsFilePath);
                return(defaultOptions);
            }
        }
Ejemplo n.º 9
0
 private static void Execute(Document document, IStylerOptions stylerOptions)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     if (IsFormatableDocument(document))
     {
         SetupExecuteContinuation(document, stylerOptions)()();
     }
 }
Ejemplo n.º 10
0
 public ElementDocumentProcessor(IStylerOptions options, AttributeInfoFactory attributeInfoFactory, AttributeInfoFormatter attributeInfoFormatter, IndentService indentService)
 {
     _options = options;
     _attributeInfoFactory   = attributeInfoFactory;
     _attributeInfoFormatter = attributeInfoFormatter;
     _indentService          = indentService;
     _noNewLineElementsList  = options.NoNewLineElements.ToList();
 }
 public ElementDocumentProcessor(IStylerOptions options, AttributeInfoFactory attributeInfoFactory, AttributeInfoFormatter attributeInfoFormatter, IndentService indentService)
 {
     _options = options;
     _attributeInfoFactory = attributeInfoFactory;
     _attributeInfoFormatter = attributeInfoFormatter;
     _indentService = indentService;
     _noNewLineElementsList = options.NoNewLineElements.ToList();
 }
Ejemplo n.º 12
0
 public static StylerService CreateInstance(IStylerOptions options)
 {
     var stylerServiceInstance = new StylerService { Options = options };
     stylerServiceInstance.NewlineExemptionElementsList = stylerServiceInstance.Options.NewlineExemptionElements.ToList();
     stylerServiceInstance.NoNewLineMarkupExtensionsList = stylerServiceInstance.Options.NoNewLineMarkupExtensions.ToList();
     stylerServiceInstance.OrderRules = new AttributeOrderRules(options);
     stylerServiceInstance.ElementProcessStatusStack.Clear();
     stylerServiceInstance.ElementProcessStatusStack.Push(new ElementProcessStatus());
     return stylerServiceInstance;
 }
 public DocumentManipulationService(IStylerOptions options)
 {
     _options = options;
     _processElementServices = new List<IProcessElementService>
     {
         new FormatThicknessService(_options.ThicknessStyle, _options.ThicknessAttributes),
         GetReorderGridChildrenService(),
         GetReorderCanvasChildrenService(),
         GetReorderSettersService()
     };
 }
 public DocumentManipulationService(IStylerOptions options)
 {
     _options = options;
     _processElementServices = new List <IProcessElementService>
     {
         new FormatThicknessService(_options.ThicknessStyle, _options.ThicknessAttributes),
         GetReorderGridChildrenService(),
         GetReorderCanvasChildrenService(),
         GetReorderSettersService()
     };
 }
 public void SaveGlobalOptions(IStylerOptions options)
 {
     try
     {
         var fileData = JsonConvert.SerializeObject(options, new GlobalOptionsJsonConverter());
         File.WriteAllText(GlobalOptionsFilePath, fileData);
     }
     catch (Exception ex)
     {
         LoggingService.LogError("Failed to save Global XamlStyler options", ex);
     }
 }
 public DocumentManipulationService(IStylerOptions options)
 {
     this.options = options;
     this.processElementServices = new List<IProcessElementService>
     {
         new VSMReorderService() { Mode = this.options.ReorderVSM },
         new FormatThicknessService(this.options.ThicknessStyle, this.options.ThicknessAttributes),
         this.GetReorderGridChildrenService(),
         this.GetReorderCanvasChildrenService(),
         this.GetReorderSettersService()
     };
 }
Ejemplo n.º 17
0
 public DocumentManipulationService(IStylerOptions options)
 {
     this.options = options;
     this.processElementServices = new List<IProcessElementService>
     {
         new VSMReorderService() { Mode = this.options.ReorderVSM },
         new FormatThicknessService(this.options.ThicknessStyle, this.options.ThicknessAttributes),
         this.GetReorderGridChildrenService(),
         this.GetReorderCanvasChildrenService(),
         this.GetReorderSettersService()
     };
 }
Ejemplo n.º 18
0
 public ElementDocumentProcessor(
     IStylerOptions options,
     AttributeInfoFactory attributeInfoFactory,
     AttributeInfoFormatter attributeInfoFormatter,
     IndentService indentService)
 {
     this.options = options;
     this.attributeInfoFactory   = attributeInfoFactory;
     this.attributeInfoFormatter = attributeInfoFormatter;
     this.indentService          = indentService;
     this.noNewLineElementsList  = options.NoNewLineElements.ToList();
     this.firstLineAttributes    = options.FirstLineAttributes.ToList();
 }
Ejemplo n.º 19
0
        public bool TryFormatXaml(ref string xamlText, IStylerOptions stylerOptions)
        {
            var stylerService = new StylerService(stylerOptions);
            var styledText    = stylerService.StyleDocument(xamlText);

            if (xamlText == styledText)
            {
                return(false);
            }

            xamlText = styledText;
            return(true);
        }
Ejemplo n.º 20
0
        public static StylerService CreateInstance(IStylerOptions options)
        {
            var stylerServiceInstance = new StylerService {
                Options = options
            };

            stylerServiceInstance.NewlineExemptionElementsList  = stylerServiceInstance.Options.NewlineExemptionElements.ToList();
            stylerServiceInstance.FirstLineAttributes           = stylerServiceInstance.Options.FirstLineAttributes.ToList();
            stylerServiceInstance.NoNewLineMarkupExtensionsList = stylerServiceInstance.Options.NoNewLineMarkupExtensions.ToList();
            stylerServiceInstance.OrderRules = new AttributeOrderRules(options);
            stylerServiceInstance.ElementProcessStatusStack.Clear();
            stylerServiceInstance.ElementProcessStatusStack.Push(new ElementProcessStatus());
            return(stylerServiceInstance);
        }
        public AttributeOrderRules(IStylerOptions options)
        {
            _internalDictionary = new Dictionary<string, AttributeOrderRule>();

            Populate(options.AttributeOrderWpfNamespace, AttributeTokenTypeEnum.WPF_NAMESPACE)
                .Populate(options.AttributeOrderClass, AttributeTokenTypeEnum.CLASS)
                .Populate(options.AttributeOrderKey, AttributeTokenTypeEnum.KEY)
                .Populate(options.AttributeOrderName, AttributeTokenTypeEnum.NAME)
                .Populate(options.AttributeOrderAttachedLayout, AttributeTokenTypeEnum.ATTACHED_LAYOUT)
                .Populate(options.AttributeOrderCoreLayout, AttributeTokenTypeEnum.CORE_LAYOUT)
                .Populate(options.AttributeOrderAlignmentLayout, AttributeTokenTypeEnum.ALIGNMENT_LAYOUT)
                .Populate(options.AttributeOrderOthers, AttributeTokenTypeEnum.OTHER)
                .Populate(options.AttributeOrderBlendRelated, AttributeTokenTypeEnum.BLEND_RELATED);
        }
Ejemplo n.º 22
0
        public AttributeOrderRules(IStylerOptions options)
        {
            _internalDictionary = new Dictionary <string, AttributeOrderRule>();

            Populate(options.AttributeOrderWpfNamespace, AttributeTokenTypeEnum.WPF_NAMESPACE)
            .Populate(options.AttributeOrderClass, AttributeTokenTypeEnum.CLASS)
            .Populate(options.AttributeOrderKey, AttributeTokenTypeEnum.KEY)
            .Populate(options.AttributeOrderName, AttributeTokenTypeEnum.NAME)
            .Populate(options.AttributeOrderAttachedLayout, AttributeTokenTypeEnum.ATTACHED_LAYOUT)
            .Populate(options.AttributeOrderCoreLayout, AttributeTokenTypeEnum.CORE_LAYOUT)
            .Populate(options.AttributeOrderAlignmentLayout, AttributeTokenTypeEnum.ALIGNMENT_LAYOUT)
            .Populate(options.AttributeOrderOthers, AttributeTokenTypeEnum.OTHER)
            .Populate(options.AttributeOrderBlendRelated, AttributeTokenTypeEnum.BLEND_RELATED);
        }
        public AttributeOrderRules(IStylerOptions options)
        {
            internalDictionary = new Dictionary<string, AttributeOrderRule>();

            this.Populate(options.AttributeOrderWpfNamespace, AttributeTokenInfoEnum.WpfNamespace)
                .Populate(options.AttributeOrderClass, AttributeTokenInfoEnum.Class)
                .Populate(options.AttributeOrderKey, AttributeTokenInfoEnum.Key)
                .Populate(options.AttributeOrderName, AttributeTokenInfoEnum.Name)
                .Populate(options.AttributeOrderAttachedLayout, AttributeTokenInfoEnum.AttachedLayout)
                .Populate(options.AttributeOrderCoreLayout, AttributeTokenInfoEnum.CoreLayout)
                .Populate(options.AttributeOrderAlignmentLayout, AttributeTokenInfoEnum.AlignmentLayout)
                .Populate(options.AttributeOrderOthers, AttributeTokenInfoEnum.Other)
                .Populate(options.AttributeOrderBlendRelated, AttributeTokenInfoEnum.BlendRelated);
        }
Ejemplo n.º 24
0
 private void FormatDocument(Document document, IStylerOptions stylerOptions = null)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         if (document.IsFormatable())
         {
             SetupFormatDocumentContinuation(document, stylerOptions ?? this.optionsHelper.GetDocumentStylerOptions(document))()();
         }
     }
     catch (Exception ex)
     {
         this.ShowMessageBox(ex);
     }
 }
Ejemplo n.º 25
0
 private void FormatDocument(Document document, IStylerOptions stylerOptions = null)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     try
     {
         var xamlLanguageOptions = document.GetXamlLanguageOptions();
         if (xamlLanguageOptions.IsFormatable)
         {
             SetupFormatDocumentContinuation(document, stylerOptions ?? this.optionsHelper.GetDocumentStylerOptions(document), xamlLanguageOptions)()();
         }
     }
     catch (Exception ex)
     {
         this.ShowMessageBox(ex);
     }
 }
Ejemplo n.º 26
0
        public bool TryFormatXamlDocument(Document document, IStylerOptions stylerOptions)
        {
            var textBuffer          = document.TextBuffer;
            var currentTextSnapshot = textBuffer.CurrentSnapshot;
            var xamlText            = currentTextSnapshot.GetText();

            if (!TryFormatXaml(ref xamlText, stylerOptions))
            {
                return(false);
            }

            var replaceSpan = new Span(0, currentTextSnapshot.Length);

            textBuffer.Replace(replaceSpan, xamlText);

            document.IsDirty = true;
            return(true);
        }
Ejemplo n.º 27
0
        public static StylerService CreateInstance(IStylerOptions options)
        {
            var stylerServiceInstance = new StylerService { Options = options };

            if (!String.IsNullOrEmpty(stylerServiceInstance.Options.NoNewLineElements))
            {
                stylerServiceInstance.NoNewLineElementsList = stylerServiceInstance.Options.NoNewLineElements.Split(',')
                    .Where(x => !String.IsNullOrWhiteSpace(x))
                    .Select(x => x.Trim())
                    .ToList();
            }
            stylerServiceInstance.OrderRules = new AttributeOrderRules(options);

            stylerServiceInstance._elementProcessStatusStack.Clear();
            stylerServiceInstance._elementProcessStatusStack.Push(new ElementProcessStatus());

            return stylerServiceInstance;
        }
Ejemplo n.º 28
0
        private void OnFileSave(string guid, int id, object customIn, object customOut, ref bool cancelDefault)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IStylerOptions globalOptions = this.optionsHelper.GetGlobalStylerOptions();

            if (!globalOptions.FormatOnSave)
            {
                return;
            }

            Document       document = this.IDE2.ActiveDocument;
            IStylerOptions options  = this.optionsHelper.GetDocumentStylerOptions(document);

            if (options.FormatOnSave)
            {
                this.FormatDocument(document, options);
            }
        }
Ejemplo n.º 29
0
        private void FormatDocument(ProjectItem projectItem)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            try
            {
                if (projectItem.IsFormatable())
                {
                    // Open document if not already open.
                    bool wasOpen = projectItem.IsOpen[EnvDTE.Constants.vsViewKindTextView] || projectItem.IsOpen[EnvDTE.Constants.vsViewKindCode];

                    if (!wasOpen)
                    {
                        try
                        {
                            projectItem.Open(EnvDTE.Constants.vsViewKindTextView);
                        }
                        catch (Exception)
                        {
                            // Skip if file cannot be opened.
                        }
                    }

                    Document document = projectItem.Document;
                    if (document != null)
                    {
                        document.Activate();
                        this.FormatDocument(document);

                        IStylerOptions globalOptions = this.optionsHelper.GetGlobalStylerOptions();
                        IStylerOptions options       = this.optionsHelper.GetDocumentStylerOptions(document);
                        if (!wasOpen && globalOptions.SaveAndCloseOnFormat && options.SaveAndCloseOnFormat)
                        {
                            document.Close(vsSaveChanges.vsSaveChangesYes);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                this.ShowMessageBox(ex);
            }
        }
Ejemplo n.º 30
0
        public static StylerService CreateInstance(IStylerOptions options)
        {
            var stylerServiceInstance = new StylerService {
                Options = options
            };

            if (!String.IsNullOrEmpty(stylerServiceInstance.Options.NoNewLineElements))
            {
                stylerServiceInstance.NoNewLineElementsList = stylerServiceInstance.Options.NoNewLineElements.Split(',')
                                                              .Where(x => !String.IsNullOrWhiteSpace(x))
                                                              .Select(x => x.Trim())
                                                              .ToList();
            }
            stylerServiceInstance.OrderRules = new AttributeOrderRules(options);

            stylerServiceInstance._elementProcessStatusStack.Clear();
            stylerServiceInstance._elementProcessStatusStack.Push(new ElementProcessStatus());

            return(stylerServiceInstance);
        }
Ejemplo n.º 31
0
        private void OnFileSaveAll(string guid, int id, object customIn, object customOut, ref bool cancelDefault)
        {
            ThreadHelper.ThrowIfNotOnUIThread();
            IStylerOptions globalOptions = this.optionsHelper.GetGlobalStylerOptions();

            if (!globalOptions.FormatOnSave)
            {
                return;
            }

            // Use parallel processing, but only on the documents that are formatable (to avoid the overhead of Task creating when it's not necessary).
            var jobs = new List <Func <Action> >();

            foreach (Document document in this.IDE2.Documents)
            {
                // Skip unopened documents.
                if (document.ActiveWindow != null)
                {
                    continue;
                }

                var xamlLanguageOptions = document.GetXamlLanguageOptions();
                if (xamlLanguageOptions.IsFormatable)
                {
                    IStylerOptions options = this.optionsHelper.GetDocumentStylerOptions(document);
                    if (options.FormatOnSave)
                    {
                        jobs.Add(SetupFormatDocumentContinuation(document, options, xamlLanguageOptions));
                    }
                }
            }

            // Executes job() in parallel, then execute finish() sequentially.
            foreach (Action finish in jobs.AsParallel().Select(job => job()))
            {
                finish();
            }
        }
 public EndElementDocumentProcessor(IStylerOptions options,IndentService indentService)
 {
     _indentService = indentService;
     _options = options;
 }
Ejemplo n.º 33
0
 public EndElementDocumentProcessor(IStylerOptions options, IndentService indentService)
 {
     _indentService = indentService;
     _options       = options;
 }
Ejemplo n.º 34
0
 public PackageOptions()
 {
     this.options = new StylerOptions();
 }
 public CommentDocumentProcessor(IStylerOptions options, IndentService indentService)
 {
     this.options       = options;
     this.indentService = indentService;
 }
Ejemplo n.º 36
0
 public IndentService(IStylerOptions options)
 {
     this.indentWithTabs            = options.IndentWithTabs;
     this.indentSize                = options.IndentSize;
     this.attributeIndentationStyle = options.AttributeIndentationStyle;
 }
Ejemplo n.º 37
0
 public PackageOptions()
 {
     _options = new StylerOptions();
 }
Ejemplo n.º 38
0
        private void ApplyOptionOverrides(CommandLineOptions options, IStylerOptions stylerOptions)
        {
            if (options.IndentSize != null)
            {
                stylerOptions.IndentSize = options.IndentSize.Value;
            }

            if (options.IndentWithTabs != null)
            {
                stylerOptions.IndentWithTabs = options.IndentWithTabs.Value;
            }

            if (options.AttributesTolerance != null)
            {
                stylerOptions.AttributesTolerance = options.AttributesTolerance.Value;
            }

            if (options.KeepFirstAttributeOnSameLine != null)
            {
                stylerOptions.KeepFirstAttributeOnSameLine = options.KeepFirstAttributeOnSameLine.Value;
            }

            if (options.MaxAttributeCharactersPerLine != null)
            {
                stylerOptions.MaxAttributeCharactersPerLine = options.MaxAttributeCharactersPerLine.Value;
            }

            if (options.MaxAttributesPerLine != null)
            {
                stylerOptions.MaxAttributesPerLine = options.MaxAttributesPerLine.Value;
            }

            if (options.NoNewLineElements != null)
            {
                stylerOptions.NoNewLineElements = options.NoNewLineElements;
            }

            if (options.PutAttributeOrderRuleGroupsOnSeparateLines != null)
            {
                stylerOptions.PutAttributeOrderRuleGroupsOnSeparateLines = options.PutAttributeOrderRuleGroupsOnSeparateLines.Value;
            }

            if (options.AttributeIndentation != null)
            {
                stylerOptions.AttributeIndentation = options.AttributeIndentation.Value;
            }

            if (options.AttributeIndentationStyle != null)
            {
                stylerOptions.AttributeIndentationStyle = options.AttributeIndentationStyle.Value;
            }

            if (options.RemoveDesignTimeReferences != null)
            {
                stylerOptions.RemoveDesignTimeReferences = options.RemoveDesignTimeReferences.Value;
            }

            if (options.EnableAttributeReordering != null)
            {
                stylerOptions.EnableAttributeReordering = options.EnableAttributeReordering.Value;
            }

            if (options.FirstLineAttributes != null)
            {
                stylerOptions.FirstLineAttributes = options.FirstLineAttributes;
            }

            if (options.OrderAttributesByName != null)
            {
                stylerOptions.OrderAttributesByName = options.OrderAttributesByName.Value;
            }

            if (options.PutEndingBracketOnNewLine != null)
            {
                stylerOptions.PutEndingBracketOnNewLine = options.PutEndingBracketOnNewLine.Value;
            }

            if (options.RemoveEndingTagOfEmptyElement != null)
            {
                stylerOptions.RemoveEndingTagOfEmptyElement = options.RemoveEndingTagOfEmptyElement.Value;
            }

            if (options.RootElementLineBreakRule != null)
            {
                stylerOptions.RootElementLineBreakRule = options.RootElementLineBreakRule.Value;
            }

            if (options.ReorderVSM != null)
            {
                stylerOptions.ReorderVSM = options.ReorderVSM.Value;
            }

            if (options.ReorderGridChildren != null)
            {
                stylerOptions.ReorderGridChildren = options.ReorderGridChildren.Value;
            }

            if (options.ReorderCanvasChildren != null)
            {
                stylerOptions.ReorderCanvasChildren = options.ReorderCanvasChildren.Value;
            }

            if (options.ReorderSetters != null)
            {
                stylerOptions.ReorderSetters = options.ReorderSetters.Value;
            }

            if (options.FormatMarkupExtension != null)
            {
                stylerOptions.FormatMarkupExtension = options.FormatMarkupExtension.Value;
            }

            if (options.NoNewLineMarkupExtensions != null)
            {
                stylerOptions.NoNewLineMarkupExtensions = options.NoNewLineMarkupExtensions;
            }

            if (options.ThicknessStyle != null)
            {
                stylerOptions.ThicknessStyle = options.ThicknessStyle.Value;
            }

            if (options.ThicknessAttributes != null)
            {
                stylerOptions.ThicknessAttributes = options.ThicknessAttributes;
            }

            if (options.CommentSpaces != null)
            {
                stylerOptions.CommentSpaces = options.CommentSpaces.Value;
            }
        }
Ejemplo n.º 39
0
 public PackageOptions()
 {
     this.options = new StylerOptions();
 }
Ejemplo n.º 40
0
 public PackageOptions()
 {
     _options = new StylerOptions();
 }
Ejemplo n.º 41
0
 public CommentDocumentProcessor(IStylerOptions options, IndentService indentService)
 {
     this.options = options;
     this.indentService = indentService;
 }
Ejemplo n.º 42
0
 public IndentService(IStylerOptions options)
 {
     this.indentWithTabs = options.IndentWithTabs;
     this.indentSize = options.IndentSize;
     this.attributeIndentationStyle = options.AttributeIndentationStyle;
 }