Skip to content

Commit

Permalink
feat(#175): fix all qulice suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
volodya-lombrozo committed Oct 26, 2023
1 parent 789285b commit 90aa096
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,13 @@ private static void replace(
* It's not correct, because we need to handle arguments correctly.
*/
private static void replaceArguments(final XmlClass clazz) {
clazz.methods().stream()
clazz.methods()
.stream()
.map(XmlMethod::instructions)
.flatMap(Collection::stream)
.forEach(
instruction -> instruction.replaceArguementsValues(
"org/eolang/jeo/B",
"org/eolang/jeo/A$B"
)
instruction ->
instruction.replaceArguementsValues("org/eolang/jeo/B", "org/eolang/jeo/A$B")
);
}

Expand Down Expand Up @@ -441,11 +440,9 @@ private void handleRootObject(final Node root, final String bytename) {
if (base.getNodeValue().equals("seq")) {
final NodeList instructions = item.getChildNodes();
for (int inst = 0; inst < instructions.getLength(); ++inst) {
new XmlInstruction(instructions.item(inst))
.replaceArguementsValues(
this.decorated.name(),
bytename
);
new XmlInstruction(
instructions.item(inst)
).replaceArguementsValues(this.decorated.name(), bytename);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public final class XmlInstruction {
@SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
private final Node node;

/**
* Constructor.
* @param xml XML node as String.
*/
public XmlInstruction(final String xml) {
this(new XMLDocument(xml).node().getFirstChild());
}
Expand Down Expand Up @@ -96,19 +100,6 @@ public Object[] arguments() {
return XmlInstruction.arguments(this.node);
}

/**
* XML node.
* @return XML node.
* @todo #157:90min Hide internal node representation in XmlInstruction.
* This class should not expose internal node representation.
* We have to consider to add methods or classes in order to avoid
* exposing internal node representation.
*/
@SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
Node node() {
return this.node;
}

@Override
public boolean equals(final Object other) {
final boolean result;
Expand All @@ -133,6 +124,19 @@ public String toString() {
return new XMLDocument(this.node).toString();
}

/**
* XML node.
* @return XML node.
* @todo #157:90min Hide internal node representation in XmlInstruction.
* This class should not expose internal node representation.
* We have to consider to add methods or classes in order to avoid
* exposing internal node representation.
*/
@SuppressWarnings("PMD.AvoidFieldNameMatchingMethodName")
Node node() {
return this.node;
}

/**
* Get opcode arguments.
* @param node Node.
Expand Down
12 changes: 12 additions & 0 deletions src/main/java/org/eolang/jeo/representation/xmir/XmlNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ XmlNode child(final String name) {
throw this.notFound(name);
}

/**
* Get all child nodes.
* @return Child nodes.
*/
Stream<XmlNode> children() {
return this.objects().map(XmlNode::new);
}
Expand All @@ -81,10 +85,18 @@ XmlClass toClass() {
return new XmlClass(this.node);
}

/**
* Retrieve node text content.
* @return Text content.
*/
String text() {
return this.node.getTextContent();
}

/**
* Set node text content.
* @param text Text content.
*/
void withText(final String text) {
this.node.setTextContent(text);
}
Expand Down

0 comments on commit 90aa096

Please sign in to comment.