@ckeditor/ckeditor5-dev-docs 34.1.3 → 35.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/lib/build.js +8 -0
- package/lib/buildtypedoc.js +13 -10
- package/lib/validators/fires-validator/index.js +6 -4
- package/lib/validators/index.js +9 -5
- package/lib/validators/link-validator/index.js +3 -3
- package/lib/validators/module-validator/index.js +7 -2
- package/lib/validators/overloads-validator/index.js +5 -2
- package/lib/validators/see-validator/index.js +3 -3
- package/package.json +4 -4
- package/lib/validators/utils/index.js +0 -205
package/lib/build.js
CHANGED
|
@@ -61,4 +61,12 @@ module.exports = async function build( config ) {
|
|
|
61
61
|
* @property {String} [outputPath] A path to the place where extracted doclets will be saved. Is an optional value due to tests.
|
|
62
62
|
*
|
|
63
63
|
* @property {String} [extraPlugins=[]] An array of path to extra plugins that will be added to Typedoc.
|
|
64
|
+
*
|
|
65
|
+
* @property {TypedocValidator} [validatorOptions={}] An optional configuration object for validator.
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @typedef {Object} TypedocValidator
|
|
70
|
+
*
|
|
71
|
+
* @property {Boolean} [enableOverloadValidator=false] If set to `true`, the overloads validator will be enabled.
|
|
64
72
|
*/
|
package/lib/buildtypedoc.js
CHANGED
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
|
|
8
8
|
const glob = require( 'fast-glob' );
|
|
9
9
|
const TypeDoc = require( 'typedoc' );
|
|
10
|
+
const { plugins } = require( '@ckeditor/typedoc-plugins' );
|
|
11
|
+
|
|
10
12
|
const validators = require( './validators' );
|
|
11
13
|
|
|
12
14
|
/**
|
|
@@ -19,6 +21,7 @@ module.exports = async function build( config ) {
|
|
|
19
21
|
const sourceFilePatterns = config.sourceFiles.filter( Boolean );
|
|
20
22
|
const strictMode = config.strict || false;
|
|
21
23
|
const extraPlugins = config.extraPlugins || [];
|
|
24
|
+
const validatorOptions = config.validatorOptions || {};
|
|
22
25
|
|
|
23
26
|
const files = await glob( sourceFilePatterns );
|
|
24
27
|
const typeDoc = new TypeDoc.Application();
|
|
@@ -49,19 +52,19 @@ module.exports = async function build( config ) {
|
|
|
49
52
|
// Fixes `"name": 'default" in the output project.
|
|
50
53
|
'typedoc-plugin-rename-defaults',
|
|
51
54
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
plugins[ 'typedoc-plugin-module-fixer' ],
|
|
56
|
+
plugins[ 'typedoc-plugin-symbol-fixer' ],
|
|
57
|
+
plugins[ 'typedoc-plugin-interface-augmentation-fixer' ],
|
|
58
|
+
plugins[ 'typedoc-plugin-tag-error' ],
|
|
59
|
+
plugins[ 'typedoc-plugin-tag-event' ],
|
|
60
|
+
plugins[ 'typedoc-plugin-tag-observable' ],
|
|
61
|
+
plugins[ 'typedoc-plugin-purge-private-api-docs' ],
|
|
59
62
|
|
|
60
63
|
// The `event-inheritance-fixer` plugin must be loaded after `tag-event` plugin, as it depends on its output.
|
|
61
|
-
|
|
64
|
+
plugins[ 'typedoc-plugin-event-inheritance-fixer' ],
|
|
62
65
|
|
|
63
66
|
// The `event-param-fixer` plugin must be loaded after `tag-event` and `tag-observable` plugins, as it depends on their output.
|
|
64
|
-
|
|
67
|
+
plugins[ 'typedoc-plugin-event-param-fixer' ],
|
|
65
68
|
|
|
66
69
|
...extraPlugins
|
|
67
70
|
]
|
|
@@ -75,7 +78,7 @@ module.exports = async function build( config ) {
|
|
|
75
78
|
throw 'Something went wrong with TypeDoc.';
|
|
76
79
|
}
|
|
77
80
|
|
|
78
|
-
const validationResult = validators.validate( conversionResult, typeDoc );
|
|
81
|
+
const validationResult = validators.validate( conversionResult, typeDoc, validatorOptions );
|
|
79
82
|
|
|
80
83
|
if ( !validationResult && strictMode ) {
|
|
81
84
|
throw 'Something went wrong with TypeDoc.';
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const { ReflectionKind } = require( 'typedoc' );
|
|
9
|
-
const {
|
|
9
|
+
const { utils } = require( '@ckeditor/typedoc-plugins' );
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Validates the output produced by TypeDoc.
|
|
@@ -17,7 +17,9 @@ const { isReflectionValid, isIdentifierValid, isAbsoluteIdentifier } = require(
|
|
|
17
17
|
* @param {Function} onError A callback that is executed when a validation error is detected.
|
|
18
18
|
*/
|
|
19
19
|
module.exports = function validate( project, onError ) {
|
|
20
|
-
const reflections = project
|
|
20
|
+
const reflections = project
|
|
21
|
+
.getReflectionsByKind( ReflectionKind.Class | ReflectionKind.CallSignature )
|
|
22
|
+
.filter( utils.isReflectionValid );
|
|
21
23
|
|
|
22
24
|
for ( const reflection of reflections ) {
|
|
23
25
|
const identifiers = getIdentifiersFromFiresTag( reflection );
|
|
@@ -27,7 +29,7 @@ module.exports = function validate( project, onError ) {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
for ( const identifier of identifiers ) {
|
|
30
|
-
const isValid = isIdentifierValid( reflection, identifier );
|
|
32
|
+
const isValid = utils.isIdentifierValid( reflection, identifier );
|
|
31
33
|
|
|
32
34
|
if ( !isValid ) {
|
|
33
35
|
const eventName = identifier.replace( /^#event:/, '' );
|
|
@@ -46,7 +48,7 @@ function getIdentifiersFromFiresTag( reflection ) {
|
|
|
46
48
|
return reflection.comment.getTags( '@fires' )
|
|
47
49
|
.flatMap( tag => tag.content.map( item => item.text.trim() ) )
|
|
48
50
|
.map( identifier => {
|
|
49
|
-
if ( isAbsoluteIdentifier( identifier ) ) {
|
|
51
|
+
if ( utils.isAbsoluteIdentifier( identifier ) ) {
|
|
50
52
|
return identifier;
|
|
51
53
|
}
|
|
52
54
|
|
package/lib/validators/index.js
CHANGED
|
@@ -5,30 +5,34 @@
|
|
|
5
5
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
|
+
const { utils } = require( '@ckeditor/typedoc-plugins' );
|
|
8
9
|
const seeValidator = require( './see-validator' );
|
|
9
10
|
const linkValidator = require( './link-validator' );
|
|
10
11
|
const firesValidator = require( './fires-validator' );
|
|
11
|
-
const overloadsValidator = require( './overloads-validator' );
|
|
12
12
|
const moduleValidator = require( './module-validator' );
|
|
13
|
-
const
|
|
13
|
+
const overloadsValidator = require( './overloads-validator' );
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Validates the CKEditor 5 documentation.
|
|
17
17
|
*
|
|
18
18
|
* @param {Object} project Generated output from TypeDoc to validate.
|
|
19
19
|
* @param {Object} typeDoc A TypeDoc application instance.
|
|
20
|
+
* @param {TypedocValidator} [options={}] A configuration object.
|
|
20
21
|
* @returns {Boolean}
|
|
21
22
|
*/
|
|
22
23
|
module.exports = {
|
|
23
|
-
validate( project, typeDoc ) {
|
|
24
|
+
validate( project, typeDoc, options = {} ) {
|
|
24
25
|
const validators = [
|
|
25
26
|
seeValidator,
|
|
26
27
|
linkValidator,
|
|
27
28
|
firesValidator,
|
|
28
|
-
overloadsValidator,
|
|
29
29
|
moduleValidator
|
|
30
30
|
];
|
|
31
31
|
|
|
32
|
+
if ( options.enableOverloadValidator ) {
|
|
33
|
+
validators.push( overloadsValidator );
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
typeDoc.logger.info( 'Starting validation...' );
|
|
33
37
|
|
|
34
38
|
// The same error can be reported twice:
|
|
@@ -39,7 +43,7 @@ module.exports = {
|
|
|
39
43
|
|
|
40
44
|
for ( const validator of validators ) {
|
|
41
45
|
validator( project, ( error, reflection ) => {
|
|
42
|
-
const node = getNode( reflection );
|
|
46
|
+
const node = utils.getNode( reflection );
|
|
43
47
|
|
|
44
48
|
errors.set( node, { error, node } );
|
|
45
49
|
} );
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const { ReflectionKind } = require( 'typedoc' );
|
|
9
|
-
const {
|
|
9
|
+
const { utils } = require( '@ckeditor/typedoc-plugins' );
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Validates the output produced by TypeDoc.
|
|
@@ -17,7 +17,7 @@ const { isReflectionValid, isIdentifierValid } = require( '../utils' );
|
|
|
17
17
|
* @param {Function} onError A callback that is executed when a validation error is detected.
|
|
18
18
|
*/
|
|
19
19
|
module.exports = function validate( project, onError ) {
|
|
20
|
-
const reflections = project.getReflectionsByKind( ReflectionKind.All ).filter( isReflectionValid );
|
|
20
|
+
const reflections = project.getReflectionsByKind( ReflectionKind.All ).filter( utils.isReflectionValid );
|
|
21
21
|
|
|
22
22
|
for ( const reflection of reflections ) {
|
|
23
23
|
const identifiers = getIdentifiersFromLinkTag( reflection );
|
|
@@ -27,7 +27,7 @@ module.exports = function validate( project, onError ) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
for ( const identifier of identifiers ) {
|
|
30
|
-
const isValid = isIdentifierValid( reflection, identifier );
|
|
30
|
+
const isValid = utils.isIdentifierValid( reflection, identifier );
|
|
31
31
|
|
|
32
32
|
if ( !isValid ) {
|
|
33
33
|
onError( `Incorrect link: "${ identifier }"`, reflection );
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const { ReflectionKind } = require( 'typedoc' );
|
|
9
|
-
const {
|
|
9
|
+
const { utils } = require( '@ckeditor/typedoc-plugins' );
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Validates the output produced by TypeDoc.
|
|
@@ -27,7 +27,12 @@ module.exports = function validate( project, onError ) {
|
|
|
27
27
|
continue;
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
const filePath = getNode( reflection ).fileName;
|
|
30
|
+
const filePath = utils.getNode( reflection ).fileName;
|
|
31
|
+
|
|
32
|
+
if ( filePath.endsWith( 'src/augmentation.ts' ) ) {
|
|
33
|
+
continue;
|
|
34
|
+
}
|
|
35
|
+
|
|
31
36
|
const expectedFilePath = `ckeditor5-${ packageName }/src/${ moduleName.join( '/' ) }.ts`;
|
|
32
37
|
|
|
33
38
|
if ( !filePath.endsWith( expectedFilePath ) ) {
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const { ReflectionKind } = require( 'typedoc' );
|
|
9
|
-
const {
|
|
9
|
+
const { utils } = require( '@ckeditor/typedoc-plugins' );
|
|
10
|
+
|
|
11
|
+
// The `@label` validator is currently not used.
|
|
12
|
+
// See: https://github.com/ckeditor/ckeditor5/issues/13591.
|
|
10
13
|
|
|
11
14
|
/**
|
|
12
15
|
* Validates the output produced by TypeDoc.
|
|
@@ -20,7 +23,7 @@ const { isReflectionValid } = require( '../utils' );
|
|
|
20
23
|
*/
|
|
21
24
|
module.exports = function validate( project, onError ) {
|
|
22
25
|
const kinds = ReflectionKind.Method | ReflectionKind.Constructor | ReflectionKind.Function;
|
|
23
|
-
const reflections = project.getReflectionsByKind( kinds ).filter( isReflectionValid );
|
|
26
|
+
const reflections = project.getReflectionsByKind( kinds ).filter( utils.isReflectionValid );
|
|
24
27
|
|
|
25
28
|
for ( const reflection of reflections ) {
|
|
26
29
|
// Omit non-overloaded structures.
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
'use strict';
|
|
7
7
|
|
|
8
8
|
const { ReflectionKind } = require( 'typedoc' );
|
|
9
|
-
const {
|
|
9
|
+
const { utils } = require( '@ckeditor/typedoc-plugins' );
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* Validates the output produced by TypeDoc.
|
|
@@ -17,7 +17,7 @@ const { isReflectionValid, isIdentifierValid } = require( '../utils' );
|
|
|
17
17
|
* @param {Function} onError A callback that is executed when a validation error is detected.
|
|
18
18
|
*/
|
|
19
19
|
module.exports = function validate( project, onError ) {
|
|
20
|
-
const reflections = project.getReflectionsByKind( ReflectionKind.All ).filter( isReflectionValid );
|
|
20
|
+
const reflections = project.getReflectionsByKind( ReflectionKind.All ).filter( utils.isReflectionValid );
|
|
21
21
|
|
|
22
22
|
for ( const reflection of reflections ) {
|
|
23
23
|
const identifiers = getIdentifiersFromSeeTag( reflection );
|
|
@@ -27,7 +27,7 @@ module.exports = function validate( project, onError ) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
for ( const identifier of identifiers ) {
|
|
30
|
-
const isValid = isIdentifierValid( reflection, identifier );
|
|
30
|
+
const isValid = utils.isIdentifierValid( reflection, identifier );
|
|
31
31
|
|
|
32
32
|
if ( !isValid ) {
|
|
33
33
|
onError( `Incorrect link: "${ identifier }"`, reflection );
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ckeditor/ckeditor5-dev-docs",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "35.0.0",
|
|
4
4
|
"description": "Tasks used to build and verify the documentation for CKEditor 5.",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@ckeditor/ckeditor5-dev-utils": "^
|
|
9
|
-
"@ckeditor/jsdoc-plugins": "^
|
|
10
|
-
"@ckeditor/typedoc-plugins": "^
|
|
8
|
+
"@ckeditor/ckeditor5-dev-utils": "^35.0.0",
|
|
9
|
+
"@ckeditor/jsdoc-plugins": "^35.0.0",
|
|
10
|
+
"@ckeditor/typedoc-plugins": "^35.0.0",
|
|
11
11
|
"fast-glob": "^3.2.4",
|
|
12
12
|
"fs-extra": "^9.0.0",
|
|
13
13
|
"jsdoc": "ckeditor/jsdoc#fixed-trailing-comment-doclets",
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license Copyright (c) 2003-2023, CKSource Holding sp. z o.o. All rights reserved.
|
|
3
|
-
* For licensing, see LICENSE.md.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
'use strict';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Common utils for TypeDoc validators.
|
|
10
|
-
*/
|
|
11
|
-
module.exports = {
|
|
12
|
-
isReflectionValid,
|
|
13
|
-
isIdentifierValid,
|
|
14
|
-
isAbsoluteIdentifier,
|
|
15
|
-
getNode
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Checks if the reflection can be considered as "valid" (supported). Only reflections that are not nested inside a type are supported.
|
|
20
|
-
*
|
|
21
|
-
* @param {require('typedoc').Reflection} reflection The reflection to check if it is valid.
|
|
22
|
-
* @returns {Boolean}
|
|
23
|
-
*/
|
|
24
|
-
function isReflectionValid( reflection ) {
|
|
25
|
-
if ( reflection.name === '__type' ) {
|
|
26
|
-
return false;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if ( reflection.parent ) {
|
|
30
|
-
return isReflectionValid( reflection.parent );
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return true;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Checks if the name (identifier) that is provided for a tag, points to an existing reflection in the whole project.
|
|
38
|
-
* The identifier can be either a relative or an absolute one.
|
|
39
|
-
*
|
|
40
|
-
* @param {require('typedoc').Reflection} reflection The reflection that contain given identifier.
|
|
41
|
-
* @param {String} identifier An identifier to check.
|
|
42
|
-
* @returns {Boolean}
|
|
43
|
-
*/
|
|
44
|
-
function isIdentifierValid( reflection, identifier ) {
|
|
45
|
-
// We don't want to validate inherited identifiers, because they should be checked only once in the base class.
|
|
46
|
-
// Inherited reflections could contain identifiers (links) that are valid only in the base class and not in the derived class.
|
|
47
|
-
if ( reflection.inheritedFrom ) {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const absoluteIdentifier = isAbsoluteIdentifier( identifier ) ?
|
|
52
|
-
identifier :
|
|
53
|
-
toAbsoluteIdentifier( reflection, identifier );
|
|
54
|
-
|
|
55
|
-
return hasTarget( reflection.project, absoluteIdentifier );
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* Checks if the identifier is an absolute one.
|
|
60
|
-
*
|
|
61
|
-
* @param {String} identifier An identifier to check.
|
|
62
|
-
* @returns {Boolean}
|
|
63
|
-
*/
|
|
64
|
-
function isAbsoluteIdentifier( identifier ) {
|
|
65
|
-
return identifier.startsWith( 'module:' );
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Converts a relative identifier into an absolute one.
|
|
70
|
-
*
|
|
71
|
-
* @param {require('typedoc').Reflection} reflection The reflection that contain given identifier.
|
|
72
|
-
* @param {String} identifier An identifier to convert.
|
|
73
|
-
* @returns {String}
|
|
74
|
-
*/
|
|
75
|
-
function toAbsoluteIdentifier( reflection, identifier ) {
|
|
76
|
-
const separator = identifier[ 0 ];
|
|
77
|
-
const parts = getLongNameParts( reflection );
|
|
78
|
-
|
|
79
|
-
return separator === '~' ?
|
|
80
|
-
'module:' + parts[ 0 ] + identifier :
|
|
81
|
-
'module:' + parts[ 0 ] + '~' + parts[ 1 ] + identifier;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Returns a longname for a reflection, divided into separate parts.
|
|
86
|
-
*
|
|
87
|
-
* @param {require('typedoc').Reflection} reflection A reflection for which we want to get its longname.
|
|
88
|
-
* @returns {Array.<String>}
|
|
89
|
-
*/
|
|
90
|
-
function getLongNameParts( reflection ) {
|
|
91
|
-
// Kinds of reflection that affect the longname format.
|
|
92
|
-
const kinds = [
|
|
93
|
-
'Module',
|
|
94
|
-
'Class',
|
|
95
|
-
'Function',
|
|
96
|
-
'Interface',
|
|
97
|
-
'Type alias',
|
|
98
|
-
'Accessor',
|
|
99
|
-
'Variable',
|
|
100
|
-
'Method',
|
|
101
|
-
'Property',
|
|
102
|
-
'Event'
|
|
103
|
-
];
|
|
104
|
-
|
|
105
|
-
const parts = [];
|
|
106
|
-
|
|
107
|
-
while ( reflection ) {
|
|
108
|
-
if ( kinds.includes( reflection.kindString ) ) {
|
|
109
|
-
parts.unshift( reflection.name );
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
reflection = reflection.parent;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return parts;
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Returns the TypeScript node from the reflection.
|
|
120
|
-
*
|
|
121
|
-
* @param {require('typedoc').Reflection} reflection A reflection for which we want to get its TypeScript node.
|
|
122
|
-
* @returns {Object}
|
|
123
|
-
*/
|
|
124
|
-
function getNode( reflection ) {
|
|
125
|
-
let symbol = reflection.project.getSymbolFromReflection( reflection );
|
|
126
|
-
let declarationIndex = 0;
|
|
127
|
-
|
|
128
|
-
if ( !symbol ) {
|
|
129
|
-
// The TypeDoc project does not store symbols for signatures. To get the TypeScript node from a signature, we need to get the
|
|
130
|
-
// symbol from its parent, which contains all nodes for each signature.
|
|
131
|
-
symbol = reflection.project.getSymbolFromReflection( reflection.parent );
|
|
132
|
-
declarationIndex = reflection.parent.signatures ? reflection.parent.signatures.indexOf( reflection ) : 0;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return symbol.declarations[ declarationIndex ];
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Checks if the provided identifier targets an existing reflection within the whole project.
|
|
140
|
-
*
|
|
141
|
-
* @param {require('typedoc').ProjectReflection} project The project reflection.
|
|
142
|
-
* @param {String} identifier The absolute identifier to locate the target reflection.
|
|
143
|
-
* @returns {Boolean}
|
|
144
|
-
*/
|
|
145
|
-
function hasTarget( project, identifier ) {
|
|
146
|
-
const parts = identifier
|
|
147
|
-
// Remove leading "module:" prefix from the doclet longname.
|
|
148
|
-
.substring( 'module:'.length )
|
|
149
|
-
// Then, split the rest of the longname into separate parts.
|
|
150
|
-
.split( /#|~|\./ );
|
|
151
|
-
|
|
152
|
-
// The last part of the longname may contain a colon, which can be either a part of the event name, or it indicates that the name
|
|
153
|
-
// targets a labeled signature.
|
|
154
|
-
const lastPart = parts.pop();
|
|
155
|
-
const [ lastPartName, lastPartLabel ] = lastPart.split( ':' );
|
|
156
|
-
|
|
157
|
-
const isIdentifierEvent = lastPart.startsWith( 'event:' );
|
|
158
|
-
const isIdentifierLabeledSignature = !isIdentifierEvent && lastPart.includes( ':' );
|
|
159
|
-
|
|
160
|
-
if ( isIdentifierLabeledSignature ) {
|
|
161
|
-
// If the identifier is a labeled signature, just use the method/function name and the labeled signature will be searched later.
|
|
162
|
-
parts.push( lastPartName );
|
|
163
|
-
} else {
|
|
164
|
-
// Otherwise, restore the original identifier part.
|
|
165
|
-
parts.push( lastPart );
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
const targetReflection = project.getChildByName( parts );
|
|
169
|
-
|
|
170
|
-
if ( !targetReflection ) {
|
|
171
|
-
return false;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
// Now, when the target reflection is found, do some checks whether it matches the identifier.
|
|
175
|
-
// (1) Check if the labeled signature targets an existing signature.
|
|
176
|
-
if ( isIdentifierLabeledSignature ) {
|
|
177
|
-
if ( !targetReflection.signatures ) {
|
|
178
|
-
return false;
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return targetReflection.signatures.some( signature => {
|
|
182
|
-
if ( !signature.comment ) {
|
|
183
|
-
return false;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
const labelTag = signature.comment.getTag( '@label' );
|
|
187
|
-
|
|
188
|
-
if ( !labelTag ) {
|
|
189
|
-
return false;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
return labelTag.content[ 0 ].text === lastPartLabel;
|
|
193
|
-
} );
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
const isIdentifierStatic = identifier.includes( '.' );
|
|
197
|
-
const isTargetReflectionStatic = Boolean( targetReflection.flags && targetReflection.flags.isStatic );
|
|
198
|
-
|
|
199
|
-
// (2) Check if the static/non-static reflection flag matches the separator used in the identifier.
|
|
200
|
-
if ( isIdentifierStatic !== isTargetReflectionStatic ) {
|
|
201
|
-
return false;
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
return true;
|
|
205
|
-
}
|