Skip to content

Commit

Permalink
objectionary#2649 rename addRust, add documentation, create todo
Browse files Browse the repository at this point in the history
  • Loading branch information
c71n93 committed Dec 4, 2023
1 parent 98c0d20 commit 1595ba1
Showing 1 changed file with 14 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,9 @@ public final class BinarizeParseMojo extends SafeMojo {
public static final Path DIR = Paths.get("binarize");

/**
* Parsing train with XSLs.
* Parsing train with XSLs. The task of XSLs is to find all the FFI inserts and put them at
* the end of the xmir file. When adding a new language for FFI inserts, you need to add the
* appropriate XSL transformation.
*/
static final Train<Shift> TRAIN = new TrBulk<>(
new TrClasspath<>(
Expand Down Expand Up @@ -122,11 +124,11 @@ public void exec() throws IOException {
}

/**
* Creates a "rust" section in xml file and returns the resulting XML.
* Creates sections for each language for FFI insert in xmir and returns the resulting XML file.
* @param input The .xmir file
* @return The content of rust section
* @return The content of FFI inserts sections
*/
private XML addRust(
private XML addFFIs(
final XML input
) {
final String name = input.xpath("/program/@name").get(0);
Expand All @@ -142,14 +144,17 @@ private XML addRust(
* Add ffi node via xsl transformation and return list of them.
* @param input Input xmir.
* @return FFI nodes.
* @todo #2609:90min We can make the current class more generic
* by transferring this.addRust(input) snippet to corresponding
* FFINode- {@link RustNode}. We wanna make the class independent of
* ffi-insert as a result.
* @todo #2649:90min This method may be more general. We need to get rid from rust dependencies
* in this method, because when adding another type of inserts it will be just copy-paste here.
* First of all, the for-loop must create all kinds of FFI nodes, not only {@link RustNode}. I
* think we can implement it, using something like {@code FFINodeBuilder}, that will return
* appropriate FFI node for every XML node from {@code nodes}. Also it will be great to move
* paths to XML FFI insert nodes (such as {@code "/program/rusts/rust"}) from this method to
* a class field.
* @checkstyle AbbreviationAsWordInNameCheck (8 lines)
*/
private Collection<FFINode> getFFIs(final XML input) {
final List<XML> nodes = this.addRust(input).nodes("/program/rusts/rust");
final List<XML> nodes = this.addFFIs(input).nodes("/program/rusts/rust");
final Collection<FFINode> ret = new ArrayList<>(nodes.size());
for (final XML node : nodes) {
ret.add(
Expand Down

0 comments on commit 1595ba1

Please sign in to comment.