Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@
"outFiles": [
"${workspaceFolder}/editors/vscode/out/test/**/*.js"
]
},
{
"type": "java",
"name": "Debug Tests",
"request": "attach",
"hostName": "localhost",
"port": 5005
}
]
}
7 changes: 7 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
plugins {
id 'org.jetbrains.kotlin.jvm' version "$kotlinVersion"
}

repositories {
mavenCentral()
}
8 changes: 4 additions & 4 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
teamCityUrl=https://teamcity.jetbrains.com
teamCityUsername=guest
teamCityPassword=guest
kotlinVersion=1.3.11
kotlinBuildType=Kotlin_130_CompilerAllPlugins
kotlinBuild=1.3.11-release-272
kotlinPluginBuild=1.3.11-release-IJ2018.3-1
kotlinVersion=1.3.40
kotlinBuildType=Kotlin_1340_CompilerAllPlugins
kotlinBuild=1.3.41-release-150
kotlinPluginBuild=1.3.41-release-IJ2019.2-1
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6-rc-1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
168 changes: 84 additions & 84 deletions gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
10 changes: 6 additions & 4 deletions server/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id 'org.jetbrains.kotlin.jvm'
id 'maven'
id 'application'
id 'com.github.jk1.tcdeps' version '0.17'
id 'com.github.jk1.tcdeps' version '0.19'
id 'com.jaredsburrows.license' version '0.8.42'
}

Expand Down Expand Up @@ -40,18 +40,19 @@ configurations {
}

dependencies {
def kotlinTeamCity = "$kotlinBuildType:$kotlinBuild:kotlin-plugin-${kotlinPluginBuild}.zip!/Kotlin"
def kotlinPluginTC = "$kotlinBuildType:$kotlinBuild:kotlin-plugin-${kotlinPluginBuild}.zip!/Kotlin"

implementation project(':shared')
implementation 'com.google.guava:guava:21.0'
implementation 'org.eclipse.lsp4j:org.eclipse.lsp4j:0.5.0'
implementation 'org.jetbrains.kotlin:kotlin-compiler'
implementation 'org.jetbrains.kotlin:kotlin-scripting-compiler'
implementation 'org.jetbrains.kotlin:kotlin-reflect'
implementation 'org.jetbrains:fernflower:1.0'
implementation fileTree(dir: "$projectDir/lib-kotlin", include: ["*.jar"])

kotlinJVMLib tc("$kotlinTeamCity/lib/kotlin-plugin.jar")
kotlinJVMLib tc("$kotlinTeamCity/lib/j2k.jar")
// TODO: Isolate J2K dependency from the plugin:
kotlinJVMLib tc("$kotlinPluginTC/lib/kotlin-plugin.jar")

testImplementation 'org.hamcrest:hamcrest-all:1.3'
testImplementation 'junit:junit:4.11'
Expand Down Expand Up @@ -118,6 +119,7 @@ run {
}

test {
maxHeapSize = "1G"
testLogging {
events "failed"
exceptionFormat "short"
Expand Down
23 changes: 16 additions & 7 deletions server/src/main/kotlin/org/javacs/kt/Compiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.openapi.vfs.VirtualFileSystem
import com.intellij.psi.PsiFileFactory
import com.intellij.mock.MockProject
import org.jetbrains.kotlin.cli.common.script.CliScriptDefinitionProvider
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.jvm.compiler.CliBindingTrace
import org.jetbrains.kotlin.cli.jvm.compiler.EnvironmentConfigFiles
Expand All @@ -20,25 +19,34 @@ import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.config.JvmTarget
import org.jetbrains.kotlin.container.ComponentProvider
import org.jetbrains.kotlin.container.get
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.idea.KotlinLanguage
import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.BindingTraceContext
import org.jetbrains.kotlin.resolve.LazyTopDownAnalyzer
import org.jetbrains.kotlin.resolve.TopDownAnalysisMode.TopLevelDeclarations
import org.jetbrains.kotlin.resolve.calls.components.InferenceSession
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
import org.jetbrains.kotlin.resolve.lazy.declarations.FileBasedDeclarationProviderFactory
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.script.KotlinScriptDefinition
import org.jetbrains.kotlin.script.ScriptDefinitionProvider
import org.jetbrains.kotlin.scripting.configuration.ScriptingConfigurationKeys
import org.jetbrains.kotlin.scripting.compiler.plugin.definitions.CliScriptDefinitionProvider
import org.jetbrains.kotlin.scripting.compiler.plugin.definitions.CliScriptDependenciesProvider
import org.jetbrains.kotlin.scripting.compiler.plugin.ScriptingCompilerConfigurationComponentRegistrar
import org.jetbrains.kotlin.scripting.definitions.KotlinScriptDefinition
import org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider
import org.jetbrains.kotlin.scripting.definitions.ScriptDependenciesProvider
import org.jetbrains.kotlin.scripting.definitions.StandardScriptDefinition
import org.jetbrains.kotlin.types.TypeUtils
import org.jetbrains.kotlin.types.expressions.ExpressionTypingServices
import org.jetbrains.kotlin.util.KotlinFrontEndException
import java.nio.file.Path
import java.nio.file.Paths
import java.util.concurrent.locks.ReentrantLock
import kotlin.concurrent.withLock
import kotlin.script.experimental.jvm.defaultJvmScriptingHostConfiguration
import org.javacs.kt.util.KotlinLSException
import org.javacs.kt.util.KotlinNullableNotNullManager
import org.javacs.kt.util.LoggingMessageCollector
Expand All @@ -51,7 +59,7 @@ class Compiler(classPath: Set<Path>) {
val environment: KotlinCoreEnvironment

private var parser: KtPsiFactory
private var scripts: CliScriptDefinitionProvider
private var scripts: ScriptDefinitionProvider
private val localFileSystem: VirtualFileSystem

companion object {
Expand All @@ -67,6 +75,8 @@ class Compiler(classPath: Set<Path>) {
configuration = KotlinCompilerConfiguration().apply {
put(CommonConfigurationKeys.MODULE_NAME, JvmAbi.DEFAULT_MODULE_NAME)
put(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY, LoggingMessageCollector)
add(ComponentRegistrar.PLUGIN_COMPONENT_REGISTRARS, ScriptingCompilerConfigurationComponentRegistrar())
add(ScriptingConfigurationKeys.SCRIPT_DEFINITIONS, StandardScriptDefinition)
addJvmClasspathRoots(classPath.map { it.toFile() })
},
configFiles = EnvironmentConfigFiles.JVM_CONFIG_FILES
Expand All @@ -78,8 +88,7 @@ class Compiler(classPath: Set<Path>) {
}

parser = KtPsiFactory(environment.project)
scripts = ScriptDefinitionProvider.getInstance(environment.project) as CliScriptDefinitionProvider
scripts.setScriptDefinitions(listOf(KotlinScriptDefinition(Any::class)))
scripts = ScriptDefinitionProvider.getInstance(environment.project)!!
localFileSystem = VirtualFileManager.getInstance().getFileSystem(StandardFileSystems.FILE_PROTOCOL)
}

Expand All @@ -97,7 +106,6 @@ class Compiler(classPath: Set<Path>) {
"default" -> JvmTarget.DEFAULT
"1.6" -> JvmTarget.JVM_1_6
"1.8" -> JvmTarget.JVM_1_8
// TODO: Add once Java 9+ is supported
// "9" -> JvmTarget.JVM_9
// "10" -> JvmTarget.JVM_10
// "11" -> JvmTarget.JVM_11
Expand Down Expand Up @@ -181,6 +189,7 @@ class Compiler(classPath: Set<Path>) {
expression,
TypeUtils.NO_EXPECTED_TYPE,
DataFlowInfo.EMPTY,
InferenceSession.default,
trace,
true)
return Pair(trace.bindingContext, container)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,11 @@ class KotlinTextDocumentService(
private fun clearDiagnostics(file: Path) {
client.publishDiagnostics(PublishDiagnosticsParams(file.toUri().toString(), listOf()))
}

fun shutdownExecutors(awaitTermination: Boolean) {
async.shutdown(awaitTermination)
debounceLint.shutdown(awaitTermination)
}
}

private inline fun<T> reportTime(block: () -> T): T {
Expand Down
7 changes: 0 additions & 7 deletions server/src/main/kotlin/org/javacs/kt/hover/Hovers.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,6 @@ import org.jetbrains.kotlin.psi.KtCallableDeclaration
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.descriptors.CallableDescriptor
import org.jetbrains.kotlin.descriptors.ClassifierDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.caches.resolve.findModuleDescriptor
import org.jetbrains.kotlin.idea.caches.resolve.getResolutionFacade
import org.jetbrains.kotlin.idea.project.languageVersionSettings
import org.jetbrains.kotlin.idea.references.mainReference
import org.jetbrains.kotlin.idea.resolve.frontendService
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
Expand All @@ -27,7 +21,6 @@ import org.jetbrains.kotlin.resolve.BindingContext
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.calls.callUtil.getType
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowValueFactory
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode
import org.javacs.kt.CompiledFile
import org.javacs.kt.completion.DECL_RENDERER
import org.javacs.kt.position.position
Expand Down
2 changes: 1 addition & 1 deletion server/src/test/kotlin/org/javacs/kt/CompilerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,4 @@ private class FileToEdit {

assertThat(target.name, hasToString("intFunction"))
}
}
}
Loading