Skip to content

Commit

Permalink
Removed declaring type from declaration node simple name
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrei15193 committed Jul 7, 2023
1 parent f332d04 commit 5283488
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 84 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public void GettingSimpleNameReferenceForConstantDeclarationReturnsDeclaringType

var simpleNameReference = constantDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.ClassShadowedTestConstant", simpleNameReference);
Assert.Equal("ClassShadowedTestConstant", simpleNameReference);
}

[Fact]
Expand All @@ -152,7 +152,7 @@ public void GettingSimpleNameReferenceForFieldDeclarationReturnsDeclaringTypeNam

var simpleNameReference = fieldDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.StaticTestField", simpleNameReference);
Assert.Equal("StaticTestField", simpleNameReference);
}

[Fact]
Expand All @@ -170,7 +170,7 @@ public void GettingSimpleNameReferenceForConstructorDeclarationReturnsDeclaringT

var simpleNameReference = constructorDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.TestClass(int)", simpleNameReference);
Assert.Equal("TestClass(int)", simpleNameReference);
}

[Fact]
Expand All @@ -188,7 +188,7 @@ public void GettingSimpleNameReferenceForEventDeclarationReturnsDeclaringTypeNam

var simpleNameReference = eventDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.AbstractTestEvent", simpleNameReference);
Assert.Equal("AbstractTestEvent", simpleNameReference);
}

[Fact]
Expand All @@ -206,7 +206,7 @@ public void GettingSimpleNameReferenceForPropertyDeclarationReturnsDeclaringType

var simpleNameReference = propertyDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.InterfaceShadowedTestProperty", simpleNameReference);
Assert.Equal("InterfaceShadowedTestProperty", simpleNameReference);
}

[Fact]
Expand All @@ -224,7 +224,7 @@ public void GettingSimpleNameReferenceForIndexPropertyDeclarationReturnsDeclarin

var simpleNameReference = propertyDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.Item[int]", simpleNameReference);
Assert.Equal("Item[int]", simpleNameReference);
}

[Fact]
Expand All @@ -242,7 +242,7 @@ public void GettingSimpleNameReferenceForMethodDeclarationReturnsDeclaringTypeNa

var simpleNameReference = methodDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.TestMethod(int, string)", simpleNameReference);
Assert.Equal("TestMethod(int, string)", simpleNameReference);
}

[Fact]
Expand All @@ -260,7 +260,7 @@ public void GettingSimpleNameReferenceForGenericMethodDeclarationReturnsDeclarin

var simpleNameReference = methodDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.TestMethod38<TMethodParam>(TMethodParam)", simpleNameReference);
Assert.Equal("TestMethod38<TMethodParam>(TMethodParam)", simpleNameReference);
}

[Fact]
Expand All @@ -278,7 +278,7 @@ public void GettingSimpleNameReferenceForNestedEnumReturnsDeclaringTypeNameAndOw

var simpleNameReference = typeDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.NestedTestEnum", simpleNameReference);
Assert.Equal("NestedTestEnum", simpleNameReference);
}

[Fact]
Expand All @@ -296,7 +296,7 @@ public void GettingSimpleNameReferenceForNestedDelegateReturnsDeclaringTypeNameO

var simpleNameReference = typeDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.NestedTestDelegate()", simpleNameReference);
Assert.Equal("NestedTestDelegate()", simpleNameReference);
}

[Fact]
Expand All @@ -314,7 +314,7 @@ public void GettingSimpleNameReferenceForNestedInterfaceReturnsDeclaringTypeName

var simpleNameReference = typeDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.INestedTestInterface", simpleNameReference);
Assert.Equal("INestedTestInterface", simpleNameReference);
}

[Fact]
Expand All @@ -332,7 +332,7 @@ public void GettingSimpleNameReferenceForNestedInterfaceReturnsDeclaringTypeName

var simpleNameReference = typeDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.NestedTestClass<TParam2, TParam3>", simpleNameReference);
Assert.Equal("NestedTestClass<TParam2, TParam3>", simpleNameReference);
}

[Fact]
Expand All @@ -350,7 +350,7 @@ public void GettingSimpleNameReferenceForNestedRecordReturnsDeclaringTypeNameAnd

var simpleNameReference = typeDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.NestedTestRecord", simpleNameReference);
Assert.Equal("NestedTestRecord", simpleNameReference);
}

[Fact]
Expand All @@ -368,7 +368,7 @@ public void GettingSimpleNameReferenceForNestedStructReturnsDeclaringTypeNameAnd

var simpleNameReference = typeDeclaration.GetSimpleNameReference();

Assert.Equal("TestClass<TParam>.NestedTestStruct", simpleNameReference);
Assert.Equal("NestedTestStruct", simpleNameReference);
}
}
}
75 changes: 5 additions & 70 deletions CodeMap/Html/SimpleNameDeclarationNodeVisitor.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using System.Data;
using System.Linq;
using System.Text;
using CodeMap.DeclarationNodes;
Expand All @@ -10,9 +9,7 @@ internal class SimpleNameDeclarationNodeVisitor : DeclarationNodeVisitor
public StringBuilder StringBuilder { get; } = new StringBuilder();

protected internal override void VisitAssembly(AssemblyDeclaration assembly)
{
StringBuilder.Append(assembly.Name);
}
=> StringBuilder.Append(assembly.Name);

protected internal override void VisitNamespace(NamespaceDeclaration @namespace)
{
Expand All @@ -22,12 +19,6 @@ protected internal override void VisitNamespace(NamespaceDeclaration @namespace)

protected internal override void VisitInterface(InterfaceDeclaration @interface)
{
if (@interface.DeclaringType is object)
{
@interface.DeclaringType.Accept(this);
StringBuilder.Append('.');
}

StringBuilder.Append(@interface.Name);

if (@interface.GenericParameters.Any())
Expand All @@ -48,12 +39,6 @@ protected internal override void VisitInterface(InterfaceDeclaration @interface)

protected internal override void VisitClass(ClassDeclaration @class)
{
if (@class.DeclaringType is object)
{
@class.DeclaringType.Accept(this);
StringBuilder.Append('.');
}

StringBuilder.Append(@class.Name);
if (@class.GenericParameters.Any())
{
Expand All @@ -73,12 +58,6 @@ protected internal override void VisitClass(ClassDeclaration @class)

protected internal override void VisitRecord(RecordDeclaration record)
{
if (record.DeclaringType is object)
{
record.DeclaringType.Accept(this);
StringBuilder.Append('.');
}

StringBuilder.Append(record.Name);
if (record.GenericParameters.Any())
{
Expand All @@ -98,12 +77,6 @@ protected internal override void VisitRecord(RecordDeclaration record)

protected internal override void VisitStruct(StructDeclaration @struct)
{
if (@struct.DeclaringType is object)
{
@struct.DeclaringType.Accept(this);
StringBuilder.Append('.');
}

StringBuilder.Append(@struct.Name);
if (@struct.GenericParameters.Any())
{
Expand All @@ -123,12 +96,6 @@ protected internal override void VisitStruct(StructDeclaration @struct)

protected internal override void VisitDelegate(DelegateDeclaration @delegate)
{
if (@delegate.DeclaringType is object)
{
@delegate.DeclaringType.Accept(this);
StringBuilder.Append('.');
}

StringBuilder.Append(@delegate.Name);
if (@delegate.GenericParameters.Any())
{
Expand Down Expand Up @@ -161,37 +128,16 @@ protected internal override void VisitDelegate(DelegateDeclaration @delegate)
}

protected internal override void VisitEnum(EnumDeclaration @enum)
{
if (@enum.DeclaringType is object)
{
@enum.DeclaringType.Accept(this);
StringBuilder.Append('.');
}

StringBuilder.Append(@enum.Name);
}
=> StringBuilder.Append(@enum.Name);

protected internal override void VisitConstant(ConstantDeclaration constant)
{
constant.DeclaringType.Accept(this);
StringBuilder.Append('.');

StringBuilder.Append(constant.Name);
}
=> StringBuilder.Append(constant.Name);

protected internal override void VisitField(FieldDeclaration field)
{
field.DeclaringType.Accept(this);
StringBuilder.Append('.');

StringBuilder.Append(field.Name);
}
=> StringBuilder.Append(field.Name);

protected internal override void VisitConstructor(ConstructorDeclaration constructor)
{
constructor.DeclaringType.Accept(this);
StringBuilder.Append('.');

StringBuilder.Append(constructor.Name);
StringBuilder.Append('(');
var isFirst = true;
Expand All @@ -207,18 +153,10 @@ protected internal override void VisitConstructor(ConstructorDeclaration constru
}

protected internal override void VisitEvent(EventDeclaration @event)
{
@event.DeclaringType.Accept(this);
StringBuilder.Append('.');

StringBuilder.Append(@event.Name);
}
=> StringBuilder.Append(@event.Name);

protected internal override void VisitProperty(PropertyDeclaration property)
{
property.DeclaringType.Accept(this);
StringBuilder.Append('.');

StringBuilder.Append(property.Name);
if (property.Parameters.Any())
{
Expand All @@ -238,9 +176,6 @@ protected internal override void VisitProperty(PropertyDeclaration property)

protected internal override void VisitMethod(MethodDeclaration method)
{
method.DeclaringType.Accept(this);
StringBuilder.Append('.');

StringBuilder.Append(method.Name);
if (method.GenericParameters.Any())
{
Expand Down

0 comments on commit 5283488

Please sign in to comment.