diff --git a/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponent.java b/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponent.java
index 3b433b207..e106e61fd 100644
--- a/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponent.java
+++ b/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponent.java
@@ -32,30 +32,26 @@ public final class PipelineComponent
extends Component
{
private static final Map> COMPONENTS = new HashMap<>();
- private final Class extends PipelineComponents> container;
-
- private PipelineComponent(Class extends PipelineComponents> container, String name, Class type) {
+ private PipelineComponent(String name, Class
type) {
super(name, type, 0);
- this.container = container;
}
@Override
public String toString() {
- return container.getSimpleName() + "::" + super.toString();
+ return super.toString();
}
/**
* Create component
*
- * @param container the parent container
* @param name the name of component
* @param type the type of component
* @param generic type of component
* @return a new component
*/
@SuppressWarnings("unchecked")
- public static PipelineComponent of(Class extends PipelineComponents> container, String name, Class type) {
- return (PipelineComponent) ofComponents(COMPONENTS, name, () -> new PipelineComponent<>(container, name, type));
+ public static PipelineComponent of(String name, Class type) {
+ return (PipelineComponent) ofComponents(COMPONENTS, name, () -> new PipelineComponent<>(name, type));
}
/**
diff --git a/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponents.java b/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponents.java
deleted file mode 100644
index 8bbbda928..000000000
--- a/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/PipelineComponents.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (c) 2015-2020 Dzikoysk
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.panda_lang.framework.design.interpreter.parser.pipeline;
-
-import org.panda_lang.framework.PandaFrameworkException;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.stream.Collectors;
-
-/**
- * Represents collection of pipeline components
- */
-public interface PipelineComponents {
-
- /**
- * Collect pipeline components
- *
- * @return collection of pipeline components
- */
- default Collection> collectPipelineComponents() {
- return Arrays.stream(this.getClass().getFields())
- .filter(field -> PipelineComponent.class.isAssignableFrom(field.getType()))
- .map(field -> {
- try {
- return (PipelineComponent>) field.get(this);
- } catch (IllegalAccessException e) {
- throw new PandaFrameworkException(e);
- }
- })
- .collect(Collectors.toList());
- }
-
-}
diff --git a/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/Pipelines.java b/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/Pipelines.java
index 647bdd6af..8d7744ced 100644
--- a/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/Pipelines.java
+++ b/panda-framework/src/main/java/org/panda_lang/framework/design/interpreter/parser/pipeline/Pipelines.java
@@ -18,10 +18,13 @@
import org.panda_lang.framework.design.interpreter.parser.ContextParser;
+import java.util.Arrays;
+import java.util.Collection;
+
/**
* Default pipelines used by the framework
*/
-public final class Pipelines implements PipelineComponents {
+public final class Pipelines {
/**
* Text representation of {@link Pipelines#ALL}
@@ -30,7 +33,7 @@ public final class Pipelines implements PipelineComponents {
/**
* All pipelines
*/
- public static final PipelineComponent ALL = PipelineComponent.of(Pipelines.class, ALL_LABEL, ContextParser.class);
+ public static final PipelineComponent ALL = PipelineComponent.of(ALL_LABEL, ContextParser.class);
/**
* Text representation of {@link Pipelines#HEAD}
@@ -39,7 +42,7 @@ public final class Pipelines implements PipelineComponents {
/**
* Head pipeline
*/
- public static final PipelineComponent HEAD = PipelineComponent.of(Pipelines.class, HEAD_LABEL, ContextParser.class);
+ public static final PipelineComponent HEAD = PipelineComponent.of(HEAD_LABEL, ContextParser.class);
/**
* Text representation of {@link Pipelines#TYPE}
@@ -48,7 +51,7 @@ public final class Pipelines implements PipelineComponents {
/**
* Class type parsers, used by type parser
*/
- public static final PipelineComponent TYPE = PipelineComponent.of(Pipelines.class, TYPE_LABEL, ContextParser.class);
+ public static final PipelineComponent TYPE = PipelineComponent.of(TYPE_LABEL, ContextParser.class);
/**
* Text representation of {@link Pipelines#SCOPE}
@@ -57,6 +60,15 @@ public final class Pipelines implements PipelineComponents {
/**
* Scope parsers
*/
- public static final PipelineComponent SCOPE = PipelineComponent.of(Pipelines.class, SCOPE_LABEL, ContextParser.class);
+ public static final PipelineComponent SCOPE = PipelineComponent.of(SCOPE_LABEL, ContextParser.class);
+
+ /**
+ * Get collection of all components
+ *
+ * @return the collection of components
+ */
+ public static Collection> getPipelineComponents() {
+ return Arrays.asList(ALL, HEAD, TYPE, SCOPE);
+ }
}
diff --git a/panda-framework/src/main/java/org/panda_lang/framework/design/resource/Resources.java b/panda-framework/src/main/java/org/panda_lang/framework/design/resource/Resources.java
index 69b6a86b0..b475c2099 100644
--- a/panda-framework/src/main/java/org/panda_lang/framework/design/resource/Resources.java
+++ b/panda-framework/src/main/java/org/panda_lang/framework/design/resource/Resources.java
@@ -16,7 +16,9 @@
package org.panda_lang.framework.design.resource;
+import io.vavr.control.Option;
import org.panda_lang.framework.design.interpreter.messenger.MessengerInitializer;
+import org.panda_lang.framework.design.interpreter.messenger.MessengerOutputListener;
import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparsers;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelinePath;
@@ -44,6 +46,13 @@ public interface Resources {
*
* @return the messenger initializer
*/
- MessengerInitializer getMessengerInitializer();
+ Option getMessengerInitializer();
+
+ /**
+ * Get output listener for {@link org.panda_lang.framework.design.interpreter.messenger.Messenger}
+ *
+ * @return the output listener to use by messenger
+ */
+ Option getOutputListener();
}
diff --git a/panda-framework/src/main/java/org/panda_lang/framework/language/interpreter/messenger/PandaMessenger.java b/panda-framework/src/main/java/org/panda_lang/framework/language/interpreter/messenger/PandaMessenger.java
index 88303e2d3..eaa92759d 100644
--- a/panda-framework/src/main/java/org/panda_lang/framework/language/interpreter/messenger/PandaMessenger.java
+++ b/panda-framework/src/main/java/org/panda_lang/framework/language/interpreter/messenger/PandaMessenger.java
@@ -16,7 +16,9 @@
package org.panda_lang.framework.language.interpreter.messenger;
+import io.vavr.control.Option;
import org.jetbrains.annotations.Nullable;
+import org.panda_lang.framework.FrameworkController;
import org.panda_lang.framework.PandaFrameworkException;
import org.panda_lang.framework.design.interpreter.messenger.Messenger;
import org.panda_lang.framework.design.interpreter.messenger.MessengerFormatter;
@@ -34,25 +36,29 @@
public final class PandaMessenger implements Messenger {
private final Logger logger;
- private final @Nullable MessengerInitializer initializer;
+ private final MessengerInitializer initializer;
private final MessengerFormatter formatter = new PandaMessengerFormatter(this);
private final List> translators = new ArrayList<>();
private MessengerOutputListener outputListener;
private boolean initialized;
- public PandaMessenger(Logger logger, @Nullable MessengerInitializer initializer) {
+ public PandaMessenger(Logger logger, @Nullable MessengerInitializer initializer, @Nullable MessengerOutputListener outputListener) {
this.logger = logger;
- this.initializer = initializer;
- this.outputListener = new LoggerMessengerOutputListener(logger);
+ this.initializer = Option.of(initializer).getOrElse(messenger -> {});
+ this.outputListener = Option.of(outputListener).getOrElse(() -> new LoggerMessengerOutputListener(logger));
+ }
+
+ public PandaMessenger(FrameworkController controller) {
+ this(controller.getLogger(), controller.getResources().getMessengerInitializer().getOrNull(), controller.getResources().getOutputListener().getOrNull());
}
public PandaMessenger(Logger logger) {
- this(logger, null);
+ this(logger, null, null);
}
@Override
public boolean send(Object message) {
- if (!initialized && initializer != null) {
+ if (!initialized) {
initialized = true;
initializer.onInitialize(this);
}
diff --git a/panda-framework/src/main/java/org/panda_lang/framework/language/resource/PandaResources.java b/panda-framework/src/main/java/org/panda_lang/framework/language/resource/PandaResources.java
index 239d72e6e..00c3938a9 100644
--- a/panda-framework/src/main/java/org/panda_lang/framework/language/resource/PandaResources.java
+++ b/panda-framework/src/main/java/org/panda_lang/framework/language/resource/PandaResources.java
@@ -16,7 +16,9 @@
package org.panda_lang.framework.language.resource;
+import io.vavr.control.Option;
import org.panda_lang.framework.design.interpreter.messenger.MessengerInitializer;
+import org.panda_lang.framework.design.interpreter.messenger.MessengerOutputListener;
import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparsers;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelinePath;
import org.panda_lang.framework.design.resource.Resources;
@@ -41,8 +43,13 @@ public PipelinePath getPipelinePath() {
}
@Override
- public MessengerInitializer getMessengerInitializer() {
- return builder.messengerInitializer;
+ public Option getMessengerInitializer() {
+ return Option.of(builder.messengerInitializer);
+ }
+
+ @Override
+ public Option getOutputListener() {
+ return Option.of(builder.outputListener);
}
public static PandaResourcesBuilder builder() {
@@ -51,12 +58,18 @@ public static PandaResourcesBuilder builder() {
public static final class PandaResourcesBuilder {
+ public MessengerOutputListener outputListener;
public MessengerInitializer messengerInitializer;
public PipelinePath pipelinePath;
public ExpressionSubparsers expressionSubparsers;
private PandaResourcesBuilder() { }
+ public PandaResourcesBuilder withOutputListener(MessengerOutputListener outputListener) {
+ this.outputListener = outputListener;
+ return this;
+ }
+
public PandaResourcesBuilder withMessengerInitializer(MessengerInitializer messengerInitializer) {
this.messengerInitializer = messengerInitializer;
return this;
diff --git a/panda-framework/src/test/java/org/panda_lang/framework/language/interpreter/parser/pipeline/PandaPipelinePathTest.java b/panda-framework/src/test/java/org/panda_lang/framework/language/interpreter/parser/pipeline/PandaPipelinePathTest.java
index 774f6023e..36694256c 100644
--- a/panda-framework/src/test/java/org/panda_lang/framework/language/interpreter/parser/pipeline/PandaPipelinePathTest.java
+++ b/panda-framework/src/test/java/org/panda_lang/framework/language/interpreter/parser/pipeline/PandaPipelinePathTest.java
@@ -21,7 +21,6 @@
import org.junit.jupiter.api.Test;
import org.panda_lang.framework.design.interpreter.parser.Parser;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelineComponent;
-import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelineComponents;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelinePath;
import org.panda_lang.framework.language.interpreter.parser.PandaContext;
import org.panda_lang.framework.language.interpreter.token.PandaTokenInfo;
@@ -29,10 +28,10 @@
import java.util.Arrays;
-class PandaPipelinePathTest implements PipelineComponents {
+class PandaPipelinePathTest {
- private static final PipelineComponent> TEST_COMPONENT = PipelineComponent.of(PandaPipelinePathTest.class, "test", Parser.class);
- private static final PipelineComponent> ANOTHER_TEST_COMPONENT = PipelineComponent.of(PandaPipelinePathTest.class, "another-test", Parser.class);
+ private static final PipelineComponent> TEST_COMPONENT = PipelineComponent.of("test", Parser.class);
+ private static final PipelineComponent> ANOTHER_TEST_COMPONENT = PipelineComponent.of("another-test", Parser.class);
private PipelinePath defaultPath;
diff --git a/panda/src/main/java/org/panda_lang/panda/PandaFactory.java b/panda/src/main/java/org/panda_lang/panda/PandaFactory.java
index 05901e29b..52752bd69 100644
--- a/panda/src/main/java/org/panda_lang/panda/PandaFactory.java
+++ b/panda/src/main/java/org/panda_lang/panda/PandaFactory.java
@@ -37,6 +37,8 @@
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.assignation.AssignationParsers;
import org.slf4j.Logger;
+import java.util.Arrays;
+
/**
* Simplify creation of Panda instance
*/
@@ -55,23 +57,35 @@ public Panda createPanda(Logger logger) {
// initialize messenger
.initializeMessenger()
- .addLayouts(ExceptionTranslatorLayout.class)
- .addLayouts(PandaLexerFailureTranslatorLayout.class, InterpreterFailureTranslatorLayout.class, ParserFailureTranslatorLayout.class)
- .addLayouts(ProcessFailureTranslatorLayout.class)
- .addDataFormatters(EnvironmentFormatter.class, ThrowableFormatter.class, StacktraceElementsFormatter.class, ExceptionFormatter.class)
- .addDataFormatters(IndicatedSourceFormatter.class, ParserFailureFormatter.class)
- .addDataFormatters(ProcessFailureFormatter.class)
+ .addLayouts(() -> Arrays.asList(
+ new ExceptionTranslatorLayout(),
+ new PandaLexerFailureTranslatorLayout(),
+ new InterpreterFailureTranslatorLayout(),
+ new ParserFailureTranslatorLayout(),
+ new ProcessFailureTranslatorLayout()
+ ))
+ .addDataFormatters(() -> Arrays.asList(
+ new EnvironmentFormatter(),
+ new ThrowableFormatter(),
+ new StacktraceElementsFormatter(),
+ new ExceptionFormatter(),
+ new IndicatedSourceFormatter(),
+ new ParserFailureFormatter(),
+ new ProcessFailureFormatter()
+ ))
.addDataMapper(new StacktraceMapper())
.collect()
// load pipelines
.initializePipelines()
- .usePipelines(Pipelines.class, PandaPipeline.class)
+ .usePipelines(Pipelines.getPipelineComponents())
+ .usePipelines(PandaPipeline.getPipelineComponents())
.collect()
// load parsers and expressions subparsers
.initializeParsers()
- .loadParsersClasses(PandaParsers.PARSERS, AssignationParsers.SUBPARSERS)
+ .loadParsers(PandaParsers.PARSERS)
+ .loadParsers(AssignationParsers.SUBPARSERS)
.loadDefaultExpressionSubparsers()
.collect()
diff --git a/panda/src/main/java/org/panda_lang/panda/bootstrap/MessengerInitializer.java b/panda/src/main/java/org/panda_lang/panda/bootstrap/MessengerInitializer.java
index 1ab98e640..02449569e 100644
--- a/panda/src/main/java/org/panda_lang/panda/bootstrap/MessengerInitializer.java
+++ b/panda/src/main/java/org/panda_lang/panda/bootstrap/MessengerInitializer.java
@@ -24,10 +24,10 @@
import org.panda_lang.panda.language.interpreter.messenger.PandaTranslatorLayoutManager;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
+import java.util.function.Supplier;
/**
* {@link org.panda_lang.framework.design.interpreter.messenger.Messenger} creator
@@ -35,9 +35,9 @@
public final class MessengerInitializer implements Initializer {
private final PandaBootstrap bootstrap;
- private final Collection>> layouts = new ArrayList<>();
- private final Collection>> dataFormatters = new ArrayList<>();
- private final Map, MessengerDataMapper> dataMappers = new HashMap<>();
+ private final Collection>>> layouts = new ArrayList<>(2);
+ private final Collection>>> dataFormatters = new ArrayList<>(2);
+ private final Map, MessengerDataMapper, ?>> dataMappers = new HashMap<>(2);
private MessengerOutputListener outputListener;
MessengerInitializer(PandaBootstrap bootstrap) {
@@ -47,24 +47,22 @@ public final class MessengerInitializer implements Initializer {
/**
* Add translator layouts to messenger
*
- * @param layoutClasses classes of layouts to add
+ * @param layouts layouts to add
* @return the category instance
*/
- @SafeVarargs
- public final MessengerInitializer addLayouts(Class extends PandaTranslatorLayout>>... layoutClasses) {
- layouts.addAll(Arrays.asList(layoutClasses));
+ public final MessengerInitializer addLayouts(Supplier>> layouts) {
+ this.layouts.add(layouts);
return this;
}
/**
* Add data formatters to messenger
*
- * @param dataFormatterClasses classes of formatters to add
+ * @param dataFormatters classes of formatters to add
* @return the category instance
*/
- @SafeVarargs
- public final MessengerInitializer addDataFormatters(Class extends MessengerDataFormatter>>... dataFormatterClasses) {
- dataFormatters.addAll(Arrays.asList(dataFormatterClasses));
+ public final MessengerInitializer addDataFormatters(Supplier>> dataFormatters) {
+ this.dataFormatters.add(dataFormatters);
return this;
}
@@ -92,16 +90,20 @@ public MessengerInitializer addDataMapper(MessengerDataMapper, ?> dataMapper)
@Override
public PandaBootstrap collect() {
- bootstrap.resources.withMessengerInitializer(messenger -> {
- if (outputListener != null) {
- messenger.setOutputListener(outputListener);
- }
+ if (outputListener != null) {
+ bootstrap.resources.withOutputListener(outputListener);
+ }
+ bootstrap.resources.withMessengerInitializer(messenger -> {
PandaTranslatorLayoutManager translatorLayoutManager = new PandaTranslatorLayoutManager(messenger, dataMappers);
- layouts.forEach(translatorLayoutManager::load);
+ layouts.stream()
+ .flatMap(layout -> layout.get().stream())
+ .forEach(translatorLayoutManager::load);
MessengerDataFormatterManager dataFormatterManager = new MessengerDataFormatterManager(messenger);
- dataFormatters.forEach(dataFormatterManager::load);
+ dataFormatters.stream()
+ .flatMap(layout -> layout.get().stream())
+ .forEach(dataFormatterManager::load);
});
return bootstrap;
diff --git a/panda/src/main/java/org/panda_lang/panda/bootstrap/ParsersInitializer.java b/panda/src/main/java/org/panda_lang/panda/bootstrap/ParsersInitializer.java
index ed63614c9..55b07da5c 100644
--- a/panda/src/main/java/org/panda_lang/panda/bootstrap/ParsersInitializer.java
+++ b/panda/src/main/java/org/panda_lang/panda/bootstrap/ParsersInitializer.java
@@ -20,7 +20,7 @@
import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparser;
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionSubparsers;
import org.panda_lang.panda.language.interpreter.parser.RegistrableParsersLoader;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import java.util.ArrayList;
import java.util.Arrays;
@@ -43,12 +43,11 @@ public final class ParsersInitializer implements Initializer {
/**
* Load custom expression subparser classes
*
- * @param subparserClasses the classes to load
+ * @param subparsers the subparsers to load
* @return the initializer instance
*/
- @SafeVarargs
- public final ParsersInitializer loadExpressionSubparsers(Class extends ExpressionSubparser>... subparserClasses) {
- this.expressionSubparsers.addAll(PandaExpressionUtils.collectSubparsers(subparserClasses).getSubparsers());
+ public final ParsersInitializer loadExpressionSubparsers(ExpressionSubparser... subparsers) {
+ this.expressionSubparsers.addAll(Arrays.asList(subparsers));
return this;
}
@@ -59,48 +58,32 @@ public final ParsersInitializer loadExpressionSubparsers(Class extends Express
* @see org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions#SUBPARSERS
*/
public ParsersInitializer loadDefaultExpressionSubparsers() {
- this.expressionSubparsers.addAll(PandaExpressionUtils.collectSubparsers().getSubparsers());
- return this;
- }
-
- /**
- * Load arrays of parsers classes
- *
- * @param classes classes to load
- * @return the initializer instance
- */
- @SafeVarargs
- public final ParsersInitializer loadParsersClasses(Class extends Parser>[]... classes) {
- for (Class extends Parser>[] parsers : classes) {
- loadParsersClasses(parsers);
- }
-
+ this.expressionSubparsers.addAll(PandaExpressions.getSubparsers());
return this;
}
/**
* Load array of parsers classes
*
- * @param classes classes to load
+ * @param parsers classes to load
* @return the initializer instance
*/
- @SafeVarargs
- public final ParsersInitializer loadParsersClasses(Class extends Parser>... classes) {
- return loadParsers(Arrays.asList(classes));
+ public final ParsersInitializer loadParsers(Parser... parsers) {
+ return loadParsers(Arrays.asList(parsers));
}
/**
* Load collection of parsers classes
*
- * @param classes classes to load
+ * @param parsers classes to load
* @return the initializer instance
*/
- public ParsersInitializer loadParsers(Collection> classes) {
+ public ParsersInitializer loadParsers(Collection parsers) {
if (bootstrap.resources.pipelinePath == null) {
throw new BootstrapException("Cannot load parsers because pipeline was not initialized");
}
- registrationLoader.loadParsers(bootstrap.resources.pipelinePath, classes);
+ registrationLoader.loadParsers(bootstrap.resources.pipelinePath, parsers);
return this;
}
diff --git a/panda/src/main/java/org/panda_lang/panda/bootstrap/PipelinesInitializer.java b/panda/src/main/java/org/panda_lang/panda/bootstrap/PipelinesInitializer.java
index ceeaab04b..1d86d7329 100644
--- a/panda/src/main/java/org/panda_lang/panda/bootstrap/PipelinesInitializer.java
+++ b/panda/src/main/java/org/panda_lang/panda/bootstrap/PipelinesInitializer.java
@@ -16,9 +16,7 @@
package org.panda_lang.panda.bootstrap;
-import org.panda_lang.framework.PandaFrameworkException;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelineComponent;
-import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelineComponents;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelinePath;
import org.panda_lang.framework.language.interpreter.parser.pipeline.PandaPipelinePath;
@@ -39,21 +37,14 @@ public final class PipelinesInitializer implements Initializer {
/**
* Add pipeline components to the path
*
- * @param componentsClasses pipeline components classes to add
+ * @param componentsCollections pipeline components to add
* @return the initializer
*/
@SafeVarargs
- public final PipelinesInitializer usePipelines(Class extends PipelineComponents>... componentsClasses) {
- for (Class extends PipelineComponents> componentClass : componentsClasses) {
- try {
- PipelineComponents pipelines = componentClass.newInstance();
- Collection> components = pipelines.collectPipelineComponents();
-
- for (PipelineComponent> component : components) {
- path.createPipeline(component);
- }
- } catch (InstantiationException | IllegalAccessException e) {
- throw new PandaFrameworkException("Cannot create instance of pipelines container: " + e.getMessage());
+ public final PipelinesInitializer usePipelines(Collection>... componentsCollections) {
+ for (Collection> components : componentsCollections) {
+ for (PipelineComponent> component : components) {
+ path.createPipeline(component);
}
}
diff --git a/panda/src/main/java/org/panda_lang/panda/language/architecture/PandaEnvironment.java b/panda/src/main/java/org/panda_lang/panda/language/architecture/PandaEnvironment.java
index 14472f3dd..c7df6db53 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/architecture/PandaEnvironment.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/architecture/PandaEnvironment.java
@@ -46,7 +46,7 @@ public PandaEnvironment(FrameworkController controller, File workingDirectory) {
this.workingDirectory = workingDirectory;
this.modulePath = new PandaModulePath();
this.typeLoader = new PandaTypeLoader();
- this.messenger = new PandaMessenger(controller.getLogger(), controller.getResources().getMessengerInitializer());
+ this.messenger = new PandaMessenger(controller);
this.interpreter = new PandaInterpreter(this);
}
@@ -56,7 +56,7 @@ public synchronized void initialize() {
}
this.initialized = true;
- controller.getResources().getMessengerInitializer().onInitialize(messenger);
+ controller.getResources().getOutputListener().peek(messenger::setOutputListener);
ResourcesLoader resourcesLoader = new ResourcesLoader();
resourcesLoader.load(modulePath, typeLoader);
diff --git a/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslator.java b/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslator.java
index 87ccd7eaf..bfb3dfb17 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslator.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslator.java
@@ -24,6 +24,7 @@
import org.panda_lang.panda.language.interpreter.messenger.template.MicroTemplate;
import org.panda_lang.panda.language.interpreter.messenger.template.MicroTemplateEngine;
import org.panda_lang.panda.language.interpreter.messenger.template.MicroTemplateRequest;
+import org.panda_lang.utilities.commons.ObjectUtils;
import java.util.HashMap;
import java.util.Map;
@@ -32,9 +33,9 @@ final class PandaTranslator implements MessengerMessageTranslator {
private final MicroTemplateEngine engine;
private final PandaTranslatorLayout scheme;
- private final Map, MessengerDataMapper> mappers;
+ private final Map, MessengerDataMapper, ?>> mappers;
- PandaTranslator(MicroTemplateEngine engine, PandaTranslatorLayout scheme, Map, MessengerDataMapper> mappers) {
+ PandaTranslator(MicroTemplateEngine engine, PandaTranslatorLayout scheme, Map, MessengerDataMapper, ?>> mappers) {
this.engine = engine;
this.scheme = scheme;
this.mappers = mappers;
@@ -54,8 +55,7 @@ public boolean translate(Messenger messenger, T element) {
return;
}
- //noinspection unchecked
- patch.put(key, mappers.get(value.getClass()).apply(value));
+ patch.put(key, mappers.get(value.getClass()).apply(ObjectUtils.cast(value)));
});
data.putAll(patch);
diff --git a/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslatorLayoutManager.java b/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslatorLayoutManager.java
index b3faae349..e2de4152c 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslatorLayoutManager.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/interpreter/messenger/PandaTranslatorLayoutManager.java
@@ -26,10 +26,10 @@
public final class PandaTranslatorLayoutManager {
private final Messenger messenger;
- private final Map, MessengerDataMapper> mappers;
+ private final Map, MessengerDataMapper, ?>> mappers;
private final MicroTemplateEngine engine = new MicroTemplateEngine();
- public PandaTranslatorLayoutManager(Messenger messenger, Map, MessengerDataMapper> mappers) {
+ public PandaTranslatorLayoutManager(Messenger messenger, Map, MessengerDataMapper, ?>> mappers) {
this.messenger = messenger;
this.mappers = mappers;
}
diff --git a/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaContextUtils.java b/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaContextUtils.java
index c862305ed..53a725b7e 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaContextUtils.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaContextUtils.java
@@ -28,12 +28,13 @@
import org.panda_lang.framework.language.architecture.module.PandaTypeLoader;
import org.panda_lang.framework.language.interpreter.parser.PandaContext;
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParser;
+import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionSubparsers;
import org.panda_lang.framework.language.interpreter.parser.generation.GenerationCycles;
import org.panda_lang.framework.language.interpreter.parser.generation.PandaGeneration;
import org.panda_lang.panda.language.architecture.PandaEnvironment;
import org.panda_lang.panda.language.architecture.PandaScript;
import org.panda_lang.panda.language.resource.ResourcesLoader;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import java.io.File;
@@ -42,13 +43,13 @@ public final class PandaContextUtils {
private PandaContextUtils() { }
public static Context createStubContext(FrameworkController frameworkController) {
- PandaEnvironment environment = new PandaEnvironment(frameworkController, new File("."));
+ PandaEnvironment environment = new PandaEnvironment(frameworkController, new File("./"));
environment.initialize();
Context context = new PandaContext()
.withComponent(Components.CONTROLLER, frameworkController)
.withComponent(Components.ENVIRONMENT, environment)
- .withComponent(Components.EXPRESSION, new PandaExpressionParser(PandaExpressionUtils.collectSubparsers()));
+ .withComponent(Components.EXPRESSION, new PandaExpressionParser(new PandaExpressionSubparsers(PandaExpressions.getSubparsers())));
ModulePath path = new PandaModulePath();
TypeLoader loader = new PandaTypeLoader();
diff --git a/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaPipeline.java b/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaPipeline.java
index cbcf044d0..8c5b777f5 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaPipeline.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/PandaPipeline.java
@@ -17,14 +17,16 @@
package org.panda_lang.panda.language.interpreter.parser;
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelineComponent;
-import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelineComponents;
import org.panda_lang.panda.language.interpreter.parser.block.BlockSubparser;
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.assignation.AssignationSubparser;
+import java.util.Arrays;
+import java.util.Collection;
+
/**
* Used by {@link RegistrableParser}
*/
-public final class PandaPipeline implements PipelineComponents {
+public final class PandaPipeline {
/**
* Text representation of {@link PandaPipeline#BLOCK}
@@ -33,7 +35,7 @@ public final class PandaPipeline implements PipelineComponents {
/**
* Class type parsers, used by {@link org.panda_lang.panda.language.interpreter.parser.block.BlockParser}
*/
- public static final PipelineComponent BLOCK = PipelineComponent.of(PandaPipeline.class, BLOCK_LABEL, BlockSubparser.class);
+ public static final PipelineComponent BLOCK = PipelineComponent.of(BLOCK_LABEL, BlockSubparser.class);
/**
* Text representation of {@link PandaPipeline#ASSIGNER}
@@ -42,6 +44,15 @@ public final class PandaPipeline implements PipelineComponents {
/**
* Assigner parsers, used by {@link org.panda_lang.panda.language.resource.syntax.expressions.subparsers.assignation.AssignationExpressionSubparser}
*/
- public static final PipelineComponent ASSIGNER = PipelineComponent.of(PandaPipeline.class, ASSIGNER_LABEL, AssignationSubparser.class);
+ public static final PipelineComponent ASSIGNER = PipelineComponent.of(ASSIGNER_LABEL, AssignationSubparser.class);
+
+ /**
+ * Get collection of all components
+ *
+ * @return the collection of components
+ */
+ public static Collection> getPipelineComponents() {
+ return Arrays.asList(BLOCK, ASSIGNER);
+ }
}
diff --git a/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/RegistrableParsersLoader.java b/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/RegistrableParsersLoader.java
index 44e1ade1c..45f73dda6 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/RegistrableParsersLoader.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/interpreter/parser/RegistrableParsersLoader.java
@@ -17,7 +17,6 @@
package org.panda_lang.panda.language.interpreter.parser;
import org.panda_lang.framework.PandaFrameworkException;
-import org.panda_lang.framework.design.interpreter.parser.ContextParser;
import org.panda_lang.framework.design.interpreter.parser.Parser;
import org.panda_lang.framework.design.interpreter.parser.ParserRepresentation;
import org.panda_lang.framework.design.interpreter.parser.pipeline.Handler;
@@ -25,11 +24,9 @@
import org.panda_lang.framework.design.interpreter.parser.pipeline.PipelinePath;
import org.panda_lang.framework.language.interpreter.parser.pipeline.PandaParserRepresentation;
import org.panda_lang.panda.PandaException;
-import org.panda_lang.utilities.annotations.AnnotationsScannerProcess;
import org.slf4j.Logger;
import java.util.Collection;
-import java.util.stream.Collectors;
public final class RegistrableParsersLoader {
@@ -39,32 +36,7 @@ public RegistrableParsersLoader(Logger logger) {
this.logger = logger;
}
- public PipelinePath load(PipelinePath path, AnnotationsScannerProcess scannerProcess) {
- logger.debug("");
- logger.debug("--- Loading pipelines ");
-
- @SuppressWarnings("unchecked")
- Collection> loaded = scannerProcess.createSelector()
- .selectTypesAnnotatedWith(RegistrableParser.class)
- .stream()
- .filter(clazz -> {
- if (Parser.class.isAssignableFrom(clazz)) {
- return true;
- }
-
- logger.error(clazz + " is annotated with ParserRegistration and does not implement Parser");
- return true;
- })
- .map(clazz -> (Class extends Parser>) clazz)
- .collect(Collectors.toList());
-
- loadParsers(path, loaded);
- logger.debug("");
-
- return path;
- }
-
- public PipelinePath loadParsers(PipelinePath path, Collection> parsers) {
+ public PipelinePath loadParsers(PipelinePath path, Collection parsers) {
try {
return loadParsersInternal(path, parsers);
} catch (Exception e) {
@@ -72,15 +44,14 @@ public PipelinePath loadParsers(PipelinePath path, Collection> parsers) throws InstantiationException, IllegalAccessException {
- for (Class> clazz : parsers) {
- RegistrableParser registrable = clazz.getAnnotation(RegistrableParser.class);
+ private PipelinePath loadParsersInternal(PipelinePath path, Collection parsers) throws InstantiationException, IllegalAccessException {
+ for (Parser parser : parsers) {
+ RegistrableParser registrable = parser.getClass().getAnnotation(RegistrableParser.class);
if (registrable == null) {
continue;
}
- Parser parser = createParserInstance(clazz, registrable.parserClass());
Handler handler = createHandlerInstance(parser, registrable.handlerClass());
ParserRepresentation representation = new PandaParserRepresentation<>(parser, handler, registrable.priority());
@@ -100,17 +71,6 @@ private PipelinePath loadParsersInternal(PipelinePath path, Collection createParserInstance(Class> currentClass, Class extends ContextParser> parserClass) throws IllegalAccessException, InstantiationException {
- if (parserClass != ContextParser.class) {
- return parserClass.newInstance();
- }
- else if (ContextParser.class.isAssignableFrom(currentClass)) {
- return (ContextParser>) currentClass.newInstance();
- }
-
- throw new PandaException("Cannot create parser instance (source: " + currentClass + ")");
- }
-
private Handler createHandlerInstance(Parser currentParser, Class extends Handler> handlerClass) throws IllegalAccessException, InstantiationException {
if (handlerClass != Handler.class) {
return handlerClass.newInstance();
diff --git a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/PandaParsers.java b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/PandaParsers.java
index 138e533f2..5c09dd739 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/PandaParsers.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/PandaParsers.java
@@ -16,12 +16,8 @@
package org.panda_lang.panda.language.resource.syntax;
-import org.panda_lang.framework.design.interpreter.parser.Parser;
-import org.panda_lang.panda.language.interpreter.parser.ApplicationParser;
-import org.panda_lang.panda.language.interpreter.parser.ScopeParser;
+import org.panda_lang.framework.design.interpreter.parser.ContextParser;
import org.panda_lang.panda.language.interpreter.parser.block.BlockParser;
-import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.ArgumentsParser;
-import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.number.NumberParser;
import org.panda_lang.panda.language.resource.syntax.head.CommentParser;
import org.panda_lang.panda.language.resource.syntax.head.ExportParser;
import org.panda_lang.panda.language.resource.syntax.head.ImportParser;
@@ -45,59 +41,43 @@
import org.panda_lang.panda.language.resource.syntax.type.ConstructorParser;
import org.panda_lang.panda.language.resource.syntax.type.FieldParser;
import org.panda_lang.panda.language.resource.syntax.type.MethodParser;
-import org.panda_lang.panda.language.resource.syntax.type.ParameterParser;
import org.panda_lang.panda.language.resource.syntax.type.SelfConstructorParser;
import org.panda_lang.panda.language.resource.syntax.type.TypeParser;
public final class PandaParsers {
- @SuppressWarnings("unchecked")
- public static final Class extends Parser>[] PARSERS = new Class[] {
- // lead
- ApplicationParser.class,
- ScopeParser.class,
+ public static final ContextParser>[] PARSERS = {
+ new CommentParser(),
- // common
- CommentParser.class,
- ArgumentsParser.class,
- NumberParser.class,
+ new ExportParser(),
+ new ImportParser(),
+ new RequireParser(),
+ new MainParser(),
+ new ModuleParser(),
- // overall
- ExportParser.class,
- ImportParser.class,
- RequireParser.class,
- MainParser.class,
- ModuleParser.class,
+ new BaseCallParser(),
+ new ConstructorParser(),
+ new SelfConstructorParser(),
+ new FieldParser(),
+ new MethodParser(),
+ new TypeParser(),
- // type
- BaseCallParser.class,
- ConstructorParser.class,
- SelfConstructorParser.class,
- FieldParser.class,
- MethodParser.class,
- ParameterParser.class,
- TypeParser.class,
+ new LateDeclarationParser(),
+ new LogParser(),
+ new StandaloneExpressionParser(),
+ new TryCatchParser(),
- // scope
- // AssignationParser.class, off
- LateDeclarationParser.class,
- LogParser.class,
- StandaloneExpressionParser.class,
- TryCatchParser.class,
+ new BlockParser(),
+ new ConditionalBlockParser(),
+ new ForEachParser(),
+ new ForParser(),
+ new LoopParser(),
+ new WhileParser(),
- // block
- BlockParser.class,
- ConditionalBlockParser.class,
- ForEachParser.class,
- ForParser.class,
- LoopParser.class,
- WhileParser.class,
-
- // branching
- BreakParser.class,
- ContinueParser.class,
- ReturnParser.class,
- ThrowParser.class
+ new BreakParser(),
+ new ContinueParser(),
+ new ReturnParser(),
+ new ThrowParser()
};
private PandaParsers() { }
diff --git a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressionUtils.java b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressionUtils.java
deleted file mode 100644
index c2470cf86..000000000
--- a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressionUtils.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (c) 2015-2020 Dzikoysk
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.panda_lang.panda.language.resource.syntax.expressions;
-
-import org.panda_lang.framework.PandaFrameworkException;
-import org.panda_lang.framework.design.architecture.module.ModuleLoaderUtils;
-import org.panda_lang.framework.design.architecture.type.Type;
-import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionContext;
-import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparser;
-import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparsers;
-import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionSubparsers;
-
-import java.util.Arrays;
-import java.util.stream.Collectors;
-
-public final class PandaExpressionUtils {
-
- private PandaExpressionUtils() { }
-
- public static ExpressionSubparsers collectSubparsers() {
- return collectSubparsers(PandaExpressions.SUBPARSERS);
- }
-
- @SafeVarargs
- public static ExpressionSubparsers collectSubparsers(Class extends ExpressionSubparser>... classes) {
- return new PandaExpressionSubparsers(Arrays.stream(classes)
- .map(clazz -> {
- try {
- return (ExpressionSubparser) clazz.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- throw new PandaFrameworkException(e);
- }
- })
- .collect(Collectors.toList()));
- }
-
- public static Type forClass(ExpressionContext expressionContext, Class> associatedClass) {
- return ModuleLoaderUtils.requireType(expressionContext.getContext(), associatedClass);
- }
-
-}
diff --git a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressions.java b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressions.java
index 4b626ceb9..62acaee5d 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressions.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/PandaExpressions.java
@@ -17,7 +17,8 @@
package org.panda_lang.panda.language.resource.syntax.expressions;
import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparser;
-import org.panda_lang.framework.language.interpreter.parser.PandaParsersUtils;
+import org.panda_lang.framework.design.interpreter.parser.expression.ExpressionSubparsers;
+import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionSubparsers;
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.ArrayValueExpressionSubparser;
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.CastExpressionSubparser;
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.ConstructorExpressionSubparser;
@@ -35,28 +36,39 @@
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.VariableExpressionSubparser;
import org.panda_lang.panda.language.resource.syntax.expressions.subparsers.assignation.AssignationExpressionSubparser;
+import java.util.Arrays;
+import java.util.Collection;
+
public final class PandaExpressions {
/**
* Array of default expression subparsers
*/
- public static final Class extends ExpressionSubparser>[] SUBPARSERS = PandaParsersUtils.of(
- ArrayValueExpressionSubparser.class,
- AssignationExpressionSubparser.class,
- CastExpressionSubparser.class,
- ConstructorExpressionSubparser.class,
- CreaseExpressionSubparser.class,
- IsExpressionSubparser.class,
- LiteralExpressionSubparser.class,
- MethodExpressionSubparser.class,
- NegateExpressionSubparser.class,
- NegativeExpressionSubparser.class,
- NumberExpressionSubparser.class,
- OperationExpressionSubparser.class,
- SectionExpressionSubparser.class,
- SequenceExpressionSubparser.class,
- StaticExpressionSubparser.class,
- VariableExpressionSubparser.class
- );
+ public static final ExpressionSubparser[] SUBPARSERS = {
+ new ArrayValueExpressionSubparser(),
+ new AssignationExpressionSubparser(),
+ new CastExpressionSubparser(),
+ new ConstructorExpressionSubparser(),
+ new CreaseExpressionSubparser(),
+ new IsExpressionSubparser(),
+ new LiteralExpressionSubparser(),
+ new MethodExpressionSubparser(),
+ new NegateExpressionSubparser(),
+ new NegativeExpressionSubparser(),
+ new NumberExpressionSubparser(),
+ new OperationExpressionSubparser(),
+ new SectionExpressionSubparser(),
+ new SequenceExpressionSubparser(),
+ new StaticExpressionSubparser(),
+ new VariableExpressionSubparser()
+ };
+
+ public static Collection getSubparsers() {
+ return Arrays.asList(SUBPARSERS);
+ }
+
+ public static ExpressionSubparsers getExpressionSubparsers() {
+ return new PandaExpressionSubparsers(getSubparsers());
+ }
}
diff --git a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/subparsers/assignation/AssignationParsers.java b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/subparsers/assignation/AssignationParsers.java
index 30580712b..54bb3b4f5 100644
--- a/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/subparsers/assignation/AssignationParsers.java
+++ b/panda/src/main/java/org/panda_lang/panda/language/resource/syntax/expressions/subparsers/assignation/AssignationParsers.java
@@ -22,11 +22,10 @@
public final class AssignationParsers {
- @SuppressWarnings("unchecked")
- public static final Class extends AssignationSubparser>>[] SUBPARSERS = new Class[] {
- VariableAssignationSubparser.class,
- VariableDeclarationSubparser.class,
- ArrayValueAssignationSubparser.class
+ public static final AssignationSubparser>[] SUBPARSERS = {
+ new VariableAssignationSubparser(),
+ new VariableDeclarationSubparser(),
+ new ArrayValueAssignationSubparser()
};
private AssignationParsers() { }
diff --git a/panda/src/main/java/org/panda_lang/panda/shell/PandaCli.java b/panda/src/main/java/org/panda_lang/panda/shell/PandaCli.java
index 5ae60f637..4ee4324bf 100644
--- a/panda/src/main/java/org/panda_lang/panda/shell/PandaCli.java
+++ b/panda/src/main/java/org/panda_lang/panda/shell/PandaCli.java
@@ -99,7 +99,7 @@ public void run() throws Exception {
}
if (script.getName().endsWith("panda.hjson")) {
- PackageManager packageManager = new PackageManager(new PandaMessenger(shell.getLogger()), script.getParentFile());
+ PackageManager packageManager = new PackageManager(new PandaMessenger(panda), script.getParentFile());
packageManager.install(script);
packageManager.run(panda, script);
return;
diff --git a/panda/src/main/java/org/panda_lang/panda/shell/repl/Repl.java b/panda/src/main/java/org/panda_lang/panda/shell/repl/Repl.java
index 81e0308d7..7cb00a9d3 100644
--- a/panda/src/main/java/org/panda_lang/panda/shell/repl/Repl.java
+++ b/panda/src/main/java/org/panda_lang/panda/shell/repl/Repl.java
@@ -204,7 +204,7 @@ private ReplResult evaluateExpression(Snippet expressionSource) {
/**
* Initiate REPL creator
*
- * @param
+ * @param console the console instance to use
* @return a REPL creator instance
*/
public static ReplCreator creator(ReplConsole console) {
diff --git a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionBenchmark.java b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionBenchmark.java
index 3d133d431..cc21e4b76 100644
--- a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionBenchmark.java
+++ b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionBenchmark.java
@@ -30,7 +30,7 @@
import org.panda_lang.framework.design.interpreter.token.Snippet;
import org.panda_lang.framework.language.interpreter.lexer.PandaLexerUtils;
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParser;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import org.panda_lang.panda.util.BenchmarkUtils;
@Fork(value = 1)
@@ -55,7 +55,7 @@ public static class Configuration {
@Setup(Level.Trial)
public void setup() {
- this.expressionParser = new PandaExpressionParser(PandaExpressionUtils.collectSubparsers());
+ this.expressionParser = new PandaExpressionParser(PandaExpressions.getExpressionSubparsers());
this.context = prepareData();
}
diff --git a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionContextUtils.java b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionContextUtils.java
index d9c359817..93e2059ef 100644
--- a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionContextUtils.java
+++ b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionContextUtils.java
@@ -18,9 +18,9 @@
import org.panda_lang.framework.design.architecture.module.Imports;
import org.panda_lang.framework.design.architecture.module.ModulePath;
+import org.panda_lang.framework.design.architecture.module.TypeLoader;
import org.panda_lang.framework.design.architecture.statement.StandardizedFramedScope;
import org.panda_lang.framework.design.architecture.statement.VariableData;
-import org.panda_lang.framework.design.architecture.module.TypeLoader;
import org.panda_lang.framework.design.interpreter.parser.Components;
import org.panda_lang.framework.design.interpreter.parser.Context;
import org.panda_lang.framework.language.architecture.module.PandaImports;
@@ -32,7 +32,7 @@
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParser;
import org.panda_lang.panda.language.architecture.PandaScript;
import org.panda_lang.panda.language.resource.ResourcesLoader;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import java.util.Map;
import java.util.function.Function;
@@ -56,7 +56,7 @@ private ExpressionContextUtils() { }
*/
public static Context createFakeContext(Function> variablesSupplier) {
Context context = new PandaContext();
- context.withComponent(Components.EXPRESSION, new PandaExpressionParser(PandaExpressionUtils.collectSubparsers()));
+ context.withComponent(Components.EXPRESSION, new PandaExpressionParser(PandaExpressions.getExpressionSubparsers()));
ModulePath path = new PandaModulePath();
TypeLoader loader = new PandaTypeLoader();
diff --git a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionParserTestBootstrap.java b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionParserTestBootstrap.java
index 93ce290b3..f055a6eb7 100644
--- a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionParserTestBootstrap.java
+++ b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/ExpressionParserTestBootstrap.java
@@ -33,7 +33,7 @@
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParser;
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParserFailure;
import org.panda_lang.framework.language.interpreter.token.PandaSourceStream;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import org.panda_lang.utilities.commons.StringUtils;
import java.util.HashMap;
@@ -45,7 +45,7 @@ class ExpressionParserTestBootstrap {
@BeforeAll
public static void load() {
- PARSER = new PandaExpressionParser(PandaExpressionUtils.collectSubparsers());
+ PARSER = new PandaExpressionParser(PandaExpressions.getExpressionSubparsers());
DATA = prepareData();
}
diff --git a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionBenchmark.java b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionBenchmark.java
index 6209d7f78..7385eb980 100644
--- a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionBenchmark.java
+++ b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionBenchmark.java
@@ -30,7 +30,7 @@
import org.panda_lang.framework.language.interpreter.lexer.PandaLexerUtils;
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParser;
import org.panda_lang.framework.language.resource.expression.ExpressionContextUtils;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import org.panda_lang.panda.util.BenchmarkUtils;
import java.util.HashMap;
@@ -51,7 +51,7 @@ public class OperationExpressionBenchmark {
@Setup
public void setup() {
- ExpressionParser parser = new PandaExpressionParser(PandaExpressionUtils.collectSubparsers());
+ ExpressionParser parser = new PandaExpressionParser(PandaExpressions.getExpressionSubparsers());
Snippet source = PandaLexerUtils.convert(OperationExpressionBenchmark.class.getSimpleName(), "1 + 2");
this.expression = parser.parse(ExpressionContextUtils.createFakeContext((context -> new HashMap<>())), source).getExpression();
}
diff --git a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionTest.java b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionTest.java
index b03a0187b..8e5638fbe 100644
--- a/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionTest.java
+++ b/panda/src/test/java/org/panda_lang/framework/language/resource/expression/subparsers/OperationExpressionTest.java
@@ -24,14 +24,14 @@
import org.panda_lang.framework.language.interpreter.lexer.PandaLexerUtils;
import org.panda_lang.framework.language.interpreter.parser.expression.PandaExpressionParser;
import org.panda_lang.framework.language.resource.expression.ExpressionContextUtils;
-import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressionUtils;
+import org.panda_lang.panda.language.resource.syntax.expressions.PandaExpressions;
import org.panda_lang.utilities.commons.TimeUtils;
import java.util.HashMap;
class OperationExpressionTest {
- private static final ExpressionParser PARSER = new PandaExpressionParser(PandaExpressionUtils.collectSubparsers());
+ private static final ExpressionParser PARSER = new PandaExpressionParser(PandaExpressions.getExpressionSubparsers());
private static final Snippet SOURCE = PandaLexerUtils.convert(OperationExpressionTest.class.getSimpleName(), "1 + 2");
@Test