Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

XSD versioning mechanism added #3586

Merged
merged 9 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions eo-maven-plugin/src/main/java/org/eolang/maven/PhiMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
import org.cactoos.text.TextOf;
import org.eolang.maven.footprint.Saved;
import org.eolang.maven.util.Walk;
import org.eolang.parser.Schema;
import org.eolang.parser.StUnhex;
import org.eolang.parser.TrParsing;

Expand Down Expand Up @@ -156,7 +155,6 @@ private int translate(final Path xmir, final Xsline xsline, final int position,
position, total, xmir, xmir.toFile().length()
);
final XML xml = new XMLDocument(new TextOf(xmir).asString());
new Schema(xml).check();
final Path relative = Paths.get(
this.phiInputDir.toPath().relativize(xmir).toString().replace(
String.format(".%s", AssembleMojo.XMIR),
Expand Down
21 changes: 8 additions & 13 deletions eo-maven-plugin/src/main/java/org/eolang/maven/PrintMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
import org.eolang.maven.util.HmBase;
import org.eolang.maven.util.Home;
import org.eolang.maven.util.Walk;
import org.eolang.parser.Schema;
import org.eolang.parser.xmir.Xmir;
import org.eolang.parser.xmir.XmirReversed;
import org.eolang.parser.xmir.XmirSwap;
import org.eolang.parser.Xmir;

/**
* Print XMIR to EO.
Expand Down Expand Up @@ -101,15 +98,13 @@ void exec() throws IOException {
.replace(".xmir", ".eo")
);
final XML xml = new XMLDocument(new TextOf(source).asString());
new Schema(xml).check();
home.save(
new XmirSwap(
this.printReversed,
new XmirReversed(xml),
new Xmir.Default(xml)
).toEO(),
relative
);
final String program;
if (this.printReversed) {
program = new Xmir(xml).toReversed();
} else {
program = new Xmir(xml).toEO();
}
home.save(program, relative);
Logger.info(
this,
"Printed: %[file]s (%[size]s) => %[file]s (%[size]s)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ public final class OptTrain implements Optimization {
static final Train<Shift> DEFAULT_TRAIN = new TrFast(
new TrLambda(
new TrClasspath<>(
new TrDefault<>(),
"/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/set-locators.xsl",
"/org/eolang/parser/blank-xsd-schema.xsl"
).back(),
StEoLogged::new
),
Expand Down
2 changes: 1 addition & 1 deletion eo-maven-plugin/src/main/resources/log4j.properties
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,5 @@ log4j.logger.org.eolang=INFO
log4j.logger.com.yegor256.xsline=INFO
log4j.logger.org.eolang.parser.EoSyntax=INFO
log4j.logger.org.eolang.parser.Scenario=INFO
log4j.logger.org.eolang.parser.xmir.XmirTest=INFO
log4j.logger.org.eolang.parser.XmirTest=INFO
log4j.logger.org.eolang.maven.SodgMojo=TRACE
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ void shakesSuccessfully(@Mktmp final Path temp) throws IOException {
.execute(new FakeMaven.Shake())
.result();
MatcherAssert.assertThat(
"After successful operation of the ShakeMojo, a xml should appear.",
"After successful operation of the ShakeMojo, an XML should appear",
res,
Matchers.hasKey(
String.format("target/%s/foo/x/main/01-remove-refs.xml", ShakeMojo.STEPS)
)
);
MatcherAssert.assertThat(
"After successful operation of the ShakeMojo, a xmir should appear.",
"After successful operation of the ShakeMojo, an XMIR should appear",
res,
Matchers.hasKey(
String.format(this.key, ShakeMojo.DIR, AssembleMojo.XMIR)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;
Expand Down Expand Up @@ -69,6 +70,11 @@ void convertsSimpleObjectToGraph(@Mktmp final Path temp) throws Exception {
new Farea(temp).together(
f -> {
f.clean();
f.files().file("XMIR.xsd").save(
Paths.get(System.getProperty("user.dir")).resolve(
"../eo-parser/src/main/resources/XMIR.xsd"
)
);
f.files().file("src/main/eo/foo.eo").write(
"# This unit test is supposed to check the functionality of the corresponding object.\n[] > foo\n".getBytes()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ xsls:
- /org/eolang/parser/add-refs.xsl
- /org/eolang/parser/add-default-package.xsl
- /org/eolang/parser/optimize/constant-folding.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //o[@base='org.eolang.bool' and o[@base='org.eolang.bytes' and text()='01-']]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java/text()[contains(., 'new PhWith(ret, 0')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
eo: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), '.take("org").take("eolang").take("true")')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), 'PhMethod(new PhMethod(rho, "ρ"), "ρ")')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), 'new PhLocated(ret, 3, 2, "Φ.foo.φ")')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), 'public final class EOtest$EOblah0$EOblah1$EO89_58 extends PhDefault')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
xsls:
- /org/eolang/maven/pre/classes.xsl
- /org/eolang/maven/pre/package.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //class[@name='bar' and @package='foo.long-name']
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
eo: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), ' @Test')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ xsls:
- /org/eolang/maven/pre/align-test-classes.xsl
- /org/eolang/maven/pre/remove-high-level-inner-classes.xsl
- /org/eolang/maven/pre/rename-tests-inners.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- /program/objects[count(class)=1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), '@Test')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), 'Phi ret = Phi.Φ.take("org").take("eolang").take("tuple");')]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ xsls:
- /org/eolang/maven/pre/attrs.xsl
- /org/eolang/maven/pre/data.xsl
- /org/eolang/maven/pre/to-java.xsl
- /org/eolang/parser/blank-xsd-schema.xsl
tests:
- /program[not(errors)]
- //java[contains(text(), 'public final class EOfoo__underscore extends PhDefault')]
Expand Down
4 changes: 2 additions & 2 deletions eo-parser/src/main/java/org/eolang/parser/BytesToHex.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*
* @since 0.44
*/
public final class BytesToHex implements Supplier<String> {
final class BytesToHex implements Supplier<String> {

/**
* The bytes.
Expand All @@ -43,7 +43,7 @@ public final class BytesToHex implements Supplier<String> {
* Ctor.
* @param bts Bytes
*/
public BytesToHex(final byte[] bts) {
BytesToHex(final byte[] bts) {
this.bytes = Arrays.copyOf(bts, bts.length);
}

Expand Down
15 changes: 10 additions & 5 deletions eo-parser/src/main/java/org/eolang/parser/CheckPack.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.eolang.parser;

import com.jcabi.log.Logger;
import com.jcabi.xml.StrictXML;
import com.jcabi.xml.XML;
import com.yegor256.xsline.Shift;
import com.yegor256.xsline.StClasspath;
Expand Down Expand Up @@ -78,11 +79,15 @@ public Collection<String> failures() throws IOException {
train = train.with(new StClasspath(xsl));
}
}
final XML out = new Xsline(train).pass(
new EoSyntax(
"scenario",
new InputOf(String.format("%s\n", src))
).parsed()
final XML out = new StrictXML(
new Xsline(train).pass(
new StrictXML(
new EoSyntax(
"scenario",
new InputOf(String.format("%s\n", src))
).parsed()
)
)
);
Logger.debug(this, "Output XML:\n%s", out);
final Collection<String> failures = new LinkedList<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,19 @@
*/
package org.eolang.parser;

import java.util.Iterator;
import org.antlr.v4.runtime.ParserRuleContext;
import org.antlr.v4.runtime.misc.Interval;
import org.xembly.Directive;
import org.xembly.Directives;

/**
* Source text of parser context.
*
* @since 0.34.0
*/
public final class SourceText {
final class DrListing implements Iterable<Directive> {

/**
* Context.
*/
Expand All @@ -40,17 +45,22 @@ public final class SourceText {
* Ctor.
* @param ctx Context
*/
public SourceText(final ParserRuleContext ctx) {
DrListing(final ParserRuleContext ctx) {
this.context = ctx;
}

@Override
public String toString() {
return this.context.getStart().getInputStream().getText(
public Iterator<Directive> iterator() {
final String text = this.context.getStart().getInputStream().getText(
new Interval(
this.context.getStart().getStartIndex(),
this.context.getStop().getStopIndex()
)
);
return new Directives()
.xpath("/program")
.strict(1).add("listing")
.set(text)
.iterator();
}
}
Loading
Loading