public static void DoFormat(CodeFormattingContext context, IProgressIndicator pi) { if (context.FirstNode == context.LastNode) { return; } var stage = new SecretFormattingStage(context); IEnumerable<FormattingRange> nodePairs = GetNodePairs(context); IEnumerable<FormatResult<IEnumerable<string>>> spaces = nodePairs.Select( range => new FormatResult<IEnumerable<string>>(range, stage.CalcSpaces(new FormattingStageContext(range)))); FormatterImplHelper.ForeachResult(spaces, pi, res => stage.MakeFormat(res.Range, res.ResultValue)); }
public static void DoFormat(CodeFormattingContext context, IProgressIndicator pi) { if (context.FirstNode == context.LastNode) { return; } var stage = new SecretFormattingStage(context); IEnumerable <FormattingRange> nodePairs = GetNodePairs(context); IEnumerable <FormatResult <IEnumerable <string> > > spaces = nodePairs.Select( range => new FormatResult <IEnumerable <string> >(range, stage.CalcSpaces(new FormattingStageContext(range)))); FormatterImplHelper.ForeachResult(spaces, pi, res => stage.MakeFormat(res.Range, res.ResultValue)); }
public override ITreeRange Format( ITreeNode firstElement, ITreeNode lastElement, CodeFormatProfile profile, IProgressIndicator pi, IContextBoundSettingsStore overrideSettingsStore = null) { ITreeNode firstNode; ITreeNode lastNode; GetFirstAndLastNode(firstElement, lastElement, out firstNode, out lastNode); var contextBoundSettingsStore = this.GetProperContextBoundSettingsStore(overrideSettingsStore, firstNode); var globalSettings = GlobalFormatSettingsHelper .GetService(firstNode.GetSolution()) .GetSettingsForLanguage(this.myLanguage, firstNode.GetProjectFileType(), contextBoundSettingsStore); using (pi.SafeTotal(4)) { var context = new PsiCodeFormattingContext(this, firstNode, lastNode); if (profile != CodeFormatProfile.INDENT) { using (IProgressIndicator subPi = pi.CreateSubProgress(2)) { using (subPi.SafeTotal(2)) { SecretFormattingStage.DoFormat(context, subPi.CreateSubProgress(1)); SecretIndentingStage.DoIndent(context, globalSettings, subPi.CreateSubProgress(1), false); } } } else { using (IProgressIndicator subPi = pi.CreateSubProgress(4)) { SecretIndentingStage.DoIndent(context, globalSettings, subPi, true); } } } return(new TreeRange(firstElement, lastElement)); }