-
Notifications
You must be signed in to change notification settings - Fork 12.9k
RFC: Extensibility model #9038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
RFC: Extensibility model #9038
Changes from 1 commit
8b3aeb8
8583037
a7ae427
a03e465
4eee39d
bff6b05
f4384f6
b874ad9
d716dc9
1433411
0f9a816
0e9650c
dec0bf8
06dbfb7
80d89fb
67f6e26
2c15bb3
02834c4
257e939
9425485
c2f1cc5
3480c7c
adccddf
af9c1e1
908d9e7
a4762a8
3036843
69f0473
680a75b
19846c3
8283881
4fd46c8
7eca070
ab90cba
8a972d9
dad1bbe
9405dd3
5c97262
9f10c74
625e3cf
ed12a9c
a011aec
b4fc76c
1582d10
b5b7817
84c683e
ee23587
5d2618b
67063cc
50735ae
732da00
eab3c5a
86fcfb4
e173bc6
4676ca2
b8ca16a
563d71f
ae66e99
842d3c3
805bc2f
40b35c4
e5c342a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1170,7 +1170,7 @@ namespace ts { | |
// be returned by the TypeScript language service. If a plugin returns a defined results | ||
// (that is, is not undefined) then that result is used instead of invoking the | ||
// corresponding TypeScript method. If multiple plugins are registered, they are | ||
// consulted in the order they are returned from the host. The first defined result | ||
// consulted in the order they are returned from the program. The first defined result | ||
// returned by a plugin is used and no other plugin overrides are consulted. | ||
|
||
getProgramDiagnostics?(): Diagnostic[]; | ||
|
@@ -1208,7 +1208,7 @@ namespace ts { | |
// prior to the host receiving it. The TypeScript language service is invoked and the | ||
// result is passed to the plugin as the value of the previous parameter. If more than one | ||
// plugin is registered, the plugins are consulted in the order they are returned from the | ||
// host. The value passed in as previous is the result returned by the prior plugin. If a | ||
// program. The value passed in as previous is the result returned by the prior plugin. If a | ||
// plugin returns undefined, the result passed in as previous is used and the undefined | ||
// result is ignored. All plugins are consulted before the result is returned to the host. | ||
// If a plugin overrides behavior of the method, no filter methods are consulted. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I'm confused by the relationship of override and filter methods. Are overrides and filters called in the same sequence? It sounds like they are, with the first override aborting the cascade of the previous filters (but not throwing away their filtered values).
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If an override returns a non- A plugin can have both an override and a filter because it may, at times, wish to override everything (and at other times returning There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So overrides are before (or replace) and filters are after, but overrides stop filters from running? I'd suggest two things:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
@@ -3003,28 +3003,35 @@ namespace ts { | |
const baseService = createUnextendedLanguageService(host, documentRegistry); | ||
const extensions = baseService.getProgram().getCompilerExtensions()["language-service"]; | ||
const instantiatedExtensions = map(extensions, extension => new extension.ctor(ts, host, baseService, documentRegistry, extension.args)); | ||
const extensionCount = instantiatedExtensions && instantiatedExtensions.length; | ||
|
||
function wrap(key: string): Function { | ||
return (...args: any[]) => { | ||
if (instantiatedExtensions && instantiatedExtensions.length) { | ||
for (let i = 0; i < instantiatedExtensions.length; i++) { | ||
if (extensionCount) { | ||
return (...args: any[]) => { | ||
for (let i = 0; i < extensionCount; i++) { | ||
const extension = instantiatedExtensions[i]; | ||
if ((extension as any)[key]) { | ||
return (extension as any)[key](...args); | ||
const temp = (extension as any)[key](...args); | ||
if (temp !== undefined) { | ||
return temp; | ||
} | ||
} | ||
} | ||
let result: any = (baseService as any)[key](...args); | ||
const filterKey = `${key}Filter`; | ||
for (let i = 0; i < instantiatedExtensions.length; i++) { | ||
for (let i = 0; i < extensionCount; i++) { | ||
const extension = instantiatedExtensions[i]; | ||
if ((extension as any)[filterKey]) { | ||
result = (extension as any)[filterKey](...args, result); | ||
const temp = (extension as any)[filterKey](...args, result); | ||
if (temp !== undefined) { | ||
result = temp; | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
return (baseService as any)[key](...args); | ||
}; | ||
}; | ||
} | ||
return (baseService as any)[key]; | ||
} | ||
|
||
function buildWrappedService(underlyingMembers: Map<any>, wrappedMembers: string[]): LanguageService { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: result