-
Notifications
You must be signed in to change notification settings - Fork 178
bug(#4504): FQN resolution for compact array base #4637
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
Open
h1alexbel
wants to merge
9
commits into
objectionary:master
Choose a base branch
from
h1alexbel:4504
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c694656
bug(#4504): compacts base resolution via XSL
h1alexbel 3147442
Merge branch 'master' into 4504
h1alexbel ce56e1d
bug(#4504): clean for qulice
h1alexbel 06d878a
bug(#4504): copyright, unused tail
h1alexbel a2c2ece
bug(#4504): remove trailing whitespace from compact-array.yaml test f…
h1alexbel 2822684
bug(#4504): remove obsolete XSL transformations for star-related vali…
h1alexbel f654a36
bug(#4504): add alias resolution step for compact oname FQN lookup
h1alexbel d845d29
bug(#4504): change alias selection from part[2] to part[last()] for d…
h1alexbel 1d8a837
bug(#4504): remove @compact prefix and integrate compact resolution i…
h1alexbel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
eo-integration-tests/src/test/resources/org/eolang/snippets/compact-array.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| # yamllint disable rule:line-length | ||
| out: | ||
| - ".*Hello, 上海.*" | ||
| file: program.eo | ||
| args: ["org.eolang.snippets.program", "上海"] | ||
| target: "eoc" | ||
| eo: | | ||
| +alias org.eolang.io.stdout | ||
| +package org.eolang.snippets | ||
|
|
||
| [args] > program | ||
| io.stdout > @ | ||
| tt.sprintf *1 | ||
| "Hello, %s\n" | ||
| args.at 0 |
24 changes: 24 additions & 0 deletions
24
eo-maven-plugin/src/test/resources/org/eolang/maven/transpile-packs/compact-array.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| # yamllint disable rule:line-length | ||
| sheets: | ||
| - /org/eolang/maven/transpile/set-locators.xsl | ||
| - /org/eolang/maven/transpile/set-original-names.xsl | ||
| - /org/eolang/maven/transpile/classes.xsl | ||
| - /org/eolang/maven/transpile/package.xsl | ||
| - /org/eolang/maven/transpile/attrs.xsl | ||
| - /org/eolang/maven/transpile/data.xsl | ||
| - /org/eolang/maven/transpile/to-java.xsl | ||
| asserts: | ||
| - /object[not(errors)] | ||
| - //java[contains(text(), 'base="Φ.org.eolang.tt.sprintf"')] | ||
| input: | | ||
| +alias org.eolang.io.stdout | ||
| +package org.eolang.snippets | ||
|
|
||
| [args] > program | ||
| io.stdout > @ | ||
| tt.sprintf *1 | ||
| "Hello, %s\n" | ||
| args.at 0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
eo-parser/src/main/resources/org/eolang/parser/parse/resolve-compacts.xsl
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,39 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| * SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| * SPDX-License-Identifier: MIT | ||
| --> | ||
| <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" id="resolve-compacts" version="2.0"> | ||
| <!-- | ||
| Here we go through all `@compact:oname` bases and resolve it's FQN: | ||
| 1. If `oname` is defined in the current scope => `oname` | ||
| 2. Otherwise => `Φ.org.eolang.oname` | ||
h1alexbel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| --> | ||
| <xsl:template match="@*|node()"> | ||
| <xsl:copy> | ||
| <xsl:apply-templates select="@*|node()"/> | ||
| </xsl:copy> | ||
| </xsl:template> | ||
| <xsl:template match="@base[starts-with(., '@compact:')]"> | ||
| <xsl:variable name="q" select="substring-after(., '@compact:')"/> | ||
| <xsl:variable name="head" select="substring-before(concat($q, '.'), '.')"/> | ||
| <xsl:variable name="alias" select="/object/metas/meta[head='alias' and part[1]=$head]/part[2]"/> | ||
coderabbitai[bot] marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <xsl:choose> | ||
| <xsl:when test="parent::o/parent::o/o[@name = $head]"> | ||
| <xsl:attribute name="base"> | ||
| <xsl:value-of select="$q"/> | ||
| </xsl:attribute> | ||
| </xsl:when> | ||
| <xsl:when test="string-length($alias) > 0"> | ||
| <xsl:attribute name="base"> | ||
| <xsl:value-of select="$alias"/> | ||
| </xsl:attribute> | ||
| </xsl:when> | ||
h1alexbel marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| <xsl:otherwise> | ||
| <xsl:attribute name="base"> | ||
| <xsl:value-of select="concat('Φ.org.eolang.', $q)"/> | ||
| </xsl:attribute> | ||
| </xsl:otherwise> | ||
| </xsl:choose> | ||
| </xsl:template> | ||
| </xsl:stylesheet> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...src/test/resources/org/eolang/parser/eo-syntax/compact-array-with-defined-first-part.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| # yamllint disable rule:line-length | ||
| sheets: [] | ||
| asserts: | ||
| - /object[not(errors)] | ||
| - //o[@base='foo.bar']/o[@base='Φ.org.eolang.x'] | ||
| - //o[@base='foo.bar']//o[@base='Φ.org.eolang.y'] | ||
| input: | | ||
| # No comments. | ||
| [] > app | ||
| boom > foo | ||
| foo.bar *1 > @ | ||
| x | ||
| y |
17 changes: 17 additions & 0 deletions
17
eo-parser/src/test/resources/org/eolang/parser/eo-syntax/compact-array.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| # yamllint disable rule:line-length | ||
| sheets: [] | ||
| asserts: | ||
| - /object[not(errors)] | ||
| - //o[@base='Φ.org.eolang.tt.sprintf'] | ||
| input: | | ||
| +alias org.eolang.io.stdout | ||
| +package org.eolang.snippets | ||
|
|
||
| [args] > program | ||
| io.stdout > @ | ||
| tt.sprintf *1 | ||
| "Hello, %s\n" | ||
| args.at 0 |
18 changes: 18 additions & 0 deletions
18
eo-parser/src/test/resources/org/eolang/parser/eo-syntax/compact-sprintf-aliased.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| # yamllint disable rule:line-length | ||
| sheets: [] | ||
| asserts: | ||
| - /object[not(errors)] | ||
| - //o[@base='Φ.org.eolang.tt.sprintf']/o[@base='Φ.org.eolang.string'] | ||
| input: | | ||
| +alias org.eolang.io.stdout | ||
| +alias org.eolang.tt.sprintf | ||
|
|
||
| # No comments. | ||
| [args] > simple | ||
| stdout > @ | ||
| sprintf *1 | ||
| "Hello, %s" | ||
| args.at 0 |
16 changes: 16 additions & 0 deletions
16
...test/resources/org/eolang/parser/eo-syntax/sugared-array-with-composite-name-aliased.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| # SPDX-FileCopyrightText: Copyright (c) 2016-2025 Objectionary.com | ||
| # SPDX-License-Identifier: MIT | ||
| --- | ||
| # yamllint disable rule:line-length | ||
| sheets: [] | ||
| asserts: | ||
| - /object[not(errors)] | ||
| - //o[@base='Φ.org.eolang.foo.bar']/o[@base='Φ.org.eolang.x'] | ||
| - //o[@base='Φ.org.eolang.foo.bar']//o[@base='Φ.org.eolang.y'] | ||
| input: | | ||
| +alias org.eolang.foo.bar | ||
|
|
||
| [] > app | ||
| bar *1 > @ | ||
| x | ||
| y |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.