@reqlan/language 1.9.5 → 1.9.7
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/README.md +14 -0
- package/README.template.md +2 -0
- package/out/file-path-rewrite.d.ts +3 -0
- package/out/file-path-rewrite.js +1 -0
- package/out/file-path-rewrite.js.map +1 -1
- package/out/index.d.ts +2 -1
- package/out/index.js +2 -1
- package/out/index.js.map +1 -1
- package/out/reqlan-code-action-provider.d.ts +1 -0
- package/out/reqlan-code-action-provider.js +12 -21
- package/out/reqlan-code-action-provider.js.map +1 -1
- package/out/reqlan-comment-diagnostics.d.ts +11 -0
- package/out/reqlan-comment-diagnostics.js +81 -11
- package/out/reqlan-comment-diagnostics.js.map +1 -1
- package/out/reqlan-comment-rename.d.ts +1 -0
- package/out/reqlan-comment-rename.js.map +1 -1
- package/out/reqlan-document-builder.d.ts +9 -0
- package/out/reqlan-document-builder.js +26 -0
- package/out/reqlan-document-builder.js.map +1 -0
- package/out/reqlan-document-link-provider.d.ts +3 -1
- package/out/reqlan-document-link-provider.js +6 -1
- package/out/reqlan-document-link-provider.js.map +1 -1
- package/out/reqlan-idea-move-imports.d.ts +24 -0
- package/out/reqlan-idea-move-imports.js +309 -0
- package/out/reqlan-idea-move-imports.js.map +1 -0
- package/out/reqlan-idea-refactor.d.ts +15 -4
- package/out/reqlan-idea-refactor.js +106 -14
- package/out/reqlan-idea-refactor.js.map +1 -1
- package/out/reqlan-import-edits.d.ts +1 -0
- package/out/reqlan-import-edits.js +8 -0
- package/out/reqlan-import-edits.js.map +1 -1
- package/out/reqlan-module.js +3 -1
- package/out/reqlan-module.js.map +1 -1
- package/out/reqlan-path-references.js +8 -2
- package/out/reqlan-path-references.js.map +1 -1
- package/out/reqlan-validator.d.ts +5 -0
- package/out/reqlan-validator.js +17 -0
- package/out/reqlan-validator.js.map +1 -1
- package/package.json +1 -1
- package/src/file-path-rewrite.ts +3 -0
- package/src/index.ts +4 -0
- package/src/reqlan-code-action-provider.ts +12 -24
- package/src/reqlan-comment-diagnostics.ts +108 -11
- package/src/reqlan-comment-rename.ts +1 -0
- package/src/reqlan-document-builder.ts +35 -0
- package/src/reqlan-document-link-provider.ts +18 -3
- package/src/reqlan-idea-move-imports.ts +398 -0
- package/src/reqlan-idea-refactor.ts +152 -15
- package/src/reqlan-import-edits.ts +9 -0
- package/src/reqlan-module.ts +3 -1
- package/src/reqlan-path-references.ts +9 -2
- package/src/reqlan-validator.ts +23 -0
|
@@ -70,6 +70,7 @@ export function findCommentPathReferencesInText(text, lineOffset = 0) {
|
|
|
70
70
|
const startPos = offsetToPosition(text, absoluteStart);
|
|
71
71
|
references.push({
|
|
72
72
|
path: commentRef.path,
|
|
73
|
+
idea: commentRef.idea,
|
|
73
74
|
range: {
|
|
74
75
|
start: startPos,
|
|
75
76
|
end: { line: startPos.line, character: startPos.character + quoted.length }
|
|
@@ -79,9 +80,14 @@ export function findCommentPathReferencesInText(text, lineOffset = 0) {
|
|
|
79
80
|
return references;
|
|
80
81
|
}
|
|
81
82
|
export function findPathReferencesInMovedFile(text, isRqFile) {
|
|
83
|
+
const commentPaths = findCommentPathReferencesInText(text);
|
|
82
84
|
const references = isRqFile
|
|
83
|
-
? [
|
|
84
|
-
|
|
85
|
+
? [
|
|
86
|
+
...findImportPathReferencesInText(text),
|
|
87
|
+
...findEmbeddedPathReferencesInText(text),
|
|
88
|
+
...commentPaths
|
|
89
|
+
]
|
|
90
|
+
: commentPaths;
|
|
85
91
|
return dedupePathReferences(references);
|
|
86
92
|
}
|
|
87
93
|
function dedupePathReferences(references) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reqlan-path-references.js","sourceRoot":"","sources":["../src/reqlan-path-references.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reqlan-path-references.js","sourceRoot":"","sources":["../src/reqlan-path-references.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAA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GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,KAAK,IAAI,KAAK,GAAG,CAAC,EAAE,KAAK,GAAG,SAAS,EAAE,KAAK,EAAE,EAAE,CAAC;QAC7C,MAAM,IAAI,KAAK,CAAC,KAAK,CAAE,CAAC,MAAM,GAAG,CAAC,CAAC;IACvC,CAAC;IACD,OAAO,MAAM,CAAC;AAClB,CAAC;AAED,SAAS,oBAAoB,CAAC,IAAY,EAAE,QAAwB;IAChE,OAAO,gBAAgB,CAAC,IAAI,EAAE,QAAQ,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC;AACtE,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,MAAc;IAClD,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IACrC,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACpC,OAAO;QACH,IAAI,EAAE,KAAK,CAAC,MAAM,GAAG,CAAC;QACtB,SAAS,EAAE,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAE,CAAC,MAAM;KAC7C,CAAC;AACN,CAAC"}
|
|
@@ -7,6 +7,8 @@ import type { ReqlanServices } from './reqlan-module.js';
|
|
|
7
7
|
* rq:["../../../reqlan rq/language/imports.rq".import_error_recovery]
|
|
8
8
|
* rq:["../../../reqlan rq/language/imports.rq".import_tokenisation]
|
|
9
9
|
* rq:["../../../reqlan rq/language/syntax.rq".no_name_idea_safe_warning]
|
|
10
|
+
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference_resolution_error]
|
|
11
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
10
12
|
*/
|
|
11
13
|
export declare function registerValidationChecks(services: ReqlanServices): void;
|
|
12
14
|
/**
|
|
@@ -15,6 +17,8 @@ export declare function registerValidationChecks(services: ReqlanServices): void
|
|
|
15
17
|
* rq:["../../../reqlan rq/language/imports.rq".import_error_recovery]
|
|
16
18
|
* rq:["../../../reqlan rq/language/imports.rq".import_tokenisation]
|
|
17
19
|
* rq:["../../../reqlan rq/language/syntax.rq".no_name_idea_safe_warning]
|
|
20
|
+
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference_resolution_error]
|
|
21
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
18
22
|
*/
|
|
19
23
|
export declare class ReqlanValidator {
|
|
20
24
|
private readonly services;
|
|
@@ -43,5 +47,6 @@ export declare class ReqlanValidator {
|
|
|
43
47
|
*/
|
|
44
48
|
checkImportTargets(model: Model, accept: ValidationAcceptor): void;
|
|
45
49
|
checkFileReferenceTargets(model: Model, accept: ValidationAcceptor): void;
|
|
50
|
+
checkCommentReferences(model: Model, accept: ValidationAcceptor): void;
|
|
46
51
|
checkWildcardReferences(model: Model, accept: ValidationAcceptor): void;
|
|
47
52
|
}
|
package/out/reqlan-validator.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { AstUtils } from 'langium';
|
|
2
2
|
import { isFromImport, isIdea, isInvalidFromImport, isModel, isOneLinerIdea, isWildcardReference } from './generated/ast.js';
|
|
3
|
+
import { collectCommentReferenceIssues } from './reqlan-comment-diagnostics.js';
|
|
3
4
|
import { collectFileLinks, fileLinkTargetIssueMessage } from './reqlan-file-link-resolver.js';
|
|
4
5
|
import { importBindings, importPathOf, isWellFormedFromImport } from './reqlan-import-bindings.js';
|
|
5
6
|
import { isResolvableImportPath } from './reqlan-imports.js';
|
|
@@ -12,6 +13,8 @@ import { resolveWildcardReferenceMatches, parseWildcardPathPattern, wildcardRefe
|
|
|
12
13
|
* rq:["../../../reqlan rq/language/imports.rq".import_error_recovery]
|
|
13
14
|
* rq:["../../../reqlan rq/language/imports.rq".import_tokenisation]
|
|
14
15
|
* rq:["../../../reqlan rq/language/syntax.rq".no_name_idea_safe_warning]
|
|
16
|
+
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference_resolution_error]
|
|
17
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
15
18
|
*/
|
|
16
19
|
export function registerValidationChecks(services) {
|
|
17
20
|
const registry = services.validation.ValidationRegistry;
|
|
@@ -28,6 +31,8 @@ export function registerValidationChecks(services) {
|
|
|
28
31
|
* rq:["../../../reqlan rq/language/imports.rq".import_error_recovery]
|
|
29
32
|
* rq:["../../../reqlan rq/language/imports.rq".import_tokenisation]
|
|
30
33
|
* rq:["../../../reqlan rq/language/syntax.rq".no_name_idea_safe_warning]
|
|
34
|
+
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference_resolution_error]
|
|
35
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
31
36
|
*/
|
|
32
37
|
export class ReqlanValidator {
|
|
33
38
|
constructor(services) {
|
|
@@ -39,6 +44,7 @@ export class ReqlanValidator {
|
|
|
39
44
|
this.checkImportSyntax(model, accept);
|
|
40
45
|
this.checkImportTargets(model, accept);
|
|
41
46
|
this.checkFileReferenceTargets(model, accept);
|
|
47
|
+
this.checkCommentReferences(model, accept);
|
|
42
48
|
this.checkWildcardReferences(model, accept);
|
|
43
49
|
}
|
|
44
50
|
/**
|
|
@@ -158,6 +164,17 @@ export class ReqlanValidator {
|
|
|
158
164
|
});
|
|
159
165
|
}
|
|
160
166
|
}
|
|
167
|
+
checkCommentReferences(model, accept) {
|
|
168
|
+
const document = AstUtils.getDocument(model);
|
|
169
|
+
const { shared } = this.services;
|
|
170
|
+
for (const issue of collectCommentReferenceIssues(document, shared.workspace.LangiumDocuments, shared.workspace.FileSystemProvider, pathResolveContextFromServices(this.services))) {
|
|
171
|
+
accept('error', issue.message, {
|
|
172
|
+
node: model,
|
|
173
|
+
range: issue.range,
|
|
174
|
+
code: issue.code
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
161
178
|
checkWildcardReferences(model, accept) {
|
|
162
179
|
const { shared } = this.services;
|
|
163
180
|
const context = pathResolveContextFromServices(this.services);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reqlan-validator.js","sourceRoot":"","sources":["../src/reqlan-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EACH,YAAY,EACZ,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,mBAAmB,EAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACH,gBAAgB,EAChB,0BAA0B,EAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,cAAc,EACd,YAAY,EACZ,sBAAsB,EACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAE7D,OAAO,EAAE,8BAA8B,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,EACH,+BAA+B,EAC/B,wBAAwB,EACxB,sBAAsB,EACzB,MAAM,8BAA8B,CAAC;AAEtC
|
|
1
|
+
{"version":3,"file":"reqlan-validator.js","sourceRoot":"","sources":["../src/reqlan-validator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,OAAO,EACH,YAAY,EACZ,MAAM,EACN,mBAAmB,EACnB,OAAO,EACP,cAAc,EACd,mBAAmB,EAGtB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,6BAA6B,EAAE,MAAM,iCAAiC,CAAC;AAChF,OAAO,EACH,gBAAgB,EAChB,0BAA0B,EAC7B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACH,cAAc,EACd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AAC;QAC9D,KAAK,MAAM,IAAI,IAAI,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;gBAC7B,SAAS;YACb,CAAC;YACD,MAAM,IAAI,GAAG,wBAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxD,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,CAAC;gBACf,MAAM,CAAC,SAAS,EAAE,iCAAiC,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;gBACxF,SAAS;YACb,CAAC;YACD,MAAM,OAAO,GAAG,+BAA+B,CAC3C,IAAI,EACJ,MAAM,CAAC,SAAS,CAAC,gBAAgB,EACjC,OAAO,CACV,CAAC;YACF,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACvB,MAAM,CACF,SAAS,EACT,sCAAsC,sBAAsB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,IAAI,EACxF,EAAE,IAAI,EAAE,CACX,CAAC;YACN,CAAC;QACL,CAAC;IACL,CAAC;CACJ;AAID,SAAS,kBAAkB,CAAC,IAAY;IACpC,OAAO,+BAA+B,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACtD,CAAC"}
|
package/package.json
CHANGED
package/src/file-path-rewrite.ts
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
* rq:["../../../reqlan rq/language/imports.rq".configuration_import_root_alias]
|
|
6
6
|
* rq:["../../../reqlan rq/extension/features-mutation-hooks.rq".move_file]
|
|
7
7
|
* rq:["../../../reqlan rq/extension/refactor_support.rq".refactor_file_moves]
|
|
8
|
+
* rq:["../../../reqlan rq/extension/refactor_support.rq".comment_reference_refactor_support]
|
|
8
9
|
*/
|
|
9
10
|
import { URI, UriUtils } from 'langium';
|
|
10
11
|
import type { Range } from 'vscode-languageserver';
|
|
@@ -18,6 +19,8 @@ import {
|
|
|
18
19
|
export interface PathReference {
|
|
19
20
|
path: string;
|
|
20
21
|
range: Range;
|
|
22
|
+
/** Idea name when this path came from `rq:["path".idea]`. */
|
|
23
|
+
idea?: string;
|
|
21
24
|
}
|
|
22
25
|
|
|
23
26
|
export interface PathRewriteEdit {
|
package/src/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './reqlan-module.js';
|
|
|
2
2
|
export * from './reqlan-parse-budget.js';
|
|
3
3
|
export { ReqlanAsyncParser, resolveParseWorkerPath } from './reqlan-async-parser.js';
|
|
4
4
|
export { ReqlanLangiumDocumentFactory } from './reqlan-document-factory.js';
|
|
5
|
+
export { ReqlanDocumentBuilder } from './reqlan-document-builder.js';
|
|
5
6
|
export * from './reqlan-validator.js';
|
|
6
7
|
export * from './reqlan-comment-resolver.js';
|
|
7
8
|
export * from './reqlan-comment-diagnostics.js';
|
|
@@ -17,7 +18,10 @@ export {
|
|
|
17
18
|
isRefactorIdeaDeclaration,
|
|
18
19
|
planIdeaDeleteEdits,
|
|
19
20
|
planIdeaMoveEdits,
|
|
21
|
+
findIdeaDeclarationAtRange,
|
|
22
|
+
listRefactorIdeaDeclarations,
|
|
20
23
|
type DocumentTextEdits,
|
|
24
|
+
type PlanIdeaMoveInput,
|
|
21
25
|
type RefactorIdeaDeclaration
|
|
22
26
|
} from './reqlan-idea-refactor.js';
|
|
23
27
|
export * from './reqlan-path-resolve.js';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* rq:["../../../reqlan rq/extension/features-commands.rq".file_based_code_actions]
|
|
9
9
|
*/
|
|
10
10
|
import type { LangiumDocument, URI } from 'langium';
|
|
11
|
-
import {
|
|
11
|
+
import { DocumentValidator, URI as UriCtor, UriUtils } from 'langium';
|
|
12
12
|
import type { CodeActionParams, Command, Diagnostic } from 'vscode-languageserver';
|
|
13
13
|
import { CodeActionKind } from 'vscode-languageserver';
|
|
14
14
|
import type { CodeActionProvider } from 'langium/lsp';
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
buildFromImportEdit,
|
|
24
24
|
relativeRqImportPath
|
|
25
25
|
} from './reqlan-import-edits.js';
|
|
26
|
-
import { isRefactorIdeaDeclaration } from './reqlan-idea-refactor.js';
|
|
26
|
+
import { isRefactorIdeaDeclaration, findIdeaDeclarationAtRange } from './reqlan-idea-refactor.js';
|
|
27
27
|
import type { ReqlanServices } from './reqlan-module.js';
|
|
28
28
|
import {
|
|
29
29
|
sharedNameCatalog,
|
|
@@ -37,6 +37,7 @@ export const REQLAN_IMPORT_ERROR_CREATE_COMMAND = 'reqlan.importError.createFile
|
|
|
37
37
|
export const REQLAN_SEARCH_REFERENCE_COMMAND = 'reqlan.searchReference';
|
|
38
38
|
export const REQLAN_REFACTOR_DELETE_IDEA_COMMAND = 'reqlan.refactor.deleteIdea';
|
|
39
39
|
export const REQLAN_REFACTOR_MOVE_IDEA_COMMAND = 'reqlan.refactor.moveIdea';
|
|
40
|
+
export const REQLAN_REFACTOR_MOVE_IDEA_CONTENT_COMMAND = 'reqlan.refactor.moveIdeaContent';
|
|
40
41
|
export const REQLAN_BARREL_PAGE_COMMAND = 'reqlan.barrelPage';
|
|
41
42
|
/** Source-action kind for whole-file barrel page. */
|
|
42
43
|
export const REQLAN_BARREL_PAGE_KIND = `${CodeActionKind.Source}.barrelPage`;
|
|
@@ -163,6 +164,15 @@ export class ReqlanCodeActionProvider implements CodeActionProvider {
|
|
|
163
164
|
command: REQLAN_REFACTOR_MOVE_IDEA_COMMAND,
|
|
164
165
|
arguments: [args]
|
|
165
166
|
}
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
title: `Move idea '${idea.name}' content to another file…`,
|
|
170
|
+
kind: CodeActionKind.Refactor,
|
|
171
|
+
command: {
|
|
172
|
+
title: `Move idea '${idea.name}' content`,
|
|
173
|
+
command: REQLAN_REFACTOR_MOVE_IDEA_CONTENT_COMMAND,
|
|
174
|
+
arguments: [args]
|
|
175
|
+
}
|
|
166
176
|
}
|
|
167
177
|
];
|
|
168
178
|
}
|
|
@@ -468,25 +478,3 @@ export function collectImportErrorCodeActions(
|
|
|
468
478
|
export function isModelDocument(document: LangiumDocument): document is LangiumDocument<Model> {
|
|
469
479
|
return isModel(document.parseResult.value);
|
|
470
480
|
}
|
|
471
|
-
|
|
472
|
-
function findIdeaDeclarationAtRange(document: LangiumDocument, range: Diagnostic['range']) {
|
|
473
|
-
const offset = document.textDocument.offsetAt(range.start);
|
|
474
|
-
for (const node of AstUtils.streamAst(document.parseResult.value)) {
|
|
475
|
-
if (!isRefactorIdeaDeclaration(node) || !node.$cstNode) {
|
|
476
|
-
continue;
|
|
477
|
-
}
|
|
478
|
-
const start = document.textDocument.offsetAt(node.$cstNode.range.start);
|
|
479
|
-
const end = document.textDocument.offsetAt(node.$cstNode.range.end);
|
|
480
|
-
if (offset >= start && offset <= end) {
|
|
481
|
-
return node;
|
|
482
|
-
}
|
|
483
|
-
// Also match when the selection is exactly on the name token line.
|
|
484
|
-
if (
|
|
485
|
-
range.start.line === node.$cstNode.range.start.line
|
|
486
|
-
&& range.start.character <= (node.name?.length ?? 0) + 1
|
|
487
|
-
) {
|
|
488
|
-
return node;
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
return undefined;
|
|
492
|
-
}
|
|
@@ -1,18 +1,26 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Diagnostics and document-link targets for `rq:[…]` comment references.
|
|
3
|
+
* One presentation supplies both, so the clickable link and the error underline stay in sync.
|
|
3
4
|
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference_resolution_error]
|
|
4
5
|
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference]
|
|
5
6
|
* rq:["../../../reqlan rq/language/syntax.rq".comment_reference_ignore]
|
|
7
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
6
8
|
*/
|
|
7
9
|
import type { FileSystemProvider, LangiumDocument, LangiumDocuments } from 'langium';
|
|
10
|
+
import { AstUtils, URI } from 'langium';
|
|
8
11
|
import type { Range } from 'vscode-languageserver';
|
|
9
12
|
import {
|
|
10
13
|
findCommentReferencesInText,
|
|
11
14
|
resolveCommentReferenceIdea,
|
|
15
|
+
resolveFileUri,
|
|
12
16
|
type EmbeddedCommentReference
|
|
13
17
|
} from './reqlan-comment-resolver.js';
|
|
14
18
|
import { findRqIgnoreErrorTargetLines } from './reqlan-ignore-error.js';
|
|
15
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
findImportedDocument,
|
|
21
|
+
isResolvableImportPath,
|
|
22
|
+
resolveImportCandidateUris
|
|
23
|
+
} from './reqlan-imports.js';
|
|
16
24
|
import type { PathResolveContext } from './reqlan-path-resolve.js';
|
|
17
25
|
|
|
18
26
|
export const COMMENT_REFERENCE_MISSING_FILE = 'comment-reference-missing-file';
|
|
@@ -22,11 +30,13 @@ export interface CommentReferenceFileHost {
|
|
|
22
30
|
exists(absolutePath: string): boolean;
|
|
23
31
|
declaresIdea?(absolutePath: string, idea: string): boolean;
|
|
24
32
|
workspaceDeclaresIdea?(idea: string): boolean;
|
|
33
|
+
resolveWorkspaceIdea?(idea: string): string | undefined;
|
|
25
34
|
}
|
|
26
35
|
|
|
27
36
|
export interface CommentReferenceLink {
|
|
28
37
|
range: Range;
|
|
29
38
|
targetPath: string;
|
|
39
|
+
targetUri?: string;
|
|
30
40
|
idea: string;
|
|
31
41
|
}
|
|
32
42
|
|
|
@@ -49,6 +59,10 @@ export function commentReferenceMissingIdeaMessage(idea: string): string {
|
|
|
49
59
|
return `Could not resolve comment reference to idea '${idea}'.`;
|
|
50
60
|
}
|
|
51
61
|
|
|
62
|
+
export function isCommentReferenceDiagnosticCode(code: unknown): boolean {
|
|
63
|
+
return code === COMMENT_REFERENCE_MISSING_FILE || code === COMMENT_REFERENCE_MISSING_IDEA;
|
|
64
|
+
}
|
|
65
|
+
|
|
52
66
|
export function presentCommentReferences(
|
|
53
67
|
text: string,
|
|
54
68
|
sourceDir: string,
|
|
@@ -61,10 +75,13 @@ export function presentCommentReferences(
|
|
|
61
75
|
for (const reference of findCommentReferencesInText(text)) {
|
|
62
76
|
const issue = commentReferenceFileIssue(reference, sourceDir, host, resolvePath);
|
|
63
77
|
if (!issue) {
|
|
64
|
-
|
|
78
|
+
const targetPath = reference.path
|
|
79
|
+
? resolvePath(sourceDir, reference.path)
|
|
80
|
+
: host.resolveWorkspaceIdea?.(reference.idea);
|
|
81
|
+
if (targetPath) {
|
|
65
82
|
links.push({
|
|
66
83
|
range: reference.range,
|
|
67
|
-
targetPath
|
|
84
|
+
targetPath,
|
|
68
85
|
idea: reference.idea
|
|
69
86
|
});
|
|
70
87
|
}
|
|
@@ -78,30 +95,75 @@ export function presentCommentReferences(
|
|
|
78
95
|
return { links, diagnostics };
|
|
79
96
|
}
|
|
80
97
|
|
|
81
|
-
export function
|
|
98
|
+
export function presentCommentReferencesForDocument(
|
|
82
99
|
document: LangiumDocument,
|
|
83
100
|
documents: LangiumDocuments,
|
|
84
101
|
fileSystem?: FileSystemProvider,
|
|
85
102
|
context?: PathResolveContext
|
|
86
|
-
):
|
|
103
|
+
): CommentReferencePresentation {
|
|
87
104
|
const text = document.textDocument.getText();
|
|
88
105
|
const ignoredLines = findRqIgnoreErrorTargetLines(text);
|
|
106
|
+
const links: CommentReferenceLink[] = [];
|
|
89
107
|
const diagnostics: CommentReferenceDiagnostic[] = [];
|
|
90
108
|
for (const reference of findCommentReferencesInText(text)) {
|
|
109
|
+
if (!isSlashOrBlockCommentReference(text, reference.range)) {
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
const issue = commentReferenceLangiumIssue(reference, document, documents, fileSystem, context);
|
|
113
|
+
if (!issue) {
|
|
114
|
+
const link = commentReferenceLangiumLink(reference, document, documents, context);
|
|
115
|
+
if (link) {
|
|
116
|
+
links.push(link);
|
|
117
|
+
}
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
91
120
|
if (ignoredLines.has(reference.range.start.line)) {
|
|
92
121
|
continue;
|
|
93
122
|
}
|
|
94
|
-
|
|
95
|
-
|
|
123
|
+
diagnostics.push(issue);
|
|
124
|
+
}
|
|
125
|
+
return { links, diagnostics };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
export function collectCommentReferenceIssues(
|
|
129
|
+
document: LangiumDocument,
|
|
130
|
+
documents: LangiumDocuments,
|
|
131
|
+
fileSystem?: FileSystemProvider,
|
|
132
|
+
context?: PathResolveContext
|
|
133
|
+
): CommentReferenceDiagnostic[] {
|
|
134
|
+
return presentCommentReferencesForDocument(document, documents, fileSystem, context).diagnostics;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Relink this document when a changed `.rq` file can change comment-reference
|
|
139
|
+
* resolution (missing idea becomes present, or a targeted file changes).
|
|
140
|
+
*/
|
|
141
|
+
export function shouldRelinkCommentReferences(
|
|
142
|
+
document: LangiumDocument,
|
|
143
|
+
changedUris: Set<string>,
|
|
144
|
+
context?: PathResolveContext
|
|
145
|
+
): boolean {
|
|
146
|
+
const text = document.textDocument.getText();
|
|
147
|
+
if (!text.includes('rq:[')) {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
if (document.diagnostics?.some(diagnostic => isCommentReferenceDiagnosticCode(diagnostic.code))) {
|
|
151
|
+
return true;
|
|
152
|
+
}
|
|
153
|
+
for (const reference of findCommentReferencesInText(text)) {
|
|
96
154
|
if (!isSlashOrBlockCommentReference(text, reference.range)) {
|
|
97
155
|
continue;
|
|
98
156
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
157
|
+
if (!reference.path) {
|
|
158
|
+
return true;
|
|
159
|
+
}
|
|
160
|
+
for (const uri of resolveImportCandidateUris(reference.path, document, context)) {
|
|
161
|
+
if (changedUris.has(uri.toString())) {
|
|
162
|
+
return true;
|
|
163
|
+
}
|
|
102
164
|
}
|
|
103
165
|
}
|
|
104
|
-
return
|
|
166
|
+
return false;
|
|
105
167
|
}
|
|
106
168
|
|
|
107
169
|
function isSlashOrBlockCommentReference(text: string, range: Range): boolean {
|
|
@@ -181,3 +243,38 @@ function commentReferenceLangiumIssue(
|
|
|
181
243
|
code: COMMENT_REFERENCE_MISSING_IDEA
|
|
182
244
|
};
|
|
183
245
|
}
|
|
246
|
+
|
|
247
|
+
function commentReferenceLangiumLink(
|
|
248
|
+
reference: EmbeddedCommentReference,
|
|
249
|
+
document: LangiumDocument,
|
|
250
|
+
documents: LangiumDocuments,
|
|
251
|
+
context?: PathResolveContext
|
|
252
|
+
): CommentReferenceLink | undefined {
|
|
253
|
+
const idea = resolveCommentReferenceIdea(reference, document, documents, context);
|
|
254
|
+
if (idea) {
|
|
255
|
+
const targetDocument = documents.getDocument(AstUtils.getDocument(idea).uri);
|
|
256
|
+
if (!targetDocument) {
|
|
257
|
+
return undefined;
|
|
258
|
+
}
|
|
259
|
+
const ideaNode = idea.$cstNode;
|
|
260
|
+
const targetUri = ideaNode
|
|
261
|
+
? `${targetDocument.textDocument.uri}#L${ideaNode.range.start.line + 1}`
|
|
262
|
+
: targetDocument.textDocument.uri;
|
|
263
|
+
return {
|
|
264
|
+
range: reference.range,
|
|
265
|
+
targetPath: URI.parse(targetDocument.textDocument.uri).fsPath,
|
|
266
|
+
targetUri,
|
|
267
|
+
idea: reference.idea
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
if (!reference.path) {
|
|
271
|
+
return undefined;
|
|
272
|
+
}
|
|
273
|
+
const target = resolveFileUri(reference.path, document, context);
|
|
274
|
+
return {
|
|
275
|
+
range: reference.range,
|
|
276
|
+
targetPath: target.fsPath,
|
|
277
|
+
targetUri: target.toString(),
|
|
278
|
+
idea: reference.idea
|
|
279
|
+
};
|
|
280
|
+
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Build text edits that rename idea tokens inside `rq:[...]` comment references.
|
|
3
3
|
* rq:["../../../reqlan rq/extension/refactor_support.rq".refactor_symbol_rename]
|
|
4
|
+
* rq:["../../../reqlan rq/extension/refactor_support.rq".comment_reference_refactor_support]
|
|
4
5
|
*/
|
|
5
6
|
import type { Range } from 'vscode-languageserver';
|
|
6
7
|
import { findCommentReferencesInText, type EmbeddedCommentReference } from './reqlan-comment-resolver.js';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Rebuilds documents whose comment-reference diagnostics depend on other `.rq` files.
|
|
3
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
4
|
+
*/
|
|
5
|
+
import {
|
|
6
|
+
DefaultDocumentBuilder,
|
|
7
|
+
type LangiumDocument,
|
|
8
|
+
type LangiumSharedCoreServices
|
|
9
|
+
} from 'langium';
|
|
10
|
+
import { shouldRelinkCommentReferences } from './reqlan-comment-diagnostics.js';
|
|
11
|
+
import { pathResolveContextFromServices } from './reqlan-path-resolve.js';
|
|
12
|
+
|
|
13
|
+
export class ReqlanDocumentBuilder extends DefaultDocumentBuilder {
|
|
14
|
+
constructor(services: LangiumSharedCoreServices) {
|
|
15
|
+
super(services);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
protected override shouldRelink(document: LangiumDocument, changedUris: Set<string>): boolean {
|
|
19
|
+
if (super.shouldRelink(document, changedUris)) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
return shouldRelinkCommentReferences(
|
|
23
|
+
document,
|
|
24
|
+
changedUris,
|
|
25
|
+
pathResolveContextFromServices({
|
|
26
|
+
shared: {
|
|
27
|
+
workspace: {
|
|
28
|
+
WorkspaceManager: this.workspaceManager(),
|
|
29
|
+
FileSystemProvider: this.fileSystemProvider
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
})
|
|
33
|
+
);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Clickable document links for idea references, file references, and
|
|
2
|
+
* Clickable document links for idea references, file references, import paths, and comment references.
|
|
3
3
|
* Same-file and cross-file idea refs both get links so the editor underline is consistent.
|
|
4
|
+
* Comment-reference links come from the same presentation as the missing-idea underline.
|
|
5
|
+
* rq:["../../../reqlan rq/extension/features-non-rq-code-comment/functional-code-comment-references.rq".comment_reference_resolution_error_state]
|
|
4
6
|
*/
|
|
5
7
|
import type { LangiumDocument } from 'langium';
|
|
8
|
+
import { URI } from 'langium';
|
|
6
9
|
import type { DocumentLinkProvider } from 'langium/lsp';
|
|
7
10
|
import type { DocumentLink, DocumentLinkParams } from 'vscode-languageserver';
|
|
8
11
|
import { DocumentLink as LspDocumentLink } from 'vscode-languageserver';
|
|
12
|
+
import { presentCommentReferencesForDocument } from './reqlan-comment-diagnostics.js';
|
|
9
13
|
import { collectFileLinks, resolvedFileLinkTargetUri } from './reqlan-file-link-resolver.js';
|
|
10
14
|
import { folderReferenceCommandTarget } from './reqlan-reference-at-position.js';
|
|
11
15
|
import { wildcardReferenceCommandTarget } from './reqlan-wildcard-resolve.js';
|
|
@@ -25,11 +29,12 @@ export class ReqlanDocumentLinkProvider implements DocumentLinkProvider {
|
|
|
25
29
|
}
|
|
26
30
|
|
|
27
31
|
getDocumentLinks(document: LangiumDocument, _params: DocumentLinkParams): DocumentLink[] {
|
|
28
|
-
|
|
32
|
+
const pathContext = pathResolveContextFromServices(this.services);
|
|
33
|
+
const fileLinks = collectFileLinks(
|
|
29
34
|
document,
|
|
30
35
|
this.documents,
|
|
31
36
|
this.fileSystem,
|
|
32
|
-
|
|
37
|
+
pathContext
|
|
33
38
|
).flatMap(link => {
|
|
34
39
|
if (link.resolution === 'folder') {
|
|
35
40
|
return [LspDocumentLink.create(
|
|
@@ -49,5 +54,15 @@ export class ReqlanDocumentLinkProvider implements DocumentLinkProvider {
|
|
|
49
54
|
}
|
|
50
55
|
return [LspDocumentLink.create(link.sourceRange, target)];
|
|
51
56
|
});
|
|
57
|
+
const commentLinks = presentCommentReferencesForDocument(
|
|
58
|
+
document,
|
|
59
|
+
this.documents,
|
|
60
|
+
this.fileSystem,
|
|
61
|
+
pathContext
|
|
62
|
+
).links.map(link => LspDocumentLink.create(
|
|
63
|
+
link.range,
|
|
64
|
+
link.targetUri ?? URI.file(link.targetPath).toString()
|
|
65
|
+
));
|
|
66
|
+
return [...fileLinks, ...commentLinks];
|
|
52
67
|
}
|
|
53
68
|
}
|