Skip to content

Commit 30b20ab

Browse files
Added additional source generation pieces
1 parent 8595f08 commit 30b20ab

File tree

5 files changed

+1275
-20
lines changed

5 files changed

+1275
-20
lines changed

src/JsonRpc.Generators/GenerateHandlerMethodsGenerator.cs

+15-17
Original file line numberDiff line numberDiff line change
@@ -131,25 +131,23 @@ public void Execute(GeneratorExecutionContext context)
131131
new[] {
132132
NamespaceDeclaration(ParseName(symbol.ContainingNamespace.ToDisplayString()))
133133
.WithMembers(
134-
List(
135-
new MemberDeclarationSyntax[] {
136-
ClassDeclaration(className)
137-
.WithAttributeLists(attributes)
138-
.WithModifiers(
139-
TokenList(
140-
new[] { isInternal ? Token(SyntaxKind.InternalKeyword) : Token(SyntaxKind.PublicKeyword) }.Concat(
141-
new[] {
142-
Token(SyntaxKind.StaticKeyword),
143-
Token(SyntaxKind.PartialKeyword)
144-
}
145-
)
134+
SingletonList<MemberDeclarationSyntax>(
135+
ClassDeclaration(className)
136+
.WithAttributeLists(attributes)
137+
.WithModifiers(
138+
TokenList(
139+
new[] { isInternal ? Token(SyntaxKind.InternalKeyword) : Token(SyntaxKind.PublicKeyword) }.Concat(
140+
new[] {
141+
Token(SyntaxKind.StaticKeyword),
142+
Token(SyntaxKind.PartialKeyword)
143+
}
146144
)
147145
)
148-
.WithMembers(List(methods))
149-
.WithLeadingTrivia(TriviaList(Trivia(NullableDirectiveTrivia(Token(SyntaxKind.EnableKeyword), true))))
150-
.WithTrailingTrivia(TriviaList(Trivia(NullableDirectiveTrivia(Token(SyntaxKind.RestoreKeyword), true))))
151-
.NormalizeWhitespace()
152-
}
146+
)
147+
.WithMembers(List(methods))
148+
.WithLeadingTrivia(TriviaList(Trivia(NullableDirectiveTrivia(Token(SyntaxKind.EnableKeyword), true))))
149+
.WithTrailingTrivia(TriviaList(Trivia(NullableDirectiveTrivia(Token(SyntaxKind.RestoreKeyword), true))))
150+
.NormalizeWhitespace()
153151
)
154152
)
155153
}

src/JsonRpc.Generators/GeneratorDiagnostics.cs

+22-3
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,36 @@ internal static class GeneratorDiagnostics
66
{
77
public static DiagnosticDescriptor MissingDirection { get; } = new DiagnosticDescriptor(
88
"LSP1000", "Missing Direction",
9-
"No direction defined for Language Server Protocol Handler", "JsonRPC", DiagnosticSeverity.Warning, true
9+
"No direction defined for Language Server Protocol Handler", "LSP", DiagnosticSeverity.Warning, true
10+
);
11+
public static DiagnosticDescriptor Exception { get; } = new DiagnosticDescriptor(
12+
"JRPC0001", "Exception",
13+
"{0}", "JRPC", DiagnosticSeverity.Error, true
1014
);
1115

1216
public static DiagnosticDescriptor NoHandlerRegistryProvided { get; } = new DiagnosticDescriptor(
1317
"JRPC1000", "No Handler Registry Provided",
14-
"No Handler Registry Provided for handler {0}.", "JsonRPC", DiagnosticSeverity.Warning, true
18+
"No Handler Registry Provided for handler {0}.", "JsonRPC", DiagnosticSeverity.Info, true
1519
);
1620

1721
public static DiagnosticDescriptor NoResponseRouterProvided { get; } = new DiagnosticDescriptor(
1822
"JRPC1001", "No Response Router Provided",
19-
"No Response Router Provided for handler {0}, defaulting to {1}.", "JsonRPC", DiagnosticSeverity.Warning, true
23+
"No Response Router Provided for handler {0}, defaulting to {1}.", "JsonRPC", DiagnosticSeverity.Info, true
24+
);
25+
26+
public static DiagnosticDescriptor ClassMustBePartial { get; } = new DiagnosticDescriptor(
27+
"JRPC1002", "Class must be made partial",
28+
"Class {0} must be made partial.", "JsonRPC", DiagnosticSeverity.Warning, true
29+
);
30+
31+
public static DiagnosticDescriptor MustInheritFromCanBeResolved { get; } = new DiagnosticDescriptor(
32+
"LSP1001", "The target class must implement ICanBeResolved",
33+
"The target class must implement ICanBeResolved", "LSP", DiagnosticSeverity.Error, true
34+
);
35+
36+
public static DiagnosticDescriptor MustInheritFromCanHaveData { get; } = new DiagnosticDescriptor(
37+
"LSP1002", "The target class must implement ICanHaveData",
38+
"The target class must implement ICanHaveData", "LSP", DiagnosticSeverity.Error, true
2039
);
2140
}
2241
}

0 commit comments

Comments
 (0)