Beispiel #1
0
        /// <summary>
        /// Visits a <see cref="ImportPluginStatement"/>.
        /// </summary>
        /// <param name="node">
        /// The node.
        /// </param>
        /// <returns>
        /// The node, or a new version of the node.
        /// </returns>
        protected internal override Node VisitImportPluginStatement([NotNull] ImportPluginStatement node)
        {
            if (this.Scope.IsPluginEnabled(node.Plugin))
            {
                this.AddWarning(node, $"Plugin {node.Plugin} was already enabled.");
            }

            if (!this.Scope.EnablePlugin(node.Plugin) && !this.Scope.IsLoadingPlugins)
            {
                var plugins          = this.Scope.GetAvailablePlugins().ToArray();
                var availablePlugins = plugins.Length == 0 ? string.Empty : $" Available plugins: {string.Join(", ", plugins.Where(p => !string.Equals(p, "DefaultFunctions")))}";
                this.AddError(node, $"Plugin {node.Plugin} was not found.{availablePlugins}");
            }

            return(base.VisitImportPluginStatement(node));
        }
Beispiel #2
0
        /// <summary>
        /// Visits a <see cref="ImportPluginStatement"/>.
        /// </summary>
        /// <param name="node">
        /// The node.
        /// </param>
        /// <returns>
        /// The node, or a new version of the node.
        /// </returns>
        protected internal override Node VisitImportPluginStatement(ImportPluginStatement node)
        {
            var plugin = this.plugins.FirstOrDefault(p => string.Equals(p.Name, node.Plugin, StringComparison.OrdinalIgnoreCase));

            try
            {
                if (this.registered.Add(plugin))
                {
                    plugin?.RegisterPlugin(this.context);
                }
            }
            catch (Exception e)
            {
                this.logger.Error(e);
            }

            return(node);
        }
Beispiel #3
0
 /// <summary>
 /// Visits a <see cref="ImportPluginStatement"/>.
 /// </summary>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <returns>
 /// The node, or a new version of the node.
 /// </returns>
 protected internal virtual Node VisitImportPluginStatement([NotNull] ImportPluginStatement node)
 {
     return(node.VisitChildren(this));
 }
 /// <summary>
 /// Visits a <see cref="ImportPluginStatement"/>.
 /// </summary>
 /// <param name="node">
 /// The node.
 /// </param>
 /// <returns>
 /// The node, or a new version of the node.
 /// </returns>
 protected internal override Node VisitImportPluginStatement(ImportPluginStatement node)
 {
     return(this.VisitImplementation(node) ?? base.VisitImportPluginStatement(node));
 }