Hide last authors
Soeren Domroes 7.1 1 = Running KEITH =
Soeren Domroes 6.1 2
Soeren Domroes 7.1 3
4
Soeren Domroes 16.1 5 {{toc maxLevel="2"/}}
Soeren Domroes 6.1 6
Soeren Domroes 5.1 7 == Setting up your eclipse ==
Soeren Domroes 1.1 8
Soeren Domroes 8.1 9 For everything not mentioned here refer to [[Getting Eclipse>>doc:KIELER.Getting Eclipse||shape="rect"]] guide.
Soeren Domroes 1.1 10
Soeren Domroes 15.1 11 Use the installer go to advanced mode, add the KIELER url. Then select first pragmatics and after that semantics (**that is very** **important**).
Soeren Domroes 1.1 12
Soeren Domroes 15.1 13 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.
Soeren Domroes 1.1 14
Soeren Domroes 8.1 15 Wait till everything installs and the setup tasks finish. If you have any problems in this stage refer to the [[Getting Eclipse>>doc:KIELER.Getting Eclipse||shape="rect"]] guide.
Soeren Domroes 1.1 16
Soeren Domroes 5.1 17 \\
Soeren Domroes 1.1 18
Soeren Domroes 13.1 19 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.
Soeren Domroes 1.1 20
Soeren Domroes 5.1 21 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//
Soeren Domroes 1.1 22
Soeren Domroes 5.1 23 == [[image:attach:Screenshot from 2019-02-15 14-10-50.png]] ==
Soeren Domroes 1.1 24
Soeren Domroes 5.1 25 \\
Soeren Domroes 1.1 26
Soeren Domroes 5.1 27 You have to edit the arguments too. The Vm arguments host and port are added to connect the LS via socket.
Soeren Domroes 1.1 28
Soeren Domroes 5.1 29 [[image:attach:Screenshot from 2019-02-15 14-13-34.png]]
Soeren Domroes 1.1 30
Soeren Domroes 5.1 31 The default port to which KEITH tries to connect is 5007.
Soeren Domroes 1.1 32
33 == Setting up a KEITH developer setup... ==
34
35 General requirements:
36
37 * node
38 * npm (whatever node installs)
39 * yarn (latest version)
40 * Python (2.7.X)
41 * gcc, g++, and make (for native dependencies of some npm packages)
42 * [[Visual Studio Code>>url:https://code.visualstudio.com/||shape="rect"]] (latest version)
43 * a cloned [[keith >>url:https://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/keith/browse||shape="rect"]]repository
44
45 == ... on linux: ==
46
47 (Theia has a [[guide >>url:https://www.theia-ide.org/doc/authoring_extensions||shape="rect"]]for extension development that might be helpful)
48
49 install node 8:
50
51 {{code}}
52 curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.33.5/install.sh | bash
53 nvm install 8
54 {{/code}}
55
56 Install python if you haven't (remember: Python 2: , Python 3: ).
57
58 {{code language="none"}}
59 Install yarn (a package manager build on the package manager npm):
60 {{/code}}
61
62 {{{}}}
63
64 \\
65
66 {{code}}
67 npm install -g yarn
68 {{/code}}
69
70 \\
71
72 == ... on windows: ==
73
74 Install [[node 8>>url:https://nodejs.org/download/release/v8.15.0/||shape="rect"]] for windows. I personally used the {{code language="none"}}.msi{{/code}}.
75
Soeren Domroes 11.1 76 Use that to install windows-build-tools by executing the command in an administrative powershell.
Soeren Domroes 1.1 77
78 {{code}}
79 npm install -g windows-build-tools
80 {{/code}}
81
Soeren Domroes 15.1 82 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.
Soeren Domroes 1.1 83
Soeren Domroes 15.1 84 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.
85
Soeren Domroes 14.1 86 Yarn can be downloaded and installed from [[here>>url:https://yarnpkg.com/lang/en/docs/install/#windows-stable||shape="rect"]].
87
Soeren Domroes 11.1 88 === Known Problems in this step ===
89
Soeren Domroes 15.1 90 If python3 was already installed this may cause some problems.
Soeren Domroes 11.1 91
Soeren Domroes 1.1 92 == ... on mac: ==
93
94 Get a package manager, something like [[brew>>url:https://brew.sh/index_de||shape="rect"]].
95
96 Use brew to install all necessary stuff.
97
98 Apparently there is an issue with xcode-select: [[Theia developers>>url:https://github.com/theia-ide/theia/blob/master/doc/Developing.md||shape="rect"]] recommend the following:
99
100 {{code}}
101 xcode-select --install
102 {{/code}}
103
Soeren Domroes 5.1 104 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).
Soeren Domroes 1.1 105
Soeren Domroes 5.1 106 = Stuff that may help =
Soeren Domroes 1.1 107
Soeren Domroes 5.1 108 == Running the already build LS ==
Soeren Domroes 1.1 109
Soeren Domroes 5.1 110 Go to the latest [[Bamboo build>>url:https://rtsys.informatik.uni-kiel.de/bamboo/browse/KISEMA-NSI||shape="rect"]] and go to Artifacts.
Soeren Domroes 1.1 111
Soeren Domroes 5.1 112 [[image:attach:image2019-2-7_17-46-58.png]]
Soeren Domroes 1.1 113
Soeren Domroes 5.1 114 Select Language Server Zip and download the LS and unpack it somewhere.
115
116 Locate the kieler.ini file. Depending on the OS it has a different location (linux; toplevel, windows, toplevel, mac: Content/Eclipse/kieler.ini)
117
118 Paste the following at the beginning of the ini-file:
119
Soeren Domroes 1.1 120 {{code language="bash"}}
Soeren Domroes 5.1 121 -application
122 de.cau.cs.kieler.language.server.LanguageServer
123 -noSplash
Soeren Domroes 1.1 124 {{/code}}
125
Soeren Domroes 5.1 126 Since an eclipse application is built, this is needed to start the LS without a splashscreen.
Soeren Domroes 1.1 127
Soeren Domroes 5.1 128 If you want to connect that LS via socket to your Theia application (KEITH) add the following to the vmargs:
Soeren Domroes 3.1 129
Soeren Domroes 5.1 130 {{code}}
131 -Dport=5007
132 {{/code}}
Soeren Domroes 1.1 133
Soeren Domroes 5.1 134 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:
Soeren Domroes 1.1 135
Soeren Domroes 5.1 136 Assume you are in the [[keith >>url:https://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/keith/browse||shape="rect"]]repository. Go to {{code language="none"}}keith-app{{/code}}, you should see something like this:
Soeren Domroes 1.1 137
Soeren Domroes 5.1 138 [[image:attach:image2019-2-7_17-58-22.png]]
Soeren Domroes 1.1 139
Soeren Domroes 5.1 140 Open the {{code language="none"}}package.json{{/code}}. In the{{code language="none"}} package.json{{/code}} are several scripts defined.
Soeren Domroes 3.1 141
Soeren Domroes 5.1 142 [[image:attach:image2019-2-7_18-0-7.png]]
Soeren Domroes 1.1 143
Soeren Domroes 5.1 144 The {{code language="none"}}LSP_PORT{{/code}} option is used to activate the connection via socket. It is also possible to specify a relative location to a LS via {{code language="none"}}LS_PATH=<path to LS>{{/code}}.
Soeren Domroes 3.1 145
Soeren Domroes 1.1 146 \\
147
Soeren Domroes 5.1 148 == How run KEITH in developer setup (socket) ==
Soeren Domroes 3.1 149
Soeren Domroes 5.1 150 Run the following to build and run KEITH in its developer setup (in socket mode, so the LS has to be started separately)
Soeren Domroes 3.1 151
Soeren Domroes 5.1 152 {{code language="bash"}}
153 yarn && cd keith-app && yarn run socket
154 {{/code}}
155
Soeren Domroes 13.1 156 //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.
157
Soeren Domroes 5.1 158 Per default the KEITH opens on localhost:3000.
159
160 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.
Soeren Domroes 7.1 161
Soeren Domroes 13.1 162 === Known issues for windows: ===
163
164 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.
165
166 === Known issues on mac: ===
167
168 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.
169
170 === Known issues: ===
171
172 Refreshing the browser is not enough for the diagram to work. If the diagram is needed the language server has to be restarted before the browser is refreshed. This is a known issue in theia-sprotty.
173
Soeren Domroes 7.1 174 = Developing for KEITH =
175
Soeren Domroes 9.1 176 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:
177
Soeren Domroes 19.1 178 == Register LanguageServerExtensions (ServiceLoader Example) ==
Soeren Domroes 9.1 179
Soeren Domroes 19.1 180 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.
Soeren Domroes 9.1 181
182 Here is such an example extension, the KiCoolLanguageServerExtension:
183
184 {{code}}
185 package de.cau.cs.kieler.kicool.ide.language.server
186
187
Soeren Domroes 10.1 188 /**
189 * @author really fancy name
190 *
191 */
Soeren Domroes 9.1 192 @Singleton
Soeren Domroes 19.1 193 class KiCoolLanguageServerExtension implements ILanguageServerExtension, CommandExtension, ILanguageClientProvider {
194 // fancy extension stuff
195
196 // A language server extension must implement the initialize method,
197 // it is however only called if the extension is registered via a language.
198 // This should never be the case, so this is never called.
199 override initialize(ILanguageServerAccess access) {
200 this.languageServerAccess = access
201 }
202
Soeren Domroes 9.1 203 }
204 {{/code}}
205
Soeren Domroes 19.1 206 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 in the section Register an extension (on server side).
207
208 \\
209
Soeren Domroes 9.1 210 This language server extension is provided by a corresponding contribution, which is later used to access it:
211
212 {{code}}
213 package de.cau.cs.kieler.kicool.ide.language.server
214
215 import com.google.inject.Injector
216 import de.cau.cs.kieler.language.server.ILanguageServerContribution
217
218 /**
219 * @author really fancy name
220 *
221 */
222 class KiCoolLanguageServerContribution implements ILanguageServerContribution {
223
224 override getLanguageServerExtension(Injector injector) {
225 return injector.getInstance(KiCoolLanguageServerExtension)
226 }
227 }
228 {{/code}}
229
Soeren Domroes 10.1 230 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:
Soeren Domroes 9.1 231
Soeren Domroes 10.1 232 {{code}}
233 de.cau.cs.kieler.kicool.ide.language.server.KiCoolLanguageServerContribution
234 {{/code}}
235
Soeren Domroes 11.1 236 This is the fully qualified name of the contribution written earlier.
Soeren Domroes 10.1 237
Soeren Domroes 11.1 238 The language server uses all LanguageServerExtensions like this:
239
240 {{code}}
241 var iLanguageServerExtensions = <Object>newArrayList(languageServer) // list of all language server extensions
242 for (lse : KielerServiceLoader.load(ILanguageServerContribution)) { // load all contributions
243 iLanguageServerExtensions.add(lse.getLanguageServerExtension(injector))
244 }
245 {{/code}}
246
247 The resulting list of implementions is used to add the extensions to the language server.
248
Soeren Domroes 7.1 249 == Register an extension (on server side) ==
250
Soeren Domroes 11.1 251 See example above for ServiceLoader and initial stuff.
Soeren Domroes 7.1 252
Soeren Domroes 11.1 253 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.
254
Soeren Domroes 19.1 255 {{code title="Example CommandExtension"}}
Soeren Domroes 11.1 256 package de.cau.cs.kieler.kicool.ide.language.server
257
258 import java.util.concurrent.CompletableFuture
259 import org.eclipse.lsp4j.jsonrpc.services.JsonRequest
260 import org.eclipse.lsp4j.jsonrpc.services.JsonSegment
261
262 /**
263 * Interface to the LSP extension commands
264 *
265 * @author really fancy name
266 *
267 */
268 @JsonSegment('keith/kicool')
269 interface CommandExtension {
270
271 /**
272 * Compiles file given by uri with compilationsystem given by command.
273 */
274 @JsonRequest('compile')
275 def CompletableFuture<CompilationResults> compile(String uri, String clientId, String command, boolean inplace);
276
277 /**
278 * Build diagram for snapshot with id index for file given by uri. Only works, if the file was already compiled.
279 */
280 @JsonRequest('show')
281 def CompletableFuture<String> show(String uri, String clientId, int index)
282
283 /**
284 * Returns all compilation systems which are applicable for the file at given uri.
285 *
286 * @param uri URI as string to get compilation systems for
287 * @param filter boolean indicating whether compilation systems should be filtered
288 */
289 @JsonRequest('get-systems')
290 def CompletableFuture<Object> getSystems(String uri, boolean filterSystems)
291 }
292 {{/code}}
293
294 This defines three json-rpc commands: "keith/kicool/compile", "keith/kicool/show", "keith/kicool/get-systems". These are implemented in KiCoolLanguageServerExtension.
295
296 == Register and calling an extension (on client side) ==
297
298 Language server extension do not have to be registered on the client side. It is just called.
299
300 You can send a request or a notification to the language server like this:
301
302 {{code}}
303 const lclient = await this.client.languageClient
304 const snapshotsDescriptions: CodeContainer = await lclient.sendRequest("keith/kicool/compile", [uri, KeithDiagramManager.DIAGRAM_TYPE + '_sprotty', command,
305 this.compilerWidget.compileInplace]) as CodeContainer
306 // or via a thenable
Soeren Domroes 12.1 307 client.languageClient.then(lClient => {
Soeren Domroes 13.1 308 lClient.sendRequest("keith/kicool/compile").then((snapshotsDescriptions: CodeContainer) => {
Soeren Domroes 12.1 309 // very important stuff
310 }
311 // await is preferred, since it is shorter.
312 {{/code}}
Soeren Domroes 11.1 313
Soeren Domroes 13.1 314 In this example client is an instance of a language client. It is usually injected like this:
Soeren Domroes 11.1 315
Soeren Domroes 12.1 316 {{code}}
317 constructor(
318 @inject(KeithLanguageClientContribution) public readonly client: KeithLanguageClientContribution
319 // other injected classes
320 ) {
321 // constructor stuff
322 }
Soeren Domroes 11.1 323 {{/code}}
324
325 \\
326
Soeren Domroes 13.1 327 == How to make a new package for KEITH ==
Soeren Domroes 7.1 328
Soeren Domroes 13.1 329 Clone the [[KEITH repository>>url:https://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/keith/browse||shape="rect"]].
330
331 Open the keith folder in VSCode. You are know in the keith directory in VSCode.
332
333 You see something like this: TODO picture
334
335 Create a new folder called keith-<your extension name>.
336
337 Copy a package.json, a tslint.json, a tsconfig.json, and a src folder into the folder.
338
339 Add keith-<your extension name> to workspaces in the top level package.json.
340
341 Add "keith-<your extension name>(% style="color: rgb(0,0,0);" %)": (%%)"0.1.0"(% style="color: rgb(0,0,0);" %) to the dependencies in the top level package.json and the product package.json files (e.g. the package.json in keith-app).
342
343 === What is in the src directory? ===
344
345 The source directory has three optional subfolders.
346
347 * node: Holds all backend related classes. This does currently only exist in the [[keith-language package>>url:https://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/keith/browse/keith-language||shape="rect"]].
348 * common: Holds general helper methods, string constants and some data classes
349 * browser: Holds all widgets, contribution for commands, menus, and widgets, and the frontend-extension.
350
351 ==== The frontend-extension ====
352
353 This binds all necessary classes. Look at existing frontend extension in [[KEITH>>url:https://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/keith/browse||shape="rect"]] or [[Theia>>url:https://github.com/theia-ide/theia/tree/master/packages||shape="rect"]] to see how this is done.
354
355 ==== More examples for stuff ====
356
357 See [[Theia examples>>url:https://www.theia-ide.org/doc/Commands_Keybindings.html||shape="rect"]].
358
Soeren Domroes 7.1 359 == How to write a widget ==
Soeren Domroes 13.1 360
361 There are different kinds of widgets that are commonly used in [[KEITH>>url:https://git.rtsys.informatik.uni-kiel.de/projects/KIELER/repos/keith/browse||shape="rect"]] or in existing [[Theia packages>>url:https://github.com/theia-ide/theia/tree/master/packages||shape="rect"]].
362
363 * BaseWidget: Very basic
364 * ReactWidget: A render method has to be implemented that redraws the widget on demand. Additionally several on* event methods can beimplemented.
365 * TreeWidget: Extends the ReactWidget and draws the contents of the widget in a tree view.
366
367 If a widget has a state it should implement the StatefulWidget interface, which allows to imlement a store and restore method.
368
369 Look at examples in KEITH or Theia to see how this is done.
370
Soeren Domroes 18.1 371 == How to make a new module for sprotty (see actionModule, ...) ==
372
373 WIP
374
Soeren Domroes 13.1 375 \\