# Code

These are the endpoints used to retrieve system code: packages, classes and methods.

It is important to mention that the JSON objects returned by these endpoints should include common properties of every `object`. This is used by Webside IDE to provide inspection services over objects of the meta-model (classes, methods, etc.). These are the common properties at the moment:

```json
{
	"class": "string",
	"hasNamedSlots": "boolean",
	"hasIndexedSlots": "boolean",
	"size": "number",
	"printString": "string"
}
```

## Endpoints

| Method | Path                                                     | Description                                                                                                                                                                                                             |                                                                                Parameters                                                                               | Payload |
| :----: | -------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | :---------------------------------------------------------------------------------------------------------------------------------------------------------------------: | ------- |
|   GET  | [/methods](code/methods/get)                             | Retrieve methods satisfying the condition specified in the query (or all the methods in the system if no condition is provided)                                                                                         | `selector`, `category`, `accessing`, `using`, `assigning`, `sending`, `referencingClass`, `selectorMatching`, `ast`, `annotations`, `bytecodes`, `dissasembly`, `count` | -       |
|   GET  | [/classes](code/classes/get)                             | Retrieve all subclasses of a given root class (if no root is provided, the uppermost class in the system is used). It is also possible get a tree-like structure as well as to limit the depth in the classes hierarchy |                                                               `root`, `names`, `tree`, `depth`, `category`                                                              | -       |
|   GET  | [/classes/{name}](code/classes/get-1)                    | Retrieve a given class                                                                                                                                                                                                  |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/superclasses](code/classes/get-11)      | Retrieve superclasses a given class                                                                                                                                                                                     |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/subclasses](code/classes/get-10)        | Retrieve subclasses a given class                                                                                                                                                                                       |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/variables](code/classes/get-3)          | Retrieve instance and class variables of a given class                                                                                                                                                                  |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/instance-variables](code/classes/get-5) | Retrieve instance variables of a given class                                                                                                                                                                            |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/class-variables](code/classes/get-4)    | Retrieve class variables of a given class                                                                                                                                                                               |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/categories](code/classes/get-2)         | Retrieve categories of a given class                                                                                                                                                                                    |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/used-categories](code/classes/get-12)   | Retrieve categories used throughout the hierarchy of a given class                                                                                                                                                      |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/methods](code/classes/get-7)            | Retrieve methods of a given class                                                                                                                                                                                       |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/selectors](code/classes/get-6)          | Retrieve selectors of a given class                                                                                                                                                                                     |                                                                                    -                                                                                    | -       |
|   GET  | [/classes/{name}/methods/{selector}](code/classes/get-8) | Retrieve the method with the given selector in the given class                                                                                                                                                          |                                                                                    -                                                                                    | -       |
|   GET  | [/categories](code/categories/get)                       | Retrieve all categories in the system                                                                                                                                                                                   |                                                                                    -                                                                                    | -       |
|   GET  | [/usual-categories](code/categories/get-1)               | Retrieve popular categories used throughout the system                                                                                                                                                                  |                                                                                    -                                                                                    | -       |
|   GET  | [/packages](code/packages/get)                           | Retrieve all packages                                                                                                                                                                                                   |                                                                                 `names`                                                                                 | -       |
|   GET  | [/packages/{name}](code/packages/get-1)                  | Retrieve a given package                                                                                                                                                                                                |                                                                                    -                                                                                    | -       |
|   GET  | [/packages/{name}/classes](code/packages/get-2)          | Retrieve actual classes of a given package                                                                                                                                                                              |                                                                 `extended`, `tree`, `names`, `category`                                                                 | -       |
|   GET  | [/packages/{name}/methods](code/packages/get-3)          | Retrieve actual methods of a given package                                                                                                                                                                              |                                                                                    -                                                                                    | -       |
|   GET  | [/search](code/get)                                      | Perform a search on the system                                                                                                                                                                                          |                                                                `text`, `ignoreCase`, `condition`, `type`                                                                | -       |
|   GET  | [/autocompletions](code/autocompletions/post)            | Retrieve completion entries for a given code, position and context                                                                                                                                                      |                                                                                    -                                                                                    | -       |
|   GET  | [/classtemplate](code/classtemplate/get)                 | Provide a class template                                                                                                                                                                                                |                                                                                `package`                                                                                | -       |
|   GET  | [/methodtemplate](code/classtemplate/get-1)              | Provide a method template                                                                                                                                                                                               |                                                                                    -                                                                                    | -       |
|  POST  | [/selectors](code/selectors/post)                        | Find a selector in a piece of source code                                                                                                                                                                               |                                                                                    -                                                                                    | -       |
