Changes for page Running KEITH
Last modified by Richard Kreissig on 2023/09/14 08:48
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
-
Objects (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -169,207 +169,6 @@ 169 169 170 170 === Known issues: === 171 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 - 174 -= Developing for KEITH = 175 - 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 - 178 -== Register LanguageServerExtensions (ServiceLoader Example) == 179 - 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. 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 - 188 -/** 189 - * @author really fancy name 190 - * 191 - */ 192 -@Singleton 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 - 203 -} 204 -{{/code}} 205 - 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 is an example how to [[define a server side extension interface.>>doc:||anchor="Registeranextension(onserverside)"]] 207 - 208 208 \\ 209 209 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 - 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: 231 - 232 -{{code}} 233 -de.cau.cs.kieler.kicool.ide.language.server.KiCoolLanguageServerContribution 234 -{{/code}} 235 - 236 -This is the fully qualified name of the contribution written earlier. 237 - 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 - 249 -== Register an extension (on server side) == 250 - 251 -See example above for ServiceLoader and initial stuff. 252 - 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 - 255 -{{code title="Example CommandExtension"}} 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 307 -client.languageClient.then(lClient => { 308 -lClient.sendRequest("keith/kicool/compile").then((snapshotsDescriptions: CodeContainer) => { 309 - // very important stuff 310 -} 311 -// await is preferred, since it is shorter. 312 -{{/code}} 313 - 314 -In this example client is an instance of a language client. It is usually injected like this: 315 - 316 -{{code}} 317 -constructor( 318 - @inject(KeithLanguageClientContribution) public readonly client: KeithLanguageClientContribution 319 - // other injected classes 320 - ) { 321 - // constructor stuff 322 -} 323 -{{/code}} 324 - 325 325 \\ 326 - 327 -== How to make a new package for KEITH == 328 - 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 - 359 -== How to write a widget == 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 - 371 -== How to make a new module for sprotty (see actionModule, ...) == 372 - 373 -WIP 374 - 375 -\\
- Confluence.Code.ConfluencePageClass[0]
-
- Id
-
... ... @@ -1,1 +1,1 @@ 1 - 578029941 +60522741 - URL
-
... ... @@ -1,1 +1,1 @@ 1 -https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/ 57802994/Running KEITH1 +https://rtsys.informatik.uni-kiel.de/confluence//wiki/spaces/KIELER/pages/60522741/Running KEITH