diff --git a/Elsa.sln b/Elsa.sln index 4eec25c12..d2149e5f8 100644 --- a/Elsa.sln +++ b/Elsa.sln @@ -240,8 +240,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Http", "src\modules\El EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Expressions.CSharp", "src\modules\Elsa.Expressions.CSharp\Elsa.Expressions.CSharp.csproj", "{16C3FBDE-A832-E3CD-5FBF-F51744D1F79B}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Expressions.Dsl", "src\modules\Elsa.Expressions.Dsl\Elsa.Expressions.Dsl.csproj", "{765392DE-8560-B464-62DD-6890720FF5D5}" -EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Expressions.JavaScript", "src\modules\Elsa.Expressions.JavaScript\Elsa.Expressions.JavaScript.csproj", "{099D5DCE-CCF7-16FE-6EDC-A64B694F50BE}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Expressions.JavaScript.Libraries", "src\modules\Elsa.Expressions.JavaScript.Libraries\Elsa.Expressions.JavaScript.Libraries.csproj", "{08B69CC4-B5F0-44E8-FA7A-6BF6F00CA40A}" @@ -262,6 +260,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Resilience", "src\modu EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.WorkflowProviders.BlobStorage", "src\modules\Elsa.WorkflowProviders.BlobStorage\Elsa.WorkflowProviders.BlobStorage.csproj", "{0125BC8D-C837-414C-BB53-FCEA62E3060F}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "scheduling", "scheduling", "{7C038270-8BF7-4911-AC24-54D7BBE9BBF2}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Elsa.Scheduling", "src\modules\Elsa.Scheduling\Elsa.Scheduling.csproj", "{26849C37-2ACA-4DDE-83CD-B87939465791}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -410,10 +412,6 @@ Global {16C3FBDE-A832-E3CD-5FBF-F51744D1F79B}.Debug|Any CPU.Build.0 = Debug|Any CPU {16C3FBDE-A832-E3CD-5FBF-F51744D1F79B}.Release|Any CPU.ActiveCfg = Release|Any CPU {16C3FBDE-A832-E3CD-5FBF-F51744D1F79B}.Release|Any CPU.Build.0 = Release|Any CPU - {765392DE-8560-B464-62DD-6890720FF5D5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {765392DE-8560-B464-62DD-6890720FF5D5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {765392DE-8560-B464-62DD-6890720FF5D5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {765392DE-8560-B464-62DD-6890720FF5D5}.Release|Any CPU.Build.0 = Release|Any CPU {099D5DCE-CCF7-16FE-6EDC-A64B694F50BE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {099D5DCE-CCF7-16FE-6EDC-A64B694F50BE}.Debug|Any CPU.Build.0 = Debug|Any CPU {099D5DCE-CCF7-16FE-6EDC-A64B694F50BE}.Release|Any CPU.ActiveCfg = Release|Any CPU @@ -450,6 +448,10 @@ Global {0125BC8D-C837-414C-BB53-FCEA62E3060F}.Debug|Any CPU.Build.0 = Debug|Any CPU {0125BC8D-C837-414C-BB53-FCEA62E3060F}.Release|Any CPU.ActiveCfg = Release|Any CPU {0125BC8D-C837-414C-BB53-FCEA62E3060F}.Release|Any CPU.Build.0 = Release|Any CPU + {26849C37-2ACA-4DDE-83CD-B87939465791}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {26849C37-2ACA-4DDE-83CD-B87939465791}.Debug|Any CPU.Build.0 = Debug|Any CPU + {26849C37-2ACA-4DDE-83CD-B87939465791}.Release|Any CPU.ActiveCfg = Release|Any CPU + {26849C37-2ACA-4DDE-83CD-B87939465791}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -516,7 +518,6 @@ Global {C55015F0-E9DF-4BF9-8131-D7539E938220} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} {E0B22AB7-7CB5-6D17-562C-4A989DC61F8A} = {C55015F0-E9DF-4BF9-8131-D7539E938220} {16C3FBDE-A832-E3CD-5FBF-F51744D1F79B} = {6EF07978-A6D2-40EB-891D-7D70C5F37E76} - {765392DE-8560-B464-62DD-6890720FF5D5} = {6EF07978-A6D2-40EB-891D-7D70C5F37E76} {099D5DCE-CCF7-16FE-6EDC-A64B694F50BE} = {6EF07978-A6D2-40EB-891D-7D70C5F37E76} {08B69CC4-B5F0-44E8-FA7A-6BF6F00CA40A} = {6EF07978-A6D2-40EB-891D-7D70C5F37E76} {6AF53651-99F0-1DE0-D37B-4FF6B0348DBB} = {6EF07978-A6D2-40EB-891D-7D70C5F37E76} @@ -527,6 +528,8 @@ Global {58064618-A7BD-4D3E-8D57-B15018110AB5} = {E023660A-162E-498E-BA00-A941FBC82664} {467573C9-DDC7-4351-9EC8-22E23F554DA7} = {E023660A-162E-498E-BA00-A941FBC82664} {0125BC8D-C837-414C-BB53-FCEA62E3060F} = {B08B4E00-C2AB-48F3-8389-449F42AEF179} + {7C038270-8BF7-4911-AC24-54D7BBE9BBF2} = {5BA4A8FA-F7F4-45B3-AEC8-8886D35AAC79} + {26849C37-2ACA-4DDE-83CD-B87939465791} = {7C038270-8BF7-4911-AC24-54D7BBE9BBF2} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {D4B5CEAA-7D70-4FCB-A68E-B03FBE5E0E5E} diff --git a/src/apps/Elsa.Server.Web/Program.cs b/src/apps/Elsa.Server.Web/Program.cs index b0024da7b..961bdfdaa 100644 --- a/src/apps/Elsa.Server.Web/Program.cs +++ b/src/apps/Elsa.Server.Web/Program.cs @@ -3,6 +3,7 @@ using Elsa.Caching.Options; using Elsa.Common.RecurringTasks; using Elsa.Expressions.Helpers; using Elsa.Extensions; +using Elsa.Features.Services; using Elsa.Identity.Multitenancy; using Elsa.Server.Web.Filters; using Elsa.Tenants.AspNetCore; @@ -15,14 +16,13 @@ using Elsa.Workflows.LogPersistence; using Elsa.Workflows.Options; using Elsa.Workflows.Runtime.Options; using Elsa.Workflows.Runtime.Tasks; +using JetBrains.Annotations; using Microsoft.Extensions.Options; // ReSharper disable RedundantAssignment -const bool useZipCompression = false; const bool useReadOnlyMode = false; const bool useSignalR = false; // Disabled until Elsa Studio sends authenticated requests. const bool useMultitenancy = false; -const bool useTenantsFromConfiguration = true; const bool disableVariableWrappers = false; ObjectConverter.StrictMode = true; @@ -55,19 +55,14 @@ services strategies.AddStandardStrategies(); strategies.Add("Every 10 seconds", new PeriodicWorkflowStrategy(TimeSpan.FromSeconds(10))); }); - - workflows.UseCaching(); }) .UseWorkflowManagement(management => { management.SetDefaultLogPersistenceMode(LogPersistenceMode.Inherit); - management.UseCaching(); + management.UseCache(); management.UseReadOnlyMode(useReadOnlyMode); }) - .UseWorkflowRuntime(runtime => - { - runtime.UseCaching(); - }) + .UseWorkflowRuntime(runtime => runtime.UseCache()) .UseWorkflowsApi() .UseCSharp(options => { @@ -104,8 +99,7 @@ services { http.ConfigureHttpOptions = options => configuration.GetSection("Http").Bind(options); http.UseCache(); - }) - ; + }); ConfigureForTest?.Invoke(elsa); }); diff --git a/src/apps/Elsa.ServerAndStudio.Web/Activities/CustomDelay.cs b/src/apps/Elsa.ServerAndStudio.Web/Activities/CustomDelay.cs deleted file mode 100644 index 999848742..000000000 --- a/src/apps/Elsa.ServerAndStudio.Web/Activities/CustomDelay.cs +++ /dev/null @@ -1,26 +0,0 @@ -using Elsa.Extensions; -using Elsa.Workflows; - -namespace Elsa.ServerAndStudio.Web.Activities; - -public class CustomDelay : Activity -{ - protected override ValueTask ExecuteAsync(ActivityExecutionContext context) - { - context.DelayFor(TimeSpan.FromSeconds(5), FailAsync); - context.DelayFor(TimeSpan.FromSeconds(500), OnDelayElapsedAsync); - return default; - } - - private ValueTask FailAsync(ActivityExecutionContext context) - { - Console.WriteLine("Failing!"); - throw new("Failing!"); - } - - private async ValueTask OnDelayElapsedAsync(ActivityExecutionContext context) - { - Console.WriteLine("Delay elapsed"); - await context.CompleteActivityAsync(); - } -} \ No newline at end of file diff --git a/src/apps/Elsa.ServerAndStudio.Web/Activities/CustomTimer.cs b/src/apps/Elsa.ServerAndStudio.Web/Activities/CustomTimer.cs deleted file mode 100644 index 32336116c..000000000 --- a/src/apps/Elsa.ServerAndStudio.Web/Activities/CustomTimer.cs +++ /dev/null @@ -1,18 +0,0 @@ -using Elsa.Expressions.Models; -using Elsa.Scheduling.Activities; -using Elsa.Workflows; - -namespace Elsa.ServerAndStudio.Web.Activities; - -public class CustomTimer : TimerBase -{ - protected override TimeSpan GetInterval(ExpressionExecutionContext context) - { - return TimeSpan.FromSeconds(5); - } - - protected override void OnTimerElapsed(ActivityExecutionContext context) - { - Console.WriteLine("Timer elapsed"); - } -} \ No newline at end of file diff --git a/src/apps/Elsa.ServerAndStudio.Web/Program.cs b/src/apps/Elsa.ServerAndStudio.Web/Program.cs index be6a4cc96..2ea41f335 100644 --- a/src/apps/Elsa.ServerAndStudio.Web/Program.cs +++ b/src/apps/Elsa.ServerAndStudio.Web/Program.cs @@ -1,18 +1,8 @@ -using Elsa.Agents; -using Elsa.Expressions.JavaScript.Libraries.Extensions; using Elsa.Extensions; -using Elsa.Persistence.EFCore.Extensions; -using Elsa.Persistence.EFCore.Modules.Management; -using Elsa.Persistence.EFCore.Modules.Runtime; using Elsa.ServerAndStudio.Web.Enums; using Elsa.ServerAndStudio.Web.Extensions; -using Elsa.ServiceBus.MassTransit.Extensions; -using Elsa.ServiceBus.MassTransit.Options; using Medallion.Threading.FileSystem; using Microsoft.AspNetCore.Mvc; -using Microsoft.Data.Sqlite; -using Proto.Persistence.Sqlite; -using WebhooksCore.Options; const bool useMassTransit = true; const bool useProtoActor = true; @@ -24,22 +14,11 @@ var builder = WebApplication.CreateBuilder(args); builder.WebHost.UseStaticWebAssets(); var services = builder.Services; var configuration = builder.Configuration; -var sqliteConnectionString = configuration.GetConnectionString("Sqlite")!; -var mySqlConnectionString = configuration.GetConnectionString("MySql")!; -var sqlServerConnectionString = configuration.GetConnectionString("SqlServer")!; -var postgreSqlConnectionString = configuration.GetConnectionString("PostgreSql")!; -var rabbitMqConnectionString = configuration.GetConnectionString("RabbitMq")!; -var azureServiceBusConnectionString = configuration.GetConnectionString("AzureServiceBus")!; var identitySection = configuration.GetSection("Identity"); var identityTokenSection = identitySection.GetSection("Tokens"); -var massTransitSection = configuration.GetSection("MassTransit"); -var massTransitDispatcherSection = configuration.GetSection("MassTransit.Dispatcher"); var heartbeatSection = configuration.GetSection("Heartbeat"); var sqlDatabaseProvider = Enum.Parse(configuration["DatabaseProvider"] ?? "Sqlite"); -services.Configure(massTransitSection); -services.Configure(massTransitDispatcherSection); - // Add Elsa services. services .AddElsa(elsa => @@ -54,66 +33,15 @@ services identity.UseConfigurationBasedRoleProvider(options => identitySection.Bind(options)); }) .UseDefaultAuthentication() - .UseApplicationCluster(x => x.HeartbeatOptions = settings => heartbeatSection.Bind(settings)) - .UseWorkflowManagement(management => - { - if (useMassTransit) - { - management.UseMassTransitDispatcher(); - } - - if (useCaching) - management.UseCache(); - - if (sqlDatabaseProvider == SqlDatabaseProvider.SqlServer) - management.UseEntityFrameworkCore(ef => ef.UseSqlServer(sqlServerConnectionString)); - else if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql) - management.UseEntityFrameworkCore(ef => ef.UsePostgreSql(postgreSqlConnectionString)); - else if (sqlDatabaseProvider == SqlDatabaseProvider.Sqlite) - management.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)); -#if !NET9_0 - else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql) - management.UseEntityFrameworkCore(ef => ef.UseMySql(mySqlConnectionString)); -#endif - }) + .UseWorkflowManagement(management => management.UseCache()) .UseWorkflowRuntime(runtime => { - if (sqlDatabaseProvider == SqlDatabaseProvider.SqlServer) - runtime.UseEntityFrameworkCore(ef => ef.UseSqlServer(sqlServerConnectionString)); - else if (sqlDatabaseProvider == SqlDatabaseProvider.PostgreSql) - runtime.UseEntityFrameworkCore(ef => ef.UsePostgreSql(postgreSqlConnectionString)); - else if (sqlDatabaseProvider == SqlDatabaseProvider.Sqlite) - runtime.UseEntityFrameworkCore(ef => ef.UseSqlite(sqliteConnectionString)); -#if !NET9_0 - else if (sqlDatabaseProvider == SqlDatabaseProvider.MySql) - runtime.UseEntityFrameworkCore(ef => ef.UseMySql(mySqlConnectionString)); -#endif - - if (useMassTransit) - { - runtime.UseMassTransitDispatcher(); - } - - if (useProtoActor) - { - runtime.UseProtoActor(); - } - - if (useCaching) - runtime.UseCache(); - + runtime.UseCache(); runtime.DistributedLockProvider = _ => new FileDistributedSynchronizationProvider(new DirectoryInfo(Path.Combine(Directory.GetCurrentDirectory(), "App_Data", "locks"))); runtime.WorkflowInboxCleanupOptions = options => configuration.GetSection("Runtime:WorkflowInboxCleanup").Bind(options); runtime.WorkflowDispatcherOptions = options => configuration.GetSection("Runtime:WorkflowDispatcher").Bind(options); }) - .UseScheduling() - .UseJavaScript(javaScriptFeature => - { - javaScriptFeature - .ConfigureJintOptions(jintOptions => jintOptions.AllowClrAccess = true) - .UseLodashFp() - .UseMoment(); - }) + .UseJavaScript(javaScriptFeature => javaScriptFeature.ConfigureJintOptions(jintOptions => jintOptions.AllowClrAccess = true)) .UseLiquid() .UseCSharp() .UsePython(python => @@ -136,59 +64,12 @@ services options.BasePath = configuration["Http:BasePath"]; }; }) - .UseEmail(email => email.ConfigureOptions = options => configuration.GetSection("Smtp").Bind(options)) - .UseWebhooks(webhooks => webhooks.ConfigureSinks = options => builder.Configuration.GetSection("Webhooks:Sinks").Bind(options)) .UseWorkflowsApi() .AddActivitiesFrom() .AddWorkflowsFrom(); - - if (useProtoActor) - { - elsa.UseProtoActor(proto => proto.PersistenceProvider = _ => - { - return new SqliteProvider(new SqliteConnectionStringBuilder(sqliteConnectionString)); - }); - } - - if (useMassTransit) - { - elsa.UseMassTransit(massTransit => - { - switch (useMassTransitBroker) - { - case MassTransitBroker.AzureServiceBus: - massTransit.UseAzureServiceBus(azureServiceBusConnectionString, asb => - { - asb.SubscriptionCleanupOptions = options => options.Interval = TimeSpan.FromMinutes(5); - asb.EnableAutomatedSubscriptionCleanup = true; - }); - break; - case MassTransitBroker.RabbitMq: - massTransit.UseRabbitMq(rabbitMqConnectionString); - break; - } - } - ); - } - - if (distributedCachingTransport != DistributedCachingTransport.None) - { - elsa.UseDistributedCache(distributedCaching => - { - if (distributedCachingTransport == DistributedCachingTransport.MassTransit) distributedCaching.UseMassTransit(); - }); - } - - elsa.UseConnections( - configure=> configure.AddConnectionsFrom()); - elsa.UseConnectionPersistence(ef=> ef.UseEntityFrameworkCore(f=>f.UseSqlite())); - elsa.UseConnectionsApi(); }); -services.Configure(options => configuration.GetSection("Webhooks").Bind(options)); - services.AddHealthChecks(); - services.AddCors(cors => cors.Configure(configuration.GetSection("CorsPolicy"))); // Razor Pages. diff --git a/src/common/Elsa.Testing.Shared.Integration/Elsa.Testing.Shared.Integration.csproj b/src/common/Elsa.Testing.Shared.Integration/Elsa.Testing.Shared.Integration.csproj index a815e699a..75336573d 100644 --- a/src/common/Elsa.Testing.Shared.Integration/Elsa.Testing.Shared.Integration.csproj +++ b/src/common/Elsa.Testing.Shared.Integration/Elsa.Testing.Shared.Integration.csproj @@ -17,6 +17,7 @@ + diff --git a/src/common/Elsa.Testing.Shared.Integration/TestApplicationBuilder.cs b/src/common/Elsa.Testing.Shared.Integration/TestApplicationBuilder.cs index 74c521e21..14154f166 100644 --- a/src/common/Elsa.Testing.Shared.Integration/TestApplicationBuilder.cs +++ b/src/common/Elsa.Testing.Shared.Integration/TestApplicationBuilder.cs @@ -38,7 +38,6 @@ public class TestApplicationBuilder .UseCSharp() .UseJavaScript() .UseLiquid() - .UseDsl() .UseWorkflowManagement() .UseWorkflows(workflows => workflows .WithStandardOutStreamProvider(_ => new StandardOutStreamProvider(new XunitConsoleTextWriter(_testOutputHelper))) diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.cs b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.cs deleted file mode 100644 index 2e85bf2a6..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.cs +++ /dev/null @@ -1,223 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.10.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from C:/Projects/Elsa/v3/src/dsl/Elsa.Expressions.Dsl/Dsl\ElsaLexer.g4 by ANTLR 4.10.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -using System; -using System.IO; -using System.Text; -using Antlr4.Runtime; -using Antlr4.Runtime.Atn; -using Antlr4.Runtime.Misc; -using DFA = Antlr4.Runtime.Dfa.DFA; - -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")] -[System.CLSCompliant(false)] -public partial class ElsaLexer : Lexer { - protected static DFA[] decisionToDFA; - protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); - public const int - EQ=1, GREATER=2, INCREMENT=3, DECREMENT=4, NEW=5, VARIABLE=6, LET=7, IF=8, - THEN=9, ELSE=10, FOR=11, RETURN=12, VOID=13, FLOAT=14, INT=15, STRING=16, - OBJECT=17, EXPRESSION_MARKER=18, SYMBOL=19, COLON=20, SEMICOLON=21, COMMA=22, - PLUS=23, MINUS=24, STAR=25, EQUALS=26, NOT_EQUALS=27, GREATER_EQUALS=28, - LESS=29, LESS_EQUALS=30, LAMBDA=31, PARENTHESES_OPEN=32, PARENTHESES_CLOSE=33, - BRACKET_OPEN=34, BRACKET_CLOSE=35, CURLYBRACE_OPEN=36, CURLYBRACE_CLOSE=37, - EXCLAMATION=38, PIPE=39, PIPE_DBL=40, PERIOD=41, STRING_VAL=42, BACKTICKSTRING_VAL=43, - LINE_COMMENT=44, INTEGER_VAL=45, ID=46, WS=47, ESC=48; - public static string[] channelNames = { - "DEFAULT_TOKEN_CHANNEL", "HIDDEN" - }; - - public static string[] modeNames = { - "DEFAULT_MODE" - }; - - public static readonly string[] ruleNames = { - "EQ", "GREATER", "INCREMENT", "DECREMENT", "NEW", "VARIABLE", "LET", "IF", - "THEN", "ELSE", "FOR", "RETURN", "VOID", "FLOAT", "INT", "STRING", "OBJECT", - "EXPRESSION_MARKER", "SYMBOL", "COLON", "SEMICOLON", "COMMA", "PLUS", - "MINUS", "STAR", "EQUALS", "NOT_EQUALS", "GREATER_EQUALS", "LESS", "LESS_EQUALS", - "LAMBDA", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "BRACKET_OPEN", "BRACKET_CLOSE", - "CURLYBRACE_OPEN", "CURLYBRACE_CLOSE", "EXCLAMATION", "PIPE", "PIPE_DBL", - "PERIOD", "STRING_VAL", "BACKTICKSTRING_VAL", "LINE_COMMENT", "INTEGER_VAL", - "ID", "WS", "LETTER", "DIGIT", "ESC" - }; - - - public ElsaLexer(ICharStream input) - : this(input, Console.Out, Console.Error) { } - - public ElsaLexer(ICharStream input, TextWriter output, TextWriter errorOutput) - : base(input, output, errorOutput) - { - Interpreter = new LexerATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); - } - - private static readonly string[] _LiteralNames = { - null, "'='", "'>'", "'++'", "'--'", "'new'", "'variable'", "'let'", "'if'", - "'then'", "'else'", "'for'", "'return'", "'void'", "'float'", "'int'", - "'string'", "'object'", "'expression'", null, "':'", "';'", "','", "'+'", - "'-'", "'*'", "'=='", "'!='", "'>='", "'<'", "'<='", "'=>'", "'('", "')'", - "'['", "']'", "'{'", "'}'", "'!'", "'|'", "'||'", "'.'", null, null, null, - null, null, null, "'\\|'" - }; - private static readonly string[] _SymbolicNames = { - null, "EQ", "GREATER", "INCREMENT", "DECREMENT", "NEW", "VARIABLE", "LET", - "IF", "THEN", "ELSE", "FOR", "RETURN", "VOID", "FLOAT", "INT", "STRING", - "OBJECT", "EXPRESSION_MARKER", "SYMBOL", "COLON", "SEMICOLON", "COMMA", - "PLUS", "MINUS", "STAR", "EQUALS", "NOT_EQUALS", "GREATER_EQUALS", "LESS", - "LESS_EQUALS", "LAMBDA", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "BRACKET_OPEN", - "BRACKET_CLOSE", "CURLYBRACE_OPEN", "CURLYBRACE_CLOSE", "EXCLAMATION", - "PIPE", "PIPE_DBL", "PERIOD", "STRING_VAL", "BACKTICKSTRING_VAL", "LINE_COMMENT", - "INTEGER_VAL", "ID", "WS", "ESC" - }; - public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); - - [NotNull] - public override IVocabulary Vocabulary - { - get - { - return DefaultVocabulary; - } - } - - public override string GrammarFileName { get { return "ElsaLexer.g4"; } } - - public override string[] RuleNames { get { return ruleNames; } } - - public override string[] ChannelNames { get { return channelNames; } } - - public override string[] ModeNames { get { return modeNames; } } - - public override int[] SerializedAtn { get { return _serializedATN; } } - - static ElsaLexer() { - decisionToDFA = new DFA[_ATN.NumberOfDecisions]; - for (int i = 0; i < _ATN.NumberOfDecisions; i++) { - decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); - } - } - private static int[] _serializedATN = { - 4,0,48,306,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, - 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14, - 7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,2,21, - 7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2,26,7,26,2,27,7,27,2,28, - 7,28,2,29,7,29,2,30,7,30,2,31,7,31,2,32,7,32,2,33,7,33,2,34,7,34,2,35, - 7,35,2,36,7,36,2,37,7,37,2,38,7,38,2,39,7,39,2,40,7,40,2,41,7,41,2,42, - 7,42,2,43,7,43,2,44,7,44,2,45,7,45,2,46,7,46,2,47,7,47,2,48,7,48,2,49, - 7,49,1,0,1,0,1,1,1,1,1,2,1,2,1,2,1,3,1,3,1,3,1,4,1,4,1,4,1,4,1,5,1,5,1, - 5,1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,8,1,8,1,8,1,8, - 1,8,1,9,1,9,1,9,1,9,1,9,1,10,1,10,1,10,1,10,1,11,1,11,1,11,1,11,1,11,1, - 11,1,11,1,12,1,12,1,12,1,12,1,12,1,13,1,13,1,13,1,13,1,13,1,13,1,14,1, - 14,1,14,1,14,1,15,1,15,1,15,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,16,1, - 16,1,16,1,16,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1,17,1, - 18,1,18,1,19,1,19,1,20,1,20,1,21,1,21,1,22,1,22,1,23,1,23,1,24,1,24,1, - 25,1,25,1,25,1,26,1,26,1,26,1,27,1,27,1,27,1,28,1,28,1,29,1,29,1,29,1, - 30,1,30,1,30,1,31,1,31,1,32,1,32,1,33,1,33,1,34,1,34,1,35,1,35,1,36,1, - 36,1,37,1,37,1,38,1,38,1,39,1,39,1,39,1,40,1,40,1,41,1,41,1,41,1,41,5, - 41,249,8,41,10,41,12,41,252,9,41,1,41,1,41,1,42,1,42,1,42,1,42,5,42,260, - 8,42,10,42,12,42,263,9,42,1,42,1,42,1,43,1,43,1,43,1,43,5,43,271,8,43, - 10,43,12,43,274,9,43,1,43,3,43,277,8,43,1,43,1,43,1,43,1,43,1,44,4,44, - 284,8,44,11,44,12,44,285,1,45,1,45,1,45,5,45,291,8,45,10,45,12,45,294, - 9,45,1,46,1,46,1,46,1,46,1,47,1,47,1,48,1,48,1,49,1,49,1,49,3,250,261, - 272,0,50,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9,19,10,21,11,23,12,25, - 13,27,14,29,15,31,16,33,17,35,18,37,19,39,20,41,21,43,22,45,23,47,24,49, - 25,51,26,53,27,55,28,57,29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73, - 37,75,38,77,39,79,40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,95,0,97, - 0,99,48,1,0,4,4,0,36,36,43,43,61,62,96,96,3,0,9,10,13,13,32,32,3,0,65, - 90,95,95,97,122,1,0,48,57,312,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7, - 1,0,0,0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0, - 0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0,0,0,29, - 1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0,0,0,39,1,0,0, - 0,0,41,1,0,0,0,0,43,1,0,0,0,0,45,1,0,0,0,0,47,1,0,0,0,0,49,1,0,0,0,0,51, - 1,0,0,0,0,53,1,0,0,0,0,55,1,0,0,0,0,57,1,0,0,0,0,59,1,0,0,0,0,61,1,0,0, - 0,0,63,1,0,0,0,0,65,1,0,0,0,0,67,1,0,0,0,0,69,1,0,0,0,0,71,1,0,0,0,0,73, - 1,0,0,0,0,75,1,0,0,0,0,77,1,0,0,0,0,79,1,0,0,0,0,81,1,0,0,0,0,83,1,0,0, - 0,0,85,1,0,0,0,0,87,1,0,0,0,0,89,1,0,0,0,0,91,1,0,0,0,0,93,1,0,0,0,0,99, - 1,0,0,0,1,101,1,0,0,0,3,103,1,0,0,0,5,105,1,0,0,0,7,108,1,0,0,0,9,111, - 1,0,0,0,11,115,1,0,0,0,13,124,1,0,0,0,15,128,1,0,0,0,17,131,1,0,0,0,19, - 136,1,0,0,0,21,141,1,0,0,0,23,145,1,0,0,0,25,152,1,0,0,0,27,157,1,0,0, - 0,29,163,1,0,0,0,31,167,1,0,0,0,33,174,1,0,0,0,35,181,1,0,0,0,37,192,1, - 0,0,0,39,194,1,0,0,0,41,196,1,0,0,0,43,198,1,0,0,0,45,200,1,0,0,0,47,202, - 1,0,0,0,49,204,1,0,0,0,51,206,1,0,0,0,53,209,1,0,0,0,55,212,1,0,0,0,57, - 215,1,0,0,0,59,217,1,0,0,0,61,220,1,0,0,0,63,223,1,0,0,0,65,225,1,0,0, - 0,67,227,1,0,0,0,69,229,1,0,0,0,71,231,1,0,0,0,73,233,1,0,0,0,75,235,1, - 0,0,0,77,237,1,0,0,0,79,239,1,0,0,0,81,242,1,0,0,0,83,244,1,0,0,0,85,255, - 1,0,0,0,87,266,1,0,0,0,89,283,1,0,0,0,91,287,1,0,0,0,93,295,1,0,0,0,95, - 299,1,0,0,0,97,301,1,0,0,0,99,303,1,0,0,0,101,102,5,61,0,0,102,2,1,0,0, - 0,103,104,5,62,0,0,104,4,1,0,0,0,105,106,5,43,0,0,106,107,5,43,0,0,107, - 6,1,0,0,0,108,109,5,45,0,0,109,110,5,45,0,0,110,8,1,0,0,0,111,112,5,110, - 0,0,112,113,5,101,0,0,113,114,5,119,0,0,114,10,1,0,0,0,115,116,5,118,0, - 0,116,117,5,97,0,0,117,118,5,114,0,0,118,119,5,105,0,0,119,120,5,97,0, - 0,120,121,5,98,0,0,121,122,5,108,0,0,122,123,5,101,0,0,123,12,1,0,0,0, - 124,125,5,108,0,0,125,126,5,101,0,0,126,127,5,116,0,0,127,14,1,0,0,0,128, - 129,5,105,0,0,129,130,5,102,0,0,130,16,1,0,0,0,131,132,5,116,0,0,132,133, - 5,104,0,0,133,134,5,101,0,0,134,135,5,110,0,0,135,18,1,0,0,0,136,137,5, - 101,0,0,137,138,5,108,0,0,138,139,5,115,0,0,139,140,5,101,0,0,140,20,1, - 0,0,0,141,142,5,102,0,0,142,143,5,111,0,0,143,144,5,114,0,0,144,22,1,0, - 0,0,145,146,5,114,0,0,146,147,5,101,0,0,147,148,5,116,0,0,148,149,5,117, - 0,0,149,150,5,114,0,0,150,151,5,110,0,0,151,24,1,0,0,0,152,153,5,118,0, - 0,153,154,5,111,0,0,154,155,5,105,0,0,155,156,5,100,0,0,156,26,1,0,0,0, - 157,158,5,102,0,0,158,159,5,108,0,0,159,160,5,111,0,0,160,161,5,97,0,0, - 161,162,5,116,0,0,162,28,1,0,0,0,163,164,5,105,0,0,164,165,5,110,0,0,165, - 166,5,116,0,0,166,30,1,0,0,0,167,168,5,115,0,0,168,169,5,116,0,0,169,170, - 5,114,0,0,170,171,5,105,0,0,171,172,5,110,0,0,172,173,5,103,0,0,173,32, - 1,0,0,0,174,175,5,111,0,0,175,176,5,98,0,0,176,177,5,106,0,0,177,178,5, - 101,0,0,178,179,5,99,0,0,179,180,5,116,0,0,180,34,1,0,0,0,181,182,5,101, - 0,0,182,183,5,120,0,0,183,184,5,112,0,0,184,185,5,114,0,0,185,186,5,101, - 0,0,186,187,5,115,0,0,187,188,5,115,0,0,188,189,5,105,0,0,189,190,5,111, - 0,0,190,191,5,110,0,0,191,36,1,0,0,0,192,193,7,0,0,0,193,38,1,0,0,0,194, - 195,5,58,0,0,195,40,1,0,0,0,196,197,5,59,0,0,197,42,1,0,0,0,198,199,5, - 44,0,0,199,44,1,0,0,0,200,201,5,43,0,0,201,46,1,0,0,0,202,203,5,45,0,0, - 203,48,1,0,0,0,204,205,5,42,0,0,205,50,1,0,0,0,206,207,5,61,0,0,207,208, - 5,61,0,0,208,52,1,0,0,0,209,210,5,33,0,0,210,211,5,61,0,0,211,54,1,0,0, - 0,212,213,5,62,0,0,213,214,5,61,0,0,214,56,1,0,0,0,215,216,5,60,0,0,216, - 58,1,0,0,0,217,218,5,60,0,0,218,219,5,61,0,0,219,60,1,0,0,0,220,221,5, - 61,0,0,221,222,5,62,0,0,222,62,1,0,0,0,223,224,5,40,0,0,224,64,1,0,0,0, - 225,226,5,41,0,0,226,66,1,0,0,0,227,228,5,91,0,0,228,68,1,0,0,0,229,230, - 5,93,0,0,230,70,1,0,0,0,231,232,5,123,0,0,232,72,1,0,0,0,233,234,5,125, - 0,0,234,74,1,0,0,0,235,236,5,33,0,0,236,76,1,0,0,0,237,238,5,124,0,0,238, - 78,1,0,0,0,239,240,5,124,0,0,240,241,5,124,0,0,241,80,1,0,0,0,242,243, - 5,46,0,0,243,82,1,0,0,0,244,250,5,34,0,0,245,246,5,92,0,0,246,249,5,34, - 0,0,247,249,9,0,0,0,248,245,1,0,0,0,248,247,1,0,0,0,249,252,1,0,0,0,250, - 251,1,0,0,0,250,248,1,0,0,0,251,253,1,0,0,0,252,250,1,0,0,0,253,254,5, - 34,0,0,254,84,1,0,0,0,255,261,5,96,0,0,256,257,5,92,0,0,257,260,5,34,0, - 0,258,260,9,0,0,0,259,256,1,0,0,0,259,258,1,0,0,0,260,263,1,0,0,0,261, - 262,1,0,0,0,261,259,1,0,0,0,262,264,1,0,0,0,263,261,1,0,0,0,264,265,5, - 96,0,0,265,86,1,0,0,0,266,267,5,47,0,0,267,268,5,47,0,0,268,272,1,0,0, - 0,269,271,9,0,0,0,270,269,1,0,0,0,271,274,1,0,0,0,272,273,1,0,0,0,272, - 270,1,0,0,0,273,276,1,0,0,0,274,272,1,0,0,0,275,277,5,13,0,0,276,275,1, - 0,0,0,276,277,1,0,0,0,277,278,1,0,0,0,278,279,5,10,0,0,279,280,1,0,0,0, - 280,281,6,43,0,0,281,88,1,0,0,0,282,284,3,97,48,0,283,282,1,0,0,0,284, - 285,1,0,0,0,285,283,1,0,0,0,285,286,1,0,0,0,286,90,1,0,0,0,287,292,3,95, - 47,0,288,291,3,95,47,0,289,291,3,97,48,0,290,288,1,0,0,0,290,289,1,0,0, - 0,291,294,1,0,0,0,292,290,1,0,0,0,292,293,1,0,0,0,293,92,1,0,0,0,294,292, - 1,0,0,0,295,296,7,1,0,0,296,297,1,0,0,0,297,298,6,46,0,0,298,94,1,0,0, - 0,299,300,7,2,0,0,300,96,1,0,0,0,301,302,7,3,0,0,302,98,1,0,0,0,303,304, - 5,92,0,0,304,305,5,124,0,0,305,100,1,0,0,0,10,0,248,250,259,261,272,276, - 285,290,292,1,6,0,0 - }; - - public static readonly ATN _ATN = - new ATNDeserializer().Deserialize(_serializedATN); - - -} diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.interp b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.interp deleted file mode 100644 index fbc6e3edf..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.interp +++ /dev/null @@ -1,163 +0,0 @@ -token literal names: -null -'=' -'>' -'++' -'--' -'new' -'variable' -'let' -'if' -'then' -'else' -'for' -'return' -'void' -'float' -'int' -'string' -'object' -'expression' -null -':' -';' -',' -'+' -'-' -'*' -'==' -'!=' -'>=' -'<' -'<=' -'=>' -'(' -')' -'[' -']' -'{' -'}' -'!' -'|' -'||' -'.' -null -null -null -null -null -null -'\\|' - -token symbolic names: -null -EQ -GREATER -INCREMENT -DECREMENT -NEW -VARIABLE -LET -IF -THEN -ELSE -FOR -RETURN -VOID -FLOAT -INT -STRING -OBJECT -EXPRESSION_MARKER -SYMBOL -COLON -SEMICOLON -COMMA -PLUS -MINUS -STAR -EQUALS -NOT_EQUALS -GREATER_EQUALS -LESS -LESS_EQUALS -LAMBDA -PARENTHESES_OPEN -PARENTHESES_CLOSE -BRACKET_OPEN -BRACKET_CLOSE -CURLYBRACE_OPEN -CURLYBRACE_CLOSE -EXCLAMATION -PIPE -PIPE_DBL -PERIOD -STRING_VAL -BACKTICKSTRING_VAL -LINE_COMMENT -INTEGER_VAL -ID -WS -ESC - -rule names: -EQ -GREATER -INCREMENT -DECREMENT -NEW -VARIABLE -LET -IF -THEN -ELSE -FOR -RETURN -VOID -FLOAT -INT -STRING -OBJECT -EXPRESSION_MARKER -SYMBOL -COLON -SEMICOLON -COMMA -PLUS -MINUS -STAR -EQUALS -NOT_EQUALS -GREATER_EQUALS -LESS -LESS_EQUALS -LAMBDA -PARENTHESES_OPEN -PARENTHESES_CLOSE -BRACKET_OPEN -BRACKET_CLOSE -CURLYBRACE_OPEN -CURLYBRACE_CLOSE -EXCLAMATION -PIPE -PIPE_DBL -PERIOD -STRING_VAL -BACKTICKSTRING_VAL -LINE_COMMENT -INTEGER_VAL -ID -WS -LETTER -DIGIT -ESC - -channel names: -DEFAULT_TOKEN_CHANNEL -HIDDEN - -mode names: -DEFAULT_MODE - -atn: -[4, 0, 48, 306, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 2, 21, 7, 21, 2, 22, 7, 22, 2, 23, 7, 23, 2, 24, 7, 24, 2, 25, 7, 25, 2, 26, 7, 26, 2, 27, 7, 27, 2, 28, 7, 28, 2, 29, 7, 29, 2, 30, 7, 30, 2, 31, 7, 31, 2, 32, 7, 32, 2, 33, 7, 33, 2, 34, 7, 34, 2, 35, 7, 35, 2, 36, 7, 36, 2, 37, 7, 37, 2, 38, 7, 38, 2, 39, 7, 39, 2, 40, 7, 40, 2, 41, 7, 41, 2, 42, 7, 42, 2, 43, 7, 43, 2, 44, 7, 44, 2, 45, 7, 45, 2, 46, 7, 46, 2, 47, 7, 47, 2, 48, 7, 48, 2, 49, 7, 49, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 1, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 20, 1, 20, 1, 21, 1, 21, 1, 22, 1, 22, 1, 23, 1, 23, 1, 24, 1, 24, 1, 25, 1, 25, 1, 25, 1, 26, 1, 26, 1, 26, 1, 27, 1, 27, 1, 27, 1, 28, 1, 28, 1, 29, 1, 29, 1, 29, 1, 30, 1, 30, 1, 30, 1, 31, 1, 31, 1, 32, 1, 32, 1, 33, 1, 33, 1, 34, 1, 34, 1, 35, 1, 35, 1, 36, 1, 36, 1, 37, 1, 37, 1, 38, 1, 38, 1, 39, 1, 39, 1, 39, 1, 40, 1, 40, 1, 41, 1, 41, 1, 41, 1, 41, 5, 41, 249, 8, 41, 10, 41, 12, 41, 252, 9, 41, 1, 41, 1, 41, 1, 42, 1, 42, 1, 42, 1, 42, 5, 42, 260, 8, 42, 10, 42, 12, 42, 263, 9, 42, 1, 42, 1, 42, 1, 43, 1, 43, 1, 43, 1, 43, 5, 43, 271, 8, 43, 10, 43, 12, 43, 274, 9, 43, 1, 43, 3, 43, 277, 8, 43, 1, 43, 1, 43, 1, 43, 1, 43, 1, 44, 4, 44, 284, 8, 44, 11, 44, 12, 44, 285, 1, 45, 1, 45, 1, 45, 5, 45, 291, 8, 45, 10, 45, 12, 45, 294, 9, 45, 1, 46, 1, 46, 1, 46, 1, 46, 1, 47, 1, 47, 1, 48, 1, 48, 1, 49, 1, 49, 1, 49, 3, 250, 261, 272, 0, 50, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 29, 15, 31, 16, 33, 17, 35, 18, 37, 19, 39, 20, 41, 21, 43, 22, 45, 23, 47, 24, 49, 25, 51, 26, 53, 27, 55, 28, 57, 29, 59, 30, 61, 31, 63, 32, 65, 33, 67, 34, 69, 35, 71, 36, 73, 37, 75, 38, 77, 39, 79, 40, 81, 41, 83, 42, 85, 43, 87, 44, 89, 45, 91, 46, 93, 47, 95, 0, 97, 0, 99, 48, 1, 0, 4, 4, 0, 36, 36, 43, 43, 61, 62, 96, 96, 3, 0, 9, 10, 13, 13, 32, 32, 3, 0, 65, 90, 95, 95, 97, 122, 1, 0, 48, 57, 312, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 0, 29, 1, 0, 0, 0, 0, 31, 1, 0, 0, 0, 0, 33, 1, 0, 0, 0, 0, 35, 1, 0, 0, 0, 0, 37, 1, 0, 0, 0, 0, 39, 1, 0, 0, 0, 0, 41, 1, 0, 0, 0, 0, 43, 1, 0, 0, 0, 0, 45, 1, 0, 0, 0, 0, 47, 1, 0, 0, 0, 0, 49, 1, 0, 0, 0, 0, 51, 1, 0, 0, 0, 0, 53, 1, 0, 0, 0, 0, 55, 1, 0, 0, 0, 0, 57, 1, 0, 0, 0, 0, 59, 1, 0, 0, 0, 0, 61, 1, 0, 0, 0, 0, 63, 1, 0, 0, 0, 0, 65, 1, 0, 0, 0, 0, 67, 1, 0, 0, 0, 0, 69, 1, 0, 0, 0, 0, 71, 1, 0, 0, 0, 0, 73, 1, 0, 0, 0, 0, 75, 1, 0, 0, 0, 0, 77, 1, 0, 0, 0, 0, 79, 1, 0, 0, 0, 0, 81, 1, 0, 0, 0, 0, 83, 1, 0, 0, 0, 0, 85, 1, 0, 0, 0, 0, 87, 1, 0, 0, 0, 0, 89, 1, 0, 0, 0, 0, 91, 1, 0, 0, 0, 0, 93, 1, 0, 0, 0, 0, 99, 1, 0, 0, 0, 1, 101, 1, 0, 0, 0, 3, 103, 1, 0, 0, 0, 5, 105, 1, 0, 0, 0, 7, 108, 1, 0, 0, 0, 9, 111, 1, 0, 0, 0, 11, 115, 1, 0, 0, 0, 13, 124, 1, 0, 0, 0, 15, 128, 1, 0, 0, 0, 17, 131, 1, 0, 0, 0, 19, 136, 1, 0, 0, 0, 21, 141, 1, 0, 0, 0, 23, 145, 1, 0, 0, 0, 25, 152, 1, 0, 0, 0, 27, 157, 1, 0, 0, 0, 29, 163, 1, 0, 0, 0, 31, 167, 1, 0, 0, 0, 33, 174, 1, 0, 0, 0, 35, 181, 1, 0, 0, 0, 37, 192, 1, 0, 0, 0, 39, 194, 1, 0, 0, 0, 41, 196, 1, 0, 0, 0, 43, 198, 1, 0, 0, 0, 45, 200, 1, 0, 0, 0, 47, 202, 1, 0, 0, 0, 49, 204, 1, 0, 0, 0, 51, 206, 1, 0, 0, 0, 53, 209, 1, 0, 0, 0, 55, 212, 1, 0, 0, 0, 57, 215, 1, 0, 0, 0, 59, 217, 1, 0, 0, 0, 61, 220, 1, 0, 0, 0, 63, 223, 1, 0, 0, 0, 65, 225, 1, 0, 0, 0, 67, 227, 1, 0, 0, 0, 69, 229, 1, 0, 0, 0, 71, 231, 1, 0, 0, 0, 73, 233, 1, 0, 0, 0, 75, 235, 1, 0, 0, 0, 77, 237, 1, 0, 0, 0, 79, 239, 1, 0, 0, 0, 81, 242, 1, 0, 0, 0, 83, 244, 1, 0, 0, 0, 85, 255, 1, 0, 0, 0, 87, 266, 1, 0, 0, 0, 89, 283, 1, 0, 0, 0, 91, 287, 1, 0, 0, 0, 93, 295, 1, 0, 0, 0, 95, 299, 1, 0, 0, 0, 97, 301, 1, 0, 0, 0, 99, 303, 1, 0, 0, 0, 101, 102, 5, 61, 0, 0, 102, 2, 1, 0, 0, 0, 103, 104, 5, 62, 0, 0, 104, 4, 1, 0, 0, 0, 105, 106, 5, 43, 0, 0, 106, 107, 5, 43, 0, 0, 107, 6, 1, 0, 0, 0, 108, 109, 5, 45, 0, 0, 109, 110, 5, 45, 0, 0, 110, 8, 1, 0, 0, 0, 111, 112, 5, 110, 0, 0, 112, 113, 5, 101, 0, 0, 113, 114, 5, 119, 0, 0, 114, 10, 1, 0, 0, 0, 115, 116, 5, 118, 0, 0, 116, 117, 5, 97, 0, 0, 117, 118, 5, 114, 0, 0, 118, 119, 5, 105, 0, 0, 119, 120, 5, 97, 0, 0, 120, 121, 5, 98, 0, 0, 121, 122, 5, 108, 0, 0, 122, 123, 5, 101, 0, 0, 123, 12, 1, 0, 0, 0, 124, 125, 5, 108, 0, 0, 125, 126, 5, 101, 0, 0, 126, 127, 5, 116, 0, 0, 127, 14, 1, 0, 0, 0, 128, 129, 5, 105, 0, 0, 129, 130, 5, 102, 0, 0, 130, 16, 1, 0, 0, 0, 131, 132, 5, 116, 0, 0, 132, 133, 5, 104, 0, 0, 133, 134, 5, 101, 0, 0, 134, 135, 5, 110, 0, 0, 135, 18, 1, 0, 0, 0, 136, 137, 5, 101, 0, 0, 137, 138, 5, 108, 0, 0, 138, 139, 5, 115, 0, 0, 139, 140, 5, 101, 0, 0, 140, 20, 1, 0, 0, 0, 141, 142, 5, 102, 0, 0, 142, 143, 5, 111, 0, 0, 143, 144, 5, 114, 0, 0, 144, 22, 1, 0, 0, 0, 145, 146, 5, 114, 0, 0, 146, 147, 5, 101, 0, 0, 147, 148, 5, 116, 0, 0, 148, 149, 5, 117, 0, 0, 149, 150, 5, 114, 0, 0, 150, 151, 5, 110, 0, 0, 151, 24, 1, 0, 0, 0, 152, 153, 5, 118, 0, 0, 153, 154, 5, 111, 0, 0, 154, 155, 5, 105, 0, 0, 155, 156, 5, 100, 0, 0, 156, 26, 1, 0, 0, 0, 157, 158, 5, 102, 0, 0, 158, 159, 5, 108, 0, 0, 159, 160, 5, 111, 0, 0, 160, 161, 5, 97, 0, 0, 161, 162, 5, 116, 0, 0, 162, 28, 1, 0, 0, 0, 163, 164, 5, 105, 0, 0, 164, 165, 5, 110, 0, 0, 165, 166, 5, 116, 0, 0, 166, 30, 1, 0, 0, 0, 167, 168, 5, 115, 0, 0, 168, 169, 5, 116, 0, 0, 169, 170, 5, 114, 0, 0, 170, 171, 5, 105, 0, 0, 171, 172, 5, 110, 0, 0, 172, 173, 5, 103, 0, 0, 173, 32, 1, 0, 0, 0, 174, 175, 5, 111, 0, 0, 175, 176, 5, 98, 0, 0, 176, 177, 5, 106, 0, 0, 177, 178, 5, 101, 0, 0, 178, 179, 5, 99, 0, 0, 179, 180, 5, 116, 0, 0, 180, 34, 1, 0, 0, 0, 181, 182, 5, 101, 0, 0, 182, 183, 5, 120, 0, 0, 183, 184, 5, 112, 0, 0, 184, 185, 5, 114, 0, 0, 185, 186, 5, 101, 0, 0, 186, 187, 5, 115, 0, 0, 187, 188, 5, 115, 0, 0, 188, 189, 5, 105, 0, 0, 189, 190, 5, 111, 0, 0, 190, 191, 5, 110, 0, 0, 191, 36, 1, 0, 0, 0, 192, 193, 7, 0, 0, 0, 193, 38, 1, 0, 0, 0, 194, 195, 5, 58, 0, 0, 195, 40, 1, 0, 0, 0, 196, 197, 5, 59, 0, 0, 197, 42, 1, 0, 0, 0, 198, 199, 5, 44, 0, 0, 199, 44, 1, 0, 0, 0, 200, 201, 5, 43, 0, 0, 201, 46, 1, 0, 0, 0, 202, 203, 5, 45, 0, 0, 203, 48, 1, 0, 0, 0, 204, 205, 5, 42, 0, 0, 205, 50, 1, 0, 0, 0, 206, 207, 5, 61, 0, 0, 207, 208, 5, 61, 0, 0, 208, 52, 1, 0, 0, 0, 209, 210, 5, 33, 0, 0, 210, 211, 5, 61, 0, 0, 211, 54, 1, 0, 0, 0, 212, 213, 5, 62, 0, 0, 213, 214, 5, 61, 0, 0, 214, 56, 1, 0, 0, 0, 215, 216, 5, 60, 0, 0, 216, 58, 1, 0, 0, 0, 217, 218, 5, 60, 0, 0, 218, 219, 5, 61, 0, 0, 219, 60, 1, 0, 0, 0, 220, 221, 5, 61, 0, 0, 221, 222, 5, 62, 0, 0, 222, 62, 1, 0, 0, 0, 223, 224, 5, 40, 0, 0, 224, 64, 1, 0, 0, 0, 225, 226, 5, 41, 0, 0, 226, 66, 1, 0, 0, 0, 227, 228, 5, 91, 0, 0, 228, 68, 1, 0, 0, 0, 229, 230, 5, 93, 0, 0, 230, 70, 1, 0, 0, 0, 231, 232, 5, 123, 0, 0, 232, 72, 1, 0, 0, 0, 233, 234, 5, 125, 0, 0, 234, 74, 1, 0, 0, 0, 235, 236, 5, 33, 0, 0, 236, 76, 1, 0, 0, 0, 237, 238, 5, 124, 0, 0, 238, 78, 1, 0, 0, 0, 239, 240, 5, 124, 0, 0, 240, 241, 5, 124, 0, 0, 241, 80, 1, 0, 0, 0, 242, 243, 5, 46, 0, 0, 243, 82, 1, 0, 0, 0, 244, 250, 5, 34, 0, 0, 245, 246, 5, 92, 0, 0, 246, 249, 5, 34, 0, 0, 247, 249, 9, 0, 0, 0, 248, 245, 1, 0, 0, 0, 248, 247, 1, 0, 0, 0, 249, 252, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 250, 248, 1, 0, 0, 0, 251, 253, 1, 0, 0, 0, 252, 250, 1, 0, 0, 0, 253, 254, 5, 34, 0, 0, 254, 84, 1, 0, 0, 0, 255, 261, 5, 96, 0, 0, 256, 257, 5, 92, 0, 0, 257, 260, 5, 34, 0, 0, 258, 260, 9, 0, 0, 0, 259, 256, 1, 0, 0, 0, 259, 258, 1, 0, 0, 0, 260, 263, 1, 0, 0, 0, 261, 262, 1, 0, 0, 0, 261, 259, 1, 0, 0, 0, 262, 264, 1, 0, 0, 0, 263, 261, 1, 0, 0, 0, 264, 265, 5, 96, 0, 0, 265, 86, 1, 0, 0, 0, 266, 267, 5, 47, 0, 0, 267, 268, 5, 47, 0, 0, 268, 272, 1, 0, 0, 0, 269, 271, 9, 0, 0, 0, 270, 269, 1, 0, 0, 0, 271, 274, 1, 0, 0, 0, 272, 273, 1, 0, 0, 0, 272, 270, 1, 0, 0, 0, 273, 276, 1, 0, 0, 0, 274, 272, 1, 0, 0, 0, 275, 277, 5, 13, 0, 0, 276, 275, 1, 0, 0, 0, 276, 277, 1, 0, 0, 0, 277, 278, 1, 0, 0, 0, 278, 279, 5, 10, 0, 0, 279, 280, 1, 0, 0, 0, 280, 281, 6, 43, 0, 0, 281, 88, 1, 0, 0, 0, 282, 284, 3, 97, 48, 0, 283, 282, 1, 0, 0, 0, 284, 285, 1, 0, 0, 0, 285, 283, 1, 0, 0, 0, 285, 286, 1, 0, 0, 0, 286, 90, 1, 0, 0, 0, 287, 292, 3, 95, 47, 0, 288, 291, 3, 95, 47, 0, 289, 291, 3, 97, 48, 0, 290, 288, 1, 0, 0, 0, 290, 289, 1, 0, 0, 0, 291, 294, 1, 0, 0, 0, 292, 290, 1, 0, 0, 0, 292, 293, 1, 0, 0, 0, 293, 92, 1, 0, 0, 0, 294, 292, 1, 0, 0, 0, 295, 296, 7, 1, 0, 0, 296, 297, 1, 0, 0, 0, 297, 298, 6, 46, 0, 0, 298, 94, 1, 0, 0, 0, 299, 300, 7, 2, 0, 0, 300, 96, 1, 0, 0, 0, 301, 302, 7, 3, 0, 0, 302, 98, 1, 0, 0, 0, 303, 304, 5, 92, 0, 0, 304, 305, 5, 124, 0, 0, 305, 100, 1, 0, 0, 0, 10, 0, 248, 250, 259, 261, 272, 276, 285, 290, 292, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.tokens b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.tokens deleted file mode 100644 index 0d4fb8cb2..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaLexer.tokens +++ /dev/null @@ -1,89 +0,0 @@ -EQ=1 -GREATER=2 -INCREMENT=3 -DECREMENT=4 -NEW=5 -VARIABLE=6 -LET=7 -IF=8 -THEN=9 -ELSE=10 -FOR=11 -RETURN=12 -VOID=13 -FLOAT=14 -INT=15 -STRING=16 -OBJECT=17 -EXPRESSION_MARKER=18 -SYMBOL=19 -COLON=20 -SEMICOLON=21 -COMMA=22 -PLUS=23 -MINUS=24 -STAR=25 -EQUALS=26 -NOT_EQUALS=27 -GREATER_EQUALS=28 -LESS=29 -LESS_EQUALS=30 -LAMBDA=31 -PARENTHESES_OPEN=32 -PARENTHESES_CLOSE=33 -BRACKET_OPEN=34 -BRACKET_CLOSE=35 -CURLYBRACE_OPEN=36 -CURLYBRACE_CLOSE=37 -EXCLAMATION=38 -PIPE=39 -PIPE_DBL=40 -PERIOD=41 -STRING_VAL=42 -BACKTICKSTRING_VAL=43 -LINE_COMMENT=44 -INTEGER_VAL=45 -ID=46 -WS=47 -ESC=48 -'='=1 -'>'=2 -'++'=3 -'--'=4 -'new'=5 -'variable'=6 -'let'=7 -'if'=8 -'then'=9 -'else'=10 -'for'=11 -'return'=12 -'void'=13 -'float'=14 -'int'=15 -'string'=16 -'object'=17 -'expression'=18 -':'=20 -';'=21 -','=22 -'+'=23 -'-'=24 -'*'=25 -'=='=26 -'!='=27 -'>='=28 -'<'=29 -'<='=30 -'=>'=31 -'('=32 -')'=33 -'['=34 -']'=35 -'{'=36 -'}'=37 -'!'=38 -'|'=39 -'||'=40 -'.'=41 -'\\|'=48 diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.cs b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.cs deleted file mode 100644 index 995f484bb..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.cs +++ /dev/null @@ -1,2196 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.10.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from C:/Projects/Elsa/v3/src/dsl/Elsa.Expressions.Dsl/Dsl\ElsaParser.g4 by ANTLR 4.10.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -using System; -using System.IO; -using System.Text; -using System.Diagnostics; -using System.Collections.Generic; -using Antlr4.Runtime; -using Antlr4.Runtime.Atn; -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using DFA = Antlr4.Runtime.Dfa.DFA; - -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")] -[System.CLSCompliant(false)] -public partial class ElsaParser : Parser { - protected static DFA[] decisionToDFA; - protected static PredictionContextCache sharedContextCache = new PredictionContextCache(); - public const int - EQ=1, GREATER=2, INCREMENT=3, DECREMENT=4, NEW=5, VARIABLE=6, LET=7, IF=8, - THEN=9, ELSE=10, FOR=11, RETURN=12, VOID=13, FLOAT=14, INT=15, STRING=16, - OBJECT=17, EXPRESSION_MARKER=18, SYMBOL=19, COLON=20, SEMICOLON=21, COMMA=22, - PLUS=23, MINUS=24, STAR=25, EQUALS=26, NOT_EQUALS=27, GREATER_EQUALS=28, - LESS=29, LESS_EQUALS=30, LAMBDA=31, PARENTHESES_OPEN=32, PARENTHESES_CLOSE=33, - BRACKET_OPEN=34, BRACKET_CLOSE=35, CURLYBRACE_OPEN=36, CURLYBRACE_CLOSE=37, - EXCLAMATION=38, PIPE=39, PIPE_DBL=40, PERIOD=41, STRING_VAL=42, BACKTICKSTRING_VAL=43, - LINE_COMMENT=44, INTEGER_VAL=45, ID=46, WS=47, ESC=48; - public const int - RULE_program = 0, RULE_object = 1, RULE_newObject = 2, RULE_varDecl = 3, - RULE_localVarDecl = 4, RULE_type = 5, RULE_expressionMarker = 6, RULE_expressionContent = 7, - RULE_methodCall = 8, RULE_funcCall = 9, RULE_args = 10, RULE_arg = 11, - RULE_block = 12, RULE_objectInitializer = 13, RULE_propertyList = 14, - RULE_property = 15, RULE_stat = 16, RULE_thenStat = 17, RULE_elseStat = 18, - RULE_expr = 19, RULE_exprList = 20; - public static readonly string[] ruleNames = { - "program", "object", "newObject", "varDecl", "localVarDecl", "type", "expressionMarker", - "expressionContent", "methodCall", "funcCall", "args", "arg", "block", - "objectInitializer", "propertyList", "property", "stat", "thenStat", "elseStat", - "expr", "exprList" - }; - - private static readonly string[] _LiteralNames = { - null, "'='", "'>'", "'++'", "'--'", "'new'", "'variable'", "'let'", "'if'", - "'then'", "'else'", "'for'", "'return'", "'void'", "'float'", "'int'", - "'string'", "'object'", "'expression'", null, "':'", "';'", "','", "'+'", - "'-'", "'*'", "'=='", "'!='", "'>='", "'<'", "'<='", "'=>'", "'('", "')'", - "'['", "']'", "'{'", "'}'", "'!'", "'|'", "'||'", "'.'", null, null, null, - null, null, null, "'\\|'" - }; - private static readonly string[] _SymbolicNames = { - null, "EQ", "GREATER", "INCREMENT", "DECREMENT", "NEW", "VARIABLE", "LET", - "IF", "THEN", "ELSE", "FOR", "RETURN", "VOID", "FLOAT", "INT", "STRING", - "OBJECT", "EXPRESSION_MARKER", "SYMBOL", "COLON", "SEMICOLON", "COMMA", - "PLUS", "MINUS", "STAR", "EQUALS", "NOT_EQUALS", "GREATER_EQUALS", "LESS", - "LESS_EQUALS", "LAMBDA", "PARENTHESES_OPEN", "PARENTHESES_CLOSE", "BRACKET_OPEN", - "BRACKET_CLOSE", "CURLYBRACE_OPEN", "CURLYBRACE_CLOSE", "EXCLAMATION", - "PIPE", "PIPE_DBL", "PERIOD", "STRING_VAL", "BACKTICKSTRING_VAL", "LINE_COMMENT", - "INTEGER_VAL", "ID", "WS", "ESC" - }; - public static readonly IVocabulary DefaultVocabulary = new Vocabulary(_LiteralNames, _SymbolicNames); - - [NotNull] - public override IVocabulary Vocabulary - { - get - { - return DefaultVocabulary; - } - } - - public override string GrammarFileName { get { return "ElsaParser.g4"; } } - - public override string[] RuleNames { get { return ruleNames; } } - - public override int[] SerializedAtn { get { return _serializedATN; } } - - static ElsaParser() { - decisionToDFA = new DFA[_ATN.NumberOfDecisions]; - for (int i = 0; i < _ATN.NumberOfDecisions; i++) { - decisionToDFA[i] = new DFA(_ATN.GetDecisionState(i), i); - } - } - - public ElsaParser(ITokenStream input) : this(input, Console.Out, Console.Error) { } - - public ElsaParser(ITokenStream input, TextWriter output, TextWriter errorOutput) - : base(input, output, errorOutput) - { - Interpreter = new ParserATNSimulator(this, _ATN, decisionToDFA, sharedContextCache); - } - - public partial class ProgramContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public StatContext[] stat() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public StatContext stat(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] LINE_COMMENT() { return GetTokens(ElsaParser.LINE_COMMENT); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LINE_COMMENT(int i) { - return GetToken(ElsaParser.LINE_COMMENT, i); - } - public ProgramContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_program; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitProgram(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ProgramContext program() { - ProgramContext _localctx = new ProgramContext(Context, State); - EnterRule(_localctx, 0, RULE_program); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 46; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << VARIABLE) | (1L << LET) | (1L << IF) | (1L << FOR) | (1L << RETURN) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << CURLYBRACE_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << LINE_COMMENT) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - State = 44; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case NEW: - case VARIABLE: - case LET: - case IF: - case FOR: - case RETURN: - case EXPRESSION_MARKER: - case MINUS: - case PARENTHESES_OPEN: - case BRACKET_OPEN: - case CURLYBRACE_OPEN: - case EXCLAMATION: - case STRING_VAL: - case BACKTICKSTRING_VAL: - case INTEGER_VAL: - case ID: - { - State = 42; - stat(); - } - break; - case LINE_COMMENT: - { - State = 43; - Match(LINE_COMMENT); - } - break; - default: - throw new NoViableAltException(this); - } - } - State = 48; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ObjectContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ObjectInitializerContext objectInitializer() { - return GetRuleContext(0); - } - public ObjectContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_object; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitObject(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ObjectContext @object() { - ObjectContext _localctx = new ObjectContext(Context, State); - EnterRule(_localctx, 2, RULE_object); - try { - EnterOuterAlt(_localctx, 1); - { - State = 49; - Match(ID); - State = 51; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,2,Context) ) { - case 1: - { - State = 50; - objectInitializer(); - } - break; - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class NewObjectContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NEW() { return GetToken(ElsaParser.NEW, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_OPEN() { return GetToken(ElsaParser.PARENTHESES_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_CLOSE() { return GetToken(ElsaParser.PARENTHESES_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LESS() { return GetToken(ElsaParser.LESS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GREATER() { return GetToken(ElsaParser.GREATER, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ArgsContext args() { - return GetRuleContext(0); - } - public NewObjectContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_newObject; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitNewObject(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public NewObjectContext newObject() { - NewObjectContext _localctx = new NewObjectContext(Context, State); - EnterRule(_localctx, 4, RULE_newObject); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 53; - Match(NEW); - State = 54; - Match(ID); - State = 59; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==LESS) { - { - State = 55; - Match(LESS); - State = 56; - type(); - State = 57; - Match(GREATER); - } - } - - State = 61; - Match(PARENTHESES_OPEN); - State = 63; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - State = 62; - args(); - } - } - - State = 65; - Match(PARENTHESES_CLOSE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class VarDeclContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VARIABLE() { return GetToken(ElsaParser.VARIABLE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COLON() { return GetToken(ElsaParser.COLON, 0); } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQ() { return GetToken(ElsaParser.EQ, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - public VarDeclContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_varDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitVarDecl(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public VarDeclContext varDecl() { - VarDeclContext _localctx = new VarDeclContext(Context, State); - EnterRule(_localctx, 6, RULE_varDecl); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 67; - Match(VARIABLE); - State = 68; - Match(ID); - State = 71; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==COLON) { - { - State = 69; - Match(COLON); - State = 70; - type(); - } - } - - State = 75; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==EQ) { - { - State = 73; - Match(EQ); - State = 74; - expr(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class LocalVarDeclContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LET() { return GetToken(ElsaParser.LET, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COLON() { return GetToken(ElsaParser.COLON, 0); } - [System.Diagnostics.DebuggerNonUserCode] public TypeContext type() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQ() { return GetToken(ElsaParser.EQ, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - public LocalVarDeclContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_localVarDecl; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitLocalVarDecl(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public LocalVarDeclContext localVarDecl() { - LocalVarDeclContext _localctx = new LocalVarDeclContext(Context, State); - EnterRule(_localctx, 8, RULE_localVarDecl); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 77; - Match(LET); - State = 78; - Match(ID); - State = 81; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==COLON) { - { - State = 79; - Match(COLON); - State = 80; - type(); - } - } - - State = 85; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==EQ) { - { - State = 83; - Match(EQ); - State = 84; - expr(0); - } - } - - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class TypeContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode VOID() { return GetToken(ElsaParser.VOID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FLOAT() { return GetToken(ElsaParser.FLOAT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INT() { return GetToken(ElsaParser.INT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode OBJECT() { return GetToken(ElsaParser.OBJECT, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING() { return GetToken(ElsaParser.STRING, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - public TypeContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_type; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitType(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public TypeContext type() { - TypeContext _localctx = new TypeContext(Context, State); - EnterRule(_localctx, 10, RULE_type); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 87; - _la = TokenStream.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << VOID) | (1L << FLOAT) | (1L << INT) | (1L << STRING) | (1L << OBJECT) | (1L << ID))) != 0)) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ExpressionMarkerContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EXPRESSION_MARKER() { return GetToken(ElsaParser.EXPRESSION_MARKER, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_OPEN() { return GetToken(ElsaParser.PARENTHESES_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA() { return GetToken(ElsaParser.COMMA, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExpressionContentContext expressionContent() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_CLOSE() { return GetToken(ElsaParser.PARENTHESES_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LAMBDA() { return GetToken(ElsaParser.LAMBDA, 0); } - public ExpressionMarkerContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_expressionMarker; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitExpressionMarker(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ExpressionMarkerContext expressionMarker() { - ExpressionMarkerContext _localctx = new ExpressionMarkerContext(Context, State); - EnterRule(_localctx, 12, RULE_expressionMarker); - try { - State = 99; - ErrorHandler.Sync(this); - switch (TokenStream.LA(1)) { - case EXPRESSION_MARKER: - EnterOuterAlt(_localctx, 1); - { - State = 89; - Match(EXPRESSION_MARKER); - State = 90; - Match(PARENTHESES_OPEN); - State = 91; - Match(ID); - State = 92; - Match(COMMA); - State = 93; - expressionContent(); - State = 94; - Match(PARENTHESES_CLOSE); - } - break; - case ID: - EnterOuterAlt(_localctx, 2); - { - State = 96; - Match(ID); - State = 97; - Match(LAMBDA); - State = 98; - expressionContent(); - } - break; - default: - throw new NoViableAltException(this); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ExpressionContentContext : ParserRuleContext { - public ExpressionContentContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_expressionContent; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitExpressionContent(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ExpressionContentContext expressionContent() { - ExpressionContentContext _localctx = new ExpressionContentContext(Context, State); - EnterRule(_localctx, 14, RULE_expressionContent); - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 104; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,10,Context); - while ( _alt!=1 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1+1 ) { - { - { - State = 101; - MatchWildcard(); - } - } - } - State = 106; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,10,Context); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class MethodCallContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PERIOD() { return GetToken(ElsaParser.PERIOD, 0); } - [System.Diagnostics.DebuggerNonUserCode] public FuncCallContext funcCall() { - return GetRuleContext(0); - } - public MethodCallContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_methodCall; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodCall(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public MethodCallContext methodCall() { - MethodCallContext _localctx = new MethodCallContext(Context, State); - EnterRule(_localctx, 16, RULE_methodCall); - try { - EnterOuterAlt(_localctx, 1); - { - State = 107; - Match(ID); - State = 108; - Match(PERIOD); - State = 109; - funcCall(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class FuncCallContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_OPEN() { return GetToken(ElsaParser.PARENTHESES_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_CLOSE() { return GetToken(ElsaParser.PARENTHESES_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ArgsContext args() { - return GetRuleContext(0); - } - public FuncCallContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_funcCall; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitFuncCall(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public FuncCallContext funcCall() { - FuncCallContext _localctx = new FuncCallContext(Context, State); - EnterRule(_localctx, 18, RULE_funcCall); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 111; - Match(ID); - State = 112; - Match(PARENTHESES_OPEN); - State = 114; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - State = 113; - args(); - } - } - - State = 116; - Match(PARENTHESES_CLOSE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ArgsContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ArgContext[] arg() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ArgContext arg(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ElsaParser.COMMA); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { - return GetToken(ElsaParser.COMMA, i); - } - public ArgsContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_args; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitArgs(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ArgsContext args() { - ArgsContext _localctx = new ArgsContext(Context, State); - EnterRule(_localctx, 20, RULE_args); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 118; - arg(); - State = 123; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==COMMA) { - { - { - State = 119; - Match(COMMA); - State = 120; - arg(); - } - } - State = 125; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ArgContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ExpressionMarkerContext expressionMarker() { - return GetRuleContext(0); - } - public ArgContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_arg; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitArg(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ArgContext arg() { - ArgContext _localctx = new ArgContext(Context, State); - EnterRule(_localctx, 22, RULE_arg); - try { - State = 128; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,13,Context) ) { - case 1: - EnterOuterAlt(_localctx, 1); - { - State = 126; - expr(0); - } - break; - case 2: - EnterOuterAlt(_localctx, 2); - { - State = 127; - expressionMarker(); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class BlockContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURLYBRACE_OPEN() { return GetToken(ElsaParser.CURLYBRACE_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURLYBRACE_CLOSE() { return GetToken(ElsaParser.CURLYBRACE_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public StatContext[] stat() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public StatContext stat(int i) { - return GetRuleContext(i); - } - public BlockContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_block; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitBlock(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public BlockContext block() { - BlockContext _localctx = new BlockContext(Context, State); - EnterRule(_localctx, 24, RULE_block); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 130; - Match(CURLYBRACE_OPEN); - State = 134; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << VARIABLE) | (1L << LET) | (1L << IF) | (1L << FOR) | (1L << RETURN) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << CURLYBRACE_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - { - State = 131; - stat(); - } - } - State = 136; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - State = 137; - Match(CURLYBRACE_CLOSE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ObjectInitializerContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURLYBRACE_OPEN() { return GetToken(ElsaParser.CURLYBRACE_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode CURLYBRACE_CLOSE() { return GetToken(ElsaParser.CURLYBRACE_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public PropertyListContext propertyList() { - return GetRuleContext(0); - } - public ObjectInitializerContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_objectInitializer; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitObjectInitializer(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ObjectInitializerContext objectInitializer() { - ObjectInitializerContext _localctx = new ObjectInitializerContext(Context, State); - EnterRule(_localctx, 26, RULE_objectInitializer); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 139; - Match(CURLYBRACE_OPEN); - State = 141; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if (_la==ID) { - { - State = 140; - propertyList(); - } - } - - State = 143; - Match(CURLYBRACE_CLOSE); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class PropertyListContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public PropertyContext[] property() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public PropertyContext property(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ElsaParser.COMMA); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { - return GetToken(ElsaParser.COMMA, i); - } - public PropertyListContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_propertyList; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitPropertyList(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public PropertyListContext propertyList() { - PropertyListContext _localctx = new PropertyListContext(Context, State); - EnterRule(_localctx, 28, RULE_propertyList); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 145; - property(); - State = 150; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==COMMA) { - { - { - State = 146; - Match(COMMA); - State = 147; - property(); - } - } - State = 152; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class PropertyContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COLON() { return GetToken(ElsaParser.COLON, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - public PropertyContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_property; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitProperty(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public PropertyContext property() { - PropertyContext _localctx = new PropertyContext(Context, State); - EnterRule(_localctx, 30, RULE_property); - try { - EnterOuterAlt(_localctx, 1); - { - State = 153; - Match(ID); - State = 154; - Match(COLON); - State = 155; - expr(0); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class StatContext : ParserRuleContext { - public StatContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_stat; } } - - public StatContext() { } - public virtual void CopyFrom(StatContext context) { - base.CopyFrom(context); - } - } - public partial class IfStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode IF() { return GetToken(ElsaParser.IF, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode THEN() { return GetToken(ElsaParser.THEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ThenStatContext thenStat() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ELSE() { return GetToken(ElsaParser.ELSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ElseStatContext elseStat() { - return GetRuleContext(0); - } - public IfStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitIfStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class BlockStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public BlockContext block() { - return GetRuleContext(0); - } - public BlockStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitBlockStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class ExpressionStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON() { return GetToken(ElsaParser.SEMICOLON, 0); } - public ExpressionStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitExpressionStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class ObjectStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public ObjectContext @object() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON() { return GetToken(ElsaParser.SEMICOLON, 0); } - public ObjectStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitObjectStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class ReturnStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode RETURN() { return GetToken(ElsaParser.RETURN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON() { return GetToken(ElsaParser.SEMICOLON, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - public ReturnStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitReturnStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class VariableDeclarationStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public VarDeclContext varDecl() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON() { return GetToken(ElsaParser.SEMICOLON, 0); } - public VariableDeclarationStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitVariableDeclarationStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class AssignmentStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQ() { return GetToken(ElsaParser.EQ, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON() { return GetToken(ElsaParser.SEMICOLON, 0); } - public AssignmentStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitAssignmentStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class LocalVariableDeclarationStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public LocalVarDeclContext localVarDecl() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON() { return GetToken(ElsaParser.SEMICOLON, 0); } - public LocalVariableDeclarationStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitLocalVariableDeclarationStat(this); - else return visitor.VisitChildren(this); - } - } - public partial class ForStatContext : StatContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode FOR() { return GetToken(ElsaParser.FOR, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_OPEN() { return GetToken(ElsaParser.PARENTHESES_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQ() { return GetToken(ElsaParser.EQ, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] SEMICOLON() { return GetTokens(ElsaParser.SEMICOLON); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode SEMICOLON(int i) { - return GetToken(ElsaParser.SEMICOLON, i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_CLOSE() { return GetToken(ElsaParser.PARENTHESES_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public StatContext stat() { - return GetRuleContext(0); - } - public ForStatContext(StatContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitForStat(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public StatContext stat() { - StatContext _localctx = new StatContext(Context, State); - EnterRule(_localctx, 32, RULE_stat); - int _la; - try { - State = 200; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,19,Context) ) { - case 1: - _localctx = new ObjectStatContext(_localctx); - EnterOuterAlt(_localctx, 1); - { - State = 157; - @object(); - State = 158; - Match(SEMICOLON); - } - break; - case 2: - _localctx = new IfStatContext(_localctx); - EnterOuterAlt(_localctx, 2); - { - State = 160; - Match(IF); - State = 161; - expr(0); - State = 162; - Match(THEN); - State = 163; - thenStat(); - State = 166; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,17,Context) ) { - case 1: - { - State = 164; - Match(ELSE); - State = 165; - elseStat(); - } - break; - } - } - break; - case 3: - _localctx = new ForStatContext(_localctx); - EnterOuterAlt(_localctx, 3); - { - State = 168; - Match(FOR); - State = 169; - Match(PARENTHESES_OPEN); - State = 170; - Match(ID); - State = 171; - Match(EQ); - State = 172; - expr(0); - State = 173; - Match(SEMICOLON); - State = 174; - expr(0); - State = 175; - Match(SEMICOLON); - State = 176; - expr(0); - State = 177; - Match(PARENTHESES_CLOSE); - State = 178; - stat(); - } - break; - case 4: - _localctx = new ReturnStatContext(_localctx); - EnterOuterAlt(_localctx, 4); - { - State = 180; - Match(RETURN); - State = 182; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - State = 181; - expr(0); - } - } - - State = 184; - Match(SEMICOLON); - } - break; - case 5: - _localctx = new BlockStatContext(_localctx); - EnterOuterAlt(_localctx, 5); - { - State = 185; - block(); - } - break; - case 6: - _localctx = new VariableDeclarationStatContext(_localctx); - EnterOuterAlt(_localctx, 6); - { - State = 186; - varDecl(); - State = 187; - Match(SEMICOLON); - } - break; - case 7: - _localctx = new LocalVariableDeclarationStatContext(_localctx); - EnterOuterAlt(_localctx, 7); - { - State = 189; - localVarDecl(); - State = 190; - Match(SEMICOLON); - } - break; - case 8: - _localctx = new AssignmentStatContext(_localctx); - EnterOuterAlt(_localctx, 8); - { - State = 192; - expr(0); - State = 193; - Match(EQ); - State = 194; - expr(0); - State = 195; - Match(SEMICOLON); - } - break; - case 9: - _localctx = new ExpressionStatContext(_localctx); - EnterOuterAlt(_localctx, 9); - { - State = 197; - expr(0); - State = 198; - Match(SEMICOLON); - } - break; - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ThenStatContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public StatContext stat() { - return GetRuleContext(0); - } - public ThenStatContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_thenStat; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitThenStat(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ThenStatContext thenStat() { - ThenStatContext _localctx = new ThenStatContext(Context, State); - EnterRule(_localctx, 34, RULE_thenStat); - try { - EnterOuterAlt(_localctx, 1); - { - State = 202; - stat(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ElseStatContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public StatContext stat() { - return GetRuleContext(0); - } - public ElseStatContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_elseStat; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitElseStat(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ElseStatContext elseStat() { - ElseStatContext _localctx = new ElseStatContext(Context, State); - EnterRule(_localctx, 36, RULE_elseStat); - try { - EnterOuterAlt(_localctx, 1); - { - State = 204; - stat(); - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public partial class ExprContext : ParserRuleContext { - public ExprContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_expr; } } - - public ExprContext() { } - public virtual void CopyFrom(ExprContext context) { - base.CopyFrom(context); - } - } - public partial class NewObjectExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public NewObjectContext newObject() { - return GetRuleContext(0); - } - public NewObjectExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitNewObjectExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class SubtractExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MINUS() { return GetToken(ElsaParser.MINUS, 0); } - public SubtractExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitSubtractExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class IncrementExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INCREMENT() { return GetToken(ElsaParser.INCREMENT, 0); } - public IncrementExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitIncrementExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class ObjectExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ObjectContext @object() { - return GetRuleContext(0); - } - public ObjectExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitObjectExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class StringValueExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STRING_VAL() { return GetToken(ElsaParser.STRING_VAL, 0); } - public StringValueExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitStringValueExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class MultiplyExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode STAR() { return GetToken(ElsaParser.STAR, 0); } - public MultiplyExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitMultiplyExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class ParenthesesExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_OPEN() { return GetToken(ElsaParser.PARENTHESES_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PARENTHESES_CLOSE() { return GetToken(ElsaParser.PARENTHESES_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprListContext exprList() { - return GetRuleContext(0); - } - public ParenthesesExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitParenthesesExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class FunctionExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public FuncCallContext funcCall() { - return GetRuleContext(0); - } - public FunctionExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitFunctionExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class DecrementExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode DECREMENT() { return GetToken(ElsaParser.DECREMENT, 0); } - public DecrementExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitDecrementExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class NegateExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode MINUS() { return GetToken(ElsaParser.MINUS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - public NegateExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitNegateExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class MethodCallExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public MethodCallContext methodCall() { - return GetRuleContext(0); - } - public MethodCallExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitMethodCallExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class VariableExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode ID() { return GetToken(ElsaParser.ID, 0); } - public VariableExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitVariableExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class NotExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EXCLAMATION() { return GetToken(ElsaParser.EXCLAMATION, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr() { - return GetRuleContext(0); - } - public NotExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitNotExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class IntegerValueExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode INTEGER_VAL() { return GetToken(ElsaParser.INTEGER_VAL, 0); } - public IntegerValueExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitIntegerValueExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class AddExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode PLUS() { return GetToken(ElsaParser.PLUS, 0); } - public AddExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitAddExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class ExpressionMarkerExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExpressionMarkerContext expressionMarker() { - return GetRuleContext(0); - } - public ExpressionMarkerExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitExpressionMarkerExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class BackTickStringValueExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BACKTICKSTRING_VAL() { return GetToken(ElsaParser.BACKTICKSTRING_VAL, 0); } - public BackTickStringValueExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitBackTickStringValueExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class BracketsExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BRACKET_OPEN() { return GetToken(ElsaParser.BRACKET_OPEN, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode BRACKET_CLOSE() { return GetToken(ElsaParser.BRACKET_CLOSE, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ExprListContext exprList() { - return GetRuleContext(0); - } - public BracketsExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitBracketsExpr(this); - else return visitor.VisitChildren(this); - } - } - public partial class CompareExprContext : ExprContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode EQUALS() { return GetToken(ElsaParser.EQUALS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GREATER() { return GetToken(ElsaParser.GREATER, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LESS() { return GetToken(ElsaParser.LESS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode NOT_EQUALS() { return GetToken(ElsaParser.NOT_EQUALS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode GREATER_EQUALS() { return GetToken(ElsaParser.GREATER_EQUALS, 0); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode LESS_EQUALS() { return GetToken(ElsaParser.LESS_EQUALS, 0); } - public CompareExprContext(ExprContext context) { CopyFrom(context); } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitCompareExpr(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ExprContext expr() { - return expr(0); - } - - private ExprContext expr(int _p) { - ParserRuleContext _parentctx = Context; - int _parentState = State; - ExprContext _localctx = new ExprContext(Context, _parentState); - ExprContext _prevctx = _localctx; - int _startState = 38; - EnterRecursionRule(_localctx, 38, RULE_expr, _p); - int _la; - try { - int _alt; - EnterOuterAlt(_localctx, 1); - { - State = 230; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,22,Context) ) { - case 1: - { - _localctx = new FunctionExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - - State = 207; - funcCall(); - } - break; - case 2: - { - _localctx = new ExpressionMarkerExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 208; - expressionMarker(); - } - break; - case 3: - { - _localctx = new ObjectExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 209; - @object(); - } - break; - case 4: - { - _localctx = new NewObjectExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 210; - newObject(); - } - break; - case 5: - { - _localctx = new NegateExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 211; - Match(MINUS); - State = 212; - expr(13); - } - break; - case 6: - { - _localctx = new NotExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 213; - Match(EXCLAMATION); - State = 214; - expr(12); - } - break; - case 7: - { - _localctx = new IntegerValueExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 215; - Match(INTEGER_VAL); - } - break; - case 8: - { - _localctx = new StringValueExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 216; - Match(STRING_VAL); - } - break; - case 9: - { - _localctx = new BackTickStringValueExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 217; - Match(BACKTICKSTRING_VAL); - } - break; - case 10: - { - _localctx = new ParenthesesExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 218; - Match(PARENTHESES_OPEN); - State = 220; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - State = 219; - exprList(); - } - } - - State = 222; - Match(PARENTHESES_CLOSE); - } - break; - case 11: - { - _localctx = new BracketsExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 223; - Match(BRACKET_OPEN); - State = 225; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - if ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << NEW) | (1L << EXPRESSION_MARKER) | (1L << MINUS) | (1L << PARENTHESES_OPEN) | (1L << BRACKET_OPEN) | (1L << EXCLAMATION) | (1L << STRING_VAL) | (1L << BACKTICKSTRING_VAL) | (1L << INTEGER_VAL) | (1L << ID))) != 0)) { - { - State = 224; - exprList(); - } - } - - State = 227; - Match(BRACKET_CLOSE); - } - break; - case 12: - { - _localctx = new MethodCallExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 228; - methodCall(); - } - break; - case 13: - { - _localctx = new VariableExprContext(_localctx); - Context = _localctx; - _prevctx = _localctx; - State = 229; - Match(ID); - } - break; - } - Context.Stop = TokenStream.LT(-1); - State = 250; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,24,Context); - while ( _alt!=2 && _alt!=global::Antlr4.Runtime.Atn.ATN.INVALID_ALT_NUMBER ) { - if ( _alt==1 ) { - if ( ParseListeners!=null ) - TriggerExitRuleEvent(); - _prevctx = _localctx; - { - State = 248; - ErrorHandler.Sync(this); - switch ( Interpreter.AdaptivePredict(TokenStream,23,Context) ) { - case 1: - { - _localctx = new MultiplyExprContext(new ExprContext(_parentctx, _parentState)); - PushNewRecursionContext(_localctx, _startState, RULE_expr); - State = 232; - if (!(Precpred(Context, 11))) throw new FailedPredicateException(this, "Precpred(Context, 11)"); - State = 233; - Match(STAR); - State = 234; - expr(12); - } - break; - case 2: - { - _localctx = new AddExprContext(new ExprContext(_parentctx, _parentState)); - PushNewRecursionContext(_localctx, _startState, RULE_expr); - State = 235; - if (!(Precpred(Context, 10))) throw new FailedPredicateException(this, "Precpred(Context, 10)"); - State = 236; - Match(PLUS); - State = 237; - expr(11); - } - break; - case 3: - { - _localctx = new SubtractExprContext(new ExprContext(_parentctx, _parentState)); - PushNewRecursionContext(_localctx, _startState, RULE_expr); - State = 238; - if (!(Precpred(Context, 9))) throw new FailedPredicateException(this, "Precpred(Context, 9)"); - State = 239; - Match(MINUS); - State = 240; - expr(10); - } - break; - case 4: - { - _localctx = new CompareExprContext(new ExprContext(_parentctx, _parentState)); - PushNewRecursionContext(_localctx, _startState, RULE_expr); - State = 241; - if (!(Precpred(Context, 8))) throw new FailedPredicateException(this, "Precpred(Context, 8)"); - State = 242; - _la = TokenStream.LA(1); - if ( !((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << GREATER) | (1L << EQUALS) | (1L << NOT_EQUALS) | (1L << GREATER_EQUALS) | (1L << LESS) | (1L << LESS_EQUALS))) != 0)) ) { - ErrorHandler.RecoverInline(this); - } - else { - ErrorHandler.ReportMatch(this); - Consume(); - } - State = 243; - expr(9); - } - break; - case 5: - { - _localctx = new IncrementExprContext(new ExprContext(_parentctx, _parentState)); - PushNewRecursionContext(_localctx, _startState, RULE_expr); - State = 244; - if (!(Precpred(Context, 15))) throw new FailedPredicateException(this, "Precpred(Context, 15)"); - State = 245; - Match(INCREMENT); - } - break; - case 6: - { - _localctx = new DecrementExprContext(new ExprContext(_parentctx, _parentState)); - PushNewRecursionContext(_localctx, _startState, RULE_expr); - State = 246; - if (!(Precpred(Context, 14))) throw new FailedPredicateException(this, "Precpred(Context, 14)"); - State = 247; - Match(DECREMENT); - } - break; - } - } - } - State = 252; - ErrorHandler.Sync(this); - _alt = Interpreter.AdaptivePredict(TokenStream,24,Context); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - UnrollRecursionContexts(_parentctx); - } - return _localctx; - } - - public partial class ExprListContext : ParserRuleContext { - [System.Diagnostics.DebuggerNonUserCode] public ExprContext[] expr() { - return GetRuleContexts(); - } - [System.Diagnostics.DebuggerNonUserCode] public ExprContext expr(int i) { - return GetRuleContext(i); - } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode[] COMMA() { return GetTokens(ElsaParser.COMMA); } - [System.Diagnostics.DebuggerNonUserCode] public ITerminalNode COMMA(int i) { - return GetToken(ElsaParser.COMMA, i); - } - public ExprListContext(ParserRuleContext parent, int invokingState) - : base(parent, invokingState) - { - } - public override int RuleIndex { get { return RULE_exprList; } } - [System.Diagnostics.DebuggerNonUserCode] - public override TResult Accept(IParseTreeVisitor visitor) { - IElsaParserVisitor typedVisitor = visitor as IElsaParserVisitor; - if (typedVisitor != null) return typedVisitor.VisitExprList(this); - else return visitor.VisitChildren(this); - } - } - - [RuleVersion(0)] - public ExprListContext exprList() { - ExprListContext _localctx = new ExprListContext(Context, State); - EnterRule(_localctx, 40, RULE_exprList); - int _la; - try { - EnterOuterAlt(_localctx, 1); - { - State = 253; - expr(0); - State = 258; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - while (_la==COMMA) { - { - { - State = 254; - Match(COMMA); - State = 255; - expr(0); - } - } - State = 260; - ErrorHandler.Sync(this); - _la = TokenStream.LA(1); - } - } - } - catch (RecognitionException re) { - _localctx.exception = re; - ErrorHandler.ReportError(this, re); - ErrorHandler.Recover(this, re); - } - finally { - ExitRule(); - } - return _localctx; - } - - public override bool Sempred(RuleContext _localctx, int ruleIndex, int predIndex) { - switch (ruleIndex) { - case 19: return expr_sempred((ExprContext)_localctx, predIndex); - } - return true; - } - private bool expr_sempred(ExprContext _localctx, int predIndex) { - switch (predIndex) { - case 0: return Precpred(Context, 11); - case 1: return Precpred(Context, 10); - case 2: return Precpred(Context, 9); - case 3: return Precpred(Context, 8); - case 4: return Precpred(Context, 15); - case 5: return Precpred(Context, 14); - } - return true; - } - - private static int[] _serializedATN = { - 4,1,48,262,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7,6,2,7, - 7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13,2,14,7,14, - 2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,2,20,7,20,1,0,1,0,5, - 0,45,8,0,10,0,12,0,48,9,0,1,1,1,1,3,1,52,8,1,1,2,1,2,1,2,1,2,1,2,1,2,3, - 2,60,8,2,1,2,1,2,3,2,64,8,2,1,2,1,2,1,3,1,3,1,3,1,3,3,3,72,8,3,1,3,1,3, - 3,3,76,8,3,1,4,1,4,1,4,1,4,3,4,82,8,4,1,4,1,4,3,4,86,8,4,1,5,1,5,1,6,1, - 6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,1,6,3,6,100,8,6,1,7,5,7,103,8,7,10,7,12, - 7,106,9,7,1,8,1,8,1,8,1,8,1,9,1,9,1,9,3,9,115,8,9,1,9,1,9,1,10,1,10,1, - 10,5,10,122,8,10,10,10,12,10,125,9,10,1,11,1,11,3,11,129,8,11,1,12,1,12, - 5,12,133,8,12,10,12,12,12,136,9,12,1,12,1,12,1,13,1,13,3,13,142,8,13,1, - 13,1,13,1,14,1,14,1,14,5,14,149,8,14,10,14,12,14,152,9,14,1,15,1,15,1, - 15,1,15,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,3,16,167,8,16,1,16, - 1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,3,16, - 183,8,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1,16,1, - 16,1,16,1,16,1,16,3,16,201,8,16,1,17,1,17,1,18,1,18,1,19,1,19,1,19,1,19, - 1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,3,19,221,8,19,1,19,1, - 19,1,19,3,19,226,8,19,1,19,1,19,1,19,3,19,231,8,19,1,19,1,19,1,19,1,19, - 1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,19,5,19,249,8, - 19,10,19,12,19,252,9,19,1,20,1,20,1,20,5,20,257,8,20,10,20,12,20,260,9, - 20,1,20,1,104,1,38,21,0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34, - 36,38,40,0,2,2,0,13,17,46,46,2,0,2,2,26,30,288,0,46,1,0,0,0,2,49,1,0,0, - 0,4,53,1,0,0,0,6,67,1,0,0,0,8,77,1,0,0,0,10,87,1,0,0,0,12,99,1,0,0,0,14, - 104,1,0,0,0,16,107,1,0,0,0,18,111,1,0,0,0,20,118,1,0,0,0,22,128,1,0,0, - 0,24,130,1,0,0,0,26,139,1,0,0,0,28,145,1,0,0,0,30,153,1,0,0,0,32,200,1, - 0,0,0,34,202,1,0,0,0,36,204,1,0,0,0,38,230,1,0,0,0,40,253,1,0,0,0,42,45, - 3,32,16,0,43,45,5,44,0,0,44,42,1,0,0,0,44,43,1,0,0,0,45,48,1,0,0,0,46, - 44,1,0,0,0,46,47,1,0,0,0,47,1,1,0,0,0,48,46,1,0,0,0,49,51,5,46,0,0,50, - 52,3,26,13,0,51,50,1,0,0,0,51,52,1,0,0,0,52,3,1,0,0,0,53,54,5,5,0,0,54, - 59,5,46,0,0,55,56,5,29,0,0,56,57,3,10,5,0,57,58,5,2,0,0,58,60,1,0,0,0, - 59,55,1,0,0,0,59,60,1,0,0,0,60,61,1,0,0,0,61,63,5,32,0,0,62,64,3,20,10, - 0,63,62,1,0,0,0,63,64,1,0,0,0,64,65,1,0,0,0,65,66,5,33,0,0,66,5,1,0,0, - 0,67,68,5,6,0,0,68,71,5,46,0,0,69,70,5,20,0,0,70,72,3,10,5,0,71,69,1,0, - 0,0,71,72,1,0,0,0,72,75,1,0,0,0,73,74,5,1,0,0,74,76,3,38,19,0,75,73,1, - 0,0,0,75,76,1,0,0,0,76,7,1,0,0,0,77,78,5,7,0,0,78,81,5,46,0,0,79,80,5, - 20,0,0,80,82,3,10,5,0,81,79,1,0,0,0,81,82,1,0,0,0,82,85,1,0,0,0,83,84, - 5,1,0,0,84,86,3,38,19,0,85,83,1,0,0,0,85,86,1,0,0,0,86,9,1,0,0,0,87,88, - 7,0,0,0,88,11,1,0,0,0,89,90,5,18,0,0,90,91,5,32,0,0,91,92,5,46,0,0,92, - 93,5,22,0,0,93,94,3,14,7,0,94,95,5,33,0,0,95,100,1,0,0,0,96,97,5,46,0, - 0,97,98,5,31,0,0,98,100,3,14,7,0,99,89,1,0,0,0,99,96,1,0,0,0,100,13,1, - 0,0,0,101,103,9,0,0,0,102,101,1,0,0,0,103,106,1,0,0,0,104,105,1,0,0,0, - 104,102,1,0,0,0,105,15,1,0,0,0,106,104,1,0,0,0,107,108,5,46,0,0,108,109, - 5,41,0,0,109,110,3,18,9,0,110,17,1,0,0,0,111,112,5,46,0,0,112,114,5,32, - 0,0,113,115,3,20,10,0,114,113,1,0,0,0,114,115,1,0,0,0,115,116,1,0,0,0, - 116,117,5,33,0,0,117,19,1,0,0,0,118,123,3,22,11,0,119,120,5,22,0,0,120, - 122,3,22,11,0,121,119,1,0,0,0,122,125,1,0,0,0,123,121,1,0,0,0,123,124, - 1,0,0,0,124,21,1,0,0,0,125,123,1,0,0,0,126,129,3,38,19,0,127,129,3,12, - 6,0,128,126,1,0,0,0,128,127,1,0,0,0,129,23,1,0,0,0,130,134,5,36,0,0,131, - 133,3,32,16,0,132,131,1,0,0,0,133,136,1,0,0,0,134,132,1,0,0,0,134,135, - 1,0,0,0,135,137,1,0,0,0,136,134,1,0,0,0,137,138,5,37,0,0,138,25,1,0,0, - 0,139,141,5,36,0,0,140,142,3,28,14,0,141,140,1,0,0,0,141,142,1,0,0,0,142, - 143,1,0,0,0,143,144,5,37,0,0,144,27,1,0,0,0,145,150,3,30,15,0,146,147, - 5,22,0,0,147,149,3,30,15,0,148,146,1,0,0,0,149,152,1,0,0,0,150,148,1,0, - 0,0,150,151,1,0,0,0,151,29,1,0,0,0,152,150,1,0,0,0,153,154,5,46,0,0,154, - 155,5,20,0,0,155,156,3,38,19,0,156,31,1,0,0,0,157,158,3,2,1,0,158,159, - 5,21,0,0,159,201,1,0,0,0,160,161,5,8,0,0,161,162,3,38,19,0,162,163,5,9, - 0,0,163,166,3,34,17,0,164,165,5,10,0,0,165,167,3,36,18,0,166,164,1,0,0, - 0,166,167,1,0,0,0,167,201,1,0,0,0,168,169,5,11,0,0,169,170,5,32,0,0,170, - 171,5,46,0,0,171,172,5,1,0,0,172,173,3,38,19,0,173,174,5,21,0,0,174,175, - 3,38,19,0,175,176,5,21,0,0,176,177,3,38,19,0,177,178,5,33,0,0,178,179, - 3,32,16,0,179,201,1,0,0,0,180,182,5,12,0,0,181,183,3,38,19,0,182,181,1, - 0,0,0,182,183,1,0,0,0,183,184,1,0,0,0,184,201,5,21,0,0,185,201,3,24,12, - 0,186,187,3,6,3,0,187,188,5,21,0,0,188,201,1,0,0,0,189,190,3,8,4,0,190, - 191,5,21,0,0,191,201,1,0,0,0,192,193,3,38,19,0,193,194,5,1,0,0,194,195, - 3,38,19,0,195,196,5,21,0,0,196,201,1,0,0,0,197,198,3,38,19,0,198,199,5, - 21,0,0,199,201,1,0,0,0,200,157,1,0,0,0,200,160,1,0,0,0,200,168,1,0,0,0, - 200,180,1,0,0,0,200,185,1,0,0,0,200,186,1,0,0,0,200,189,1,0,0,0,200,192, - 1,0,0,0,200,197,1,0,0,0,201,33,1,0,0,0,202,203,3,32,16,0,203,35,1,0,0, - 0,204,205,3,32,16,0,205,37,1,0,0,0,206,207,6,19,-1,0,207,231,3,18,9,0, - 208,231,3,12,6,0,209,231,3,2,1,0,210,231,3,4,2,0,211,212,5,24,0,0,212, - 231,3,38,19,13,213,214,5,38,0,0,214,231,3,38,19,12,215,231,5,45,0,0,216, - 231,5,42,0,0,217,231,5,43,0,0,218,220,5,32,0,0,219,221,3,40,20,0,220,219, - 1,0,0,0,220,221,1,0,0,0,221,222,1,0,0,0,222,231,5,33,0,0,223,225,5,34, - 0,0,224,226,3,40,20,0,225,224,1,0,0,0,225,226,1,0,0,0,226,227,1,0,0,0, - 227,231,5,35,0,0,228,231,3,16,8,0,229,231,5,46,0,0,230,206,1,0,0,0,230, - 208,1,0,0,0,230,209,1,0,0,0,230,210,1,0,0,0,230,211,1,0,0,0,230,213,1, - 0,0,0,230,215,1,0,0,0,230,216,1,0,0,0,230,217,1,0,0,0,230,218,1,0,0,0, - 230,223,1,0,0,0,230,228,1,0,0,0,230,229,1,0,0,0,231,250,1,0,0,0,232,233, - 10,11,0,0,233,234,5,25,0,0,234,249,3,38,19,12,235,236,10,10,0,0,236,237, - 5,23,0,0,237,249,3,38,19,11,238,239,10,9,0,0,239,240,5,24,0,0,240,249, - 3,38,19,10,241,242,10,8,0,0,242,243,7,1,0,0,243,249,3,38,19,9,244,245, - 10,15,0,0,245,249,5,3,0,0,246,247,10,14,0,0,247,249,5,4,0,0,248,232,1, - 0,0,0,248,235,1,0,0,0,248,238,1,0,0,0,248,241,1,0,0,0,248,244,1,0,0,0, - 248,246,1,0,0,0,249,252,1,0,0,0,250,248,1,0,0,0,250,251,1,0,0,0,251,39, - 1,0,0,0,252,250,1,0,0,0,253,258,3,38,19,0,254,255,5,22,0,0,255,257,3,38, - 19,0,256,254,1,0,0,0,257,260,1,0,0,0,258,256,1,0,0,0,258,259,1,0,0,0,259, - 41,1,0,0,0,260,258,1,0,0,0,26,44,46,51,59,63,71,75,81,85,99,104,114,123, - 128,134,141,150,166,182,200,220,225,230,248,250,258 - }; - - public static readonly ATN _ATN = - new ATNDeserializer().Deserialize(_serializedATN); - - -} diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.interp b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.interp deleted file mode 100644 index 1c4963da1..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.interp +++ /dev/null @@ -1,128 +0,0 @@ -token literal names: -null -'=' -'>' -'++' -'--' -'new' -'variable' -'let' -'if' -'then' -'else' -'for' -'return' -'void' -'float' -'int' -'string' -'object' -'expression' -null -':' -';' -',' -'+' -'-' -'*' -'==' -'!=' -'>=' -'<' -'<=' -'=>' -'(' -')' -'[' -']' -'{' -'}' -'!' -'|' -'||' -'.' -null -null -null -null -null -null -'\\|' - -token symbolic names: -null -EQ -GREATER -INCREMENT -DECREMENT -NEW -VARIABLE -LET -IF -THEN -ELSE -FOR -RETURN -VOID -FLOAT -INT -STRING -OBJECT -EXPRESSION_MARKER -SYMBOL -COLON -SEMICOLON -COMMA -PLUS -MINUS -STAR -EQUALS -NOT_EQUALS -GREATER_EQUALS -LESS -LESS_EQUALS -LAMBDA -PARENTHESES_OPEN -PARENTHESES_CLOSE -BRACKET_OPEN -BRACKET_CLOSE -CURLYBRACE_OPEN -CURLYBRACE_CLOSE -EXCLAMATION -PIPE -PIPE_DBL -PERIOD -STRING_VAL -BACKTICKSTRING_VAL -LINE_COMMENT -INTEGER_VAL -ID -WS -ESC - -rule names: -program -object -newObject -varDecl -localVarDecl -type -expressionMarker -expressionContent -methodCall -funcCall -args -arg -block -objectInitializer -propertyList -property -stat -thenStat -elseStat -expr -exprList - - -atn: -[4, 1, 48, 262, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 2, 14, 7, 14, 2, 15, 7, 15, 2, 16, 7, 16, 2, 17, 7, 17, 2, 18, 7, 18, 2, 19, 7, 19, 2, 20, 7, 20, 1, 0, 1, 0, 5, 0, 45, 8, 0, 10, 0, 12, 0, 48, 9, 0, 1, 1, 1, 1, 3, 1, 52, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 60, 8, 2, 1, 2, 1, 2, 3, 2, 64, 8, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 72, 8, 3, 1, 3, 1, 3, 3, 3, 76, 8, 3, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 82, 8, 4, 1, 4, 1, 4, 3, 4, 86, 8, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 3, 6, 100, 8, 6, 1, 7, 5, 7, 103, 8, 7, 10, 7, 12, 7, 106, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 3, 9, 115, 8, 9, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 5, 10, 122, 8, 10, 10, 10, 12, 10, 125, 9, 10, 1, 11, 1, 11, 3, 11, 129, 8, 11, 1, 12, 1, 12, 5, 12, 133, 8, 12, 10, 12, 12, 12, 136, 9, 12, 1, 12, 1, 12, 1, 13, 1, 13, 3, 13, 142, 8, 13, 1, 13, 1, 13, 1, 14, 1, 14, 1, 14, 5, 14, 149, 8, 14, 10, 14, 12, 14, 152, 9, 14, 1, 15, 1, 15, 1, 15, 1, 15, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 167, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 183, 8, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 1, 16, 3, 16, 201, 8, 16, 1, 17, 1, 17, 1, 18, 1, 18, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 3, 19, 221, 8, 19, 1, 19, 1, 19, 1, 19, 3, 19, 226, 8, 19, 1, 19, 1, 19, 1, 19, 3, 19, 231, 8, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 1, 19, 5, 19, 249, 8, 19, 10, 19, 12, 19, 252, 9, 19, 1, 20, 1, 20, 1, 20, 5, 20, 257, 8, 20, 10, 20, 12, 20, 260, 9, 20, 1, 20, 1, 104, 1, 38, 21, 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40, 0, 2, 2, 0, 13, 17, 46, 46, 2, 0, 2, 2, 26, 30, 288, 0, 46, 1, 0, 0, 0, 2, 49, 1, 0, 0, 0, 4, 53, 1, 0, 0, 0, 6, 67, 1, 0, 0, 0, 8, 77, 1, 0, 0, 0, 10, 87, 1, 0, 0, 0, 12, 99, 1, 0, 0, 0, 14, 104, 1, 0, 0, 0, 16, 107, 1, 0, 0, 0, 18, 111, 1, 0, 0, 0, 20, 118, 1, 0, 0, 0, 22, 128, 1, 0, 0, 0, 24, 130, 1, 0, 0, 0, 26, 139, 1, 0, 0, 0, 28, 145, 1, 0, 0, 0, 30, 153, 1, 0, 0, 0, 32, 200, 1, 0, 0, 0, 34, 202, 1, 0, 0, 0, 36, 204, 1, 0, 0, 0, 38, 230, 1, 0, 0, 0, 40, 253, 1, 0, 0, 0, 42, 45, 3, 32, 16, 0, 43, 45, 5, 44, 0, 0, 44, 42, 1, 0, 0, 0, 44, 43, 1, 0, 0, 0, 45, 48, 1, 0, 0, 0, 46, 44, 1, 0, 0, 0, 46, 47, 1, 0, 0, 0, 47, 1, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 49, 51, 5, 46, 0, 0, 50, 52, 3, 26, 13, 0, 51, 50, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 3, 1, 0, 0, 0, 53, 54, 5, 5, 0, 0, 54, 59, 5, 46, 0, 0, 55, 56, 5, 29, 0, 0, 56, 57, 3, 10, 5, 0, 57, 58, 5, 2, 0, 0, 58, 60, 1, 0, 0, 0, 59, 55, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 61, 1, 0, 0, 0, 61, 63, 5, 32, 0, 0, 62, 64, 3, 20, 10, 0, 63, 62, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 66, 5, 33, 0, 0, 66, 5, 1, 0, 0, 0, 67, 68, 5, 6, 0, 0, 68, 71, 5, 46, 0, 0, 69, 70, 5, 20, 0, 0, 70, 72, 3, 10, 5, 0, 71, 69, 1, 0, 0, 0, 71, 72, 1, 0, 0, 0, 72, 75, 1, 0, 0, 0, 73, 74, 5, 1, 0, 0, 74, 76, 3, 38, 19, 0, 75, 73, 1, 0, 0, 0, 75, 76, 1, 0, 0, 0, 76, 7, 1, 0, 0, 0, 77, 78, 5, 7, 0, 0, 78, 81, 5, 46, 0, 0, 79, 80, 5, 20, 0, 0, 80, 82, 3, 10, 5, 0, 81, 79, 1, 0, 0, 0, 81, 82, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 84, 5, 1, 0, 0, 84, 86, 3, 38, 19, 0, 85, 83, 1, 0, 0, 0, 85, 86, 1, 0, 0, 0, 86, 9, 1, 0, 0, 0, 87, 88, 7, 0, 0, 0, 88, 11, 1, 0, 0, 0, 89, 90, 5, 18, 0, 0, 90, 91, 5, 32, 0, 0, 91, 92, 5, 46, 0, 0, 92, 93, 5, 22, 0, 0, 93, 94, 3, 14, 7, 0, 94, 95, 5, 33, 0, 0, 95, 100, 1, 0, 0, 0, 96, 97, 5, 46, 0, 0, 97, 98, 5, 31, 0, 0, 98, 100, 3, 14, 7, 0, 99, 89, 1, 0, 0, 0, 99, 96, 1, 0, 0, 0, 100, 13, 1, 0, 0, 0, 101, 103, 9, 0, 0, 0, 102, 101, 1, 0, 0, 0, 103, 106, 1, 0, 0, 0, 104, 105, 1, 0, 0, 0, 104, 102, 1, 0, 0, 0, 105, 15, 1, 0, 0, 0, 106, 104, 1, 0, 0, 0, 107, 108, 5, 46, 0, 0, 108, 109, 5, 41, 0, 0, 109, 110, 3, 18, 9, 0, 110, 17, 1, 0, 0, 0, 111, 112, 5, 46, 0, 0, 112, 114, 5, 32, 0, 0, 113, 115, 3, 20, 10, 0, 114, 113, 1, 0, 0, 0, 114, 115, 1, 0, 0, 0, 115, 116, 1, 0, 0, 0, 116, 117, 5, 33, 0, 0, 117, 19, 1, 0, 0, 0, 118, 123, 3, 22, 11, 0, 119, 120, 5, 22, 0, 0, 120, 122, 3, 22, 11, 0, 121, 119, 1, 0, 0, 0, 122, 125, 1, 0, 0, 0, 123, 121, 1, 0, 0, 0, 123, 124, 1, 0, 0, 0, 124, 21, 1, 0, 0, 0, 125, 123, 1, 0, 0, 0, 126, 129, 3, 38, 19, 0, 127, 129, 3, 12, 6, 0, 128, 126, 1, 0, 0, 0, 128, 127, 1, 0, 0, 0, 129, 23, 1, 0, 0, 0, 130, 134, 5, 36, 0, 0, 131, 133, 3, 32, 16, 0, 132, 131, 1, 0, 0, 0, 133, 136, 1, 0, 0, 0, 134, 132, 1, 0, 0, 0, 134, 135, 1, 0, 0, 0, 135, 137, 1, 0, 0, 0, 136, 134, 1, 0, 0, 0, 137, 138, 5, 37, 0, 0, 138, 25, 1, 0, 0, 0, 139, 141, 5, 36, 0, 0, 140, 142, 3, 28, 14, 0, 141, 140, 1, 0, 0, 0, 141, 142, 1, 0, 0, 0, 142, 143, 1, 0, 0, 0, 143, 144, 5, 37, 0, 0, 144, 27, 1, 0, 0, 0, 145, 150, 3, 30, 15, 0, 146, 147, 5, 22, 0, 0, 147, 149, 3, 30, 15, 0, 148, 146, 1, 0, 0, 0, 149, 152, 1, 0, 0, 0, 150, 148, 1, 0, 0, 0, 150, 151, 1, 0, 0, 0, 151, 29, 1, 0, 0, 0, 152, 150, 1, 0, 0, 0, 153, 154, 5, 46, 0, 0, 154, 155, 5, 20, 0, 0, 155, 156, 3, 38, 19, 0, 156, 31, 1, 0, 0, 0, 157, 158, 3, 2, 1, 0, 158, 159, 5, 21, 0, 0, 159, 201, 1, 0, 0, 0, 160, 161, 5, 8, 0, 0, 161, 162, 3, 38, 19, 0, 162, 163, 5, 9, 0, 0, 163, 166, 3, 34, 17, 0, 164, 165, 5, 10, 0, 0, 165, 167, 3, 36, 18, 0, 166, 164, 1, 0, 0, 0, 166, 167, 1, 0, 0, 0, 167, 201, 1, 0, 0, 0, 168, 169, 5, 11, 0, 0, 169, 170, 5, 32, 0, 0, 170, 171, 5, 46, 0, 0, 171, 172, 5, 1, 0, 0, 172, 173, 3, 38, 19, 0, 173, 174, 5, 21, 0, 0, 174, 175, 3, 38, 19, 0, 175, 176, 5, 21, 0, 0, 176, 177, 3, 38, 19, 0, 177, 178, 5, 33, 0, 0, 178, 179, 3, 32, 16, 0, 179, 201, 1, 0, 0, 0, 180, 182, 5, 12, 0, 0, 181, 183, 3, 38, 19, 0, 182, 181, 1, 0, 0, 0, 182, 183, 1, 0, 0, 0, 183, 184, 1, 0, 0, 0, 184, 201, 5, 21, 0, 0, 185, 201, 3, 24, 12, 0, 186, 187, 3, 6, 3, 0, 187, 188, 5, 21, 0, 0, 188, 201, 1, 0, 0, 0, 189, 190, 3, 8, 4, 0, 190, 191, 5, 21, 0, 0, 191, 201, 1, 0, 0, 0, 192, 193, 3, 38, 19, 0, 193, 194, 5, 1, 0, 0, 194, 195, 3, 38, 19, 0, 195, 196, 5, 21, 0, 0, 196, 201, 1, 0, 0, 0, 197, 198, 3, 38, 19, 0, 198, 199, 5, 21, 0, 0, 199, 201, 1, 0, 0, 0, 200, 157, 1, 0, 0, 0, 200, 160, 1, 0, 0, 0, 200, 168, 1, 0, 0, 0, 200, 180, 1, 0, 0, 0, 200, 185, 1, 0, 0, 0, 200, 186, 1, 0, 0, 0, 200, 189, 1, 0, 0, 0, 200, 192, 1, 0, 0, 0, 200, 197, 1, 0, 0, 0, 201, 33, 1, 0, 0, 0, 202, 203, 3, 32, 16, 0, 203, 35, 1, 0, 0, 0, 204, 205, 3, 32, 16, 0, 205, 37, 1, 0, 0, 0, 206, 207, 6, 19, -1, 0, 207, 231, 3, 18, 9, 0, 208, 231, 3, 12, 6, 0, 209, 231, 3, 2, 1, 0, 210, 231, 3, 4, 2, 0, 211, 212, 5, 24, 0, 0, 212, 231, 3, 38, 19, 13, 213, 214, 5, 38, 0, 0, 214, 231, 3, 38, 19, 12, 215, 231, 5, 45, 0, 0, 216, 231, 5, 42, 0, 0, 217, 231, 5, 43, 0, 0, 218, 220, 5, 32, 0, 0, 219, 221, 3, 40, 20, 0, 220, 219, 1, 0, 0, 0, 220, 221, 1, 0, 0, 0, 221, 222, 1, 0, 0, 0, 222, 231, 5, 33, 0, 0, 223, 225, 5, 34, 0, 0, 224, 226, 3, 40, 20, 0, 225, 224, 1, 0, 0, 0, 225, 226, 1, 0, 0, 0, 226, 227, 1, 0, 0, 0, 227, 231, 5, 35, 0, 0, 228, 231, 3, 16, 8, 0, 229, 231, 5, 46, 0, 0, 230, 206, 1, 0, 0, 0, 230, 208, 1, 0, 0, 0, 230, 209, 1, 0, 0, 0, 230, 210, 1, 0, 0, 0, 230, 211, 1, 0, 0, 0, 230, 213, 1, 0, 0, 0, 230, 215, 1, 0, 0, 0, 230, 216, 1, 0, 0, 0, 230, 217, 1, 0, 0, 0, 230, 218, 1, 0, 0, 0, 230, 223, 1, 0, 0, 0, 230, 228, 1, 0, 0, 0, 230, 229, 1, 0, 0, 0, 231, 250, 1, 0, 0, 0, 232, 233, 10, 11, 0, 0, 233, 234, 5, 25, 0, 0, 234, 249, 3, 38, 19, 12, 235, 236, 10, 10, 0, 0, 236, 237, 5, 23, 0, 0, 237, 249, 3, 38, 19, 11, 238, 239, 10, 9, 0, 0, 239, 240, 5, 24, 0, 0, 240, 249, 3, 38, 19, 10, 241, 242, 10, 8, 0, 0, 242, 243, 7, 1, 0, 0, 243, 249, 3, 38, 19, 9, 244, 245, 10, 15, 0, 0, 245, 249, 5, 3, 0, 0, 246, 247, 10, 14, 0, 0, 247, 249, 5, 4, 0, 0, 248, 232, 1, 0, 0, 0, 248, 235, 1, 0, 0, 0, 248, 238, 1, 0, 0, 0, 248, 241, 1, 0, 0, 0, 248, 244, 1, 0, 0, 0, 248, 246, 1, 0, 0, 0, 249, 252, 1, 0, 0, 0, 250, 248, 1, 0, 0, 0, 250, 251, 1, 0, 0, 0, 251, 39, 1, 0, 0, 0, 252, 250, 1, 0, 0, 0, 253, 258, 3, 38, 19, 0, 254, 255, 5, 22, 0, 0, 255, 257, 3, 38, 19, 0, 256, 254, 1, 0, 0, 0, 257, 260, 1, 0, 0, 0, 258, 256, 1, 0, 0, 0, 258, 259, 1, 0, 0, 0, 259, 41, 1, 0, 0, 0, 260, 258, 1, 0, 0, 0, 26, 44, 46, 51, 59, 63, 71, 75, 81, 85, 99, 104, 114, 123, 128, 134, 141, 150, 166, 182, 200, 220, 225, 230, 248, 250, 258] \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.tokens b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.tokens deleted file mode 100644 index 0d4fb8cb2..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParser.tokens +++ /dev/null @@ -1,89 +0,0 @@ -EQ=1 -GREATER=2 -INCREMENT=3 -DECREMENT=4 -NEW=5 -VARIABLE=6 -LET=7 -IF=8 -THEN=9 -ELSE=10 -FOR=11 -RETURN=12 -VOID=13 -FLOAT=14 -INT=15 -STRING=16 -OBJECT=17 -EXPRESSION_MARKER=18 -SYMBOL=19 -COLON=20 -SEMICOLON=21 -COMMA=22 -PLUS=23 -MINUS=24 -STAR=25 -EQUALS=26 -NOT_EQUALS=27 -GREATER_EQUALS=28 -LESS=29 -LESS_EQUALS=30 -LAMBDA=31 -PARENTHESES_OPEN=32 -PARENTHESES_CLOSE=33 -BRACKET_OPEN=34 -BRACKET_CLOSE=35 -CURLYBRACE_OPEN=36 -CURLYBRACE_CLOSE=37 -EXCLAMATION=38 -PIPE=39 -PIPE_DBL=40 -PERIOD=41 -STRING_VAL=42 -BACKTICKSTRING_VAL=43 -LINE_COMMENT=44 -INTEGER_VAL=45 -ID=46 -WS=47 -ESC=48 -'='=1 -'>'=2 -'++'=3 -'--'=4 -'new'=5 -'variable'=6 -'let'=7 -'if'=8 -'then'=9 -'else'=10 -'for'=11 -'return'=12 -'void'=13 -'float'=14 -'int'=15 -'string'=16 -'object'=17 -'expression'=18 -':'=20 -';'=21 -','=22 -'+'=23 -'-'=24 -'*'=25 -'=='=26 -'!='=27 -'>='=28 -'<'=29 -'<='=30 -'=>'=31 -'('=32 -')'=33 -'['=34 -']'=35 -'{'=36 -'}'=37 -'!'=38 -'|'=39 -'||'=40 -'.'=41 -'\\|'=48 diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParserBaseVisitor.cs b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParserBaseVisitor.cs deleted file mode 100644 index d3da69bbb..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParserBaseVisitor.cs +++ /dev/null @@ -1,535 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.10.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from C:/Projects/Elsa/v3/src/dsl/Elsa.Expressions.Dsl/Dsl\ElsaParser.g4 by ANTLR 4.10.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using IToken = Antlr4.Runtime.IToken; -using ParserRuleContext = Antlr4.Runtime.ParserRuleContext; - -/// -/// This class provides an empty implementation of , -/// which can be extended to create a visitor which only needs to handle a subset -/// of the available methods. -/// -/// The return type of the visit operation. -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")] -[System.Diagnostics.DebuggerNonUserCode] -[System.CLSCompliant(false)] -public partial class ElsaParserBaseVisitor : AbstractParseTreeVisitor, IElsaParserVisitor { - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitProgram([NotNull] ElsaParser.ProgramContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitObject([NotNull] ElsaParser.ObjectContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNewObject([NotNull] ElsaParser.NewObjectContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVarDecl([NotNull] ElsaParser.VarDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitLocalVarDecl([NotNull] ElsaParser.LocalVarDeclContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitType([NotNull] ElsaParser.TypeContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExpressionMarker([NotNull] ElsaParser.ExpressionMarkerContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExpressionContent([NotNull] ElsaParser.ExpressionContentContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodCall([NotNull] ElsaParser.MethodCallContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFuncCall([NotNull] ElsaParser.FuncCallContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitArgs([NotNull] ElsaParser.ArgsContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitArg([NotNull] ElsaParser.ArgContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBlock([NotNull] ElsaParser.BlockContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitObjectInitializer([NotNull] ElsaParser.ObjectInitializerContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitPropertyList([NotNull] ElsaParser.PropertyListContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitProperty([NotNull] ElsaParser.PropertyContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the objectStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitObjectStat([NotNull] ElsaParser.ObjectStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the ifStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIfStat([NotNull] ElsaParser.IfStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the forStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitForStat([NotNull] ElsaParser.ForStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the returnStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitReturnStat([NotNull] ElsaParser.ReturnStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the blockStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBlockStat([NotNull] ElsaParser.BlockStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the variableDeclarationStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVariableDeclarationStat([NotNull] ElsaParser.VariableDeclarationStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the localVariableDeclarationStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitLocalVariableDeclarationStat([NotNull] ElsaParser.LocalVariableDeclarationStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the assignmentStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAssignmentStat([NotNull] ElsaParser.AssignmentStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the expressionStat - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExpressionStat([NotNull] ElsaParser.ExpressionStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitThenStat([NotNull] ElsaParser.ThenStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitElseStat([NotNull] ElsaParser.ElseStatContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the newObjectExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNewObjectExpr([NotNull] ElsaParser.NewObjectExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the subtractExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitSubtractExpr([NotNull] ElsaParser.SubtractExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the incrementExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIncrementExpr([NotNull] ElsaParser.IncrementExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the objectExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitObjectExpr([NotNull] ElsaParser.ObjectExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the stringValueExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitStringValueExpr([NotNull] ElsaParser.StringValueExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the multiplyExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMultiplyExpr([NotNull] ElsaParser.MultiplyExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the parenthesesExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitParenthesesExpr([NotNull] ElsaParser.ParenthesesExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the functionExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitFunctionExpr([NotNull] ElsaParser.FunctionExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the decrementExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitDecrementExpr([NotNull] ElsaParser.DecrementExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the negateExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNegateExpr([NotNull] ElsaParser.NegateExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the methodCallExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitMethodCallExpr([NotNull] ElsaParser.MethodCallExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the variableExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitVariableExpr([NotNull] ElsaParser.VariableExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the notExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitNotExpr([NotNull] ElsaParser.NotExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the integerValueExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitIntegerValueExpr([NotNull] ElsaParser.IntegerValueExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the addExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitAddExpr([NotNull] ElsaParser.AddExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the expressionMarkerExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExpressionMarkerExpr([NotNull] ElsaParser.ExpressionMarkerExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the backTickStringValueExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBackTickStringValueExpr([NotNull] ElsaParser.BackTickStringValueExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the bracketsExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitBracketsExpr([NotNull] ElsaParser.BracketsExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by the compareExpr - /// labeled alternative in . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitCompareExpr([NotNull] ElsaParser.CompareExprContext context) { return VisitChildren(context); } - /// - /// Visit a parse tree produced by . - /// - /// The default implementation returns the result of calling - /// on . - /// - /// - /// The parse tree. - /// The visitor result. - public virtual Result VisitExprList([NotNull] ElsaParser.ExprListContext context) { return VisitChildren(context); } -} diff --git a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParserVisitor.cs b/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParserVisitor.cs deleted file mode 100644 index 69b1a72f8..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Abstractions/ElsaParserVisitor.cs +++ /dev/null @@ -1,344 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// ANTLR Version: 4.10.1 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -// Generated from C:/Projects/Elsa/v3/src/dsl/Elsa.Expressions.Dsl/Dsl\ElsaParser.g4 by ANTLR 4.10.1 - -// Unreachable code detected -#pragma warning disable 0162 -// The variable '...' is assigned but its value is never used -#pragma warning disable 0219 -// Missing XML comment for publicly visible type or member '...' -#pragma warning disable 1591 -// Ambiguous reference in cref attribute -#pragma warning disable 419 - -using Antlr4.Runtime.Misc; -using Antlr4.Runtime.Tree; -using IToken = Antlr4.Runtime.IToken; - -/// -/// This interface defines a complete generic visitor for a parse tree produced -/// by . -/// -/// The return type of the visit operation. -[System.CodeDom.Compiler.GeneratedCode("ANTLR", "4.10.1")] -[System.CLSCompliant(false)] -public interface IElsaParserVisitor : IParseTreeVisitor { - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitProgram([NotNull] ElsaParser.ProgramContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitObject([NotNull] ElsaParser.ObjectContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitNewObject([NotNull] ElsaParser.NewObjectContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitVarDecl([NotNull] ElsaParser.VarDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitLocalVarDecl([NotNull] ElsaParser.LocalVarDeclContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitType([NotNull] ElsaParser.TypeContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExpressionMarker([NotNull] ElsaParser.ExpressionMarkerContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExpressionContent([NotNull] ElsaParser.ExpressionContentContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodCall([NotNull] ElsaParser.MethodCallContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitFuncCall([NotNull] ElsaParser.FuncCallContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitArgs([NotNull] ElsaParser.ArgsContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitArg([NotNull] ElsaParser.ArgContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitBlock([NotNull] ElsaParser.BlockContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitObjectInitializer([NotNull] ElsaParser.ObjectInitializerContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitPropertyList([NotNull] ElsaParser.PropertyListContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitProperty([NotNull] ElsaParser.PropertyContext context); - /// - /// Visit a parse tree produced by the objectStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitObjectStat([NotNull] ElsaParser.ObjectStatContext context); - /// - /// Visit a parse tree produced by the ifStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitIfStat([NotNull] ElsaParser.IfStatContext context); - /// - /// Visit a parse tree produced by the forStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitForStat([NotNull] ElsaParser.ForStatContext context); - /// - /// Visit a parse tree produced by the returnStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitReturnStat([NotNull] ElsaParser.ReturnStatContext context); - /// - /// Visit a parse tree produced by the blockStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitBlockStat([NotNull] ElsaParser.BlockStatContext context); - /// - /// Visit a parse tree produced by the variableDeclarationStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitVariableDeclarationStat([NotNull] ElsaParser.VariableDeclarationStatContext context); - /// - /// Visit a parse tree produced by the localVariableDeclarationStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitLocalVariableDeclarationStat([NotNull] ElsaParser.LocalVariableDeclarationStatContext context); - /// - /// Visit a parse tree produced by the assignmentStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitAssignmentStat([NotNull] ElsaParser.AssignmentStatContext context); - /// - /// Visit a parse tree produced by the expressionStat - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitExpressionStat([NotNull] ElsaParser.ExpressionStatContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitThenStat([NotNull] ElsaParser.ThenStatContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitElseStat([NotNull] ElsaParser.ElseStatContext context); - /// - /// Visit a parse tree produced by the newObjectExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitNewObjectExpr([NotNull] ElsaParser.NewObjectExprContext context); - /// - /// Visit a parse tree produced by the subtractExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitSubtractExpr([NotNull] ElsaParser.SubtractExprContext context); - /// - /// Visit a parse tree produced by the incrementExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitIncrementExpr([NotNull] ElsaParser.IncrementExprContext context); - /// - /// Visit a parse tree produced by the objectExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitObjectExpr([NotNull] ElsaParser.ObjectExprContext context); - /// - /// Visit a parse tree produced by the stringValueExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitStringValueExpr([NotNull] ElsaParser.StringValueExprContext context); - /// - /// Visit a parse tree produced by the multiplyExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitMultiplyExpr([NotNull] ElsaParser.MultiplyExprContext context); - /// - /// Visit a parse tree produced by the parenthesesExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitParenthesesExpr([NotNull] ElsaParser.ParenthesesExprContext context); - /// - /// Visit a parse tree produced by the functionExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitFunctionExpr([NotNull] ElsaParser.FunctionExprContext context); - /// - /// Visit a parse tree produced by the decrementExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitDecrementExpr([NotNull] ElsaParser.DecrementExprContext context); - /// - /// Visit a parse tree produced by the negateExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitNegateExpr([NotNull] ElsaParser.NegateExprContext context); - /// - /// Visit a parse tree produced by the methodCallExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitMethodCallExpr([NotNull] ElsaParser.MethodCallExprContext context); - /// - /// Visit a parse tree produced by the variableExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitVariableExpr([NotNull] ElsaParser.VariableExprContext context); - /// - /// Visit a parse tree produced by the notExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitNotExpr([NotNull] ElsaParser.NotExprContext context); - /// - /// Visit a parse tree produced by the integerValueExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitIntegerValueExpr([NotNull] ElsaParser.IntegerValueExprContext context); - /// - /// Visit a parse tree produced by the addExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitAddExpr([NotNull] ElsaParser.AddExprContext context); - /// - /// Visit a parse tree produced by the expressionMarkerExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitExpressionMarkerExpr([NotNull] ElsaParser.ExpressionMarkerExprContext context); - /// - /// Visit a parse tree produced by the backTickStringValueExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitBackTickStringValueExpr([NotNull] ElsaParser.BackTickStringValueExprContext context); - /// - /// Visit a parse tree produced by the bracketsExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitBracketsExpr([NotNull] ElsaParser.BracketsExprContext context); - /// - /// Visit a parse tree produced by the compareExpr - /// labeled alternative in . - /// - /// The parse tree. - /// The visitor result. - Result VisitCompareExpr([NotNull] ElsaParser.CompareExprContext context); - /// - /// Visit a parse tree produced by . - /// - /// The parse tree. - /// The visitor result. - Result VisitExprList([NotNull] ElsaParser.ExprListContext context); -} diff --git a/src/modules/Elsa.Expressions.Dsl/AssemblyInfo.cs b/src/modules/Elsa.Expressions.Dsl/AssemblyInfo.cs deleted file mode 100644 index 4e7f1205d..000000000 --- a/src/modules/Elsa.Expressions.Dsl/AssemblyInfo.cs +++ /dev/null @@ -1 +0,0 @@ -[assembly: CLSCompliant(false)] \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Contracts/IDslEngine.cs b/src/modules/Elsa.Expressions.Dsl/Contracts/IDslEngine.cs deleted file mode 100644 index 7a1b18ff3..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Contracts/IDslEngine.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Elsa.Workflows.Activities; - -namespace Elsa.Expressions.Dsl.Contracts; - -/// -/// Represents a DSL engine that parse a workflow definition script into a instance. -/// -public interface IDslEngine -{ - /// - /// Parses the specified script into a instance. - /// - Task ParseAsync(string script, CancellationToken cancellationToken = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Contracts/IFunctionActivityRegistry.cs b/src/modules/Elsa.Expressions.Dsl/Contracts/IFunctionActivityRegistry.cs deleted file mode 100644 index 3ad592d20..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Contracts/IFunctionActivityRegistry.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Elsa.Expressions.Dsl.Models; -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Contracts; - -/// -/// Provides a registry for mapping functions to activities that can be invoked from a DSL script. -/// -public interface IFunctionActivityRegistry -{ - /// - /// Registers a function that is mapped to an activity that can be invoked from a DSL script. - /// - /// The name of the function. - /// The name of the activity type. - /// The names of the properties that are mapped to the function arguments. - /// An optional action that can be used to configure the activity. - void RegisterFunction(string functionName, string activityTypeName, IEnumerable? propertyNames = default, Action? configure = default); - - /// - /// Registers a function that is mapped to an activity that can be invoked from a DSL script. - /// - /// The descriptor that describes the function. - void RegisterFunction(FunctionActivityDescriptor descriptor); - - /// - /// Resolves a function to an activity that can be invoked from a DSL script. - /// - /// The name of the function. - /// The arguments that are passed to the function. - /// An activity that can be invoked from a DSL script. - Task ResolveFunctionAsync(string functionName, IEnumerable? arguments = default); -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Contracts/ITypeSystem.cs b/src/modules/Elsa.Expressions.Dsl/Contracts/ITypeSystem.cs deleted file mode 100644 index 1fbaf81db..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Contracts/ITypeSystem.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Contracts; - -public interface ITypeSystem -{ - void Register(TypeDescriptor descriptor); - TypeDescriptor? ResolveTypeName(string typeName); -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/ElsaLexer.g4 b/src/modules/Elsa.Expressions.Dsl/Dsl/ElsaLexer.g4 deleted file mode 100644 index 797829459..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/ElsaLexer.g4 +++ /dev/null @@ -1,54 +0,0 @@ -lexer grammar ElsaLexer; - -EQ : '='; -GREATER : '>'; -INCREMENT : '++'; -DECREMENT : '--'; -NEW : 'new'; -VARIABLE : 'variable'; -LET : 'let'; -IF : 'if'; -THEN : 'then'; -ELSE : 'else'; -FOR : 'for'; -RETURN : 'return'; -VOID : 'void'; -FLOAT : 'float'; -INT : 'int'; -STRING : 'string'; -OBJECT : 'object'; -EXPRESSION_MARKER : 'expression'; -SYMBOL : [=>$+`]; -COLON : ':'; -SEMICOLON : ';'; -COMMA : ','; -PLUS : '+'; -MINUS : '-'; -STAR : '*'; -EQUALS : '=='; -NOT_EQUALS : '!='; -GREATER_EQUALS : '>='; -LESS : '<'; -LESS_EQUALS : '<='; -LAMBDA : '=>'; -PARENTHESES_OPEN : '('; -PARENTHESES_CLOSE : ')'; -BRACKET_OPEN : '['; -BRACKET_CLOSE : ']'; -CURLYBRACE_OPEN : '{'; -CURLYBRACE_CLOSE : '}'; -EXCLAMATION : '!'; -PIPE : '|'; -PIPE_DBL : '||'; -PERIOD : '.'; -STRING_VAL : '"' ('\\"' | .)*? '"'; -BACKTICKSTRING_VAL : '`' ('\\"' | .)*? '`'; -LINE_COMMENT : '//' .*? '\r'? '\n' -> skip; -INTEGER_VAL : DIGIT+; -ID : LETTER (LETTER | DIGIT)*; -WS : [ \t\r\n] -> skip; - -fragment LETTER : [a-zA-Z_]; -fragment DIGIT : [0-9]; - -ESC : '\\|'; \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/ElsaParser.g4 b/src/modules/Elsa.Expressions.Dsl/Dsl/ElsaParser.g4 deleted file mode 100644 index 4c5e0c86c..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/ElsaParser.g4 +++ /dev/null @@ -1,121 +0,0 @@ -parser grammar ElsaParser; - -options { tokenVocab = ElsaLexer; } - -program - : (stat | LINE_COMMENT)* - ; - -object - : ID objectInitializer? - ; - -newObject - : NEW ID ('<' type '>')? '(' args? ')' - ; - -varDecl - : VARIABLE ID (':' type)? (EQ expr)? - ; - -localVarDecl - : 'let' ID (':' type)? (EQ expr)? - ; - -type - : VOID - | FLOAT - | INT - | OBJECT - | STRING - | ID - ; - -expressionMarker - : EXPRESSION_MARKER '(' ID ',' expressionContent ')' - | ID '=>' expressionContent - ; - -expressionContent - : .*? - ; - -methodCall - : ID '.' funcCall - ; - -funcCall - : ID '(' args? ')' - ; - -args - : arg (',' arg)* - ; - -arg - : expr - | expressionMarker - ; - -block - : '{' stat* '}' - ; - -objectInitializer - : '{' propertyList? '}' - ; - -propertyList - : property (',' property)* - ; - -property - : ID ':' expr - ; - -stat - : object ';' #objectStat - | 'if' expr 'then' thenStat ('else' elseStat)? #ifStat - | 'for' '(' ID '=' expr ';' expr ';' expr ')' stat #forStat - | 'return' expr? ';' #returnStat - | block #blockStat - | varDecl ';' #variableDeclarationStat - | localVarDecl ';' #localVariableDeclarationStat - | expr '=' expr ';' #assignmentStat - | expr ';' #expressionStat - ; - -thenStat - : stat - ; - -elseStat - : stat - ; - -expr - : funcCall #functionExpr - | expressionMarker #expressionMarkerExpr - | object #objectExpr - | newObject #newObjectExpr - | expr '++' #incrementExpr - | expr '--' #decrementExpr - | '-' expr #negateExpr - | '!' expr #notExpr - | expr '*' expr #multiplyExpr - | expr '+' expr #addExpr - | expr '-' expr #subtractExpr - | expr ('==' | '>' | '<' | '!=' | '>=' | '<=') expr #compareExpr - | INTEGER_VAL #integerValueExpr - | STRING_VAL #stringValueExpr - | BACKTICKSTRING_VAL #backTickStringValueExpr - | '(' exprList? ')' #parenthesesExpr - | '[' exprList? ']' #bracketsExpr - | methodCall #methodCallExpr - | ID #variableExpr - ; - -exprList - : expr (',' expr)* - ; - \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/For.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/For.elsa deleted file mode 100644 index c0ece8f4f..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/For.elsa +++ /dev/null @@ -1,9 +0,0 @@ -variable start: int = 1; -variable end: int = read(); - -print(js => `Counting numbers from ${start} to ${end}:`); - -for(i = start; i < end; i++) -{ - print(js => `Current value: ${i}`); -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Full.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Full.elsa deleted file mode 100644 index fd9602bb9..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Full.elsa +++ /dev/null @@ -1,40 +0,0 @@ -// Triggers when HTTP request comes in. -trigger HttpTrigger -{ - Path: "/hello-world", - SupportedMethods: ["GET", "POST"] -}; - -// Triggers every 1 minute. -trigger TimerTrigger -{ - Interval: "0:00:01:00" -}; - -{ - // If - print("What's your age?"); - variable age = ReadLine; - - if age > 16 then - { - print("Enjoy your driver's license!"); - delay(5000); - print("But be careful!"); - } - else - print("Enjoy your bicycle!"); - - print("Goodbye."); - - // For - variable start: int = 1; - variable end: int = 3; - - print(context => $"Counting numbers from {start.Get(context)} to {end.Get(context)}"); - - for(i = start; i < end; i++) - { - print(context => "Current value: ${i}"); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Greeting.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Greeting.elsa deleted file mode 100644 index e17dfc953..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Greeting.elsa +++ /dev/null @@ -1,7 +0,0 @@ -{ - let name: string; - - print("Hi! What's your name?"); - read(name); - print("Nice to meet you, {name.Get(context)}!"); -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HelloGoodbye.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HelloGoodbye.elsa deleted file mode 100644 index a321f86a8..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HelloGoodbye.elsa +++ /dev/null @@ -1,4 +0,0 @@ -{ - WriteLine "Hello World" - WriteLine "Goodbye cruel World" -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HelloWorld.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HelloWorld.elsa deleted file mode 100644 index 2f2b4ad87..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HelloWorld.elsa +++ /dev/null @@ -1 +0,0 @@ -WriteLine "Hello World"; \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HttpTrigger.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HttpTrigger.elsa deleted file mode 100644 index 8960629d1..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/HttpTrigger.elsa +++ /dev/null @@ -1,14 +0,0 @@ -// Triggers when HTTP request comes in. -trigger HttpTrigger -{ - Path: "/hello-world", - SupportedMethods: ["GET", "POST"] -}; - -// Triggers every 1 minute. -trigger TimerTrigger -{ - Interval: "0:00:01:00" -}; - -WriteLine("Hello World!"); \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/If.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/If.elsa deleted file mode 100644 index 81b12c0b9..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/If.elsa +++ /dev/null @@ -1,14 +0,0 @@ -print("What's your age?"); -variable age = ReadLine; - -if age > 16 then -{ - print("Enjoy your driver's license!"); - // delay(5000); - // await signal - print("But be careful!"); -} -else - print("Enjoy your bicycle!"); - -print("Goodbye."); \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Scratchpad.elsa b/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Scratchpad.elsa deleted file mode 100644 index 7444bbbfe..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Dsl/Samples/Scratchpad.elsa +++ /dev/null @@ -1,10 +0,0 @@ -Sequence { - Activities: [ - WriteLine { Text:"writeLine1" }, - Sequence { - Activities: [ - WriteLine { Text:"writeLine2" } - ] - } - ] -}; \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Elsa.Expressions.Dsl.csproj b/src/modules/Elsa.Expressions.Dsl/Elsa.Expressions.Dsl.csproj deleted file mode 100644 index d54c0e5d5..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Elsa.Expressions.Dsl.csproj +++ /dev/null @@ -1,19 +0,0 @@ - - - - - Provides a custom DSL to write workflows with in a syntax similar to JavaScript but with native keywords translating to workflow functionality. - For example if/else would translate to the If activity. Very cool, but also very experimental ;) - - elsa module scripting dsl antlr4 - - - - - - - - - - - diff --git a/src/modules/Elsa.Expressions.Dsl/Elsa.Expressions.Dsl.csproj.DotSettings b/src/modules/Elsa.Expressions.Dsl/Elsa.Expressions.Dsl.csproj.DotSettings deleted file mode 100644 index 06d2f1f51..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Elsa.Expressions.Dsl.csproj.DotSettings +++ /dev/null @@ -1,2 +0,0 @@ - - True \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Extensions/DependencyInjectionExtensions.cs b/src/modules/Elsa.Expressions.Dsl/Extensions/DependencyInjectionExtensions.cs deleted file mode 100644 index 6f4c195be..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Extensions/DependencyInjectionExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Elsa.Expressions.Dsl.Features; -using Elsa.Features.Services; - -// ReSharper disable once CheckNamespace -namespace Elsa.Extensions; - -public static class ModuleExtensions -{ - public static IModule UseDsl(this IModule configuration, Action? configure = default) - { - configuration.Configure(configure); - return configuration; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Extensions/ListConverter.cs b/src/modules/Elsa.Expressions.Dsl/Extensions/ListConverter.cs deleted file mode 100644 index ab3ed4ad7..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Extensions/ListConverter.cs +++ /dev/null @@ -1,18 +0,0 @@ -// ReSharper disable once CheckNamespace -namespace Elsa.Extensions; - -public static class ListConverter -{ - public static T ConvertTo(this IEnumerable items) where T : IEnumerable => (T)ConvertTo(items, typeof(T)); - - public static object ConvertTo(this IEnumerable items, Type type) - { - var containedType = type.GenericTypeArguments.First(); - var enumerableType = typeof(Enumerable); - var castMethod = enumerableType.GetMethod(nameof(Enumerable.Cast))!.MakeGenericMethod(containedType); - var toListMethod = enumerableType.GetMethod(nameof(Enumerable.ToList))!.MakeGenericMethod(containedType); - var castedItems = castMethod.Invoke(null, new object?[] { items }); - - return toListMethod.Invoke(null!, new[] { castedItems })!; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Extensions/TypeSystemExtensions.cs b/src/modules/Elsa.Expressions.Dsl/Extensions/TypeSystemExtensions.cs deleted file mode 100644 index 76736f182..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Extensions/TypeSystemExtensions.cs +++ /dev/null @@ -1,42 +0,0 @@ -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Workflows; -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Extensions; - -public static class TypeSystemExtensions -{ - public static TypeDescriptor Register(this ITypeSystem typeSystem, string? typeName = default) => typeSystem.Register(typeName ?? typeof(T).Name, typeof(T)); - - public static TypeDescriptor Register(this ITypeSystem typeSystem, string typeName, Type type) - { - var kind = GetKind(type); - var descriptor = new TypeDescriptor(typeName, type, kind); - typeSystem.Register(descriptor); - return descriptor; - } - - private static TypeKind GetKind(Type type) - { - var kind = TypeKind.Unknown; - var isActivity = typeof(IActivity).IsAssignableFrom(type); - var isTrigger = typeof(IEventGenerator).IsAssignableFrom(type); - var isPrimitive = type.IsPrimitive; - var isObject = type.IsClass || type.IsValueType; - - if (isActivity || isTrigger) - { - if (isActivity) - kind |= TypeKind.Activity; - - if (isTrigger) - kind |= TypeKind.Trigger; - } - else if (isPrimitive) - kind = TypeKind.Primitive; - else if(isObject) - kind = TypeKind.Object; - - return kind; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Features/DslFeature.cs b/src/modules/Elsa.Expressions.Dsl/Features/DslFeature.cs deleted file mode 100644 index d0086e1dc..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Features/DslFeature.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Expressions.Dsl.Services; -using Elsa.Expressions.Features; -using Elsa.Features.Abstractions; -using Elsa.Features.Attributes; -using Elsa.Features.Services; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.Expressions.Dsl.Features; - -/// -[DependsOn(typeof(ExpressionsFeature))] -public class DslFeature(IModule module) : FeatureBase(module) -{ - /// - public override void Configure() - { - Services - .AddScoped() - .AddScoped() - .AddScoped(); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitArgs.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitArgs.cs deleted file mode 100644 index 608b00861..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitArgs.cs +++ /dev/null @@ -1,23 +0,0 @@ -using Antlr4.Runtime.Tree; -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitArgs(ElsaParser.ArgsContext context) - { - var args = context.arg(); - - var argValues = args.Select(x => - { - Visit(x); - var childContext = x.expr() ?? (IParseTree)x.expressionMarker(); - return _expressionValue.Get(childContext); - }).ToList(); - - _argValues.Put(context, argValues); - - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitBlockStatement.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitBlockStatement.cs deleted file mode 100644 index 2a0c42ff1..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitBlockStatement.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Elsa.Workflows; -using Elsa.Workflows.Activities; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitBlockStat(ElsaParser.BlockStatContext context) - { - VisitChildren(context); - - var value = _expressionValue.Get(context.block()); - _expressionValue.Put(context, value); - - return DefaultResult; - } - - public override IWorkflowBuilder VisitBlock(ElsaParser.BlockContext context) - { - var sequence = new Sequence(); - _containerStack.Push(sequence); - - var statements = context.stat(); - - var values = statements.Select(x => - { - Visit(x); - return _expressionValue.Get(x); - }).ToList(); - - var activities = values.OfType().ToList(); - sequence.Activities = activities; - - _containerStack.Pop(); - _expressionValue.Put(context, sequence); - - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitBrackets.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitBrackets.cs deleted file mode 100644 index 147e16af7..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitBrackets.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Elsa.Expressions.Helpers; -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - /// - public override IWorkflowBuilder VisitBracketsExpr(ElsaParser.BracketsExprContext context) - { - var propertyType = _expressionType.Get(context.Parent); - var targetElementType = propertyType?.GetGenericArguments().First() ?? typeof(object); - var contents = context.exprList().expr(); - - var items = contents.Select(x => - { - Visit(x); - var stringContext = x.GetChild(0) ?? x; - return _expressionValue.Get(stringContext); - }).ToList(); - - var stronglyTypedListType = targetElementType; - var stronglyTypedList = items.ConvertTo(stronglyTypedListType); - - _expressionValue.Put(context, stronglyTypedList); - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitExternalExpression.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitExternalExpression.cs deleted file mode 100644 index 78f6d67e6..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitExternalExpression.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Elsa.Expressions.Models; -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitExpressionMarker(ElsaParser.ExpressionMarkerContext context) - { - // var language = context.ID(); - // var expressionContent = context.expressionContent().GetText(); - // - // // TODO: Determine actual expression type based on specified language. - // var expression = new JavaScriptExpression(expressionContent); - // var expressionReference = new JavaScriptExpressionBlockReference(expression); - // var externalReference = new ExternalExpressionReference(expression, expressionReference); - // _expressionValue.Put(context, externalReference); - // _expressionValue.Put(context.Parent, externalReference); - - return DefaultResult; - } -} - -public record ExternalExpressionReference(Expression Expression, MemoryBlockReference BlockReference); \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitFile.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitFile.cs deleted file mode 100644 index 439c28cee..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitFile.cs +++ /dev/null @@ -1,38 +0,0 @@ -using Elsa.Workflows; -using Elsa.Workflows.Activities; - -namespace Elsa.Expressions.Dsl.Interpreters; - -/// -public partial class WorkflowDefinitionBuilderInterpreter -{ - /// - public override IWorkflowBuilder VisitProgram(ElsaParser.ProgramContext context) - { - var stats = context.stat(); - var rootSequence = new Sequence(); - - // Push a sequence to allow multiple activities declared in sequence. - _containerStack.Push(rootSequence); - - // Interpret child nodes. - VisitChildren(context); - - // Extract activities from child nodes. - var activities = stats.Select(x => _expressionValue.Get(x) as IActivity).Where(x => x != null).Select(x => x!).ToList(); - - if (activities.Count == 1) - { - // We only have one activity, so we can use it as the root and discard the root sequence. - _workflowBuilder.Root = activities.Single(); - } - else - { - // Assign the collected child activities to the root sequence. - rootSequence.Activities = activities.ToList(); - _workflowBuilder.Root = rootSequence; - } - - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitFunction.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitFunction.cs deleted file mode 100644 index aebb95c77..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitFunction.cs +++ /dev/null @@ -1,35 +0,0 @@ -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitExpressionStat(ElsaParser.ExpressionStatContext context) - { - VisitChildren(context); - var expressionValue = _expressionValue.Get(context.expr()); - _expressionValue.Put(context, expressionValue); - return DefaultResult; - } - - public override IWorkflowBuilder VisitFunctionExpr(ElsaParser.FunctionExprContext context) - { - VisitChildren(context); - var expressionValue = _expressionValue.Get(context.funcCall()); - _expressionValue.Put(context, expressionValue); - return DefaultResult; - } - - public override IWorkflowBuilder VisitFuncCall(ElsaParser.FuncCallContext context) - { - VisitChildren(context); - - var functionName = context.ID().GetText(); - var argsNode = context.args(); - var args = argsNode != null ? _argValues.Get(context.args()) : default; - var activity = _functionActivityRegistry.ResolveFunctionAsync(functionName, args).GetAwaiter().GetResult(); - - _expressionValue.Put(context, activity); - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitIfStatement.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitIfStatement.cs deleted file mode 100644 index 44d4779a5..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitIfStatement.cs +++ /dev/null @@ -1,33 +0,0 @@ -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitIfStat(ElsaParser.IfStatContext context) - { - // var ifActivity = new If(); - // var conditionExpr = context.expr().GetText(); - // - // var javaScriptExpression = new JavaScriptExpression(conditionExpr); - // ifActivity.Condition = new Input(javaScriptExpression, new JavaScriptExpressionBlockReference(javaScriptExpression)); - // - // var thenStat = context.thenStat().stat(); - // var elseStat = context.elseStat()?.stat(); - // - // Visit(thenStat); - // - // var thenActivity = _expressionValue.Get(thenStat); - // ifActivity.Then = (IActivity?)thenActivity; - // - // if (elseStat != null) - // { - // Visit(elseStat); - // var elseActivity = _expressionValue.Get(elseStat); - // ifActivity.Else = (IActivity?)elseActivity; - // } - // - // _expressionValue.Put(context, ifActivity); - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitLocalVariable.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitLocalVariable.cs deleted file mode 100644 index df638711a..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitLocalVariable.cs +++ /dev/null @@ -1,27 +0,0 @@ -using Elsa.Expressions.Dsl.Models; -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitLocalVarDecl(ElsaParser.LocalVarDeclContext context) - { - var variableName = context.ID().GetText(); - var variableType = context.type()?.ID().GetText(); - - VisitChildren(context); - - var value = _expressionValue.Get(context.expr()); - - var variable = new DefinedVariable - { - Identifier = variableName, - Value = value - }; - - _definedVariables[variableName] = variable; - - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitNewObject.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitNewObject.cs deleted file mode 100644 index fe2102216..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitNewObject.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Elsa.Workflows; -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitNewObjectExpr(ElsaParser.NewObjectExprContext context) - { - VisitChildren(context); - - var value = _expressionValue.Get(context.newObject()); - _expressionValue.Put(context, value); - - return DefaultResult; - } - - public override IWorkflowBuilder VisitNewObject(ElsaParser.NewObjectContext context) - { - var objectTypeName = context.ID().GetText(); - var typeArg = context.type()?.GetText(); - TypeDescriptor? typeArgTypeDescriptor = default; - - if (typeArg != null) - { - objectTypeName = $"{objectTypeName}<>"; - typeArgTypeDescriptor = _typeSystem.ResolveTypeName(typeArg) ?? throw new Exception($"Cannot use type {typeArg} as type argument because it was not found in the type system."); - } - - var typeDescriptor = _typeSystem.ResolveTypeName(objectTypeName); - - if (typeDescriptor == null) - throw new Exception($"Could not instantiate type {objectTypeName} because it was not found in the type system."); - - VisitChildren(context); - - var argValues = _argValues.Get(context.args()).ToArray(); - var objectType = typeDescriptor.Type; - - if (typeArgTypeDescriptor != null) - { - var objectTypeArg = typeArgTypeDescriptor.Type; - objectType = objectType.MakeGenericType(objectTypeArg); - } - - var objectInstance = Activator.CreateInstance(objectType, argValues); - - _expressionValue.Put(context, objectInstance); - - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitObject.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitObject.cs deleted file mode 100644 index d3a02c98b..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitObject.cs +++ /dev/null @@ -1,91 +0,0 @@ -using System.Text.Json; -using Elsa.Workflows; -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - /// - public override IWorkflowBuilder VisitObjectExpr(ElsaParser.ObjectExprContext context) - { - VisitChildren(context); - var value = _expressionValue.Get(context.@object()); - _expressionValue.Put(context, value); - - return DefaultResult; - } - - /// - public override IWorkflowBuilder VisitObjectStat(ElsaParser.ObjectStatContext context) - { - VisitChildren(context); - var value = _expressionValue.Get(context.@object()); - _expressionValue.Put(context, value); - - return DefaultResult; - } - - /// - public override IWorkflowBuilder VisitObject(ElsaParser.ObjectContext context) - { - var @object = GetObjectAsync(context).GetAwaiter().GetResult(); - - _object.Put(context, @object); - _expressionValue.Put(context, @object); - VisitChildren(context); - - return DefaultResult; - } - - private async Task GetObjectAsync(ElsaParser.ObjectContext context) - { - var objectTypeName = context.ID().GetText(); - - // First, check if the symbol matches an activity type. - var activityDescriptor = await _activityRegistryLookup.FindAsync(x => x.Name == objectTypeName); - - if (activityDescriptor != null) - { - // TODO: Refactor this to remove the dependency on JsonElement and JsonSerializerOptions. - // This limits the ability to use this class in other contexts, such as constructing activities from the DSL. - var jsonElement = JsonSerializer.Deserialize("{}"); - var ctorArgs = new ActivityConstructorContext(activityDescriptor, jsonElement, new JsonSerializerOptions()); - return activityDescriptor.Constructor(ctorArgs); - } - - var objectTypeDescriptor = _typeSystem.ResolveTypeName(objectTypeName); - - if (objectTypeDescriptor == null) - { - // Perhaps this is a variable reference? - if (_definedVariables.TryGetValue(objectTypeName, out var definedVariable)) - { - _expressionValue.Put(context, definedVariable.Value); - return DefaultResult; - } - - // Or a workflow variable? - var workflowVariableQuery = - from container in _containerStack - from variable in container.Variables - where variable.Name == objectTypeName - select variable; - - var workflowVariable = workflowVariableQuery.FirstOrDefault(); - - if (workflowVariable != null) - { - _expressionValue.Put(context, workflowVariable); - return DefaultResult; - } - - throw new Exception($"Unknown type: {objectTypeName}"); - } - - var objectType = objectTypeDescriptor.Type; - var @object = Activator.CreateInstance(objectType)!; - - return @object; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitProperty.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitProperty.cs deleted file mode 100644 index 63e7fe49e..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitProperty.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System.Reflection; -using Elsa.Expressions.Helpers; -using Elsa.Expressions.Models; -using Elsa.Workflows; -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - /// - public override IWorkflowBuilder VisitProperty(ElsaParser.PropertyContext context) - { - var @object = _object.Get(context.Parent.Parent.Parent); - var objectType = @object.GetType(); - var propertyName = context.ID().GetText(); - var propertyInfo = objectType.GetProperty(propertyName); - - if (propertyInfo == null) - throw new Exception($"Type {objectType.Name} does not have a public property named {propertyName}."); - - _expressionType.Put(context, propertyInfo.PropertyType); - VisitChildren(context); - - var propertyValue = _expressionValue.Get(context.expr()); - var propertyType = propertyInfo.PropertyType; - var parsedPropertyValue = typeof(Input).IsAssignableFrom(propertyType) ? propertyValue : propertyValue.ConvertTo(propertyType); - SetPropertyValue(@object, propertyInfo, parsedPropertyValue); - - return DefaultResult; - } - - private void SetPropertyValue(object target, PropertyInfo propertyInfo, object? value) - { - if (typeof(Input).IsAssignableFrom(propertyInfo.PropertyType)) - value = CreateInputValue(propertyInfo, value); - - propertyInfo.SetValue(target, value, null); - } - - private Input CreateInputValue(PropertyInfo propertyInfo, object? propertyValue) - { - var underlyingType = propertyInfo.PropertyType.GetGenericArguments().First(); - var parsedPropertyValue = propertyValue.ConvertTo(underlyingType); - var propertyValueType = parsedPropertyValue?.GetType(); - var inputType = typeof(Input<>).MakeGenericType(underlyingType); - - if (propertyValueType != null) - { - // Create a literal value. - var literalType = typeof(Literal<>).MakeGenericType(underlyingType); - var hasCtorWithSpecifiedType = inputType.GetConstructors().Any(x => x.GetParameters().Any(y => y.ParameterType.IsAssignableFrom(literalType))); - - if (hasCtorWithSpecifiedType) - { - var literalValue = Activator.CreateInstance(literalType, parsedPropertyValue)!; - return (Input)Activator.CreateInstance(inputType, literalValue)!; - } - } - - return parsedPropertyValue is ExternalExpressionReference externalExpressionReference - ? (Input)Activator.CreateInstance(inputType, externalExpressionReference.Expression, externalExpressionReference.BlockReference)! - : (Input)Activator.CreateInstance(inputType, parsedPropertyValue)!; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitStringValue.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitStringValue.cs deleted file mode 100644 index 4d28c01a0..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitStringValue.cs +++ /dev/null @@ -1,20 +0,0 @@ -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitStringValueExpr(ElsaParser.StringValueExprContext context) - { - var value = context.GetText().Trim('\"'); - _expressionValue.Put(context, value); - return DefaultResult; - } - - public override IWorkflowBuilder VisitBackTickStringValueExpr(ElsaParser.BackTickStringValueExprContext context) - { - var value = context.GetText().Trim('\"'); - _expressionValue.Put(context, value); - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitWorkflowVariable.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitWorkflowVariable.cs deleted file mode 100644 index 330f9e446..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/VisitWorkflowVariable.cs +++ /dev/null @@ -1,50 +0,0 @@ -using Elsa.Workflows; -using Elsa.Workflows.Memory; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter -{ - public override IWorkflowBuilder VisitVariableDeclarationStat(ElsaParser.VariableDeclarationStatContext context) - { - VisitChildren(context); - var expressionValue = _expressionValue.Get(context.varDecl()); - _expressionValue.Put(context, expressionValue); - return DefaultResult; - } - - public override IWorkflowBuilder VisitVarDecl(ElsaParser.VarDeclContext context) - { - var workflowVariableName = context.ID().GetText(); - - VisitChildren(context); - - var initExpr = context.expr(); - var workflowVariableValue = initExpr != null ? _expressionValue.Get(initExpr) : default; - - var workflowVariable = new Variable - { - Name = workflowVariableName - }; - - if (workflowVariableValue is IActivity activity) - { - // When an activity is assigned to a workflow variable, what we really are doing is setting the variable to the activity's output. - var activityType = activity.GetType(); - var outputProperty = activityType.GetProperties().FirstOrDefault(x => x.Name == "Result"); - - if (outputProperty == null) - throw new Exception("Cannot assign output of an activity that does not have an Output property."); - - var outputValue = Activator.CreateInstance(outputProperty.PropertyType, workflowVariable, default); - outputProperty.SetValue(activity, outputValue); - - _expressionValue.Put(context, activity); - } - - var currentContainer = _containerStack.Peek(); - currentContainer.Variables.Add(workflowVariable); - - return DefaultResult; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/WorkflowDefinitionBuilderInterpreter.cs b/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/WorkflowDefinitionBuilderInterpreter.cs deleted file mode 100644 index 0a718a863..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Interpreters/WorkflowDefinitionBuilderInterpreter/WorkflowDefinitionBuilderInterpreter.cs +++ /dev/null @@ -1,37 +0,0 @@ -using Antlr4.Runtime.Tree; -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Expressions.Dsl.Models; -using Elsa.Workflows; -using Elsa.Workflows.Activities; - -namespace Elsa.Expressions.Dsl.Interpreters; - -public partial class WorkflowDefinitionBuilderInterpreter : ElsaParserBaseVisitor -{ - private readonly ITypeSystem _typeSystem; - private readonly IActivityRegistryLookupService _activityRegistryLookup; - private readonly IFunctionActivityRegistry _functionActivityRegistry; - private readonly IWorkflowBuilder _workflowBuilder; - private readonly ParseTreeProperty _object = new(); - private readonly ParseTreeProperty _expressionValue = new(); - private readonly ParseTreeProperty> _argValues = new(); - private readonly ParseTreeProperty _expressionType = new(); - private readonly IDictionary _definedVariables = new Dictionary(); - private readonly Stack _containerStack = new(); - - /// - public WorkflowDefinitionBuilderInterpreter( - ITypeSystem typeSystem, - IActivityRegistryLookupService activityRegistryLookup, - IFunctionActivityRegistry functionActivityRegistry, - IWorkflowBuilderFactory workflowBuilderFactory) - { - _typeSystem = typeSystem; - _activityRegistryLookup = activityRegistryLookup; - _functionActivityRegistry = functionActivityRegistry; - _workflowBuilder = workflowBuilderFactory.CreateBuilder(); - } - - /// - protected override IWorkflowBuilder DefaultResult => _workflowBuilder; -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Models/DefinedVariable.cs b/src/modules/Elsa.Expressions.Dsl/Models/DefinedVariable.cs deleted file mode 100644 index bdae72ad1..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Models/DefinedVariable.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Elsa.Expressions.Dsl.Models; - -public class DefinedVariable -{ - public string Identifier { get; set; } = default!; - public Type Type { get; set; } = default!; - public object? Value { get; set; } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Models/FunctionActivityDescriptor.cs b/src/modules/Elsa.Expressions.Dsl/Models/FunctionActivityDescriptor.cs deleted file mode 100644 index c96d5d5fb..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Models/FunctionActivityDescriptor.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Elsa.Workflows; - -namespace Elsa.Expressions.Dsl.Models; - -/// -/// Describes a function that is mapped to an activity that can be invoked from a DSL script. -/// -/// The name of the function. -/// The name of the activity type. -/// The names of the properties that are mapped to the function arguments. -/// An optional action that can be used to configure the activity. -public record FunctionActivityDescriptor(string FunctionName, string ActivityTypeName, IEnumerable? PropertyNames = default, Action? Configure = default); \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Models/WorkflowDefinitionInterpreterSettings.cs b/src/modules/Elsa.Expressions.Dsl/Models/WorkflowDefinitionInterpreterSettings.cs deleted file mode 100644 index 242565579..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Models/WorkflowDefinitionInterpreterSettings.cs +++ /dev/null @@ -1,5 +0,0 @@ -namespace Elsa.Expressions.Dsl.Models; - -public class WorkflowDefinitionInterpreterSettings -{ -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Services/DslEngine.cs b/src/modules/Elsa.Expressions.Dsl/Services/DslEngine.cs deleted file mode 100644 index cff89cd11..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Services/DslEngine.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Antlr4.Runtime; -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Expressions.Dsl.Interpreters; -using Elsa.Workflows; -using Elsa.Workflows.Activities; - -namespace Elsa.Expressions.Dsl.Services; - -/// -public class DslEngine : IDslEngine -{ - private readonly ITypeSystem _typeSystem; - private readonly IActivityRegistryLookupService _activityRegistryLookup; - private readonly IFunctionActivityRegistry _functionActivityRegistry; - private readonly IWorkflowBuilderFactory _workflowBuilderFactory; - - /// - /// Initializes a new instance of the class. - /// - public DslEngine( - ITypeSystem typeSystem, - IActivityRegistryLookupService activityRegistryLookup, - IFunctionActivityRegistry functionActivityRegistry, - IWorkflowBuilderFactory workflowBuilderFactory) - { - _typeSystem = typeSystem; - _activityRegistryLookup = activityRegistryLookup; - _functionActivityRegistry = functionActivityRegistry; - _workflowBuilderFactory = workflowBuilderFactory; - } - - /// - public async Task ParseAsync(string script, CancellationToken cancellationToken = default) - { - var stream = CharStreams.fromString(script); - var lexer = new ElsaLexer(stream); - var tokens = new CommonTokenStream(lexer); - var parser = new ElsaParser(tokens); - var tree = parser.program(); - - var interpreter = new WorkflowDefinitionBuilderInterpreter( - _typeSystem, - _activityRegistryLookup, - _functionActivityRegistry, - _workflowBuilderFactory); - - var workflowBuilder = interpreter.Visit(tree); - var workflow = await workflowBuilder.BuildWorkflowAsync(cancellationToken); - - return workflow; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Services/FunctionActivityRegistry.cs b/src/modules/Elsa.Expressions.Dsl/Services/FunctionActivityRegistry.cs deleted file mode 100644 index 81d09d64d..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Services/FunctionActivityRegistry.cs +++ /dev/null @@ -1,139 +0,0 @@ -using System.Text.Json; -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Expressions.Dsl.Interpreters; -using Elsa.Expressions.Dsl.Models; -using Elsa.Expressions.Helpers; -using Elsa.Expressions.Models; -using Elsa.Workflows; -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Services; - -/// -public class FunctionActivityRegistry : IFunctionActivityRegistry -{ - private readonly IActivityRegistryLookupService _activityRegistryLookup; - private readonly IDictionary _dictionary = new Dictionary(); - - /// - /// Creates a new instance of the class. - /// - public FunctionActivityRegistry(IActivityRegistryLookupService activityRegistryLookup) - { - _activityRegistryLookup = activityRegistryLookup; - } - - /// - public void RegisterFunction(string functionName, string activityTypeName, IEnumerable? propertyNames = default, Action? configure = default) - { - var descriptor = new FunctionActivityDescriptor(functionName, activityTypeName, propertyNames, configure); - RegisterFunction(descriptor); - } - - /// - public void RegisterFunction(FunctionActivityDescriptor descriptor) - { - _dictionary.Add(descriptor.FunctionName, descriptor); - } - - /// - public async Task ResolveFunctionAsync(string functionName, IEnumerable? arguments = default) - { - if (!_dictionary.TryGetValue(functionName, out var descriptor)) - throw new Exception($"Could not resolve function {functionName}. Did you forget to register it?"); - - var activityDescriptor = await _activityRegistryLookup.FindAsync(x => x.Name == descriptor.ActivityTypeName || x.TypeName == descriptor.ActivityTypeName); - - if (activityDescriptor == null) - throw new Exception($"Could not find activity descriptor for activity type {descriptor.ActivityTypeName}"); - - var propertyNameList = descriptor.PropertyNames?.ToList() ?? new List(); - var propertyDescriptors = activityDescriptor.Inputs.Cast().Concat(activityDescriptor.Outputs).ToList(); - - var properties = propertyNameList - .Select(propertyName => propertyDescriptors.FirstOrDefault(x => x.Name == propertyName)) - .Where(x => x != null) - .Select(x => x!) - .ToList(); - - var dummyJsonElement = JsonDocument.Parse("{}").RootElement; - var constructorContext = new ActivityConstructorContext(activityDescriptor, dummyJsonElement, new JsonSerializerOptions()); - var activity = activityDescriptor.Constructor(constructorContext); - - // Apply each argument in order of the described properties. - var index = 0; - - if (arguments != null) - foreach (var argument in arguments) - { - var property = properties[index++]; - SetPropertyValue(activity, property, argument); - } - - descriptor.Configure?.Invoke(activity); - return activity; - } - - private void SetPropertyValue(IActivity target, PropertyDescriptor propertyDescriptor, object? value) - { - value = propertyDescriptor switch - { - InputDescriptor inputDescriptor => CreateInputValue(inputDescriptor, value), - OutputDescriptor outputDescriptor => CreateOutputValue(outputDescriptor, value), - _ => value - }; - - propertyDescriptor.ValueSetter(target, value); - } - - private Input CreateInputValue(InputDescriptor inputDescriptor, object? propertyValue) - { - if (propertyValue is Input input) - return input; - - var underlyingType = inputDescriptor.Type; - var parsedPropertyValue = propertyValue.ConvertTo(underlyingType); - var propertyValueType = parsedPropertyValue?.GetType(); - var inputType = typeof(Input<>).MakeGenericType(underlyingType); - - if (parsedPropertyValue is ExternalExpressionReference externalExpressionReference) - return (Input)Activator.CreateInstance(inputType, externalExpressionReference.Expression, externalExpressionReference.BlockReference)!; - - if (propertyValueType != null) - { - // Create a literal value. - var literalType = typeof(Literal<>).MakeGenericType(underlyingType); - var hasCtorWithSpecifiedType = inputType.GetConstructors().Any(x => x.GetParameters().Any(y => y.ParameterType.IsAssignableFrom(literalType))); - - if (hasCtorWithSpecifiedType) - { - var literalValue = Activator.CreateInstance(literalType, parsedPropertyValue)!; - return (Input)Activator.CreateInstance(inputType, literalValue)!; - } - } - - return (Input)Activator.CreateInstance(inputType, parsedPropertyValue)!; - } - - private Output CreateOutputValue(OutputDescriptor outputDescriptor, object? propertyValue) - { - if (propertyValue is Output output) - return output; - - var underlyingType = outputDescriptor.Type; - var propertyValueType = propertyValue?.GetType(); - var outputType = typeof(Output<>).MakeGenericType(underlyingType); - - if (propertyValueType != null) - { - var hasCtorWithSpecifiedType = outputType.GetConstructors().Any(x => x.GetParameters().Any(y => y.ParameterType.IsAssignableFrom(propertyValueType))); - - if (hasCtorWithSpecifiedType) - return (Output)Activator.CreateInstance(outputType, propertyValue, null)!; - } - - var convertedValue = propertyValue.ConvertTo(underlyingType); - - return (Output)Activator.CreateInstance(outputType, convertedValue)!; - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/Services/TypeSystem.cs b/src/modules/Elsa.Expressions.Dsl/Services/TypeSystem.cs deleted file mode 100644 index fdc873ece..000000000 --- a/src/modules/Elsa.Expressions.Dsl/Services/TypeSystem.cs +++ /dev/null @@ -1,19 +0,0 @@ -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Workflows.Models; - -namespace Elsa.Expressions.Dsl.Services; - -public class TypeSystem : ITypeSystem -{ - private readonly IDictionary _typeNameLookup = new Dictionary(); - private readonly IDictionary _typeLookup = new Dictionary(); - - public void Register(TypeDescriptor descriptor) - { - _typeNameLookup[descriptor.Name] = descriptor; - _typeLookup[descriptor.Type] = descriptor; - } - - public TypeDescriptor? ResolveTypeName(string typeName) => _typeNameLookup.TryGetValue(typeName, out var descriptor) ? descriptor : default; - public TypeDescriptor? ResolveType(Type type) => _typeLookup.TryGetValue(type, out var descriptor) ? descriptor : default; -} \ No newline at end of file diff --git a/src/modules/Elsa.Identity/Endpoints/Applications/Create/Models.cs b/src/modules/Elsa.Identity/Endpoints/Applications/Create/Models.cs index 417471b40..261a17610 100644 --- a/src/modules/Elsa.Identity/Endpoints/Applications/Create/Models.cs +++ b/src/modules/Elsa.Identity/Endpoints/Applications/Create/Models.cs @@ -2,7 +2,7 @@ namespace Elsa.Identity.Endpoints.Applications.Create; internal class Request { - public string Name { get; set; } = default!; + public string Name { get; set; } = null!; public ICollection? Roles { get; set; } } diff --git a/src/modules/Elsa.Identity/Endpoints/Login/Models.cs b/src/modules/Elsa.Identity/Endpoints/Login/Models.cs index 2cd05356c..8373244cd 100644 --- a/src/modules/Elsa.Identity/Endpoints/Login/Models.cs +++ b/src/modules/Elsa.Identity/Endpoints/Login/Models.cs @@ -2,6 +2,6 @@ namespace Elsa.Identity.Endpoints.Login; public class Request { - public string Username { get; set; } = default!; - public string Password { get; set; } = default!; + public string Username { get; set; } = null!; + public string Password { get; set; } = null!; } \ No newline at end of file diff --git a/src/modules/Elsa.Identity/Endpoints/Roles/Create/Models.cs b/src/modules/Elsa.Identity/Endpoints/Roles/Create/Models.cs index b520856cd..f322c2d99 100644 --- a/src/modules/Elsa.Identity/Endpoints/Roles/Create/Models.cs +++ b/src/modules/Elsa.Identity/Endpoints/Roles/Create/Models.cs @@ -2,8 +2,8 @@ namespace Elsa.Identity.Endpoints.Roles.Create; internal class Request { - public string? Id { get; set; } = default!; - public string Name { get; set; } = default!; + public string? Id { get; set; } = null!; + public string Name { get; set; } = null!; public ICollection? Permissions { get; set; } } diff --git a/src/modules/Elsa.Identity/Endpoints/Secrets/Hash/Models.cs b/src/modules/Elsa.Identity/Endpoints/Secrets/Hash/Models.cs index ebd45deda..810f3611b 100644 --- a/src/modules/Elsa.Identity/Endpoints/Secrets/Hash/Models.cs +++ b/src/modules/Elsa.Identity/Endpoints/Secrets/Hash/Models.cs @@ -4,7 +4,7 @@ namespace Elsa.Identity.Endpoints.Secrets.Hash; internal class Request { - [Required] public string Secret { get; set; } = default!; + [Required] public string Secret { get; set; } = null!; } internal class Response diff --git a/src/modules/Elsa.Identity/Endpoints/Users/Create/Models.cs b/src/modules/Elsa.Identity/Endpoints/Users/Create/Models.cs index 533af073e..afb321c8f 100644 --- a/src/modules/Elsa.Identity/Endpoints/Users/Create/Models.cs +++ b/src/modules/Elsa.Identity/Endpoints/Users/Create/Models.cs @@ -2,7 +2,7 @@ namespace Elsa.Identity.Endpoints.Users.Create; internal class Request { - public string Name { get; set; } = default!; + public string Name { get; set; } = null!; public string? Password { get; set; } public ICollection? Roles { get; set; } } diff --git a/src/modules/Elsa.Identity/Entities/Application.cs b/src/modules/Elsa.Identity/Entities/Application.cs index e83536887..d058bde7d 100644 --- a/src/modules/Elsa.Identity/Entities/Application.cs +++ b/src/modules/Elsa.Identity/Entities/Application.cs @@ -10,32 +10,32 @@ public class Application : Entity /// /// The client ID. /// - public string ClientId { get; set; } = default!; + public string ClientId { get; set; } = null!; /// /// The hashed client secret. /// - public string HashedClientSecret { get; set; } = default!; + public string HashedClientSecret { get; set; } = null!; /// /// The hashed client secret salt. /// - public string HashedClientSecretSalt { get; set; } = default!; + public string HashedClientSecretSalt { get; set; } = null!; /// /// Gets or sets the name. /// - public string Name { get; set; } = default!; + public string Name { get; set; } = null!; /// /// Gets or sets the hashed password. /// - public string HashedApiKey { get; set; } = default!; + public string HashedApiKey { get; set; } = null!; /// /// Gets or sets the hashed password salt. /// - public string HashedApiKeySalt { get; set; } = default!; + public string HashedApiKeySalt { get; set; } = null!; /// /// Gets or sets the roles. diff --git a/src/modules/Elsa.Identity/Entities/Role.cs b/src/modules/Elsa.Identity/Entities/Role.cs index 4a0ab5d15..844ac844f 100644 --- a/src/modules/Elsa.Identity/Entities/Role.cs +++ b/src/modules/Elsa.Identity/Entities/Role.cs @@ -10,7 +10,7 @@ public class Role : Entity /// /// Gets or sets the name. /// - public string Name { get; set; } = default!; + public string Name { get; set; } = null!; /// /// Gets or sets the permissions. diff --git a/src/modules/Elsa.Identity/Entities/User.cs b/src/modules/Elsa.Identity/Entities/User.cs index a12d79b35..39fbedfbd 100644 --- a/src/modules/Elsa.Identity/Entities/User.cs +++ b/src/modules/Elsa.Identity/Entities/User.cs @@ -10,17 +10,17 @@ public class User : Entity /// /// Gets or sets the name. /// - public string Name { get; set; } = default!; + public string Name { get; set; } = null!; /// /// Gets or sets the hashed password. /// - public string HashedPassword { get; set; } = default!; + public string HashedPassword { get; set; } = null!; /// /// Gets or sets the hashed password salt. /// - public string HashedPasswordSalt { get; set; } = default!; + public string HashedPasswordSalt { get; set; } = null!; /// /// Gets or sets the roles. diff --git a/src/modules/Elsa.Identity/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Identity/Extensions/ModuleExtensions.cs index 33c44a44e..a0badc6b2 100644 --- a/src/modules/Elsa.Identity/Extensions/ModuleExtensions.cs +++ b/src/modules/Elsa.Identity/Extensions/ModuleExtensions.cs @@ -12,7 +12,7 @@ public static class ModuleExtensions /// /// Installs & configures the feature. /// - public static IModule UseIdentity(this IModule module, Action configure) + public static IModule UseIdentity(this IModule module, Action? configure = null) { module.Configure(configure); return module; @@ -21,7 +21,7 @@ public static class ModuleExtensions /// /// Installs & configures the feature. /// - public static IModule UseIdentity(this IModule module, string signingKey, string issuer = "http://elsa.api", string audience = "http://elsa.api", TimeSpan? tokenLifetime = default) + public static IModule UseIdentity(this IModule module, string signingKey, string issuer = "http://elsa.api", string audience = "http://elsa.api", TimeSpan? tokenLifetime = null) { module.UseIdentity(identity => identity.TokenOptions += options => { @@ -36,7 +36,7 @@ public static class ModuleExtensions /// /// Installs & configures the feature. /// - public static IModule UseDefaultAuthentication(this IModule module, Action? configure = default) + public static IModule UseDefaultAuthentication(this IModule module, Action? configure = null) { module.Configure(configure); return module; diff --git a/src/modules/Elsa.Identity/Options/IdentityTokenOptions.cs b/src/modules/Elsa.Identity/Options/IdentityTokenOptions.cs index de2cd6ad4..78069cff3 100644 --- a/src/modules/Elsa.Identity/Options/IdentityTokenOptions.cs +++ b/src/modules/Elsa.Identity/Options/IdentityTokenOptions.cs @@ -14,7 +14,7 @@ public class IdentityTokenOptions /// /// The key to use when signing tokens /// - public string SigningKey { get; set; } = default!; + public string SigningKey { get; set; } = null!; /// /// The issuer to use when creating and validating tokens diff --git a/src/modules/Elsa.Identity/Services/DefaultApplicationCredentialsValidator.cs b/src/modules/Elsa.Identity/Services/DefaultApplicationCredentialsValidator.cs index f5f9f3585..39ea24066 100644 --- a/src/modules/Elsa.Identity/Services/DefaultApplicationCredentialsValidator.cs +++ b/src/modules/Elsa.Identity/Services/DefaultApplicationCredentialsValidator.cs @@ -27,15 +27,15 @@ public class DefaultApplicationCredentialsValidator : IApplicationCredentialsVal public async ValueTask ValidateAsync(string apiKey, CancellationToken cancellationToken = default) { if(string.IsNullOrWhiteSpace(apiKey)) - return default; + return null; var clientId = _apiKeyParser.Parse(apiKey); var application = await _applicationProvider.FindByClientIdAsync(clientId, cancellationToken); if(application == null) - return default; + return null; var isValidApiKey = _secretHasher.VerifySecret(apiKey, application.HashedApiKey, application.HashedApiKeySalt); - return isValidApiKey ? application : default; + return isValidApiKey ? application : null; } } \ No newline at end of file diff --git a/src/modules/Elsa.Identity/Services/DefaultUserCredentialsValidator.cs b/src/modules/Elsa.Identity/Services/DefaultUserCredentialsValidator.cs index d52b90db1..21d7fdbff 100644 --- a/src/modules/Elsa.Identity/Services/DefaultUserCredentialsValidator.cs +++ b/src/modules/Elsa.Identity/Services/DefaultUserCredentialsValidator.cs @@ -27,10 +27,10 @@ public class DefaultUserCredentialsValidator : IUserCredentialsValidator var user = await _userProvider.FindByNameAsync(username, cancellationToken); if (user == null) - return default; + return null; var isValidPassword = _secretHasher.VerifySecret(password, user.HashedPassword, user.HashedPasswordSalt); - return isValidPassword ? user : default; + return isValidPassword ? user : null; } } \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Activities/Cron.cs b/src/modules/Elsa.Scheduling/Activities/Cron.cs new file mode 100644 index 000000000..6f0f84012 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Activities/Cron.cs @@ -0,0 +1,66 @@ +using System.Runtime.CompilerServices; +using Elsa.Extensions; +using Elsa.Scheduling.Bookmarks; +using Elsa.Workflows; +using Elsa.Workflows.Attributes; +using Elsa.Workflows.Models; + +namespace Elsa.Scheduling.Activities; + +/// +/// Represents a timer to periodically trigger the workflow. +/// +[Activity("Elsa", "Scheduling", "Trigger workflow execution at a specific interval using a CRON expression.")] +public class Cron : EventGenerator +{ + /// + public Cron([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + } + + /// + public Cron(string cronExpression, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input(cronExpression), source, line) + { + } + + /// + public Cron(Input cronExpression, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(source, line) + { + CronExpression = cronExpression; + } + + /// + /// The interval at which the timer should execute. + /// + [Input(Description = "The CRON expression at which the timer should execute.")] + public Input CronExpression { get; set; } = null!; + + /// + protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) + { + if(context.IsTriggerOfWorkflow()) + { + await context.CompleteActivityAsync(); + return; + } + + var cronParser = context.GetRequiredService(); + var cronExpression = context.ExpressionExecutionContext.Get(CronExpression)!; + var executeAt = cronParser.GetNextOccurrence(cronExpression); + + context.JournalData.Add("ExecuteAt", executeAt); + context.CreateBookmark(new CronBookmarkPayload(executeAt, cronExpression)); + } + + /// + protected override object GetTriggerPayload(TriggerIndexingContext context) + { + var cronExpression = context.ExpressionExecutionContext.Get(CronExpression)!; + return new CronTriggerPayload(cronExpression); + } + + /// + /// Creates a new activity set to trigger at the specified cron expression. + /// + public static Cron FromCronExpression(string value, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(value, source, line); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Activities/Delay.cs b/src/modules/Elsa.Scheduling/Activities/Delay.cs new file mode 100644 index 000000000..3b3c82e14 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Activities/Delay.cs @@ -0,0 +1,113 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using Elsa.Expressions.Models; +using Elsa.Extensions; +using Elsa.Workflows; +using Elsa.Workflows.Attributes; +using Elsa.Workflows.Memory; +using Elsa.Workflows.Models; + +namespace Elsa.Scheduling.Activities; + +/// +/// Delay execution for the specified amount of time. +/// +[Activity("Elsa", "Scheduling", "Delay execution for the specified amount of time.")] +public class Delay : Activity, IActivityPropertyDefaultValueProvider +{ + /// + public Delay([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + } + + /// + public Delay( + Func timeSpan, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input(timeSpan), source, line) + { + } + + /// + public Delay( + Func> timeSpan, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input(timeSpan), source, line) + { + } + + /// + public Delay( + Input timeSpan, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + TimeSpan = timeSpan; + } + + /// + public Delay( + TimeSpan timeSpan, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + TimeSpan = new Input(timeSpan); + } + + /// + public Delay( + Variable timeSpan, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + TimeSpan = new Input(timeSpan); + } + + /// + /// The amount of time to delay execution. + /// + [Input( + Description = "The timespan to delay workflow execution.", + DefaultValueProvider = typeof(Delay) + )] + public Input TimeSpan { get; set; } = null!; + + /// + protected override void Execute(ActivityExecutionContext context) + { + var timeSpan = context.ExpressionExecutionContext.Get(TimeSpan); + context.DelayFor(timeSpan); + } + + /// + /// Creates a new from the specified number of milliseconds. + /// + public static Delay FromMilliseconds( + double value, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromMilliseconds(value), source, line); + + /// + /// Creates a new from the specified number of seconds. + /// + public static Delay FromSeconds( + double value, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromSeconds(value), source, line); + + /// + /// Creates a new from the specified number of minutes. + /// + public static Delay FromMinutes( + double value, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromMinutes(value), source, line); + + /// + /// Creates a new from the specified number of hours. + /// + public static Delay FromHours( + double value, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromHours(value), source, line); + + /// + /// Creates a new from the specified number of days. + /// + public static Delay FromDays( + double value, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromDays(value), source, line); + + object IActivityPropertyDefaultValueProvider.GetDefaultValue(PropertyInfo property) => System.TimeSpan.FromMinutes(1); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Activities/StartAt.cs b/src/modules/Elsa.Scheduling/Activities/StartAt.cs new file mode 100644 index 000000000..26075294b --- /dev/null +++ b/src/modules/Elsa.Scheduling/Activities/StartAt.cs @@ -0,0 +1,107 @@ +using System.Runtime.CompilerServices; +using Elsa.Common; +using Elsa.Expressions.Models; +using Elsa.Extensions; +using Elsa.Scheduling.Bookmarks; +using Elsa.Workflows; +using Elsa.Workflows.Attributes; +using Elsa.Workflows.Memory; +using Elsa.Workflows.Models; +using Microsoft.Extensions.Logging; + +namespace Elsa.Scheduling.Activities; + +/// +/// Triggers the workflow at a specific future timestamp. +/// +[Activity("Elsa", "Scheduling", "Trigger execution at a specific time in the future.")] +public class StartAt : Trigger +{ + private const string InputKey = "ExecuteAt"; + + /// + public StartAt([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + } + + /// + public StartAt(Input dateTime, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(source, line) => DateTime = dateTime; + + /// + public StartAt(Func dateTime, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) + : this(new Input(dateTime), source, line) + { + } + + /// + public StartAt( + Func> dateTime, + [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input(dateTime), source, line) + { + } + + /// + public StartAt(Func> dateTime, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) + : this(new Input(dateTime), source, line) + { + } + + /// + public StartAt(Func dateTime, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) + : this(new Input(dateTime), source, line) + { + } + + /// + public StartAt(DateTimeOffset dateTime, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(source, line) => + DateTime = new Input(dateTime); + + /// + public StartAt(Variable dateTime, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(source, line) => + DateTime = new Input(dateTime); + + /// + /// The timestamp at which the workflow should be triggered. + /// + [Input] + public Input DateTime { get; set; } = null!; + + /// + protected override object GetTriggerPayload(TriggerIndexingContext context) + { + var executeAt = context.ExpressionExecutionContext.Get(DateTime); + return new StartAtPayload(executeAt); + } + + /// + protected override async ValueTask ExecuteAsync(ActivityExecutionContext context) + { + if (context.IsTriggerOfWorkflow()) + { + await context.CompleteActivityAsync(); + return; + } + + var executeAt = context.ExpressionExecutionContext.Get(DateTime); + var clock = context.ExpressionExecutionContext.GetRequiredService(); + var now = clock.UtcNow; + var logger = context.GetRequiredService>(); + + context.JournalData.Add("Executed At", now); + + if (executeAt <= now) + { + logger.LogDebug("Scheduled trigger time lies in the past ('{Delta}'). Completing immediately", now - executeAt); + await context.CompleteActivityAsync(); + return; + } + + var payload = new StartAtPayload(executeAt); + context.CreateBookmark(payload); + } + + /// + /// Creates a new activity set to trigger at the specified timestamp. + /// + public static StartAt From(DateTimeOffset value, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(value, source, line); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Activities/Timer.cs b/src/modules/Elsa.Scheduling/Activities/Timer.cs new file mode 100644 index 000000000..1367ba7b0 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Activities/Timer.cs @@ -0,0 +1,51 @@ +using System.Runtime.CompilerServices; +using Elsa.Expressions.Models; +using Elsa.Extensions; +using Elsa.Workflows.Attributes; +using Elsa.Workflows.Models; + +namespace Elsa.Scheduling.Activities; + +/// +/// Represents a timer to periodically trigger the workflow. +/// +[Activity("Elsa", "Scheduling", "Trigger workflow execution at a specific interval.")] +public class Timer : TimerBase +{ + /// + public Timer([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line) + { + } + + /// + public Timer(TimeSpan interval, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input(interval), source, line) + { + } + + /// + public Timer(Input interval, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(source, line) + { + Interval = interval; + } + + /// + /// The interval at which the timer should execute. + /// + [Input(Description = "The interval at which the timer should execute.", DefaultValue = "00:01:00")] + public Input Interval { get; set; } = new(TimeSpan.FromMinutes(1)); + + protected override TimeSpan GetInterval(ExpressionExecutionContext context) + { + return Interval.Get(context); + } + + /// + /// Creates a new activity set to trigger at the specified interval. + /// + public static Timer FromTimeSpan(TimeSpan value, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(value, source, line); + + /// + /// Creates a new activity set to trigger at the specified interval in seconds. + /// + public static Timer FromSeconds(double value, [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => FromTimeSpan(TimeSpan.FromSeconds(value), source, line); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Activities/TimerBase.cs b/src/modules/Elsa.Scheduling/Activities/TimerBase.cs new file mode 100644 index 000000000..b14dc16e6 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Activities/TimerBase.cs @@ -0,0 +1,43 @@ +using System.Runtime.CompilerServices; +using Elsa.Expressions.Models; +using Elsa.Extensions; +using Elsa.Workflows; + +namespace Elsa.Scheduling.Activities; + +/// +/// +public abstract class TimerBase([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : EventGenerator(source, line) +{ + protected abstract TimeSpan GetInterval(ExpressionExecutionContext context); + + protected virtual ValueTask OnTimerElapsedAsync(ActivityExecutionContext context) + { + OnTimerElapsed(context); + return default; + } + + protected virtual void OnTimerElapsed(ActivityExecutionContext context) + { + } + + /// + protected override void Execute(ActivityExecutionContext context) + { + var interval = GetInterval(context.ExpressionExecutionContext); + context.RepeatWithInterval(interval, TimerElapsedAsync); + } + + /// + protected override object GetTriggerPayload(TriggerIndexingContext context) + { + var interval = GetInterval(context.ExpressionExecutionContext); + return context.GetTimerTriggerStimulus(interval); + } + + private async ValueTask TimerElapsedAsync(ActivityExecutionContext context) + { + await OnTimerElapsedAsync(context); + await context.CompleteActivityAsync(); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Bookmarks/CronBookmarkPayload.cs b/src/modules/Elsa.Scheduling/Bookmarks/CronBookmarkPayload.cs new file mode 100644 index 000000000..609825ba1 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Bookmarks/CronBookmarkPayload.cs @@ -0,0 +1,3 @@ +namespace Elsa.Scheduling.Bookmarks; + +internal record CronBookmarkPayload(DateTimeOffset ExecuteAt, string CronExpression); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Bookmarks/CronTriggerPayload.cs b/src/modules/Elsa.Scheduling/Bookmarks/CronTriggerPayload.cs new file mode 100644 index 000000000..fc3c3c62f --- /dev/null +++ b/src/modules/Elsa.Scheduling/Bookmarks/CronTriggerPayload.cs @@ -0,0 +1,3 @@ +namespace Elsa.Scheduling.Bookmarks; + +public record CronTriggerPayload(string CronExpression); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Bookmarks/DelayPayload.cs b/src/modules/Elsa.Scheduling/Bookmarks/DelayPayload.cs new file mode 100644 index 000000000..71e6dfeed --- /dev/null +++ b/src/modules/Elsa.Scheduling/Bookmarks/DelayPayload.cs @@ -0,0 +1,8 @@ +using Elsa.Scheduling.Activities; + +namespace Elsa.Scheduling.Bookmarks; + +/// +/// A bookmark payload for . +/// +public record DelayPayload(DateTimeOffset ResumeAt); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Bookmarks/StartAtPayload.cs b/src/modules/Elsa.Scheduling/Bookmarks/StartAtPayload.cs new file mode 100644 index 000000000..d8e816cb8 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Bookmarks/StartAtPayload.cs @@ -0,0 +1,3 @@ +namespace Elsa.Scheduling.Bookmarks; + +internal record StartAtPayload(DateTimeOffset ExecuteAt); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Bookmarks/TimerBookmarkPayload.cs b/src/modules/Elsa.Scheduling/Bookmarks/TimerBookmarkPayload.cs new file mode 100644 index 000000000..43cfb0393 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Bookmarks/TimerBookmarkPayload.cs @@ -0,0 +1,3 @@ +namespace Elsa.Scheduling.Bookmarks; + +internal record TimerBookmarkPayload(DateTimeOffset ResumeAt); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Bookmarks/TimerTriggerPayload.cs b/src/modules/Elsa.Scheduling/Bookmarks/TimerTriggerPayload.cs new file mode 100644 index 000000000..939eab830 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Bookmarks/TimerTriggerPayload.cs @@ -0,0 +1,3 @@ +namespace Elsa.Scheduling.Bookmarks; + +public record TimerTriggerPayload(DateTimeOffset StartAt, TimeSpan Interval); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Commands/RunScheduledTask.cs b/src/modules/Elsa.Scheduling/Commands/RunScheduledTask.cs new file mode 100644 index 000000000..cb7efa61f --- /dev/null +++ b/src/modules/Elsa.Scheduling/Commands/RunScheduledTask.cs @@ -0,0 +1,8 @@ +using Elsa.Mediator.Contracts; + +namespace Elsa.Scheduling.Commands; + +/// +/// A command to run a scheduled task. +/// +public record RunScheduledTask(ITask Task) : ICommand; \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/IBookmarkScheduler.cs b/src/modules/Elsa.Scheduling/Contracts/IBookmarkScheduler.cs new file mode 100644 index 000000000..e3469fdfc --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/IBookmarkScheduler.cs @@ -0,0 +1,39 @@ +using Elsa.Workflows.Models; +using Elsa.Workflows.Runtime.Entities; + +namespace Elsa.Scheduling; + +/// +/// Creates timer schedules for the specified bookmarks. +/// +public interface IBookmarkScheduler +{ + /// + /// Schedules the specified list of bookmarks. + /// + /// The bookmarks to schedule. + /// An optional cancellation token. + Task ScheduleAsync(IEnumerable bookmarks, CancellationToken cancellationToken = default); + + /// + /// Schedules the specified list of bookmarks. + /// + /// The ID of the workflow instance to which the bookmarks belong. + /// The bookmarks to schedule. + /// An optional cancellation token. + Task ScheduleAsync(string workflowInstanceId, IEnumerable bookmarks, CancellationToken cancellationToken = default); + + /// + /// Unschedules the specified list of bookmarks. + /// + /// The bookmarks to unschedule. + /// An optional cancellation token. + Task UnscheduleAsync(IEnumerable bookmarks, CancellationToken cancellationToken = default); + + /// + /// Unschedules the specified list of bookmarks. + /// + /// The bookmarks to unschedule. + /// An optional cancellation token. + Task UnscheduleAsync(IEnumerable bookmarks, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/ICronParser.cs b/src/modules/Elsa.Scheduling/Contracts/ICronParser.cs new file mode 100644 index 000000000..449ddc26d --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/ICronParser.cs @@ -0,0 +1,13 @@ +namespace Elsa.Scheduling; + +/// Represents a cron expression parser. +/// The providers can support different formats. Quartz, for example, supports years. +public interface ICronParser +{ + /// + /// Converts a provider dependent cron expression to a . + /// + /// The cron expression to parse. + /// The next occurrence. + DateTimeOffset GetNextOccurrence(string expression); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/ISchedule.cs b/src/modules/Elsa.Scheduling/Contracts/ISchedule.cs new file mode 100644 index 000000000..4b0c78763 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/ISchedule.cs @@ -0,0 +1,14 @@ +namespace Elsa.Scheduling; + +/// +/// A schedule that can be used to schedule a task. +/// +public interface ISchedule +{ + /// + /// Create a scheduled task. + /// + /// The context. + /// The scheduled task. + IScheduledTask Schedule(ScheduleContext context); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/IScheduledTask.cs b/src/modules/Elsa.Scheduling/Contracts/IScheduledTask.cs new file mode 100644 index 000000000..a03657841 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/IScheduledTask.cs @@ -0,0 +1,12 @@ +namespace Elsa.Scheduling; + +/// +/// Represents a scheduled task. +/// +public interface IScheduledTask +{ + /// + /// Cancels the scheduled task. + /// + void Cancel(); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/IScheduler.cs b/src/modules/Elsa.Scheduling/Contracts/IScheduler.cs new file mode 100644 index 000000000..1db992685 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/IScheduler.cs @@ -0,0 +1,40 @@ +namespace Elsa.Scheduling; + +/// +/// Schedules tasks. +/// +public interface IScheduler +{ + /// + /// Schedules a task using the specified schedule. + /// + /// The name of the task to schedule. + /// The task to schedule. + /// The schedule to use. + /// The cancellation token. + ValueTask ScheduleAsync(string name, ITask task, ISchedule schedule, CancellationToken cancellationToken = default); + + /// + /// Schedules a task using the specified schedule. + /// + /// The name of the task to schedule. + /// The task to schedule. + /// The schedule to use. + /// A list of keys to associate with the task. + /// The cancellation token. + ValueTask ScheduleAsync(string name, ITask task, ISchedule schedule, IEnumerable? keys = null, CancellationToken cancellationToken = default); + + /// + /// Unschedules the task with the specified name. + /// + /// The name of the task to unschedule. + /// The cancellation token. + ValueTask ClearScheduleAsync(string name, CancellationToken cancellationToken = default); + + /// + /// Unschedules tasks with the specified keys. + /// + /// The keys of the tasks to unschedule. + /// The cancellation token. + ValueTask ClearScheduleAsync(IEnumerable keys, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/ITask.cs b/src/modules/Elsa.Scheduling/Contracts/ITask.cs new file mode 100644 index 000000000..f0f586c7a --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/ITask.cs @@ -0,0 +1,12 @@ +namespace Elsa.Scheduling; + +/// +/// Represents a task. +/// +public interface ITask +{ + /// + /// Executes the task. + /// + ValueTask ExecuteAsync(TaskExecutionContext context); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/ITriggerScheduler.cs b/src/modules/Elsa.Scheduling/Contracts/ITriggerScheduler.cs new file mode 100644 index 000000000..01abd37d8 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/ITriggerScheduler.cs @@ -0,0 +1,23 @@ +using Elsa.Workflows.Runtime.Entities; + +namespace Elsa.Scheduling; + +/// +/// Schedules tasks for the specified list of triggers. +/// +public interface ITriggerScheduler +{ + /// + /// Schedules tasks for the specified list of triggers. + /// + /// The triggers to schedule tasks for. + /// The cancellation token. + Task ScheduleAsync(IEnumerable triggers, CancellationToken cancellationToken = default); + + /// + /// Unschedules tasks for the specified list of triggers. + /// + /// The triggers to unschedule tasks for. + /// The cancellation token. + Task UnscheduleAsync(IEnumerable triggers, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Contracts/IWorkflowScheduler.cs b/src/modules/Elsa.Scheduling/Contracts/IWorkflowScheduler.cs new file mode 100644 index 000000000..47371ffbb --- /dev/null +++ b/src/modules/Elsa.Scheduling/Contracts/IWorkflowScheduler.cs @@ -0,0 +1,70 @@ +namespace Elsa.Scheduling; + +/// +/// A contract for scheduling workflows to execute at a specific future instant. Can be used to implement a custom scheduler, e.g. using Quartz.NET and Hangfire. +/// +public interface IWorkflowScheduler +{ + /// + /// Schedules a workflow request to be executed at the specified time. + /// + /// The name of the task to schedule. + /// The workflow request to schedule. + /// The time at which the workflow should be executed. + /// The cancellation token. + ValueTask ScheduleAtAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, DateTimeOffset at, CancellationToken cancellationToken = default); + + /// + /// Schedules a workflow request to be executed at the specified time. + /// + /// The name of the task to schedule. + /// The workflow request to schedule. + /// The time at which the workflow should be executed. + /// The cancellation token. + ValueTask ScheduleAtAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, DateTimeOffset at, CancellationToken cancellationToken = default); + + /// + /// Schedules a workflow request to be executed at the specified time. + /// + /// The name of the task to schedule. + /// The workflow request to schedule. + /// The time at which the first execution should occur. + /// The interval at which the workflow should be executed. + /// The cancellation token. + ValueTask ScheduleRecurringAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, DateTimeOffset startAt, TimeSpan interval, CancellationToken cancellationToken = default); + + /// + /// Schedules a workflow request to be executed at the specified time. + /// + /// The name of the task to schedule. + /// The workflow request to schedule. + /// The time at which the first execution should occur. + /// The interval at which the workflow should be executed. + /// The cancellation token. + ValueTask ScheduleRecurringAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, DateTimeOffset startAt, TimeSpan interval, CancellationToken cancellationToken = default); + + /// + /// Schedules a workflow request to be executed at the specified time. + /// + /// The name of the task to schedule. + /// The workflow request to schedule. + /// The cron expression to use. + /// The cancellation token. + ValueTask ScheduleCronAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, string cronExpression, CancellationToken cancellationToken = default); + + /// + /// Schedules a workflow request to be executed at the specified time. + /// + /// The name of the task to schedule. + /// The workflow request to schedule. + /// The cron expression to use. + /// The cancellation token. + ValueTask ScheduleCronAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, string cronExpression, CancellationToken cancellationToken = default); + + /// + /// Clears the schedule for the specified task. + /// + /// The name of the task to unschedule. + /// The cancellation token. + ValueTask UnscheduleAsync(string taskName, CancellationToken cancellationToken = default); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Elsa.Scheduling.csproj b/src/modules/Elsa.Scheduling/Elsa.Scheduling.csproj new file mode 100644 index 000000000..75f4cddbd --- /dev/null +++ b/src/modules/Elsa.Scheduling/Elsa.Scheduling.csproj @@ -0,0 +1,18 @@ + + + + + Provides scheduling activities such as Timer, Delay and StartAt. + + elsa extension module scheduling + + + + + + + + + + + diff --git a/src/modules/Elsa.Scheduling/Elsa.Scheduling.csproj.DotSettings b/src/modules/Elsa.Scheduling/Elsa.Scheduling.csproj.DotSettings new file mode 100644 index 000000000..5aafdbaf1 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Elsa.Scheduling.csproj.DotSettings @@ -0,0 +1,4 @@ + + True + True + True \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Extensions/DelayActivityExecutionContextExtensions.cs b/src/modules/Elsa.Scheduling/Extensions/DelayActivityExecutionContextExtensions.cs new file mode 100644 index 000000000..056fbde42 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Extensions/DelayActivityExecutionContextExtensions.cs @@ -0,0 +1,45 @@ +using Elsa.Common; +using Elsa.Scheduling; +using Elsa.Scheduling.Bookmarks; +using Elsa.Workflows; +using Elsa.Workflows.Models; + +// ReSharper disable once CheckNamespace +namespace Elsa.Extensions; + +public static class DelayActivityExecutionContextExtensions +{ + /// + /// Resumes the activity after a specified delay. + /// + /// The activity execution context in which the workflow is running. + /// The delay before the workflow resumes. + /// The delegate to execute when the activity resumes. + public static void DelayFor(this ActivityExecutionContext context, TimeSpan delay, ExecuteActivityDelegate? callback = null) + { + var clock = context.ExpressionExecutionContext.GetRequiredService(); + var resumeAt = clock.UtcNow.Add(delay); + + DelayUntil(context, resumeAt, callback); + } + + /// + /// Resumes the activity at a specified point in time. + /// + /// The activity execution context in which the workflow is running. + /// The point in time at which the workflow should resume execution. + /// The delegate to execute when the activity resumes. + public static void DelayUntil(this ActivityExecutionContext context, DateTimeOffset resumeAt, ExecuteActivityDelegate? callback = null) + { + var payload = new DelayPayload(resumeAt); + + var bookmarkOptions = new CreateBookmarkArgs + { + BookmarkName = SchedulingStimulusNames.Delay, + Stimulus = payload, + Callback = callback + }; + + context.CreateBookmark(bookmarkOptions); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Scheduling/Extensions/ModuleExtensions.cs new file mode 100644 index 000000000..e68819634 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Extensions/ModuleExtensions.cs @@ -0,0 +1,23 @@ +using Elsa.Features.Services; +using Elsa.Scheduling.Features; + +// ReSharper disable once CheckNamespace +namespace Elsa.Extensions; + +/// +/// Provides extension methods for instances. +/// +public static class ModuleExtensions +{ + /// + /// Enables the scheduling feature. + /// + /// The module. + /// A delegate to configure the feature. + /// The module. + public static IModule UseScheduling(this IModule module, Action? configure = null ) + { + module.Configure(configure); + return module; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Extensions/TimerActivityExecutionContextExtensions.cs b/src/modules/Elsa.Scheduling/Extensions/TimerActivityExecutionContextExtensions.cs new file mode 100644 index 000000000..55e620a39 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Extensions/TimerActivityExecutionContextExtensions.cs @@ -0,0 +1,45 @@ +using Elsa.Common; +using Elsa.Scheduling; +using Elsa.Scheduling.Bookmarks; +using Elsa.Workflows; +using Elsa.Workflows.Models; + +// ReSharper disable once CheckNamespace +namespace Elsa.Extensions; + +public static class TimerActivityExecutionContextExtensions +{ + /// + /// Repeats the execution of the current activity at the specified interval. + /// + /// The execution context of the activity. + /// The time interval after which the activity should be repeated. + /// An optional callback to execute immediately if the workflow is triggered. + public static void RepeatWithInterval(this ActivityExecutionContext context, TimeSpan interval, ExecuteActivityDelegate? callback = null) + { + if(context.IsTriggerOfWorkflow()) + { + callback?.Invoke(context); + return; + } + + var clock = context.ExpressionExecutionContext.GetRequiredService(); + var resumeAt = clock.UtcNow.Add(interval); + + var bookmarkOptions = new CreateBookmarkArgs + { + BookmarkName = SchedulingStimulusNames.Timer, + Stimulus = new TimerBookmarkPayload(resumeAt), + Callback = callback + }; + context.CreateBookmark(bookmarkOptions); + } + + public static TimerTriggerPayload GetTimerTriggerStimulus(this TriggerIndexingContext context, TimeSpan interval) + { + var clock = context.ExpressionExecutionContext.GetRequiredService(); + var executeAt = clock.UtcNow.Add(interval); + context.TriggerName = SchedulingStimulusNames.Timer; + return new(executeAt, interval); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Features/SchedulingFeature.cs b/src/modules/Elsa.Scheduling/Features/SchedulingFeature.cs new file mode 100644 index 000000000..41eb4b5eb --- /dev/null +++ b/src/modules/Elsa.Scheduling/Features/SchedulingFeature.cs @@ -0,0 +1,61 @@ +using Elsa.Common.Features; +using Elsa.Common.Multitenancy; +using Elsa.Extensions; +using Elsa.Features.Abstractions; +using Elsa.Features.Attributes; +using Elsa.Features.Services; +using Elsa.Scheduling.Bookmarks; +using Elsa.Scheduling.Handlers; +using Elsa.Scheduling.HostedServices; +using Elsa.Scheduling.Services; +using Elsa.Scheduling.TriggerPayloadValidators; +using Elsa.Workflows.Management.Features; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Scheduling.Features; + +/// +/// Provides scheduling features to the system. +/// +[DependsOn(typeof(SystemClockFeature))] +public class SchedulingFeature : FeatureBase +{ + /// + public SchedulingFeature(IModule module) : base(module) + { + } + + /// + /// Gets or sets the trigger scheduler. + /// + public Func WorkflowScheduler { get; set; } = sp => sp.GetRequiredService(); + + /// + /// Gets or sets the CRON parser. + /// + public Func CronParser { get; set; } = sp => sp.GetRequiredService(); + + /// + public override void Apply() + { + Services + .AddSingleton() + .AddSingleton(sp => sp.GetRequiredService()) + .AddSingleton(sp => sp.GetRequiredService()) + .AddSingleton() + .AddSingleton() + .AddSingleton(CronParser) + .AddScoped() + .AddScoped() + .AddScoped() + .AddSingleton(CronParser) + .AddScoped(WorkflowScheduler) + .AddBackgroundTask() + .AddHandlersFrom() + + //Trigger payload validators. + .AddTriggerPaylodValidator(); + + Module.Configure(management => management.AddActivitiesFrom()); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Expressions.Dsl/FodyWeavers.xml b/src/modules/Elsa.Scheduling/FodyWeavers.xml similarity index 100% rename from src/modules/Elsa.Expressions.Dsl/FodyWeavers.xml rename to src/modules/Elsa.Scheduling/FodyWeavers.xml diff --git a/src/modules/Elsa.Scheduling/Handlers/DeleteSchedules.cs b/src/modules/Elsa.Scheduling/Handlers/DeleteSchedules.cs new file mode 100644 index 000000000..7c6b38b47 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Handlers/DeleteSchedules.cs @@ -0,0 +1,40 @@ +using Elsa.Mediator.Contracts; +using Elsa.Workflows.Management.Notifications; +using Elsa.Workflows.Runtime; +using Elsa.Workflows.Runtime.Filters; +using Elsa.Workflows.Runtime.Notifications; + +namespace Elsa.Scheduling.Handlers; + +/// +/// Deletes scheduled jobs based on deleted workflow triggers and bookmarks. +/// +public class DeleteSchedules(ITriggerScheduler triggerScheduler, IBookmarkScheduler bookmarkScheduler, ITriggerStore triggerStore, IBookmarkStore bookmarkStore) + : + INotificationHandler, + INotificationHandler, + INotificationHandler, + INotificationHandler, + INotificationHandler +{ + async Task INotificationHandler.HandleAsync(BookmarksDeleting notification, CancellationToken cancellationToken) + { + var ids = notification.Bookmarks.Select(x => x.Id).ToList(); + var bookmarks = await bookmarkStore.FindManyAsync(new BookmarkFilter { BookmarkIds = ids }, cancellationToken); + await bookmarkScheduler.UnscheduleAsync(bookmarks, cancellationToken); + } + + async Task INotificationHandler.HandleAsync(WorkflowDefinitionDeleting notification, CancellationToken cancellationToken) => await RemoveSchedulesAsync(new TriggerFilter { WorkflowDefinitionId = notification.DefinitionId }, cancellationToken); + async Task INotificationHandler.HandleAsync(WorkflowDefinitionsDeleting notification, CancellationToken cancellationToken) => await RemoveSchedulesAsync(new TriggerFilter { WorkflowDefinitionIds = notification.DefinitionIds }, cancellationToken); + + async Task INotificationHandler.HandleAsync(WorkflowDefinitionVersionDeleting notification, CancellationToken cancellationToken) => + await RemoveSchedulesAsync(new TriggerFilter { WorkflowDefinitionVersionId = notification.WorkflowDefinition.Id }, cancellationToken); + + async Task INotificationHandler.HandleAsync(WorkflowDefinitionVersionsDeleting notification, CancellationToken cancellationToken) => await RemoveSchedulesAsync(new TriggerFilter { WorkflowDefinitionVersionIds = notification.Ids }, cancellationToken); + + private async Task RemoveSchedulesAsync(TriggerFilter filter, CancellationToken cancellationToken) + { + var triggers = await triggerStore.FindManyAsync(filter, cancellationToken); + await triggerScheduler.UnscheduleAsync(triggers, cancellationToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Handlers/RunScheduledTaskHandler.cs b/src/modules/Elsa.Scheduling/Handlers/RunScheduledTaskHandler.cs new file mode 100644 index 000000000..4d8eceb7a --- /dev/null +++ b/src/modules/Elsa.Scheduling/Handlers/RunScheduledTaskHandler.cs @@ -0,0 +1,29 @@ +using Elsa.Mediator.Contracts; +using Elsa.Mediator.Models; +using Elsa.Scheduling.Commands; + +namespace Elsa.Scheduling.Handlers; + +/// +/// A command handler for . +/// +public class RunScheduledTaskHandler : ICommandHandler +{ + private readonly IServiceProvider _serviceProvider; + + /// + /// Initializes a new instance of the class. + /// + public RunScheduledTaskHandler(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + /// + public async Task HandleAsync(RunScheduledTask command, CancellationToken cancellationToken) + { + var taskExecutionContext = new TaskExecutionContext(_serviceProvider, cancellationToken); + await command.Task.ExecuteAsync(taskExecutionContext); + return Unit.Instance; + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Handlers/ScheduleWorkflows.cs b/src/modules/Elsa.Scheduling/Handlers/ScheduleWorkflows.cs new file mode 100644 index 000000000..bb792ceee --- /dev/null +++ b/src/modules/Elsa.Scheduling/Handlers/ScheduleWorkflows.cs @@ -0,0 +1,41 @@ +using Elsa.Mediator.Contracts; +using Elsa.Workflows.Runtime.Notifications; + +namespace Elsa.Scheduling.Handlers; + +/// +/// Updates scheduled jobs based on updated workflow triggers and bookmarks. +/// +public class ScheduleWorkflows : INotificationHandler, INotificationHandler +{ + private readonly ITriggerScheduler _triggerScheduler; + private readonly IBookmarkScheduler _bookmarkScheduler; + + /// + /// Initializes a new instance of the class. + /// + public ScheduleWorkflows(ITriggerScheduler triggerScheduler, IBookmarkScheduler bookmarkScheduler) + { + _triggerScheduler = triggerScheduler; + _bookmarkScheduler = bookmarkScheduler; + } + + /// + /// Updates scheduled jobs based on updated triggers. + /// + public async Task HandleAsync(WorkflowTriggersIndexed notification, CancellationToken cancellationToken) + { + await _triggerScheduler.UnscheduleAsync(notification.IndexedWorkflowTriggers.RemovedTriggers, cancellationToken); + await _triggerScheduler.ScheduleAsync(notification.IndexedWorkflowTriggers.AddedTriggers, cancellationToken); + } + + /// + /// Updates scheduled jobs based on updated bookmarks. + /// + public async Task HandleAsync(WorkflowBookmarksIndexed notification, CancellationToken cancellationToken) + { + var workflowInstanceId = notification.IndexedWorkflowBookmarks.WorkflowExecutionContext.Id; + await _bookmarkScheduler.UnscheduleAsync(notification.IndexedWorkflowBookmarks.RemovedBookmarks, cancellationToken); + await _bookmarkScheduler.ScheduleAsync(workflowInstanceId, notification.IndexedWorkflowBookmarks.AddedBookmarks, cancellationToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Handlers/UpdateTenantSchedules.cs b/src/modules/Elsa.Scheduling/Handlers/UpdateTenantSchedules.cs new file mode 100644 index 000000000..bdeecad26 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Handlers/UpdateTenantSchedules.cs @@ -0,0 +1,60 @@ +using Elsa.Common.Multitenancy; +using Elsa.Scheduling.Activities; +using Elsa.Workflows.Helpers; +using Elsa.Workflows.Runtime; +using Elsa.Workflows.Runtime.Entities; +using Elsa.Workflows.Runtime.Filters; +using Microsoft.Extensions.DependencyInjection; +using Timer = Elsa.Scheduling.Activities.Timer; + +namespace Elsa.Scheduling.Handlers; + +public class UpdateTenantSchedules : ITenantActivatedEvent, ITenantDeactivatedEvent +{ + private static readonly string[] ActivityTypeNames = + [ + ActivityTypeNameHelper.GenerateTypeName(), + ActivityTypeNameHelper.GenerateTypeName(), + ActivityTypeNameHelper.GenerateTypeName() + ]; + + public async Task TenantActivatedAsync(TenantActivatedEventArgs args) + { + var serviceProvider = args.TenantScope.ServiceProvider; + var cancellationToken = args.CancellationToken; + var triggerScheduler = args.TenantScope.ServiceProvider.GetRequiredService(); + var bookmarkScheduler = args.TenantScope.ServiceProvider.GetRequiredService(); + var triggers = (await GetTriggersAsync(serviceProvider, cancellationToken)).ToList(); + var bookmarks = (await GetBookmarksAsync(serviceProvider, cancellationToken)).ToList(); + + await triggerScheduler.ScheduleAsync(triggers, args.CancellationToken); + await bookmarkScheduler.ScheduleAsync(bookmarks, args.CancellationToken); + } + + public async Task TenantDeactivatedAsync(TenantDeactivatedEventArgs args) + { + var serviceProvider = args.TenantScope.ServiceProvider; + var cancellationToken = args.CancellationToken; + var triggerScheduler = args.TenantScope.ServiceProvider.GetRequiredService(); + var bookmarkScheduler = args.TenantScope.ServiceProvider.GetRequiredService(); + var triggers = (await GetTriggersAsync(serviceProvider, cancellationToken)).ToList(); + var bookmarks = (await GetBookmarksAsync(serviceProvider, cancellationToken)).ToList(); + + await triggerScheduler.UnscheduleAsync(triggers, args.CancellationToken); + await bookmarkScheduler.UnscheduleAsync(bookmarks, args.CancellationToken); + } + + private async Task> GetTriggersAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken) + { + var triggerStore = serviceProvider.GetRequiredService(); + var filter = TriggerFilter.ByNames(ActivityTypeNames); + return await triggerStore.FindManyAsync(filter, cancellationToken); + } + + private async Task> GetBookmarksAsync(IServiceProvider serviceProvider, CancellationToken cancellationToken) + { + var bookmarkStore = serviceProvider.GetRequiredService(); + var filter = BookmarkFilter.ByActivityTypeNames(ActivityTypeNames); + return await bookmarkStore.FindManyAsync(filter, cancellationToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/HostedServices/CreateSchedulesBackgroundTask.cs b/src/modules/Elsa.Scheduling/HostedServices/CreateSchedulesBackgroundTask.cs new file mode 100644 index 000000000..510096cb6 --- /dev/null +++ b/src/modules/Elsa.Scheduling/HostedServices/CreateSchedulesBackgroundTask.cs @@ -0,0 +1,35 @@ +using Elsa.Common; +using Elsa.Workflows.Runtime; +using Elsa.Workflows.Runtime.Filters; +using JetBrains.Annotations; + +namespace Elsa.Scheduling.HostedServices; + +/// +/// Creates new schedules when using the default scheduler (which doesn't have its own persistence layer like Quartz or Hangfire). +/// +[UsedImplicitly] +public class CreateSchedulesBackgroundTask(ITriggerStore triggerStore, IBookmarkStore bookmarkStore, ITriggerScheduler triggerScheduler, IBookmarkScheduler bookmarkScheduler) : BackgroundTask +{ + /// + public override async Task ExecuteAsync(CancellationToken stoppingToken) + { + var stimulusNames = new[] + { + SchedulingStimulusNames.Cron, SchedulingStimulusNames.Timer, SchedulingStimulusNames.StartAt, SchedulingStimulusNames.Delay, + }; + var triggerFilter = new TriggerFilter + { + Names = stimulusNames + }; + var bookmarkFilter = new BookmarkFilter + { + Names = stimulusNames + }; + var triggers = (await triggerStore.FindManyAsync(triggerFilter, stoppingToken)).ToList(); + var bookmarks = (await bookmarkStore.FindManyAsync(bookmarkFilter, stoppingToken)).ToList(); + + await triggerScheduler.ScheduleAsync(triggers, stoppingToken); + await bookmarkScheduler.ScheduleAsync(bookmarks, stoppingToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Models/ScheduleContext.cs b/src/modules/Elsa.Scheduling/Models/ScheduleContext.cs new file mode 100644 index 000000000..f02395933 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Models/ScheduleContext.cs @@ -0,0 +1,8 @@ +namespace Elsa.Scheduling; + +/// +/// The context for scheduling a task. +/// +/// The service provider. +/// The task to schedule. +public record ScheduleContext(IServiceProvider ServiceProvider, ITask Task); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Models/TaskExecutionContext.cs b/src/modules/Elsa.Scheduling/Models/TaskExecutionContext.cs new file mode 100644 index 000000000..6f73485fe --- /dev/null +++ b/src/modules/Elsa.Scheduling/Models/TaskExecutionContext.cs @@ -0,0 +1,8 @@ +namespace Elsa.Scheduling; + +/// +/// Represents a task execution context. +/// +/// The service provider. +/// The cancellation token. +public record TaskExecutionContext(IServiceProvider ServiceProvider, CancellationToken CancellationToken); \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Requests/ScheduleExistingWorkflowInstanceRequest.cs b/src/modules/Elsa.Scheduling/Requests/ScheduleExistingWorkflowInstanceRequest.cs new file mode 100644 index 000000000..13a446b95 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Requests/ScheduleExistingWorkflowInstanceRequest.cs @@ -0,0 +1,31 @@ +using Elsa.Workflows.Models; + +namespace Elsa.Scheduling; + +public class ScheduleExistingWorkflowInstanceRequest +{ + /// + /// The ID of the workflow instance. + /// + public string WorkflowInstanceId { get; set; } = null!; + + /// + /// The ID of the bookmark that triggered the workflow instance, if any. + /// + public string? BookmarkId { get; set; } + + /// + /// The handle of the activity to schedule, if any. + /// + public ActivityHandle? ActivityHandle { get; set; } + + /// + /// Any additional properties to associate with the workflow instance. + /// + public IDictionary? Properties { get; set; } + + /// + /// The input to the workflow instance, if any. + /// + public IDictionary? Input { get; set; } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Requests/ScheduleNewWorkflowInstanceRequest.cs b/src/modules/Elsa.Scheduling/Requests/ScheduleNewWorkflowInstanceRequest.cs new file mode 100644 index 000000000..8b01bd6d6 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Requests/ScheduleNewWorkflowInstanceRequest.cs @@ -0,0 +1,41 @@ +using Elsa.Workflows.Models; + +namespace Elsa.Scheduling; + +public class ScheduleNewWorkflowInstanceRequest +{ + /// + /// The ID of the workflow definition version to create an instance of. + /// + public WorkflowDefinitionHandle WorkflowDefinitionHandle { get; set; } = null!; + + /// + /// The correlation ID of the workflow, if any. + /// + public string? CorrelationId { get; set; } + + /// + /// The input to the workflow instance, if any. + /// + public IDictionary? Input { get; set; } + + /// + /// A collection of variables to pass to the workflow instance during scheduling. + /// + public IDictionary? Variables { get; set; } + + /// + /// Any properties to assign to the workflow instance. + /// + public IDictionary? Properties { get; set; } + + /// + /// The ID of the parent workflow instance, if any. + /// + public string? ParentId { get; set; } + + /// + /// The ID of the activity that triggered the workflow instance, if any. + /// + public string? TriggerActivityId { get; set; } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledCronTask.cs b/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledCronTask.cs new file mode 100644 index 000000000..72b87444c --- /dev/null +++ b/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledCronTask.cs @@ -0,0 +1,106 @@ +using Elsa.Common; +using Elsa.Mediator.Contracts; +using Elsa.Scheduling.Commands; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Timer = System.Timers.Timer; + +namespace Elsa.Scheduling.ScheduledTasks; + +/// +/// A task that is scheduled using a given cron expression. +/// +public class ScheduledCronTask : IScheduledTask, IDisposable +{ + private readonly ISystemClock _systemClock; + private readonly ILogger _logger; + private Timer? _timer; + private readonly ITask _task; + private readonly string _cronExpression; + private readonly ICronParser _cronParser; + private readonly IServiceScopeFactory _scopeFactory; + private readonly CancellationTokenSource _cancellationTokenSource; + + /// + /// Initializes a new instance of . + /// + public ScheduledCronTask(ITask task, string cronExpression, ICronParser cronParser, IServiceScopeFactory scopeFactory, ISystemClock systemClock, ILogger logger) + { + _task = task; + _cronExpression = cronExpression; + _cronParser = cronParser; + _scopeFactory = scopeFactory; + _systemClock = systemClock; + _logger = logger; + _cancellationTokenSource = new CancellationTokenSource(); + + Schedule(); + } + + /// + public void Cancel() + { + _timer?.Dispose(); + _cancellationTokenSource.Cancel(); + } + + private void Schedule() + { + var adjusted = false; + + while (true) + { + var now = _systemClock.UtcNow; + var nextOccurence = _cronParser.GetNextOccurrence(_cronExpression); + var delay = nextOccurence - now; + + if (!adjusted && delay.Milliseconds <= 0) + { + adjusted = true; + continue; + } + + TrySetupTimer(delay); + break; + } + } + + private void TrySetupTimer(TimeSpan delay) + { + if (delay.Milliseconds <= 0) + return; + + try + { + SetupTimer(delay); + } + catch (ArgumentException e) + { + _logger.LogError(e, "Failed to setup timer for scheduled task"); + } + } + + private void SetupTimer(TimeSpan delay) + { + _timer = new Timer(delay.TotalMilliseconds) { Enabled = true }; + + _timer.Elapsed += async (_, _) => + { + _timer?.Dispose(); + _timer = null; + + using var scope = _scopeFactory.CreateScope(); + var commandSender = scope.ServiceProvider.GetRequiredService(); + + var cancellationToken = _cancellationTokenSource.Token; + if (!cancellationToken.IsCancellationRequested) await commandSender.SendAsync(new RunScheduledTask(_task), cancellationToken); + if (!cancellationToken.IsCancellationRequested) Schedule(); + }; + } + + void IDisposable.Dispose() + { + _timer?.Dispose(); + _cancellationTokenSource.Dispose(); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs b/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs new file mode 100644 index 000000000..21d7fd380 --- /dev/null +++ b/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledRecurringTask.cs @@ -0,0 +1,96 @@ +using Elsa.Common; +using Elsa.Mediator.Contracts; +using Elsa.Scheduling.Commands; +using Microsoft.Extensions.DependencyInjection; +using Timer = System.Timers.Timer; + +namespace Elsa.Scheduling.ScheduledTasks; + +/// +/// A scheduled recurring task. +/// +public class ScheduledRecurringTask : IScheduledTask, IDisposable +{ + private readonly ITask _task; + private readonly ISystemClock _systemClock; + private readonly IServiceScopeFactory _scopeFactory; + private readonly TimeSpan _interval; + private readonly CancellationTokenSource _cancellationTokenSource; + private DateTimeOffset _startAt; + private Timer? _timer; + + /// + /// Initializes a new instance of . + /// + /// The task to execute. + /// The instant at which to start executing the task. + /// The interval at which to execute the task. + /// The system clock. + /// Scope factory to create the scope and get dependancies. + public ScheduledRecurringTask(ITask task, DateTimeOffset startAt, TimeSpan interval, ISystemClock systemClock, IServiceScopeFactory scopeFactory) + { + _task = task; + _systemClock = systemClock; + _scopeFactory = scopeFactory; + _startAt = startAt; + _interval = interval; + _cancellationTokenSource = new(); + + Schedule(); + } + + /// + public void Cancel() + { + _timer?.Dispose(); + _cancellationTokenSource.Cancel(); + } + + private void Schedule() + { + var startAt = _startAt; + var adjusted = false; + + while (true) + { + var now = _systemClock.UtcNow; + var delay = startAt - now; + + if (!adjusted && delay.Milliseconds <= 0) + { + adjusted = true; + continue; + } + + SetupTimer(delay); + break; + } + } + + private void SetupTimer(TimeSpan delay) + { + if (delay < TimeSpan.Zero) delay = TimeSpan.FromSeconds(1); + + _timer = new(delay.TotalMilliseconds) { Enabled = true }; + + _timer.Elapsed += async (_, _) => + { + _timer?.Dispose(); + _timer = null; + _startAt = _systemClock.UtcNow + _interval; + + using var scope = _scopeFactory.CreateScope(); + var commandSender = scope.ServiceProvider.GetRequiredService(); + + var cancellationToken = _cancellationTokenSource.Token; + if (!cancellationToken.IsCancellationRequested) await commandSender.SendAsync(new RunScheduledTask(_task), cancellationToken); + if (!cancellationToken.IsCancellationRequested) Schedule(); + }; + } + + void IDisposable.Dispose() + { + _cancellationTokenSource.Dispose(); + _timer?.Dispose(); + } +} diff --git a/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs b/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs new file mode 100644 index 000000000..3d2e9c61e --- /dev/null +++ b/src/modules/Elsa.Scheduling/ScheduledTasks/ScheduledSpecificInstantTask.cs @@ -0,0 +1,80 @@ +using Elsa.Common; +using Elsa.Mediator.Contracts; +using Elsa.Scheduling.Commands; +using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Logging; +using Timer = System.Timers.Timer; + +namespace Elsa.Scheduling.ScheduledTasks; + +/// +/// A task that is scheduled to execute at a specific instant. +/// +public class ScheduledSpecificInstantTask : IScheduledTask, IDisposable +{ + private readonly ITask _task; + private readonly ISystemClock _systemClock; + private readonly IServiceScopeFactory _scopeFactory; + private readonly ILogger _logger; + private readonly DateTimeOffset _startAt; + private readonly CancellationTokenSource _cancellationTokenSource; + private Timer? _timer; + + /// + /// Initializes a new instance of . + /// + public ScheduledSpecificInstantTask(ITask task, DateTimeOffset startAt, ISystemClock systemClock, IServiceScopeFactory scopeFactory, ILogger logger) + { + _task = task; + _systemClock = systemClock; + _scopeFactory = scopeFactory; + _logger = logger; + _startAt = startAt; + _cancellationTokenSource = new CancellationTokenSource(); + + Schedule(); + } + + /// + public void Cancel() => _timer?.Dispose(); + + private void Schedule() + { + var now = _systemClock.UtcNow; + var delay = _startAt - now; + + if (delay.Milliseconds <= 0) + delay = TimeSpan.FromMilliseconds(1); + + _timer = new Timer(delay.TotalMilliseconds) { Enabled = true }; + + _timer.Elapsed += async (_, _) => + { + _timer?.Dispose(); + _timer = null; + + using var scope = _scopeFactory.CreateScope(); + var commandSender = scope.ServiceProvider.GetRequiredService(); + + var cancellationToken = _cancellationTokenSource.Token; + if (!cancellationToken.IsCancellationRequested) + { + try + { + await commandSender.SendAsync(new RunScheduledTask(_task), cancellationToken); + } + catch (Exception e) + { + _logger.LogError(e, "Error scheduled task"); + } + + } + }; + } + + void IDisposable.Dispose() + { + _cancellationTokenSource.Dispose(); + _timer?.Dispose(); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Schedules/CronSchedule.cs b/src/modules/Elsa.Scheduling/Schedules/CronSchedule.cs new file mode 100644 index 000000000..c33ded3eb --- /dev/null +++ b/src/modules/Elsa.Scheduling/Schedules/CronSchedule.cs @@ -0,0 +1,32 @@ +using Elsa.Scheduling.ScheduledTasks; +using JetBrains.Annotations; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Scheduling.Schedules; + +/// +/// A CRON schedule. +/// +[PublicAPI] +public class CronSchedule : ISchedule +{ + /// + /// Initializes a new instance of the class. + /// + /// The CRON expression. + public CronSchedule(string cronExpression) + { + CronExpression = cronExpression; + } + + /// + /// The CRON expression. + /// + public string CronExpression { get; init; } + + /// + /// Creates a . + /// + public IScheduledTask Schedule(ScheduleContext context) => + ActivatorUtilities.CreateInstance(context.ServiceProvider, context.Task, CronExpression); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Schedules/RecurringSchedule.cs b/src/modules/Elsa.Scheduling/Schedules/RecurringSchedule.cs new file mode 100644 index 000000000..cb6393850 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Schedules/RecurringSchedule.cs @@ -0,0 +1,37 @@ +using Elsa.Scheduling.ScheduledTasks; +using JetBrains.Annotations; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Scheduling.Schedules; + +/// +/// A recurring schedule. +/// +[PublicAPI] +public class RecurringSchedule : ISchedule +{ + /// + /// Initializes a new instance of the class. + /// + /// The time at which the first occurrence should occur. + /// The interval between occurrences. + public RecurringSchedule(DateTimeOffset startAt, TimeSpan interval) + { + StartAt = startAt; + Interval = interval; + } + + /// + /// The time at which the first occurrence should occur. + /// + public DateTimeOffset StartAt { get; init; } + + /// + /// The interval between occurrences. + /// + public TimeSpan Interval { get; init; } + + /// + public IScheduledTask Schedule(ScheduleContext context) => + ActivatorUtilities.CreateInstance(context.ServiceProvider, context.Task, StartAt, Interval); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Schedules/SpecificInstantSchedule.cs b/src/modules/Elsa.Scheduling/Schedules/SpecificInstantSchedule.cs new file mode 100644 index 000000000..fa38c9e21 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Schedules/SpecificInstantSchedule.cs @@ -0,0 +1,32 @@ +using Elsa.Scheduling.ScheduledTasks; +using JetBrains.Annotations; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Scheduling.Schedules; + +/// +/// A schedule that can be used to schedule a task at a specific instant. +/// +[PublicAPI] +public class SpecificInstantSchedule : ISchedule +{ + /// + /// Initializes a new instance of the class. + /// + /// The date and time to schedule the task for. + public SpecificInstantSchedule(DateTimeOffset startAt) + { + StartAt = startAt; + } + + /// + /// The date and time to schedule the task for. + /// + public DateTimeOffset StartAt { get; init; } + + /// + public IScheduledTask Schedule(ScheduleContext context) + { + return ActivatorUtilities.CreateInstance(context.ServiceProvider, context.Task, StartAt); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/SchedulingStimulusNames.cs b/src/modules/Elsa.Scheduling/SchedulingStimulusNames.cs new file mode 100644 index 000000000..b7b472dc1 --- /dev/null +++ b/src/modules/Elsa.Scheduling/SchedulingStimulusNames.cs @@ -0,0 +1,9 @@ +namespace Elsa.Scheduling; + +public static class SchedulingStimulusNames +{ + public const string Cron = "Elsa.Cron"; + public const string StartAt = "Elsa.StartAt"; + public const string Timer = "Elsa.Timer"; + public const string Delay = "Elsa.Delay"; +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Services/CronosCronParser.cs b/src/modules/Elsa.Scheduling/Services/CronosCronParser.cs new file mode 100644 index 000000000..b8b373c0d --- /dev/null +++ b/src/modules/Elsa.Scheduling/Services/CronosCronParser.cs @@ -0,0 +1,28 @@ +using Cronos; +using Elsa.Common; + +namespace Elsa.Scheduling.Services; + +/// +/// A cron parser that uses Cronos. +/// +public class CronosCronParser : ICronParser +{ + private readonly ISystemClock _systemClock; + + /// + /// Initializes a new instance of the class. + /// + public CronosCronParser(ISystemClock systemClock) + { + _systemClock = systemClock; + } + + /// + public DateTimeOffset GetNextOccurrence(string expression) + { + var parsedExpression = CronExpression.Parse(expression, CronFormat.IncludeSeconds); + var now = _systemClock.UtcNow; + return parsedExpression.GetNextOccurrence(now, TimeZoneInfo.Utc).GetValueOrDefault(); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Services/DefaultBookmarkScheduler.cs b/src/modules/Elsa.Scheduling/Services/DefaultBookmarkScheduler.cs new file mode 100644 index 000000000..c1d86fdc6 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Services/DefaultBookmarkScheduler.cs @@ -0,0 +1,174 @@ +using Elsa.Extensions; +using Elsa.Scheduling.Bookmarks; +using Elsa.Workflows.Models; +using Elsa.Workflows.Runtime.Entities; + +namespace Elsa.Scheduling.Services; + +/// +/// A default implementation of that schedules bookmarks using . +/// +public class DefaultBookmarkScheduler : IBookmarkScheduler +{ + private readonly IWorkflowScheduler _workflowScheduler; + + /// + /// Initializes a new instance of the class. + /// + public DefaultBookmarkScheduler(IWorkflowScheduler workflowScheduler) + { + _workflowScheduler = workflowScheduler; + } + + /// + public async Task ScheduleAsync(IEnumerable bookmarks, CancellationToken cancellationToken = default) + { + var bookmarkList = bookmarks.ToList(); + var delayBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Delay); + var startAtBookmarks = bookmarkList.Filter(SchedulingStimulusNames.StartAt); + var timerBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Timer); + var cronBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Cron); + + // Schedule each Delay bookmark. + foreach (var bookmark in delayBookmarks) + { + var payload = bookmark.GetPayload(); + var resumeAt = payload.ResumeAt; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = bookmark.WorkflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleAtAsync(bookmark.Id, request, resumeAt, cancellationToken); + } + + // Schedule each StartAt bookmark. + foreach (var bookmark in startAtBookmarks) + { + var payload = bookmark.GetPayload(); + var executeAt = payload.ExecuteAt; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = bookmark.WorkflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleAtAsync(bookmark.Id, request, executeAt, cancellationToken); + } + + // Schedule each Timer bookmark. + foreach (var bookmark in timerBookmarks) + { + var payload = bookmark.GetPayload(); + var resumeAt = payload.ResumeAt; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = bookmark.WorkflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleAtAsync(bookmark.Id, request, resumeAt, cancellationToken); + } + + // Schedule each Cron bookmark. + foreach (var bookmark in cronBookmarks) + { + var payload = bookmark.GetPayload(); + var cronExpression = payload.CronExpression; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = bookmark.WorkflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleCronAsync(bookmark.Id, request, cronExpression, cancellationToken); + } + } + + /// + public async Task ScheduleAsync(string workflowInstanceId, IEnumerable bookmarks, CancellationToken cancellationToken = default) + { + var bookmarkList = bookmarks.ToList(); + var delayBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Delay); + var startAtBookmarks = bookmarkList.Filter(SchedulingStimulusNames.StartAt); + var timerBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Timer); + var cronBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Cron); + + // Schedule each Delay bookmark. + foreach (var bookmark in delayBookmarks) + { + var payload = bookmark.GetPayload(); + var resumeAt = payload.ResumeAt; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = workflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleAtAsync(bookmark.Id, request, resumeAt, cancellationToken); + } + + // Schedule each StartAt bookmark. + foreach (var bookmark in startAtBookmarks) + { + var payload = bookmark.GetPayload(); + var executeAt = payload.ExecuteAt; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = workflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleAtAsync(bookmark.Id, request, executeAt, cancellationToken); + } + + // Schedule each Timer bookmark. + foreach (var bookmark in timerBookmarks) + { + var payload = bookmark.GetPayload(); + var resumeAt = payload.ResumeAt; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = workflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleAtAsync(bookmark.Id, request, resumeAt, cancellationToken); + } + + // Schedule each Cron bookmark. + foreach (var bookmark in cronBookmarks) + { + var payload = bookmark.GetPayload(); + var cronExpression = payload.CronExpression; + var request = new ScheduleExistingWorkflowInstanceRequest + { + WorkflowInstanceId = workflowInstanceId, + BookmarkId = bookmark.Id + }; + await _workflowScheduler.ScheduleCronAsync(bookmark.Id, request, cronExpression, cancellationToken); + } + } + + /// + public async Task UnscheduleAsync(IEnumerable bookmarks, CancellationToken cancellationToken = default) + { + var bookmarkList = bookmarks.ToList(); + var delayBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Delay); + var startAtBookmarks = bookmarkList.Filter(SchedulingStimulusNames.StartAt); + var timerBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Timer); + var cronBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Cron); + var bookmarksToUnSchedule = delayBookmarks.Concat(startAtBookmarks).Concat(timerBookmarks).Concat(cronBookmarks).ToList(); + + foreach (var bookmark in bookmarksToUnSchedule) + await _workflowScheduler.UnscheduleAsync(bookmark.Id, cancellationToken); + } + + /// + public async Task UnscheduleAsync(IEnumerable bookmarks, CancellationToken cancellationToken = default) + { + var bookmarkList = bookmarks.ToList(); + var delayBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Delay); + var startAtBookmarks = bookmarkList.Filter(SchedulingStimulusNames.StartAt); + var timerBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Timer); + var cronBookmarks = bookmarkList.Filter(SchedulingStimulusNames.Cron); + var bookmarksToUnSchedule = delayBookmarks.Concat(startAtBookmarks).Concat(timerBookmarks).Concat(cronBookmarks).ToList(); + + foreach (var bookmark in bookmarksToUnSchedule) + await _workflowScheduler.UnscheduleAsync(bookmark.Id, cancellationToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Services/DefaultTriggerScheduler.cs b/src/modules/Elsa.Scheduling/Services/DefaultTriggerScheduler.cs new file mode 100644 index 000000000..31165173a --- /dev/null +++ b/src/modules/Elsa.Scheduling/Services/DefaultTriggerScheduler.cs @@ -0,0 +1,105 @@ +using Elsa.Common; +using Elsa.Extensions; +using Elsa.Scheduling.Activities; +using Elsa.Scheduling.Bookmarks; +using Elsa.Workflows.Models; +using Elsa.Workflows.Runtime.Entities; +using Microsoft.Extensions.Logging; + +namespace Elsa.Scheduling.Services; + +/// +/// A default implementation of that schedules triggers using . +/// +public class DefaultTriggerScheduler(IWorkflowScheduler workflowScheduler, ISystemClock systemClock, ILogger logger) + : ITriggerScheduler +{ + /// + public async Task ScheduleAsync(IEnumerable triggers, CancellationToken cancellationToken = default) + { + var triggerList = triggers.ToList(); + var timerTriggers = triggerList.Filter(); + var startAtTriggers = triggerList.Filter(); + var cronTriggers = triggerList.Filter(); + var now = systemClock.UtcNow; + + // Schedule each Timer trigger. + foreach (var trigger in timerTriggers) + { + var (startAt, interval) = trigger.GetPayload(); + var input = new { StartAt = startAt, Interval = interval }.ToDictionary(); + var request = new ScheduleNewWorkflowInstanceRequest + { + WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(trigger.WorkflowDefinitionVersionId), + TriggerActivityId = trigger.ActivityId, + Input = input + }; + await workflowScheduler.ScheduleRecurringAsync(trigger.Id, request, startAt, interval, cancellationToken); + } + + // Schedule each StartAt trigger. + foreach (var trigger in startAtTriggers) + { + var executeAt = trigger.GetPayload().ExecuteAt; + + // If the trigger is in the past, log info and skip scheduling. + if (executeAt < now) + { + logger.LogInformation("StartAt trigger is in the past. TriggerId: {TriggerId}. ExecuteAt: {ExecuteAt}. Skipping scheduling", trigger.Id, executeAt); + continue; + } + + var input = new { ExecuteAt = executeAt }.ToDictionary(); + var request = new ScheduleNewWorkflowInstanceRequest + { + WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(trigger.WorkflowDefinitionVersionId), + TriggerActivityId = trigger.ActivityId, + Input = input + }; + + await workflowScheduler.ScheduleAtAsync(trigger.Id, request, executeAt, cancellationToken); + } + + // Schedule each Cron trigger. + foreach (var trigger in cronTriggers) + { + var payload = trigger.GetPayload(); + var cronExpression = payload.CronExpression; + + if (string.IsNullOrWhiteSpace(cronExpression)) + { + logger.LogWarning("Cron expression is empty. TriggerId: {TriggerId}. Skipping scheduling of this trigger", trigger.Id); + continue; + } + + var input = new { CronExpression = cronExpression }.ToDictionary(); + var request = new ScheduleNewWorkflowInstanceRequest + { + WorkflowDefinitionHandle = WorkflowDefinitionHandle.ByDefinitionVersionId(trigger.WorkflowDefinitionVersionId), + TriggerActivityId = trigger.ActivityId, + Input = input + }; + try + { + await workflowScheduler.ScheduleCronAsync(trigger.Id, request, cronExpression, cancellationToken); + } + catch (FormatException ex) + { + logger.LogWarning(ex, "Cron expression format error. CronExpression: {CronExpression}", cronExpression); + } + } + } + + /// + public async Task UnscheduleAsync(IEnumerable triggers, CancellationToken cancellationToken = default) + { + var triggerList = triggers.ToList(); + var timerTriggers = triggerList.Filter(); + var startAtTriggers = triggerList.Filter(); + var cronTriggers = triggerList.Filter(); + var filteredTriggers = timerTriggers.Concat(startAtTriggers).Concat(cronTriggers); + + foreach (var trigger in filteredTriggers) + await workflowScheduler.UnscheduleAsync(trigger.Id, cancellationToken); + } +} diff --git a/src/modules/Elsa.Scheduling/Services/DefaultWorkflowScheduler.cs b/src/modules/Elsa.Scheduling/Services/DefaultWorkflowScheduler.cs new file mode 100644 index 000000000..a2c732906 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Services/DefaultWorkflowScheduler.cs @@ -0,0 +1,62 @@ +using Elsa.Scheduling.Schedules; +using Elsa.Scheduling.Tasks; + +namespace Elsa.Scheduling.Services; + +/// +/// A default implementation of that uses the . +/// +public class DefaultWorkflowScheduler(IScheduler scheduler) : IWorkflowScheduler +{ + /// + public async ValueTask ScheduleAtAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, DateTimeOffset at, CancellationToken cancellationToken = default) + { + await scheduler.ScheduleAsync(taskName, new RunWorkflowTask(request), new SpecificInstantSchedule(at), cancellationToken); + } + + /// + public async ValueTask ScheduleAtAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, DateTimeOffset at, CancellationToken cancellationToken = default) + { + var task = new ResumeWorkflowTask(request); + var schedule = new SpecificInstantSchedule(at); + await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken); + } + + /// + public async ValueTask ScheduleRecurringAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, DateTimeOffset startAt, TimeSpan interval, CancellationToken cancellationToken = default) + { + var task = new RunWorkflowTask(request); + var schedule = new RecurringSchedule(startAt, interval); + await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken); + } + + /// + public async ValueTask ScheduleRecurringAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, DateTimeOffset startAt, TimeSpan interval, CancellationToken cancellationToken = default) + { + var task = new ResumeWorkflowTask(request); + var schedule = new RecurringSchedule(startAt, interval); + await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken); + } + + /// + public async ValueTask ScheduleCronAsync(string taskName, ScheduleNewWorkflowInstanceRequest request, string cronExpression, CancellationToken cancellationToken = default) + { + var task = new RunWorkflowTask(request); + var schedule = new CronSchedule(cronExpression); + await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken); + } + + /// + public async ValueTask ScheduleCronAsync(string taskName, ScheduleExistingWorkflowInstanceRequest request, string cronExpression, CancellationToken cancellationToken = default) + { + var task = new ResumeWorkflowTask(request); + var schedule = new CronSchedule(cronExpression); + await scheduler.ScheduleAsync(taskName, task, schedule, cancellationToken); + } + + /// + public async ValueTask UnscheduleAsync(string taskName, CancellationToken cancellationToken = default) + { + await scheduler.ClearScheduleAsync(taskName, cancellationToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Services/LocalScheduler.cs b/src/modules/Elsa.Scheduling/Services/LocalScheduler.cs new file mode 100644 index 000000000..779b1ac46 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Services/LocalScheduler.cs @@ -0,0 +1,91 @@ +using Elsa.Extensions; + +namespace Elsa.Scheduling.Services; + +/// +/// Represents a local, in-memory scheduler that schedules tasks in-process. +/// +public class LocalScheduler : IScheduler +{ + private readonly IServiceProvider _serviceProvider; + private readonly IDictionary _scheduledTasks = new Dictionary(); + private readonly IDictionary> _scheduledTaskKeys = new Dictionary>(); + + /// + /// Initializes a new instance of the class. + /// + public LocalScheduler(IServiceProvider serviceProvider) + { + _serviceProvider = serviceProvider; + } + + /// + public ValueTask ScheduleAsync(string name, ITask task, ISchedule schedule, CancellationToken cancellationToken = default) + { + return ScheduleAsync(name, task, schedule, null, cancellationToken); + } + + /// + public ValueTask ScheduleAsync(string name, ITask task, ISchedule schedule, IEnumerable? keys = null, CancellationToken cancellationToken = default) + { + var scheduleContext = new ScheduleContext(_serviceProvider, task); + var scheduledTask = schedule.Schedule(scheduleContext); + + RegisterScheduledTask(name, scheduledTask, keys); + return ValueTask.CompletedTask; + } + + /// + public ValueTask ClearScheduleAsync(string name, CancellationToken cancellationToken = default) + { + RemoveScheduledTask(name); + return ValueTask.CompletedTask; + } + + /// + public ValueTask ClearScheduleAsync(IEnumerable keys, CancellationToken cancellationToken = default) + { + RemoveScheduledTasks(keys); + + return ValueTask.CompletedTask; + } + + private void RegisterScheduledTask(string name, IScheduledTask scheduledTask, IEnumerable? keys = null) + { + if (_scheduledTasks.TryGetValue(name, out var existingScheduledTask)) + { + existingScheduledTask.Cancel(); + _scheduledTaskKeys.Remove(existingScheduledTask); + } + + _scheduledTasks[name] = scheduledTask; + + if (keys != null) + _scheduledTaskKeys[scheduledTask] = keys.ToList(); + } + + private void RemoveScheduledTask(string name) + { + if (_scheduledTasks.TryGetValue(name, out var existingScheduledTask)) + { + _scheduledTaskKeys.Remove(existingScheduledTask); + _scheduledTasks.Remove(name); + existingScheduledTask.Cancel(); + } + } + + private void RemoveScheduledTasks(IEnumerable keys) + { + foreach (var key in keys) + { + var scheduledTasks = _scheduledTaskKeys.Where(x => x.Value.Contains(key)).Select(x => x.Key).Distinct().ToList(); + + foreach (var scheduledTask in scheduledTasks) + { + _scheduledTasks.RemoveWhere(x => x.Value == scheduledTask); + _scheduledTaskKeys.Remove(scheduledTask); + scheduledTask.Cancel(); + } + } + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Tasks/DelegateTask.cs b/src/modules/Elsa.Scheduling/Tasks/DelegateTask.cs new file mode 100644 index 000000000..b9aaec5c0 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Tasks/DelegateTask.cs @@ -0,0 +1,21 @@ +using JetBrains.Annotations; + +namespace Elsa.Scheduling.Tasks; + +/// +/// A generic task that executes the provided delegate. +/// +[PublicAPI] +public class DelegateTask : ITask +{ + private readonly Func _task; + + /// + /// Initializes a new instance of the class. + /// + /// The delegate to execute. + public DelegateTask(Func task) => _task = task; + + /// + public ValueTask ExecuteAsync(TaskExecutionContext context) => _task(context); +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Tasks/ResumeWorkflowTask.cs b/src/modules/Elsa.Scheduling/Tasks/ResumeWorkflowTask.cs new file mode 100644 index 000000000..83e845af1 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Tasks/ResumeWorkflowTask.cs @@ -0,0 +1,38 @@ +using Elsa.Workflows.Runtime; +using Elsa.Workflows.Runtime.Messages; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Scheduling.Tasks; + +/// +/// A task that resumes a workflow. +/// +public class ResumeWorkflowTask : ITask +{ + private readonly ScheduleExistingWorkflowInstanceRequest _request; + + /// + /// Initializes a new instance of the class. + /// + /// The dispatch workflow instance request. + public ResumeWorkflowTask(ScheduleExistingWorkflowInstanceRequest request) + { + _request = request; + } + + /// + public async ValueTask ExecuteAsync(TaskExecutionContext context) + { + var cancellationToken = context.CancellationToken; + var workflowRuntime = context.ServiceProvider.GetRequiredService(); + var workflowClient = await workflowRuntime.CreateClientAsync(_request.WorkflowInstanceId, cancellationToken); + var request = new RunWorkflowInstanceRequest + { + Input = _request.Input, + Properties = _request.Properties, + ActivityHandle = _request.ActivityHandle, + BookmarkId = _request.BookmarkId + }; + await workflowClient.RunInstanceAsync(request, cancellationToken); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.Scheduling/Tasks/RunWorkflowTask.cs b/src/modules/Elsa.Scheduling/Tasks/RunWorkflowTask.cs new file mode 100644 index 000000000..66e13c947 --- /dev/null +++ b/src/modules/Elsa.Scheduling/Tasks/RunWorkflowTask.cs @@ -0,0 +1,38 @@ +using Elsa.Workflows.Runtime; +using Elsa.Workflows.Runtime.Messages; +using Microsoft.Extensions.DependencyInjection; + +namespace Elsa.Scheduling.Tasks; + +/// +/// A task that runs a workflow. +/// +public class RunWorkflowTask : ITask +{ + private readonly ScheduleNewWorkflowInstanceRequest _request; + + /// + /// Initializes a new instance of the class. + /// + public RunWorkflowTask(ScheduleNewWorkflowInstanceRequest request) + { + _request = request; + } + + /// + public async ValueTask ExecuteAsync(TaskExecutionContext context) + { + var workflowRuntime = context.ServiceProvider.GetRequiredService(); + var workflowClient = await workflowRuntime.CreateClientAsync(); + var request = new CreateAndRunWorkflowInstanceRequest + { + WorkflowDefinitionHandle = _request.WorkflowDefinitionHandle, + TriggerActivityId = _request.TriggerActivityId, + Input = _request.Input, + Properties = _request.Properties, + ParentId = _request.ParentId, + CorrelationId = _request.CorrelationId + }; + await workflowClient.CreateAndRunInstanceAsync(request); + } +} \ No newline at end of file diff --git a/src/modules/Elsa.WorkflowProviders.BlobStorage/Elsa.WorkflowProviders.BlobStorage.csproj b/src/modules/Elsa.WorkflowProviders.BlobStorage/Elsa.WorkflowProviders.BlobStorage.csproj index 7c220f1bb..5b514bf40 100644 --- a/src/modules/Elsa.WorkflowProviders.BlobStorage/Elsa.WorkflowProviders.BlobStorage.csproj +++ b/src/modules/Elsa.WorkflowProviders.BlobStorage/Elsa.WorkflowProviders.BlobStorage.csproj @@ -12,4 +12,12 @@ + + + + + + + + diff --git a/src/modules/Elsa.WorkflowProviders.BlobStorage/Features/BlobStorageFeature.cs b/src/modules/Elsa.WorkflowProviders.BlobStorage/Features/BlobStorageFeature.cs index 398d325a0..d7b1da3a5 100644 --- a/src/modules/Elsa.WorkflowProviders.BlobStorage/Features/BlobStorageFeature.cs +++ b/src/modules/Elsa.WorkflowProviders.BlobStorage/Features/BlobStorageFeature.cs @@ -15,7 +15,6 @@ namespace Elsa.WorkflowProviders.BlobStorage.Features; /// A feature that enables the FluentStorage workflow definition provider. /// [DependsOn(typeof(WorkflowManagementFeature))] -[DependsOn(typeof(DslIntegrationFeature))] public class BlobStorageFeature : FeatureBase { /// diff --git a/src/modules/Elsa.WorkflowProviders.BlobStorage/Providers/BlobStorageWorkflowsProvider.cs b/src/modules/Elsa.WorkflowProviders.BlobStorage/Providers/BlobStorageWorkflowsProvider.cs index b8da664c0..e2bae6c26 100644 --- a/src/modules/Elsa.WorkflowProviders.BlobStorage/Providers/BlobStorageWorkflowsProvider.cs +++ b/src/modules/Elsa.WorkflowProviders.BlobStorage/Providers/BlobStorageWorkflowsProvider.cs @@ -1,5 +1,4 @@ using Elsa.Common; -using Elsa.Dsl.Contracts; using Elsa.WorkflowProviders.BlobStorage.Contracts; using Elsa.Workflows; using Elsa.Workflows.Management.Mappers; @@ -19,7 +18,6 @@ public class BlobStorageWorkflowsProvider : IWorkflowsProvider { private readonly IBlobStorageProvider _blobStorageProvider; private readonly IActivitySerializer _activitySerializer; - private readonly IDslEngine _dslEngine; private readonly ISystemClock _systemClock; private readonly IHasher _hasher; private readonly WorkflowDefinitionMapper _workflowDefinitionMapper; @@ -31,7 +29,6 @@ public class BlobStorageWorkflowsProvider : IWorkflowsProvider public BlobStorageWorkflowsProvider( IBlobStorageProvider blobStorageProvider, IActivitySerializer activitySerializer, - IDslEngine dslEngine, ISystemClock systemClock, IHasher hasher, WorkflowDefinitionMapper workflowDefinitionMapper, @@ -39,7 +36,6 @@ public class BlobStorageWorkflowsProvider : IWorkflowsProvider { _blobStorageProvider = blobStorageProvider; _activitySerializer = activitySerializer; - _dslEngine = dslEngine; _systemClock = systemClock; _hasher = hasher; _workflowDefinitionMapper = workflowDefinitionMapper; @@ -80,31 +76,14 @@ public class BlobStorageWorkflowsProvider : IWorkflowsProvider if (string.Equals("json", fileExtension, StringComparison.OrdinalIgnoreCase)) return ReadJsonWorkflowDefinition(data); - if (string.Equals("elsa", fileExtension, StringComparison.OrdinalIgnoreCase)) - return await ReadElsaDslWorkflowDefinitionAsync(blob, data, cancellationToken); - throw new NotSupportedException($"The file extension '{fileExtension}' is not supported."); } - private async Task ReadElsaDslWorkflowDefinitionAsync(Blob blob, string dsl, CancellationToken cancellationToken) - { - var workflow = await _dslEngine.ParseAsync(dsl, cancellationToken); - - // TODO: Extend the DSL with support for setting the ID from there. - workflow.Identity = workflow.Identity with - { - Id = blob.Name, - DefinitionId = blob.Name - }; - - return new MaterializedWorkflow(workflow, Name, JsonWorkflowMaterializer.MaterializerName); - } - private MaterializedWorkflow ReadJsonWorkflowDefinition(string json) { var workflowDefinitionModel = _activitySerializer.Deserialize(json); var workflow = _workflowDefinitionMapper.Map(workflowDefinitionModel); - return new MaterializedWorkflow(workflow, Name, JsonWorkflowMaterializer.MaterializerName); + return new (workflow, Name, JsonWorkflowMaterializer.MaterializerName); } } \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Elsa.Workflows.Management.csproj b/src/modules/Elsa.Workflows.Management/Elsa.Workflows.Management.csproj index bf2ba1d1a..13f3ff98f 100644 --- a/src/modules/Elsa.Workflows.Management/Elsa.Workflows.Management.csproj +++ b/src/modules/Elsa.Workflows.Management/Elsa.Workflows.Management.csproj @@ -21,7 +21,6 @@ - diff --git a/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs b/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs index dc6a1dc46..ccb31472b 100644 --- a/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs +++ b/src/modules/Elsa.Workflows.Management/Extensions/ModuleExtensions.cs @@ -42,15 +42,6 @@ public static class ModuleExtensions return feature; } - /// - /// Adds the Elsa DSL integration feature. - /// - public static WorkflowManagementFeature UseDslIntegration(this WorkflowManagementFeature feature, Action? configure = null) - { - feature.Module.Configure(configure); - return feature; - } - /// /// Adds all types implementing to the system. /// diff --git a/src/modules/Elsa.Workflows.Management/Features/DslIntegrationFeature.cs b/src/modules/Elsa.Workflows.Management/Features/DslIntegrationFeature.cs deleted file mode 100644 index 70bc9483f..000000000 --- a/src/modules/Elsa.Workflows.Management/Features/DslIntegrationFeature.cs +++ /dev/null @@ -1,53 +0,0 @@ -using Elsa.Expressions.Dsl.Features; -using Elsa.Expressions.Dsl.Models; -using Elsa.Features.Abstractions; -using Elsa.Features.Attributes; -using Elsa.Features.Services; -using Elsa.Workflows.Management.HostedServices; -using Elsa.Workflows.Management.Options; -using JetBrains.Annotations; -using Microsoft.Extensions.DependencyInjection; - -namespace Elsa.Workflows.Management.Features; - -/// -/// Installs JavaScript activities. -/// -[DependsOn(typeof(DslFeature))] -[PublicAPI] -public class DslIntegrationFeature : FeatureBase -{ - private readonly IDictionary _dictionary = new Dictionary(); - - /// - public DslIntegrationFeature(IModule module) : base(module) - { - } - - /// - /// Maps a function to an activity. - /// - /// The name of the function. - /// The name of the activity type. - /// The names of the properties that are mapped to the function arguments. - /// An optional action that can be used to configure the activity. - public void MapActivityFunction(string functionName, string activityTypeName, IEnumerable? propertyNames = default, Action? configure = default) - { - _dictionary.Add(functionName, new FunctionActivityDescriptor(functionName, activityTypeName, propertyNames, configure)); - } - - /// - public override void ConfigureHostedServices() - { - ConfigureHostedService(-1); - } - - /// - public override void Apply() - { - Services.Configure(options => - { - options.FunctionActivityDescriptors = _dictionary; - }); - } -} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/HostedServices/MapActivityDslFunctionsHostedService.cs b/src/modules/Elsa.Workflows.Management/HostedServices/MapActivityDslFunctionsHostedService.cs deleted file mode 100644 index 557a347d7..000000000 --- a/src/modules/Elsa.Workflows.Management/HostedServices/MapActivityDslFunctionsHostedService.cs +++ /dev/null @@ -1,29 +0,0 @@ -using Elsa.Expressions.Dsl.Contracts; -using Elsa.Workflows.Management.Options; -using Microsoft.Extensions.DependencyInjection; -using Microsoft.Extensions.Hosting; -using Microsoft.Extensions.Options; - -namespace Elsa.Workflows.Management.HostedServices; - -/// -/// Registers function activity descriptors with the DSL. -/// -public class MapActivityDslFunctionsHostedService(IServiceScopeFactory scopeFactory, IOptions options) : IHostedService -{ - /// - public Task StartAsync(CancellationToken cancellationToken) - { - using var scope = scopeFactory.CreateScope(); - var functionActivityRegistry = scope.ServiceProvider.GetRequiredService(); - var descriptors = options.Value.FunctionActivityDescriptors; - - foreach (var descriptor in descriptors.Values) - functionActivityRegistry.RegisterFunction(descriptor); - - return Task.CompletedTask; - } - - /// - public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask; -} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Management/Options/DslIntegrationOptions.cs b/src/modules/Elsa.Workflows.Management/Options/DslIntegrationOptions.cs deleted file mode 100644 index 37f4a0dc1..000000000 --- a/src/modules/Elsa.Workflows.Management/Options/DslIntegrationOptions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using Elsa.Expressions.Dsl.Models; - -namespace Elsa.Workflows.Management.Options; - -/// -/// Options for the DSL integration. -/// -public class DslIntegrationOptions -{ - /// - /// A collection of function activity descriptors that are available to the DSL. - /// - public IDictionary FunctionActivityDescriptors { get; set; } = new Dictionary(); -} \ No newline at end of file diff --git a/src/modules/Elsa.Workflows.Runtime/Services/StimulusProxyWorkflowInbox.cs b/src/modules/Elsa.Workflows.Runtime/Services/StimulusProxyWorkflowInbox.cs index e7c79f754..9a16af564 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/StimulusProxyWorkflowInbox.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/StimulusProxyWorkflowInbox.cs @@ -1,5 +1,4 @@ using Elsa.Common; -using Elsa.Extensions; using Elsa.Workflows.Models; using Elsa.Workflows.Runtime.Contracts; using Elsa.Workflows.Runtime.Entities; diff --git a/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs b/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs index 77aaa3c83..552b75323 100644 --- a/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs +++ b/src/modules/Elsa.Workflows.Runtime/Services/WorkflowCancellationService.cs @@ -1,5 +1,4 @@ using Elsa.Common.Models; -using Elsa.Extensions; using Elsa.Workflows.Management; using Elsa.Workflows.Management.Entities; using Elsa.Workflows.Management.Filters; @@ -97,7 +96,7 @@ public class WorkflowCancellationService( var childInstances = (await workflowInstanceStore.FindManyAsync(filter, cancellationToken)).ToList(); if (childInstances.Any()) - tasks.AddRange(CancelWorkflows(childInstances, cancellationToken)); + tasks.Add(CancelWorkflows(childInstances, cancellationToken)); } await Task.WhenAll(tasks); diff --git a/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj b/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj index 11d650d19..7a1d27571 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj +++ b/test/component/Elsa.Workflows.ComponentTests/Elsa.Workflows.ComponentTests.csproj @@ -9,6 +9,10 @@ true + + + + @@ -17,6 +21,7 @@ + diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Decorators/EventPublishingChangeTokenSignaler.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Decorators/EventPublishingChangeTokenSignaler.cs index aecc42bc6..f30500235 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Decorators/EventPublishingChangeTokenSignaler.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Decorators/EventPublishingChangeTokenSignaler.cs @@ -1,7 +1,6 @@ using Elsa.Caching; -using Elsa.Testing.Shared; using Elsa.Testing.Shared.Services; -using Hangfire.Annotations; +using JetBrains.Annotations; using Microsoft.Extensions.Primitives; namespace Elsa.Workflows.ComponentTests.Decorators; diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/App.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/App.cs index bcf1d377a..4096a61a7 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/App.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/App.cs @@ -1,4 +1,4 @@ -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Fixtures; diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Cluster.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Cluster.cs index 6ef20f1a5..c36fe6412 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Cluster.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/Cluster.cs @@ -1,4 +1,4 @@ -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Fixtures; diff --git a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs index 8bb1c3054..1dfe08fd3 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Helpers/Fixtures/WorkflowServer.cs @@ -1,10 +1,12 @@ using Elsa.Caching; +using Elsa.Extensions; using Elsa.Identity.Providers; using Elsa.Testing.Shared.Services; using Elsa.Workflows.ComponentTests.Decorators; using Elsa.Workflows.ComponentTests.Materializers; using Elsa.Workflows.ComponentTests.WorkflowProviders; using Elsa.Workflows.Management; +using JetBrains.Annotations; using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.AspNetCore.TestHost; diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/EmployeeGreetingWorkflow.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/EmployeeGreetingWorkflow.cs index 5ce0e9b94..b72d8af6f 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/EmployeeGreetingWorkflow.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/EmployeeGreetingWorkflow.cs @@ -1,6 +1,6 @@ using Elsa.Extensions; using Elsa.Workflows.Activities; -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Scenarios.BulkDispatchWorkflows.Workflows; diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/FruitWorkflow.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/FruitWorkflow.cs index 50c1643f1..42d91876d 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/FruitWorkflow.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/BulkDispatchWorkflows/Workflows/FruitWorkflow.cs @@ -1,7 +1,7 @@ using Elsa.Extensions; using Elsa.Workflows.Activities; using Elsa.Workflows.ComponentTests.Activities; -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Scenarios.BulkDispatchWorkflows.Workflows; diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/DispatchWorkflows/Workflows/ChildWorkflow.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/DispatchWorkflows/Workflows/ChildWorkflow.cs index 8a5fae17f..4cb55a868 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/DispatchWorkflows/Workflows/ChildWorkflow.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/DispatchWorkflows/Workflows/ChildWorkflow.cs @@ -1,6 +1,6 @@ using Elsa.Scheduling.Activities; using Elsa.Workflows.Activities; -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Scenarios.DispatchWorkflows.Workflows; diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/ExecuteWorkflows/Workflows/SubroutineWorkflow.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/ExecuteWorkflows/Workflows/SubroutineWorkflow.cs index 531c6cfda..e685e2f3d 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/ExecuteWorkflows/Workflows/SubroutineWorkflow.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/ExecuteWorkflows/Workflows/SubroutineWorkflow.cs @@ -1,7 +1,7 @@ using Elsa.Extensions; using Elsa.Workflows.Activities; using Elsa.Workflows.Management.Activities.SetOutput; -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Scenarios.ExecuteWorkflows.Workflows; diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant1.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant1.cs index 60435fda7..d88b3d8a0 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant1.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant1.cs @@ -1,5 +1,5 @@ using Elsa.Workflows.Activities; -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Scenarios.Multitenancy.Workflows; diff --git a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant2.cs b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant2.cs index d9f27eea5..9c831939d 100644 --- a/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant2.cs +++ b/test/component/Elsa.Workflows.ComponentTests/Scenarios/Multitenancy/Workflows/WorkflowForTenant2.cs @@ -1,5 +1,5 @@ using Elsa.Workflows.Activities; -using Hangfire.Annotations; +using JetBrains.Annotations; namespace Elsa.Workflows.ComponentTests.Scenarios.Multitenancy.Workflows; diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj b/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj index 98d0529f9..d52f2709c 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj +++ b/test/integration/Elsa.Workflows.IntegrationTests/Elsa.Workflows.IntegrationTests.csproj @@ -8,6 +8,7 @@ + diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/LiquidSubWorkflow/LiquidSubWorkflowTests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/LiquidSubWorkflow/LiquidSubWorkflowTests.cs deleted file mode 100644 index 5080dfd69..000000000 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/LiquidSubWorkflow/LiquidSubWorkflowTests.cs +++ /dev/null @@ -1,40 +0,0 @@ -using Elsa.Testing.Shared; -using Elsa.Workflows.Runtime; -using Microsoft.Extensions.DependencyInjection; -using Xunit; -using Xunit.Abstractions; - -namespace Elsa.Workflows.IntegrationTests.Scenarios.LiquidSubWorkflow; - -public class LiquidSubWorkflowTests -{ - private readonly ITestOutputHelper _testOutputHelper; - - public LiquidSubWorkflowTests(ITestOutputHelper testOutputHelper) - { - _testOutputHelper = testOutputHelper; - } - - [Fact] - public async Task ShouldBeAbleToUseLiquidExpressionsToReadInputInSubWorkflows() - { - // Arrange. - var services = new TestApplicationBuilder() - .WithCapturingTextWriter() - .Build(); - - var workflowRunner = services.GetRequiredService(); - - // Act. - await workflowRunner.RunAsync(); - - // Assert. - var capturedOutput = services.GetRequiredService(); - var output = capturedOutput.ToString(); - _testOutputHelper.WriteLine(output); - - // Verify that the liquid expressions were able to read the input values. - Assert.Contains("Person: John Doe, Email: john@example.com", output); - Assert.Contains("Sub workflow result: John Doe - john@example.com", output); - } -} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/LiquidSubWorkflow/Workflows.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/LiquidSubWorkflow/Workflows.cs deleted file mode 100644 index 7d82b70a9..000000000 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/LiquidSubWorkflow/Workflows.cs +++ /dev/null @@ -1,76 +0,0 @@ -using Elsa.Extensions; -using Elsa.Workflows.Activities; -using Elsa.Workflows.Management.Activities.SetOutput; -using Elsa.Workflows.Memory; -using Elsa.Workflows.Models; -using Elsa.Expressions.Models; - -namespace Elsa.Workflows.IntegrationTests.Scenarios.LiquidSubWorkflow; - -/// -/// A sub-workflow that reads input using liquid expressions -/// -public class LiquidSubWorkflow : WorkflowBase -{ - public Input PersonName { get; set; } = default!; - public Input PersonEmail { get; set; } = default!; - public Output Result { get; set; } = default!; - - protected override void Build(IWorkflowBuilder builder) - { - var resultVariable = new Variable("Result"); - - builder.Root = new Sequence - { - Variables = { resultVariable }, - Activities = - { - // Use liquid to read inputs - new WriteLine(new Expression("Liquid", "Person: {{ Input.PersonName }}, Email: {{ Input.PersonEmail }}")), - - // Set the result with liquid expression - new SetVariable - { - Variable = resultVariable, - Value = new Expression("Liquid", "{{ Input.PersonName }} - {{ Input.PersonEmail }}") - }, - - // Set output - new SetOutput - { - OutputName = new("Result"), - OutputValue = new(resultVariable) - } - } - }; - } -} - -/// -/// A main workflow that uses the sub-workflow as an activity -/// -public class LiquidParentWorkflow : WorkflowBase -{ - protected override void Build(IWorkflowBuilder builder) - { - var resultVariable = new Variable("Result"); - - var subWorkflow = new LiquidSubWorkflow - { - PersonName = new("John Doe"), - PersonEmail = new("john@example.com"), - Result = new(resultVariable) - }; - - builder.Variables.Add(resultVariable); - - builder.Root = new Sequence - { - Activities = - { - subWorkflow, - new WriteLine(context => $"Sub workflow result: {resultVariable.Get(context)}") - } - }; - } -} \ No newline at end of file diff --git a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/RunAsynchronousActivityOutput/Tests.cs b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/RunAsynchronousActivityOutput/Tests.cs index ffe94bfab..d454b5549 100644 --- a/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/RunAsynchronousActivityOutput/Tests.cs +++ b/test/integration/Elsa.Workflows.IntegrationTests/Scenarios/RunAsynchronousActivityOutput/Tests.cs @@ -3,7 +3,6 @@ using Elsa.Testing.Shared; using Elsa.Workflows.Activities; using Elsa.Workflows.IntegrationTests.Scenarios.RunAsynchronousActivityOutput.Activities; using Elsa.Workflows.Memory; -using Elsa.Workflows.Runtime.Distributed; using Elsa.Workflows.Runtime.Stores; using Microsoft.Extensions.DependencyInjection; @@ -116,16 +115,11 @@ public class Tests // Act var workflowFinishedRecord = await workflow.DispatchWorkflowAndRunToCompletion( - configureServices: services => - { - services.AddScoped(); - }, configureElsa: elsa => { elsa.UseWorkflowRuntime(workflowRuntime => { workflowRuntime.ActivityExecutionLogStore = sp => activityExecutionStore; - workflowRuntime.WorkflowRuntime = sp => sp.GetRequiredService(); }); });