|
1 |
| -import { Observable, of } from 'rxjs' |
2 |
| -import { distinctUntilChanged, map } from 'rxjs/operators' |
3 |
| -import { TextDocument } from 'sourcegraph' |
4 | 1 | import { ConfigurationCascade } from '../protocol'
|
5 |
| -import { isEqual } from '../util' |
6 | 2 | import { Context, EMPTY_CONTEXT } from './context/context'
|
7 | 3 | import { Extension } from './extension'
|
8 | 4 | import { TextDocumentItem } from './types/textDocument'
|
@@ -47,71 +43,3 @@ export interface Component {
|
47 | 43 | /** The document displayed by the component. */
|
48 | 44 | readonly document: TextDocumentItem
|
49 | 45 | }
|
50 |
| - |
51 |
| -/** |
52 |
| - * Observables for changes to the environment. |
53 |
| - * |
54 |
| - * Includes derived observables for convenience. |
55 |
| - * |
56 |
| - * @template X extension type, to support storing additional properties on extensions |
57 |
| - * @template C configuration cascade type |
58 |
| - */ |
59 |
| -export interface ObservableEnvironment<X extends Extension, C extends ConfigurationCascade> { |
60 |
| - /** The environment (and changes to it). */ |
61 |
| - readonly environment: Observable<Environment<X, C>> |
62 |
| - |
63 |
| - /** The environment's active component (and changes to it). */ |
64 |
| - readonly component: Observable<Component | null> |
65 |
| - |
66 |
| - /** The active component's text document (and changes to it). */ |
67 |
| - readonly textDocument: Observable<Pick<TextDocument, 'uri' | 'languageId'> | null> |
68 |
| - |
69 |
| - /** The environment's configuration cascade (and changes to it). */ |
70 |
| - readonly configuration: Observable<C> |
71 |
| - |
72 |
| - /** The environment's context (and changes to it). */ |
73 |
| - readonly context: Observable<Context> |
74 |
| -} |
75 |
| - |
76 |
| -/** An ObservableEnvironment that always represents the empty environment and never emits changes. */ |
77 |
| -export const EMPTY_OBSERVABLE_ENVIRONMENT: ObservableEnvironment<any, any> = { |
78 |
| - environment: of(EMPTY_ENVIRONMENT), |
79 |
| - component: of(null), |
80 |
| - textDocument: of(null), |
81 |
| - configuration: of({}), |
82 |
| - context: of(EMPTY_CONTEXT), |
83 |
| -} |
84 |
| - |
85 |
| -/** |
86 |
| - * Helper function for creating an ObservableEnvironment from the raw environment Observable. |
87 |
| - * |
88 |
| - * @template X extension type |
89 |
| - * @template C configuration cascade type |
90 |
| - */ |
91 |
| -export function createObservableEnvironment<X extends Extension, C extends ConfigurationCascade>( |
92 |
| - environment: Observable<Environment<X, C>> |
93 |
| -): ObservableEnvironment<X, C> { |
94 |
| - const component = environment.pipe( |
95 |
| - map(({ component }) => component), |
96 |
| - distinctUntilChanged((a, b) => isEqual(a, b)) |
97 |
| - ) |
98 |
| - const textDocument = component.pipe( |
99 |
| - map(component => (component ? component.document : null)), |
100 |
| - distinctUntilChanged((a, b) => isEqual(a, b)) |
101 |
| - ) |
102 |
| - const configuration = environment.pipe( |
103 |
| - map(({ configuration }) => configuration), |
104 |
| - distinctUntilChanged((a, b) => isEqual(a, b)) |
105 |
| - ) |
106 |
| - const context = environment.pipe( |
107 |
| - map(({ context }) => context), |
108 |
| - distinctUntilChanged((a, b) => isEqual(a, b)) |
109 |
| - ) |
110 |
| - return { |
111 |
| - environment, |
112 |
| - component, |
113 |
| - textDocument, |
114 |
| - configuration, |
115 |
| - context, |
116 |
| - } |
117 |
| -} |
0 commit comments