Skip to content

[FEATURE] XMLTemplateAnalyzer: Support core:require#304

Merged
matz3 merged 4 commits intomasterfrom
xml-template-analyzer-core-require
Aug 29, 2019
Merged

[FEATURE] XMLTemplateAnalyzer: Support core:require#304
matz3 merged 4 commits intomasterfrom
xml-template-analyzer-core-require

Conversation

@matz3
Copy link
Copy Markdown
Member

@matz3 matz3 commented Jul 29, 2019

Starting with UI5 1.69, a core:require attribute can be used in XML
views/fragments to require modules/controls to be used within the XML
context.
UI5/openui5@2dab48e

This change supports detecting those modules to be included in bundles.

Open Issues

  • How to integrate/reuse JSTokenizer? (Currently a copy from OpenUI5 is included)
  • Add more test cases

Starting with UI5 1.69, a core:require attribute can be used in XML
views/fragments to require modules/controls to be used within the XML
context.
UI5/openui5@2dab48e

This change supports detecting those modules to be included in bundles.
@coveralls
Copy link
Copy Markdown

coveralls commented Jul 29, 2019

Coverage Status

Coverage increased (+0.6%) to 86.627% when pulling 3f083c5 on xml-template-analyzer-core-require into 2ba75af on master.

this.next();
};

// /**
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wouldn't it be possible to exclude the file from the JSDoc build of the tooling? At least this would simplify regular updates...

Well, the modification of the module definition remains necessary anyhow.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, that's right.
I mainly wanted to get npm test working and discuss the re-use/integration of JSTokenizer beforehand.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

log.error("Require attribute can't be parsed on Node: ", node.$ns.local);
throw e;
}
if (requireContext) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

in the runtime code, we have added some validation for the object literal (keys must be simple identifiers, values must be string literals). At least for the requireJsName, a check for string literal might make sense...

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Good point 👍
Tests for those cases should also be added.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Copy Markdown
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

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

Core change is fine with me, just some wording complaints in the test.

const sinon = require("sinon");

test("integration: Analysis of an xml view", async (t) => {
test("integration: Analysis of a xml view", async (t) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

an?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

AFAIK, "an" has to be used whenever the next following word starts with a vocal when spoken, not when written. And "XML" is spoken "EX M L". Much like "SAP" is spoken "ESS AY PEE". That's why we also write "an sap.m.Button".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Actually didn't know that, thanks 👍

});

test("integration: Analysis of an xml view with data binding in properties", async (t) => {
test("integration: Analysis of a xml view with data binding in properties", async (t) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

an?

});

test("integration: Analysis of an xml fragment", async (t) => {
test("integration: Analysis of a xml view with core:require", async (t) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

an?

"Implicit dependency should be added since an XMLView is analyzed");
});

test("integration: Analysis of a xml view with core:require (parsing error)", async (t) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

an?

"Implicit dependency should be added since an XMLView is analyzed");
});

test("integration: Analysis of a xml view with core:require (invalid module name)", async (t) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

an?

"Implicit dependency should be added since an XMLView is analyzed");
});

test("integration: Analysis of a xml fragment", async (t) => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

an?


oTokenizer2.init("{='other foo'}");
t.true(oTokenizer2.getIndex() !== oTokenizer.getIndex(), "different instances");
});
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice that you test it in NodeJS again - makes sense.

@matz3 matz3 requested a review from codeworrior August 28, 2019 07:05
Copy link
Copy Markdown
Member

@codeworrior codeworrior left a comment

Choose a reason for hiding this comment

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

LGTM

@matz3 matz3 merged commit b01fd85 into master Aug 29, 2019
@matz3 matz3 deleted the xml-template-analyzer-core-require branch August 29, 2019 10:55
matz3 added a commit to UI5/cli that referenced this pull request Sep 2, 2019
matz3 added a commit to UI5/cli that referenced this pull request Sep 2, 2019
d3xter666 pushed a commit to UI5/cli that referenced this pull request Sep 25, 2025
…-builder#304)

Starting with UI5 1.69, a core:require attribute can be used in XML
views/fragments to require modules/controls to be used within the XML
context.
UI5/openui5@2dab48e

This change supports detecting those modules to be included in bundles.
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