add a scanner, but this seems to be a wrong solution. Change open-source head
This commit is contained in:
@@ -1,37 +1,65 @@
|
||||
using System.Collections.Immutable;
|
||||
// -----------------------------------------------------------------------------
|
||||
// file="PanelStateIncrementalGenerator"
|
||||
// Project: StgSharp
|
||||
// Copyright (c) Nitload.
|
||||
// SPDX-License-Identifier: MIT
|
||||
// -----------------------------------------------------------------------------
|
||||
|
||||
using Microsoft.CodeAnalysis;
|
||||
using System.Collections.Immutable;
|
||||
|
||||
namespace StgSharp.UserInterface.Generator;
|
||||
|
||||
[Generator(LanguageNames.CSharp)]
|
||||
public sealed class PanelStateIncrementalGenerator : IIncrementalGenerator
|
||||
namespace StgSharp.UserInterface.Generator
|
||||
{
|
||||
public void Initialize(IncrementalGeneratorInitializationContext context)
|
||||
[Generator(LanguageNames.CSharp)]
|
||||
public sealed class PanelStateIncrementalGenerator : IIncrementalGenerator
|
||||
{
|
||||
IncrementalValuesProvider<PanelStateIncrementalGeneratorTypeTarget> typeTargets = context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
static (node, _) => PanelStateIncrementalGeneratorPipeline.IsCandidate(node),
|
||||
static (syntaxContext, cancellationToken) =>
|
||||
PanelStateIncrementalGeneratorPipeline.Transform(syntaxContext, cancellationToken))
|
||||
.Where(static target => target is not null)
|
||||
.Select(static (target, _) => target!);
|
||||
|
||||
IncrementalValueProvider<ImmutableArray<PanelStateIncrementalGeneratorTypeTarget>> collectedTypeTargets = typeTargets.Collect();
|
||||
public void Initialize(
|
||||
IncrementalGeneratorInitializationContext context
|
||||
)
|
||||
{
|
||||
IncrementalValuesProvider<PanelStateIncrementalGeneratorTypeTarget> typeTargets = context.SyntaxProvider
|
||||
.CreateSyntaxProvider(
|
||||
static(
|
||||
node,
|
||||
_
|
||||
) => PanelStateIncrementalGeneratorPipeline.IsCandidate(node),
|
||||
static(
|
||||
syntaxContext,
|
||||
cancellationToken
|
||||
) => PanelStateIncrementalGeneratorPipeline.Transform(syntaxContext, cancellationToken))
|
||||
.Where(static target => target is not null)
|
||||
.Select(static(
|
||||
target,
|
||||
_
|
||||
) => target!);
|
||||
|
||||
IncrementalValueProvider<PanelStateIncrementalGeneratorInput> generatorInput = context.CompilationProvider
|
||||
.Combine(collectedTypeTargets)
|
||||
.Select(
|
||||
static (pair, _) => new PanelStateIncrementalGeneratorInput(
|
||||
pair.Left,
|
||||
pair.Right));
|
||||
IncrementalValueProvider<ImmutableArray<PanelStateIncrementalGeneratorTypeTarget>> collectedTypeTargets = typeTargets.Collect();
|
||||
|
||||
IncrementalValueProvider<PanelStateIncrementalGeneratorOutput> generatorOutput = generatorInput
|
||||
.Select(
|
||||
static (input, _) => PanelStateIncrementalGeneratorAnalysis.Analyze(input));
|
||||
IncrementalValueProvider<PanelStateIncrementalGeneratorInput> generatorInput = context.CompilationProvider
|
||||
.Combine(collectedTypeTargets)
|
||||
.Select(
|
||||
static(
|
||||
pair,
|
||||
_
|
||||
) => new PanelStateIncrementalGeneratorInput(
|
||||
pair.Left,
|
||||
pair.Right));
|
||||
|
||||
IncrementalValueProvider<PanelStateIncrementalGeneratorOutput> generatorOutput = generatorInput
|
||||
.Select(
|
||||
static(
|
||||
input,
|
||||
_
|
||||
) => PanelStateIncrementalGeneratorAnalysis.Analyze(input));
|
||||
|
||||
context.RegisterSourceOutput(
|
||||
generatorOutput,
|
||||
static(
|
||||
productionContext,
|
||||
source
|
||||
) => PanelStateIncrementalGeneratorEmitter.Emit(productionContext, source));
|
||||
}
|
||||
|
||||
context.RegisterSourceOutput(
|
||||
generatorOutput,
|
||||
static (productionContext, source) =>
|
||||
PanelStateIncrementalGeneratorEmitter.Emit(productionContext, source));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user