From 8c6dda73a5d00f0de157a33647f315fc786adbf4 Mon Sep 17 00:00:00 2001 From: dzikoysk Date: Sun, 7 Feb 2021 00:24:11 +0100 Subject: [PATCH] GH-615 Add author name to package qualifier --- examples/current-test/panda.cdn | 3 +- .../panda-module-dependency/app.panda | 9 +++--- .../panda-module-dependency/panda.cdn | 8 ++--- .../panda.cdn | 2 +- .../architecture/packages/Package.java | 4 +++ .../architecture/packages/Packages.java | 1 + .../type/generator/ClassGenerator.java | 7 ++++- .../type/generator/TypeGenerator.java | 4 +-- .../type/signature/GenericSignature.java | 2 +- .../framework/resource/Mappings.java | 19 ++++++++---- .../resource/mappings/java/JavaModule.java | 2 +- .../commons/function/PandaStream.java | 5 +--- .../panda/language/std/StdLoader.java | 3 +- .../std/java/JavaCollectionsModule.java | 2 +- .../std/java/JavaExtensionModule.java | 2 +- .../language/std/java/JavaUtilsModule.java | 2 +- .../subparsers/IsExpressionSubparser.java | 2 +- .../LiteralExpressionSubparser.java | 2 +- .../subparsers/NegateLogicalExpression.java | 2 +- .../SequenceExpressionSubparser.java | 2 +- .../number/NegativeExpressionSubparser.java | 2 +- .../number/NotBitwiseExpressionSubparser.java | 2 +- .../subparsers/number/NumberParser.java | 12 ++++---- .../subparsers/number/NumberPriorities.java | 12 ++++---- .../subparsers/number/PandaNumbers.java | 12 ++++---- .../subparsers/operation/OperationUtils.java | 4 +-- .../ConcatenationOperatorSubparser.java | 2 +- .../subparsers/bitwise/BitwiseOperation.java | 2 +- .../logical/ComparisonOperator.java | 4 +-- .../logical/ComparisonOperatorAction.java | 2 +- .../subparsers/logical/EqualsToOperation.java | 6 ++-- .../subparsers/logical/OrOperation.java | 2 +- .../subparsers/math/MathOperation.java | 2 +- .../language/syntax/head/RequireParser.java | 25 +++++++++------- .../syntax/scope/block/TryCatchParser.java | 2 +- .../block/conditional/ConditionalBlock.java | 2 +- .../block/conditional/ConditionalParser.java | 2 +- .../scope/block/looping/ForEachParser.java | 2 +- .../syntax/scope/block/looping/ForParser.java | 2 +- .../scope/block/looping/LoopParser.java | 2 +- .../scope/block/looping/WhileParser.java | 2 +- .../syntax/type/ConstructorParser.java | 2 +- .../language/syntax/type/MethodParser.java | 4 +-- .../language/syntax/type/TypeParser.java | 2 +- .../panda_lang/panda/manager/Dependency.java | 29 +++++++++++++++---- .../panda_lang/panda/manager/PackageInfo.java | 2 +- .../panda/manager/goals/GitHubInstall.java | 2 +- .../panda/manager/goals/Install.java | 22 +++++++------- .../panda/manager/goals/MavenInstall.java | 2 +- .../panda_lang/panda/utils/PandaUtils.java | 3 -- .../ExpressionParserTestBootstrap.groovy | 6 ++-- .../panda/manager/DependencyTest.groovy | 2 +- .../manager/PandaModuleDependencyTest.groovy | 5 ++-- 53 files changed, 149 insertions(+), 118 deletions(-) diff --git a/examples/current-test/panda.cdn b/examples/current-test/panda.cdn index eb41f2274..5552e88aa 100644 --- a/examples/current-test/panda.cdn +++ b/examples/current-test/panda.cdn @@ -1,5 +1,4 @@ name: current-test version: 1.0.0 -owner: dzikoysk - +author: dzikoysk sources: src \ No newline at end of file diff --git a/examples/package-manager/panda-module-dependency/app.panda b/examples/package-manager/panda-module-dependency/app.panda index 76b0ed383..023932424 100644 --- a/examples/package-manager/panda-module-dependency/app.panda +++ b/examples/package-manager/panda-module-dependency/app.panda @@ -1,10 +1,9 @@ -// require panda-dependency defined in the panda.cdn -require 'panda-dependency' +// require panda-dependency implementations defined in the panda.cdn +require 'dzikoysk/panda-dependency' +require 'piotrpiatyszek/panda-dependency' main { - // print panda-dependency message + // use implementations log PandaDependency.getMessage() - - // print subdependency (defined in panda-dependency/panda.cdn) message log LDDependency.getMessage() } \ No newline at end of file diff --git a/examples/package-manager/panda-module-dependency/panda.cdn b/examples/package-manager/panda-module-dependency/panda.cdn index f60b97183..a7ee90973 100644 --- a/examples/package-manager/panda-module-dependency/panda.cdn +++ b/examples/package-manager/panda-module-dependency/panda.cdn @@ -1,12 +1,8 @@ name: panda-module-dependency version: 1.0.0 -owner: dzikoysk - -scripts: { - main: app.panda -} +author: dzikoysk dependencies: [ - github:dzikoysk/panda-dependency@1.0.5 + github:dzikoysk/panda-dependency@master ] diff --git a/examples/package-manager/panda-with-java-library-dependency/panda.cdn b/examples/package-manager/panda-with-java-library-dependency/panda.cdn index c96b54ca9..73de2ff68 100644 --- a/examples/package-manager/panda-with-java-library-dependency/panda.cdn +++ b/examples/package-manager/panda-with-java-library-dependency/panda.cdn @@ -1,6 +1,6 @@ name: panda-with-java-library-dependency version: 1.0.0 -owner: dzikoysk +author: dzikoysk scripts: { main: app.panda diff --git a/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Package.java b/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Package.java index bce4da407..476750635 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Package.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Package.java @@ -94,6 +94,10 @@ public String getAuthor() { } public String getName() { + return getAuthor() + "/" + getSimpleName(); + } + + public String getSimpleName() { return name; } diff --git a/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Packages.java b/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Packages.java index 2abc5d357..269fabd9c 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Packages.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/architecture/packages/Packages.java @@ -34,6 +34,7 @@ public Packages(SourceService sourceService) { } public Package registerPackage(Package pkg) { + packages.put(pkg.getSimpleName(), pkg); packages.put(pkg.getName(), pkg); return pkg; } diff --git a/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/ClassGenerator.java b/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/ClassGenerator.java index 666e44a57..628270046 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/ClassGenerator.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/ClassGenerator.java @@ -62,7 +62,12 @@ public final class ClassGenerator { private final Map generatedClasses = new HashMap<>(); public CtClass allocate(Type type) { - String javaName = type.getName().replace("::", "$").replace(":", "_") + "_" + ID.incrementAndGet(); + String javaName = type.getName() + .replace("/", "$") + .replace("@", "$") + .replace("::", "$") + .replace(":", "_") + + "_" + ID.incrementAndGet(); CtClass javaType = Kind.isInterface(type) ? CLASS_POOL.makeInterface(javaName) diff --git a/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/TypeGenerator.java b/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/TypeGenerator.java index dad960efa..0b2b9211d 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/TypeGenerator.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/generator/TypeGenerator.java @@ -89,8 +89,8 @@ public Reference generate(Module module, String name, Class javaType) { } if (!javaType.equals(Object.class) && type.getBases().isEmpty()) { - // type.addAutocast(typeLoader.requireType("panda@::Object"), (originalType, object, resultType) -> object); - type.addBase(typeLoader.requireType("panda@::Object").getSignature()); + // type.addAutocast(typeLoader.requireType("panda/panda@::Object"), (originalType, object, resultType) -> object); + type.addBase(typeLoader.requireType("panda/panda@::Object").getSignature()); } if (!Modifier.isPublic(javaType.getModifiers())) { diff --git a/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/signature/GenericSignature.java b/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/signature/GenericSignature.java index 33fc20c03..121a6aa06 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/signature/GenericSignature.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/architecture/type/signature/GenericSignature.java @@ -84,7 +84,7 @@ public Option getAlso() { public Type toType() { return getAny().map(Signature::toType) .orElse(() -> getAlso().map(Signature::toType)) - .orElseGet(() -> typeLoader.requireType("panda@::Object")); + .orElseGet(() -> typeLoader.requireType("panda/panda@::Object")); } @Override diff --git a/panda-framework/src/main/java/org/panda_lang/framework/resource/Mappings.java b/panda-framework/src/main/java/org/panda_lang/framework/resource/Mappings.java index 23a4c1447..7059c8b6a 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/resource/Mappings.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/resource/Mappings.java @@ -30,18 +30,25 @@ public @interface Mappings { /** - * Get the name of represented module + * Get associated with the module package * - * @return the name of module + * @return the name of package */ - String module(); + String pkg(); /** - * Get associated with the module package + * Get package author * - * @return the name of package + * @return the name of author */ - String pkg(); + String author(); + + /** + * Get the name of represented module + * + * @return the name of module + */ + String module(); /** * Get associated with the module package diff --git a/panda-framework/src/main/java/org/panda_lang/framework/resource/mappings/java/JavaModule.java b/panda-framework/src/main/java/org/panda_lang/framework/resource/mappings/java/JavaModule.java index 3be4dcfdb..263a4ef41 100644 --- a/panda-framework/src/main/java/org/panda_lang/framework/resource/mappings/java/JavaModule.java +++ b/panda-framework/src/main/java/org/panda_lang/framework/resource/mappings/java/JavaModule.java @@ -40,7 +40,7 @@ import java.util.Collections; -@Mappings(pkg = "panda", module = Package.DEFAULT_MODULE, commonPackage= "java.lang", classes = { +@Mappings(pkg = "panda", author = "panda", module = Package.DEFAULT_MODULE, commonPackage= "java.lang", classes = { "Iterable" }) public final class JavaModule implements CustomInitializer { diff --git a/panda-utilities/src/main/java/org/panda_lang/utilities/commons/function/PandaStream.java b/panda-utilities/src/main/java/org/panda_lang/utilities/commons/function/PandaStream.java index dc4b081cf..0a07bc3a6 100644 --- a/panda-utilities/src/main/java/org/panda_lang/utilities/commons/function/PandaStream.java +++ b/panda-utilities/src/main/java/org/panda_lang/utilities/commons/function/PandaStream.java @@ -33,8 +33,6 @@ public class PandaStream { - private static final PandaStream EMPTY = new PandaStream<>(Stream.empty()); - private Stream stream; private PandaStream(Stream stream) { @@ -162,9 +160,8 @@ public static PandaStream of(T... array) { return of(Arrays.stream(array)); } - @SuppressWarnings("unchecked") public static PandaStream empty() { - return (PandaStream) EMPTY; + return new PandaStream<>(Stream.empty()); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/std/StdLoader.java b/panda/src/main/java/org/panda_lang/panda/language/std/StdLoader.java index 272ad7b7b..2b4343d2d 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/std/StdLoader.java +++ b/panda/src/main/java/org/panda_lang/panda/language/std/StdLoader.java @@ -24,6 +24,7 @@ import org.panda_lang.framework.architecture.type.generator.TypeGenerator; import org.panda_lang.framework.resource.Mappings; import org.panda_lang.framework.resource.Mappings.CustomInitializer; +import org.panda_lang.panda.PandaConstants; import org.panda_lang.utilities.commons.ClassUtils; import org.panda_lang.utilities.commons.StringUtils; @@ -45,7 +46,7 @@ private void loadClass(Packages packages, TypeGenerator typeGenerator, TypeLoade Mappings mappingsInfo = mappings.getClass().getAnnotation(Mappings.class); Package packageInfo = packages.getPackage(mappingsInfo.pkg()) - .orElseGet(() -> packages.registerPackage(new Package(mappingsInfo.pkg(), "", "", new File("std")))); + .orElseGet(() -> packages.registerPackage(new Package(mappingsInfo.pkg(), mappingsInfo.author(), PandaConstants.VERSION, new File("mappings")))); Module module = packageInfo.getModuleSource(mappingsInfo.module()) .orElseGet(() -> packageInfo.createModule(mappingsInfo.module())) diff --git a/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaCollectionsModule.java b/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaCollectionsModule.java index 44cd1eeb6..9b2f65e1e 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaCollectionsModule.java +++ b/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaCollectionsModule.java @@ -18,7 +18,7 @@ import org.panda_lang.framework.resource.Mappings; -@Mappings(pkg = "java", module = "collections", commonPackage = "java.util", classes = { +@Mappings(pkg = "java", author = "panda", module = "collections", commonPackage = "java.util", classes = { "Collection", "Comparator", "Deque", diff --git a/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaExtensionModule.java b/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaExtensionModule.java index 34410a598..bf2ea2cfe 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaExtensionModule.java +++ b/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaExtensionModule.java @@ -19,7 +19,7 @@ import org.panda_lang.framework.architecture.packages.Package; import org.panda_lang.framework.resource.Mappings; -@Mappings(pkg = "java", module = Package.DEFAULT_MODULE, commonPackage = "java.lang", classes = { +@Mappings(pkg = "java",author = "panda", module = Package.DEFAULT_MODULE, commonPackage = "java.lang", classes = { "Class", "Exception", "Runtime", diff --git a/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaUtilsModule.java b/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaUtilsModule.java index bd3d207dc..4a450fe63 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaUtilsModule.java +++ b/panda/src/main/java/org/panda_lang/panda/language/std/java/JavaUtilsModule.java @@ -19,7 +19,7 @@ import org.panda_lang.framework.architecture.packages.Package; import org.panda_lang.framework.resource.Mappings; -@Mappings(pkg = "java", module = Package.DEFAULT_MODULE, commonPackage = "java.util", classes = { +@Mappings(pkg = "java", author = "panda", module = Package.DEFAULT_MODULE, commonPackage = "java.util", classes = { "Arrays", "Objects", "Optional", diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/IsExpressionSubparser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/IsExpressionSubparser.java index 7d4a5d495..675c0891a 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/IsExpressionSubparser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/IsExpressionSubparser.java @@ -52,7 +52,7 @@ private static final class IsWorker extends AbstractExpressionSubparserWorker { private final Type boolType; private IsWorker(Context context) { - this.boolType = context.getTypeLoader().requireType("panda@::Bool"); + this.boolType = context.getTypeLoader().requireType("panda/panda@::Bool"); } @Override diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/LiteralExpressionSubparser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/LiteralExpressionSubparser.java index d137e9d40..bdc3dea2b 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/LiteralExpressionSubparser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/LiteralExpressionSubparser.java @@ -54,7 +54,7 @@ private static final class SequenceWorker extends AbstractExpressionSubparserWor private final Signature boolType; public SequenceWorker(Context context) { - this.boolType = context.getTypeLoader().requireType("panda@::Bool").getSignature(); + this.boolType = context.getTypeLoader().requireType("panda/panda@::Bool").getSignature(); } @Override diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/NegateLogicalExpression.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/NegateLogicalExpression.java index 31b4c9922..cede6d764 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/NegateLogicalExpression.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/NegateLogicalExpression.java @@ -28,7 +28,7 @@ final class NegateLogicalExpression implements DynamicExpression { private final Expression logicalExpression; public NegateLogicalExpression(Expression logicalExpression) { - if (!logicalExpression.getKnownType().is("panda@::Bool")) { + if (!logicalExpression.getKnownType().is("panda/panda@::Bool")) { throw new InvalidParameterException("Cannot reverse non logical value"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/SequenceExpressionSubparser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/SequenceExpressionSubparser.java index 548d95ba6..63f4f464f 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/SequenceExpressionSubparser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/SequenceExpressionSubparser.java @@ -44,7 +44,7 @@ private static final class SequenceWorker extends AbstractExpressionSubparserWor private final Type stringType; private SequenceWorker(Context context) { - this.stringType = context.getTypeLoader().requireType("panda@::String"); + this.stringType = context.getTypeLoader().requireType("panda/panda@::String"); } @Override diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NegativeExpressionSubparser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NegativeExpressionSubparser.java index 9a2d8c418..09e2eed7e 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NegativeExpressionSubparser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NegativeExpressionSubparser.java @@ -67,7 +67,7 @@ private static final class NegateWorker extends AbstractExpressionSubparserWorke Expression expression = context.getParser().parse(context.toContext(), context.getSynchronizedSource(), SETTINGS); - if (!context.toContext().getTypeLoader().requireType("panda@::Number").isAssignableFrom(expression.getKnownType())) { + if (!context.toContext().getTypeLoader().requireType("panda/panda@::Number").isAssignableFrom(expression.getKnownType())) { throw new InvalidParameterException("Cannot reverse non logical value"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NotBitwiseExpressionSubparser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NotBitwiseExpressionSubparser.java index 2d1b7ce1c..6ef21a5ba 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NotBitwiseExpressionSubparser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NotBitwiseExpressionSubparser.java @@ -67,7 +67,7 @@ private static final class NegateWorker extends AbstractExpressionSubparserWorke Expression expression = context.getParser().parse(context.toContext(), context.getSynchronizedSource(), SETTINGS); - if (!context.toContext().getTypeLoader().requireType("panda@::Number").isAssignableFrom(expression.getKnownType())) { + if (!context.toContext().getTypeLoader().requireType("panda/panda@::Number").isAssignableFrom(expression.getKnownType())) { throw new InvalidParameterException("Cannot reverse non logical value"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberParser.java index b7b4479bf..e1f9209b7 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberParser.java @@ -77,17 +77,17 @@ else if (number.length() < 16) { switch (numberType) { case BYTE: - return new PandaExpression(loader.requireType("panda@::Byte").getSignature(), Byte.parseByte(number, radix)); + return new PandaExpression(loader.requireType("panda/panda@::Byte").getSignature(), Byte.parseByte(number, radix)); case SHORT: - return new PandaExpression(loader.requireType("panda@::Short").getSignature(), Short.parseShort(number, radix)); + return new PandaExpression(loader.requireType("panda/panda@::Short").getSignature(), Short.parseShort(number, radix)); case INT: - return new PandaExpression(loader.requireType("panda@::Int").getSignature(), Integer.parseInt(number, radix)); + return new PandaExpression(loader.requireType("panda/panda@::Int").getSignature(), Integer.parseInt(number, radix)); case LONG: - return new PandaExpression(loader.requireType("panda@::Long").getSignature(), Long.parseLong(number, radix)); + return new PandaExpression(loader.requireType("panda/panda@::Long").getSignature(), Long.parseLong(number, radix)); case FLOAT: - return new PandaExpression(loader.requireType("panda@::Float").getSignature(), Float.parseFloat(number)); + return new PandaExpression(loader.requireType("panda/panda@::Float").getSignature(), Float.parseFloat(number)); case DOUBLE: - return new PandaExpression(loader.requireType("panda@::Double").getSignature(), Double.parseDouble(number)); + return new PandaExpression(loader.requireType("panda/panda@::Double").getSignature(), Double.parseDouble(number)); default: throw new PandaParserException("Unknown number type: " + numberType); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberPriorities.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberPriorities.java index 263a0c10a..bbd9effaf 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberPriorities.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/NumberPriorities.java @@ -33,12 +33,12 @@ public class NumberPriorities { public static final int DOUBLE = 60; private static final Map HIERARCHY = Maps.of( - "panda@::Byte", BYTE, - "panda@::Short", SHORT, - "panda@::Int", INT, - "panda@::Long", LONG, - "panda@::Float", FLOAT, - "panda@::Double", DOUBLE + "panda/panda@::Byte", BYTE, + "panda/panda@::Short", SHORT, + "panda/panda@::Int", INT, + "panda/panda@::Long", LONG, + "panda/panda@::Float", FLOAT, + "panda/panda@::Double", DOUBLE ); public static int getHigherPriority(Type a, Type b) { diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/PandaNumbers.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/PandaNumbers.java index 24b4a3331..24abb2871 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/PandaNumbers.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/number/PandaNumbers.java @@ -18,16 +18,16 @@ public final class PandaNumbers { - public static final String BYTE = "panda@::Byte"; + public static final String BYTE = "panda/panda@::Byte"; - public static final String INT = "panda@::Int"; + public static final String INT = "panda/panda@::Int"; - public static final String SHORT = "panda@::Short"; + public static final String SHORT = "panda/panda@::Short"; - public static final String LONG = "panda@::Long"; + public static final String LONG = "panda/panda@::Long"; - public static final String FLOAT = "panda@::Float"; + public static final String FLOAT = "panda/panda@::Float"; - public static final String DOUBLE = "panda@::Double"; + public static final String DOUBLE = "panda/panda@::Double"; } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/OperationUtils.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/OperationUtils.java index 442ab1a2e..e351f112b 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/OperationUtils.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/OperationUtils.java @@ -38,7 +38,7 @@ static boolean isNumeric(Operation operation) { return verify(operation, null, element -> { if (element.isExpression()) { Type expressionType = element.getExpression().getKnownType(); - return expressionType.getTypeLoader().get().requireType("panda@::Number").isAssignableFrom(expressionType); + return expressionType.getTypeLoader().get().requireType("panda/panda@::Number").isAssignableFrom(expressionType); } Operator operator = ObjectUtils.cast(Operator.class, element.getOperatorRepresentation().getToken()); @@ -60,7 +60,7 @@ static boolean isConcatenation(Operation operation) { operator = Operators.ADDITION.equals(element.getOperator()); } else if (!string && element.isExpression()) { - string = element.getExpression().getKnownType().is("panda@::String"); + string = element.getExpression().getKnownType().is("panda/panda@::String"); } if (operator && string) { diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/ConcatenationOperatorSubparser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/ConcatenationOperatorSubparser.java index c7f816575..87aac616d 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/ConcatenationOperatorSubparser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/ConcatenationOperatorSubparser.java @@ -53,7 +53,7 @@ public final class ConcatenationOperatorSubparser implements OperationSubparser return null; } - Type stringType = context.getTypeLoader().requireType("panda@::String"); + Type stringType = context.getTypeLoader().requireType("panda/panda@::String"); return new ConcatenationExpressionCallback(stringType, values).toExpression(); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/bitwise/BitwiseOperation.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/bitwise/BitwiseOperation.java index 3a62a0607..036930cd7 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/bitwise/BitwiseOperation.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/bitwise/BitwiseOperation.java @@ -39,7 +39,7 @@ public Type returnType(TypeLoader typeLoader, Type a, Type b) { @Override public Type requiredType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Number"); + return typeLoader.requireType("panda/panda@::Number"); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperator.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperator.java index 7ba524de7..487d1e196 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperator.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperator.java @@ -33,12 +33,12 @@ public RPNOperationAction of(TypeLoader typeLoader, Expression a, Expre @Override public Type returnType(TypeLoader typeLoader, Type a, Type b) { - return typeLoader.requireType("panda@::Bool"); + return typeLoader.requireType("panda/panda@::Bool"); } @Override public Type requiredType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Number"); + return typeLoader.requireType("panda/panda@::Number"); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperatorAction.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperatorAction.java index bfaf77a7b..e6e7ea7b6 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperatorAction.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/ComparisonOperatorAction.java @@ -29,7 +29,7 @@ protected ComparisonOperatorAction(Expression a, Expression b) { @Override public Signature returnType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Bool").getSignature(); + return typeLoader.requireType("panda/panda@::Bool").getSignature(); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/EqualsToOperation.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/EqualsToOperation.java index ab1023a90..ef2df6b93 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/EqualsToOperation.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/EqualsToOperation.java @@ -34,7 +34,7 @@ public class EqualsToOperation extends RPNSimplifiedSupplier of(TypeLoader moduleLoader, Expression a, Expression b) { - Type numberType = moduleLoader.requireType("panda@::Number"); + Type numberType = moduleLoader.requireType("panda/panda@::Number"); if (numberType.isAssignableFrom(a.getKnownType()) && numberType.isAssignableFrom(b.getKnownType())) { int priority = NumericOperation.getHigherPriority(a.getKnownType(), b.getKnownType()); @@ -77,12 +77,12 @@ private BiFunction toFunction(int priority) { @Override public Type returnType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Bool"); + return typeLoader.requireType("panda/panda@::Bool"); } @Override public Type requiredType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Object"); + return typeLoader.requireType("panda/panda@::Object"); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/OrOperation.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/OrOperation.java index 19a494e15..8401b5415 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/OrOperation.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/logical/OrOperation.java @@ -54,7 +54,7 @@ public Type returnType(TypeLoader typeLoader, Type a, Type b) { @Override public Type requiredType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Bool"); + return typeLoader.requireType("panda/panda@::Bool"); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/math/MathOperation.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/math/MathOperation.java index 9fa68173d..ba2dba2a1 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/math/MathOperation.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/expressions/subparsers/operation/subparsers/math/MathOperation.java @@ -39,7 +39,7 @@ public Type returnType(TypeLoader typeLoader, Type a, Type b) { @Override public Type requiredType(TypeLoader typeLoader) { - return typeLoader.requireType("panda@::Number"); + return typeLoader.requireType("panda/panda@::Number"); } } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/head/RequireParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/head/RequireParser.java index e0354a860..3b4292699 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/head/RequireParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/head/RequireParser.java @@ -16,6 +16,7 @@ package org.panda_lang.panda.language.syntax.head; +import org.panda_lang.framework.architecture.module.Imports; import org.panda_lang.framework.architecture.packages.Package; import org.panda_lang.framework.architecture.packages.Packages; import org.panda_lang.framework.interpreter.parser.Component; @@ -23,7 +24,7 @@ import org.panda_lang.framework.interpreter.parser.ContextParser; import org.panda_lang.framework.interpreter.parser.PandaParserFailure; import org.panda_lang.framework.interpreter.parser.pool.Targets; -import org.panda_lang.framework.interpreter.token.Snippet; +import org.panda_lang.framework.interpreter.source.SourceService; import org.panda_lang.framework.interpreter.token.TokenInfo; import org.panda_lang.framework.resource.syntax.TokenTypes; import org.panda_lang.framework.resource.syntax.keyword.Keywords; @@ -65,17 +66,19 @@ public Option> parse(Context context) { throw new PandaParserFailure(context, packageName, "Cannot find package '" + packageName.getValue() + "'"); }); - Option detailed = sourceReader.optionalRead(sourceReader::readBody) - .map(body -> Arrays.stream(body.split(Separators.COMMA))) - .map(stream -> stream.toArray(Snippet[]::new)); + SourceService sources = context.getEnvironment().getSources(); + Imports imports = context.getImports(); - for (Snippet qualifier : detailed.get()) { - requiredPackage.forModule(context.getEnvironment().getSources(), qualifier.asSource().replace("base", "")) - .peek(module -> context.getImports().importModule(module)) - .orThrow(() -> { - throw new PandaParserFailure(context, qualifier, "Cannot find module '" + qualifier.asSource() + "' in package '" + packageName.getValue() + "'"); - }); - } + sourceReader.optionalRead(sourceReader::readBody) + .onEmpty(() -> imports.importModule(requiredPackage.forMainModule(sources))) + .toStream(body -> Arrays.stream(body.split(Separators.COMMA))) + .forEach(qualifier -> { + requiredPackage.forModule(sources, qualifier.asSource().replace("base", "")) + .peek(imports::importModule) + .orThrow(() -> { + throw new PandaParserFailure(context, qualifier, "Cannot find module '" + qualifier.asSource() + "' in package '" + packageName.getValue() + "'"); + }); + }); return Option.ofCompleted(true); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/TryCatchParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/TryCatchParser.java index 94e6aa45c..5715a5dc4 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/TryCatchParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/TryCatchParser.java @@ -82,7 +82,7 @@ public Option> parse(Context context) { Variable variable = catchBlock.createVariable(variableData); SCOPE_PARSER.parse(context, catchBlock, catchBody.get()); - if (context.getTypeLoader().requireType("java@::Throwable").isAssignableFrom(variableData.getKnownType())) { + if (context.getTypeLoader().requireType("panda/java@::Throwable").isAssignableFrom(variableData.getKnownType())) { //noinspection unchecked tryCatch.addHandler((Class) variable.getKnownType().getType().getAssociated().get(), variable, catchBlock); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalBlock.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalBlock.java index d89ed2621..9076dcb04 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalBlock.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalBlock.java @@ -35,7 +35,7 @@ final class ConditionalBlock extends AbstractBlock implements ControlledScope { public ConditionalBlock(Scope parent, Localizable localizable, Expression condition) { super(parent, localizable); - if (!condition.getKnownType().is("panda@::Bool")) { + if (!condition.getKnownType().is("panda/panda@::Bool")) { throw new PandaParserException("Condition has to return boolean"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalParser.java index 96387972f..da1955b42 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/conditional/ConditionalParser.java @@ -42,7 +42,7 @@ Option parse(ScopeParser scopeParser, Context context, bool Expression condition = hasExpression ? context.getExpressionParser().parse(context, context.getStream()) - : new PandaExpression(context.getTypeLoader().requireType("panda@::Bool").getSignature(), true); + : new PandaExpression(context.getTypeLoader().requireType("panda/panda@::Bool").getSignature(), true); Option body = sourceReader.readBody(); diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForEachParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForEachParser.java index 046a17705..4f5765d01 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForEachParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForEachParser.java @@ -62,7 +62,7 @@ public Option> parse(Context context) { Expression iterableExpression = context.getExpressionParser().parse(context, elements[1]); - if (!context.getTypeLoader().requireType("panda@::Iterable").isAssignableFrom(iterableExpression.getKnownType())) { + if (!context.getTypeLoader().requireType("panda/panda@::Iterable").isAssignableFrom(iterableExpression.getKnownType())) { throw new PandaParserException("ForEach requires Iterable value"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForParser.java index 1900dbf69..1f53802a2 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/ForParser.java @@ -41,7 +41,7 @@ public String name() { @Override public void initialize(Context context) { - this.defaultCondition = new PandaExpression(context.getTypeLoader().requireType("panda@::Bool").getSignature(), true); + this.defaultCondition = new PandaExpression(context.getTypeLoader().requireType("panda/panda@::Bool").getSignature(), true); super.initialize(context); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/LoopParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/LoopParser.java index b74c74570..198e082e8 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/LoopParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/LoopParser.java @@ -50,7 +50,7 @@ public Option> parse(Context context) { Expression loopExpression = context.getExpressionParser().parse(context, context.getStream()); - if (!loopExpression.getKnownType().is("panda@::Int")) { + if (!loopExpression.getKnownType().is("panda/panda@::Int")) { throw new PandaParserException("Loop requires number as an argument"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/WhileParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/WhileParser.java index d238b5ea5..2e67a7b4c 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/WhileParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/scope/block/looping/WhileParser.java @@ -50,7 +50,7 @@ public Option> parse(Context context) { Expression whileCondition = context.getExpressionParser().parse(context, context.getStream()); - if (!whileCondition.getKnownType().is("panda@::Bool")) { + if (!whileCondition.getKnownType().is("panda/panda@::Bool")) { throw new PandaParserFailure(context, context.getSource(), "Loop requires boolean as an argument"); } diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/type/ConstructorParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/type/ConstructorParser.java index 2b19cd9bf..d621a6db5 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/type/ConstructorParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/type/ConstructorParser.java @@ -105,7 +105,7 @@ public Option> parse(Context { type.getSuperclass() - .filterNot(superclass -> superclass.fetchType().is("panda@::Object")) + .filterNot(superclass -> superclass.fetchType().is("panda/panda@::Object")) .filterNot(superclass -> superclass.fetchType().getConstructors().getConstructor(Collections.emptyList()).isDefined()) .filterNot(superclass -> constructorScope.getBaseCall().isDefined()) .peek(superclass -> { diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/type/MethodParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/type/MethodParser.java index 279406b2a..5f2ef819c 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/type/MethodParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/type/MethodParser.java @@ -75,7 +75,7 @@ public double priority() { @Override public void initialize(Context context) { this.scopeParser = new ScopeParser(context.getPoolService()); - this.voidType = context.getTypeLoader().requireType("panda@::Void"); + this.voidType = context.getTypeLoader().requireType("panda/panda@::Void"); } @Override @@ -164,7 +164,7 @@ public Option> parse(Context cont return; } - if (!context.getTypeLoader().requireType("panda@::Void").isAssignableFrom(method.getReturnType().getKnownType()) && !methodScope.hasEffective(Returnable.class)) { + if (!context.getTypeLoader().requireType("panda/panda@::Void").isAssignableFrom(method.getReturnType().getKnownType()) && !methodScope.hasEffective(Returnable.class)) { if (method.getReturnType().equals(type.getSignature())) { methodScope.addStatement(new StandaloneExpression(context, ThisExpression.of(type.getSignature()))); return; diff --git a/panda/src/main/java/org/panda_lang/panda/language/syntax/type/TypeParser.java b/panda/src/main/java/org/panda_lang/panda/language/syntax/type/TypeParser.java index 060aa8047..a22ad8ec1 100644 --- a/panda/src/main/java/org/panda_lang/panda/language/syntax/type/TypeParser.java +++ b/panda/src/main/java/org/panda_lang/panda/language/syntax/type/TypeParser.java @@ -174,7 +174,7 @@ public Option> parse(Context context) { .collect(Collectors.toList()); if (bases.isEmpty()) { - bases.add(context.getTypeLoader().requireType("panda@::Object").getSignature()); + bases.add(context.getTypeLoader().requireType("panda/panda@::Object").getSignature()); } bases.forEach(base -> type.addBase(base.toTyped())); diff --git a/panda/src/main/java/org/panda_lang/panda/manager/Dependency.java b/panda/src/main/java/org/panda_lang/panda/manager/Dependency.java index adf4d33ce..c5c5fc56d 100644 --- a/panda/src/main/java/org/panda_lang/panda/manager/Dependency.java +++ b/panda/src/main/java/org/panda_lang/panda/manager/Dependency.java @@ -23,16 +23,20 @@ public final class Dependency { + private static final String MASTER = "master"; + private final String type; private final String owner; private final String name; private final String version; + private final String alias; - public Dependency(String type, String owner, String name, String version) { + public Dependency(String type, String owner, String name, String version, String alias) { this.type = type; this.owner = owner; this.name = name; this.version = version; + this.alias = alias; } public static Dependency createDependency(String qualifier) { @@ -43,17 +47,28 @@ public static Dependency createDependency(String qualifier) { String owner = byOwner[0]; String[] byVersion = byOwner[1].split("@"); - String version = byVersion[1]; String name = byVersion[0]; + String alias = name; + String version = byVersion[1]; + + if (version.contains(" as ")) { + String[] byAlias = version.split(" as "); + version = byAlias[0].trim(); + alias = byAlias[1].trim(); + } - return new Dependency(type, owner, name, version); + return new Dependency(type, owner, name, version, alias); } public boolean same(Dependency to) { - return getOwner().equals(to.getOwner()) && getName().equals(to.getName()); + return getAuthor().equals(to.getAuthor()) && getName().equals(to.getName()); } public boolean hasHigherVersion(String anotherVersion) { + if (version.equalsIgnoreCase(MASTER) || anotherVersion.equalsIgnoreCase(MASTER)) { + return true; + } + String[] thisElements = StringUtils.split(version, "."); String[] anotherElements = StringUtils.split(anotherVersion, "."); int length = Math.max(version.length(), anotherElements.length); @@ -95,6 +110,10 @@ public int hashCode() { return Objects.hash(type, owner, name, version); } + public String getIdentifier() { + return getAuthor() + "/" + getName(); + } + public String getVersion() { return version; } @@ -103,7 +122,7 @@ public String getName() { return name; } - public String getOwner() { + public String getAuthor() { return owner; } diff --git a/panda/src/main/java/org/panda_lang/panda/manager/PackageInfo.java b/panda/src/main/java/org/panda_lang/panda/manager/PackageInfo.java index 2eda4b4fa..2c98a9fe1 100644 --- a/panda/src/main/java/org/panda_lang/panda/manager/PackageInfo.java +++ b/panda/src/main/java/org/panda_lang/panda/manager/PackageInfo.java @@ -31,7 +31,7 @@ public final class PackageInfo { } public Dependency toDependency() { - return new Dependency("unknown", document.name, document.author, document.version); + return new Dependency("unknown", document.name, document.author, document.version, document.name); } public List getDependencies() { diff --git a/panda/src/main/java/org/panda_lang/panda/manager/goals/GitHubInstall.java b/panda/src/main/java/org/panda_lang/panda/manager/goals/GitHubInstall.java index 4a293eb67..ddac4cee8 100644 --- a/panda/src/main/java/org/panda_lang/panda/manager/goals/GitHubInstall.java +++ b/panda/src/main/java/org/panda_lang/panda/manager/goals/GitHubInstall.java @@ -45,7 +45,7 @@ public List install(BiConsumer resultCons File packageDirectory = new File(ownerDirectory, dependency.getName()); FileUtils.delete(packageDirectory); - String address = "https://github.com/" + dependency.getOwner() + "/" + dependency.getName() + "/archive/" + dependency.getVersion() + ".zip"; + String address = "https://github.com/" + dependency.getAuthor() + "/" + dependency.getName() + "/archive/" + dependency.getVersion() + ".zip"; BufferedInputStream in = null; try { diff --git a/panda/src/main/java/org/panda_lang/panda/manager/goals/Install.java b/panda/src/main/java/org/panda_lang/panda/manager/goals/Install.java index 4a4456086..82f4eec54 100644 --- a/panda/src/main/java/org/panda_lang/panda/manager/goals/Install.java +++ b/panda/src/main/java/org/panda_lang/panda/manager/goals/Install.java @@ -63,14 +63,14 @@ public void run() throws Exception { continue; } - String name = dependency.getName(); + String identifier = dependency.getIdentifier(); - if (dependencyMap.containsKey(name) && dependencyMap.get(name).hasHigherVersion(dependency.getVersion())) { + if (dependencyMap.containsKey(identifier) && dependencyMap.get(identifier).hasHigherVersion(dependency.getVersion())) { continue; } install(pandaModules, dependency, dependenciesToLoad); - dependencyMap.put(name, dependency); + dependencyMap.put(identifier, dependency); } dependencies.clear(); @@ -87,7 +87,7 @@ public void run() throws Exception { } private void install(File pandaModules, Dependency dependency, Collection dependenciesToLoad) throws Exception { - File ownerDirectory = new File(pandaModules, dependency.getOwner()); + File ownerDirectory = new File(pandaModules, dependency.getAuthor()); ownerDirectory.mkdir(); File packageDirectory = new File(ownerDirectory, dependency.getName()); @@ -115,16 +115,18 @@ private void install(File pandaModules, Dependency dependency, Collection dependenciesMap, File ownerDirectory) { - File[] modules = Objects.requireNonNull(ownerDirectory.listFiles()); + protected void scan(Map dependenciesMap, File authorDirectory) { + File[] packages = Objects.requireNonNull(authorDirectory.listFiles()); - for (File module : modules) { - if (dependenciesMap.containsKey(module.getName())) { + for (File pkg : packages) { + String identifier = authorDirectory.getName() + "/" + pkg.getName(); + + if (dependenciesMap.containsKey(identifier)) { continue; } - FileUtils.delete(module); - log(InstallStatus.REMOVED, dependenciesMap.remove(module.getName())); + FileUtils.delete(pkg); + log(InstallStatus.REMOVED, dependenciesMap.remove(identifier)); } } diff --git a/panda/src/main/java/org/panda_lang/panda/manager/goals/MavenInstall.java b/panda/src/main/java/org/panda_lang/panda/manager/goals/MavenInstall.java index 6895753ef..96526130d 100644 --- a/panda/src/main/java/org/panda_lang/panda/manager/goals/MavenInstall.java +++ b/panda/src/main/java/org/panda_lang/panda/manager/goals/MavenInstall.java @@ -46,7 +46,7 @@ public MavenInstall(PackageManager manager, PackageInfo document, Dependency dep public List install(BiConsumer resultConsumer, File ownerDirectory, File packageInfoFile) throws IOException { List repositories = document.getDocument().repositories; - String gav = dependency.getOwner().replace(".", "/") + String gav = dependency.getAuthor().replace(".", "/") + "/" + dependency.getName() + "/" + dependency.getVersion() + "/" + dependency.getName() + "-" + dependency.getVersion() + ".jar"; diff --git a/panda/src/main/java/org/panda_lang/panda/utils/PandaUtils.java b/panda/src/main/java/org/panda_lang/panda/utils/PandaUtils.java index 09692def7..aae336473 100644 --- a/panda/src/main/java/org/panda_lang/panda/utils/PandaUtils.java +++ b/panda/src/main/java/org/panda_lang/panda/utils/PandaUtils.java @@ -24,7 +24,6 @@ import org.panda_lang.panda.PandaFactory; import org.panda_lang.panda.manager.PackageUtils; import org.panda_lang.utilities.commons.TimeUtils; -import org.panda_lang.utilities.commons.UnsafeUtils; import org.panda_lang.utilities.commons.function.Lazy; import org.panda_lang.utilities.commons.function.Result; @@ -57,8 +56,6 @@ public static Result load(File workingDirectory, File sc * The method should be called as fast as it is possible. */ public static void printJVMUptime(LoggerHolder loggerHolder) { - UnsafeUtils.disableIllegalAccessMessage(); - loggerHolder.getLogger().debug(""); loggerHolder.getLogger().debug("JVM launch time: " + TimeUtils.getJVMUptime() + "ms (。•́︿•̀。)"); loggerHolder.getLogger().debug(""); diff --git a/panda/src/test/groovy/org/panda_lang/panda/language/resource/expression/ExpressionParserTestBootstrap.groovy b/panda/src/test/groovy/org/panda_lang/panda/language/resource/expression/ExpressionParserTestBootstrap.groovy index dce864f15..c4814a8b1 100644 --- a/panda/src/test/groovy/org/panda_lang/panda/language/resource/expression/ExpressionParserTestBootstrap.groovy +++ b/panda/src/test/groovy/org/panda_lang/panda/language/resource/expression/ExpressionParserTestBootstrap.groovy @@ -54,9 +54,9 @@ class ExpressionParserTestBootstrap { protected static Context prepareData() { return PandaContextUtils.createStubContext(PandaUtils.defaultInstance(), context -> new HashMap() {{ - put(new PandaVariableData(context.getTypeLoader().requireType("panda@::String").getSignature(), "variable"), null) - put(new PandaVariableData(context.getTypeLoader().requireType("panda@::String").getSignature(), "array"), null) - put(new PandaVariableData(context.getTypeLoader().requireType("panda@::Int").getSignature(), "i", true, false), null) + put(new PandaVariableData(context.getTypeLoader().requireType("panda/panda@::String").getSignature(), "variable"), null) + put(new PandaVariableData(context.getTypeLoader().requireType("panda/panda@::String").getSignature(), "array"), null) + put(new PandaVariableData(context.getTypeLoader().requireType("panda/panda@::Int").getSignature(), "i", true, false), null) }}).toContext() } diff --git a/panda/src/test/groovy/org/panda_lang/panda/manager/DependencyTest.groovy b/panda/src/test/groovy/org/panda_lang/panda/manager/DependencyTest.groovy index bd561e644..78c751bea 100644 --- a/panda/src/test/groovy/org/panda_lang/panda/manager/DependencyTest.groovy +++ b/panda/src/test/groovy/org/panda_lang/panda/manager/DependencyTest.groovy @@ -48,7 +48,7 @@ final class DependencyTest { @Test void getScope() { - assertEquals "dzikoysk", A.getOwner() + assertEquals "dzikoysk", A.getAuthor() } @Test diff --git a/panda/src/test/groovy/org/panda_lang/panda/manager/PandaModuleDependencyTest.groovy b/panda/src/test/groovy/org/panda_lang/panda/manager/PandaModuleDependencyTest.groovy index cf5ad2ada..02040a3d8 100644 --- a/panda/src/test/groovy/org/panda_lang/panda/manager/PandaModuleDependencyTest.groovy +++ b/panda/src/test/groovy/org/panda_lang/panda/manager/PandaModuleDependencyTest.groovy @@ -17,15 +17,16 @@ package org.panda_lang.panda.manager import groovy.transform.CompileStatic +import org.junit.jupiter.api.Test import org.panda_lang.panda.utils.PandaUtils @CompileStatic final class PandaModuleDependencyTest { - private static final File DIRECTORY = new File("../examples/package_manager/panda-module-dependency") + private static final File DIRECTORY = new File("../examples/package-manager/panda-module-dependency") private static final PackageManager MANAGER = new PackageManager(PandaUtils.defaultInstance(), DIRECTORY) - // @Test + @Test void test() throws Exception { PandaUtils.printJVMUptime(MANAGER) File document = new File(DIRECTORY, "panda.cdn")