From 0f41b5da93107dec3007c49e5b262e54d7c5d39f Mon Sep 17 00:00:00 2001 From: Maruf Rasully Date: Tue, 8 Aug 2023 13:03:31 +0200 Subject: [PATCH] fix: add seprator in doc and remove visibility --- packages/binding/src/definition/definition.ts | 2 +- packages/binding/src/services/hover/index.ts | 4 +-- .../providers => utils}/documentation.ts | 11 ++++--- packages/binding/src/utils/index.ts | 2 ++ .../__snapshots__/definition.test.ts.snap | 30 ------------------- .../__snapshots__/index.test.ts.snap | 30 ------------------- .../hover/__snapshots__/hover.test.ts.snap | 8 ++--- 7 files changed, 16 insertions(+), 71 deletions(-) rename packages/binding/src/{services/completion/providers => utils}/documentation.ts (87%) diff --git a/packages/binding/src/definition/definition.ts b/packages/binding/src/definition/definition.ts index 8f73b3b73..46823502e 100644 --- a/packages/binding/src/definition/definition.ts +++ b/packages/binding/src/definition/definition.ts @@ -13,7 +13,7 @@ import { } from "../types"; import { ui5NodeToFQN } from "@ui5-language-assistant/logic-utils"; import { forOwn } from "lodash"; -import { getDocumentation } from "../services/completion/providers/documentation"; +import { getDocumentation } from "../utils"; import { fallBackElements } from "./fall-back-definition"; const isBindingInfoName = (name: string): name is BindingInfoName => { diff --git a/packages/binding/src/services/hover/index.ts b/packages/binding/src/services/hover/index.ts index 298393f39..930c15e3d 100644 --- a/packages/binding/src/services/hover/index.ts +++ b/packages/binding/src/services/hover/index.ts @@ -13,7 +13,7 @@ import { import { Position } from "vscode-languageserver-types"; import { BindContext } from "../../types"; import { PROPERTY_BINDING_INFO } from "../../constant"; -import { getDocumentation } from "../completion/providers/documentation"; +import { getDocumentation } from "../../utils"; import { UI5Typedef } from "@ui5-language-assistant/semantic-model-types"; const getHoverFromBinding = ( @@ -46,7 +46,7 @@ const getHoverFromBinding = ( (prop) => prop.name === element.key?.originalText ); if (property) { - return { contents: getDocumentation(context, property) }; + return { contents: getDocumentation(context, property, true) }; } } diff --git a/packages/binding/src/services/completion/providers/documentation.ts b/packages/binding/src/utils/documentation.ts similarity index 87% rename from packages/binding/src/services/completion/providers/documentation.ts rename to packages/binding/src/utils/documentation.ts index 54566e724..82f91ef71 100644 --- a/packages/binding/src/services/completion/providers/documentation.ts +++ b/packages/binding/src/utils/documentation.ts @@ -2,10 +2,10 @@ import { UI5Type, UI5TypedefProp, } from "@ui5-language-assistant/semantic-model-types"; -import { BindContext } from "../../../types"; +import { BindContext } from "../types"; import { MarkupKind } from "vscode-languageserver-types"; import { ui5NodeToFQN, getLink } from "@ui5-language-assistant/logic-utils"; -import { PROPERTY_BINDING_INFO } from "../../../constant"; +import { PROPERTY_BINDING_INFO } from "../constant"; const getType = (type: UI5Type | undefined): string[] => { const result: string[] = []; @@ -37,7 +37,8 @@ const getType = (type: UI5Type | undefined): string[] => { export const getDocumentation = ( context: BindContext, - prop: UI5TypedefProp + prop: UI5TypedefProp, + forHover = false ): { kind: MarkupKind; value: string; @@ -47,10 +48,12 @@ export const getDocumentation = ( `\`typedef ${PROPERTY_BINDING_INFO}\``, `**Type:** ${getType(prop.type)}`, `**Description:** ${prop.description}`, - `**Visibility:** ${prop.visibility}`, `**Optional:** ${prop.optional}`, `[More information](${link})`, ]; + if (forHover) { + values.splice(1, 0, `---`); + } return { kind: MarkupKind.Markdown, value: values.join("\n\n"), diff --git a/packages/binding/src/utils/index.ts b/packages/binding/src/utils/index.ts index 427e9af0a..17af1c5a3 100644 --- a/packages/binding/src/utils/index.ts +++ b/packages/binding/src/utils/index.ts @@ -10,3 +10,5 @@ export { export { getCursorContext } from "./cursor"; export { getLogger } from "./logger"; + +export { getDocumentation } from "./documentation"; diff --git a/packages/binding/test/unit/definition/__snapshots__/definition.test.ts.snap b/packages/binding/test/unit/definition/__snapshots__/definition.test.ts.snap index 72d673572..80e698712 100644 --- a/packages/binding/test/unit/definition/__snapshots__/definition.test.ts.snap +++ b/packages/binding/test/unit/definition/__snapshots__/definition.test.ts.snap @@ -11,8 +11,6 @@ Array [ **Description:** Path in the model to bind to, either an absolute path or relative to the binding context for the corresponding model; when the path contains a '>' sign, the string preceding it will override the model property and the remainder after the '>' will be used as binding path -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -43,8 +41,6 @@ Array [ **Description:** Since 1.61, defines a static binding with the given value. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -75,8 +71,6 @@ Array [ **Description:** Name of the model to bind against; when undefined or omitted, the default model is used -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -104,8 +98,6 @@ Array [ **Description:** Whether the binding should be suspended initially -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -136,8 +128,6 @@ Array [ **Description:** Function to convert model data into a property value -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -167,8 +157,6 @@ Array [ Note: use this flag only when using multiple bindings. If you use only one binding and want raw values then simply don't specify a type for that binding. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -201,8 +189,6 @@ Array [ Note: use this flag only when using multiple bindings. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -233,8 +219,6 @@ Array [ **Description:** A type object or the name of a type class to create such a type object; the type will be used for converting model data to a property value (aka \\"formatting\\") and vice versa (in binding mode TwoWay, aka \\"parsing\\") -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -311,8 +295,6 @@ Array [ **Description:** Target type to be used by the type when formatting model data, for example \\"boolean\\" or \\"string\\" or \\"any\\"; defaults to the property's type -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -340,8 +322,6 @@ Array [ **Description:** Format options to be used for the type; only taken into account when the type is specified by its name - a given type object won't be modified -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -380,8 +360,6 @@ Array [ **Description:** Additional constraints to be used when constructing a type object from a type name, ignored when a type object is given -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -420,8 +398,6 @@ Array [ **Description:** Binding mode to be used for this property binding (e.g. one way) -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -454,8 +430,6 @@ Array [ **Description:** Map of additional parameters for this binding; the names and value ranges of the supported parameters depend on the model implementation, they should be documented with the bindProperty method of the corresponding model class or with the model specific subclass of sap.ui.model.PropertyBinding -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -483,8 +457,6 @@ Array [ **Description:** Map of event handler functions keyed by the name of the binding events that they should be attached to -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -516,8 +488,6 @@ If a part is not specified as a binding info object but as a simple string, a bi Note: recursive composite bindings are currently not supported. Therefore, a part must not contain a parts property. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", diff --git a/packages/binding/test/unit/services/completion/__snapshots__/index.test.ts.snap b/packages/binding/test/unit/services/completion/__snapshots__/index.test.ts.snap index 1acf8b1cc..1f77c432e 100644 --- a/packages/binding/test/unit/services/completion/__snapshots__/index.test.ts.snap +++ b/packages/binding/test/unit/services/completion/__snapshots__/index.test.ts.snap @@ -8,8 +8,6 @@ Array [ **Description:** Path in the model to bind to, either an absolute path or relative to the binding context for the corresponding model; when the path contains a '>' sign, the string preceding it will override the model property and the remainder after the '>' will be used as binding path -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -19,8 +17,6 @@ Array [ **Description:** Since 1.61, defines a static binding with the given value. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -30,8 +26,6 @@ Array [ **Description:** Name of the model to bind against; when undefined or omitted, the default model is used -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -41,8 +35,6 @@ Array [ **Description:** Whether the binding should be suspended initially -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -52,8 +44,6 @@ Array [ **Description:** Function to convert model data into a property value -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -65,8 +55,6 @@ Array [ Note: use this flag only when using multiple bindings. If you use only one binding and want raw values then simply don't specify a type for that binding. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -78,8 +66,6 @@ Array [ Note: use this flag only when using multiple bindings. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -89,8 +75,6 @@ Array [ **Description:** A type object or the name of a type class to create such a type object; the type will be used for converting model data to a property value (aka \\"formatting\\") and vice versa (in binding mode TwoWay, aka \\"parsing\\") -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -100,8 +84,6 @@ Array [ **Description:** Target type to be used by the type when formatting model data, for example \\"boolean\\" or \\"string\\" or \\"any\\"; defaults to the property's type -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -111,8 +93,6 @@ Array [ **Description:** Format options to be used for the type; only taken into account when the type is specified by its name - a given type object won't be modified -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -122,8 +102,6 @@ Array [ **Description:** Additional constraints to be used when constructing a type object from a type name, ignored when a type object is given -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -133,8 +111,6 @@ Array [ **Description:** Binding mode to be used for this property binding (e.g. one way) -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -144,8 +120,6 @@ Array [ **Description:** Map of additional parameters for this binding; the names and value ranges of the supported parameters depend on the model implementation, they should be documented with the bindProperty method of the corresponding model class or with the model specific subclass of sap.ui.model.PropertyBinding -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -155,8 +129,6 @@ Array [ **Description:** Map of event handler functions keyed by the name of the binding events that they should be attached to -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -170,8 +142,6 @@ If a part is not specified as a binding info object but as a simple string, a bi Note: recursive composite bindings are currently not supported. Therefore, a part must not contain a parts property. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", diff --git a/packages/binding/test/unit/services/hover/__snapshots__/hover.test.ts.snap b/packages/binding/test/unit/services/hover/__snapshots__/hover.test.ts.snap index 2dfe5e045..3010bde29 100644 --- a/packages/binding/test/unit/services/hover/__snapshots__/hover.test.ts.snap +++ b/packages/binding/test/unit/services/hover/__snapshots__/hover.test.ts.snap @@ -6,6 +6,8 @@ Object { "kind": "markdown", "value": "\`typedef sap.ui.base.ManagedObject.PropertyBindingInfo\` +--- + **Type:** Array<(String | sap.ui.base.ManagedObject.PropertyBindingInfo>) **Description:** Array of binding info objects for the parts of a composite binding; the structure of each binding info is the same as described for the oBindingInfo as a whole. @@ -14,8 +16,6 @@ If a part is not specified as a binding info object but as a simple string, a bi Note: recursive composite bindings are currently not supported. Therefore, a part must not contain a parts property. -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)", @@ -29,12 +29,12 @@ Object { "kind": "markdown", "value": "\`typedef sap.ui.base.ManagedObject.PropertyBindingInfo\` +--- + **Type:** String **Description:** Path in the model to bind to, either an absolute path or relative to the binding context for the corresponding model; when the path contains a '>' sign, the string preceding it will override the model property and the remainder after the '>' will be used as binding path -**Visibility:** public - **Optional:** true [More information](https://ui5.sap.com/1.108.1/#/api/sap.ui.base.ManagedObject.PropertyBindingInfo)",