示例#1
0
        public static void DoIndent(CodeFormattingContext context, IProgressIndicator progress, bool inTypingAssist)
        {
            var indentCache = new PsiIndentCache(context.CodeFormatter,
                                                 AlignmentTabFillStyle.USE_SPACES, new GlobalFormatSettings(true, 2));

            _indentVisitor = CreateIndentVisitor(indentCache, inTypingAssist);
            var stage = new PsiIndentingStage(inTypingAssist);
            //List<FormattingRange> nodePairs = context.SequentialEnumNodes().Where(p => context.CanModifyInsideNodeRange(p.First, p.Last)).ToList();
            List <FormattingRange> nodePairs = context.GetNodePairs().Where(p => context.CanModifyInsideNodeRange(p.First, p.Last)).ToList();
            //nodePairs.Add(new FormattingRange(null, context.FirstNode));
            IEnumerable <FormatResult <string> > indents = nodePairs.
                                                           Select(range => new FormatResult <string>(range, stage.CalcIndent(new FormattingStageContext(range)))).
                                                           Where(res => res.ResultValue != null);

            FormatterImplHelper.ForeachResult(
                indents,
                progress,
                res => res.Range.Last.MakeIndent(res.ResultValue));
        }
示例#2
0
        public static void DoIndent(PsiCodeFormattingSettings formattingSettings, CodeFormattingContext context, IProgressIndicator progress, bool inTypingAssist)
        {
            /*PsiIndentCache indentCache = new PsiIndentCache(
             * context.CodeFormatter,
             * null,
             * formattingSettings.CommonSettings.ALIGNMENT_TAB_FILL_STYLE,
             * formattingSettings.GlobalSettings); */
            PsiIndentCache indentCache = new PsiIndentCache();

            myIndentVisitor = CreateIndentVisitor(indentCache, inTypingAssist);
            var stage = new PsiIndentingStage(formattingSettings, inTypingAssist);
            List <FormattingRange> nodePairs             = context.SequentialEnumNodes().Where(p => context.CanModifyInsideNodeRange(p.First, p.Last)).ToList();
            IEnumerable <FormatResult <string> > indents = nodePairs.
                                                           Select(range => new FormatResult <string>(range, stage.CalcIndent(new FormattingStageContext(range)))).
                                                           Where(res => res.ResultValue != null);

            FormatterImplHelper.ForeachResult(
                indents,
                progress,
                res => res.Range.Last.MakeIndent(res.ResultValue));
        }