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: Detect inline XML fragments & views (reuse TS program) #519

Open
wants to merge 44 commits into
base: main
Choose a base branch
from

Conversation

d3xter666
Copy link
Contributor

@d3xter666 d3xter666 commented Feb 7, 2025

JIRA: CPOUI5FOUNDATION-986

This is alternative implementation of #517 by reusing program instead of TS transpiling file by file.

Note: This change's base is currently #518 as it paves the ground for dynamic addition of resources to the TS program

@d3xter666 d3xter666 marked this pull request as draft February 7, 2025 12:17
@d3xter666 d3xter666 force-pushed the refactor-fragments-detection branch from 5205e53 to ae136f2 Compare February 7, 2025 13:17
@d3xter666 d3xter666 changed the base branch from main to refactor-ts-language-service February 7, 2025 13:18
Base automatically changed from refactor-ts-language-service to main February 7, 2025 14:45
@d3xter666 d3xter666 force-pushed the refactor-fragments-detection branch from a196c8b to 480249c Compare February 10, 2025 11:18
@d3xter666
Copy link
Contributor Author

Note: This change sorts messages in the tests, so that many unrelated test snapshots are also included in here.
The reasoning is that XML extraction is not stable, so the order of the messages in different runs/OS might be shuffled.

@d3xter666 d3xter666 marked this pull request as ready for review February 10, 2025 13:50
@d3xter666 d3xter666 requested a review from a team February 10, 2025 13:50
@matz3
Copy link
Member

matz3 commented Feb 10, 2025

Note: This change sorts messages in the tests, so that many unrelated test snapshots are also included in here. The reasoning is that XML extraction is not stable, so the order of the messages in different runs/OS might be shuffled.

Currently, the linting results are deterministic and we should stick with that. Only sorting the results when comparing within unit tests will not lead to deterministic results for public consumers.

I suspect that this is caused by a missing sorting of the newly created files. For the initial files, this is done via:

// Sort paths to ensure consistent order (helps with debugging and comparing verbose/silly logs)
pathsToLint.sort((a, b) => a.localeCompare(b));

test/fixtures/linter/rules/XMLInJs/FragmentLoad.js Outdated Show resolved Hide resolved
src/linter/ui5Types/TypeLinter.ts Outdated Show resolved Hide resolved
test/fixtures/linter/rules/XMLInJs/ViewCreate.js Outdated Show resolved Hide resolved
test/fixtures/linter/rules/XMLInJs/ViewCreate.js Outdated Show resolved Hide resolved
test/fixtures/linter/rules/XMLInJs/SapUIView.js Outdated Show resolved Hide resolved
src/linter/ui5Types/SourceFileLinter.ts Outdated Show resolved Hide resolved
src/linter/ui5Types/TypeLinter.ts Outdated Show resolved Hide resolved
test/lib/linter/rules/XMLInJs.ts Outdated Show resolved Hide resolved
test/lib/linter/rules/snapshots/XMLInJs.ts.md Outdated Show resolved Hide resolved

const oView2 = sap.ui.view({
type: "XML",
viewContent: `<mvc:View
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please also include a test case where a normal string literal is used within one line. I could reproduce a wrong column information when using this:
viewContent: '<mvc:View controllerName="ui5app.controller.Home" displayBlock="true" xmlns="sap.m" xmlns:mvc="sap.ui.core.mvc" xmlns:core="sap.ui.core"><Button tap=".sayHello"></mvc:View>'

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me the column info seems wrong. It is 146 but should be 162, isn't it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants