Skip to content

Commit f7b2643

Browse files
authored
Add support for TypeParameters and SingleVariableDesignations for C# (#33)
1 parent 2494338 commit f7b2643

File tree

15 files changed

+196
-72
lines changed

15 files changed

+196
-72
lines changed

ScipDotnet/ScipCSharpSyntaxWalker.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,16 @@ public override void VisitParameter(ParameterSyntax node)
117117
_scipDocumentIndexer.VisitOccurrence(_semanticModel.GetDeclaredSymbol(node), node.Identifier.GetLocation(), true);
118118
base.VisitParameter(node);
119119
}
120+
121+
public override void VisitSingleVariableDesignation(SingleVariableDesignationSyntax node)
122+
{
123+
_scipDocumentIndexer.VisitOccurrence(_semanticModel.GetDeclaredSymbol(node), node.Identifier.GetLocation(), true);
124+
base.VisitSingleVariableDesignation(node);
125+
}
126+
127+
public override void VisitTypeParameter(TypeParameterSyntax node)
128+
{
129+
_scipDocumentIndexer.VisitOccurrence(_semanticModel.GetDeclaredSymbol(node), node.Identifier.GetLocation(), true);
130+
base.VisitTypeParameter(node);
131+
}
120132
}

snapshots/output-net6.0/syntax/Main/Classes.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,28 @@ public partial class PartialClass
6060
class TypeParameterClass<T>
6161
// ^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#TypeParameterClass#
6262
// documentation ```cs\nclass TypeParameterClass<T>\n```
63+
// ^ definition scip-dotnet nuget . . Main/Classes#TypeParameterClass#[T]
64+
// documentation ```cs\nT\n```
6365
{
6466
}
6567

6668
internal class InternalMultipleTypeParametersClass<T1, T2>
6769
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#InternalMultipleTypeParametersClass#
6870
// documentation ```cs\nclass InternalMultipleTypeParametersClass<T1, T2>\n```
71+
// ^^ definition scip-dotnet nuget . . Main/Classes#InternalMultipleTypeParametersClass#[T1]
72+
// documentation ```cs\nT1\n```
73+
// ^^ definition scip-dotnet nuget . . Main/Classes#InternalMultipleTypeParametersClass#[T2]
74+
// documentation ```cs\nT2\n```
6975
{
7076
}
7177

7278
interface ICovariantContravariant<in T1, out T2>
7379
// ^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#
7480
// documentation ```cs\ninterface ICovariantContravariant<in T1, out T2>\n```
81+
// ^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#[T1]
82+
// documentation ```cs\nin T1\n```
83+
// ^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#[T2]
84+
// documentation ```cs\nout T2\n```
7585
{
7686
public void Method1(T1 t1)
7787
// ^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ICovariantContravariant#Method1().
@@ -97,41 +107,53 @@ public void Method1(T1 t1)
97107
public class StructConstraintClass<T> where T : struct
98108
// ^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#StructConstraintClass#
99109
// documentation ```cs\nclass StructConstraintClass<T> where T : struct\n```
110+
// ^ definition scip-dotnet nuget . . Main/Classes#StructConstraintClass#[T]
111+
// documentation ```cs\nT\n```
100112
// ^ reference scip-dotnet nuget . . Main/Classes#StructConstraintClass#[T]
101113
{
102114
}
103115

104116
public class UnmanagedConstraintClass<T> where T : unmanaged
105117
// ^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#UnmanagedConstraintClass#
106118
// documentation ```cs\nclass UnmanagedConstraintClass<T> where T : unmanaged\n```
119+
// ^ definition scip-dotnet nuget . . Main/Classes#UnmanagedConstraintClass#[T]
120+
// documentation ```cs\nT\n```
107121
// ^ reference scip-dotnet nuget . . Main/Classes#UnmanagedConstraintClass#[T]
108122
{
109123
}
110124

111125
public class ClassConstraintClass<T> where T : class
112126
// ^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#ClassConstraintClass#
113127
// documentation ```cs\nclass ClassConstraintClass<T> where T : class\n```
128+
// ^ definition scip-dotnet nuget . . Main/Classes#ClassConstraintClass#[T]
129+
// documentation ```cs\nT\n```
114130
// ^ reference scip-dotnet nuget . . Main/Classes#ClassConstraintClass#[T]
115131
{
116132
}
117133

118134
public class NonNullableConstraintClass<T> where T : notnull
119135
// ^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#NonNullableConstraintClass#
120136
// documentation ```cs\nclass NonNullableConstraintClass<T> where T : notnull\n```
137+
// ^ definition scip-dotnet nuget . . Main/Classes#NonNullableConstraintClass#[T]
138+
// documentation ```cs\nT\n```
121139
// ^ reference scip-dotnet nuget . . Main/Classes#NonNullableConstraintClass#[T]
122140
{
123141
}
124142

125143
public class NewConstraintClass<T> where T : new()
126144
// ^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#NewConstraintClass#
127145
// documentation ```cs\nclass NewConstraintClass<T> where T : new()\n```
146+
// ^ definition scip-dotnet nuget . . Main/Classes#NewConstraintClass#[T]
147+
// documentation ```cs\nT\n```
128148
// ^ reference scip-dotnet nuget . . Main/Classes#NewConstraintClass#[T]
129149
{
130150
}
131151

132152
public class TypeParameterConstraintClass<T> where T : SomeInterface
133153
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#TypeParameterConstraintClass#
134154
// documentation ```cs\nclass TypeParameterConstraintClass<T> where T : SomeInterface\n```
155+
// ^ definition scip-dotnet nuget . . Main/Classes#TypeParameterConstraintClass#[T]
156+
// documentation ```cs\nT\n```
135157
// ^ reference scip-dotnet nuget . . Main/Classes#TypeParameterConstraintClass#[T]
136158
// ^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface#
137159
{
@@ -140,6 +162,10 @@ public class TypeParameterConstraintClass<T> where T : SomeInterface
140162
private class MultipleTypeParameterConstraintsClass<T1, T2> where T1 : SomeInterface, SomeInterface2, new()
141163
// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#
142164
// documentation ```cs\nclass MultipleTypeParameterConstraintsClass<T1, T2> where T1 : SomeInterface, SomeInterface2, new() where T2 : SomeInterface2\n```
165+
// ^^ definition scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#[T1]
166+
// documentation ```cs\nT1\n```
167+
// ^^ definition scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#[T2]
168+
// documentation ```cs\nT2\n```
143169
// ^^ reference scip-dotnet nuget . . Main/Classes#MultipleTypeParameterConstraintsClass#[T1]
144170
// ^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface#
145171
// ^^^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/SomeInterface2#

snapshots/output-net6.0/syntax/Main/Expressions.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,26 +217,30 @@ void AssignmentToLeftValueTypes()
217217
// documentation ```cs\nprivate void Expressions.AssignmentToLeftValueTypes()\n```
218218
{
219219
(var a, var b) = (1, 2);
220+
// ^ definition local 9
221+
// documentation ```cs\nvar a\n```
222+
// ^ definition local 10
223+
// documentation ```cs\nvar b\n```
220224
a = 1;
221225
// ^ reference local 9
222226
var c = new Struct { Property = 42 };
223-
// ^ definition local 10
227+
// ^ definition local 11
224228
// documentation ```cs\nStruct c\n```
225229
// ^^^^^^ reference scip-dotnet nuget . . Main/Expressions#Struct#
226230
// ^^^^^^^^ reference scip-dotnet nuget . . Main/Expressions#Struct#Property.
227231
c.Property = 1;
228-
// ^ reference local 10
232+
// ^ reference local 11
229233
// ^^^^^^^^ reference scip-dotnet nuget . . Main/Expressions#Struct#Property.
230234
var d = new IndexedClass();
231-
// ^ definition local 11
235+
// ^ definition local 12
232236
// documentation ```cs\nIndexedClass d\n```
233237
// ^^^^^^^^^^^^ reference scip-dotnet nuget . . Main/Expressions#IndexedClass#
234238
d[b] = 1;
235-
// ^ reference local 11
236-
// ^ reference local 12
239+
// ^ reference local 12
240+
// ^ reference local 10
237241
(a, b) = (1, 2);
238242
// ^ reference local 9
239-
// ^ reference local 12
243+
// ^ reference local 10
240244
var x = new IndexedClass
241245
// ^ definition local 13
242246
// documentation ```cs\nIndexedClass x\n```
@@ -245,7 +249,7 @@ void AssignmentToLeftValueTypes()
245249
Property = 1,
246250
// ^^^^^^^^ reference scip-dotnet nuget . . Main/Expressions#IndexedClass#Property.
247251
[b] = 1
248-
// ^ reference local 12
252+
// ^ reference local 10
249253
};
250254
(a) = 1;
251255
// ^ reference local 9
@@ -768,10 +772,14 @@ void Switch()
768772
{
769773
Cat c => c.Sound(),
770774
// ^^^ reference scip-dotnet nuget . . Main/Expressions#Cat#
775+
// ^ definition local 75
776+
// documentation ```cs\nCat c\n```
771777
// ^ reference local 75
772778
// ^^^^^ reference scip-dotnet nuget . . Main/Expressions#Cat#Sound().
773779
Dog c => c.Sound(),
774780
// ^^^ reference scip-dotnet nuget . . Main/Expressions#Dog#
781+
// ^ definition local 76
782+
// documentation ```cs\nDog c\n```
775783
// ^ reference local 76
776784
// ^^^^^ reference scip-dotnet nuget . . Main/Expressions#Dog#Sound().
777785
_ => throw new ArgumentOutOfRangeException()
@@ -796,6 +804,8 @@ void Is()
796804
// documentation ```cs\nobject s\n```
797805
if (s is string s2)
798806
// ^ reference local 78
807+
// ^^ definition local 79
808+
// documentation ```cs\nstring s2\n```
799809
{
800810
Console.WriteLine(s2);
801811
// ^^ reference local 79

snapshots/output-net6.0/syntax/Main/GlobalAttributes.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,14 @@ public event EventHandler SomeEvent
6262
public class InnerClass<[Author("ClassTypeParameter")] T>
6363
// ^^^^^^^^^^ definition scip-dotnet nuget . . Main/GlobalAttributes#InnerClass#
6464
// documentation ```cs\nclass InnerClass<T>\n```
65+
// ^ definition scip-dotnet nuget . . Main/GlobalAttributes#InnerClass#[T]
66+
// documentation ```cs\nT\n```
6567
{
6668
void Method<[Author("MethodTypeParameter")] T2>()
6769
// ^^^^^^ definition scip-dotnet nuget . . Main/GlobalAttributes#InnerClass#Method().
6870
// documentation ```cs\nprivate void InnerClass<T>.Method<T2>()\n```
71+
// ^^ definition scip-dotnet nuget . . Main/GlobalAttributes#InnerClass#Method().[T2]
72+
// documentation ```cs\nT2\n```
6973
{
7074
}
7175
}

snapshots/output-net6.0/syntax/Main/Interfaces.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ private interface IInherit : IOne, ITwo
113113
public interface IGetNext<T> where T : IGetNext<T>
114114
// ^^^^^^^^ definition scip-dotnet nuget . . Main/Interfaces#IGetNext#
115115
// documentation ```cs\ninterface IGetNext<T> where T : IGetNext<T>\n```
116+
// ^ definition scip-dotnet nuget . . Main/Interfaces#IGetNext#[T]
117+
// documentation ```cs\nT\n```
116118
// ^ reference scip-dotnet nuget . . Main/Interfaces#IGetNext#[T]
117119
// ^ reference scip-dotnet nuget . . Main/Interfaces#IGetNext#[T]
118120
{
@@ -130,6 +132,10 @@ private interface ITypeParameter<T1, T2> : ITwo where T1 : IOne where T2 : IThre
130132
// ^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Interfaces#ITypeParameter#
131133
// documentation ```cs\ninterface ITypeParameter<T1, T2> where T1 : IOne where T2 : IThree\n```
132134
// relationship implementation scip-dotnet nuget . . Main/Interfaces#ITwo#
135+
// ^^ definition scip-dotnet nuget . . Main/Interfaces#ITypeParameter#[T1]
136+
// documentation ```cs\nT1\n```
137+
// ^^ definition scip-dotnet nuget . . Main/Interfaces#ITypeParameter#[T2]
138+
// documentation ```cs\nT2\n```
133139
// ^^^^ reference scip-dotnet nuget . . Main/Interfaces#ITwo#
134140
// ^^ reference scip-dotnet nuget . . Main/Interfaces#ITypeParameter#[T1]
135141
// ^^^^ reference scip-dotnet nuget . . Main/Interfaces#IOne#

snapshots/output-net6.0/syntax/Main/Methods.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ T Generic<T>(T param)
5858
// ^ reference scip-dotnet nuget . . Main/Methods#Generic().[T]
5959
// ^^^^^^^ definition scip-dotnet nuget . . Main/Methods#Generic().
6060
// documentation ```cs\nprivate T Methods.Generic<T>(T param)\n```
61+
// ^ definition scip-dotnet nuget . . Main/Methods#Generic().[T]
62+
// documentation ```cs\nT\n```
6163
// ^ reference scip-dotnet nuget . . Main/Methods#Generic().[T]
6264
// ^^^^^ definition scip-dotnet nuget . . Main/Methods#Generic().(param)
6365
// documentation ```cs\nT param\n```
@@ -70,6 +72,8 @@ T Generic<T>(T param)
7072
// ^ reference scip-dotnet nuget . . Main/Methods#GenericConstraint().[T]
7173
// ^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Methods#GenericConstraint().
7274
// documentation ```cs\nprivate T Methods.GenericConstraint<T>(T param) where T : new()\n```
75+
// ^ definition scip-dotnet nuget . . Main/Methods#GenericConstraint().[T]
76+
// documentation ```cs\nT\n```
7377
// ^ reference scip-dotnet nuget . . Main/Methods#GenericConstraint().[T]
7478
// ^^^^^ definition scip-dotnet nuget . . Main/Methods#GenericConstraint().(param)
7579
// documentation ```cs\nT param\n```

snapshots/output-net6.0/syntax/Main/Records.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public record TypeParameterConstraint<T> where T : struct
4242
// ^^^^^^^^^^^^^^^^^^^^^^^ definition scip-dotnet nuget . . Main/Records#TypeParameterConstraint#
4343
// documentation ```cs\nrecord TypeParameterConstraint<T> where T : struct\n```
4444
// relationship implementation scip-dotnet nuget Main 0.0.0.0 System/IEquatable#
45+
// ^ definition scip-dotnet nuget . . Main/Records#TypeParameterConstraint#[T]
46+
// documentation ```cs\nT\n```
4547
// ^ reference scip-dotnet nuget . . Main/Records#TypeParameterConstraint#[T]
4648
{
4749
}
@@ -121,6 +123,8 @@ record I3<T>;
121123
// ^^ definition scip-dotnet nuget . . Main/Records#I3#
122124
// documentation ```cs\nrecord I3<T>\n```
123125
// relationship implementation scip-dotnet nuget Main 0.0.0.0 System/IEquatable#
126+
// ^ definition scip-dotnet nuget . . Main/Records#I3#[T]
127+
// documentation ```cs\nT\n```
124128

125129
record Teacher2() : I3<Person>(), I1;
126130
// ^^^^^^^^ definition scip-dotnet nuget . . Main/Records#Teacher2#

0 commit comments

Comments
 (0)