示例#1
0
        public static void configureMXMLPrinter(MXMLPrettyPrinter printer, Settings settings)
        {
            Boolean useTabs   = PluginBase.Settings.UseTabs;
            Int32   tabSize   = PluginBase.Settings.TabWidth;
            Int32   spaceSize = PluginBase.Settings.IndentSize;

            printer.setAttrSortMode((Int32)settings.Pref_MXML_SortAttrMode);
            printer.setIndentAmount(spaceSize);
            printer.setUseTabs(useTabs);
            printer.setTabSize(tabSize);
            printer.setTabSize(tabSize);
            printer.setIndentAmount(tabSize);
            printer.setSortOtherAttrs(settings.Pref_MXML_SortExtraAttrs);
            printer.setSpacesAroundEquals(settings.Pref_MXML_SpacesAroundEquals);
            printer.setSpacesBeforeEmptyTagEnd(settings.Pref_MXML_SpacesBeforeEmptyTagEnd);
            printer.setKeepBlankLines(settings.Pref_MXML_KeepBlankLines);
            printer.setKeepRelativeCommentIndent(settings.Pref_MXML_KeepRelativeIndentInMultilineComments);
            printer.setBlankLinesBeforeComments(settings.Pref_MXML_BlankLinesBeforeComments);
            printer.setBlankLinesBeforeTags(settings.Pref_MXML_BlankLinesBeforeTags);
            printer.setBlankLinesAfterSpecificParentTags(settings.Pref_MXML_BlankLinesAfterSpecificParentTags);
            printer.setSpacesBetweenSiblingTags(settings.Pref_MXML_BlankLinesBetweenSiblingTags);
            printer.setSpacesAfterParentTags(settings.Pref_MXML_BlankLinesAfterParentTags);
            printer.setBlankLinesBeforeCloseTags(settings.Pref_MXML_BlankLinesBeforeClosingTags);
            printer.setWrapStyle((Int32)settings.Pref_MXML_WrapIndentStyle);
            printer.setHangingIndentTabs(settings.Pref_MXML_TabsInHangingIndent);
            printer.setUseSpacesInsideAttrBraces(settings.Pref_MXML_UseSpacesInsideAttributeBraces);
            printer.setFormatBoundAttributes(settings.Pref_MXML_UseFormattingOfBoundAttributes);
            printer.setSpacesInsideAttrBraces(settings.Pref_MXML_SpacesInsideAttributeBraces);
            printer.setCDATAIndentTabs(settings.Pref_MXML_ScriptCDataIndentTabs);
            printer.setScriptIndentTabs(settings.Pref_MXML_ScriptIndentTabs);
            printer.setBlankLinesAtCDataStart(settings.Pref_MXML_BlankLinesAtCDataStart);
            printer.setBlankLinesAtCDataEnd(settings.Pref_MXML_BlankLinesAtCDataStart);
            printer.setKeepCDataOnSameLine(settings.Pref_MXML_KeepScriptCDataOnSameLine);
            printer.setMaxLineLength(settings.Pref_MXML_MaxLineLength);
            printer.setWrapMode((Int32)settings.Pref_MXML_AttrWrapMode);
            printer.setAttrsPerLine(settings.Pref_MXML_AttrsPerLine);
            printer.setAddNewlineAfterLastAttr(settings.Pref_MXML_AddNewlineAfterLastAttr);
            printer.setIndentCloseTag(settings.Pref_MXML_IndentTagClose);
            printer.setUseAttrsToKeepOnSameLine(settings.Pref_MXML_UseAttrsToKeepOnSameLine);
            printer.setRequireCDATAForASContent(settings.Pref_MXML_RequireCDATAForASFormatting);
            printer.setAttrsToKeepOnSameLine(settings.Pref_MXML_AttrsToKeepOnSameLine);
            printer.setObeyMaxLineLength(settings.Pref_MXML_AlwaysUseMaxLineLength);
            String[]      tags   = settings.Pref_MXML_TagsCannotFormat.Split(',');
            List <String> tagSet = new List <String>();

            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.setTagsThatCannotBeFormatted(tagSet);
            tags   = settings.Pref_MXML_TagsCanFormat.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.setTagsThatCanBeFormatted(tagSet);
            tags   = settings.Pref_MXML_TagsWithBlankLinesBefore.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.setTagsWithBlankLinesBeforeThem(tagSet);
            tags   = settings.Pref_MXML_ParentTagsWithBlankLinesAfter.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.setParentTagsWithBlankLinesAfterThem(tagSet);
            tags   = settings.Pref_MXML_TagsWithASContent.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.setASScriptTags(tagSet);
            List <AttrGroup> attrGroups = new List <AttrGroup>();
            String           groupData  = settings.Pref_MXML_AttrGroups;

            String[] groups = groupData.Split(Settings.LineSplitter);
            foreach (String g in groups)
            {
                AttrGroup group = AttrGroup.load(g);
                if (group != null)
                {
                    attrGroups.Add(group);
                }
            }
            printer.setAttrGroups(attrGroups);
            printer.setUsePrivateTags(settings.Pref_MXML_UseTagsDoNotFormatInside);
            tags = settings.Pref_MXML_TagsDoNotFormatInside.Split(',');
            List <String> tagList = new List <String>();

            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagList.Add(tag);
                }
            }
            printer.setPrivateTags(tagList);
            configureASPrinter(printer.getASPrinter(), settings);
            printer.getASPrinter().setBlankLinesBeforeImports(0); //special case: we only want blank lines before imports in .as files
        }
        public static void ConfigureMXMLPrinter(MXMLPrettyPrinter printer, Settings settings, int tabSize)
        {
            printer.SetAttrSortMode((Int32)settings.Pref_MXML_SortAttrMode);
            printer.SetUseTabs(settings.Pref_Flex_UseTabs);
            printer.SetTabSize(tabSize);
            printer.SetIndentAmount(tabSize);
            List <string> sortAttrData = new List <string>();

            string[] sortAttrDataArray = settings.Pref_MXML_SortAttrData.Split('\n');
            foreach (string attr in sortAttrDataArray)
            {
                sortAttrData.Add(attr);
            }
            printer.SetManualAttrSortData(sortAttrData);
            printer.SetSortOtherAttrs(settings.Pref_MXML_SortExtraAttrs);
            printer.SetSpacesAroundEquals(settings.Pref_MXML_SpacesAroundEquals);
            printer.SetSpacesBeforeEmptyTagEnd(settings.Pref_MXML_SpacesBeforeEmptyTagEnd);
            printer.SetKeepBlankLines(settings.Pref_MXML_KeepBlankLines);
            printer.SetBlankLinesBeforeTags(settings.Pref_MXML_BlankLinesBeforeTags);
            printer.SetWrapStyle((Int32)settings.Pref_MXML_WrapIndentStyle);
            printer.SetMaxLineLength(settings.Pref_MXML_MaxLineLength);
            printer.SetWrapMode((Int32)settings.Pref_MXML_AttrWrapMode);
            printer.SetAttrsPerLine(settings.Pref_MXML_AttrsPerLine);
            printer.SetAddNewlineAfterLastAttr(settings.Pref_MXML_AddNewlineAfterLastAttr);
            printer.SetUseAttrsToKeepOnSameLine(settings.Pref_MXML_UseAttrsToKeepOnSameLine);
            printer.SetRequireCDATAForASContent(settings.Pref_MXML_RequireCDATAForASFormatting);
            printer.SetAttrsToKeepOnSameLine(settings.Pref_MXML_AttrsToKeepOnSameLine);
            String[]      tags   = settings.Pref_MXML_TagsCannotFormat.Split(',');
            List <String> tagSet = new List <String>();

            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.SetTagsThatCannotBeFormatted(tagSet);
            tags   = settings.Pref_MXML_TagsCanFormat.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.SetTagsThatCanBeFormatted(tagSet);
            tags   = settings.Pref_MXML_TagsWithBlankLinesBefore.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.SetTagsWithBlankLinesBeforeThem(tagSet);
            tags   = settings.Pref_MXML_TagsWithASContent.Split(',');
            tagSet = new List <String>();
            foreach (String tag in tags)
            {
                if (tag.Length > 0)
                {
                    tagSet.Add(tag);
                }
            }
            printer.SetASScriptTags(tagSet);
            List <AttrGroup> attrGroups = new List <AttrGroup>();
            String           groupData  = settings.Pref_MXML_AttrGroups;

            String[] groups = groupData.Split(Settings.LineSplitter);
            foreach (String g in groups)
            {
                AttrGroup group = AttrGroup.Load(g);
                if (group != null)
                {
                    attrGroups.Add(group);
                }
            }
            printer.SetAttrGroups(attrGroups);
            ConfigureASPrinter(printer.GetASPrinter(), settings, tabSize);
        }