Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Oct 20, 2024
2 parents c48b98e + b0d14da commit 7e41469
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eolang.jeo.representation.MethodName;
import org.eolang.jeo.representation.PrefixedName;
import org.eolang.jeo.representation.Signature;
import org.xembly.Directive;
import org.xembly.Directives;
Expand Down Expand Up @@ -170,7 +171,7 @@ public DirectivesMethod withAnnotation(final DirectivesAnnotation annotation) {
@Override
public Iterator<Directive> iterator() {
return new DirectivesAbstractObject(
this.name.encoded(),
new PrefixedName(this.name.encoded()).encode(),
Stream.concat(
Stream.of(
this.properties,
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/org/eolang/jeo/representation/xmir/XmlMethod.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.eolang.jeo.representation.MethodName;
import org.eolang.jeo.representation.PrefixedName;
import org.eolang.jeo.representation.Signature;
import org.eolang.jeo.representation.bytecode.BytecodeAnnotations;
import org.eolang.jeo.representation.bytecode.BytecodeMaxs;
Expand Down Expand Up @@ -163,12 +164,16 @@ public BytecodeMethod bytecode() {
*/
private String name() {
return new MethodName(
new Signature(
this.node.attribute("name")
.orElseThrow(
() -> new IllegalStateException("Method 'name' attribute is not present")
)
).name()
new PrefixedName(
new Signature(
this.node.attribute("name")
.orElseThrow(
() -> new IllegalStateException(
"Method 'name' attribute is not present"
)
)
).name()
).decode()
).bytecode();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
*/
package org.eolang.jeo.representation.directives;

import com.jcabi.matchers.XhtmlMatchers;
import org.eolang.jeo.representation.bytecode.BytecodeAnnotation;
import org.eolang.jeo.representation.bytecode.BytecodeAnnotations;
import org.eolang.jeo.representation.bytecode.BytecodeMaxs;
Expand Down Expand Up @@ -94,4 +95,13 @@ void transformsAnnotationsToXmir() throws ImpossibleModificationException {
)
);
}

@Test
void addsPrefixToTheMethodName() throws ImpossibleModificationException {
MatcherAssert.assertThat(
"We expect that 'j$' prefix will be added to the method name",
new Xembler(new BytecodeMethod("φTerm").directives(false)).xml(),
XhtmlMatchers.hasXPaths("./o[contains(@name, 'j$φTerm')]")
);
}
}

0 comments on commit 7e41469

Please sign in to comment.