mirror of
https://github.com/irmen/prog8.git
synced 2025-07-28 14:24:13 +00:00
Compare commits
6 Commits
v11.4
...
languageSe
Author | SHA1 | Date | |
---|---|---|---|
|
9daa116148 | ||
|
054c98da7c | ||
|
a4a1b563aa | ||
|
7dd64b4f13 | ||
|
edc353cc24 | ||
|
0a16dcafc0 |
8
.idea/kotlinc.xml
generated
8
.idea/kotlinc.xml
generated
@@ -7,13 +7,13 @@
|
|||||||
<option name="jvmTarget" value="11" />
|
<option name="jvmTarget" value="11" />
|
||||||
</component>
|
</component>
|
||||||
<component name="KotlinCommonCompilerArguments">
|
<component name="KotlinCommonCompilerArguments">
|
||||||
<option name="apiVersion" value="2.1" />
|
<option name="apiVersion" value="2.2" />
|
||||||
<option name="languageVersion" value="2.1" />
|
<option name="languageVersion" value="2.2" />
|
||||||
</component>
|
</component>
|
||||||
<component name="KotlinCompilerSettings">
|
<component name="KotlinCompilerSettings">
|
||||||
<option name="additionalArguments" value="-Xwhen-guards" />
|
<option name="additionalArguments" value="-Xwhen-guards -jvm-default=no-compatibility" />
|
||||||
</component>
|
</component>
|
||||||
<component name="KotlinJpsPluginSettings">
|
<component name="KotlinJpsPluginSettings">
|
||||||
<option name="version" value="2.1.10" />
|
<option name="version" value="2.2.0" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
20
.idea/libraries/KotlinJavaRuntime.xml
generated
20
.idea/libraries/KotlinJavaRuntime.xml
generated
@@ -1,23 +1,23 @@
|
|||||||
<component name="libraryTable">
|
<component name="libraryTable">
|
||||||
<library name="KotlinJavaRuntime" type="repository">
|
<library name="KotlinJavaRuntime" type="repository">
|
||||||
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.20" />
|
<properties maven-id="org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.2.0" />
|
||||||
<CLASSES>
|
<CLASSES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.1.20/kotlin-stdlib-jdk8-2.1.20.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.2.0/kotlin-stdlib-jdk8-2.2.0.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.1.20/kotlin-stdlib-2.1.20.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.2.0/kotlin-stdlib-2.2.0.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.1.20/kotlin-stdlib-jdk7-2.1.20.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.2.0/kotlin-stdlib-jdk7-2.2.0.jar!/" />
|
||||||
</CLASSES>
|
</CLASSES>
|
||||||
<JAVADOC>
|
<JAVADOC>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.1.20/kotlin-stdlib-jdk8-2.1.20-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.2.0/kotlin-stdlib-jdk8-2.2.0-javadoc.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.1.20/kotlin-stdlib-2.1.20-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.2.0/kotlin-stdlib-2.2.0-javadoc.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.1.20/kotlin-stdlib-jdk7-2.1.20-javadoc.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.2.0/kotlin-stdlib-jdk7-2.2.0-javadoc.jar!/" />
|
||||||
</JAVADOC>
|
</JAVADOC>
|
||||||
<SOURCES>
|
<SOURCES>
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.1.20/kotlin-stdlib-jdk8-2.1.20-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/2.2.0/kotlin-stdlib-jdk8-2.2.0-sources.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.1.20/kotlin-stdlib-2.1.20-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/2.2.0/kotlin-stdlib-2.2.0-sources.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
|
||||||
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.1.20/kotlin-stdlib-jdk7-2.1.20-sources.jar!/" />
|
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/2.2.0/kotlin-stdlib-jdk7-2.2.0-sources.jar!/" />
|
||||||
</SOURCES>
|
</SOURCES>
|
||||||
</library>
|
</library>
|
||||||
</component>
|
</component>
|
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@@ -15,6 +15,7 @@
|
|||||||
<module fileurl="file://$PROJECT_DIR$/docs/docs.iml" filepath="$PROJECT_DIR$/docs/docs.iml" />
|
<module fileurl="file://$PROJECT_DIR$/docs/docs.iml" filepath="$PROJECT_DIR$/docs/docs.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/examples/examples.iml" filepath="$PROJECT_DIR$/examples/examples.iml" />
|
<module fileurl="file://$PROJECT_DIR$/examples/examples.iml" filepath="$PROJECT_DIR$/examples/examples.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/intermediate/intermediate.iml" filepath="$PROJECT_DIR$/intermediate/intermediate.iml" />
|
<module fileurl="file://$PROJECT_DIR$/intermediate/intermediate.iml" filepath="$PROJECT_DIR$/intermediate/intermediate.iml" />
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/languageServer/languageServer.iml" filepath="$PROJECT_DIR$/languageServer/languageServer.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/parser/parser.iml" filepath="$PROJECT_DIR$/parser/parser.iml" />
|
<module fileurl="file://$PROJECT_DIR$/parser/parser.iml" filepath="$PROJECT_DIR$/parser/parser.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/modules/prog8.iml" filepath="$PROJECT_DIR$/.idea/modules/prog8.iml" />
|
<module fileurl="file://$PROJECT_DIR$/.idea/modules/prog8.iml" filepath="$PROJECT_DIR$/.idea/modules/prog8.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/simpleAst/simpleAst.iml" filepath="$PROJECT_DIR$/simpleAst/simpleAst.iml" />
|
<module fileurl="file://$PROJECT_DIR$/simpleAst/simpleAst.iml" filepath="$PROJECT_DIR$/simpleAst/simpleAst.iml" />
|
||||||
|
@@ -1,9 +1,10 @@
|
|||||||
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
import org.jetbrains.kotlin.gradle.dsl.JvmTarget
|
||||||
|
import org.jetbrains.kotlin.gradle.dsl.JvmDefaultMode
|
||||||
import org.jetbrains.kotlin.gradle.internal.config.LanguageFeature
|
import org.jetbrains.kotlin.gradle.internal.config.LanguageFeature
|
||||||
|
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("jvm") version "2.1.20"
|
kotlin("jvm") version "2.2.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
@@ -18,6 +19,7 @@ allprojects {
|
|||||||
compilerOptions {
|
compilerOptions {
|
||||||
freeCompilerArgs = listOf("-Xwhen-guards")
|
freeCompilerArgs = listOf("-Xwhen-guards")
|
||||||
jvmTarget = JvmTarget.JVM_11
|
jvmTarget = JvmTarget.JVM_11
|
||||||
|
jvmDefault = JvmDefaultMode.NO_COMPATIBILITY
|
||||||
}
|
}
|
||||||
sourceSets.all {
|
sourceSets.all {
|
||||||
languageSettings {
|
languageSettings {
|
||||||
|
@@ -2491,8 +2491,9 @@ $endLabel""")
|
|||||||
BaseDataType.UBYTE -> {
|
BaseDataType.UBYTE -> {
|
||||||
when(targetDt) {
|
when(targetDt) {
|
||||||
BaseDataType.BOOL -> {
|
BaseDataType.BOOL -> {
|
||||||
|
val compare = if(regs==RegisterOrPair.A) "cmp" else "cp${regs.toString().lowercase()}"
|
||||||
asmgen.out("""
|
asmgen.out("""
|
||||||
cp${regs.toString().lowercase()} #0
|
$compare #0
|
||||||
beq +
|
beq +
|
||||||
ld${regs.toString().lowercase()} #1
|
ld${regs.toString().lowercase()} #1
|
||||||
+ st${regs.toString().lowercase()} $targetAsmVarName""")
|
+ st${regs.toString().lowercase()} $targetAsmVarName""")
|
||||||
|
@@ -5,7 +5,7 @@
|
|||||||
<content url="file://$MODULE_DIR$">
|
<content url="file://$MODULE_DIR$">
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build" />
|
<excludeFolder url="file://$MODULE_DIR$/build" />
|
||||||
</content>
|
</content>
|
||||||
<orderEntry type="jdk" jdkName="Python 3.12" jdkType="Python SDK" />
|
<orderEntry type="jdk" jdkName="Python 3" jdkType="Python SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@@ -65,6 +65,11 @@ Various things:
|
|||||||
and it does it at run time. In this demo a jump table is not only created in the library,
|
and it does it at run time. In this demo a jump table is not only created in the library,
|
||||||
but also in the main program and copied into the library for its use.
|
but also in the main program and copied into the library for its use.
|
||||||
|
|
||||||
|
`Additional custom compilation targets (such as VIC-20) <https://github.com/gillham/prog8targets>`_
|
||||||
|
Various custom targets for Prog8 that are not (yet?) part of the Prog8 examples themselves.
|
||||||
|
These additional compilation targets may be in varying state of completeness.
|
||||||
|
Perhaps most recognisable at the time of adding this link, are the various VIC-20 targets.
|
||||||
|
|
||||||
|
|
||||||
.. image:: _static/curious.png
|
.. image:: _static/curious.png
|
||||||
:align: center
|
:align: center
|
||||||
|
@@ -3,4 +3,4 @@ org.gradle.console=rich
|
|||||||
org.gradle.parallel=true
|
org.gradle.parallel=true
|
||||||
org.gradle.daemon=true
|
org.gradle.daemon=true
|
||||||
kotlin.code.style=official
|
kotlin.code.style=official
|
||||||
version=11.4
|
version=11.5-SNAPSHOT
|
||||||
|
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
BIN
gradle/wrapper/gradle-wrapper.jar
vendored
Binary file not shown.
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@@ -1,6 +1,6 @@
|
|||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.3-bin.zip
|
||||||
networkTimeout=10000
|
networkTimeout=10000
|
||||||
validateDistributionUrl=true
|
validateDistributionUrl=true
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
|
9
gradlew
vendored
9
gradlew
vendored
@@ -86,8 +86,7 @@ done
|
|||||||
# shellcheck disable=SC2034
|
# shellcheck disable=SC2034
|
||||||
APP_BASE_NAME=${0##*/}
|
APP_BASE_NAME=${0##*/}
|
||||||
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
|
||||||
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
|
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit
|
||||||
' "$PWD" ) || exit
|
|
||||||
|
|
||||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||||
MAX_FD=maximum
|
MAX_FD=maximum
|
||||||
@@ -115,7 +114,7 @@ case "$( uname )" in #(
|
|||||||
NONSTOP* ) nonstop=true ;;
|
NONSTOP* ) nonstop=true ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
|
CLASSPATH="\\\"\\\""
|
||||||
|
|
||||||
|
|
||||||
# Determine the Java command to use to start the JVM.
|
# Determine the Java command to use to start the JVM.
|
||||||
@@ -206,7 +205,7 @@ fi
|
|||||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||||
|
|
||||||
# Collect all arguments for the java command:
|
# Collect all arguments for the java command:
|
||||||
# * DEFAULT_JVM_OPTS, JAVA_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments,
|
||||||
# and any embedded shellness will be escaped.
|
# and any embedded shellness will be escaped.
|
||||||
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be
|
||||||
# treated as '${Hostname}' itself on the command line.
|
# treated as '${Hostname}' itself on the command line.
|
||||||
@@ -214,7 +213,7 @@ DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
|||||||
set -- \
|
set -- \
|
||||||
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
"-Dorg.gradle.appname=$APP_BASE_NAME" \
|
||||||
-classpath "$CLASSPATH" \
|
-classpath "$CLASSPATH" \
|
||||||
org.gradle.wrapper.GradleWrapperMain \
|
-jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \
|
||||||
"$@"
|
"$@"
|
||||||
|
|
||||||
# Stop when "xargs" is not available.
|
# Stop when "xargs" is not available.
|
||||||
|
4
gradlew.bat
vendored
4
gradlew.bat
vendored
@@ -70,11 +70,11 @@ goto fail
|
|||||||
:execute
|
:execute
|
||||||
@rem Setup the command line
|
@rem Setup the command line
|
||||||
|
|
||||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
set CLASSPATH=
|
||||||
|
|
||||||
|
|
||||||
@rem Execute Gradle
|
@rem Execute Gradle
|
||||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
|
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %*
|
||||||
|
|
||||||
:end
|
:end
|
||||||
@rem End local scope for the variables with windows NT shell
|
@rem End local scope for the variables with windows NT shell
|
||||||
|
103
languageServer/build.gradle.kts
Normal file
103
languageServer/build.gradle.kts
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
plugins {
|
||||||
|
kotlin("jvm")
|
||||||
|
id("application")
|
||||||
|
}
|
||||||
|
|
||||||
|
val debugPort = 8000
|
||||||
|
val debugArgs = "-agentlib:jdwp=transport=dt_socket,server=y,address=8000,suspend=n,quiet=y"
|
||||||
|
|
||||||
|
val serverMainClassName = "prog8lsp.MainKt"
|
||||||
|
val applicationName = "prog8-language-server"
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass.set(serverMainClassName)
|
||||||
|
description = "Code completions, diagnostics and more for Prog8"
|
||||||
|
// applicationDefaultJvmArgs = listOf("-DkotlinLanguageServer.version=$version")
|
||||||
|
applicationDistribution.into("bin") {
|
||||||
|
filePermissions {
|
||||||
|
user {
|
||||||
|
read=true
|
||||||
|
execute=true
|
||||||
|
write=true
|
||||||
|
}
|
||||||
|
other.execute = true
|
||||||
|
group.execute = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j:0.24.0")
|
||||||
|
implementation("org.eclipse.lsp4j:org.eclipse.lsp4j.jsonrpc:0.24.0")
|
||||||
|
}
|
||||||
|
|
||||||
|
configurations.forEach { config ->
|
||||||
|
config.resolutionStrategy {
|
||||||
|
preferProjectModules()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.main {
|
||||||
|
java.srcDir("src")
|
||||||
|
resources.srcDir("resources")
|
||||||
|
}
|
||||||
|
|
||||||
|
sourceSets.test {
|
||||||
|
java.srcDir("src")
|
||||||
|
resources.srcDir("resources")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.startScripts {
|
||||||
|
applicationName = "prog8-language-server"
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Exec>("fixFilePermissions") {
|
||||||
|
// When running on macOS or Linux the start script
|
||||||
|
// needs executable permissions to run.
|
||||||
|
|
||||||
|
onlyIf { !System.getProperty("os.name").lowercase().contains("windows") }
|
||||||
|
commandLine("chmod", "+x", "${tasks.installDist.get().destinationDir}/bin/prog8-language-server")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<JavaExec>("debugRun") {
|
||||||
|
mainClass.set(serverMainClassName)
|
||||||
|
classpath(sourceSets.main.get().runtimeClasspath)
|
||||||
|
standardInput = System.`in`
|
||||||
|
|
||||||
|
jvmArgs(debugArgs)
|
||||||
|
doLast {
|
||||||
|
println("Using debug port $debugPort")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<CreateStartScripts>("debugStartScripts") {
|
||||||
|
applicationName = "prog8-language-server"
|
||||||
|
mainClass.set(serverMainClassName)
|
||||||
|
outputDir = tasks.installDist.get().destinationDir.toPath().resolve("bin").toFile()
|
||||||
|
classpath = tasks.startScripts.get().classpath
|
||||||
|
defaultJvmOpts = listOf(debugArgs)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Sync>("installDebugDist") {
|
||||||
|
dependsOn("installDist")
|
||||||
|
finalizedBy("debugStartScripts")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.withType<Test>() {
|
||||||
|
testLogging {
|
||||||
|
events("failed")
|
||||||
|
exceptionFormat = org.gradle.api.tasks.testing.logging.TestExceptionFormat.FULL
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.installDist {
|
||||||
|
finalizedBy("fixFilePermissions")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.build {
|
||||||
|
finalizedBy("installDist")
|
||||||
|
}
|
13
languageServer/languageServer.iml
Normal file
13
languageServer/languageServer.iml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" name="eclipse.lsp4j" level="project" />
|
||||||
|
<orderEntry type="library" name="KotlinJavaRuntime" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
34
languageServer/src/prog8lsp/AsyncExecutor.kt
Normal file
34
languageServer/src/prog8lsp/AsyncExecutor.kt
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
package prog8lsp
|
||||||
|
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
import java.util.concurrent.TimeUnit
|
||||||
|
import java.util.function.Supplier
|
||||||
|
|
||||||
|
private var threadCount = 0
|
||||||
|
|
||||||
|
class AsyncExecutor {
|
||||||
|
private val workerThread = Executors.newSingleThreadExecutor { Thread(it, "async${threadCount++}") }
|
||||||
|
|
||||||
|
fun execute(task: () -> Unit) =
|
||||||
|
CompletableFuture.runAsync(Runnable(task), workerThread)
|
||||||
|
|
||||||
|
fun <R> compute(task: () -> R) =
|
||||||
|
CompletableFuture.supplyAsync(Supplier(task), workerThread)
|
||||||
|
|
||||||
|
fun <R> computeOr(defaultValue: R, task: () -> R?) =
|
||||||
|
CompletableFuture.supplyAsync(Supplier {
|
||||||
|
try {
|
||||||
|
task() ?: defaultValue
|
||||||
|
} catch (e: Exception) {
|
||||||
|
defaultValue
|
||||||
|
}
|
||||||
|
}, workerThread)
|
||||||
|
|
||||||
|
fun shutdown(awaitTermination: Boolean) {
|
||||||
|
workerThread.shutdown()
|
||||||
|
if (awaitTermination) {
|
||||||
|
workerThread.awaitTermination(Long.MAX_VALUE, TimeUnit.DAYS)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
19
languageServer/src/prog8lsp/Main.kt
Normal file
19
languageServer/src/prog8lsp/Main.kt
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
package prog8lsp
|
||||||
|
|
||||||
|
import org.eclipse.lsp4j.launch.LSPLauncher
|
||||||
|
import java.util.concurrent.Executors
|
||||||
|
import java.util.logging.Level
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
Logger.getLogger("").level = Level.INFO
|
||||||
|
|
||||||
|
val inStream = System.`in`
|
||||||
|
val outStream = System.out
|
||||||
|
val server = Prog8LanguageServer()
|
||||||
|
val threads = Executors.newSingleThreadExecutor { Thread(it, "client") }
|
||||||
|
val launcher = LSPLauncher.createServerLauncher(server, inStream, outStream, threads) { it }
|
||||||
|
|
||||||
|
server.connect(launcher.remoteProxy)
|
||||||
|
launcher.startListening()
|
||||||
|
}
|
46
languageServer/src/prog8lsp/Prog8LanguageServer.kt
Normal file
46
languageServer/src/prog8lsp/Prog8LanguageServer.kt
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
package prog8lsp
|
||||||
|
|
||||||
|
import org.eclipse.lsp4j.InitializeParams
|
||||||
|
import org.eclipse.lsp4j.InitializeResult
|
||||||
|
import org.eclipse.lsp4j.services.*
|
||||||
|
import java.io.Closeable
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
import java.util.concurrent.CompletableFuture.completedFuture
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
|
class Prog8LanguageServer: LanguageServer, LanguageClientAware, Closeable {
|
||||||
|
private lateinit var client: LanguageClient
|
||||||
|
private val textDocuments = Prog8TextDocumentService()
|
||||||
|
private val workspaces = Prog8WorkspaceService()
|
||||||
|
private val async = AsyncExecutor()
|
||||||
|
private val logger = Logger.getLogger(Prog8LanguageServer::class.simpleName)
|
||||||
|
|
||||||
|
override fun initialize(params: InitializeParams): CompletableFuture<InitializeResult> = async.compute {
|
||||||
|
logger.info("Initializing LanguageServer")
|
||||||
|
|
||||||
|
InitializeResult()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun shutdown(): CompletableFuture<Any> {
|
||||||
|
close()
|
||||||
|
return completedFuture(null)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun exit() { }
|
||||||
|
|
||||||
|
override fun getTextDocumentService(): TextDocumentService = textDocuments
|
||||||
|
|
||||||
|
override fun getWorkspaceService(): WorkspaceService = workspaces
|
||||||
|
|
||||||
|
override fun connect(client: LanguageClient) {
|
||||||
|
logger.info("connecting to language client")
|
||||||
|
this.client = client
|
||||||
|
workspaces.connect(client)
|
||||||
|
textDocuments.connect(client)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun close() {
|
||||||
|
logger.info("closing down")
|
||||||
|
async.shutdown(awaitTermination = true)
|
||||||
|
}
|
||||||
|
}
|
62
languageServer/src/prog8lsp/Prog8TextDocumentService.kt
Normal file
62
languageServer/src/prog8lsp/Prog8TextDocumentService.kt
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
package prog8lsp
|
||||||
|
|
||||||
|
import org.eclipse.lsp4j.*
|
||||||
|
import org.eclipse.lsp4j.jsonrpc.messages.Either
|
||||||
|
import org.eclipse.lsp4j.services.LanguageClient
|
||||||
|
import org.eclipse.lsp4j.services.TextDocumentService
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
import java.util.logging.Logger
|
||||||
|
import kotlin.system.measureTimeMillis
|
||||||
|
|
||||||
|
class Prog8TextDocumentService: TextDocumentService {
|
||||||
|
private var client: LanguageClient? = null
|
||||||
|
private val async = AsyncExecutor()
|
||||||
|
private val logger = Logger.getLogger(Prog8TextDocumentService::class.simpleName)
|
||||||
|
|
||||||
|
fun connect(client: LanguageClient) {
|
||||||
|
this.client = client
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didOpen(params: DidOpenTextDocumentParams) {
|
||||||
|
logger.info("didOpen: $params")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didChange(params: DidChangeTextDocumentParams) {
|
||||||
|
logger.info("didChange: $params")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didClose(params: DidCloseTextDocumentParams) {
|
||||||
|
logger.info("didClose: $params")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didSave(params: DidSaveTextDocumentParams) {
|
||||||
|
logger.info("didSave: $params")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun documentSymbol(params: DocumentSymbolParams): CompletableFuture<MutableList<Either<SymbolInformation, DocumentSymbol>>> = async.compute {
|
||||||
|
logger.info("Find symbols in ${params.textDocument.uri}")
|
||||||
|
val result: MutableList<Either<SymbolInformation, DocumentSymbol>>
|
||||||
|
val time = measureTimeMillis {
|
||||||
|
result = mutableListOf()
|
||||||
|
val range = Range(Position(1,1), Position(1,5))
|
||||||
|
val selectionRange = Range(Position(1,2), Position(1,10))
|
||||||
|
val symbol = DocumentSymbol("test-symbolName", SymbolKind.Constant, range, selectionRange)
|
||||||
|
result.add(Either.forRight(symbol))
|
||||||
|
}
|
||||||
|
logger.info("Finished in $time ms")
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun completion(position: CompletionParams): CompletableFuture<Either<MutableList<CompletionItem>, CompletionList>> = async.compute{
|
||||||
|
logger.info("Completion for ${position}")
|
||||||
|
val result: Either<MutableList<CompletionItem>, CompletionList>
|
||||||
|
val time = measureTimeMillis {
|
||||||
|
val list = CompletionList(false, listOf(CompletionItem("test-completionItem")))
|
||||||
|
result = Either.forRight(list)
|
||||||
|
}
|
||||||
|
logger.info("Finished in $time ms")
|
||||||
|
result
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO add all other methods that get called.... :P
|
||||||
|
}
|
80
languageServer/src/prog8lsp/Prog8WorkspaceService.kt
Normal file
80
languageServer/src/prog8lsp/Prog8WorkspaceService.kt
Normal file
@@ -0,0 +1,80 @@
|
|||||||
|
package prog8lsp
|
||||||
|
|
||||||
|
import org.eclipse.lsp4j.*
|
||||||
|
import org.eclipse.lsp4j.jsonrpc.messages.Either
|
||||||
|
import org.eclipse.lsp4j.services.LanguageClient
|
||||||
|
import org.eclipse.lsp4j.services.WorkspaceService
|
||||||
|
import java.util.concurrent.CompletableFuture
|
||||||
|
import java.util.logging.Logger
|
||||||
|
|
||||||
|
class Prog8WorkspaceService: WorkspaceService {
|
||||||
|
private var client: LanguageClient? = null
|
||||||
|
private val logger = Logger.getLogger(Prog8WorkspaceService::class.simpleName)
|
||||||
|
|
||||||
|
fun connect(client: LanguageClient) {
|
||||||
|
this.client = client
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun executeCommand(params: ExecuteCommandParams): CompletableFuture<Any> {
|
||||||
|
logger.info("executeCommand $params")
|
||||||
|
return super.executeCommand(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun symbol(params: WorkspaceSymbolParams): CompletableFuture<Either<MutableList<out SymbolInformation>, MutableList<out WorkspaceSymbol>>> {
|
||||||
|
logger.info("symbol $params")
|
||||||
|
return super.symbol(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun resolveWorkspaceSymbol(workspaceSymbol: WorkspaceSymbol): CompletableFuture<WorkspaceSymbol> {
|
||||||
|
logger.info("resolveWorkspaceSymbol $workspaceSymbol")
|
||||||
|
return super.resolveWorkspaceSymbol(workspaceSymbol)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didChangeConfiguration(params: DidChangeConfigurationParams) {
|
||||||
|
logger.info("didChangeConfiguration: $params")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didChangeWatchedFiles(params: DidChangeWatchedFilesParams) {
|
||||||
|
logger.info("didChangeWatchedFiles: $params")
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didChangeWorkspaceFolders(params: DidChangeWorkspaceFoldersParams) {
|
||||||
|
logger.info("didChangeWorkspaceFolders $params")
|
||||||
|
super.didChangeWorkspaceFolders(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun willCreateFiles(params: CreateFilesParams): CompletableFuture<WorkspaceEdit> {
|
||||||
|
logger.info("willCreateFiles $params")
|
||||||
|
return super.willCreateFiles(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didCreateFiles(params: CreateFilesParams) {
|
||||||
|
logger.info("didCreateFiles $params")
|
||||||
|
super.didCreateFiles(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun willRenameFiles(params: RenameFilesParams): CompletableFuture<WorkspaceEdit> {
|
||||||
|
logger.info("willRenameFiles $params")
|
||||||
|
return super.willRenameFiles(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didRenameFiles(params: RenameFilesParams) {
|
||||||
|
logger.info("didRenameFiles $params")
|
||||||
|
super.didRenameFiles(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun willDeleteFiles(params: DeleteFilesParams): CompletableFuture<WorkspaceEdit> {
|
||||||
|
logger.info("willDeleteFiles $params")
|
||||||
|
return super.willDeleteFiles(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun didDeleteFiles(params: DeleteFilesParams) {
|
||||||
|
logger.info("didDeleteFiles $params")
|
||||||
|
super.didDeleteFiles(params)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun diagnostic(params: WorkspaceDiagnosticParams): CompletableFuture<WorkspaceDiagnosticReport> {
|
||||||
|
logger.info("diagnostic $params")
|
||||||
|
return super.diagnostic(params)
|
||||||
|
}
|
||||||
|
}
|
@@ -10,5 +10,6 @@ include(
|
|||||||
':codeGenCpu6502',
|
':codeGenCpu6502',
|
||||||
':codeGenExperimental',
|
':codeGenExperimental',
|
||||||
':compiler',
|
':compiler',
|
||||||
':beanshell'
|
':beanshell',
|
||||||
|
':languageServer'
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user