Skip to content

Commit 0d00643

Browse files
committed
修改加载流程
1 parent 862938f commit 0d00643

File tree

5 files changed

+16
-19
lines changed

5 files changed

+16
-19
lines changed

EmmyLua-LS/src/main/kotlin/com/tang/vscode/LuaLanguageServer.kt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,6 @@ class LuaLanguageServer : LanguageServer, LanguageClientAware {
129129
client?.registerCapability(RegistrationParams(listOf(didChangeWatchedFiles)))
130130
val didChangeWorkspaceFolders = Registration(WORKSPACE_FOLDERS_CAPABILITY_ID, WORKSPACE_FOLDERS_CAPABILITY_NAME)
131131
client?.registerCapability(RegistrationParams(listOf(didChangeWorkspaceFolders)))
132-
133-
workspaceService.loadWorkspace()
134132
}
135133

136134
override fun getWorkspaceService(): WorkspaceService {

EmmyLua-LS/src/main/kotlin/com/tang/vscode/LuaTextDocumentService.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,9 @@ class LuaTextDocumentService(private val workspace: LuaWorkspaceService) : TextD
6464

6565
@Suppress("unused")
6666
@JsonRequest("emmy/reportAPI")
67-
fun reportAPI(params: LuaReportApiParams): CompletableFuture<Boolean> {
68-
return computeAsync { checker ->
69-
ExtendApiService.loadApi(workspace.getProject(), params)
70-
true
71-
}
67+
fun reportAPI(params: LuaReportApiParams): CompletableFuture<Void> {
68+
ExtendApiService.loadApi(workspace.getProject(), params)
69+
return CompletableFuture()
7270
}
7371

7472
private fun findAnnotators(file: ILuaFile): List<Annotator> {

EmmyLua-LS/src/main/kotlin/com/tang/vscode/LuaWorkspaceService.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import org.eclipse.lsp4j.services.WorkspaceService
3030
import java.io.File
3131
import java.net.URI
3232
import java.util.concurrent.CompletableFuture
33+
import java.util.concurrent.locks.ReentrantReadWriteLock
3334

3435
/**
3536
* tangzx
@@ -41,6 +42,10 @@ class LuaWorkspaceService : WorkspaceService, IWorkspace {
4142
private val configurationManager = ConfigurationManager()
4243
private var client: LuaLanguageClient? = null
4344
private var configVersion = 0
45+
private val project: Project = WProject()
46+
private val fileManager = FileManager(project)
47+
private val fileScopeProvider = WorkspaceRootFileScopeProvider()
48+
private var initWorkspace = true
4449

4550
inner class WProject : UserDataHolderBase(), Project {
4651
override fun process(processor: Processor<PsiFile>) {
@@ -56,11 +61,6 @@ class LuaWorkspaceService : WorkspaceService, IWorkspace {
5661
}
5762
}
5863

59-
private val project: Project = WProject()
60-
61-
private val fileManager = FileManager(project)
62-
private val fileScopeProvider = WorkspaceRootFileScopeProvider()
63-
6464
init {
6565
project.putUserData(IWorkspace.KEY, this)
6666
fileManager.addProvider(fileScopeProvider)
@@ -87,11 +87,11 @@ class LuaWorkspaceService : WorkspaceService, IWorkspace {
8787
val settings = params.settings as? JsonObject ?: return
8888
val ret = VSCodeSettings.update(settings)
8989
++configVersion
90-
if (ret.associationChanged) {
90+
if (ret.associationChanged || initWorkspace) {
91+
initWorkspace = false
9192
loadWorkspace()
9293
refreshWorkspace()
9394
}
94-
9595
}
9696

9797
fun initConfigFiles(files: Array<EmmyConfigurationSource>) {
@@ -356,7 +356,7 @@ class LuaWorkspaceService : WorkspaceService, IWorkspace {
356356
}
357357
}
358358
} catch (e: Exception) {
359-
System.err.println("workspace parse error: ${e.toString()}")
359+
System.err.println("workspace parse error: $e")
360360
}
361361
monitor.done()
362362
}

EmmyLua-LS/src/main/kotlin/com/tang/vscode/extendApi/ExtendApiService.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ object ExtendApiService {
1616

1717
fun loadApi(project: Project, api: LuaReportApiParams) {
1818
val mgr = PsiManager.getInstance(project)
19-
rootNamespaceName = api.root
19+
rootNamespaceName = api.root.ifEmpty {
20+
"_G"
21+
}
2022
rootNamespace = Namespace(api.root, null, mgr, false)
2123
namespaceMap.clear()
2224
classMap.clear()
@@ -87,8 +89,7 @@ object ExtendApiService {
8789
}
8890
// generic workaround
8991
val genericIndex = name.indexOf('<')
90-
if(genericIndex != -1)
91-
{
92+
if (genericIndex != -1) {
9293
val baseTypeName = name.substring(0, genericIndex)
9394
return classMap[baseTypeName]
9495
}

EmmyLua-LS/src/main/kotlin/com/tang/vscode/extendApi/ExtendTy.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ class Namespace(
227227
get() = myType
228228

229229
override fun toString(): String {
230-
return "namespace: $fullName"
230+
return "namespace $fullName"
231231
}
232232

233233
override fun getComment(): String {

0 commit comments

Comments
 (0)