Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

Running KEITH

Setting up your eclipse

For everything not mentioned here refer to Getting Eclipse guide.

Use the installer go to advanced mode, add the KIELER url. Then select first pragmatics and after that semantics (that is very important).

Select the Theia stream for semantics and the Keith stream for pragmatics and use the latest eclipse if possible. Set the targetplatform to photon and finish.

Wait till everything installs and the setup tasks finish. If you have any problems in this stage refer to the Getting Eclipse guide.


The setup tasks for Modular Target will fail. Disable it after this happens and execute them again via Help>Perform Setup Tasks. Run clean build. Several pragmatics projects have error. Just close them and you will be fine.

To run the language server go to Run Configurations create a new eclipse application run configuration and select Run an application  and de.cau.cs.kieler.language.server.LanguageServer


You have to edit the arguments too. The Vm arguments host and port are added to connect the LS via socket.

The default port to which KEITH tries to connect is 5007.

Setting up a KEITH developer setup...

General requirements:

  • node
  • npm (whatever node installs)
  • yarn (latest version)
  • Python (2.7.X)
  • gcc, g++, and make (for native dependencies of some npm packages)
  • Visual Studio Code (latest version)
  • a cloned keith repository

... on linux:

(Theia has a guide for extension development that might be helpful)

install node 8:

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
nvm install 8

Install python if you haven't (remember: Python 2: (thumbs up), Python 3: (thumbs down)).

Install yarn (a package manager build on the package manager npm):


npm install -g yarn


... on windows:

Install node 8 for windows. I personally used the .msi.

Use that to install windows-build-tools by executing the command in an administrative powershell.

npm install -g windows-build-tools

This installs make, gcc, g++, python and all this (I am not sure about yarn, anyway you can always install yarn the same way as in the linux description)

Known Problems in this step

Python is not correctly registered in the path.

... on mac:

Get a package manager, something like brew.

Use brew to install all necessary stuff.

Apparently there is an issue with xcode-select: Theia developers recommend the following:

xcode-select --install

After doing this for your OS all that is missing is running KEITH (in developer setup) and setting up your eclipse for language server development).

Stuff that may help

Running the already build LS

Go to the latest Bamboo build and go to Artifacts.

Select Language Server Zip and download the LS and unpack it somewhere.

Locate the kieler.ini file. Depending on the OS it has a different location (linux; toplevel, windows, toplevel, mac: Content/Eclipse/kieler.ini)

Paste the following at the beginning of the ini-file:

-application 
de.cau.cs.kieler.language.server.LanguageServer 
-noSplash

Since an eclipse application is built, this is needed to start the LS without a splashscreen.

If you want to connect that LS via socket to your Theia application (KEITH) add the following to the vmargs:

-Dport=5007

5007 is the standard port KEITH is currently connecting to in socket mode. You can find this port in your Theia application at the following location:

Assume you are in the keith repository. Go to keith-app, you should see something like this:

Open the package.json. In the package.json are several scripts defined.

The LSP_PORT option is used to activate the connection via socket. It is also possible to specify a relative location to a LS via LS_PATH=<path to LS>.

You can also set these options for an already build keith electron app.


How run KEITH in developer setup (socket)

Run the following to build and run KEITH in its developer setup (in socket mode, so the LS has to be started separately)

yarn && cd keith-app && yarn run socket

Per default the KEITH opens on localhost:3000.

It is required to restart the language server if KEITH is restarted, since the diagram view has a problem (since theia-sprotty is used) to reconnect after that.

Developing for KEITH

We use java ServiceLoader to register stuff. Here is a small example how a LanguageServerExtension is registered via a ServiceLoader and how it is used:

ServiceLoader Example

This is a LanguageServerExtension. It has to be used in the de.cau.cs.kieler.language.server plugin. Since the language-sever-plugin should not have dependencies to all plugins that define a language server extension dependency inversion is used to prevent that. A ServiceLoader does exactly that.

Here is such an example extension, the KiCoolLanguageServerExtension:

package de.cau.cs.kieler.kicool.ide.language.server


/**
 * @author really fancy name
 *
 */
@Singleton
class KiCoolLanguageServerExtension implements ILanguageServerExtension, CommandExtension {
	// fancy extension stuff   
}

This language server extension is provided by a corresponding contribution, which is later used to access it:

package de.cau.cs.kieler.kicool.ide.language.server

import com.google.inject.Injector
import de.cau.cs.kieler.language.server.ILanguageServerContribution

/**
 * @author really fancy name
 *
 */
class KiCoolLanguageServerContribution implements ILanguageServerContribution {
    
    override getLanguageServerExtension(Injector injector) {
        return injector.getInstance(KiCoolLanguageServerExtension)
    }
}

Create a file called de.cau.cs.kieler.language.server.ILanguageServerContribution in <plugin>/META-INF/services/ (in this example this is de.cau.cs.kieler.kicool.ide). The name of the file refers to the contribution interface that should be used to provide the contribution. The content of the file is the following:

de.cau.cs.kieler.kicool.ide.language.server.KiCoolLanguageServerContribution

This is the fully qualified name of the contribution written earlier.

The language server uses all LanguageServerExtensions like this:

var iLanguageServerExtensions = <Object>newArrayList(languageServer) // list of all language server extensions
for (lse : KielerServiceLoader.load(ILanguageServerContribution)) { // load all contributions
	iLanguageServerExtensions.add(lse.getLanguageServerExtension(injector))
}

The resulting list of implementions is used to add the extensions to the language server.

Register an extension (on server side)

See example above for ServiceLoader and initial stuff.

What is still missing are the contents of the CommandExtension implemented by the KiCoolLanguageServerExtension. This is an interface defining all additional commands. The CommandExtension looks like this.

package de.cau.cs.kieler.kicool.ide.language.server

import java.util.concurrent.CompletableFuture
import org.eclipse.lsp4j.jsonrpc.services.JsonRequest
import org.eclipse.lsp4j.jsonrpc.services.JsonSegment

/**
 * Interface to the LSP extension commands
 * 
 * @author really fancy name
 *
 */
@JsonSegment('keith/kicool')
interface CommandExtension {
    
    /**
     * Compiles file given by uri with compilationsystem given by command.
     */
    @JsonRequest('compile')
    def CompletableFuture<CompilationResults> compile(String uri, String clientId, String command, boolean inplace);
    
    /**
     * Build diagram for snapshot with id index for file given by uri. Only works, if the file was already compiled.
     */
    @JsonRequest('show')
    def CompletableFuture<String> show(String uri, String clientId, int index)
    
    /**
     * Returns all compilation systems which are applicable for the file at given uri.
     * 
     * @param uri URI as string to get compilation systems for
     * @param filter boolean indicating whether compilation systems should be filtered
     */
    @JsonRequest('get-systems')
    def CompletableFuture<Object> getSystems(String uri, boolean filterSystems)
}

This defines three json-rpc commands: "keith/kicool/compile", "keith/kicool/show", "keith/kicool/get-systems". These are implemented in KiCoolLanguageServerExtension.

Register and calling an extension (on client side)

Language server extension do not have to be registered on the client side. It is just called.

You can send a request or a notification to the language server like this:

const lclient = await this.client.languageClient
const snapshotsDescriptions: CodeContainer = await lclient.sendRequest("keith/kicool/compile", [uri, KeithDiagramManager.DIAGRAM_TYPE + '_sprotty', command,
	this.compilerWidget.compileInplace]) as CodeContainer
// or via a thenable
client.languageClient.then(lClient => {
lClient.sendRequest("keith/kicool/compile").then((languages: LanguageDescription[]) => {
	// very important stuff
}
// await is preferred, since it is shorter. 

In this example client is an instance of a language client. It is usally injected like this:

constructor(
	@inject(KeithLanguageClientContribution) public readonly client: KeithLanguageClientContribution
	// other injected classes
    ) {
	// constructor stuff
}


How to make a new

How to write a widget

  • No labels