@@ -4,22 +4,22 @@ import com.google.gson.Gson
44import  org.eclipse.lsp4j.ExecuteCommandParams 
55import  org.eclipse.lsp4j.Position 
66import  org.eclipse.lsp4j.Range 
7+ import  org.eclipse.lsp4j.TextDocumentIdentifier 
78import  org.junit.Test 
89import  org.junit.Assert.assertEquals 
910import  org.junit.Assert.assertNotNull 
1011import  org.junit.Assert.assertNull 
11- import  org.javacs.kt.command.RESOLVE_MAIN 
1212
1313class  NoMainResolve  : SingleFileTestFixture (" resolvemain" " NoMain.kt" 
1414    @Test
1515    fun  `Should not find any main class info` 
1616        val  root =  testResourcesRoot().resolve(workspaceRoot)
17-         val  executeCommandParams  =  ExecuteCommandParams ( RESOLVE_MAIN ,  listOf ( Gson ().toJsonTree( root.resolve(file).toUri().toString(), )) )
17+         val  fileUri  =  root.resolve(file).toUri().toString()
1818
19-         val  commandResult  =  languageServer.workspaceService.executeCommand(executeCommandParams ).get()
19+         val  result  =  languageServer.getProtocolExtensionService().mainClass( TextDocumentIdentifier (fileUri) ).get()
2020
21-         assertNotNull(commandResult )
22-         val  mainInfo =  commandResult  as  Map <String , String >
21+         assertNotNull(result )
22+         val  mainInfo =  result  as  Map <String , String >
2323        assertNull(mainInfo[" mainClass" 
2424        assertEquals(root.toString(), mainInfo[" projectRoot" 
2525    }
@@ -30,12 +30,12 @@ class SimpleMainResolve : SingleFileTestFixture("resolvemain", "Simple.kt") {
3030    @Test
3131    fun  `Should resolve correct main class of simple file` 
3232        val  root =  testResourcesRoot().resolve(workspaceRoot)
33-         val  executeCommandParams  =  ExecuteCommandParams ( RESOLVE_MAIN ,  listOf ( Gson ().toJsonTree( root.resolve(file).toUri().toString())) )
33+         val  fileUri  =  root.resolve(file).toUri().toString()
3434
35-         val  commandResult  =  languageServer.workspaceService.executeCommand(executeCommandParams ).get()
35+         val  result  =  languageServer.getProtocolExtensionService().mainClass( TextDocumentIdentifier (fileUri) ).get()
3636
37-         assertNotNull(commandResult )
38-         val  mainInfo =  commandResult  as  Map <String , Any >
37+         assertNotNull(result )
38+         val  mainInfo =  result  as  Map <String , Any >
3939        assertEquals(" test.SimpleKt" " mainClass" 
4040        assertEquals(Range (Position (2 , 0 ), Position (4 , 1 )), mainInfo[" range" 
4141        assertEquals(root.toString(), mainInfo[" projectRoot" 
@@ -47,12 +47,12 @@ class JvmNameAnnotationMainResolve : SingleFileTestFixture("resolvemain", "JvmNa
4747    @Test
4848    fun  `Should resolve correct main class of file annotated with JvmName` 
4949        val  root =  testResourcesRoot().resolve(workspaceRoot)
50-         val  executeCommandParams  =  ExecuteCommandParams ( RESOLVE_MAIN ,  listOf ( Gson ().toJsonTree( root.resolve(file).toUri().toString())) )
50+         val  fileUri  =  root.resolve(file).toUri().toString()
5151
52-         val  commandResult  =  languageServer.workspaceService.executeCommand(executeCommandParams ).get()
52+         val  result  =  languageServer.getProtocolExtensionService().mainClass( TextDocumentIdentifier (fileUri) ).get()
5353
54-         assertNotNull(commandResult )
55-         val  mainInfo =  commandResult  as  Map <String , Any >
54+         assertNotNull(result )
55+         val  mainInfo =  result  as  Map <String , Any >
5656        assertEquals(" com.mypackage.name.Potato" " mainClass" 
5757        assertEquals(Range (Position (5 , 0 ), Position (7 , 1 )), mainInfo[" range" 
5858        assertEquals(root.toString(), mainInfo[" projectRoot" 
@@ -63,12 +63,12 @@ class CompanionObjectMainResolve : SingleFileTestFixture("resolvemain", "Compani
6363    @Test
6464    fun  `Should resolve correct main class of main function inside companion object` 
6565        val  root =  testResourcesRoot().resolve(workspaceRoot)
66-         val  executeCommandParams  =  ExecuteCommandParams ( RESOLVE_MAIN ,  listOf ( Gson ().toJsonTree( root.resolve(file).toUri().toString())) )
66+         val  fileUri  =  root.resolve(file).toUri().toString()
6767
68-         val  commandResult  =  languageServer.workspaceService.executeCommand(executeCommandParams ).get()
68+         val  result  =  languageServer.getProtocolExtensionService().mainClass( TextDocumentIdentifier (fileUri) ).get()
6969
70-         assertNotNull(commandResult )
71-         val  mainInfo =  commandResult  as  Map <String , Any >
70+         assertNotNull(result )
71+         val  mainInfo =  result  as  Map <String , Any >
7272        assertEquals(" test.my.companion.SweetPotato" " mainClass" 
7373        assertEquals(Range (Position (8 , 8 ), Position (11 , 9 )), mainInfo[" range" 
7474        assertEquals(root.toString(), mainInfo[" projectRoot" 
0 commit comments