Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b691d6e0e3 |
4
Clients/VisualStudioCode/package-lock.json
generated
4
Clients/VisualStudioCode/package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "java-tx-language-extension",
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.18",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "java-tx-language-extension",
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.18",
|
||||
"dependencies": {
|
||||
"@vscode/vsce": "^3.6.1",
|
||||
"vscode-languageclient": "^9.0.1"
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"name": "java-tx-language-extension",
|
||||
"displayName": "Java-TX Language Extension",
|
||||
"description": "The Language Extension for Java-TX with Typehints and Syntax Checks",
|
||||
"version": "0.0.17",
|
||||
"version": "0.0.18",
|
||||
"engines": {
|
||||
"vscode": "^1.94.0"
|
||||
},
|
||||
@@ -21,7 +21,7 @@
|
||||
"title": "TX: Restart Language Server"
|
||||
}
|
||||
],
|
||||
"configuration":[
|
||||
"configuration": [
|
||||
{
|
||||
"title": "JavaTX Language Server Plugin",
|
||||
"properties": {
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import path from 'path';
|
||||
import os from "os";
|
||||
import * as vscode from 'vscode';
|
||||
import {
|
||||
Executable,
|
||||
@@ -6,17 +8,51 @@ import {
|
||||
ServerOptions
|
||||
} from 'vscode-languageclient/node';
|
||||
|
||||
let homeDirectory: string;
|
||||
let currentUser: string;
|
||||
|
||||
function untildify(pathWithTilde: string) {
|
||||
if (homeDirectory === undefined) {
|
||||
homeDirectory = os.homedir();
|
||||
}
|
||||
|
||||
// Handle regular ~ expansion (current user)
|
||||
if (homeDirectory && /^~(?=$|\/|\\)/.test(pathWithTilde)) {
|
||||
return pathWithTilde.replace(/^~/, homeDirectory);
|
||||
}
|
||||
|
||||
// Handle ~username expansion (only for current user)
|
||||
const userMatch = pathWithTilde.match(/^~([^/\\]+)(.*)/);
|
||||
if (userMatch) {
|
||||
if (currentUser === undefined) {
|
||||
currentUser = os.userInfo().username;
|
||||
}
|
||||
|
||||
if (currentUser) {
|
||||
const username = userMatch[1];
|
||||
const rest = userMatch[2];
|
||||
if (username === currentUser) {
|
||||
return homeDirectory + rest;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return unchanged if no expansion occurred
|
||||
return pathWithTilde;
|
||||
}
|
||||
|
||||
let client: LanguageClient | undefined; // <— global, damit wir neu starten können
|
||||
|
||||
function createClient(context: vscode.ExtensionContext): LanguageClient | null {
|
||||
const workspaceFolder = context.extensionPath;
|
||||
const config = vscode.workspace.getConfiguration("tx");
|
||||
|
||||
const compiler = config.get<string>("compilerLocation");
|
||||
let compiler = config.get<string>("compilerLocation");
|
||||
if (!compiler || compiler.trim() === "") {
|
||||
vscode.window.showErrorMessage("Bitte konfiguriere den Pfad des Java-TX Compilers in den Einstellungen!");
|
||||
return null;
|
||||
}
|
||||
compiler = path.resolve(untildify(compiler));
|
||||
|
||||
const cmd: Executable = {
|
||||
command: 'java',
|
||||
@@ -55,12 +91,6 @@ export async function activate(context: vscode.ExtensionContext) {
|
||||
|
||||
console.log('Congratulations, your extension "tx" is now active!');
|
||||
|
||||
// Beispiel-Command aus deinem Code bleibt
|
||||
const hello = vscode.commands.registerCommand('lspclient.helloWorld', () => {
|
||||
vscode.window.showInformationMessage('Hello World from TX!');
|
||||
});
|
||||
context.subscriptions.push(hello);
|
||||
|
||||
// *** NEU: Restart-Command ***
|
||||
const restart = vscode.commands.registerCommand('tx.restartLanguageServer', async () => {
|
||||
if (!client) {
|
||||
|
||||
Reference in New Issue
Block a user