# @eclipse-emfcloud/modelserver-markers-theia

> ## Use case

Latest version **0.8.0-theia-cr03** (published 2023-05-25) · (EPL-2.0 OR MIT) license · 0 weekly downloads

## Install

```sh
npm install @eclipse-emfcloud/modelserver-markers-theia
pnpm add @eclipse-emfcloud/modelserver-markers-theia
yarn add @eclipse-emfcloud/modelserver-markers-theia
bun add @eclipse-emfcloud/modelserver-markers-theia
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: no vulnerabilities; high maintenance score.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.8.0-theia-cr03 |
| Published | 2023-05-25 |
| First published | 2021-04-02 |
| Weekly downloads | 0 |
| License | (EPL-2.0 OR MIT) |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 45.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Vincent HEMERY |
| Maintainers | ndoschek, tortmayr, eugenneufeld, eclipse-emfcloud-bot, mfleck, jfaltermeier, planger, lkoehler |
| Keywords | theia-extension, model-server, modeling |

## Links

- npm: https://www.npmjs.com/package/@eclipse-emfcloud/modelserver-markers-theia
- Repository: https://github.com/eclipse-emfcloud/emfcloud-modelserver-theia
- Homepage: https://www.eclipse.org/emfcloud/
- Issues: https://github.com/eclipse-emfcloud/emfcloud-modelserver-theia/issues
- npm.io page: https://npm.io/package/@eclipse-emfcloud/modelserver-markers-theia

## Dependencies (1)

- [@eclipse-emfcloud/modelserver-client](https://npm.io/package/@eclipse-emfcloud/modelserver-client.md) ^0.8.0-theia-cr03

## Recent versions

- 0.8.0-theia-cr03 (latest) — 2023-05-25
- 0.8.0-next.68f5427.97 (next) — 2023-05-25
- 0.8.0-RC01 (rc-latest) — 2021-06-14
- 0.8.0-next.f465139.96 — 2023-04-03
- 0.8.0-next.675f9d9.95 — 2023-03-31
- 0.8.0-next.363b58d.94 — 2023-03-17
- 0.8.0-next.46ba3ca.93 — 2023-03-15
- 0.8.0-next.d7db15a.92 — 2023-02-09
- 0.8.0-theia-cr02 — 2023-02-02
- 0.8.0-next.5200d03.91 — 2023-02-01
- 0.8.0-next.97b0990.90 — 2023-01-26
- 0.8.0-next.94e8ad2.89 — 2023-01-25
- 0.8.0-next.e6ace1d.88 — 2023-01-25
- 0.8.0-next.e8752f2.87 — 2023-01-20
- 0.8.0-next.d9dd44f.86 — 2023-01-18
- … 37 more at https://npm.io/package/@eclipse-emfcloud/modelserver-markers-theia/versions

## README

# Markers management for Model Server validation Diagnostics

## Use case

The model server client API provides validation methods which manipulate JSON objects which can be cast as `Diagnostic` objects (`@eclipse-emfcloud/modelserver-theia/lib/browser/diagnostic`).

```typescript
export interface ModelServerClient extends JsonRpcServer<ModelServerFrontendClient> {
  validation(modeluri: URI): Promise<Response<string>>;

  // WebSocket connection
  subscribeWithValidation(modeluri: URI): void;
}
```

Users may want to log these validation diagnostics in Theia's Problems view (provided by `@theia/markers`).
This module provides the necessary tools to achieve this purpose with minimalist code.

## Typescript API Examples

After calling the validation, you can create markers as simply as :

```typescript

@inject(MessageService) protected readonly messageService: MessageService;
@inject(DiagnosticManager) protected readonly diagnosticManager: DiagnosticManager;

const modelURI : URI;
// perform validation
this.modelServerClient.validation(modelURI.toString())
    .then((response: Response<any>) => {
        // get resulting diagnostic
        const diagnostic = response.body as Diagnostic;
        // print markers in Problems view
        diagnosticManager.setDiagnostic(modelURI, diagnostic);
        // display the validation status
        this.messageService.info(`Validation finished with level ${Diagnostic.getSeverityLabel(diagnostic)}.`)
    });

```

## Selecting the model element from the marker

The marker in the problems view can be used to navigate to the precise element in error.
As this navigation depends on your model editor implementation, you must implement the `OpenHandler` interface if you want this functionality (see `@theia/core/lib/browser/opener-service.ts`).
In the opener options, you will find a `selection` entry, which value can be cast as a `ModelElementRange`, containing fake start and end values, but the correct model element's URI fragment (identifier) at the `uriFragment` key.
It is up to your widget implementation to select the correct element corresponding to this URI fragment.

---
_Source: https://npm.io/package/@eclipse-emfcloud/modelserver-markers-theia · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
