Example #1
0
 public static void configureASPrinter(ASPrettyPrinter printer, Settings settings)
 {
     Boolean useTabs = PluginBase.Settings.UseTabs;
     Int32 tabSize = PluginBase.Settings.TabWidth;
     Int32 spaceSize = PluginBase.Settings.IndentSize;
     Int32 braceStyle = PluginBase.Settings.CodingStyle == CodingStyle.BracesOnLine ? 4 : 5;
     printer.setIndentMultilineComments(settings.Pref_AS_IndentMultilineComments);
     printer.setBlankLinesBeforeFunction(settings.Pref_AS_BlankLinesBeforeFunctions);
     printer.setBlankLinesBeforeClass(settings.Pref_AS_BlankLinesBeforeClasses);
     printer.setBlankLinesBeforeControlStatement(settings.Pref_AS_BlankLinesBeforeControlStatements);
     printer.setBlankLinesBeforeImports(settings.Pref_AS_BlankLinesBeforeImportBlock);
     printer.setBlankLinesBeforeProperties(settings.Pref_AS_BlankLinesBeforeProperties);
     printer.setBlankLinesToStartFunctions(settings.Pref_AS_BlankLinesAtFunctionStart);
     printer.setBlankLinesToEndFunctions(settings.Pref_AS_BlankLinesAtFunctionEnd);
     printer.setBlockIndent(spaceSize);
     printer.setUseTabs(useTabs);
     printer.setTabSize(tabSize);
     printer.setSpacesAfterComma(settings.Pref_AS_SpacesAfterComma);
     printer.setSpacesBeforeComma(settings.Pref_AS_SpacesBeforeComma);
     printer.setCRBeforeOpenBrace(settings.Pref_AS_OpenBraceOnNewLine);
     printer.setCRBeforeCatch(settings.Pref_AS_CatchOnNewLine);
     printer.setCRBeforeElse(settings.Pref_AS_ElseOnNewLine);
     printer.setCRBeforeWhile(settings.Pref_AS_WhileOnNewLine);
     printer.setUseBraceStyleSetting(true);
     printer.setBraceStyleSetting(braceStyle);
     printer.setKeepBlankLines(settings.Pref_AS_KeepBlankLines);
     printer.setBlankLinesToKeep(settings.Pref_AS_BlankLinesToKeep);
     printer.setSpacesAroundAssignment(settings.Pref_AS_SpacesAroundAssignment);
     printer.setAdvancedSpacesAroundAssignmentInOptionalParameters(settings.Pref_AS_Tweak_SpacesAroundEqualsInOptionalParameters);
     printer.setUseAdvancedSpacesAroundAssignmentInOptionalParameters(settings.Pref_AS_Tweak_UseSpacesAroundEqualsInOptionalParameters);
     printer.setAdvancedSpacesAroundAssignmentInMetatags(settings.Pref_AS_Tweak_SpacesAroundEqualsInMetatags);
     printer.setUseAdvancedSpacesAroundAssignmentInMetatags(settings.Pref_AS_Tweak_UseSpacesAroundEqualsInMetatags);
     printer.setSpacesAroundColons(settings.Pref_AS_SpacesAroundColons);
     printer.setAdvancedSpacesAfterColonsInDeclarations(settings.Pref_AS_AdvancedSpacesAfterColonsInDeclarations);
     printer.setAdvancedSpacesBeforeColonsInDeclarations(settings.Pref_AS_AdvancedSpacesBeforeColonsInDeclarations);
     printer.setAdvancedSpacesAfterColonsInFunctionTypes(settings.Pref_AS_AdvancedSpacesAfterColonsInFunctionTypes);
     printer.setAdvancedSpacesBeforeColonsInFunctionTypes(settings.Pref_AS_AdvancedSpacesBeforeColonsInFunctionTypes);
     printer.setUseGlobalSpacesAroundColons(settings.Pref_AS_UseGlobalSpacesAroundColons);
     printer.setMaxLineLength(settings.Pref_AS_MaxLineLength);
     printer.setExpressionSpacesAroundSymbolicOperators(settings.Pref_AS_SpacesAroundSymbolicOperator);
     printer.setKeepElseIfOnSameLine(settings.Pref_AS_ElseIfOnSameLine);
     printer.setKeepSingleLineCommentsAtColumn1(settings.Pref_AS_KeepSLCommentsOnColumn1);
     printer.setUseLineCommentWrapping(settings.Pref_AS_UseLineCommentWrapping);
     printer.setUseMLCommentWrapping(settings.Pref_AS_UseMLCommentWrapping);
     printer.setMLCommentCollapseLines(settings.Pref_AS_MLCommentReflow);
     printer.setDocCommentCollapseLines(settings.Pref_AS_DocCommentReflow);
     printer.setMLTextOnNewLines(settings.Pref_AS_MLCommentHeaderOnSeparateLine);
     printer.setMLAsteriskMode((Int32)settings.Pref_AS_MLCommentAsteriskMode);
     printer.setUseDocCommentWrapping(settings.Pref_AS_UseDocCommentWrapping);
     printer.setDocCommentHangingIndentTabs(settings.Pref_AS_DocCommentHangingIndentTabs);
     printer.setDocCommentKeepBlankLines(settings.Pref_AS_DocCommentKeepBlankLines);
     printer.setMLCommentKeepBlankLines(settings.Pref_AS_MLCommentKeepBlankLines);
     printer.setKeepSingleLineFunctions(settings.Pref_AS_LeaveSingleLineFunctions);
     printer.setNoIndentForTerminators(settings.Pref_AS_UnindentExpressionTerminators);
     printer.setNoCRBeforeBreak(settings.Pref_AS_NoNewCRsBeforeBreak);
     printer.setNoCRBeforeContinue(settings.Pref_AS_NoNewCRsBeforeContinue);
     printer.setNoCRBeforeReturn(settings.Pref_AS_NoNewCRsBeforeReturn);
     printer.setNoCRBeforeThrow(settings.Pref_AS_NoNewCRsBeforeThrow);
     printer.setNoCRBeforeExpressions(settings.Pref_AS_NoNewCRsBeforeExpression);
     printer.setKeepRelativeCommentIndent(settings.Pref_AS_KeepRelativeIndentInDocComments);
     printer.setSpacesInsideParensEtc(settings.Pref_AS_SpacesInsideParens);
     printer.setUseSpacesInsideParensEtc(settings.Pref_AS_UseGlobalSpacesInsideParens);
     printer.setHangingIndentTabs(settings.Pref_AS_TabsInHangingIndent);
     printer.setAdvancedSpacesInsideArrayDeclBrackets(settings.Pref_AS_AdvancedSpacesInsideArrayDeclBrackets);
     printer.setAdvancedSpacesInsideArrayReferenceBrackets(settings.Pref_AS_AdvancedSpacesInsideArrayRefBrackets);
     printer.setAdvancedSpacesInsideObjectBraces(settings.Pref_AS_AdvancedSpacesInsideLiteralBraces);
     printer.setAdvancedSpacesInsideParensInOtherPlaces(settings.Pref_AS_AdvancedSpacesInsideParensInOtherPlaces);
     printer.setAdvancedSpacesInsideParensInParameterLists(settings.Pref_AS_AdvancedSpacesInsideParensInParameterLists);
     printer.setAdvancedSpacesInsideParensInArgumentLists(settings.Pref_AS_AdvancedSpacesInsideParensInArgumentLists);
     printer.setSpacesBetweenControlKeywordsAndParens(settings.Pref_AS_SpacesBeforeOpenControlParen);
     printer.setSpacesBeforeFormalParameters(settings.Pref_AS_SpacesBeforeFormalParameters);
     printer.setSpacesBeforeArguments(settings.Pref_AS_SpacesBeforeArguments);
     printer.setAlwaysGenerateIndent(settings.Pref_AS_AlwaysGenerateIndent);
     printer.setUseGNUBraceIndent(settings.Pref_AS_UseGnuBraceIndent);
     printer.setLoopBraceMode(settings.Pref_AS_EnsureLoopsHaveBraces ? ASPrettyPrinter.Braces_AddIfMissing : ASPrettyPrinter.Braces_NoModify);
     printer.setLoopBraceMode(settings.Pref_AS_AddBracesToLoops);
     printer.setSwitchBraceMode(settings.Pref_AS_EnsureSwitchCasesHaveBraces ? ASPrettyPrinter.Braces_AddIfMissing : ASPrettyPrinter.Braces_NoModify);
     printer.setSwitchBraceMode(settings.Pref_AS_AddBracesToCases);
     printer.setConditionalBraceMode(settings.Pref_AS_EnsureConditionalsHaveBraces ? ASPrettyPrinter.Braces_AddIfMissing : ASPrettyPrinter.Braces_NoModify);
     printer.setConditionalBraceMode(settings.Pref_AS_AddBracesToConditionals);
     printer.setIndentAtPackageLevel(!settings.Pref_AS_DontIndentPackageItems);
     printer.setIndentSwitchCases(!settings.Pref_AS_DontIndentSwitchCases);
     printer.setKeepingExcessDeclWhitespace(settings.Pref_AS_LeaveExtraWhitespaceAroundVarDecls);
     printer.setAlignDeclEquals(settings.Pref_AS_AlignDeclEquals);
     printer.setAlignDeclMode((Int32)settings.Pref_AS_AlignDeclMode);
     printer.setKeepSpacesBeforeLineComments(settings.Pref_AS_KeepSpacesBeforeLineComments);
     printer.setLineCommentColumn(settings.Pref_AS_AlignLineCommentsAtColumn);
     printer.setUseGlobalNewlineBeforeBraceSetting(settings.Pref_AS_UseGlobalCRBeforeBrace);
     printer.setAdvancedNewlineBeforeBraceSettings(settings.Pref_AS_AdvancedCRBeforeBraceSettings);
     printer.setCollapseSpaceForAdjacentParens(settings.Pref_AS_CollapseSpacesForAdjacentParens);
     //printer.setNewlineAfterBindable(settings.Pref_AS_NewlineAfterBindable);
     printer.setNewlineBeforeBindableFunction(settings.Pref_AS_NewlineBeforeBindableFunction);
     printer.setNewlineBeforeBindableProperty(settings.Pref_AS_NewlineBeforeBindableProperty);
     List<String> tags = new List<String>();
     tags.AddRange(settings.Pref_AS_MetaTagsOnSameLineAsTargetFunction.Split(','));
     printer.setMetaTagsToKeepOnSameLineAsFunction(tags);
     tags.Clear();
     tags.AddRange(settings.Pref_AS_MetaTagsOnSameLineAsTargetProperty.Split(','));
     printer.setMetaTagsToKeepOnSameLineAsProperty(tags);
     printer.setTrimTrailingWS(settings.Pref_AS_TrimTrailingWhitespace);
     printer.setSpacesAfterLabel(settings.Pref_AS_SpacesAfterLabel);
     printer.setEmptyStatementsOnNewLine(settings.Pref_AS_PutEmptyStatementsOnNewLine);
     printer.setUseAdvancedWrapping(settings.Pref_AS_UseAdvancedWrapping);
     printer.setAdvancedWrappingElements(settings.Pref_AS_AdvancedWrappingElements);
     printer.setAdvancedWrappingEnforceMax(settings.Pref_AS_AdvancedWrappingEnforceMax);
     printer.setWrapAllArgumentsIfAny(settings.Pref_AS_AdvancedWrappingAllArgs);
     printer.setWrapAllParametersIfAny(settings.Pref_AS_AdvancedWrappingAllParms);
     printer.setWrapFirstArgument(settings.Pref_AS_AdvancedWrappingFirstArg);
     printer.setWrapFirstParameter(settings.Pref_AS_AdvancedWrappingFirstParm);
     printer.setWrapFirstArrayItem(settings.Pref_AS_AdvancedWrappingFirstArrayItem);
     printer.setWrapFirstObjectItem(settings.Pref_AS_AdvancedWrappingFirstObjectItem);
     printer.setWrapAllArrayItemsIfAny(settings.Pref_AS_AdvancedWrappingAllArrayItems);
     printer.setWrapAllObjectItemsIfAny(settings.Pref_AS_AdvancedWrappingAllObjectItems);
     printer.setWrapArrayItemsAlignStart(settings.Pref_AS_AdvancedWrappingAlignArrayItems);
     printer.setWrapObjectItemsAlignStart(settings.Pref_AS_AdvancedWrappingAlignObjectItems);
     printer.setAdvancedWrappingGraceColumns(settings.Pref_AS_AdvancedWrappingGraceColumns);
     printer.setAdvancedWrappingPreservePhrases(settings.Pref_AS_AdvancedWrappingPreservePhrases);
     bool breakBeforeComma = settings.Pref_AS_BreakLinesBeforeComma;
     bool breakBeforeArithmetic = settings.Pref_AS_BreakLinesBeforeArithmetic;
     bool breakBeforeLogical = settings.Pref_AS_BreakLinesBeforeLogical;
     bool breakBeforeAssign = settings.Pref_AS_BreakLinesBeforeAssignment;
     int wrapIndentStyle = (Int32)settings.Pref_AS_WrapIndentStyle;
     WrapOptions options = new WrapOptions((Int32)settings.Pref_AS_WrapArrayDeclMode);
     options.setBeforeSeparator(breakBeforeComma);
     options.setBeforeArithmeticOperator(breakBeforeArithmetic);
     options.setBeforeLogicalOperator(breakBeforeLogical);
     options.setBeforeAssignmentOperator(breakBeforeAssign);
     options.setIndentStyle(wrapIndentStyle);
     printer.setArrayInitWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapMethodCallMode);
     options.setBeforeSeparator(breakBeforeComma);
     options.setBeforeArithmeticOperator(breakBeforeArithmetic);
     options.setBeforeLogicalOperator(breakBeforeLogical);
     options.setBeforeAssignmentOperator(breakBeforeAssign);
     options.setIndentStyle(wrapIndentStyle);
     printer.setMethodCallWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapMethodDeclMode);
     options.setBeforeSeparator(breakBeforeComma);
     options.setIndentStyle(wrapIndentStyle);
     printer.setMethodDeclWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapExpressionMode);
     options.setBeforeSeparator(breakBeforeComma);
     options.setBeforeArithmeticOperator(breakBeforeArithmetic);
     options.setBeforeLogicalOperator(breakBeforeLogical);
     options.setBeforeAssignmentOperator(breakBeforeAssign);
     options.setIndentStyle(wrapIndentStyle);
     printer.setExpressionWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapXMLMode);
     options.setBeforeSeparator(breakBeforeComma);
     options.setBeforeArithmeticOperator(breakBeforeArithmetic);
     options.setBeforeLogicalOperator(breakBeforeLogical);
     options.setBeforeAssignmentOperator(breakBeforeAssign);
     options.setIndentStyle(wrapIndentStyle);
     printer.setXMLWrapOptions(options);
 }
Example #2
0
 public static void ConfigureASPrinter(ASPrettyPrinter printer, Settings settings, int tabSize)
 {
     printer.SetIndentMultilineComments(settings.Pref_AS_IndentMultilineComments);
     printer.SetBlankLinesBeforeFunction(settings.Pref_AS_BlankLinesBeforeFunctions);
     printer.SetBlankLinesBeforeClass(settings.Pref_AS_BlankLinesBeforeClasses);
     printer.SetBlankLinesBeforeControlStatement(settings.Pref_AS_BlankLinesBeforeControlStatements);
     printer.SetBlankLinesBeforeProperties(settings.Pref_AS_BlankLinesBeforeProperties);
     printer.SetBlockIndent(tabSize);
     printer.SetUseTabs(settings.Pref_Flex_UseTabs);
     printer.SetTabSize(tabSize);
     printer.SetSpacesAfterComma(settings.Pref_AS_SpacesAfterComma);
     printer.SetSpacesBeforeComma(settings.Pref_AS_SpacesBeforeComma);
     printer.SetCRBeforeOpenBrace(settings.Pref_AS_OpenBraceOnNewLine);
     printer.SetCRBeforeCatch(settings.Pref_AS_CatchOnNewLine);
     printer.SetCRBeforeElse(settings.Pref_AS_ElseOnNewLine);
     printer.SetUseBraceStyleSetting(settings.Pref_AS_UseBraceStyle);
     printer.SetBraceStyleSetting((Int32)settings.Pref_AS_BraceStyle);
     printer.SetKeepBlankLines(settings.Pref_AS_KeepBlankLines);
     printer.SetBlankLinesToKeep(settings.Pref_AS_BlankLinesToKeep);
     printer.SetSpacesAroundAssignment(settings.Pref_AS_SpacesAroundAssignment);
     printer.SetAdvancedSpacesAroundAssignmentInOptionalParameters(settings.Pref_AS_Tweak_SpacesAroundEqualsInOptionalParameters);
     printer.SetUseAdvancedSpacesAroundAssignmentInOptionalParameters(settings.Pref_AS_Tweak_UseSpacesAroundEqualsInOptionalParameters);
     printer.SetSpacesAroundColons(settings.Pref_AS_SpacesAroundColons);
     printer.SetAdvancedSpacesAfterColons(settings.Pref_AS_AdvancedSpacesAfterColons);
     printer.SetAdvancedSpacesBeforeColons(settings.Pref_AS_AdvancedSpacesBeforeColons);
     printer.SetUseGlobalSpacesAroundColons(settings.Pref_AS_UseGlobalSpacesAroundColons);
     printer.SetMaxLineLength(settings.Pref_AS_MaxLineLength);
     printer.SetExpressionSpacesAroundSymbolicOperators(settings.Pref_AS_SpacesAroundSymbolicOperator);
     printer.SetKeepElseIfOnSameLine(settings.Pref_AS_ElseIfOnSameLine);
     printer.SetKeepSingleLineCommentsAtColumn1(settings.Pref_AS_KeepSLCommentsOnColumn1);
     printer.SetSpacesInsideParensEtc(settings.Pref_AS_SpacesInsideParens);
     printer.SetUseSpacesInsideParensEtc(settings.Pref_AS_UseGlobalSpacesInsideParens);
     printer.SetAdvancedSpacesInsideArrayDeclBrackets(settings.Pref_AS_AdvancedSpacesInsideArrayDeclBrackets);
     printer.SetAdvancedSpacesInsideArrayReferenceBrackets(settings.Pref_AS_AdvancedSpacesInsideArrayRefBrackets);
     printer.SetAdvancedSpacesInsideObjectBraces(settings.Pref_AS_AdvancedSpacesInsideLiteralBraces);
     printer.SetAdvancedSpacesInsideParens(settings.Pref_AS_AdvancedSpacesInsideParens);
     printer.SetSpacesBetweenControlKeywordsAndParens(settings.Pref_AS_SpacesBeforeOpenControlParen);
     printer.SetAlwaysGenerateIndent(settings.Pref_AS_AlwaysGenerateIndent);
     printer.SetIndentAtPackageLevel(!settings.Pref_AS_DontIndentPackageItems);
     printer.SetKeepingExcessDeclWhitespace(settings.Pref_AS_LeaveExtraWhitespaceAroundVarDecls);
     printer.SetCollapseSpaceForAdjacentParens(settings.Pref_AS_CollapseSpacesForAdjacentParens);
     printer.SetNewlineAfterBindable(settings.Pref_AS_NewlineAfterBindable);
     printer.SetTrimTrailingWS(settings.Pref_AS_TrimTrailingWhitespace);
     printer.SetSpacesAfterLabel(settings.Pref_AS_SpacesAfterLabel);
     printer.SetEmptyStatementsOnNewLine(settings.Pref_AS_PutEmptyStatementsOnNewLine);
     bool breakBeforeComma = settings.Pref_AS_BreakLinesBeforeComma;
     int wrapIndentStyle = (Int32)settings.Pref_AS_WrapIndentStyle;
     WrapOptions options = new WrapOptions((Int32)settings.Pref_AS_WrapArrayDeclMode);
     options.BeforeSeparator = breakBeforeComma;
     options.IndentStyle = wrapIndentStyle;
     printer.SetArrayInitWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapMethodCallMode);
     options.BeforeSeparator = breakBeforeComma;
     options.IndentStyle = wrapIndentStyle;
     printer.SetMethodCallWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapMethodDeclMode);
     options.BeforeSeparator = breakBeforeComma;
     options.IndentStyle = wrapIndentStyle;
     printer.SetMethodDeclWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapExpressionMode);
     options.BeforeSeparator = breakBeforeComma;
     options.IndentStyle = wrapIndentStyle;
     printer.SetExpressionWrapOptions(options);
     options = new WrapOptions((Int32)settings.Pref_AS_WrapXMLMode);
     options.BeforeSeparator = breakBeforeComma;
     options.IndentStyle = wrapIndentStyle;
     printer.SetXMLWrapOptions(options);
 }
 public void setXMLWrapOptions(WrapOptions wrapOptions) {
     mXMLWrapOptions = wrapOptions;
 }
 private void initSettings()
 {
     mBlockIndent=3;
     mCRBeforeOpenBrace=true;
     mDoFormat=true;
     mArrayInitWrapOptions=new WrapOptions(WrapOptions.WRAP_NONE);
     mMethodCallWrapOptions=new WrapOptions(WrapOptions.WRAP_NONE);
     mMethodDeclWrapOptions=new WrapOptions(WrapOptions.WRAP_NONE);
     mExpressionWrapOptions=new WrapOptions(WrapOptions.WRAP_NONE);
     mXMLWrapOptions=new WrapOptions(WrapOptions.WRAP_DONT_PROCESS);
     mAdvancedNewlineBeforeBraceSettings=0;
     mMetaTagsToKeepOnSameLineAsProperty=new List<String>();
     mMetaTagsToKeepOnSameLineAsFunction=new List<String>();
     mAllowMultiplePasses=true;
 }
 public void setMethodDeclWrapOptions(WrapOptions methodDeclWrapOptions) {
     mMethodDeclWrapOptions = methodDeclWrapOptions;
 }
 public void setExpressionWrapOptions(WrapOptions expressionWrapOptions) {
     mExpressionWrapOptions = expressionWrapOptions;
 }
Example #7
0
    	private bool EmitCommaWithSpacingAndCRs(WrapOptions options, CommonToken comma, bool pushedIndent)
    	{
    		if ((options.WrapType==WrapOptions.WRAP_BY_COLUMN || options.WrapType==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS) && options.BeforeSeparator)
    		{
    			InsertMaxColumnCR();
    		}

    		if (!pushedIndent)
    		{
    			pushedIndent=true;
    			PushExpressionIndent();
    		}

    		InsertWS(mPrinter.GetSpacesBeforeComma());
    		Emit(comma); 
    		if ((options.WrapType==WrapOptions.WRAP_BY_COLUMN || options.WrapType==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS) && !options.BeforeSeparator)
    		{
    			InsertMaxColumnCR();
    		}
    		InsertWS(mPrinter.GetSpacesAfterComma());
    		return pushedIndent;
    	}
 public void setArrayInitWrapOptions(WrapOptions arrayInitWrapOptions) {
     mArrayInitWrapOptions = arrayInitWrapOptions;
 }
Example #9
0
    	private bool PushFormatType(WrapOptions options, bool lazy)
    	{
    		if (mPrinter.IsDoFormat())
    		{
    			int formatMode=0;
    			if (options.WrapType==WrapOptions.WRAP_DONT_PROCESS)
    			{
    				formatMode=ASPrettyPrinter.FORMAT_INDENT;
    			}
    			else if (options.WrapType==WrapOptions.WRAP_FORMAT_NO_CRs)
    			{
    				formatMode=ASPrettyPrinter.FORMAT_NOCRs;
    			}
    			else if (options.WrapType==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS)
    			{
    				formatMode=ASPrettyPrinter.FORMAT_OnlyAddCRs;
    			}
    			else
    			{
    				//if we didn't have a restrictive format, we want to make sure we're using the full format
    				formatMode=ASPrettyPrinter.FORMAT_ALL;
    			}

    			if (formatMode>0)
    			{		
    				mPrinter.SetFirstTokenBeforeFormatIndent();
    				if (lazy)
    					mPrinter.PushLazyFormat(formatMode);
    				else
    					mPrinter.PushFormatMode(formatMode);
    				return true;
    			}

    		} 

    		return false;
    	}
Example #10
0
    	private void EmitCRForTag(WrapOptions options)
    	{
    		if (options.WrapType==WrapOptions.WRAP_BY_COLUMN || options.WrapType==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS)
    		{
    			InsertMaxColumnCR();
    		}
    		else if (options.WrapType==WrapOptions.WRAP_BY_TAG)
    		{
    			InsertCR(false);
    		}

    	}
 private void InitSettings()
 {
     mBlockIndent = 3;
     mCRBeforeOpenBrace = true;
     mDoFormat = true;
     mArrayInitWrapOptions = new WrapOptions(WrapOptions.WRAP_NONE);
     mMethodCallWrapOptions = new WrapOptions(WrapOptions.WRAP_NONE);
     mMethodDeclWrapOptions = new WrapOptions(WrapOptions.WRAP_NONE);
     mExpressionWrapOptions = new WrapOptions(WrapOptions.WRAP_NONE);
     mXMLWrapOptions = new WrapOptions(WrapOptions.WRAP_DONT_PROCESS);
 }
 public void SetMethodCallWrapOptions(WrapOptions methodCallWrapOptions)
 {
     mMethodCallWrapOptions = methodCallWrapOptions;
 }
Example #13
0
 private bool emitCommaWithSpacingAndCRs(WrapOptions options, IToken comma, bool pushedIndent, int firstParmLocation, String contextType)
 {
     if ((options.getWrapType()==WrapOptions.WRAP_BY_COLUMN || options.getWrapType()==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS) && options.isBeforeSeparator())
     {
         insertMaxColumnCR();
     }
     
     if (!pushedIndent)
     {
         pushedIndent=true;
         pushExpressionIndent();
     }
     
     insertWS(mPrinter.getSpacesBeforeComma());
     emit(comma); 
     if ((options.getWrapType()==WrapOptions.WRAP_BY_COLUMN || options.getWrapType()==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS) && !options.isBeforeSeparator())
     {
         insertMaxColumnCR();
     }
     if ((options.getWrapType()==WrapOptions.WRAP_BY_COLUMN || options.getWrapType()==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS))
     {
         mPrinter.saveWrapChar(comma, ASPrettyPrinter.Break_Commas_code, options.isBeforeSeparator(), options.getIndentStyle()==WrapOptions.WRAP_STYLE_INDENT_TO_WRAP_ELEMENT, firstParmLocation, contextType);
     }
     insertWS(mPrinter.getSpacesAfterComma());
     return pushedIndent;
 }
Example #14
0
    private bool pushFormatType(WrapOptions options, bool lazy)
    {
        if (mPrinter.isDoFormat())
        {
            int formatMode=0;
            if (options.getWrapType()==WrapOptions.WRAP_DONT_PROCESS)
            {
                formatMode=ASPrettyPrinter.FORMAT_INDENT;
            }
            else if (options.getWrapType()==WrapOptions.WRAP_FORMAT_NO_CRs)
            {
                formatMode=ASPrettyPrinter.FORMAT_NOCRs;
            }
            else if (options.getWrapType()==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS)
            {
                formatMode=ASPrettyPrinter.FORMAT_OnlyAddCRs;
            }
            else
            {
                //if we didn't have a restrictive format, we want to make sure we're using the full format
                formatMode=ASPrettyPrinter.FORMAT_ALL;
            }

            if (formatMode>0)
            {
    //          if (formatMode==mPrinter.getFormatMode())
    //              return false; //no need to nest format modes of the same type
                    
                if (lazy)
                    mPrinter.pushLazyFormat(formatMode);
                else
                    mPrinter.pushFormatMode(formatMode);
                return true;
            }
            
        } 
        
        return false;
    }
Example #15
0
 private bool pushWrapInfo(WrapOptions options, bool newLevel)
 {
     if (mPrinter.isDoFormat())
     {
         if (options.getWrapType()==WrapOptions.WRAP_BY_COLUMN_ONLY_ADD_CRS || options.getWrapType()==WrapOptions.WRAP_BY_COLUMN)
         {
             mPrinter.createWrapContext(newLevel);
             return true;
         }
     }
     
     return false;
 }