From 7e88ff229e4634f70f214e0900d9899ac956bf2c Mon Sep 17 00:00:00 2001 From: aget Date: Tue, 24 Dec 2024 19:29:16 +0300 Subject: [PATCH] remove redundant optimization package --- .../org/eolang/maven/optimization/OptSpy.java | 73 ---------- .../eolang/maven/optimization/OptTrain.java | 129 ------------------ .../maven/optimization/Optimization.java | 36 ----- .../maven/optimization/package-info.java | 32 ----- 4 files changed, 270 deletions(-) delete mode 100644 eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptSpy.java delete mode 100644 eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java delete mode 100644 eo-maven-plugin/src/main/java/org/eolang/maven/optimization/Optimization.java delete mode 100644 eo-maven-plugin/src/main/java/org/eolang/maven/optimization/package-info.java diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptSpy.java b/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptSpy.java deleted file mode 100644 index ca6999a621..0000000000 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptSpy.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2024 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.eolang.maven.optimization; - -import com.jcabi.log.Logger; -import com.jcabi.xml.XML; -import com.yegor256.xsline.Shift; -import com.yegor256.xsline.Train; -import java.nio.file.Path; -import org.eolang.maven.Place; -import org.eolang.maven.SpyTrain; - -/** - * Optimization that spies. - * @since 0.28.12 - */ -public final class OptSpy implements Optimization { - /** - * Optimizations train. - */ - private final Train train; - - /** - * Where to track optimization steps. - */ - private final Path target; - - /** - * Ctor. - * @param target Where to track optimization steps. - */ - public OptSpy(final Path target) { - this(OptTrain.DEFAULT_TRAIN, target); - } - - /** - * The main constructor. - * @param trn Optimizations train. - * @param target Where to track optimization steps. - */ - public OptSpy(final Train trn, final Path target) { - this.train = trn; - this.target = target; - } - - @Override - public XML apply(final XML xml) { - final Path dir = new Place(xml.xpath("/program/@name").get(0)).make(this.target, ""); - Logger.debug(this, "Optimization steps will be tracked to %[file]s", dir); - return new OptTrain(new SpyTrain(this.train, dir)).apply(xml); - } -} diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java b/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java deleted file mode 100644 index 91493c413c..0000000000 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/OptTrain.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2024 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.eolang.maven.optimization; - -import com.jcabi.xml.XML; -import com.yegor256.xsline.Shift; -import com.yegor256.xsline.StClasspath; -import com.yegor256.xsline.TrClasspath; -import com.yegor256.xsline.TrDefault; -import com.yegor256.xsline.TrFast; -import com.yegor256.xsline.TrLambda; -import com.yegor256.xsline.Train; -import com.yegor256.xsline.Xsline; -import org.eolang.parser.StEoLogged; - -/** - * Optimisation train of XLS`s. - * @since 0.28.12 - * @todo #3115:30min Return constant-folding.xsl when it's ready. This optimization was removed from - * the train because it's not really ready and works only with `bool` object which was removed. We - * need to make this optimization great again and add to the train. - */ -public final class OptTrain implements Optimization { - - /** - * Parsing train with XSLs. - * - * @implNote The list of applied XSLs is adjusted during execution. - *
Separate instance of the train is used of each optimization - * thread since {@link com.jcabi.xml.XSLDocument}, which is used under - * the hood in {@link TrClasspath}, is not thread-safe. - */ - static final Train DEFAULT_TRAIN = new TrFast( - new TrLambda( - new TrClasspath<>( - "/org/eolang/parser/optimize/globals-to-abstracts.xsl", - "/org/eolang/parser/optimize/remove-refs.xsl", - "/org/eolang/parser/optimize/abstracts-float-up.xsl", - "/org/eolang/parser/optimize/remove-levels.xsl", - "/org/eolang/parser/add-refs.xsl", - "/org/eolang/parser/optimize/fix-missed-names.xsl", - "/org/eolang/parser/add-refs.xsl", - "/org/eolang/parser/set-locators.xsl", - "/org/eolang/parser/blank-xsd-schema.xsl" - ).back(), - StEoLogged::new - ), - TrFast.class, - 500L - ); - - /** - * Delegate. - */ - private final Optimization delegate; - - /** - * Shifts that we are going to apply. - */ - private final Train shifts; - - /** - * The default constructor with the default preset of xsl optimizations. - */ - public OptTrain() { - this(OptTrain.DEFAULT_TRAIN); - } - - /** - * Constructor that accepts train of shifts. - * - * @param shifts XLS shifts. - */ - public OptTrain(final Train shifts) { - this(xml -> xml, shifts); - } - - /** - * Constructor for single {@link StClasspath} optimization. - * - * @param delegate Optimizations that have to be done before. - * @param xls File from classpath. - */ - public OptTrain(final Optimization delegate, final String xls) { - this( - delegate, - new TrDefault().with(new StClasspath(xls)) - ); - } - - /** - * The default constructor. - * @param delegate Optimizations that have to be done before. - * @param shifts To apply - */ - public OptTrain( - final Optimization delegate, - final Train shifts - ) { - this.delegate = delegate; - this.shifts = shifts; - } - - @Override - public XML apply(final XML xml) { - return new Xsline(this.shifts).pass(this.delegate.apply(xml)); - } -} diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/Optimization.java b/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/Optimization.java deleted file mode 100644 index 78efed87ba..0000000000 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/Optimization.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2024 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -package org.eolang.maven.optimization; - -import com.jcabi.xml.XML; -import java.util.function.Function; - -/** - * Abstraction for XML optimizations. - * - * @since 0.28.11 - */ -@FunctionalInterface -public interface Optimization extends Function { -} diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/package-info.java b/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/package-info.java deleted file mode 100644 index 65a3637239..0000000000 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/optimization/package-info.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * The MIT License (MIT) - * - * Copyright (c) 2016-2024 Objectionary.com - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ -/** - * Optimizations package. - * The main purpose of classes under the package is to provide different implementations - * of xml optimizations: - * - {@link org.eolang.maven.optimization.OptCached} - looks for optimization in cache first - * - {@link org.eolang.maven.optimization.OptSpy} - makes XLS optimizations that are tracked - * - {@link org.eolang.maven.optimization.OptTrain} - makes XLS optimizations directly - */ -package org.eolang.maven.optimization;