Skip to content

Commit 3858ae7

Browse files
authored
Add API for component groups (#3286)
1 parent 2ae636f commit 3858ae7

File tree

41 files changed

+2023
-143
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+2023
-143
lines changed

RELEASES.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212
- Updated to
1313
[GraalVM 21.3.0](https://github.com/graalvm/graalvm-ce-builds/releases/tag/vm-21.3.0)
1414
([#3258](https://github.com/enso-org/enso/pull/3258)).
15+
- Extended language server API to allow accessing the package definition, and to
16+
get the available component groups
17+
[#3286](https://github.com/enso-org/enso/pull/3286).
1518

1619
## Interpreter/Runtime
1720

docs/language-server/protocol-language-server.md

Lines changed: 202 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ transport formats, please look [here](./protocol-architecture).
6262
- [`LibraryVersion`](#libraryversion)
6363
- [`Contact`](#contact)
6464
- [`EditionReference`](#editionreference)
65+
- [`ComponentGroups`](#componentgroups)
66+
- [`ComponentGroup`](#componentgroup)
67+
- [`ExtendedComponentGroup`](#extendedcomponentgroup)
68+
- [`ModuleReference`](#modulereference)
69+
- [`Component`](#component)
70+
- [`LibraryComponentGroup`](#librarycomponentgroup)
6571
- [Connection Management](#connection-management)
6672
- [`session/initProtocolConnection`](#sessioninitprotocolconnection)
6773
- [`session/initBinaryConnection`](#sessioninitbinaryconnection)
@@ -156,10 +162,12 @@ transport formats, please look [here](./protocol-architecture).
156162
- [`editions/setProjectParentEdition`](#editionssetprojectparentedition)
157163
- [`editions/setProjectLocalLibrariesPreference`](#editionssetprojectlocallibrariespreference)
158164
- [`editions/listDefinedLibraries`](#editionslistdefinedlibraries)
165+
- [`editions/listDefinedComponents`](#editionslistdefinedcomponents)
159166
- [`library/listLocal`](#librarylistlocal)
160167
- [`library/create`](#librarycreate)
161168
- [`library/getMetadata`](#librarygetmetadata)
162169
- [`library/setMetadata`](#librarysetmetadata)
170+
- [`library/getPackage`](#librarygetpackage)
163171
- [`library/publish`](#librarypublish)
164172
- [`library/preinstall`](#librarypreinstall)
165173
- [Errors](#errors-75)
@@ -204,6 +212,7 @@ transport formats, please look [here](./protocol-architecture).
204212
- [`LibraryNotResolved`](#librarynotresolved)
205213
- [`InvalidLibraryName`](#invalidlibraryname)
206214
- [`DependencyDiscoveryError`](#dependencydiscoveryerror)
215+
- [`InvalidSemverVersion`](#invalidsemverversion)
207216

208217
<!-- /MarkdownTOC -->
209218

@@ -1418,6 +1427,114 @@ interface NamedEdition {
14181427
}
14191428
```
14201429

1430+
### `ComponentGroups`
1431+
1432+
The description of component groups provided by the package. Object fields can
1433+
be omitted if the corresponding list is empty.
1434+
1435+
```typescript
1436+
interface ComponentGroups {
1437+
/** The list of component groups provided by the package. */
1438+
newGroups?: ComponentGroup[];
1439+
1440+
/** The list of component groups that this package extends.*/
1441+
extendedGroups?: ExtendedComponentGroup[];
1442+
}
1443+
```
1444+
1445+
### `ComponentGroup`
1446+
1447+
The definition of a single component group.
1448+
1449+
```typescript
1450+
interface ComponentGroup {
1451+
/** The module name containing the declared componennts. */
1452+
module: string;
1453+
1454+
color?: string;
1455+
1456+
icon?: string;
1457+
1458+
/** The list of components provided by this component group. */
1459+
exports: Component[];
1460+
}
1461+
```
1462+
1463+
### `ExtendedComponentGroup`
1464+
1465+
The definition of a component group that extends an existing one.
1466+
1467+
```typescript
1468+
interface ExtendedComponentGroup {
1469+
/** The reference to the component group module being extended. */
1470+
module: ModuleReference;
1471+
1472+
/** The list of components provided by this component group. */
1473+
exports: Component[];
1474+
}
1475+
```
1476+
1477+
### `ModuleReference`
1478+
1479+
The reference to a module.
1480+
1481+
```typescript
1482+
interface ModuleReference {
1483+
/**
1484+
* A string consisting of a namespace and a lirary name separated by the dot
1485+
* <namespace>.<library name>, i.e. `Standard.Base`.
1486+
*/
1487+
libraryName: string;
1488+
1489+
/** The module name without the library name prefix.
1490+
* E.g. given the `Standard.Base.Data.Vector` module reference,
1491+
* the `moduleName` field contains `Data.Vector`.
1492+
*/
1493+
moduleName: string;
1494+
}
1495+
```
1496+
1497+
### `Component`
1498+
1499+
A single component of a component group.
1500+
1501+
```typescript
1502+
interface Component {
1503+
/** The component name. */
1504+
name: string;
1505+
1506+
/** The component shortcut. */
1507+
shortcut?: string;
1508+
}
1509+
```
1510+
1511+
### `LibraryComponentGroup`
1512+
1513+
The component group provided by a library.
1514+
1515+
```typescript
1516+
interface LibraryComponentGroup {
1517+
/**
1518+
* A string consisting of a namespace and a lirary name separated by the dot
1519+
* <namespace>.<library name>, i.e. `Standard.Base`.
1520+
*/
1521+
library: string;
1522+
1523+
/** The module name without the library name prefix.
1524+
* E.g. given the `Standard.Base.Data.Vector` module reference,
1525+
* the `module` field contains `Data.Vector`.
1526+
*/
1527+
module: string;
1528+
1529+
color?: string;
1530+
1531+
icon?: string;
1532+
1533+
/** The list of components provided by this component group. */
1534+
exports: Component[];
1535+
}
1536+
```
1537+
14211538
## Connection Management
14221539

14231540
In order to properly set-up and tear-down the language server connection, we
@@ -4305,6 +4422,33 @@ To get local libraries that are not directly referenced in the edition, use
43054422

43064423
#### Errors
43074424

4425+
- [`EditionNotFoundError`](#editionnotfounderror) indicates that the requested
4426+
edition, or an edition referenced in one of its parents, could not be found.
4427+
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
4428+
file-system error.
4429+
4430+
### `editions/listDefinedComponents`
4431+
4432+
Lists all the component groups defined in an edition.
4433+
4434+
#### Parameters
4435+
4436+
```typescript
4437+
{
4438+
edition: EditionReference;
4439+
}
4440+
```
4441+
4442+
#### Result
4443+
4444+
```typescript
4445+
{
4446+
availableComponents: LibraryComponentGroup[];
4447+
}
4448+
```
4449+
4450+
#### Errors
4451+
43084452
- [`EditionNotFoundError`](#editionnotfounderror) indicates that the requested
43094453
edition, or an edition referenced in one of its parents, could not be found.
43104454
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
@@ -4412,6 +4556,8 @@ All returned fields are optional, as they may be missing.
44124556

44134557
- [`LocalLibraryNotFound`](#locallibrarynotfound) to signal that a local library
44144558
with the given name does not exist on the local libraries path.
4559+
- [`InvalidSemverVersion`](#invalidsemverversion) to signal that the provided
4560+
version string is not a valid semver version.
44154561
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
44164562
file-system error.
44174563

@@ -4446,6 +4592,47 @@ null;
44464592
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
44474593
file-system error.
44484594

4595+
### `library/getPackage`
4596+
4597+
Gets the package config associated with a specific library version.
4598+
4599+
If the version is `LocalLibraryVersion`, it will try to read the package file of
4600+
the local library and return an empty result if the manifest does not exist.
4601+
4602+
If the version is `PublishedLibraryVersion`, it will fetch the package config
4603+
from the library repository. A cached package config may also be used, if it is
4604+
available.
4605+
4606+
All returned fields are optional, as they may be missing.
4607+
4608+
#### Parameters
4609+
4610+
```typescript
4611+
{
4612+
namespace: String;
4613+
name: String;
4614+
version: LibraryVersion;
4615+
}
4616+
```
4617+
4618+
#### Results
4619+
4620+
```typescript
4621+
{
4622+
license?: String;
4623+
componentGroups?: ComponentGroups;
4624+
}
4625+
```
4626+
4627+
#### Errors
4628+
4629+
- [`LocalLibraryNotFound`](#locallibrarynotfound) to signal that a local library
4630+
with the given name does not exist on the local libraries path.
4631+
- [`InvalidSemverVersion`](#invalidsemverversion) to signal that the provided
4632+
version string is not a valid semver version.
4633+
- [`FileSystemError`](#filesystemerror) to signal a generic, unrecoverable
4634+
file-system error.
4635+
44494636
### `library/publish`
44504637

44514638
Publishes a library located in the local libraries directory to the main Enso
@@ -5083,3 +5270,18 @@ dependencies of the requested library.
50835270
"message" : "Error occurred while discovering dependencies: <reason>."
50845271
}
50855272
```
5273+
5274+
### `InvalidSemverVersion`
5275+
5276+
Signals that the provided version string is not a valid semver version. The
5277+
message contains the invalid version in the payload.
5278+
5279+
```typescript
5280+
"error" : {
5281+
"code" : 8011,
5282+
"message" : "[<invalid-version>] is not a valid semver version.",
5283+
"payload" : {
5284+
"version" : "<invalid-version>"
5285+
}
5286+
}
5287+
```

0 commit comments

Comments
 (0)