You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is how the projects API is designed with the different parts of the project flow. Here `getPythonProjects` is used as an example function but behavior will mirror other getter and setter functions exposed in the API.
5
+
6
+
1.**API Call:** Extensions can calls `getPythonProjects` on [`PythonEnvironmentApi`](../src/api.ts).
7
+
2.**API Implementation:**[`PythonEnvironmentApiImpl`](../src/features/pythonApi.ts) delegates to its internal project manager.
8
+
3.**Internal API:** The project manager is typed as [`PythonProjectManager`](../src/internal.api.ts).
9
+
4.**Concrete Implementation:**[`PythonProjectManagerImpl`](../src/features/projectManager.ts) implements the actual logic.
10
+
5.**Data Model:** Returns an array of [`PythonProject`](../src/api.ts) objects.
11
+
12
+
## Project Creators
13
+
This is how creating projects work with the API as it uses a method of registering
14
+
external or internal project creators and maintaining project states internally in
15
+
just this extension.
16
+
17
+
-**Project Creators:** Any extension can implement and register a project creator by conforming to the [`PythonProjectCreator`](../src/api.ts) interface. Each creator provides a `create` method that returns one or more new projects (or their URIs). The create method is responsible for add the new projects to the project manager.
18
+
-**Registration:** Project creators are registered with the API, making them discoverable and usable by the extension or other consumers.
19
+
-**Integration:** Once a project is created, it is added to the internal project manager (`PythonProjectManagerImpl` in [`src/features/projectManager.ts`](../src/features/projectManager.ts)), which updates the set of known projects and persists settings if necessary.
20
+
21
+
### What an Extension Must Do
22
+
23
+
1.**Implement the Creator Interface:**
24
+
- Create a class that implements the [`PythonProjectCreator`](../src/api.ts) interface.
25
+
- Provide a unique `name`, a user-friendly `displayName`, and a `create` method that returns one or more `PythonProject` objects or URIs.
26
+
27
+
2.**Register the Creator:**
28
+
- Register the creator with the main API (usually via a registration method exposed by this extension’s API surface).
29
+
- This makes the creator discoverable and usable by the extension and other consumers.
30
+
31
+
3.**Add Projects Directly:**
32
+
- If your creator directly creates `PythonProject` objects, you MUST call the internal project manager’s `add` method during your create function to add projects as ones in the workspace.
### Example Implementation: [`ExistingProjects`](../src/features/creators/existingProjects.ts)
49
+
50
+
The [`ExistingProjects`](../src/features/creators/existingProjects.ts) class is an example of a project creator. It allows users to select files or folders from the workspace and creates new `PythonProject` instances for them. After creation, these projects are added to the internal project manager:
0 commit comments