Пример #1
0
        public override void VisitAccessor(Accessor accessor)
        {
            FixAttributesAndDocComment(accessor);

            base.VisitAccessor(accessor);
        }
Пример #2
0
        void FormatAccessor(Accessor accessor, BraceStyle braceStyle, PropertyFormatting blockFormatting, bool oneLine)
        {
            if (accessor.IsNull)
            {
                return;
            }
            if (!oneLine)
            {
                if (!IsLineIsEmptyUpToEol(accessor.StartLocation))
                {
                    int    offset       = this.document.GetOffset(accessor.StartLocation);
                    int    start        = SearchWhitespaceStart(offset);
                    string indentString = this.curIndent.IndentString;
                    AddChange(start, offset - start, this.options.EolMarker + indentString);
                }
                else
                {
                    FixIndentation(accessor);
                }
            }
            else
            {
                blockFormatting = PropertyFormatting.ForceOneLine;
                if (!accessor.Body.IsNull)
                {
                    ForceSpacesBeforeRemoveNewLines(accessor.Body.LBraceToken, true);
                    ForceSpacesBeforeRemoveNewLines(accessor.Body.RBraceToken, true);
                }
            }


            if (!accessor.IsNull)
            {
                if (!accessor.Body.IsNull)
                {
                    if (IsSimpleAccessor(accessor))
                    {
                        switch (blockFormatting)
                        {
                        case PropertyFormatting.AllowOneLine:
                            if (accessor.Body.LBraceToken.StartLocation.Line != accessor.Body.RBraceToken.StartLocation.Line)
                            {
                                goto case PropertyFormatting.ForceNewLine;
                            }
                            nextStatementIndent = " ";
                            VisitBlockWithoutFixingBraces(accessor.Body, policy.IndentBlocks);
                            nextStatementIndent = null;
                            if (!oneLine)
                            {
                                ForceSpacesBeforeRemoveNewLines(accessor.Body.RBraceToken, true);
                            }
                            break;

                        case PropertyFormatting.ForceOneLine:
                            FixOpenBrace(BraceStyle.EndOfLine, accessor.Body.LBraceToken);


                            var statement = accessor.Body.Statements.FirstOrDefault();
                            if (statement != null)
                            {
                                ForceSpacesBeforeRemoveNewLines(statement, true);
                                statement.AcceptVisitor(this);
                            }
                            if (!oneLine)
                            {
                                ForceSpacesBeforeRemoveNewLines(accessor.Body.RBraceToken, true);
                            }
                            break;

                        case PropertyFormatting.ForceNewLine:
                            FixOpenBrace(braceStyle, accessor.Body.LBraceToken);
                            VisitBlockWithoutFixingBraces(accessor.Body, policy.IndentBlocks);
                            if (!oneLine)
                            {
                                FixClosingBrace(braceStyle, accessor.Body.RBraceToken);
                            }
                            break;
                        }
                    }
                    else
                    {
                        FixOpenBrace(braceStyle, accessor.Body.LBraceToken);
                        VisitBlockWithoutFixingBraces(accessor.Body, policy.IndentBlocks);
                        FixClosingBrace(braceStyle, accessor.Body.RBraceToken);
                    }
                }
            }
        }
 public virtual S VisitAccessor(Accessor accessor, T data)
 {
     throw new NotImplementedException();
 }
Пример #4
0
 public virtual S VisitAccessor(Accessor accessor, T data)
 {
     return(VisitChildren(accessor, data));
 }
Пример #5
0
        protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
        {
            Accessor o = other as Accessor;

            return(o != null && !o.IsNull && this.MatchAttributesAndModifiers(o, match) && this.Body.DoMatch(o.Body, match));
        }