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 (or latest?) 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. Open the plug-in development perspective. Select working sets as top level elements. Run clean build. Several pragmatics projects have errors. 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...
- 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:
Install python if you haven't (remember: Python 2: , Python 3: ).
Install yarn (a package manager build on the package manager npm):
... on windows:
Install node 8 for windows. I personally used the
Use that to install windows-build-tools by executing the command in an administrative powershell.
This installs make, gcc, g++, python and all this. Somehow this does not really terminate. If nothing happens anymore it may be finished, just kill the process if it does not terminate.
All the installed executables are not in the path and that is okay. This is not needed since yarn/npm knows how to call them when needed.
Yarn can be downloaded and installed from here.
Known Problems in this step
If python3 was already installed this may cause some problems.
... 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:
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:
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:
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:
package.json. In the
package.json are several scripts defined.
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>.
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 builds all the stuff. yarn run socket in keith-app starts the application. After an initial build via yarn you can run yarn watch to watch the changes in your repository. In another console you run yarn run socket in keith-app. Now refreshing your browser is enough to apply the changes.
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.
Known issues for windows:
nsfw.code not found: In the top level package.json exists a script called postinstall. Remove this on windows, delete the node_modules folder and rebuilt the application. This is a known issue of electron-builder.
Known issues on mac:
Since SWT is still used as part of the diagram synthesis (but is not relevant anymore). Since it is not called on the main thread this causes a deadlock. Therefore mac just does not work.
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:
Register LanguageServerExtensions (ServiceLoader Example)
This is a LanguageServerExtension. It has to be used in the de.cau.cs.kieler.language.server plugin. Since the language-server-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:
The CommandExtension defines all commands (requests or notifications) that are send from client to server. An example how this looks like can be seen in the code snippet Example CommandExtension is an example how to define a server side extension interface.
The ILanguageClientProvider should be implemented by an extension that plans to send messages from the server to the client.
This language server extension is provided by a corresponding contribution, which is later used to access it:
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:
This is the fully qualified name of the contribution written earlier.
The language server uses all LanguageServerExtensions like this:
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.
This defines three json-rpc commands: "keith/kicool/compile", "keith/kicool/show", "keith/kicool/get-systems". These are implemented in KiCoolLanguageServerExtension.
Server Client communication interface
Not only messages from client to server but rather messages from server client might be needed.
Messages that can be send from server to client are defined in the KeithLanguageClient:
These messages can be caught on the client side by defining the message that is caught like this:
This message type is bound to a method that should be called whenever the client receives such a message.
The method should receive all parameters specific in the KeithLanguageClient interface on the serevr side.
Such a notification from server to client is send like this:
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:
In this example client is an instance of a language client. It is usually injected like this:
How to make a new package for KEITH
Clone the KEITH repository.
Open the keith folder in VSCode. You are know in the keith directory in VSCode.
You see something like this: TODO picture
Create a new folder called keith-<your extension name>.
Copy a package.json, a tslint.json, a tsconfig.json, and a src folder into the folder.
Add keith-<your extension name> to workspaces in the top level package.json.
Add "keith-<your extension name>": "0.1.0" to the dependencies in the top level package.json and the product package.json files (e.g. the package.json in keith-app).
What is in the src directory?
The source directory has three optional subfolders.
- node: Holds all backend related classes. This does currently only exist in the keith-language package.
- common: Holds general helper methods, string constants and some data classes
- browser: Holds all widgets, contribution for commands, menus, and widgets, and the frontend-extension.
More examples for stuff
See Theia examples.
How to write a widget
- BaseWidget: Very basic
- ReactWidget: A render method has to be implemented that redraws the widget on demand. Additionally several on* event methods can beimplemented.
- TreeWidget: Extends the ReactWidget and draws the contents of the widget in a tree view.
If a widget has a state it should implement the StatefulWidget interface, which allows to imlement a store and restore method.
Look at examples in KEITH or Theia to see how this is done.
How to make a new module for sprotty (see actionModule, ...)