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

[FEATURE] jsdoc: Support destructuring of enums for defaultValue #775

Merged
merged 69 commits into from
Nov 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
97172b8
ES6 destructuring of UI5 enums
d3xter666 Aug 3, 2022
6934989
Refactor plugin.js and reorder code
d3xter666 Aug 3, 2022
a1cce38
Modify fixtres with destructuring cases
d3xter666 Aug 3, 2022
c2ddb96
Bugfix: Add arrow functions into the scope
d3xter666 Aug 3, 2022
8160672
Tests: Modify expectations to cover destructuring cases
d3xter666 Aug 3, 2022
d0bd9b6
Add copyright for the dependencies
d3xter666 Aug 4, 2022
c67bed6
Tests: Align expectations w/ fixtures
d3xter666 Aug 4, 2022
f1e2ce4
Bugfixing for destructuring
d3xter666 Aug 4, 2022
584ad5e
Destructuring at function paramers
d3xter666 Aug 4, 2022
6ef9ac9
Update documentation
d3xter666 Aug 4, 2022
eb4aa0e
Cover cases where the var after destructuring does not look like an ENUM
d3xter666 Aug 5, 2022
95603bb
Enable the known test cases
d3xter666 Aug 5, 2022
1914d05
Test: Align expectations with fixtures
d3xter666 Aug 5, 2022
b0f7ad0
Refactoring
d3xter666 Aug 5, 2022
27f44da
Refactor: Cover cases from MVN plugin + cleanup
d3xter666 Aug 11, 2022
116de02
Refactor getEnclosingVariableScope to be more generic
d3xter666 Aug 12, 2022
3d69b1d
Fix typos
d3xter666 Aug 16, 2022
44d3fbe
Fix test cases
d3xter666 Aug 17, 2022
22c54ec
Resolve destructuring in the parametter and consider var renaming
d3xter666 Aug 25, 2022
941fff6
Update samples to support destructuring w/ rename as func argument
d3xter666 Aug 26, 2022
105952c
Add failing rename test case
matz3 Sep 8, 2022
6ded432
Var renaming while generating fully quantified name fixed
d3xter666 Sep 9, 2022
a575a4b
Adjust tests
d3xter666 Sep 9, 2022
7500083
Put renamed var as key in the localNames
d3xter666 Sep 9, 2022
ea06965
Remove optional chaining in plugin as we need to support node 12
d3xter666 Sep 12, 2022
63d5464
Adjust tests
d3xter666 Sep 12, 2022
fbb0cb0
Fixe comments
d3xter666 Sep 19, 2022
c0b52d4
Replace regex with string comparisson function
d3xter666 Sep 20, 2022
272fee5
Cleanups
d3xter666 Sep 20, 2022
719b317
Typo fixes
d3xter666 Sep 21, 2022
3ffd86b
Store expected api.json as beautified json
matz3 Sep 26, 2022
8afbadb
Remove renaming
d3xter666 Sep 28, 2022
4682618
Remove commented code
d3xter666 Sep 29, 2022
1d944e3
Make tests closer to the real world naming and usage
d3xter666 Sep 29, 2022
7af3202
Modify tests to fit more likely on the real world scenarios
d3xter666 Sep 29, 2022
c861fcf
Beautify api.json
d3xter666 Sep 30, 2022
b6c3f96
Make tests more production like
d3xter666 Oct 3, 2022
e6dd1ff
Bugfix: Properly define dependencies
d3xter666 Oct 4, 2022
7f9eed3
Align with UI5 repo comments
d3xter666 Oct 14, 2022
41f2200
Align with OpenUI5 repo
d3xter666 Oct 17, 2022
519559a
Align with UI5
d3xter666 Oct 17, 2022
482e99a
Refactor: checkVarRenaming
d3xter666 Nov 3, 2022
0bb4dc4
Refactor fully qunitified name resolver
d3xter666 Nov 4, 2022
e152dac
Support aria.hasPopup case
d3xter666 Nov 7, 2022
65732e7
Refactor code and introducce isVarDestructuring()
d3xter666 Nov 7, 2022
d17363e
Align with OpenUI5
d3xter666 Nov 14, 2022
ec7cee0
Define new scenarios for destructuring
d3xter666 Nov 15, 2022
cb726a5
Handle ObjectPattern nested destructuring in arguments
d3xter666 Nov 15, 2022
b2eee55
Additional test cases
d3xter666 Nov 15, 2022
1f2060f
Refactor arguments handler to cover ObjectPattern, ArrayPattern & mix…
d3xter666 Nov 15, 2022
f2a6458
Make ObjectPattern resolver reusable
d3xter666 Nov 15, 2022
f44c701
Adjust tests
d3xter666 Nov 15, 2022
fbbe10b
Include "path" to the resolved variables
d3xter666 Nov 16, 2022
99912e5
Refactor getFuncArgumentDestructNode() and include ArrayPattern in de…
d3xter666 Nov 16, 2022
66dc043
Fix test cases
d3xter666 Nov 16, 2022
a6528f5
Fix tests
d3xter666 Nov 16, 2022
f53d53d
Fix for path resolving
d3xter666 Nov 16, 2022
2c61a82
Enahnce with the new test cases
d3xter666 Nov 16, 2022
9cff121
Add FunctionDeclaration && FunctionExpression
d3xter666 Nov 17, 2022
4fdc917
Revise ArrayPattern handling
d3xter666 Nov 17, 2022
d547a6b
Include indices in the path for the ArrayPattern
d3xter666 Nov 17, 2022
41f8f58
Fix test cases for ArrayPattern
d3xter666 Nov 17, 2022
171746e
Refactor resolveFullyQuantifiedName()
d3xter666 Nov 24, 2022
a9761bd
Refactor resolveObjectPatternChain()
d3xter666 Nov 24, 2022
41d4e20
Remove names from ArrayPattern: makes no sense
d3xter666 Nov 24, 2022
5a6b328
Fix tests
d3xter666 Nov 24, 2022
f4db252
Aquire proper scope (bugfix)
d3xter666 Nov 24, 2022
98875ae
Formatting fixes & minor refactoring
d3xter666 Nov 28, 2022
fd369cf
Consistent returns
d3xter666 Nov 28, 2022
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
361 changes: 317 additions & 44 deletions lib/processors/jsdoc/lib/ui5/plugin.cjs

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*!
* ${copyright}
*/

/**
* Covers:
* - ArrowFunctionExpression
*/
window.someRandomModule ||
sap.ui.define(
["sap/ui/core/Control"],
/**
* Constructor for a new library.j.SubControl.
*
* @param {string} [sId] ID for the new control, generated automatically if no ID is given
* @param {object} [mSettings] Initial settings for the new control
*
* @class
*
* @author SAP SE
* @version ${version}
*
* @constructor
* @extends sap.ui.core.Control
* @public
* @since 1.22
* @alias library.j.SubControl
*/
(Control) =>
Control.extend(`library.j.SubControl`, {
metadata: {
properties: {
/**
* MyProp property
* @since 1.46
*/
MyProp: {
type: "boolean",
group: `Misc`,
defaultValue: false,
},
},
},
})
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@
/*!
* ${copyright}
*/
sap.ui.define(
[
"sap/ui/core/Control",
"./library",
"./core/library",
"sap/external/thirdparty/library",
"sap/external2/thirdparty/library",
"sap/external3/thirdparty/library",
],
(
Control,
{ MyValidEnum, ThisIsEnumToo: RenamedEnum },
coreLibrary,
[ {arrPattern}, {arrWith: {deep: arrPatternDeepDestruct}}],
{ objPattern: {deeply: {destructured: objPatternDeepDestruct}, objPattern1Lvl} },
libraryExt
) => {
const { AnotherValidEnum } = coreLibrary;
const { Buzz } = AnotherValidEnum;
const { AnotherValidEnum: {Buzz: BuzzRenamed} } = coreLibrary;
const { AnotherValidEnum: AnotherRenamedEnum } = coreLibrary;
const { H1 } = sap.ui.core.TitleLevel;
const { Value2: RenamedValue2 } = RenamedEnum;
const [ {arrPatternVarDef}, {nested: {arrPatternVarDef: arrPatternVarDefNestedAndRenamed}} ] = libraryExt;

/**
* @class
* My super documentation of this class
*
* @extends sap.ui.core.Control
*
* @author SAP SE
* @version ${version}
*
* @public
* @alias library.j.ValidPropertyDefaultValue
* @ui5-metamodel text
*/
var ValidPropertyDefaultValue = Control.extend(
"library.j.ValidPropertyDefaultValue",
{
metadata: {
properties: {
/**
* validPropertyDefaultValueEnumSimpleDestructuring
*/
validPropertyDefaultValueEnumSimpleDestructuring: {
type: "library.j.core.AnotherValidEnum",
group: "Misc",
defaultValue: AnotherValidEnum.Buzz
},

/**
* validPropertyDefaultValueEnumChainedDestructuring
*/
validPropertyDefaultValueEnumChainedDestructuring: {
type: "library.j.core.AnotherValidEnum",
group: "Misc",
defaultValue: Buzz
},

/**
* validPropertyDefaultValueEnumNestedDestructuring
*/
validPropertyDefaultValueEnumNestedDestructuring: {
type: "library.j.core.AnotherValidEnum",
group: "Misc",
defaultValue: BuzzRenamed
},

/**
* validPropertyDefaultValueEnumDestructuringWithRename
*/
validPropertyDefaultValueEnumDestructuringWithRename: {
type: "library.j.core.AnotherValidEnum",
group: "Misc",
defaultValue: AnotherRenamedEnum.Fizz
},

/**
* validPropertyDefaultValueEnumDestructuringWithRenameInArguments
*/
validPropertyDefaultValueEnumDestructuringWithRenameInArguments:
{
type: "library.j.ThisIsEnumToo",
group: "Misc",
defaultValue: RenamedEnum.Value1
},

/**
* validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar
*/
validPropertyDefaultValueEnumDestructuringWithRenameInArgumentsAndLocalVar:
{
type: "library.j.ThisIsEnumToo",
group: "Misc",
defaultValue: RenamedValue2
},

/**
* validPropertyDefaultValueEnumViaDestructuringInArrowFn
*/
validPropertyDefaultValueEnumViaDestructuringInArrowFn:
{
type: "library.j.MyValidEnum",
group: "Misc",
defaultValue: MyValidEnum.Foo
},

/**
* validPropertyDefaultValueEnumViaDestructuringGlobal
*/
validPropertyDefaultValueEnumViaDestructuringGlobal: {
type: "sap.ui.core.TitleLevel",
group: "Misc",
defaultValue: H1
},

/**
* validPropertyDefaultValueArrPattern
*/
validPropertyDefaultValueArrPattern: {
type: "sap.external.thirdparty.0",
group: "Misc",
defaultValue: arrPattern
},

/**
* validPropertyDefaultValueArrPatternDeepDestruct
*/
validPropertyDefaultValueArrPatternDeepDestruct: {
type: "sap.external.thirdparty.1.arrWith",
group: "Misc",
defaultValue: arrPatternDeepDestruct
},

/**
* validPropertyDefaultValueArrPatternDeepDestruct
*/
validPropertyDefaultValueObjPatternDeepDestruct: {
type: "sap.external2.thirdparty.objPattern.deeply",
group: "Misc",
defaultValue: objPatternDeepDestruct
},

/**
* validPropertyDefaultValueObjPatternNested
*/
validPropertyDefaultValueObjPatternNested: {
type: "sap.external2.thirdparty.objPattern",
group: "Misc",
defaultValue: objPattern1Lvl
},

/**
* validPropertyDefaultValueArrPatternVarDef
*/
validPropertyDefaultValueArrPatternVarDef: {
type: "sap.external3.thirdparty.0",
group: "Misc",
defaultValue: arrPatternVarDef
},

/**
* validPropertyDefaultValueArrPatternVarDef
*/
validPropertyDefaultValueArrPatternVarDefNestedAndRenamed: {
type: "sap.external3.thirdparty.1.nested",
group: "Misc",
defaultValue: arrPatternVarDefNestedAndRenamed
}
},
},
renderer: function () {},
}
);

return ValidPropertyDefaultValue;
},
/* bExport= */ true
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*!
* ${copyright}
*/
sap.ui.define([], function () {
sap.ui.getCore().initLibrary({
name: "library.j.core",
version: "${version}",
dependencies: ["sap.ui.core"],
designtime: "library/j/core/designtime/library.designtime",
types: ["library.j.core.AnotherValidEnum"],
});

/**
* AnotherValidEnum
*
* @enum {string}
* @public
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
library.j.core.AnotherValidEnum = {
/**
* Fizz
* @public
*/
Fizz: "Fizz",
/**
* Buzz
* @public
*/
Buzz: "Buzz",
};

return library.j.core;
});

This file was deleted.

53 changes: 53 additions & 0 deletions test/expected/build/library.j/dest/resources/library/j/library.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*!
* ${copyright}
*/
sap.ui.define([], function () {
sap.ui.getCore().initLibrary({
name: "library.j",
version: "${version}",
dependencies: ["sap.ui.core"],
designtime: "library/j/designtime/library.designtime",
types: ["library.j.MyValidEnum"],
});

/**
* MyValidEnum
*
* @enum {string}
* @public
* @ui5-metamodel This enumeration also will be described in the UI5 (legacy) designtime metamodel
*/
library.j.MyValidEnum = {
/**
* Foo
* @public
*/
Foo: "Foo",
/**
* Bar
* @public
*/
Bar: "Bar",
};

/**
* ThisIsEnumToo
*
* @enum {string}
* @public
*/
library.j.ThisIsEnumToo = {
/**
* Value1
* @public
*/
Value1: "Value1",
/**
* Value2
* @public
*/
Value2: "Value2",
};

return library.j;
});
20 changes: 0 additions & 20 deletions test/expected/build/library.j/dest/resources/library/j/some.js

This file was deleted.

Loading