JavaTXLanguageServer

This Repo contains the LanguageServer for JavaTX as well as various Clients to use it.
It uses the LSP4J Framework in Version 0.23.1.

Functionality

Currently the Language Server has the following functionalities:

  • Syntax-Check
  • Autocomplete for ForLoops and Main Method.
  • Basic Autoformatting (removing every Space at the End of the Line)
  • Display Type of Methods and Parameters with TypeInference
  • Select Type of typinfered Type and replace it (including Generics)
  • Give Hint of all possible Types to Select from (including Generics)

Project Structure

.
├── Client/
│   ├── VisualStudioCode                       -> Containing the Client for VS Code. In this Case a Extension. 
│   ├── Emacs
│   ├── Intellij
│   └── ...
└── LanguageServer/
    └── src/main/java/de/dhbw/
        ├── compiler/                           -> Containing the JavaTX Compiler
        │   └── ... 
        ├── model/
        │   └── parseError/
        │       └── ...                         -> Containing Custom Parse-Errors.
        ├── parser/
        │   └── ...                             -> Containing an the JavaTX ANTLR Parser for Syntax-Checks.
        ├── helper/
        │   └── ...                             -> Containing Helper-Classes for the Language Server.
        ├── JavaTXLanguageServer.java           -> Orchestrator of the Language Server
        ├── JavaTXLanguageServerLauncher.java   -> Class to start the Language Server.
        ├── JavaTXTextDocumentService.java      -> Language-Server Features for a Single File
        └── JavaTXWorkspaceService.java         -> Language-Server Features for the Workspace

Usage

To use this Language Server you have to follow this steps:

  1. Package the LanguageServer with maven:package.
  2. Open the VS-Code Client and run npm install.
  3. run npm run compile
  4. Go to Debug and Run the Extension.
  5. Press F1 and execute the Hello World Command.
  6. You can create .jav Files which will be analysed by the Language Server.

Known Problems and what to do

  1. If the TypeInference does not display any Typehints or Typeselection, restart the IDE including the Extension thus deleting the Cache.
  2. Selecting a Generic will Result in a Class-Generic extending Object, wich is not legal in Java. Delete the extends Statement.
  3. Selecting a Generic after another Generic is selected results in illegal Syntax. Delete the newly greated Generic and add the Generic Name and if needet its extension into the other Declaration.

Logic

The Language Server in itself can be used for any Client. The Clients task is to start the Langauge Server and handle the Communication with it.

Diagram

Description
Language Server for JavaTX including various Clients.
Readme 366 MiB
Languages
Java 99.8%
TypeScript 0.2%