Skip to content
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
4 changes: 2 additions & 2 deletions src/linter/xmlTemplate/Parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ export default class Parser {
}

popTag(_tag: SaxTag) { // No need to use the parsed tag, we rely on our nodeStack
const level = this.#nodeStack.length;
const closingNode = this.#nodeStack.pop();
const level = this.#nodeStack.length;

if (closingNode &&
(closingNode.kind & (NodeKind.Control | NodeKind.FragmentDefinition))) {
// Generate view code for this control
// If this is the root control, export it
if (level === 1) {
if (level === 0) {
// Actually closingNode might be a FragmentDefinitionDeclaration here
// But that's tricky with the current generator signatures
this.#generator.writeRootControl(closingNode as ControlDeclaration);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<VBox xmlns="sap.m">

<Table xmlns="sap.ui.table" group="onGroup" visibleRowCountMode="Fixed">
<footer>
<Button xmlns="sap.m" tap="onTap" />
</footer>
</Table>

<Button tap="onTap" />

</VBox>
11 changes: 11 additions & 0 deletions test/fixtures/transpiler/xml/MultipleXmlns.fragment.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<VBox xmlns="sap.m">

<Table xmlns="sap.ui.table" group="onGroup">
<footer>
<Button xmlns="sap.m" tap="onTap" />
</footer>
</Table>

<Button tap="onTap" />

</VBox>
72 changes: 72 additions & 0 deletions test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -981,6 +981,78 @@ Generated by [AVA](https://avajs.dev).
},
]

## General: MultipleXmlns.fragment.xml

> Snapshot 1

[
{
coverageInfo: [],
errorCount: 4,
fatalErrorCount: 0,
filePath: 'MultipleXmlns.fragment.xml',
messages: [
{
column: 30,
line: 3,
message: 'Event handler \'onGroup\' must be prefixed by a dot \'.\' or refer to a local name',
messageDetails: 'If the handler is defined on the controller, use the leading dot notation. Otherwise import the module via core:require and use the handler via the local name. See Handling Events in XML Views (https://ui5.sap.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe)',
ruleId: 'no-ambiguous-event-handler',
severity: 1,
},
{
column: 30,
line: 3,
message: 'Use of deprecated property \'group\' of class \'Table\'',
messageDetails: 'Deprecated test message',
ruleId: 'no-deprecated-api',
severity: 2,
},
{
column: 46,
line: 3,
message: 'Use of deprecated property \'visibleRowCountMode\' of class \'Table\'',
messageDetails: 'Deprecated test message',
ruleId: 'no-deprecated-api',
severity: 2,
},
{
column: 26,
line: 5,
message: 'Event handler \'onTap\' must be prefixed by a dot \'.\' or refer to a local name',
messageDetails: 'If the handler is defined on the controller, use the leading dot notation. Otherwise import the module via core:require and use the handler via the local name. See Handling Events in XML Views (https://ui5.sap.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe)',
ruleId: 'no-ambiguous-event-handler',
severity: 1,
},
{
column: 26,
line: 5,
message: 'Use of deprecated property \'tap\' of class \'Button\'',
messageDetails: 'Deprecated test message',
ruleId: 'no-deprecated-api',
severity: 2,
},
{
column: 10,
line: 9,
message: 'Event handler \'onTap\' must be prefixed by a dot \'.\' or refer to a local name',
messageDetails: 'If the handler is defined on the controller, use the leading dot notation. Otherwise import the module via core:require and use the handler via the local name. See Handling Events in XML Views (https://ui5.sap.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe)',
ruleId: 'no-ambiguous-event-handler',
severity: 1,
},
{
column: 10,
line: 9,
message: 'Use of deprecated property \'tap\' of class \'Button\'',
messageDetails: 'Deprecated test message',
ruleId: 'no-deprecated-api',
severity: 2,
},
],
warningCount: 3,
},
]

## General: NoDeprecatedApi.js

> Snapshot 1
Expand Down
Binary file modified test/lib/linter/rules/snapshots/NoDeprecatedApi.ts.snap
Binary file not shown.
82 changes: 82 additions & 0 deletions test/lib/linter/xmlTemplate/snapshots/transpiler.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,88 @@ Generated by [AVA](https://avajs.dev).

Map {}

## Transpile MultipleXmlns.fragment.xml

> source

`import Button from "sap/m/Button";␊
import Button2 from "sap/m/Button";␊
import Table from "sap/ui/table/Table";␊
import VBox from "sap/m/VBox";␊
const oButton = new Button({␊
tap: "onTap",␊
});␊
const oTable = new Table({␊
group: "onGroup",␊
footer: [␊
oButton,␊
],␊
});␊
const oButton2 = new Button2({␊
tap: "onTap",␊
});␊
const oVBox = new VBox({␊
items: [␊
oTable,␊
oButton2,␊
],␊
});␊
export default {␊
createContent: function () {␊
return oVBox;␊
}␊
}␊
`

> map

{
file: 'MultipleXmlns.fragment.js',
mappings: 'AAIG,kCAAoC;AAItC,mCAAsB;AANtB,uCAA4C;AAF7C,8BAAoB;gBAIjB,YAAoC;IAAd,aAAW;;;eAFnC,WAA4C;IAAhB,iBAAe;IAC1C,MAAQ;;;;;iBAKT,aAAsB;IAAd,aAAW;;;cARpB,UAAoB;IAEnB,KAA4C',
names: [],
sources: [
'MultipleXmlns.fragment.xml',
],
version: 3,
}

> messages

[
{
column: 30,
line: 3,
message: 'Event handler \'onGroup\' must be prefixed by a dot \'.\' or refer to a local name',
messageDetails: 'If the handler is defined on the controller, use the leading dot notation. Otherwise import the module via core:require and use the handler via the local name. See Handling Events in XML Views (https://ui5.sap.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe)',
ruleId: 'no-ambiguous-event-handler',
severity: 1,
},
{
column: 26,
line: 5,
message: 'Event handler \'onTap\' must be prefixed by a dot \'.\' or refer to a local name',
messageDetails: 'If the handler is defined on the controller, use the leading dot notation. Otherwise import the module via core:require and use the handler via the local name. See Handling Events in XML Views (https://ui5.sap.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe)',
ruleId: 'no-ambiguous-event-handler',
severity: 1,
},
{
column: 10,
line: 9,
message: 'Event handler \'onTap\' must be prefixed by a dot \'.\' or refer to a local name',
messageDetails: 'If the handler is defined on the controller, use the leading dot notation. Otherwise import the module via core:require and use the handler via the local name. See Handling Events in XML Views (https://ui5.sap.com/#/topic/b0fb4de7364f4bcbb053a99aa645affe)',
ruleId: 'no-ambiguous-event-handler',
severity: 1,
},
]

> controllerByIdInfo

Map {}

## Transpile UnknownAttrNamespace.fragment.xml

> source
Expand Down
Binary file modified test/lib/linter/xmlTemplate/snapshots/transpiler.ts.snap
Binary file not shown.