Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Language Server & VSC extension #139

Merged
merged 40 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
bfedfe5
Language Server: Part 1
fowenix Feb 17, 2024
cce424a
Language Server: Part 2
fowenix Feb 17, 2024
37744f8
Language Server: Part 3
fowenix Feb 17, 2024
2645d2d
Language Server: Part 4
fowenix Feb 17, 2024
841a705
Language Server: Part 5
fowenix Feb 17, 2024
744f47f
Language Server: Part 6
fowenix Feb 18, 2024
882c40c
actually working lang server
zznty Feb 25, 2024
9d5e5a1
treat all non-fatal errors as errors
zznty Feb 26, 2024
f75941f
detailed completions
zznty Feb 26, 2024
3ea72f8
fix issues with top-level methods of the script
zznty Feb 26, 2024
991ee6e
fix activation of vsc extension
zznty Feb 26, 2024
6dd7d2d
make vsc extension naming more user friendly
zznty Feb 26, 2024
346a99d
fix ls crash for unresolved classes
zznty Feb 26, 2024
7bfb0f7
add runConfig support for ls
zznty Feb 26, 2024
aa6c997
fix extension build for vsc
zznty Mar 7, 2024
b3e1fdc
types for game object handlers
brachy84 Mar 7, 2024
269fa8d
resolve definitions for game object handlers
zznty Mar 7, 2024
f7f8206
abstraction for ls documentation
zznty Mar 10, 2024
ab113cd
simple snippets for vscode extension
zznty Mar 10, 2024
dc13275
autocomplete for keywords
zznty Mar 10, 2024
2e9c1fe
update packaging information for ls extension
zznty Mar 11, 2024
5563da7
jvm arg instead of config
brachy84 Mar 11, 2024
c5ed5a2
allow using groovy log before sandbox init
brachy84 Mar 11, 2024
1cab453
update vsc extension readme
brachy84 Mar 11, 2024
a1808c2
sort keywords last
brachy84 Mar 11, 2024
3fd0ab1
completion for item names
brachy84 Mar 11, 2024
b0b3ebc
game object handlers now with builders & completion for all
brachy84 Mar 12, 2024
d065523
try fix ls crash on typing
brachy84 Mar 12, 2024
9351e5e
try fix Botania crash
brachy84 Mar 12, 2024
207ebd3
try fix forestry crash
brachy84 Mar 12, 2024
12be3a6
clean up ASTNodeVisitor
brachy84 Mar 13, 2024
5e03fc1
change default port to 25564
brachy84 Mar 13, 2024
b5fb5c5
better snippets
brachy84 Mar 13, 2024
0acef58
format main.ts
brachy84 Mar 13, 2024
c52f8c2
add command to start ls & update readme
brachy84 Mar 13, 2024
4869292
clean up imports
brachy84 Mar 13, 2024
ff8c061
Merge remote-tracking branch 'origin/master' into server
brachy84 Mar 14, 2024
af2365b
fix Alchemistry goh & roots
brachy84 Mar 14, 2024
8b28165
rename IGameObjectHandler to IGameObjectParser
brachy84 Mar 14, 2024
3adf579
extension 1.0.2
brachy84 Mar 14, 2024
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
3 changes: 3 additions & 0 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -265,4 +265,7 @@ minecraft {
if (project.debug_use_examples_folder.toBoolean()) {
extraRunJvmArguments.add('-Dgroovyscript.use_examples_folder=true')
}
if (project.debug_run_ls.toBoolean()) {
extraRunJvmArguments.add('-Dgroovyscript.run_ls=true')
}
}
1 change: 1 addition & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ modGroup = com.cleanroommc.groovyscript
modVersion = 0.8.0
groovy_version = 4.0.13
debug_use_examples_folder = true
debug_run_ls = true

# Whether to use the old jar naming structure (modid-mcversion-version) instead of the new version (modid-version)
includeMCVersionJar = false
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/cleanroommc/groovyscript/GroovyScript.java
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public class GroovyScript {

@Mod.EventHandler
public void onConstruction(FMLConstructionEvent event) {
if (Boolean.parseBoolean(System.getProperty("groovyscript.run_ls"))) {
new Thread(GroovyScriptLanguageServer::listen).start();
}

MinecraftForge.EVENT_BUS.register(this);
MinecraftForge.EVENT_BUS.register(EventHandler.class);
NetworkHandler.init();
Expand Down Expand Up @@ -185,8 +189,6 @@ public void onPostInit(FMLPostInitializationEvent event) {
.appendSibling(new TextComponentString(value).setStyle(new Style().setColor(TextFormatting.GOLD)))
.appendSibling(new TextComponentTranslation("groovyscript.command.copy.copied_end")));
});

if (GroovyScriptConfig.server) new Thread(GroovyScriptLanguageServer::listen).start();
}

@Mod.EventHandler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,4 @@ public class GroovyScriptConfig {
@ApiStatus.Internal
@Config.Comment("The current set packmode")
public static String packmode = "";

@ApiStatus.Internal
@Config.Comment("Enable the language server")
public static boolean server = true; // TODO: change to false

@ApiStatus.Internal
@Config.Comment("Listening port for the language server")
@Config.RangeInt(min = 1, max = 65535)
public static int port = 8000; // TODO: change port
}
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
package com.cleanroommc.groovyscript.server;

import java.net.ServerSocket;

import com.cleanroommc.groovyscript.GroovyScript;
import com.cleanroommc.groovyscript.api.GroovyLog;
import net.prominic.groovyls.GroovyLanguageServer;
import org.eclipse.lsp4j.jsonrpc.Launcher;
import org.eclipse.lsp4j.services.LanguageClient;

import com.cleanroommc.groovyscript.GroovyScript;
import com.cleanroommc.groovyscript.GroovyScriptConfig;

import net.prominic.groovyls.GroovyLanguageServer;
import java.net.ServerSocket;

public class GroovyScriptLanguageServer extends GroovyLanguageServer {

@SuppressWarnings("InfiniteLoopStatement")
public static void listen() {
GroovyLog.get().infoMC("Starting Language server");
var languageServerContext = new GroovyScriptLanguageServerContext();

while (true) {
GroovyScript.LOGGER.info("Listening on port: {}", GroovyScriptConfig.port);

var server = new GroovyScriptLanguageServer(languageServerContext);
try (var serverSocket = new ServerSocket(GroovyScriptConfig.port);
try (var serverSocket = new ServerSocket(8000);
brachy84 marked this conversation as resolved.
Show resolved Hide resolved
var socket = serverSocket.accept()) {

GroovyScript.LOGGER.info("Accepted connection from: {}", socket.getInetAddress());
Expand Down