Browse Source

do not print method bodies in Interfaces

newNRvisualizers
Siegfried Pammer 14 years ago
parent
commit
1e2bce63a4
  1. 11
      ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs
  2. 39
      ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

11
ICSharpCode.NRefactory.VB/OutputVisitor/OutputVisitor.cs

@ -526,6 +526,7 @@ namespace ICSharpCode.NRefactory.VB @@ -526,6 +526,7 @@ namespace ICSharpCode.NRefactory.VB
}
WriteHandlesClause(methodDeclaration.HandlesClause);
WriteImplementsClause(methodDeclaration.ImplementsClause);
if (!methodDeclaration.Body.IsNull) {
NewLine();
Indent();
WriteBlock(methodDeclaration.Body);
@ -535,6 +536,7 @@ namespace ICSharpCode.NRefactory.VB @@ -535,6 +536,7 @@ namespace ICSharpCode.NRefactory.VB
WriteKeyword("Sub");
else
WriteKeyword("Function");
}
NewLine();
return EndNode(methodDeclaration);
@ -1317,20 +1319,25 @@ namespace ICSharpCode.NRefactory.VB @@ -1317,20 +1319,25 @@ namespace ICSharpCode.NRefactory.VB
WriteAttributes(propertyDeclaration.ReturnTypeAttributes);
propertyDeclaration.ReturnType.AcceptVisitor(this, data);
}
bool needsBody = !propertyDeclaration.Getter.Body.IsNull || !propertyDeclaration.Setter.Body.IsNull;
if (needsBody) {
NewLine();
Indent();
if (!propertyDeclaration.Getter.IsNull) {
if (!propertyDeclaration.Getter.Body.IsNull) {
propertyDeclaration.Getter.AcceptVisitor(this, data);
}
if (!propertyDeclaration.Setter.IsNull) {
if (!propertyDeclaration.Setter.Body.IsNull) {
propertyDeclaration.Setter.AcceptVisitor(this, data);
}
Unindent();
WriteKeyword("End");
WriteKeyword("Property");
}
NewLine();
return EndNode(propertyDeclaration);

39
ICSharpCode.NRefactory.VB/Visitors/CSharpToVBConverterVisitor.cs

@ -1101,10 +1101,49 @@ namespace ICSharpCode.NRefactory.VB.Visitors @@ -1101,10 +1101,49 @@ namespace ICSharpCode.NRefactory.VB.Visitors
mod |= Modifiers.Friend;
if ((modifier & CSharp.Modifiers.Private) == CSharp.Modifiers.Private)
mod |= Modifiers.Private;
if (container is CSharp.IndexerDeclaration)
mod |= Modifiers.Default;
bool writeable = IsWriteableProperty(container);
bool readable = IsReadableProperty(container);
if (writeable && !readable)
mod |= Modifiers.WriteOnly;
if (readable && !writeable)
mod |= Modifiers.ReadOnly;
return mod;
}
bool IsReadableProperty(ICSharpCode.NRefactory.CSharp.AstNode container)
{
if (container is CSharp.IndexerDeclaration) {
var i = container as CSharp.IndexerDeclaration;
return !i.Getter.IsNull;
}
if (container is CSharp.PropertyDeclaration) {
var p = container as CSharp.PropertyDeclaration;
return !p.Getter.IsNull;
}
return false;
}
bool IsWriteableProperty(ICSharpCode.NRefactory.CSharp.AstNode container)
{
if (container is CSharp.IndexerDeclaration) {
var i = container as CSharp.IndexerDeclaration;
return !i.Setter.IsNull;
}
if (container is CSharp.PropertyDeclaration) {
var p = container as CSharp.PropertyDeclaration;
return !p.Setter.IsNull;
}
return false;
}
public AstNode VisitIdentifier(CSharp.Identifier identifier, object data)
{
var ident = new Identifier(identifier.Name, ConvertLocation(identifier.StartLocation));

Loading…
Cancel
Save