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

feat(#2119): rename synthetic-reference.xsl -> scopes.xsl #2244

Closed
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
14 changes: 14 additions & 0 deletions .github/workflows/daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,26 @@ on:
schedule:
# Run load testing at 01:30 UTC every day
- cron: '30 1 * * *'
pull_request:
branches:
- master
paths-ignore: [ 'paper/**', 'sandbox/**' ]
jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ runner.os }}-jdk-${{ matrix.java }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-jdk-${{ matrix.java }}-maven-
- run: |
# Clean the test classes to avoid caching issues and prepare testing environment
# without running the tests
mvn clean install -Pqulice -DskipTests -DskipITs -Dinvoker.skip=true
# Find script
SCRIPT="${GITHUB_WORKSPACE}/src/test/scripts/test-repetition.sh"
# Check that script is exists
if [ ! -f "${SCRIPT}" ]; then
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The aim of this test is to check that entire pipeline with
# synthetic-referenses.xsl transformation works as expected without creating
# any warnings or errors.
# Pay attention to synthetic-references.xsl and to-java.xsl transformations.
# Pay attention to scopes.xsl and to-java.xsl transformations.
xsls:
- /org/eolang/parser/errors/not-empty-atoms.xsl
- /org/eolang/parser/critical-errors/duplicate-names.xsl
Expand All @@ -25,7 +25,7 @@ xsls:
- /org/eolang/parser/warnings/incorrect-version.xsl
- /org/eolang/parser/expand-aliases.xsl
- /org/eolang/parser/resolve-aliases.xsl
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
- /org/eolang/parser/add-default-package.xsl
- /org/eolang/parser/errors/broken-refs.xsl
- /org/eolang/parser/errors/unknown-names.xsl
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The aim of this test is to check that entire pipeline with
# synthetic-referenses.xsl transformation works as expected without creating
# any warnings or errors.
# Pay attention to synthetic-references.xsl and to-java.xsl transformations.
# Pay attention to scopes.xsl and to-java.xsl transformations.
xsls:
- /org/eolang/parser/errors/not-empty-atoms.xsl
- /org/eolang/parser/critical-errors/duplicate-names.xsl
Expand All @@ -25,7 +25,7 @@ xsls:
- /org/eolang/parser/warnings/incorrect-version.xsl
- /org/eolang/parser/expand-aliases.xsl
- /org/eolang/parser/resolve-aliases.xsl
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
- /org/eolang/parser/add-default-package.xsl
- /org/eolang/parser/errors/broken-refs.xsl
- /org/eolang/parser/errors/unknown-names.xsl
Expand Down
23 changes: 11 additions & 12 deletions eo-parser/src/main/java/org/eolang/parser/Objects.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,15 @@ interface Objects extends Iterable<Directive> {
void leave();

/**
* Mark next object for aliasing.
* Mark next object for scoping.
*/
void alias();
void scope();

/**
* Mark current object as last inside the scope.
* Last object that relates to the alias.
* Last object that relates to the scope.
*/
void closeAlias();
void closeScope();

/**
* Xembly object tree.
Expand All @@ -91,16 +91,15 @@ final class ObjXembly implements Objects {
/**
* Generated aliases.
*/
private final Deque<String> aliases = new LinkedList<>();
private final Deque<String> scopes = new LinkedList<>();

@Override
public void start(final int line, final int pos) {
this.dirs.add("o");
this.prop("line", line);
this.prop("pos", pos);
if (!this.aliases.isEmpty()) {
final String alias = String.join("-", this.aliases);
this.prop("alias", alias);
if (!this.scopes.isEmpty()) {
this.prop("scope", String.join("-", this.scopes));
}
}

Expand All @@ -125,8 +124,8 @@ public void leave() {
}

@Override
public void alias() {
this.aliases.push(
public void scope() {
this.scopes.push(
String.format(
"scope-%s",
UUID.randomUUID()
Expand All @@ -135,8 +134,8 @@ public void alias() {
}

@Override
public void closeAlias() {
this.aliases.remove();
public void closeScope() {
this.scopes.remove();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public final class ParsingTrain extends TrEnvelope {
"/org/eolang/parser/warnings/incorrect-version.xsl",
"/org/eolang/parser/expand-aliases.xsl",
"/org/eolang/parser/resolve-aliases.xsl",
"/org/eolang/parser/synthetic-references.xsl",
"/org/eolang/parser/scopes.xsl",
"/org/eolang/parser/add-refs.xsl",
"/org/eolang/parser/add-default-package.xsl",
"/org/eolang/parser/errors/broken-refs.xsl",
Expand Down
4 changes: 2 additions & 2 deletions eo-parser/src/main/java/org/eolang/parser/XeListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,12 +319,12 @@ public void exitMethod(final ProgramParser.MethodContext ctx) {

@Override
public void enterScope(final ProgramParser.ScopeContext ctx) {
this.objects.alias();
this.objects.scope();
}

@Override
public void exitScope(final ProgramParser.ScopeContext ctx) {
this.objects.closeAlias();
this.objects.closeScope();
}

@Override
Expand Down
2 changes: 1 addition & 1 deletion eo-parser/src/main/resources/XMIR.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ SOFTWARE.
</xs:sequence>
<xs:attribute name="line" type="xs:decimal"/>
<xs:attribute name="pos" type="xs:decimal"/>
<xs:attribute name="alias" type="xs:string"/>
<xs:attribute name="scope" type="xs:string"/>
<xs:attribute name="name"/>
<xs:attribute name="base"/>
<xs:attribute name="data"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,22 +22,11 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="synthetic-references" version="2.0">
<!--
Process alias attribute.
@todo #2110:90m Rename synthetic-attributes to synthetic-scopes.
We call all attributes in the transformation as "aliases".
(you can read more about the original issue and why it is named so right
<a href="https://github.com/objectionary/eo/issues/415">here</a>.)
which is quite confusing and conflicts with the concept of aliases as
foreign references. We should rename the transformation to "scopes" or
"synthetic-scopes" and rename the "aliases" attributes in that stylesheet
accordingly.
-->
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="scopes" version="2.0">
<xsl:output encoding="UTF-8" method="xml"/>
<xsl:template match="o[@alias and count(child::o) &gt; 1]">
<xsl:template match="o[@scope and count(child::o) &gt; 1]">
<xsl:element name="o">
<xsl:variable name="curr" select="@alias"/>
<xsl:variable name="curr" select="@scope"/>
<xsl:attribute name="abstract"/>
<xsl:attribute name="name">
<xsl:value-of select="concat('generated-',$curr)"/>
Expand All @@ -52,14 +41,14 @@ SOFTWARE.
<xsl:copy-of select="@*"/>
<xsl:attribute name="name">
<xsl:text>org.eolang.</xsl:text>
<xsl:value-of select="@alias"/>
<xsl:value-of select="@scope"/>
</xsl:attribute>
<xsl:apply-templates select="child::o[contains(@alias, $curr)]"/>
<xsl:apply-templates select="child::o[contains(@scope, $curr)]"/>
</xsl:copy>
<xsl:element name="o">
<xsl:attribute name="base">
<xsl:text>org.eolang.</xsl:text>
<xsl:value-of select="@alias"/>
<xsl:value-of select="@scope"/>
</xsl:attribute>
<xsl:attribute name="name">
<xsl:text>@</xsl:text>
Expand All @@ -70,7 +59,7 @@ SOFTWARE.
<xsl:attribute name="pos">
<xsl:value-of select="@pos"/>
</xsl:attribute>
<xsl:apply-templates select="child::o[not(@alias) or not(contains(@alias, $curr))]"/>
<xsl:apply-templates select="child::o[not(@scope) or not(contains(@scope, $curr))]"/>
</xsl:element>
</xsl:element>
</xsl:template>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xsls:
- /org/eolang/parser/wrap-method-calls.xsl
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
- /org/eolang/parser/optimize/abstracts-float-up.xsl
- /org/eolang/parser/optimize/remove-levels.xsl
tests:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xsls:
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='foo' and count(o)=2]
- //o[@base='bar' and count(o)=2]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xsls:
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='foo' and count(o)=3]
eo: |
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xsls:
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='foo' and count(o)=2]
- //o[@base='bar' and count(o)=2]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xsls:
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='foo' and count(o)=1]
eo: |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# The aim of this test is to check that all synthetic attributes are added
# correctly and further optimization chain works as expected without creating
# any warnings or errors.
# Pay attention to synthetic-references.xsl and add-refs.xsl transformations.
# Pay attention to scopes.xsl and add-refs.xsl transformations.
xsls:
- /org/eolang/parser/errors/not-empty-atoms.xsl
- /org/eolang/parser/critical-errors/duplicate-names.xsl
Expand All @@ -25,7 +25,7 @@ xsls:
- /org/eolang/parser/warnings/incorrect-version.xsl
- /org/eolang/parser/expand-aliases.xsl
- /org/eolang/parser/resolve-aliases.xsl
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
- /org/eolang/parser/add-default-package.xsl
- /org/eolang/parser/errors/broken-refs.xsl
- /org/eolang/parser/errors/unknown-names.xsl
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xsls:
- /org/eolang/parser/wrap-method-calls.xsl
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='.foo' and count(o[@abstract]/o[@base='.bar'])=2]
- //o[@base='.bar' and count(o)=2]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
xsls:
- /org/eolang/parser/wrap-method-calls.xsl
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='.with']/o[@abstract]/o[@base='.with']/o[@abstract]/o[@base='.with']/o[@base='foobar']
- //o[@base='.with']/o[@abstract]/o[@base='.with']/o[@abstract]/o[@base='.with' and count(o)=3]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
xsls:
- /org/eolang/parser/synthetic-references.xsl
- /org/eolang/parser/scopes.xsl
tests:
- //o[@base='foo' and count(o)=2]
eo: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
xsls: []
tests:
- //objects[count(.//o[@scope])=3]
eo: |
[] > aliases
a (b (c d))
Loading