public override void VisitPropertyDeclaration(ICSharpCode.NRefactory.CSharp.PropertyDeclaration propertyDeclaration) { base.VisitPropertyDeclaration(propertyDeclaration); AddAccessorMethod(propertyDeclaration.Getter); AddAccessorMethod(propertyDeclaration.Setter); }
public bool CheckProperty(ICS.PropertyDeclaration node, InspectionData data) { if ((MatchKind != 0 && (MatchKind & DeclarationKinds.Property) == 0) || !CheckAttributedNode(node, ICS.Modifiers.Private)) { return(false); } string name = node.Name; if (IsValid(name)) { return(true); } data.Add(GetFixableResult(node.NameToken.StartLocation, null, name)); return(true); }
void IAstVisitor.VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { Visit(EnterPropertyDeclaration, LeavePropertyDeclaration, propertyDeclaration); }
public virtual S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data) { return(VisitChildren(propertyDeclaration, data)); }
public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { // skip }
public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { FixAttributesAndDocComment(propertyDeclaration); bool oneLine = false; bool fixClosingBrace = false; switch (policy.PropertyFormatting) { case PropertyFormatting.AllowOneLine: bool isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); int accessorLine = propertyDeclaration.RBraceToken.StartLocation.Line; if (!propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull) { accessorLine = propertyDeclaration.Getter.StartLocation.Line; } else if (propertyDeclaration.Getter.IsNull && !propertyDeclaration.Setter.IsNull) { accessorLine = propertyDeclaration.Setter.StartLocation.Line; } else { var acc = propertyDeclaration.Getter.StartLocation < propertyDeclaration.Setter.StartLocation ? propertyDeclaration.Getter : propertyDeclaration.Setter; accessorLine = acc.StartLocation.Line; } if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != accessorLine) { fixClosingBrace = true; FixOpenBrace(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken); } else { ForceSpacesBefore(propertyDeclaration.Getter, true); ForceSpacesBefore(propertyDeclaration.Setter, true); ForceSpacesBeforeRemoveNewLines(propertyDeclaration.RBraceToken, true); oneLine = true; } break; case PropertyFormatting.ForceNewLine: fixClosingBrace = true; FixOpenBrace(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken); break; case PropertyFormatting.ForceOneLine: isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); if (isSimple) { int offset = this.document.GetOffset(propertyDeclaration.LBraceToken.StartLocation); int start = SearchWhitespaceStart(offset); int end = SearchWhitespaceEnd(offset); AddChange(start, offset - start, " "); AddChange(offset + 1, end - offset - 2, " "); offset = this.document.GetOffset(propertyDeclaration.RBraceToken.StartLocation); start = SearchWhitespaceStart(offset); AddChange(start, offset - start, " "); oneLine = true; } else { fixClosingBrace = true; FixOpenBrace(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken); } break; } if (policy.IndentPropertyBody) { curIndent.Push(IndentType.Block); } ///System.Console.WriteLine ("one line: " + oneLine); if (!propertyDeclaration.Getter.IsNull) { if (!oneLine) { if (!IsLineIsEmptyUpToEol(propertyDeclaration.Getter.StartLocation)) { int offset = this.document.GetOffset(propertyDeclaration.Getter.StartLocation); int start = SearchWhitespaceStart(offset); string indentString = this.curIndent.IndentString; AddChange(start, offset - start, this.options.EolMarker + indentString); } else { FixIndentation(propertyDeclaration.Getter); } } else { int offset = this.document.GetOffset(propertyDeclaration.Getter.StartLocation); int start = SearchWhitespaceStart(offset); AddChange(start, offset - start, " "); ForceSpacesBefore(propertyDeclaration.Getter.Body.LBraceToken, true); ForceSpacesBefore(propertyDeclaration.Getter.Body.RBraceToken, true); } if (!propertyDeclaration.Getter.Body.IsNull) { if (!policy.AllowPropertyGetBlockInline || propertyDeclaration.Getter.Body.LBraceToken.StartLocation.Line != propertyDeclaration.Getter.Body.RBraceToken.StartLocation.Line) { FixOpenBrace(policy.PropertyGetBraceStyle, propertyDeclaration.Getter.Body.LBraceToken); VisitBlockWithoutFixingBraces(propertyDeclaration.Getter.Body, policy.IndentBlocks); FixClosingBrace(policy.PropertyGetBraceStyle, propertyDeclaration.Getter.Body.RBraceToken); } else { nextStatementIndent = " "; VisitBlockWithoutFixingBraces(propertyDeclaration.Getter.Body, policy.IndentBlocks); } } } if (!propertyDeclaration.Setter.IsNull) { if (!oneLine) { if (!IsLineIsEmptyUpToEol(propertyDeclaration.Setter.StartLocation)) { int offset = document.GetOffset(propertyDeclaration.Setter.StartLocation); int start = SearchWhitespaceStart(offset); string indentString = curIndent.IndentString; AddChange(start, offset - start, options.EolMarker + indentString); } else { FixIndentation(propertyDeclaration.Setter); } } else { int offset = this.document.GetOffset(propertyDeclaration.Setter.StartLocation); int start = SearchWhitespaceStart(offset); AddChange(start, offset - start, " "); ForceSpacesBefore(propertyDeclaration.Setter.Body.LBraceToken, true); ForceSpacesBefore(propertyDeclaration.Setter.Body.RBraceToken, true); } if (!propertyDeclaration.Setter.Body.IsNull) { if (!policy.AllowPropertySetBlockInline || propertyDeclaration.Setter.Body.LBraceToken.StartLocation.Line != propertyDeclaration.Setter.Body.RBraceToken.StartLocation.Line) { FixOpenBrace(policy.PropertySetBraceStyle, propertyDeclaration.Setter.Body.LBraceToken); VisitBlockWithoutFixingBraces(propertyDeclaration.Setter.Body, policy.IndentBlocks); FixClosingBrace(policy.PropertySetBraceStyle, propertyDeclaration.Setter.Body.RBraceToken); } else { nextStatementIndent = " "; VisitBlockWithoutFixingBraces(propertyDeclaration.Setter.Body, policy.IndentBlocks); } } } if (policy.IndentPropertyBody) { curIndent.Pop(); } if (fixClosingBrace) { FixClosingBrace(policy.PropertyBraceStyle, propertyDeclaration.RBraceToken); } }
public override void VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration) { FixAttributesAndDocComment(propertyDeclaration); bool oneLine = false; bool fixClosingBrace = false; PropertyFormatting propertyFormatting; if ((propertyDeclaration.Getter.IsNull || propertyDeclaration.Getter.Body.IsNull) && (propertyDeclaration.Setter.IsNull || propertyDeclaration.Setter.Body.IsNull)) { propertyFormatting = policy.AutoPropertyFormatting; } else { propertyFormatting = policy.SimplePropertyFormatting; } switch (propertyFormatting) { case PropertyFormatting.AllowOneLine: bool isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); int accessorLine = propertyDeclaration.RBraceToken.StartLocation.Line; if (!propertyDeclaration.Getter.IsNull && propertyDeclaration.Setter.IsNull) { accessorLine = propertyDeclaration.Getter.StartLocation.Line; } else if (propertyDeclaration.Getter.IsNull && !propertyDeclaration.Setter.IsNull) { accessorLine = propertyDeclaration.Setter.StartLocation.Line; } else { var acc = propertyDeclaration.Getter.StartLocation < propertyDeclaration.Setter.StartLocation ? propertyDeclaration.Getter : propertyDeclaration.Setter; accessorLine = acc.StartLocation.Line; } if (isSimple && Math.Min(propertyDeclaration.Getter.StartLocation.Line, propertyDeclaration.Setter.StartLocation.Line) == propertyDeclaration.LBraceToken.StartLocation.Line && propertyDeclaration.Getter.StartLocation.Line != propertyDeclaration.Setter.StartLocation.Line) { goto case PropertyFormatting.ForceOneLine; } if (!isSimple || propertyDeclaration.LBraceToken.StartLocation.Line != accessorLine) { fixClosingBrace = true; FixOpenBrace(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken); } else { ForceSpacesBefore(propertyDeclaration.Getter, true); ForceSpacesBefore(propertyDeclaration.Setter, true); ForceSpacesBeforeRemoveNewLines(propertyDeclaration.RBraceToken, true); oneLine = true; } break; case PropertyFormatting.ForceNewLine: fixClosingBrace = true; FixOpenBrace(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken); break; case PropertyFormatting.ForceOneLine: isSimple = IsSimpleAccessor(propertyDeclaration.Getter) && IsSimpleAccessor(propertyDeclaration.Setter); if (isSimple) { var lBraceToken = propertyDeclaration.LBraceToken; var rBraceToken = propertyDeclaration.RBraceToken; ForceSpacesBeforeRemoveNewLines(lBraceToken, true); if (!propertyDeclaration.Getter.IsNull) { ForceSpacesBeforeRemoveNewLines(propertyDeclaration.Getter, true); } if (!propertyDeclaration.Setter.IsNull) { ForceSpacesBeforeRemoveNewLines(propertyDeclaration.Setter, true); } ForceSpacesBeforeRemoveNewLines(rBraceToken, true); oneLine = true; } else { fixClosingBrace = true; FixOpenBrace(policy.PropertyBraceStyle, propertyDeclaration.LBraceToken); } break; } if (policy.IndentPropertyBody) { curIndent.Push(IndentType.Block); } FormatAccessor(propertyDeclaration.Getter, policy.PropertyGetBraceStyle, policy.SimpleGetBlockFormatting, oneLine); FormatAccessor(propertyDeclaration.Setter, policy.PropertySetBraceStyle, policy.SimpleSetBlockFormatting, oneLine); if (policy.IndentPropertyBody) { curIndent.Pop(); } if (fixClosingBrace) { FixClosingBrace(policy.PropertyBraceStyle, propertyDeclaration.RBraceToken); } }
public virtual S VisitPropertyDeclaration(PropertyDeclaration propertyDeclaration, T data) { throw new NotImplementedException(); }