diff --git "a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" "b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" index 07e2f1d3ce..cd24460b54 100644 --- "a/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" +++ "b/eo-runtime/src/main/java/EOorg/EOeolang/EOcage$EOencaged$EO\317\206.java" @@ -31,7 +31,7 @@ import org.eolang.Attr; import org.eolang.Param; import org.eolang.PhDefault; -import org.eolang.PhTracing; +import org.eolang.PhTraced; import org.eolang.Phi; import org.eolang.Versionized; import org.eolang.XmirObject; @@ -57,7 +57,7 @@ public Phi lambda() throws Exception { final int locator = Math.toIntExact( new Param(this.take(Attr.RHO), "locator").strong(Long.class) ); - return new PhTracing( + return new PhTraced( Cages.INSTANCE.get(locator), locator ); diff --git a/eo-runtime/src/main/java/org/eolang/PhTracing.java b/eo-runtime/src/main/java/org/eolang/PhTraced.java similarity index 83% rename from eo-runtime/src/main/java/org/eolang/PhTracing.java rename to eo-runtime/src/main/java/org/eolang/PhTraced.java index 0a2187a7b6..e8d59f70af 100644 --- a/eo-runtime/src/main/java/org/eolang/PhTracing.java +++ b/eo-runtime/src/main/java/org/eolang/PhTraced.java @@ -35,7 +35,7 @@ * @since 0.36 */ @Versionized -public final class PhTracing implements Phi { +public final class PhTraced implements Phi { /** * Name of property that responsible for keeping max depth. @@ -70,12 +70,12 @@ public final class PhTracing implements Phi { * @param object Encaged object * @param locator Locator of encaged object */ - public PhTracing(final Phi object, final Integer locator) { + public PhTraced(final Phi object, final Integer locator) { this( object, locator, Integer.parseInt( - System.getProperty(PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, "100") + System.getProperty(PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, "100") ) ); } @@ -86,7 +86,7 @@ public PhTracing(final Phi object, final Integer locator) { * @param locator Locator of encaged object * @param depth Max depth of cage recursion */ - public PhTracing(final Phi object, final Integer locator, final int depth) { + public PhTraced(final Phi object, final Integer locator, final int depth) { this.object = object; this.locator = locator; this.depth = depth; @@ -94,26 +94,26 @@ public PhTracing(final Phi object, final Integer locator, final int depth) { @Override public Phi copy() { - return new PhTracing(this.object.copy(), this.locator); + return new PhTraced(this.object.copy(), this.locator); } @Override public Phi take(final String name) { - return new PhTracing.TracingWhileGetting<>( + return new PhTraced.TracingWhileGetting<>( () -> this.object.take(name) ).get(); } @Override public boolean put(final int pos, final Phi obj) { - return new PhTracing.TracingWhileGetting<>( + return new PhTraced.TracingWhileGetting<>( () -> this.object.put(pos, obj) ).get(); } @Override public boolean put(final String name, final Phi obj) { - return new PhTracing.TracingWhileGetting<>( + return new PhTraced.TracingWhileGetting<>( () -> this.object.put(name, obj) ).get(); } @@ -183,19 +183,19 @@ public T get() { } /** - * Increments counter of cage in the {@link PhTracing#DATAIZING_CAGES}. + * Increments counter of cage in the {@link PhTraced#DATAIZING_CAGES}. * @return New value in the map. */ private Integer incrementCageCounter() { - return PhTracing.DATAIZING_CAGES.get().compute( - PhTracing.this.locator, (key, counter) -> { + return PhTraced.DATAIZING_CAGES.get().compute( + PhTraced.this.locator, (key, counter) -> { final int ret = this.incremented(counter); - if (ret > PhTracing.this.depth) { + if (ret > PhTraced.this.depth) { throw new ExFailure( "The cage %s with locator %d has reached the maximum nesting depth = %d", - PhTracing.this.object, - PhTracing.this.locator, - PhTracing.this.depth + PhTraced.this.object, + PhTraced.this.locator, + PhTraced.this.depth ); } return ret; @@ -221,19 +221,19 @@ private Integer incremented(final Integer number) { } /** - * Decrements counter in the {@link PhTracing#DATAIZING_CAGES}. + * Decrements counter in the {@link PhTraced#DATAIZING_CAGES}. * @param incremented Current value of counter. This argument ensures * temporal coupling with {@link TracingWhileGetting#incrementCageCounter} method. */ private void decrementCageCounter(final int incremented) { final int decremented = incremented - 1; if (decremented == 0) { - PhTracing.DATAIZING_CAGES.get().remove( - PhTracing.this.locator + PhTraced.DATAIZING_CAGES.get().remove( + PhTraced.this.locator ); } else { - PhTracing.DATAIZING_CAGES.get().put( - PhTracing.this.locator, decremented + PhTraced.DATAIZING_CAGES.get().put( + PhTraced.this.locator, decremented ); } } diff --git a/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java b/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java index 11630e321d..9eeaa375a4 100644 --- a/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java +++ b/eo-runtime/src/test/java/EOorg/EOeolang/EOcageTest.java @@ -40,7 +40,7 @@ import org.eolang.PhCopy; import org.eolang.PhDefault; import org.eolang.PhMethod; -import org.eolang.PhTracing; +import org.eolang.PhTraced; import org.eolang.PhWith; import org.eolang.Phi; import org.hamcrest.MatcherAssert; @@ -200,13 +200,13 @@ class RecursionTests { @BeforeEach void setDepth() { System.setProperty( - PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, String.valueOf(MAX_DEPTH) + PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, String.valueOf(MAX_DEPTH) ); } @AfterEach void clearDepth() { - System.clearProperty(PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME); + System.clearProperty(PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME); } @Test @@ -244,7 +244,7 @@ void doesNotThrowIfDataizesConcurrently() { @Test void rewritesItselfToItselfViaDummy() { System.setProperty( - PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, "2" + PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, "2" ); final Phi cage = EOcageTest.encaged( new PhWith(new EOcageTest.Dummy(Phi.Φ), 0, new Data.ToPhi(1L)) @@ -282,8 +282,8 @@ void doesNotThrowExceptionIfSmallDepth() { () -> new Dataized(cage).take(), String.format( "We expect that dataizing of nested cage which recursion depth is less than property %s = %s does not throw %s", - PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, - System.getProperty(PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), + PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, + System.getProperty(PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), ExAbstract.class ) ); @@ -303,8 +303,8 @@ void doesNotThrowExceptionIfMaxDepth() { () -> new Dataized(cage).take(), String.format( "We expect that dataizing of nested cage which recursion depth is equal to property %s = %s does not throw %s", - PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, - System.getProperty(PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), + PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, + System.getProperty(PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), ExAbstract.class ) ); @@ -322,8 +322,8 @@ void throwsExceptionIfBigDepth() { () -> new Dataized(cage).take(), String.format( "We expect that dataizing of nested cage which recursion depth is more than property %s = %s does not throw %s", - PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, - System.getProperty(PhTracing.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), + PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME, + System.getProperty(PhTraced.MAX_CAGE_RECURSION_DEPTH_PROPERTY_NAME), ExAbstract.class ) );