firefly-compiler 0.5.66 → 0.5.67
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/lsp/CompletionHandler.ff +36 -25
- package/lsp/Handler.ff +3 -1
- package/package.json +1 -1
- package/vscode/package.json +1 -1
package/lsp/CompletionHandler.ff
CHANGED
|
@@ -49,7 +49,7 @@ handleCompletion(
|
|
|
49
49
|
mutable typeCompletions = []
|
|
50
50
|
let completions = patternCompletions.else {lspHook.results().flatMap {
|
|
51
51
|
| ResolveTypeHook h =>
|
|
52
|
-
typeCompletions = [...typeCompletions, ...typeCompletion(h.types, h.typeGenerics)]
|
|
52
|
+
typeCompletions = [...typeCompletions, ...typeCompletion(h.types, h.typeGenerics, importSymbols)]
|
|
53
53
|
[]
|
|
54
54
|
| ResolveVariantFieldHook _ =>
|
|
55
55
|
sawParameterOrVariantFieldHook = True
|
|
@@ -259,7 +259,11 @@ importCompletion(moduleKeys: List[ModuleKey]): List[CompletionInfo] {
|
|
|
259
259
|
}
|
|
260
260
|
}
|
|
261
261
|
|
|
262
|
-
typeCompletion(
|
|
262
|
+
typeCompletion(
|
|
263
|
+
types: Map[String, String]
|
|
264
|
+
typeGenerics: Map[String, List[String]]
|
|
265
|
+
importSymbols: ImportSymbolsInfo
|
|
266
|
+
): List[CompletionInfo] {
|
|
263
267
|
let completions = types.toList().filter {| Pair(n, full) =>
|
|
264
268
|
n.all {_.isAsciiLetterOrDigit()}
|
|
265
269
|
}.map {| Pair(typeName, full) =>
|
|
@@ -270,7 +274,11 @@ typeCompletion(types: Map[String, String], typeGenerics: Map[String, List[String
|
|
|
270
274
|
let snippet = typeName + if(realGenerics.isEmpty()) {""} else {"[$0]"}
|
|
271
275
|
CompletionInfo(label, extra, "", snippet, False, TConstructor(Location("", 0, 0), "type", []), full, None)
|
|
272
276
|
}
|
|
273
|
-
|
|
277
|
+
let importCompletions = importSymbols.importSymbols.flatMap {| info =>
|
|
278
|
+
info.typeNames.map: name =>
|
|
279
|
+
makeAutoimportCompletion(info, importSymbols.importLine, name, True)
|
|
280
|
+
}
|
|
281
|
+
[...completions, ...importCompletions]
|
|
274
282
|
}
|
|
275
283
|
|
|
276
284
|
completion(
|
|
@@ -357,34 +365,37 @@ completion(
|
|
|
357
365
|
if(prefix == "") {
|
|
358
366
|
importSymbols.importSymbols.each {| info =>
|
|
359
367
|
[info.moduleKey.name, ...info.variantNames].distinct().each: name =>
|
|
360
|
-
|
|
361
|
-
let fromName = if(
|
|
362
|
-
info.moduleKey.packagePair.name == "script" && info.moduleKey.packagePair.group == "script"
|
|
363
|
-
) {
|
|
364
|
-
""
|
|
365
|
-
} else {
|
|
366
|
-
info.moduleKey.packagePair.groupName(":")
|
|
367
|
-
}
|
|
368
|
-
let importName = if(fromName == "") {moduleName} else {moduleName + " from " + fromName}
|
|
369
|
-
// TODO: Add edit that inserts the import
|
|
370
|
-
members.push(CompletionInfo(
|
|
371
|
-
label = name
|
|
372
|
-
extra = ""
|
|
373
|
-
more = if(fromName == "") {moduleName} else {fromName + "/" + moduleName}
|
|
374
|
-
snippet = name
|
|
375
|
-
member = False
|
|
376
|
-
type = TConstructor(Location("", 0, 0), "", [])
|
|
377
|
-
documentation = "// Will import the following module:\nimport " + importName
|
|
378
|
-
expectedType = None
|
|
379
|
-
secondarySort = 9
|
|
380
|
-
insertion = Some(Pair(importSymbols.importLine, "import " + importName + "\n"))
|
|
381
|
-
))
|
|
368
|
+
members.push(makeAutoimportCompletion(info, importSymbols.importLine, name, False))
|
|
382
369
|
}
|
|
383
370
|
}
|
|
384
371
|
|
|
385
372
|
members.toList()
|
|
386
373
|
}
|
|
387
374
|
|
|
375
|
+
makeAutoimportCompletion(info: ImportSymbolInfo, importLine: Int, name: String, isType: Bool): CompletionInfo {
|
|
376
|
+
let moduleName = info.moduleKey.folders.map {_ + "."}.join() + info.moduleKey.name
|
|
377
|
+
let fromName = if(
|
|
378
|
+
info.moduleKey.packagePair.name == "script" && info.moduleKey.packagePair.group == "script"
|
|
379
|
+
) {
|
|
380
|
+
""
|
|
381
|
+
} else {
|
|
382
|
+
info.moduleKey.packagePair.groupName(":")
|
|
383
|
+
}
|
|
384
|
+
let importName = if(fromName == "") {moduleName} else {moduleName + " from " + fromName}
|
|
385
|
+
CompletionInfo(
|
|
386
|
+
label = name
|
|
387
|
+
extra = ""
|
|
388
|
+
more = if(fromName == "") {moduleName} else {fromName + "/" + moduleName}
|
|
389
|
+
snippet = name
|
|
390
|
+
member = False
|
|
391
|
+
type = TConstructor(Location("", 0, 0), if(isType) {"type"} else {""}, [])
|
|
392
|
+
documentation = "// Will import the following module:\nimport " + importName
|
|
393
|
+
expectedType = None
|
|
394
|
+
secondarySort = 9
|
|
395
|
+
insertion = Some(Pair(importLine, "import " + importName + "\n"))
|
|
396
|
+
)
|
|
397
|
+
}
|
|
398
|
+
|
|
388
399
|
makeCompletion(
|
|
389
400
|
unification: Unification
|
|
390
401
|
expected: Type
|
package/lsp/Handler.ff
CHANGED
|
@@ -406,7 +406,9 @@ extend self: Handler {
|
|
|
406
406
|
errors.each {| CompileError(at, message) =>
|
|
407
407
|
Log.trace("handleCompletion check error: " + message)
|
|
408
408
|
}
|
|
409
|
-
let importSymbols = self.
|
|
409
|
+
let importSymbols = self.printTime(system.mainTask(), "findModulesToImport") {
|
|
410
|
+
self.findModulesToImport(system, path, lspHook)
|
|
411
|
+
}
|
|
410
412
|
let o = CompletionHandler.handleCompletion(
|
|
411
413
|
lspHook = lspHook
|
|
412
414
|
toplevel = completionAt.column == 1
|
package/package.json
CHANGED