umple-lsp-server 0.2.1 → 0.2.2
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/completions.scm +21 -6
- package/definitions.scm +4 -0
- package/out/completionAnalysis.d.ts +44 -0
- package/out/completionAnalysis.js +391 -0
- package/out/completionAnalysis.js.map +1 -0
- package/out/completionBuilder.d.ts +28 -0
- package/out/completionBuilder.js +251 -0
- package/out/completionBuilder.js.map +1 -0
- package/out/documentSymbolBuilder.d.ts +13 -0
- package/out/documentSymbolBuilder.js +95 -0
- package/out/documentSymbolBuilder.js.map +1 -0
- package/out/formatter.d.ts +31 -0
- package/out/formatter.js +96 -0
- package/out/formatter.js.map +1 -0
- package/out/hoverBuilder.d.ts +21 -0
- package/out/hoverBuilder.js +308 -0
- package/out/hoverBuilder.js.map +1 -0
- package/out/importGraph.d.ts +28 -0
- package/out/importGraph.js +91 -0
- package/out/importGraph.js.map +1 -0
- package/out/referenceSearch.d.ts +22 -0
- package/out/referenceSearch.js +271 -0
- package/out/referenceSearch.js.map +1 -0
- package/out/resolver.d.ts +21 -0
- package/out/resolver.js +174 -0
- package/out/resolver.js.map +1 -0
- package/out/server.js +350 -328
- package/out/server.js.map +1 -1
- package/out/symbolIndex.d.ts +86 -94
- package/out/symbolIndex.js +357 -399
- package/out/symbolIndex.js.map +1 -1
- package/out/symbolTypes.d.ts +34 -0
- package/out/symbolTypes.js +9 -0
- package/out/symbolTypes.js.map +1 -0
- package/out/tokenAnalysis.d.ts +24 -0
- package/out/tokenAnalysis.js +195 -0
- package/out/tokenAnalysis.js.map +1 -0
- package/out/tokenTypes.d.ts +46 -0
- package/out/tokenTypes.js +28 -0
- package/out/tokenTypes.js.map +1 -0
- package/out/treeUtils.d.ts +32 -0
- package/out/treeUtils.js +89 -0
- package/out/treeUtils.js.map +1 -0
- package/package.json +4 -2
- package/references.scm +78 -10
- package/tree-sitter-umple.wasm +0 -0
package/completions.scm
CHANGED
|
@@ -23,8 +23,14 @@
|
|
|
23
23
|
; =====================
|
|
24
24
|
(source_file) @scope.none
|
|
25
25
|
(mixset_definition) @scope.none
|
|
26
|
-
(statemachine_definition) @scope.
|
|
26
|
+
(statemachine_definition) @scope.state
|
|
27
27
|
(requirement_definition) @scope.none
|
|
28
|
+
; Suppress completions inside require body (opaque content)
|
|
29
|
+
(require_body) @scope.suppress
|
|
30
|
+
; filter blocks: no symbol completions by default…
|
|
31
|
+
(filter_definition) @scope.none
|
|
32
|
+
; …except inside include statements, where class names are valid targets
|
|
33
|
+
(filter_value) @scope.class
|
|
28
34
|
|
|
29
35
|
; =====================
|
|
30
36
|
; CLASS-LIKE SCOPES (offer type names)
|
|
@@ -33,14 +39,14 @@
|
|
|
33
39
|
(trait_definition) @scope.class_interface_trait_enum
|
|
34
40
|
(interface_definition) @scope.class_interface_trait_enum
|
|
35
41
|
(association_class_definition) @scope.class_interface_trait_enum
|
|
36
|
-
(isa_declaration) @scope.
|
|
42
|
+
(isa_declaration) @scope.class_interface_trait
|
|
37
43
|
|
|
38
44
|
; =====================
|
|
39
|
-
; ASSOCIATION SCOPES (offer
|
|
45
|
+
; ASSOCIATION SCOPES (offer type names — classes, interfaces, traits)
|
|
40
46
|
; =====================
|
|
41
|
-
(association_definition) @scope.
|
|
42
|
-
(association_inline) @scope.
|
|
43
|
-
(association_member) @scope.
|
|
47
|
+
(association_definition) @scope.class_interface_trait
|
|
48
|
+
(association_inline) @scope.class_interface_trait
|
|
49
|
+
(association_member) @scope.class_interface_trait
|
|
44
50
|
|
|
45
51
|
; =====================
|
|
46
52
|
; STATE MACHINE SCOPES (offer state names)
|
|
@@ -54,6 +60,15 @@
|
|
|
54
60
|
; =====================
|
|
55
61
|
; key { attr1, attr2 } — offer attribute names (scoped to class + inherited)
|
|
56
62
|
(key_definition) @scope.attribute
|
|
63
|
+
; Guard expressions — sentinel for keyword filtering + scoped attr/method completion
|
|
64
|
+
(guard) @scope.guard_attribute_method
|
|
65
|
+
|
|
66
|
+
; trace entity references — sentinel for keyword filtering + scoped attr/method completion
|
|
67
|
+
(trace_statement "trace" . (identifier) @scope.trace_attribute_method)
|
|
68
|
+
(trace_postfix "record" . (identifier) @scope.trace_attribute_method)
|
|
69
|
+
|
|
70
|
+
; referenced_statemachine definition — offer statemachine names from enclosing class
|
|
71
|
+
(referenced_statemachine definition: (identifier) @scope.statemachine)
|
|
57
72
|
|
|
58
73
|
; depend java.util.* — suppress (not a symbol reference)
|
|
59
74
|
(depend_statement) @scope.suppress
|
package/definitions.scm
CHANGED
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
(interface_definition name: (identifier) @definition.interface)
|
|
16
16
|
(trait_definition name: (identifier) @definition.trait)
|
|
17
17
|
(enum_definition name: (identifier) @definition.enum)
|
|
18
|
+
(enum_value name: (identifier) @definition.enum_value)
|
|
18
19
|
(external_definition name: (identifier) @definition.class)
|
|
19
20
|
(association_definition name: (identifier) @definition.association)
|
|
20
21
|
(requirement_definition name: (identifier) @definition.requirement)
|
|
@@ -28,10 +29,13 @@
|
|
|
28
29
|
; These require a parent scope (class, statemachine, etc.)
|
|
29
30
|
|
|
30
31
|
(attribute_declaration name: (identifier) @definition.attribute)
|
|
32
|
+
(const_declaration name: (identifier) @definition.const)
|
|
31
33
|
(method_declaration name: (identifier) @definition.method)
|
|
32
34
|
(method_signature name: (identifier) @definition.method)
|
|
35
|
+
(trait_method_signature name: (identifier) @definition.method)
|
|
33
36
|
(state_machine name: (identifier) @definition.statemachine)
|
|
34
37
|
(state name: (identifier) @definition.state)
|
|
35
38
|
(referenced_statemachine name: (identifier) @definition.statemachine)
|
|
36
39
|
(emit_method name: (identifier) @definition.method)
|
|
37
40
|
(template_attribute name: (identifier) @definition.template)
|
|
41
|
+
(trace_statement name: (identifier) @definition.tracecase)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Completion context analysis.
|
|
3
|
+
*
|
|
4
|
+
* Pure analysis of a parsed tree + cursor position to produce CompletionInfo.
|
|
5
|
+
* No dependency on SymbolIndex class or any index state.
|
|
6
|
+
*/
|
|
7
|
+
declare const TreeSitter: any;
|
|
8
|
+
type Language = InstanceType<typeof TreeSitter.Language>;
|
|
9
|
+
type Tree = InstanceType<typeof TreeSitter.Tree>;
|
|
10
|
+
type Query = InstanceType<typeof TreeSitter.Query>;
|
|
11
|
+
import type { SymbolKind } from "./tokenTypes";
|
|
12
|
+
/** Information needed by the completion handler. */
|
|
13
|
+
export interface CompletionInfo {
|
|
14
|
+
/** Keywords the parser expects at this position. */
|
|
15
|
+
keywords: string[];
|
|
16
|
+
/** Operators the parser expects at this position. */
|
|
17
|
+
operators: string[];
|
|
18
|
+
/** Which symbol kinds to offer, or null for none. */
|
|
19
|
+
symbolKinds: SymbolKind[] | "suppress" | "use_path" | "own_attribute" | "guard_attribute_method" | "trace_attribute_method" | null;
|
|
20
|
+
/** True if cursor is at a definition-name position (suppress all). */
|
|
21
|
+
isDefinitionName: boolean;
|
|
22
|
+
/** True if cursor is inside a comment. */
|
|
23
|
+
isComment: boolean;
|
|
24
|
+
/** Text of the token at the cursor (identifier or use_path), empty if none. */
|
|
25
|
+
prefix: string;
|
|
26
|
+
/** Name of enclosing class (for scoped attribute lookups). */
|
|
27
|
+
enclosingClass?: string;
|
|
28
|
+
/** Name of enclosing root state machine (for scoped state lookups). */
|
|
29
|
+
enclosingStateMachine?: string;
|
|
30
|
+
/** Dotted path prefix for state completions (e.g., ["EEE", "Open"] when typing "EEE.Open."). */
|
|
31
|
+
dottedStatePrefix?: string[];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Analyze the completion context at a given position in a parsed tree.
|
|
35
|
+
*
|
|
36
|
+
* @param tree Pre-parsed tree for the document
|
|
37
|
+
* @param language Tree-sitter language (for LookaheadIterator)
|
|
38
|
+
* @param completionsQuery Loaded completions.scm query
|
|
39
|
+
* @param content Document text
|
|
40
|
+
* @param line 0-based line
|
|
41
|
+
* @param column 0-based column
|
|
42
|
+
*/
|
|
43
|
+
export declare function analyzeCompletion(tree: Tree, language: Language, completionsQuery: Query, content: string, line: number, column: number): CompletionInfo;
|
|
44
|
+
export {};
|
|
@@ -0,0 +1,391 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Completion context analysis.
|
|
4
|
+
*
|
|
5
|
+
* Pure analysis of a parsed tree + cursor position to produce CompletionInfo.
|
|
6
|
+
* No dependency on SymbolIndex class or any index state.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.analyzeCompletion = analyzeCompletion;
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
11
|
+
const TreeSitter = require("web-tree-sitter");
|
|
12
|
+
const treeUtils_1 = require("./treeUtils");
|
|
13
|
+
// ── Completion-specific constants ───────────────────────────────────────────
|
|
14
|
+
/**
|
|
15
|
+
* Keywords after which the next token is always a new name (definition).
|
|
16
|
+
* Completions are suppressed when the cursor immediately follows one of these.
|
|
17
|
+
*/
|
|
18
|
+
const DEFINITION_KEYWORDS = new Set([
|
|
19
|
+
"class",
|
|
20
|
+
"interface",
|
|
21
|
+
"trait",
|
|
22
|
+
"enum",
|
|
23
|
+
"mixset",
|
|
24
|
+
"req",
|
|
25
|
+
"associationClass",
|
|
26
|
+
"statemachine",
|
|
27
|
+
"namespace",
|
|
28
|
+
"queued",
|
|
29
|
+
"pooled",
|
|
30
|
+
"emit",
|
|
31
|
+
]);
|
|
32
|
+
/** Structural tokens that should NOT appear in completions. */
|
|
33
|
+
const STRUCTURAL_TOKENS = new Set([
|
|
34
|
+
"{",
|
|
35
|
+
"}",
|
|
36
|
+
"(",
|
|
37
|
+
")",
|
|
38
|
+
"[",
|
|
39
|
+
"]",
|
|
40
|
+
";",
|
|
41
|
+
",",
|
|
42
|
+
".",
|
|
43
|
+
"<",
|
|
44
|
+
">",
|
|
45
|
+
"=",
|
|
46
|
+
"/",
|
|
47
|
+
"[]",
|
|
48
|
+
"*",
|
|
49
|
+
"||",
|
|
50
|
+
]);
|
|
51
|
+
function isOperatorToken(name) {
|
|
52
|
+
return /^[<>-]/.test(name) && name.length > 1;
|
|
53
|
+
}
|
|
54
|
+
// ── Main analysis function ──────────────────────────────────────────────────
|
|
55
|
+
/**
|
|
56
|
+
* Analyze the completion context at a given position in a parsed tree.
|
|
57
|
+
*
|
|
58
|
+
* @param tree Pre-parsed tree for the document
|
|
59
|
+
* @param language Tree-sitter language (for LookaheadIterator)
|
|
60
|
+
* @param completionsQuery Loaded completions.scm query
|
|
61
|
+
* @param content Document text
|
|
62
|
+
* @param line 0-based line
|
|
63
|
+
* @param column 0-based column
|
|
64
|
+
*/
|
|
65
|
+
function analyzeCompletion(tree, language, completionsQuery, content, line, column) {
|
|
66
|
+
const empty = {
|
|
67
|
+
keywords: [],
|
|
68
|
+
operators: [],
|
|
69
|
+
symbolKinds: null,
|
|
70
|
+
isDefinitionName: false,
|
|
71
|
+
isComment: false,
|
|
72
|
+
prefix: "",
|
|
73
|
+
};
|
|
74
|
+
// --- Comment check ---
|
|
75
|
+
const nodeAtCursor = tree.rootNode.descendantForPosition({
|
|
76
|
+
row: line,
|
|
77
|
+
column: Math.max(0, column - 1),
|
|
78
|
+
});
|
|
79
|
+
if (nodeAtCursor && isInsideComment(nodeAtCursor)) {
|
|
80
|
+
return { ...empty, isComment: true };
|
|
81
|
+
}
|
|
82
|
+
// --- Extract prefix from the token at cursor ---
|
|
83
|
+
let prefix = "";
|
|
84
|
+
if (column > 0 &&
|
|
85
|
+
nodeAtCursor &&
|
|
86
|
+
(nodeAtCursor.type === "identifier" || nodeAtCursor.type === "use_path")) {
|
|
87
|
+
const nodeStartCol = nodeAtCursor.startPosition.row === line
|
|
88
|
+
? nodeAtCursor.startPosition.column
|
|
89
|
+
: 0;
|
|
90
|
+
prefix = nodeAtCursor.text.substring(0, column - nodeStartCol);
|
|
91
|
+
}
|
|
92
|
+
// --- Definition name check ---
|
|
93
|
+
const lastToken = lastTokenBeforeCursor(content, line, column);
|
|
94
|
+
if ((lastToken && DEFINITION_KEYWORDS.has(lastToken)) ||
|
|
95
|
+
isAtAttributeNamePosition(tree, content, line, column)) {
|
|
96
|
+
return { ...empty, isDefinitionName: true };
|
|
97
|
+
}
|
|
98
|
+
// --- LookaheadIterator for keywords ---
|
|
99
|
+
const prevLeaf = findPreviousLeaf(tree, content, line, column);
|
|
100
|
+
const stateId = prevLeaf
|
|
101
|
+
? prevLeaf.nextParseState
|
|
102
|
+
: (nodeAtCursor?.parseState ?? 0);
|
|
103
|
+
const keywords = [];
|
|
104
|
+
const operators = [];
|
|
105
|
+
const iter = language.lookaheadIterator(stateId);
|
|
106
|
+
if (iter) {
|
|
107
|
+
try {
|
|
108
|
+
for (const symbolName of iter) {
|
|
109
|
+
const typeId = iter.currentTypeId;
|
|
110
|
+
if (language.nodeTypeIsNamed(typeId))
|
|
111
|
+
continue;
|
|
112
|
+
if (STRUCTURAL_TOKENS.has(symbolName))
|
|
113
|
+
continue;
|
|
114
|
+
if (isOperatorToken(symbolName)) {
|
|
115
|
+
operators.push(symbolName);
|
|
116
|
+
}
|
|
117
|
+
else if (/^[a-zA-Z]/.test(symbolName)) {
|
|
118
|
+
keywords.push(symbolName);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
finally {
|
|
123
|
+
iter.delete();
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// --- Scope query for symbol kinds ---
|
|
127
|
+
let symbolKinds = resolveCompletionScope(completionsQuery, tree, line, column);
|
|
128
|
+
// --- before/after method-name completion (position-aware) ---
|
|
129
|
+
const baNode = nodeAtCursor?.type === "identifier" && nodeAtCursor.parent?.type === "before_after"
|
|
130
|
+
? nodeAtCursor : (prevLeaf?.type === "identifier" && prevLeaf.parent?.type === "before_after" ? prevLeaf : null);
|
|
131
|
+
if (baNode && line === baNode.startPosition.row && column <= baNode.endPosition.column) {
|
|
132
|
+
const firstId = baNode.parent.namedChildren.find((c) => c.type === "identifier");
|
|
133
|
+
if (firstId && firstId.id === baNode.id) {
|
|
134
|
+
symbolKinds = ["method"];
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
// --- Trace completion fallback for zero-identifier case ("trace |") ---
|
|
138
|
+
if (prevLeaf?.type === "trace" && prevLeaf.parent?.type === "ERROR") {
|
|
139
|
+
symbolKinds = "trace_attribute_method";
|
|
140
|
+
}
|
|
141
|
+
// --- Zero-identifier completion fallbacks ---
|
|
142
|
+
const CLASS_LIKE_TYPES = new Set([
|
|
143
|
+
"class_definition", "trait_definition",
|
|
144
|
+
"interface_definition", "association_class_definition",
|
|
145
|
+
]);
|
|
146
|
+
if (prevLeaf?.type === "isA" && prevLeaf.parent?.type === "ERROR") {
|
|
147
|
+
const errorParent = prevLeaf.parent.parent;
|
|
148
|
+
if (errorParent && CLASS_LIKE_TYPES.has(errorParent.type)) {
|
|
149
|
+
symbolKinds = ["class", "interface", "trait"];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
if ((prevLeaf?.type === "before" || prevLeaf?.type === "after") &&
|
|
153
|
+
prevLeaf.parent?.type === "ERROR") {
|
|
154
|
+
const errorParent = prevLeaf.parent.parent;
|
|
155
|
+
if (errorParent && CLASS_LIKE_TYPES.has(errorParent.type)) {
|
|
156
|
+
symbolKinds = ["method"];
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
if (prevLeaf?.type === "as" && prevLeaf.parent?.type === "ERROR") {
|
|
160
|
+
const errorParent = prevLeaf.parent.parent;
|
|
161
|
+
if (errorParent &&
|
|
162
|
+
(CLASS_LIKE_TYPES.has(errorParent.type) || errorParent.type === "attribute_declaration")) {
|
|
163
|
+
symbolKinds = ["statemachine"];
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
if (prevLeaf?.type === "->" && prevLeaf.parent?.type === "ERROR") {
|
|
167
|
+
let n = prevLeaf.parent;
|
|
168
|
+
while (n) {
|
|
169
|
+
if (n.type === "state_machine" || n.type === "statemachine_definition") {
|
|
170
|
+
symbolKinds = ["state"];
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
if (n.type === "class_definition" || n.type === "source_file")
|
|
174
|
+
break;
|
|
175
|
+
n = n.parent;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
// --- Enclosing scope for scoped lookups ---
|
|
179
|
+
const { enclosingClass, enclosingStateMachine } = (0, treeUtils_1.resolveEnclosingScope)(tree, line, column);
|
|
180
|
+
// --- Dotted state prefix for path-scoped completions ---
|
|
181
|
+
let dottedStatePrefix;
|
|
182
|
+
if (enclosingStateMachine &&
|
|
183
|
+
isInTransitionTarget(tree, line, column, content)) {
|
|
184
|
+
const lineText = content.split("\n")[line] ?? "";
|
|
185
|
+
let pos = column;
|
|
186
|
+
while (pos > 0 && /[a-zA-Z_0-9]/.test(lineText[pos - 1])) {
|
|
187
|
+
pos--;
|
|
188
|
+
}
|
|
189
|
+
if (pos > 0 && lineText[pos - 1] === ".") {
|
|
190
|
+
dottedStatePrefix = extractDottedPrefix(lineText, pos - 1);
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
keywords,
|
|
195
|
+
operators,
|
|
196
|
+
symbolKinds,
|
|
197
|
+
isDefinitionName: false,
|
|
198
|
+
isComment: false,
|
|
199
|
+
prefix,
|
|
200
|
+
enclosingClass,
|
|
201
|
+
enclosingStateMachine,
|
|
202
|
+
dottedStatePrefix,
|
|
203
|
+
};
|
|
204
|
+
}
|
|
205
|
+
// ── Private helpers ─────────────────────────────────────────────────────────
|
|
206
|
+
function isInsideComment(node) {
|
|
207
|
+
let current = node;
|
|
208
|
+
while (current) {
|
|
209
|
+
if (current.type === "line_comment" || current.type === "block_comment") {
|
|
210
|
+
return true;
|
|
211
|
+
}
|
|
212
|
+
current = current.parent;
|
|
213
|
+
}
|
|
214
|
+
return false;
|
|
215
|
+
}
|
|
216
|
+
function findPreviousLeaf(tree, content, line, column) {
|
|
217
|
+
const lines = content.split("\n");
|
|
218
|
+
let offset = 0;
|
|
219
|
+
for (let i = 0; i < line && i < lines.length; i++) {
|
|
220
|
+
offset += lines[i].length + 1;
|
|
221
|
+
}
|
|
222
|
+
offset += Math.min(column, lines[line]?.length ?? 0);
|
|
223
|
+
let pos = offset;
|
|
224
|
+
while (pos > 0 && /[a-zA-Z_0-9]/.test(content[pos - 1])) {
|
|
225
|
+
pos--;
|
|
226
|
+
}
|
|
227
|
+
while (pos > 0 && /\s/.test(content[pos - 1])) {
|
|
228
|
+
pos--;
|
|
229
|
+
}
|
|
230
|
+
if (pos === 0)
|
|
231
|
+
return null;
|
|
232
|
+
let node = tree.rootNode.descendantForIndex(pos - 1, pos - 1);
|
|
233
|
+
if (!node)
|
|
234
|
+
return null;
|
|
235
|
+
while (node && node.isExtra) {
|
|
236
|
+
const prev = node.previousSibling;
|
|
237
|
+
if (prev) {
|
|
238
|
+
node = prev;
|
|
239
|
+
while (node.childCount > 0) {
|
|
240
|
+
node = node.lastChild;
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
else if (node.parent) {
|
|
244
|
+
node = node.parent;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
return null;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
while (node && node.childCount > 0) {
|
|
251
|
+
node = node.lastChild;
|
|
252
|
+
}
|
|
253
|
+
return node;
|
|
254
|
+
}
|
|
255
|
+
function resolveCompletionScope(completionsQuery, tree, line, column) {
|
|
256
|
+
const captures = completionsQuery.captures(tree.rootNode);
|
|
257
|
+
let best = null;
|
|
258
|
+
for (const capture of captures) {
|
|
259
|
+
const node = capture.node;
|
|
260
|
+
const startOk = node.startPosition.row < line ||
|
|
261
|
+
(node.startPosition.row === line &&
|
|
262
|
+
node.startPosition.column <= column);
|
|
263
|
+
const endOk = node.endPosition.row > line ||
|
|
264
|
+
(node.endPosition.row === line && node.endPosition.column >= column);
|
|
265
|
+
if (startOk && endOk) {
|
|
266
|
+
const size = node.endIndex - node.startIndex;
|
|
267
|
+
if (!best || size < best.size) {
|
|
268
|
+
best = { name: capture.name, size };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
if (!best)
|
|
273
|
+
return null;
|
|
274
|
+
const prefix = "scope.";
|
|
275
|
+
if (!best.name.startsWith(prefix))
|
|
276
|
+
return null;
|
|
277
|
+
const kindStr = best.name.substring(prefix.length);
|
|
278
|
+
if (kindStr === "suppress")
|
|
279
|
+
return "suppress";
|
|
280
|
+
if (kindStr === "use_path")
|
|
281
|
+
return "use_path";
|
|
282
|
+
if (kindStr === "own_attribute")
|
|
283
|
+
return "own_attribute";
|
|
284
|
+
if (kindStr === "guard_attribute_method")
|
|
285
|
+
return "guard_attribute_method";
|
|
286
|
+
if (kindStr === "trace_attribute_method")
|
|
287
|
+
return "trace_attribute_method";
|
|
288
|
+
if (kindStr === "none")
|
|
289
|
+
return null;
|
|
290
|
+
return kindStr.split("_");
|
|
291
|
+
}
|
|
292
|
+
function isAtAttributeNamePosition(tree, content, line, column) {
|
|
293
|
+
const prevLeaf = findPreviousLeaf(tree, content, line, column);
|
|
294
|
+
if (!prevLeaf)
|
|
295
|
+
return false;
|
|
296
|
+
let node = prevLeaf;
|
|
297
|
+
while (node) {
|
|
298
|
+
if (node.type === "type_name") {
|
|
299
|
+
const parent = node.parent;
|
|
300
|
+
if (parent) {
|
|
301
|
+
for (let i = 0; i < parent.childCount; i++) {
|
|
302
|
+
if (parent.child(i)?.id === node.id) {
|
|
303
|
+
const fieldName = parent.fieldNameForChild(i);
|
|
304
|
+
if (fieldName === "type" || fieldName === "return_type") {
|
|
305
|
+
return true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
node = node.parent;
|
|
313
|
+
}
|
|
314
|
+
return false;
|
|
315
|
+
}
|
|
316
|
+
function lastTokenBeforeCursor(content, line, column) {
|
|
317
|
+
const lines = content.split("\n");
|
|
318
|
+
let offset = 0;
|
|
319
|
+
for (let i = 0; i < line && i < lines.length; i++) {
|
|
320
|
+
offset += lines[i].length + 1;
|
|
321
|
+
}
|
|
322
|
+
offset += Math.min(column, lines[line]?.length ?? 0);
|
|
323
|
+
let pos = offset;
|
|
324
|
+
while (pos > 0 && /[a-zA-Z_0-9]/.test(content[pos - 1])) {
|
|
325
|
+
pos--;
|
|
326
|
+
}
|
|
327
|
+
while (pos > 0 && /\s/.test(content[pos - 1])) {
|
|
328
|
+
pos--;
|
|
329
|
+
}
|
|
330
|
+
if (pos === 0)
|
|
331
|
+
return null;
|
|
332
|
+
let start = pos;
|
|
333
|
+
while (start > 0 && /[a-zA-Z_]/.test(content[start - 1])) {
|
|
334
|
+
start--;
|
|
335
|
+
}
|
|
336
|
+
if (start === pos)
|
|
337
|
+
return null;
|
|
338
|
+
return content.substring(start, pos);
|
|
339
|
+
}
|
|
340
|
+
function isInTransitionTarget(tree, line, column, content) {
|
|
341
|
+
let node = tree.rootNode.descendantForPosition({
|
|
342
|
+
row: line,
|
|
343
|
+
column: Math.max(0, column - 1),
|
|
344
|
+
});
|
|
345
|
+
while (node) {
|
|
346
|
+
if (node.type === "qualified_name") {
|
|
347
|
+
const parent = node.parent;
|
|
348
|
+
if (parent?.type === "transition") {
|
|
349
|
+
const targetNode = parent.childForFieldName("target");
|
|
350
|
+
if (targetNode?.id === node.id)
|
|
351
|
+
return true;
|
|
352
|
+
}
|
|
353
|
+
break;
|
|
354
|
+
}
|
|
355
|
+
if (node.type === "transition" ||
|
|
356
|
+
node.type === "state" ||
|
|
357
|
+
node.type === "state_machine" ||
|
|
358
|
+
node.type === "statemachine_definition") {
|
|
359
|
+
break;
|
|
360
|
+
}
|
|
361
|
+
node = node.parent;
|
|
362
|
+
}
|
|
363
|
+
const lineText = content.split("\n")[line] ?? "";
|
|
364
|
+
const beforeCursor = lineText.substring(0, column);
|
|
365
|
+
if (beforeCursor.includes("->")) {
|
|
366
|
+
return true;
|
|
367
|
+
}
|
|
368
|
+
return false;
|
|
369
|
+
}
|
|
370
|
+
function extractDottedPrefix(lineText, dotPos) {
|
|
371
|
+
const segments = [];
|
|
372
|
+
let pos = dotPos;
|
|
373
|
+
while (pos >= 0 && lineText[pos] === ".") {
|
|
374
|
+
const identEnd = pos;
|
|
375
|
+
let identStart = pos;
|
|
376
|
+
while (identStart > 0 && /[a-zA-Z_0-9]/.test(lineText[identStart - 1])) {
|
|
377
|
+
identStart--;
|
|
378
|
+
}
|
|
379
|
+
if (identStart === identEnd)
|
|
380
|
+
break;
|
|
381
|
+
segments.unshift(lineText.substring(identStart, identEnd));
|
|
382
|
+
if (identStart > 0 && lineText[identStart - 1] === ".") {
|
|
383
|
+
pos = identStart - 1;
|
|
384
|
+
}
|
|
385
|
+
else {
|
|
386
|
+
break;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
return segments.length > 0 ? segments : undefined;
|
|
390
|
+
}
|
|
391
|
+
//# sourceMappingURL=completionAnalysis.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"completionAnalysis.js","sourceRoot":"","sources":["../src/completionAnalysis.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA6FH,8CA0KC;AArQD,iEAAiE;AACjE,MAAM,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAO9C,2CAAoD;AAEpD,+EAA+E;AAE/E;;;GAGG;AACH,MAAM,mBAAmB,GAAG,IAAI,GAAG,CAAC;IAClC,OAAO;IACP,WAAW;IACX,OAAO;IACP,MAAM;IACN,QAAQ;IACR,KAAK;IACL,kBAAkB;IAClB,cAAc;IACd,WAAW;IACX,QAAQ;IACR,QAAQ;IACR,MAAM;CACP,CAAC,CAAC;AAEH,+DAA+D;AAC/D,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,GAAG;IACH,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C,CAAC,CAAC,EAAE,CAAC;YACvE,UAAU,EAAE,CAAC;QACf,CAAC;QACD,IAAI,UAAU,KAAK,QAAQ;YAAE,MAAM;QAEnC,QAAQ,CAAC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC;QAE3D,IAAI,UAAU,GAAG,CAAC,IAAI,QAAQ,CAAC,UAAU,GAAG,CAAC,CAAC,KAAK,GAAG,EAAE,CAAC;YACvD,GAAG,GAAG,UAAU,GAAG,CAAC,CAAC;QACvB,CAAC;aAAM,CAAC;YACN,MAAM;QACR,CAAC;IACH,CAAC;IAED,OAAO,QAAQ,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared completion-item assembly logic.
|
|
3
|
+
*
|
|
4
|
+
* Extracted from server.ts so both the LSP server and the test harness
|
|
5
|
+
* exercise the same production code path.
|
|
6
|
+
*
|
|
7
|
+
* Scope: keyword filtering, operator suppression, built-in types, and
|
|
8
|
+
* symbol-based completions. Does NOT handle use-path file completions,
|
|
9
|
+
* trigger-character gating, or comment/definition-name suppression —
|
|
10
|
+
* those stay in server.ts.
|
|
11
|
+
*/
|
|
12
|
+
import { CompletionItem, CompletionItemKind } from "vscode-languageserver/node";
|
|
13
|
+
import { SymbolIndex, SymbolKind, CompletionInfo } from "./symbolIndex";
|
|
14
|
+
export declare function symbolKindToCompletionKind(kind: SymbolKind): CompletionItemKind;
|
|
15
|
+
/**
|
|
16
|
+
* Build semantic completion items from a CompletionInfo + SymbolIndex.
|
|
17
|
+
*
|
|
18
|
+
* Handles: keyword filtering, operator suppression, built-in types,
|
|
19
|
+
* own-attribute completion, guard/trace attribute+method completion,
|
|
20
|
+
* and array-based symbol completions.
|
|
21
|
+
*
|
|
22
|
+
* Does NOT handle: use-path file completions, trigger-character gating,
|
|
23
|
+
* dotted-state dot-trigger fast path, or comment/definition-name suppression.
|
|
24
|
+
*
|
|
25
|
+
* @param symbolKinds - the normalized symbolKinds (after use_path → mixset conversion).
|
|
26
|
+
* Caller should not pass "suppress", "use_path", isComment, or isDefinitionName states.
|
|
27
|
+
*/
|
|
28
|
+
export declare function buildSemanticCompletionItems(info: CompletionInfo, symbolKinds: CompletionInfo["symbolKinds"], symbolIndex: SymbolIndex, reachableFiles: Set<string>): CompletionItem[];
|