@sap-ux/fiori-annotation-api 0.11.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/annotation-provider.d.ts +1 -1
- package/dist/annotation-provider.d.ts.map +1 -1
- package/dist/annotation-provider.js +30 -36
- package/dist/annotation-provider.js.map +1 -1
- package/dist/avt/annotations.js +53 -56
- package/dist/avt/annotations.js.map +1 -1
- package/dist/avt/expressions.js +3 -7
- package/dist/avt/expressions.js.map +1 -1
- package/dist/avt/find.d.ts +2 -2
- package/dist/avt/find.d.ts.map +1 -1
- package/dist/avt/find.js +16 -20
- package/dist/avt/find.js.map +1 -1
- package/dist/avt/index.d.ts +8 -8
- package/dist/avt/index.d.ts.map +1 -1
- package/dist/avt/index.js +7 -31
- package/dist/avt/index.js.map +1 -1
- package/dist/avt/metadata.js +1 -4
- package/dist/avt/metadata.js.map +1 -1
- package/dist/avt/pointer.d.ts +1 -1
- package/dist/avt/pointer.d.ts.map +1 -1
- package/dist/avt/pointer.js +12 -15
- package/dist/avt/pointer.js.map +1 -1
- package/dist/avt/to-internal.d.ts +1 -1
- package/dist/avt/to-internal.d.ts.map +1 -1
- package/dist/avt/to-internal.js +53 -65
- package/dist/avt/to-internal.js.map +1 -1
- package/dist/avt/types.js +1 -2
- package/dist/avt/utils.d.ts +2 -2
- package/dist/avt/utils.d.ts.map +1 -1
- package/dist/avt/utils.js +11 -20
- package/dist/avt/utils.js.map +1 -1
- package/dist/cds/adapter.d.ts +5 -5
- package/dist/cds/adapter.d.ts.map +1 -1
- package/dist/cds/adapter.js +184 -187
- package/dist/cds/adapter.js.map +1 -1
- package/dist/cds/cds-compiler-tokens.js +11 -21
- package/dist/cds/cds-compiler-tokens.js.map +1 -1
- package/dist/cds/change.d.ts +1 -1
- package/dist/cds/change.d.ts.map +1 -1
- package/dist/cds/change.js +63 -79
- package/dist/cds/change.js.map +1 -1
- package/dist/cds/comments.d.ts +1 -1
- package/dist/cds/comments.d.ts.map +1 -1
- package/dist/cds/comments.js +4 -7
- package/dist/cds/comments.js.map +1 -1
- package/dist/cds/deletion.d.ts +1 -1
- package/dist/cds/deletion.d.ts.map +1 -1
- package/dist/cds/deletion.js +74 -61
- package/dist/cds/deletion.js.map +1 -1
- package/dist/cds/document.d.ts +4 -4
- package/dist/cds/document.d.ts.map +1 -1
- package/dist/cds/document.js +20 -27
- package/dist/cds/document.js.map +1 -1
- package/dist/cds/indent.d.ts +2 -2
- package/dist/cds/indent.d.ts.map +1 -1
- package/dist/cds/indent.js +16 -20
- package/dist/cds/indent.js.map +1 -1
- package/dist/cds/index.d.ts +2 -2
- package/dist/cds/index.d.ts.map +1 -1
- package/dist/cds/index.js +4 -22
- package/dist/cds/index.js.map +1 -1
- package/dist/cds/pointer.d.ts +1 -1
- package/dist/cds/pointer.d.ts.map +1 -1
- package/dist/cds/pointer.js +38 -42
- package/dist/cds/pointer.js.map +1 -1
- package/dist/cds/preprocessor.d.ts +3 -3
- package/dist/cds/preprocessor.d.ts.map +1 -1
- package/dist/cds/preprocessor.js +91 -95
- package/dist/cds/preprocessor.js.map +1 -1
- package/dist/cds/references.d.ts +2 -2
- package/dist/cds/references.d.ts.map +1 -1
- package/dist/cds/references.js +49 -55
- package/dist/cds/references.js.map +1 -1
- package/dist/cds/service.d.ts +1 -1
- package/dist/cds/service.d.ts.map +1 -1
- package/dist/cds/service.js +6 -8
- package/dist/cds/service.js.map +1 -1
- package/dist/cds/utils.d.ts +2 -2
- package/dist/cds/utils.d.ts.map +1 -1
- package/dist/cds/utils.js +20 -24
- package/dist/cds/utils.js.map +1 -1
- package/dist/cds/writer.d.ts +6 -6
- package/dist/cds/writer.d.ts.map +1 -1
- package/dist/cds/writer.js +199 -202
- package/dist/cds/writer.js.map +1 -1
- package/dist/change-converter.d.ts +1 -1
- package/dist/change-converter.d.ts.map +1 -1
- package/dist/change-converter.js +124 -128
- package/dist/change-converter.js.map +1 -1
- package/dist/error.js +3 -7
- package/dist/error.js.map +1 -1
- package/dist/external-services.d.ts +1 -1
- package/dist/external-services.d.ts.map +1 -1
- package/dist/external-services.js +10 -13
- package/dist/external-services.js.map +1 -1
- package/dist/fiori-service.d.ts +4 -4
- package/dist/fiori-service.d.ts.map +1 -1
- package/dist/fiori-service.js +41 -45
- package/dist/fiori-service.js.map +1 -1
- package/dist/index.d.ts +9 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -31
- package/dist/index.js.map +1 -1
- package/dist/logger.js +2 -5
- package/dist/logger.js.map +1 -1
- package/dist/protected.d.ts +2 -2
- package/dist/protected.d.ts.map +1 -1
- package/dist/protected.js +2 -8
- package/dist/protected.js.map +1 -1
- package/dist/sap/builders.d.ts +1 -1
- package/dist/sap/builders.d.ts.map +1 -1
- package/dist/sap/builders.js +22 -30
- package/dist/sap/builders.js.map +1 -1
- package/dist/sap/collector.d.ts +1 -1
- package/dist/sap/collector.d.ts.map +1 -1
- package/dist/sap/collector.js +50 -53
- package/dist/sap/collector.js.map +1 -1
- package/dist/sap/converter.d.ts +1 -1
- package/dist/sap/converter.d.ts.map +1 -1
- package/dist/sap/converter.js +37 -42
- package/dist/sap/converter.js.map +1 -1
- package/dist/sap/index.d.ts +1 -1
- package/dist/sap/index.d.ts.map +1 -1
- package/dist/sap/index.js +1 -6
- package/dist/sap/index.js.map +1 -1
- package/dist/sap/types.js +5 -8
- package/dist/sap/types.js.map +1 -1
- package/dist/types/adapter.d.ts +3 -3
- package/dist/types/adapter.d.ts.map +1 -1
- package/dist/types/adapter.js +1 -2
- package/dist/types/change.js +11 -14
- package/dist/types/change.js.map +1 -1
- package/dist/types/index.d.ts +6 -6
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.js +3 -32
- package/dist/types/index.js.map +1 -1
- package/dist/types/internal-change.d.ts +1 -1
- package/dist/types/internal-change.d.ts.map +1 -1
- package/dist/types/internal-change.js +13 -16
- package/dist/types/internal-change.js.map +1 -1
- package/dist/types/project-info.js +1 -2
- package/dist/types/service.d.ts +1 -1
- package/dist/types/service.d.ts.map +1 -1
- package/dist/types/service.js +1 -2
- package/dist/types/text-file.js +1 -2
- package/dist/utils/constants.js +20 -22
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/indent.js +1 -4
- package/dist/utils/indent.js.map +1 -1
- package/dist/utils/index.d.ts +7 -7
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +7 -17
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/metadata.js +1 -4
- package/dist/utils/metadata.js.map +1 -1
- package/dist/utils/path.js +5 -8
- package/dist/utils/path.js.map +1 -1
- package/dist/utils/pointer.d.ts +1 -1
- package/dist/utils/pointer.d.ts.map +1 -1
- package/dist/utils/pointer.js +1 -4
- package/dist/utils/pointer.js.map +1 -1
- package/dist/utils/range.js +1 -4
- package/dist/utils/range.js.map +1 -1
- package/dist/utils/reference.d.ts +1 -1
- package/dist/utils/reference.d.ts.map +1 -1
- package/dist/utils/reference.js +1 -4
- package/dist/utils/reference.js.map +1 -1
- package/dist/vocabularies.js +1 -4
- package/dist/vocabularies.js.map +1 -1
- package/dist/xml/adapter.d.ts +2 -2
- package/dist/xml/adapter.d.ts.map +1 -1
- package/dist/xml/adapter.js +92 -96
- package/dist/xml/adapter.js.map +1 -1
- package/dist/xml/changes.d.ts +1 -1
- package/dist/xml/changes.d.ts.map +1 -1
- package/dist/xml/changes.js +11 -15
- package/dist/xml/changes.js.map +1 -1
- package/dist/xml/comments.js +3 -6
- package/dist/xml/comments.js.map +1 -1
- package/dist/xml/document.d.ts +1 -1
- package/dist/xml/document.d.ts.map +1 -1
- package/dist/xml/document.js +1 -2
- package/dist/xml/index.d.ts +2 -2
- package/dist/xml/index.d.ts.map +1 -1
- package/dist/xml/index.js +4 -9
- package/dist/xml/index.js.map +1 -1
- package/dist/xml/pointer.js +1 -4
- package/dist/xml/pointer.js.map +1 -1
- package/dist/xml/references.js +15 -18
- package/dist/xml/references.js.map +1 -1
- package/dist/xml/service.d.ts +1 -1
- package/dist/xml/service.d.ts.map +1 -1
- package/dist/xml/service.js +4 -7
- package/dist/xml/service.js.map +1 -1
- package/dist/xml/writer.d.ts +2 -2
- package/dist/xml/writer.d.ts.map +1 -1
- package/dist/xml/writer.js +100 -104
- package/dist/xml/writer.js.map +1 -1
- package/package.json +13 -11
package/dist/cds/document.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
exports.getItems = getItems;
|
|
8
|
-
const node_url_1 = require("node:url");
|
|
9
|
-
const odata_annotation_core_types_1 = require("@sap-ux/odata-annotation-core-types");
|
|
10
|
-
const cds_odata_annotation_converter_1 = require("@sap-ux/cds-odata-annotation-converter");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const comments_1 = require("./comments");
|
|
13
|
-
exports.CDS_DOCUMENT_TYPE = 'document';
|
|
1
|
+
import { fileURLToPath } from 'node:url';
|
|
2
|
+
import { Range } from '@sap-ux/odata-annotation-core-types';
|
|
3
|
+
import { toAnnotationFile, toTargetMap } from '@sap-ux/cds-odata-annotation-converter';
|
|
4
|
+
import { compareByRange, pathFromUri } from '../utils/index.js';
|
|
5
|
+
import { collectComments } from './comments.js';
|
|
6
|
+
export const CDS_DOCUMENT_TYPE = 'document';
|
|
14
7
|
/**
|
|
15
8
|
* Creates CDS document.
|
|
16
9
|
*
|
|
@@ -22,13 +15,13 @@ exports.CDS_DOCUMENT_TYPE = 'document';
|
|
|
22
15
|
* @param metadataCollector - Metadata collector instance.
|
|
23
16
|
* @returns CDS document.
|
|
24
17
|
*/
|
|
25
|
-
function getDocument(serviceName, vocabularyService, facade, fileCache, file, metadataCollector) {
|
|
18
|
+
export function getDocument(serviceName, vocabularyService, facade, fileCache, file, metadataCollector) {
|
|
26
19
|
const comments = getComments(fileCache, file, facade, false);
|
|
27
|
-
const cdsAnnotationFile =
|
|
28
|
-
const tokens = facade.getTokensForUri(
|
|
20
|
+
const cdsAnnotationFile = toTargetMap(facade.blitzIndex.forUri(file.uri), file.uri, vocabularyService, facade);
|
|
21
|
+
const tokens = facade.getTokensForUri(pathFromUri(file.uri));
|
|
29
22
|
const line = fileCache.get(file.uri)?.split('\n').length ?? 0;
|
|
30
23
|
const character = fileCache.get(file.uri)?.split('\n').pop()?.length ?? 0;
|
|
31
|
-
const range =
|
|
24
|
+
const range = Range.create(0, 0, line, character);
|
|
32
25
|
const cdsDocument = {
|
|
33
26
|
type: 'document',
|
|
34
27
|
uri: file.uri,
|
|
@@ -37,7 +30,7 @@ function getDocument(serviceName, vocabularyService, facade, fileCache, file, me
|
|
|
37
30
|
references: cdsAnnotationFile.references,
|
|
38
31
|
targets: [...(cdsAnnotationFile.targetMap || [])].map(([, value]) => value)
|
|
39
32
|
};
|
|
40
|
-
const annotationFile =
|
|
33
|
+
const annotationFile = toAnnotationFile(file.uri, vocabularyService, cdsAnnotationFile, metadataCollector).file;
|
|
41
34
|
filterTargets(serviceName, annotationFile);
|
|
42
35
|
return {
|
|
43
36
|
uri: file.uri,
|
|
@@ -52,8 +45,8 @@ function getComments(fileCache, file, facade, ignoreComments = true) {
|
|
|
52
45
|
if (content === undefined || content === null) {
|
|
53
46
|
throw new Error(`File ${file.uri} not found in cache!`);
|
|
54
47
|
}
|
|
55
|
-
const tokenVector = facade.getTokensForUri(
|
|
56
|
-
return ignoreComments ? [] :
|
|
48
|
+
const tokenVector = facade.getTokensForUri(fileURLToPath(file.uri));
|
|
49
|
+
return ignoreComments ? [] : collectComments(tokenVector);
|
|
57
50
|
}
|
|
58
51
|
/**
|
|
59
52
|
* Creates ghost file document.
|
|
@@ -67,11 +60,11 @@ function getComments(fileCache, file, facade, ignoreComments = true) {
|
|
|
67
60
|
* @param propagatedTargetMap - Propagation map.
|
|
68
61
|
* @returns Ghost file document.
|
|
69
62
|
*/
|
|
70
|
-
function getGhostFileDocument(serviceName, vocabularyService, facade, fileCache, file, metadataCollector, propagatedTargetMap) {
|
|
63
|
+
export function getGhostFileDocument(serviceName, vocabularyService, facade, fileCache, file, metadataCollector, propagatedTargetMap) {
|
|
71
64
|
const comments = getComments(fileCache, file, facade, false);
|
|
72
|
-
const tokens = facade.getTokensForUri(
|
|
73
|
-
const cdsAnnotationFile =
|
|
74
|
-
const annotationFile =
|
|
65
|
+
const tokens = facade.getTokensForUri(pathFromUri(file.uri));
|
|
66
|
+
const cdsAnnotationFile = toTargetMap(facade.blitzIndex.forUri(file.uri), file.uri, vocabularyService, facade);
|
|
67
|
+
const annotationFile = toAnnotationFile(file.uri, vocabularyService, cdsAnnotationFile, metadataCollector, undefined, propagatedTargetMap).file;
|
|
75
68
|
filterTargets(serviceName, annotationFile);
|
|
76
69
|
annotationFile.uri = '!' + annotationFile.uri;
|
|
77
70
|
const cdsDocument = {
|
|
@@ -101,7 +94,7 @@ function filterTargets(serviceName, annotationFile) {
|
|
|
101
94
|
* @param container - Container AST node.
|
|
102
95
|
* @returns Number of children.
|
|
103
96
|
*/
|
|
104
|
-
function getChildCount(container) {
|
|
97
|
+
export function getChildCount(container) {
|
|
105
98
|
return getItems(container).length;
|
|
106
99
|
}
|
|
107
100
|
/**
|
|
@@ -110,13 +103,13 @@ function getChildCount(container) {
|
|
|
110
103
|
* @param container - Container AST node.
|
|
111
104
|
* @returns All child nodes of the container.
|
|
112
105
|
*/
|
|
113
|
-
function getItems(container) {
|
|
106
|
+
export function getItems(container) {
|
|
114
107
|
switch (container.type) {
|
|
115
108
|
case 'target':
|
|
116
109
|
return container.assignments;
|
|
117
110
|
case 'record':
|
|
118
111
|
return container.annotations?.length
|
|
119
|
-
? [...container.properties, ...container.annotations].sort(
|
|
112
|
+
? [...container.properties, ...container.annotations].sort(compareByRange)
|
|
120
113
|
: container.properties;
|
|
121
114
|
case 'annotation-group-items':
|
|
122
115
|
case 'collection':
|
package/dist/cds/document.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/cds/document.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"document.js","sourceRoot":"","sources":["../../src/cds/document.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAGzC,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAU5D,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAGvF,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhE,OAAO,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAGhD,MAAM,CAAC,MAAM,iBAAiB,GAAG,UAAU,CAAC;AAoB5C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,WAAW,CACvB,WAAmB,EACnB,iBAAoC,EACpC,MAAyB,EACzB,SAA8B,EAC9B,IAAc,EACd,iBAAoC;IAEpC,MAAM,QAAQ,GAAG,WAAW,CAAC,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,CAAC;IAC7D,MAAM,iBAAiB,GAAG,WAAW,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,iBAAiB,EAAE,MAAM,CAAC,CAAC;IAC/G,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAC7D,MAAM,IAAI,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC;IAC9D,MAAM,SAAS,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,MAAM,IAAI,CAAC,CAAC;IAC1E,MAAM,KAAK,GAAG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.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AstNode, CDSDocument } from './document';
|
|
2
|
-
import type { CompilerToken } from './cds-compiler-tokens';
|
|
1
|
+
import type { AstNode, CDSDocument } from './document.js';
|
|
2
|
+
import type { CompilerToken } from './cds-compiler-tokens.js';
|
|
3
3
|
/**
|
|
4
4
|
* Finds the indentation level matching to the node of a pointer.
|
|
5
5
|
*
|
package/dist/cds/indent.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../src/cds/indent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"indent.d.ts","sourceRoot":"","sources":["../../src/cds/indent.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAM9D;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,aAAa,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAQjH;AAED;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,IAAI,EAAE,OAAO,GAAG,MAAM,CAKrF"}
|
package/dist/cds/indent.js
CHANGED
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const cds_odata_annotation_converter_1 = require("@sap-ux/cds-odata-annotation-converter");
|
|
7
|
-
const pointer_1 = require("./pointer");
|
|
8
|
-
const cds_compiler_tokens_1 = require("./cds-compiler-tokens");
|
|
9
|
-
const printOptions = { ...odata_annotation_core_1.printOptions, useSnippetSyntax: false };
|
|
1
|
+
import { printOptions as defaultPrintOptions } from '@sap-ux/odata-annotation-core';
|
|
2
|
+
import { TARGET_TYPE } from '@sap-ux/cds-odata-annotation-converter';
|
|
3
|
+
import { getAstNodesFromPointer } from './pointer.js';
|
|
4
|
+
import { createTokenRange, findLastTokenBeforePosition, tokenColumn, tokenLine } from './cds-compiler-tokens.js';
|
|
5
|
+
const printOptions = { ...defaultPrintOptions, useSnippetSyntax: false };
|
|
10
6
|
const ANNOTATE_PATTERN = /annotate/i;
|
|
11
7
|
/**
|
|
12
8
|
* Finds the indentation level matching to the node of a pointer.
|
|
@@ -16,8 +12,8 @@ const ANNOTATE_PATTERN = /annotate/i;
|
|
|
16
12
|
* @param pointer - Pointer to a node for which indentation will be returned.
|
|
17
13
|
* @returns Indentation level of the node matching the pointer.
|
|
18
14
|
*/
|
|
19
|
-
function getIndentLevelFromPointer(document, tokens, pointer) {
|
|
20
|
-
const path =
|
|
15
|
+
export function getIndentLevelFromPointer(document, tokens, pointer) {
|
|
16
|
+
const path = getAstNodesFromPointer(document, pointer).reverse();
|
|
21
17
|
const node = path.shift();
|
|
22
18
|
if (!node) {
|
|
23
19
|
return 0;
|
|
@@ -31,7 +27,7 @@ function getIndentLevelFromPointer(document, tokens, pointer) {
|
|
|
31
27
|
* @param node - Node for which indentation will be returned.
|
|
32
28
|
* @returns Indentation level of the node.
|
|
33
29
|
*/
|
|
34
|
-
function getIndentLevelFromNode(tokens, node) {
|
|
30
|
+
export function getIndentLevelFromNode(tokens, node) {
|
|
35
31
|
const width = printOptions.useTabs ? 1 : printOptions.tabWidth;
|
|
36
32
|
const startCharacter = getLineStartCharacter(node, tokens);
|
|
37
33
|
const indentLevel = startCharacter / width;
|
|
@@ -45,17 +41,17 @@ function getIndentLevelFromNode(tokens, node) {
|
|
|
45
41
|
* @returns column number
|
|
46
42
|
*/
|
|
47
43
|
function getTargetNodeLineStartCharacter(node, tokens) {
|
|
48
|
-
const token =
|
|
44
|
+
const token = findLastTokenBeforePosition(ANNOTATE_PATTERN, tokens, node.range.end);
|
|
49
45
|
if (node.kind === 'element' && node.nameRange) {
|
|
50
|
-
const range = token ?
|
|
46
|
+
const range = token ? createTokenRange(token) : undefined;
|
|
51
47
|
if (token && range?.start?.line === node.nameRange.start.line) {
|
|
52
48
|
// element is in the same line as the annotate statement, so we should use the indent level of the annotate statement
|
|
53
|
-
return
|
|
49
|
+
return tokenColumn(token);
|
|
54
50
|
}
|
|
55
51
|
return node.nameRange.start.character;
|
|
56
52
|
}
|
|
57
53
|
if (token) {
|
|
58
|
-
return
|
|
54
|
+
return tokenColumn(token);
|
|
59
55
|
}
|
|
60
56
|
return 0;
|
|
61
57
|
}
|
|
@@ -63,11 +59,11 @@ function getLineStartCharacter(node, tokens) {
|
|
|
63
59
|
if (!node?.range) {
|
|
64
60
|
return 0;
|
|
65
61
|
}
|
|
66
|
-
if (node.type ===
|
|
62
|
+
if (node.type === TARGET_TYPE && node.range) {
|
|
67
63
|
return getTargetNodeLineStartCharacter(node, tokens);
|
|
68
64
|
}
|
|
69
65
|
const token = findFirstTokenOfLine(tokens, node.range.start.line);
|
|
70
|
-
return token ?
|
|
66
|
+
return token ? tokenColumn(token) : 0;
|
|
71
67
|
}
|
|
72
68
|
function findFirstTokenOfLine(tokens, nodeLine) {
|
|
73
69
|
// use binary search to find a token at the same line
|
|
@@ -76,7 +72,7 @@ function findFirstTokenOfLine(tokens, nodeLine) {
|
|
|
76
72
|
while (left <= right) {
|
|
77
73
|
const middle = Math.floor((left + right) / 2);
|
|
78
74
|
let token = tokens[middle];
|
|
79
|
-
const line =
|
|
75
|
+
const line = tokenLine(token);
|
|
80
76
|
if (line < nodeLine) {
|
|
81
77
|
left = middle + 1;
|
|
82
78
|
}
|
|
@@ -87,7 +83,7 @@ function findFirstTokenOfLine(tokens, nodeLine) {
|
|
|
87
83
|
// we found a token in correct line, search for first token of the line
|
|
88
84
|
let index = middle - 1;
|
|
89
85
|
let previousToken = tokens[index];
|
|
90
|
-
while (previousToken && line ===
|
|
86
|
+
while (previousToken && line === tokenLine(previousToken)) {
|
|
91
87
|
token = previousToken;
|
|
92
88
|
previousToken = tokens[index];
|
|
93
89
|
index--;
|
package/dist/cds/indent.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"indent.js","sourceRoot":"","sources":["../../src/cds/indent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"indent.js","sourceRoot":"","sources":["../../src/cds/indent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,IAAI,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACpF,OAAO,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAIrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAE,gBAAgB,EAAE,2BAA2B,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,0BAA0B,CAAC;AAEjH,MAAM,YAAY,GAA+B,EAAE,GAAG,mBAAmB,EAAE,gBAAgB,EAAE,KAAK,EAAE,CAAC;AACrG,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CAAC,QAAqB,EAAE,MAAuB,EAAE,OAAe;IACrG,MAAM,IAAI,GAAG,sBAAsB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IACjE,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,EAAE,CAAC;IAC1B,IAAI,CAAC,IAAI,EAAE,CAAC;QACR,OAAO,CAAC,CAAC;IACb,CAAC;IAED,OAAO,sBAAsB,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CAAC,MAAuB,EAAE,IAAa;IACzE,MAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,QAAQ,CAAC;IAC/D,MAAM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ux/odata-vocabularies';
|
|
2
|
-
export * from './service';
|
|
3
|
-
export { CDSAnnotationServiceAdapter } from './adapter';
|
|
2
|
+
export * from './service.js';
|
|
3
|
+
export { CDSAnnotationServiceAdapter } from './adapter.js';
|
|
4
4
|
export declare const CDS_VOCABULARY_SERVICE: VocabularyService;
|
|
5
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/cds/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cds/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cds/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,eAAO,MAAM,sBAAsB,mBAA8B,CAAC"}
|
package/dist/cds/index.js
CHANGED
|
@@ -1,23 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.CDS_VOCABULARY_SERVICE = exports.CDSAnnotationServiceAdapter = void 0;
|
|
18
|
-
const odata_vocabularies_1 = require("@sap-ux/odata-vocabularies");
|
|
19
|
-
__exportStar(require("./service"), exports);
|
|
20
|
-
var adapter_1 = require("./adapter");
|
|
21
|
-
Object.defineProperty(exports, "CDSAnnotationServiceAdapter", { enumerable: true, get: function () { return adapter_1.CDSAnnotationServiceAdapter; } });
|
|
22
|
-
exports.CDS_VOCABULARY_SERVICE = new odata_vocabularies_1.VocabularyService(true);
|
|
1
|
+
import { VocabularyService } from '@sap-ux/odata-vocabularies';
|
|
2
|
+
export * from './service.js';
|
|
3
|
+
export { CDSAnnotationServiceAdapter } from './adapter.js';
|
|
4
|
+
export const CDS_VOCABULARY_SERVICE = new VocabularyService(true);
|
|
23
5
|
//# sourceMappingURL=index.js.map
|
package/dist/cds/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cds/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/cds/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAE/D,cAAc,cAAc,CAAC;AAC7B,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAE3D,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,iBAAiB,CAAC,IAAI,CAAC,CAAC"}
|
package/dist/cds/pointer.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/cds/pointer.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACR,cAAc,EAMjB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"pointer.d.ts","sourceRoot":"","sources":["../../src/cds/pointer.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EACR,cAAc,EAMjB,MAAM,qCAAqC,CAAC;AAM7C,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAqc1D;;;;;;GAMG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,EAAE,CA0BxF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC1B,cAAc,EAAE,cAAc,EAC9B,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,WAAW,GACzB;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,sBAAsB,EAAE,OAAO,CAAC;CACnC,CAeA"}
|
package/dist/cds/pointer.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const odata_annotation_core_1 = require("@sap-ux/odata-annotation-core");
|
|
8
|
-
const odata_annotation_core_types_1 = require("@sap-ux/odata-annotation-core-types");
|
|
9
|
-
const error_1 = require("../error");
|
|
10
|
-
const utils_1 = require("../utils");
|
|
1
|
+
import { ReservedProperties, COLLECTION_TYPE, ANNOTATION_GROUP_TYPE, ANNOTATION_TYPE, RECORD_TYPE } from '@sap-ux/cds-annotation-parser';
|
|
2
|
+
import { TARGET_TYPE } from '@sap-ux/cds-odata-annotation-converter';
|
|
3
|
+
import { rangeContained } from '@sap-ux/odata-annotation-core';
|
|
4
|
+
import { ELEMENT_TYPE, Edm, TEXT_TYPE } from '@sap-ux/odata-annotation-core-types';
|
|
5
|
+
import { ApiError } from '../error.js';
|
|
6
|
+
import { PRIMITIVE_TYPE_NAMES } from '../utils/index.js';
|
|
11
7
|
/**
|
|
12
8
|
*
|
|
13
9
|
*/
|
|
@@ -46,7 +42,7 @@ class Visitor {
|
|
|
46
42
|
};
|
|
47
43
|
}
|
|
48
44
|
target(astNode, node, pointer) {
|
|
49
|
-
if (astNode.type ===
|
|
45
|
+
if (astNode.type === TARGET_TYPE) {
|
|
50
46
|
const [segment, indexSegment, ...segments] = pointer;
|
|
51
47
|
const index = Number.parseInt(indexSegment, 10);
|
|
52
48
|
const nextGenericNode = node.terms[index];
|
|
@@ -72,7 +68,7 @@ class Visitor {
|
|
|
72
68
|
return undefined;
|
|
73
69
|
}
|
|
74
70
|
assignment(astNode, node, pointer) {
|
|
75
|
-
if (astNode.type ===
|
|
71
|
+
if (astNode.type === ANNOTATION_TYPE) {
|
|
76
72
|
const result = this.annotation(astNode, node, pointer);
|
|
77
73
|
if (result) {
|
|
78
74
|
return result;
|
|
@@ -81,7 +77,7 @@ class Visitor {
|
|
|
81
77
|
return undefined;
|
|
82
78
|
}
|
|
83
79
|
}
|
|
84
|
-
else if (astNode.type ===
|
|
80
|
+
else if (astNode.type === ANNOTATION_GROUP_TYPE && node.range) {
|
|
85
81
|
const annotationIndex = findNodeIndexByRange(astNode.items.items, node.range);
|
|
86
82
|
const annotation = astNode.items.items[annotationIndex];
|
|
87
83
|
this.inVocabularyGroup = true;
|
|
@@ -132,12 +128,12 @@ class Visitor {
|
|
|
132
128
|
};
|
|
133
129
|
}
|
|
134
130
|
}
|
|
135
|
-
if (segment === 'attributes' && indexSegment ===
|
|
131
|
+
if (segment === 'attributes' && indexSegment === Edm.Qualifier && astNode.qualifier) {
|
|
136
132
|
return {
|
|
137
133
|
pointer: ['qualifier']
|
|
138
134
|
};
|
|
139
135
|
}
|
|
140
|
-
if (segment === 'attributes' && indexSegment ===
|
|
136
|
+
if (segment === 'attributes' && indexSegment === Edm.Term && astNode.term) {
|
|
141
137
|
return {
|
|
142
138
|
pointer: ['term']
|
|
143
139
|
};
|
|
@@ -145,7 +141,7 @@ class Visitor {
|
|
|
145
141
|
return undefined;
|
|
146
142
|
}
|
|
147
143
|
value(astNode, node, pointer) {
|
|
148
|
-
if (astNode.type ===
|
|
144
|
+
if (astNode.type === COLLECTION_TYPE && node.type === ELEMENT_TYPE && node.name === Edm.Collection) {
|
|
149
145
|
const [segment, indexSegment, ...segments] = pointer;
|
|
150
146
|
const index = Number.parseInt(indexSegment, 10);
|
|
151
147
|
if (!Number.isNaN(index)) {
|
|
@@ -167,15 +163,15 @@ class Visitor {
|
|
|
167
163
|
};
|
|
168
164
|
}
|
|
169
165
|
}
|
|
170
|
-
if (astNode.type ===
|
|
166
|
+
if (astNode.type === RECORD_TYPE && node.type === ELEMENT_TYPE && node.name === Edm.Record) {
|
|
171
167
|
const [segment, indexSegment, ...segments] = pointer;
|
|
172
168
|
const index = Number.parseInt(indexSegment, 10);
|
|
173
169
|
if (!Number.isNaN(index)) {
|
|
174
170
|
const nextGenericNode = node.content[index];
|
|
175
|
-
if (segment === 'content' && nextGenericNode.type ===
|
|
171
|
+
if (segment === 'content' && nextGenericNode.type === ELEMENT_TYPE && nextGenericNode.range) {
|
|
176
172
|
const propertyIndex = findNodeIndexByRange(astNode.properties, nextGenericNode.range);
|
|
177
173
|
const property = astNode.properties[propertyIndex];
|
|
178
|
-
if (nextGenericNode.name ===
|
|
174
|
+
if (nextGenericNode.name === Edm.PropertyValue && property) {
|
|
179
175
|
const result = this.recordProperty(property, nextGenericNode, segments);
|
|
180
176
|
if (result) {
|
|
181
177
|
result.pointer = ['properties', propertyIndex.toString(), ...result.pointer];
|
|
@@ -185,7 +181,7 @@ class Visitor {
|
|
|
185
181
|
pointer: ['properties', propertyIndex.toString()]
|
|
186
182
|
};
|
|
187
183
|
}
|
|
188
|
-
if (nextGenericNode.name ===
|
|
184
|
+
if (nextGenericNode.name === Edm.Annotation && astNode.annotations) {
|
|
189
185
|
const annotationIndex = findNodeIndexByRange(astNode.annotations, nextGenericNode.range);
|
|
190
186
|
const annotation = astNode.annotations?.[annotationIndex];
|
|
191
187
|
if (annotation) {
|
|
@@ -201,7 +197,7 @@ class Visitor {
|
|
|
201
197
|
}
|
|
202
198
|
}
|
|
203
199
|
}
|
|
204
|
-
else if (indexSegment ===
|
|
200
|
+
else if (indexSegment === Edm.Type && segment === 'attributes') {
|
|
205
201
|
const recordTypePropIdx = astNode.properties.findIndex((prop) => prop.name.type === 'path' && prop.name.value === '$Type');
|
|
206
202
|
if (recordTypePropIdx > -1) {
|
|
207
203
|
return {
|
|
@@ -210,12 +206,12 @@ class Visitor {
|
|
|
210
206
|
}
|
|
211
207
|
}
|
|
212
208
|
}
|
|
213
|
-
if (astNode.type ===
|
|
209
|
+
if (astNode.type === RECORD_TYPE && node.type === ELEMENT_TYPE && node.name !== Edm.Record) {
|
|
214
210
|
if (node.range) {
|
|
215
|
-
const valuePropertyIndex = astNode.properties.findIndex((prop) => prop.name.value ===
|
|
211
|
+
const valuePropertyIndex = astNode.properties.findIndex((prop) => prop.name.value === ReservedProperties.Value);
|
|
216
212
|
const valueProperty = astNode.properties[valuePropertyIndex];
|
|
217
213
|
if (valueProperty) {
|
|
218
|
-
if (node.name ===
|
|
214
|
+
if (node.name === Edm.Annotation && astNode.annotations) {
|
|
219
215
|
const annotationIndex = findNodeIndexByRange(astNode.annotations, node.range);
|
|
220
216
|
const annotation = astNode.annotations?.[annotationIndex];
|
|
221
217
|
if (annotation) {
|
|
@@ -242,7 +238,7 @@ class Visitor {
|
|
|
242
238
|
}
|
|
243
239
|
}
|
|
244
240
|
}
|
|
245
|
-
if (node.type ===
|
|
241
|
+
if (node.type === ELEMENT_TYPE && PRIMITIVE_TYPE_NAMES.includes(node.name)) {
|
|
246
242
|
return {
|
|
247
243
|
pointer: []
|
|
248
244
|
};
|
|
@@ -250,7 +246,7 @@ class Visitor {
|
|
|
250
246
|
return undefined;
|
|
251
247
|
}
|
|
252
248
|
recordProperty(astNode, node, pointer) {
|
|
253
|
-
if (node.type !==
|
|
249
|
+
if (node.type !== ELEMENT_TYPE || node.name !== Edm.PropertyValue) {
|
|
254
250
|
return undefined;
|
|
255
251
|
}
|
|
256
252
|
const [segment, indexSegment, ...segments] = pointer;
|
|
@@ -260,7 +256,7 @@ class Visitor {
|
|
|
260
256
|
this.containsFlattenedNodes = true;
|
|
261
257
|
}
|
|
262
258
|
if (segment === 'attributes') {
|
|
263
|
-
if (indexSegment ===
|
|
259
|
+
if (indexSegment === Edm.Property) {
|
|
264
260
|
if (this.flattenedSegments.length > 0) {
|
|
265
261
|
return {
|
|
266
262
|
pointer: ['name', 'segments', this.currentFlattenedSegmentIndexInPath.toString()]
|
|
@@ -296,7 +292,7 @@ class Visitor {
|
|
|
296
292
|
return undefined;
|
|
297
293
|
}
|
|
298
294
|
flattenedProperty(astNode, node, pointer) {
|
|
299
|
-
if (node.type !==
|
|
295
|
+
if (node.type !== ELEMENT_TYPE || node.name !== Edm.Record) {
|
|
300
296
|
return undefined;
|
|
301
297
|
}
|
|
302
298
|
const [segment, indexSegment, ...segments] = pointer;
|
|
@@ -317,7 +313,7 @@ class Visitor {
|
|
|
317
313
|
};
|
|
318
314
|
}
|
|
319
315
|
}
|
|
320
|
-
else if (segment === 'attributes' && indexSegment ===
|
|
316
|
+
else if (segment === 'attributes' && indexSegment === Edm.Property) {
|
|
321
317
|
return {
|
|
322
318
|
pointer: ['name', 'segments', this.currentFlattenedSegmentIndexInPath.toString()]
|
|
323
319
|
};
|
|
@@ -325,7 +321,7 @@ class Visitor {
|
|
|
325
321
|
return undefined;
|
|
326
322
|
}
|
|
327
323
|
flattenedAnnotation(astNode, node, pointer) {
|
|
328
|
-
if (node.type !==
|
|
324
|
+
if (node.type !== ELEMENT_TYPE || (node.name !== Edm.Record && node.name !== Edm.Annotation)) {
|
|
329
325
|
return undefined;
|
|
330
326
|
}
|
|
331
327
|
const [segment, indexSegment, ...segments] = pointer;
|
|
@@ -338,10 +334,10 @@ class Visitor {
|
|
|
338
334
|
if (segment.length === 0) {
|
|
339
335
|
return undefined;
|
|
340
336
|
}
|
|
341
|
-
if (node.name ===
|
|
337
|
+
if (node.name === Edm.Record) {
|
|
342
338
|
return this.flattenedAnnotationPropertyValue(astNode, propertyValue, segments);
|
|
343
339
|
}
|
|
344
|
-
else if (node.name ===
|
|
340
|
+
else if (node.name === Edm.Annotation) {
|
|
345
341
|
return this.flattenedAnnotationValue(astNode, propertyValue, segments);
|
|
346
342
|
}
|
|
347
343
|
}
|
|
@@ -349,14 +345,14 @@ class Visitor {
|
|
|
349
345
|
return undefined;
|
|
350
346
|
}
|
|
351
347
|
flattenedAnnotationPropertyValue(astNode, node, pointer) {
|
|
352
|
-
if (node?.type !==
|
|
348
|
+
if (node?.type !== ELEMENT_TYPE || node.name !== Edm.PropertyValue || !astNode.value) {
|
|
353
349
|
return undefined;
|
|
354
350
|
}
|
|
355
351
|
const [segment, indexSegment, ...segments] = pointer;
|
|
356
352
|
const index = Number.parseInt(indexSegment, 10);
|
|
357
353
|
if (!Number.isNaN(index) && segment === 'content') {
|
|
358
354
|
const next = node.content[index];
|
|
359
|
-
if (next?.type !==
|
|
355
|
+
if (next?.type !== ELEMENT_TYPE) {
|
|
360
356
|
return undefined;
|
|
361
357
|
}
|
|
362
358
|
const result = this.flattenedSegments.length > 0
|
|
@@ -367,7 +363,7 @@ class Visitor {
|
|
|
367
363
|
return result;
|
|
368
364
|
}
|
|
369
365
|
}
|
|
370
|
-
else if (segment === 'attributes' && indexSegment ===
|
|
366
|
+
else if (segment === 'attributes' && indexSegment === Edm.Property) {
|
|
371
367
|
return {
|
|
372
368
|
pointer: ['term', 'segments', this.currentFlattenedSegmentIndexInPath.toString()]
|
|
373
369
|
};
|
|
@@ -375,7 +371,7 @@ class Visitor {
|
|
|
375
371
|
return undefined;
|
|
376
372
|
}
|
|
377
373
|
flattenedAnnotationValue(astNode, node, pointer) {
|
|
378
|
-
if (node?.type !==
|
|
374
|
+
if (node?.type !== ELEMENT_TYPE || !astNode.value) {
|
|
379
375
|
return undefined;
|
|
380
376
|
}
|
|
381
377
|
if (pointer.length === 0) {
|
|
@@ -388,7 +384,7 @@ class Visitor {
|
|
|
388
384
|
if (!Number.isNaN(index) && segment === 'content') {
|
|
389
385
|
// value could also be a text node for primitive values
|
|
390
386
|
const next = node.content[index];
|
|
391
|
-
if (next?.type ===
|
|
387
|
+
if (next?.type === TEXT_TYPE) {
|
|
392
388
|
return {
|
|
393
389
|
pointer: ['value']
|
|
394
390
|
};
|
|
@@ -404,7 +400,7 @@ function findNodeIndexByRange(nodes, range) {
|
|
|
404
400
|
if (!node.range) {
|
|
405
401
|
continue;
|
|
406
402
|
}
|
|
407
|
-
if (
|
|
403
|
+
if (rangeContained(node.range, range)) {
|
|
408
404
|
return index;
|
|
409
405
|
}
|
|
410
406
|
}
|
|
@@ -417,7 +413,7 @@ function findNodeIndexByRange(nodes, range) {
|
|
|
417
413
|
* @param pointer - Pointer matching a node in the document.
|
|
418
414
|
* @returns All the nodes in path to the matching node.
|
|
419
415
|
*/
|
|
420
|
-
function getAstNodesFromPointer(document, pointer) {
|
|
416
|
+
export function getAstNodesFromPointer(document, pointer) {
|
|
421
417
|
const [, ...segments] = pointer.split('/');
|
|
422
418
|
const path = [];
|
|
423
419
|
if (segments.length === 0) {
|
|
@@ -447,15 +443,15 @@ function getAstNodesFromPointer(document, pointer) {
|
|
|
447
443
|
* @param cdsDocument - Internal representation root.
|
|
448
444
|
* @returns Converted pointer.
|
|
449
445
|
*/
|
|
450
|
-
function convertPointer(annotationFile, pointer, cdsDocument) {
|
|
446
|
+
export function convertPointer(annotationFile, pointer, cdsDocument) {
|
|
451
447
|
const [prefix, ...segments] = pointer.split('/');
|
|
452
448
|
if (prefix !== '') {
|
|
453
|
-
throw new
|
|
449
|
+
throw new ApiError(`Invalid pointer! ${pointer} must be absolute pointer starting with "/".`);
|
|
454
450
|
}
|
|
455
451
|
const visitor = new Visitor();
|
|
456
452
|
const result = visitor.document(cdsDocument, annotationFile, segments);
|
|
457
453
|
if (result.pointer.length === 0) {
|
|
458
|
-
throw new
|
|
454
|
+
throw new ApiError(`Could not convert pointer! ${pointer} must lead to existing node in annotation file.`);
|
|
459
455
|
}
|
|
460
456
|
return {
|
|
461
457
|
...result,
|