forked from liza/Questionable
Update source gen
This commit is contained in:
parent
5823a0a88c
commit
381354eff6
@ -24,6 +24,7 @@
|
|||||||
</EmbeddedResource>
|
</EmbeddedResource>
|
||||||
<AdditionalFiles Include="gatheringlocation-v1.json" />
|
<AdditionalFiles Include="gatheringlocation-v1.json" />
|
||||||
<AdditionalFiles Include="..\Questionable.Model\common-schema.json" />
|
<AdditionalFiles Include="..\Questionable.Model\common-schema.json" />
|
||||||
|
<AdditionalFiles Include="..\QuestPaths\quest-v1.json" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
<ItemGroup Condition="'$(Configuration)' == 'Release'">
|
||||||
|
@ -42,9 +42,10 @@ public class GatheringSourceGenerator : ISourceGenerator
|
|||||||
private void GenerateGatheringSource(GeneratorExecutionContext context, AdditionalText jsonSchemaFile)
|
private void GenerateGatheringSource(GeneratorExecutionContext context, AdditionalText jsonSchemaFile)
|
||||||
{
|
{
|
||||||
var gatheringSchema = JsonSchema.FromText(jsonSchemaFile.GetText()!.ToString());
|
var gatheringSchema = JsonSchema.FromText(jsonSchemaFile.GetText()!.ToString());
|
||||||
|
var jsonSchemaFiles = Utils.RegisterSchemas(context);
|
||||||
|
|
||||||
List<(ushort, GatheringRoot)> gatheringLocations = [];
|
List<(ushort, GatheringRoot)> gatheringLocations = [];
|
||||||
foreach (var (id, node) in Utils.GetAdditionalFiles(context, jsonSchemaFile, gatheringSchema, InvalidJson,
|
foreach (var (id, node) in Utils.GetAdditionalFiles(context, jsonSchemaFiles, gatheringSchema, InvalidJson,
|
||||||
ushort.Parse))
|
ushort.Parse))
|
||||||
{
|
{
|
||||||
var gatheringLocation = node.Deserialize<GatheringRoot>()!;
|
var gatheringLocation = node.Deserialize<GatheringRoot>()!;
|
||||||
@ -88,6 +89,12 @@ public class GatheringSourceGenerator : ISourceGenerator
|
|||||||
IdentifierName("Questionable"),
|
IdentifierName("Questionable"),
|
||||||
IdentifierName("Model")),
|
IdentifierName("Model")),
|
||||||
IdentifierName("Gathering"))),
|
IdentifierName("Gathering"))),
|
||||||
|
UsingDirective(
|
||||||
|
QualifiedName(
|
||||||
|
QualifiedName(
|
||||||
|
IdentifierName("Questionable"),
|
||||||
|
IdentifierName("Model")),
|
||||||
|
IdentifierName("Questing"))),
|
||||||
UsingDirective(
|
UsingDirective(
|
||||||
QualifiedName(
|
QualifiedName(
|
||||||
QualifiedName(
|
QualifiedName(
|
||||||
|
@ -46,9 +46,10 @@ public class QuestSourceGenerator : ISourceGenerator
|
|||||||
private void GenerateQuestSource(GeneratorExecutionContext context, AdditionalText jsonSchemaFile)
|
private void GenerateQuestSource(GeneratorExecutionContext context, AdditionalText jsonSchemaFile)
|
||||||
{
|
{
|
||||||
var questSchema = JsonSchema.FromText(jsonSchemaFile.GetText()!.ToString());
|
var questSchema = JsonSchema.FromText(jsonSchemaFile.GetText()!.ToString());
|
||||||
|
var jsonSchemaFiles = Utils.RegisterSchemas(context);
|
||||||
|
|
||||||
List<(ElementId, QuestRoot)> quests = [];
|
List<(ElementId, QuestRoot)> quests = [];
|
||||||
foreach (var (id, node) in Utils.GetAdditionalFiles(context, jsonSchemaFile, questSchema, InvalidJson,
|
foreach (var (id, node) in Utils.GetAdditionalFiles(context, jsonSchemaFiles, questSchema, InvalidJson,
|
||||||
ElementId.FromString))
|
ElementId.FromString))
|
||||||
{
|
{
|
||||||
var quest = node.Deserialize<QuestRoot>()!;
|
var quest = node.Deserialize<QuestRoot>()!;
|
||||||
@ -195,140 +196,7 @@ public class QuestSourceGenerator : ISourceGenerator
|
|||||||
.AsSyntaxNodeOrToken(),
|
.AsSyntaxNodeOrToken(),
|
||||||
Assignment(nameof(QuestSequence.Comment), sequence.Comment, null)
|
Assignment(nameof(QuestSequence.Comment), sequence.Comment, null)
|
||||||
.AsSyntaxNodeOrToken(),
|
.AsSyntaxNodeOrToken(),
|
||||||
AssignmentExpression(
|
AssignmentList(nameof(QuestSequence.Steps), sequence.Steps)
|
||||||
SyntaxKind.SimpleAssignmentExpression,
|
|
||||||
IdentifierName(nameof(QuestSequence.Steps)),
|
|
||||||
CreateQuestSteps(sequence.Steps))))))),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
}.ToArray())));
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ExpressionSyntax CreateQuestSteps(List<QuestStep> steps)
|
|
||||||
{
|
|
||||||
QuestStep emptyStep = new();
|
|
||||||
return CollectionExpression(
|
|
||||||
SeparatedList<CollectionElementSyntax>(
|
|
||||||
steps.SelectMany(step => new SyntaxNodeOrToken[]
|
|
||||||
{
|
|
||||||
ExpressionElement(
|
|
||||||
ObjectCreationExpression(
|
|
||||||
IdentifierName(nameof(QuestStep)))
|
|
||||||
.WithArgumentList(
|
|
||||||
ArgumentList(
|
|
||||||
SeparatedList<ArgumentSyntax>(
|
|
||||||
new SyntaxNodeOrToken[]
|
|
||||||
{
|
|
||||||
Argument(LiteralValue(step.InteractionType)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(step.DataId)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(step.Position)),
|
|
||||||
Token(SyntaxKind.CommaToken),
|
|
||||||
Argument(LiteralValue(step.TerritoryId))
|
|
||||||
})))
|
|
||||||
.WithInitializer(
|
|
||||||
InitializerExpression(
|
|
||||||
SyntaxKind.ObjectInitializerExpression,
|
|
||||||
SeparatedList<ExpressionSyntax>(
|
|
||||||
SyntaxNodeList(
|
|
||||||
Assignment(nameof(QuestStep.StopDistance), step.StopDistance,
|
|
||||||
emptyStep.StopDistance)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.NpcWaitDistance), step.NpcWaitDistance,
|
|
||||||
emptyStep.NpcWaitDistance)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.TargetTerritoryId), step.TargetTerritoryId,
|
|
||||||
emptyStep.TargetTerritoryId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.DelaySecondsAtStart), step.DelaySecondsAtStart,
|
|
||||||
emptyStep.DelaySecondsAtStart)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Disabled), step.Disabled, emptyStep.Disabled)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.DisableNavmesh), step.DisableNavmesh,
|
|
||||||
emptyStep.DisableNavmesh)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Mount), step.Mount, emptyStep.Mount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Fly), step.Fly, emptyStep.Fly)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Land), step.Land, emptyStep.Land)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Sprint), step.Sprint, emptyStep.Sprint)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.IgnoreDistanceToObject),
|
|
||||||
step.IgnoreDistanceToObject, emptyStep.IgnoreDistanceToObject)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Comment), step.Comment, emptyStep.Comment)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Aetheryte), step.Aetheryte, emptyStep.Aetheryte)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AethernetShard), step.AethernetShard,
|
|
||||||
emptyStep.AethernetShard)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AetheryteShortcut), step.AetheryteShortcut,
|
|
||||||
emptyStep.AetheryteShortcut)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AethernetShortcut), step.AethernetShortcut,
|
|
||||||
emptyStep.AethernetShortcut)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.AetherCurrentId), step.AetherCurrentId,
|
|
||||||
emptyStep.AetherCurrentId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ItemId), step.ItemId, emptyStep.ItemId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.GroundTarget), step.GroundTarget,
|
|
||||||
emptyStep.GroundTarget)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ItemCount), step.ItemCount, emptyStep.ItemCount)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Emote), step.Emote, emptyStep.Emote)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ChatMessage), step.ChatMessage,
|
|
||||||
emptyStep.ChatMessage)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.Action), step.Action, emptyStep.Action)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.EnemySpawnType), step.EnemySpawnType,
|
|
||||||
emptyStep.EnemySpawnType)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.KillEnemyDataIds), step.KillEnemyDataIds)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
|
|
||||||
step.CombatDelaySecondsAtStart,
|
|
||||||
emptyStep.CombatDelaySecondsAtStart)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.JumpDestination), step.JumpDestination,
|
|
||||||
emptyStep.JumpDestination)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.ContentFinderConditionId),
|
|
||||||
step.ContentFinderConditionId, emptyStep.ContentFinderConditionId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.SkipConditions), step.SkipConditions,
|
|
||||||
emptyStep.SkipConditions)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.RequiredQuestVariables),
|
|
||||||
step.RequiredQuestVariables)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.RequiredGatheredItems),
|
|
||||||
step.RequiredGatheredItems),
|
|
||||||
AssignmentList(nameof(QuestStep.CompletionQuestVariablesFlags),
|
|
||||||
step.CompletionQuestVariablesFlags)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.DialogueChoices), step.DialogueChoices)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
AssignmentList(nameof(QuestStep.PointMenuChoices), step.PointMenuChoices)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.PickUpQuestId), step.PickUpQuestId,
|
|
||||||
emptyStep.PickUpQuestId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.TurnInQuestId), step.TurnInQuestId,
|
|
||||||
emptyStep.TurnInQuestId)
|
|
||||||
.AsSyntaxNodeOrToken(),
|
|
||||||
Assignment(nameof(QuestStep.NextQuestId), step.NextQuestId,
|
|
||||||
emptyStep.NextQuestId)
|
|
||||||
.AsSyntaxNodeOrToken()))))),
|
.AsSyntaxNodeOrToken()))))),
|
||||||
Token(SyntaxKind.CommaToken),
|
Token(SyntaxKind.CommaToken),
|
||||||
}.ToArray())));
|
}.ToArray())));
|
||||||
|
@ -56,6 +56,129 @@ public static class RoslynShortcuts
|
|||||||
SyntaxKind.SimpleMemberAccessExpression,
|
SyntaxKind.SimpleMemberAccessExpression,
|
||||||
IdentifierName(value.GetType().Name),
|
IdentifierName(value.GetType().Name),
|
||||||
IdentifierName(value.GetType().GetEnumName(value)!));
|
IdentifierName(value.GetType().GetEnumName(value)!));
|
||||||
|
else if (value is QuestStep step)
|
||||||
|
{
|
||||||
|
var emptyStep = new QuestStep();
|
||||||
|
return ObjectCreationExpression(
|
||||||
|
IdentifierName(nameof(QuestStep)))
|
||||||
|
.WithArgumentList(
|
||||||
|
ArgumentList(
|
||||||
|
SeparatedList<ArgumentSyntax>(
|
||||||
|
new SyntaxNodeOrToken[]
|
||||||
|
{
|
||||||
|
Argument(LiteralValue(step.InteractionType)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(step.DataId)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(step.Position)),
|
||||||
|
Token(SyntaxKind.CommaToken),
|
||||||
|
Argument(LiteralValue(step.TerritoryId))
|
||||||
|
})))
|
||||||
|
.WithInitializer(
|
||||||
|
InitializerExpression(
|
||||||
|
SyntaxKind.ObjectInitializerExpression,
|
||||||
|
SeparatedList<ExpressionSyntax>(
|
||||||
|
SyntaxNodeList(
|
||||||
|
Assignment(nameof(QuestStep.StopDistance), step.StopDistance,
|
||||||
|
emptyStep.StopDistance)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.NpcWaitDistance), step.NpcWaitDistance,
|
||||||
|
emptyStep.NpcWaitDistance)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.TargetTerritoryId), step.TargetTerritoryId,
|
||||||
|
emptyStep.TargetTerritoryId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.DelaySecondsAtStart), step.DelaySecondsAtStart,
|
||||||
|
emptyStep.DelaySecondsAtStart)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Disabled), step.Disabled, emptyStep.Disabled)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.DisableNavmesh), step.DisableNavmesh,
|
||||||
|
emptyStep.DisableNavmesh)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Mount), step.Mount, emptyStep.Mount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Fly), step.Fly, emptyStep.Fly)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Land), step.Land, emptyStep.Land)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Sprint), step.Sprint, emptyStep.Sprint)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.IgnoreDistanceToObject),
|
||||||
|
step.IgnoreDistanceToObject, emptyStep.IgnoreDistanceToObject)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Comment), step.Comment, emptyStep.Comment)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Aetheryte), step.Aetheryte, emptyStep.Aetheryte)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AethernetShard), step.AethernetShard,
|
||||||
|
emptyStep.AethernetShard)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AetheryteShortcut), step.AetheryteShortcut,
|
||||||
|
emptyStep.AetheryteShortcut)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AethernetShortcut), step.AethernetShortcut,
|
||||||
|
emptyStep.AethernetShortcut)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.AetherCurrentId), step.AetherCurrentId,
|
||||||
|
emptyStep.AetherCurrentId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ItemId), step.ItemId, emptyStep.ItemId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.GroundTarget), step.GroundTarget,
|
||||||
|
emptyStep.GroundTarget)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ItemCount), step.ItemCount, emptyStep.ItemCount)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Emote), step.Emote, emptyStep.Emote)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ChatMessage), step.ChatMessage,
|
||||||
|
emptyStep.ChatMessage)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.Action), step.Action, emptyStep.Action)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.EnemySpawnType), step.EnemySpawnType,
|
||||||
|
emptyStep.EnemySpawnType)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.KillEnemyDataIds), step.KillEnemyDataIds)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.ComplexCombatData), step.ComplexCombatData)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.CombatDelaySecondsAtStart),
|
||||||
|
step.CombatDelaySecondsAtStart,
|
||||||
|
emptyStep.CombatDelaySecondsAtStart)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.JumpDestination), step.JumpDestination,
|
||||||
|
emptyStep.JumpDestination)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.ContentFinderConditionId),
|
||||||
|
step.ContentFinderConditionId, emptyStep.ContentFinderConditionId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.SkipConditions), step.SkipConditions,
|
||||||
|
emptyStep.SkipConditions)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.RequiredQuestVariables),
|
||||||
|
step.RequiredQuestVariables)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.RequiredGatheredItems),
|
||||||
|
step.RequiredGatheredItems),
|
||||||
|
AssignmentList(nameof(QuestStep.CompletionQuestVariablesFlags),
|
||||||
|
step.CompletionQuestVariablesFlags)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.DialogueChoices), step.DialogueChoices)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
AssignmentList(nameof(QuestStep.PointMenuChoices), step.PointMenuChoices)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.PickUpQuestId), step.PickUpQuestId,
|
||||||
|
emptyStep.PickUpQuestId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.TurnInQuestId), step.TurnInQuestId,
|
||||||
|
emptyStep.TurnInQuestId)
|
||||||
|
.AsSyntaxNodeOrToken(),
|
||||||
|
Assignment(nameof(QuestStep.NextQuestId), step.NextQuestId,
|
||||||
|
emptyStep.NextQuestId)
|
||||||
|
.AsSyntaxNodeOrToken()))));
|
||||||
|
}
|
||||||
else if (value is QuestId questId)
|
else if (value is QuestId questId)
|
||||||
{
|
{
|
||||||
return ObjectCreationExpression(
|
return ObjectCreationExpression(
|
||||||
@ -398,7 +521,8 @@ public static class RoslynShortcuts
|
|||||||
Assignment(nameof(GatheredItem.Collectability), gatheredItem.Collectability,
|
Assignment(nameof(GatheredItem.Collectability), gatheredItem.Collectability,
|
||||||
emptyItem.Collectability)
|
emptyItem.Collectability)
|
||||||
.AsSyntaxNodeOrToken(),
|
.AsSyntaxNodeOrToken(),
|
||||||
Assignment(nameof(GatheredItem.QuestAcceptedAsClass), gatheredItem.QuestAcceptedAsClass,
|
Assignment(nameof(GatheredItem.QuestAcceptedAsClass),
|
||||||
|
gatheredItem.QuestAcceptedAsClass,
|
||||||
emptyItem.QuestAcceptedAsClass)
|
emptyItem.QuestAcceptedAsClass)
|
||||||
.AsSyntaxNodeOrToken()))));
|
.AsSyntaxNodeOrToken()))));
|
||||||
}
|
}
|
||||||
|
@ -14,16 +14,40 @@ namespace Questionable.QuestPathGenerator;
|
|||||||
|
|
||||||
public static class Utils
|
public static class Utils
|
||||||
{
|
{
|
||||||
public static IEnumerable<(T, JsonNode)> GetAdditionalFiles<T>(GeneratorExecutionContext context,
|
public static List<AdditionalText> RegisterSchemas(GeneratorExecutionContext context)
|
||||||
AdditionalText jsonSchemaFile, JsonSchema jsonSchema, DiagnosticDescriptor invalidJson, Func<string, T> idParser)
|
|
||||||
{
|
{
|
||||||
var commonSchemaFile = context.AdditionalFiles.Single(x => Path.GetFileName(x.Path) == "common-schema.json");
|
var commonSchemaFile = context.AdditionalFiles.Single(x => Path.GetFileName(x.Path) == "common-schema.json");
|
||||||
List<AdditionalText> jsonSchemaFiles = [jsonSchemaFile, commonSchemaFile];
|
var gatheringSchemaFile =
|
||||||
|
context.AdditionalFiles.SingleOrDefault(x => Path.GetFileName(x.Path) == "gatheringlocation-v1.json");
|
||||||
|
var questSchemaFile = context.AdditionalFiles.SingleOrDefault(x => Path.GetFileName(x.Path) == "quest-v1.json");
|
||||||
|
|
||||||
SchemaRegistry.Global.Register(
|
SchemaRegistry.Global.Register(
|
||||||
new Uri("https://git.carvel.li/liza/Questionable/raw/branch/master/Questionable.Model/common-schema.json"),
|
new Uri("https://git.carvel.li/liza/Questionable/raw/branch/master/Questionable.Model/common-schema.json"),
|
||||||
JsonSchema.FromText(commonSchemaFile.GetText()!.ToString()));
|
JsonSchema.FromText(commonSchemaFile.GetText()!.ToString()));
|
||||||
|
|
||||||
|
if (gatheringSchemaFile != null)
|
||||||
|
{
|
||||||
|
SchemaRegistry.Global.Register(
|
||||||
|
new Uri(
|
||||||
|
"https://git.carvel.li/liza/Questionable/raw/branch/master/GatheringPaths/gatheringlocation-v1.json"),
|
||||||
|
JsonSchema.FromText(gatheringSchemaFile.GetText()!.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (questSchemaFile != null)
|
||||||
|
{
|
||||||
|
SchemaRegistry.Global.Register(
|
||||||
|
new Uri("https://git.carvel.li/liza/Questionable/raw/branch/master/QuestPaths/quest-v1.json"),
|
||||||
|
JsonSchema.FromText(questSchemaFile.GetText()!.ToString()));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<AdditionalText?> jsonSchemaFiles = [commonSchemaFile, gatheringSchemaFile, questSchemaFile];
|
||||||
|
return jsonSchemaFiles.Where(x => x != null).Cast<AdditionalText>().ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IEnumerable<(T, JsonNode)> GetAdditionalFiles<T>(GeneratorExecutionContext context,
|
||||||
|
List<AdditionalText> jsonSchemaFiles, JsonSchema jsonSchema, DiagnosticDescriptor invalidJson,
|
||||||
|
Func<string, T> idParser)
|
||||||
|
{
|
||||||
foreach (var additionalFile in context.AdditionalFiles)
|
foreach (var additionalFile in context.AdditionalFiles)
|
||||||
{
|
{
|
||||||
if (additionalFile == null || jsonSchemaFiles.Contains(additionalFile))
|
if (additionalFile == null || jsonSchemaFiles.Contains(additionalFile))
|
||||||
|
Loading…
Reference in New Issue
Block a user