This repository was archived by the owner on Oct 16, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
Support TS plugins #327
Merged
Merged
Support TS plugins #327
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
9b9c821
feat: hackish implementation of plugin loading for tslint
tomv564 112102d
fix: Improve plugin import logic
tomv564 77429ce
fix: don't override diagnostic source if provided
tomv564 3df438c
fix: Add documentation and reorder functions
tomv564 64d7378
fix: plugin loading for windows
0d79881
feat: plugin configuration
tomv564 786b0c0
fix: missing semicolon
tomv564 0f0f039
fix: extract plugin functionality + add tests
tomv564 2292e96
fix: Fix and clean up tests
tomv564 7382e8f
fix: use arrow fun, log error, state plugin source
tomv564 791074d
fix: Rename didChangeConfiguration handler to expected workspaceDidCh…
tomv564 d807ec3
fix: Switch to didChangeConfiguration, always use local filesystem
tomv564 d3e4419
fix: Review fixes: rename enableProxy, extend PluginSettings, formatting
tomv564 bbfd5b4
fix: missing semicolon
tomv564 e333011
Merge branch 'master' into feature-ts-plugins
felixfbecker 42ce6e8
fix: paths for windows test
tomv564 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
fix: Switch to didChangeConfiguration, always use local filesystem
Also add 'node_modules' to resolvedPath Don't give up when resolveJavaScriptModule fails
- Loading branch information
commit d807ec3c967668e215c9940d3b10781acc516326
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,7 @@ import { FileSystemUpdater } from './fs'; | |
import { Logger, NoopLogger } from './logging'; | ||
import { InMemoryFileSystem } from './memfs'; | ||
import { PluginCreateInfo, PluginLoader, PluginModuleFactory } from './plugins'; | ||
import { InitializationOptions } from './request-type'; | ||
import { PluginSettings } from './request-type'; | ||
import { traceObservable, traceSync } from './tracing'; | ||
import { | ||
isConfigFile, | ||
|
@@ -105,7 +105,7 @@ export class ProjectManager implements Disposable { | |
/** | ||
* Options passed to the language server at startup | ||
*/ | ||
private initializationOptions?: InitializationOptions; | ||
private pluginSettings?: PluginSettings; | ||
|
||
/** | ||
* @param rootPath root path as passed to `initialize` | ||
|
@@ -118,14 +118,14 @@ export class ProjectManager implements Disposable { | |
inMemoryFileSystem: InMemoryFileSystem, | ||
updater: FileSystemUpdater, | ||
traceModuleResolution?: boolean, | ||
initializationOptions?: InitializationOptions, | ||
pluginSettings?: PluginSettings, | ||
protected logger: Logger = new NoopLogger() | ||
) { | ||
this.rootPath = rootPath; | ||
this.updater = updater; | ||
this.inMemoryFs = inMemoryFileSystem; | ||
this.versions = new Map<string, number>(); | ||
this.initializationOptions = initializationOptions; | ||
this.pluginSettings = pluginSettings; | ||
this.traceModuleResolution = traceModuleResolution || false; | ||
|
||
// Share DocumentRegistry between all ProjectConfigurations | ||
|
@@ -153,7 +153,7 @@ export class ProjectManager implements Disposable { | |
'', | ||
tsConfig, | ||
this.traceModuleResolution, | ||
this.initializationOptions, | ||
this.pluginSettings, | ||
this.logger | ||
); | ||
configs.set(trimmedRootPath, config); | ||
|
@@ -183,7 +183,7 @@ export class ProjectManager implements Disposable { | |
filePath, | ||
undefined, | ||
this.traceModuleResolution, | ||
this.initializationOptions, | ||
this.pluginSettings, | ||
this.logger | ||
)); | ||
// Remove catch-all config (if exists) | ||
|
@@ -813,7 +813,7 @@ export class ProjectConfiguration { | |
configFilePath: string, | ||
configContent?: any, | ||
traceModuleResolution?: boolean, | ||
private initializationOptions?: InitializationOptions, | ||
private pluginSettings?: PluginSettings, | ||
private logger: Logger = new NoopLogger() | ||
) { | ||
this.fs = fs; | ||
|
@@ -922,8 +922,8 @@ export class ProjectConfiguration { | |
this.logger | ||
); | ||
this.service = ts.createLanguageService(this.host, this.documentRegistry); | ||
const pluginLoader = new PluginLoader(this.rootFilePath, this.fs, this.initializationOptions, this.logger); | ||
pluginLoader.loadPlugins(options, (factory, config) => this.enableProxy(factory, config)); | ||
const pluginLoader = new PluginLoader(this.rootFilePath, this.fs, this.pluginSettings, this.logger); | ||
pluginLoader.loadPlugins(options, this.enableProxy.bind(this) /* (factory, config) => this.enableProxy(factory, config)) */); | ||
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. don't use |
||
this.initialized = true; | ||
} | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ import { | |
InitializeResult, | ||
PackageDescriptor, | ||
PackageInformation, | ||
PluginSettings, | ||
ReferenceInformation, | ||
SymbolDescriptor, | ||
SymbolLocationInformation, | ||
|
@@ -86,9 +87,9 @@ export type TypeScriptServiceFactory = (client: LanguageClient, options?: TypeSc | |
/** | ||
* Settings synced through `didChangeConfiguration` | ||
*/ | ||
export interface Settings { | ||
format: ts.FormatCodeSettings; | ||
} | ||
export type Settings = { | ||
format: ts.FormatCodeSettings | ||
} & PluginSettings; | ||
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. prefer |
||
|
||
/** | ||
* Handles incoming requests and return responses. There is a one-to-one-to-one | ||
|
@@ -171,7 +172,10 @@ export class TypeScriptService { | |
insertSpaceBeforeFunctionParenthesis: false, | ||
placeOpenBraceOnNewLineForFunctions: false, | ||
placeOpenBraceOnNewLineForControlBlocks: false | ||
} | ||
}, | ||
allowLocalPluginLoads: false, | ||
globalPlugins: [], | ||
pluginProbeLocations: [] | ||
}; | ||
|
||
/** | ||
|
@@ -223,7 +227,7 @@ export class TypeScriptService { | |
this.inMemoryFileSystem, | ||
this.updater, | ||
this.traceModuleResolution, | ||
params.initializationOptions, | ||
this.settings, | ||
this.logger | ||
); | ||
this.packageManager = new PackageManager(this.updater, this.inMemoryFileSystem, this.logger); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
please wrap long lines by making one argument per line: