-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Add build target for packaging tsserver as a library #3513
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
Changes from all commits
ab1512f
8554791
b8f6ada
9a3fead
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,11 +100,20 @@ var serverSources = [ | |
| "editorServices.ts", | ||
| "protocol.d.ts", | ||
| "session.ts", | ||
| "nodeimpl.ts", | ||
| "server.ts" | ||
| ].map(function (f) { | ||
| return path.join(serverDirectory, f); | ||
| }); | ||
|
|
||
| var languageServiceLibrarySources = [ | ||
|
Contributor
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 would concat the services sources as well, to get incremental compilation working correctly.
Member
Author
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. Alright. |
||
| "editorServices.ts", | ||
| "protocol.d.ts", | ||
| "session.ts" | ||
| ].map(function (f) { | ||
| return path.join(serverDirectory, f); | ||
| }); | ||
|
|
||
| var harnessSources = [ | ||
| "harness.ts", | ||
| "sourceMapRecorder.ts", | ||
|
|
@@ -137,6 +146,7 @@ var harnessSources = [ | |
| "protocol.d.ts", | ||
| "session.ts", | ||
| "client.ts", | ||
| "nodeimpl.ts", | ||
| "editorServices.ts", | ||
| ].map(function (f) { | ||
| return path.join(serverDirectory, f); | ||
|
|
@@ -369,6 +379,20 @@ compileFile(servicesFile, servicesSources,[builtLocalDirectory, copyright].conca | |
| var serverFile = path.join(builtLocalDirectory, "tsserver.js"); | ||
| compileFile(serverFile, serverSources,[builtLocalDirectory, copyright].concat(serverSources), /*prefixes*/ [copyright], /*useBuiltCompiler*/ true); | ||
|
|
||
| var lsslFile = path.join(builtLocalDirectory, "tslssl.js"); | ||
| compileFile( | ||
| lsslFile, | ||
| languageServiceLibrarySources, | ||
| [builtLocalDirectory, copyright].concat(serverSources).concat(languageServiceLibrarySources), | ||
|
Contributor
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. you do not need
Member
Author
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. Aye, good catch. Didn't change that since removing the extra section up above. |
||
| /*prefixes*/ [copyright], | ||
| /*useBuiltCompiler*/ true, | ||
| /*noOutFile*/ false, | ||
| /*generateDeclarations*/ true); | ||
|
|
||
| // Local target to build the language service server library | ||
| desc("Builds language service server library"); | ||
| task("lssl", [lsslFile]); | ||
|
|
||
| // Local target to build the compiler and services | ||
| desc("Builds the full compiler and services"); | ||
| task("local", ["generate-diagnostics", "lib", tscFile, servicesFile, nodeDefinitionsFile, serverFile]); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,7 +2,6 @@ | |
| /// <reference path="..\services\services.ts" /> | ||
| /// <reference path="protocol.d.ts" /> | ||
| /// <reference path="session.ts" /> | ||
| /// <reference path="node.d.ts" /> | ||
|
|
||
| module ts.server { | ||
| export interface Logger { | ||
|
|
@@ -28,15 +27,15 @@ module ts.server { | |
| }); | ||
| } | ||
|
|
||
| class ScriptInfo { | ||
| export class ScriptInfo { | ||
| svc: ScriptVersionCache; | ||
| children: ScriptInfo[] = []; // files referenced by this file | ||
| defaultProject: Project; // project to use by default for file | ||
| fileWatcher: FileWatcher; | ||
| formatCodeOptions = ts.clone(CompilerService.defaultFormatCodeOptions); | ||
|
|
||
| constructor(private host: ServerHost, public fileName: string, public content: string, public isOpen = false) { | ||
| this.svc = ScriptVersionCache.fromString(content); | ||
| this.svc = ScriptVersionCache.fromString(host, content); | ||
| } | ||
|
|
||
| setFormatOptions(formatOptions: protocol.FormatOptions): void { | ||
|
|
@@ -80,7 +79,7 @@ module ts.server { | |
| } | ||
| } | ||
|
|
||
| class LSHost implements ts.LanguageServiceHost { | ||
| export class LSHost implements ts.LanguageServiceHost { | ||
| ls: ts.LanguageService = null; | ||
| compilationSettings: ts.CompilerOptions; | ||
| filenameToScript: ts.Map<ScriptInfo> = {}; | ||
|
|
@@ -273,7 +272,7 @@ module ts.server { | |
| } | ||
| } | ||
|
|
||
| interface ProjectOptions { | ||
| export interface ProjectOptions { | ||
| // these fields can be present in the project file | ||
| files?: string[]; | ||
| compilerOptions?: ts.CompilerOptions; | ||
|
|
@@ -376,7 +375,7 @@ module ts.server { | |
| } | ||
| } | ||
|
|
||
| interface ProjectOpenResult { | ||
| export interface ProjectOpenResult { | ||
| success?: boolean; | ||
| errorMsg?: string; | ||
| project?: Project; | ||
|
|
@@ -392,11 +391,11 @@ module ts.server { | |
| return copiedList; | ||
| } | ||
|
|
||
| interface ProjectServiceEventHandler { | ||
| export interface ProjectServiceEventHandler { | ||
| (eventName: string, project: Project, fileName: string): void; | ||
| } | ||
|
|
||
| interface HostConfiguration { | ||
| export interface HostConfiguration { | ||
| formatCodeOptions: ts.FormatCodeOptions; | ||
| hostInfo: string; | ||
| } | ||
|
|
@@ -916,7 +915,7 @@ module ts.server { | |
| return rawConfig.error; | ||
| } | ||
| else { | ||
| var parsedCommandLine = ts.parseConfigFile(rawConfig.config, ts.sys, dirPath); | ||
| var parsedCommandLine = ts.parseConfigFile(rawConfig.config, this.host, dirPath); | ||
| if (parsedCommandLine.errors && (parsedCommandLine.errors.length > 0)) { | ||
| return { errorMsg: "tsconfig option errors" }; | ||
| } | ||
|
|
@@ -953,7 +952,7 @@ module ts.server { | |
|
|
||
| } | ||
|
|
||
| class CompilerService { | ||
| export class CompilerService { | ||
| host: LSHost; | ||
| languageService: ts.LanguageService; | ||
| classifier: ts.Classifier; | ||
|
|
@@ -985,7 +984,7 @@ module ts.server { | |
| static defaultFormatCodeOptions: ts.FormatCodeOptions = { | ||
| IndentSize: 4, | ||
| TabSize: 4, | ||
| NewLineCharacter: ts.sys.newLine, | ||
| NewLineCharacter: ts.sys ? ts.sys.newLine : '\n', | ||
| ConvertTabsToSpaces: true, | ||
| InsertSpaceAfterCommaDelimiter: true, | ||
| InsertSpaceAfterSemicolonInForStatements: true, | ||
|
|
@@ -999,7 +998,7 @@ module ts.server { | |
|
|
||
| } | ||
|
|
||
| interface LineCollection { | ||
| export interface LineCollection { | ||
| charCount(): number; | ||
| lineCount(): number; | ||
| isLeaf(): boolean; | ||
|
|
@@ -1013,7 +1012,7 @@ module ts.server { | |
| leaf?: LineLeaf; | ||
| } | ||
|
|
||
| enum CharRangeSection { | ||
| export enum CharRangeSection { | ||
| PreStart, | ||
| Start, | ||
| Entire, | ||
|
|
@@ -1022,7 +1021,7 @@ module ts.server { | |
| PostEnd | ||
| } | ||
|
|
||
| interface ILineIndexWalker { | ||
| export interface ILineIndexWalker { | ||
| goSubtree: boolean; | ||
| done: boolean; | ||
| leaf(relativeStart: number, relativeLength: number, lineCollection: LineLeaf): void; | ||
|
|
@@ -1248,7 +1247,7 @@ module ts.server { | |
| } | ||
|
|
||
| // text change information | ||
| class TextChange { | ||
| export class TextChange { | ||
| constructor(public pos: number, public deleteLen: number, public insertedText?: string) { | ||
| } | ||
|
|
||
|
|
@@ -1263,6 +1262,7 @@ module ts.server { | |
| versions: LineIndexSnapshot[] = []; | ||
| minVersion = 0; // no versions earlier than min version will maintain change history | ||
| private currentVersion = 0; | ||
| private host: System; | ||
|
Contributor
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.
|
||
|
|
||
| static changeNumberThreshold = 8; | ||
| static changeLengthThreshold = 256; | ||
|
|
@@ -1290,7 +1290,7 @@ module ts.server { | |
| } | ||
|
|
||
| reloadFromFile(filename: string, cb?: () => any) { | ||
| var content = ts.sys.readFile(filename); | ||
| var content = this.host.readFile(filename); | ||
| this.reload(content); | ||
| if (cb) | ||
| cb(); | ||
|
|
@@ -1360,18 +1360,19 @@ module ts.server { | |
| } | ||
| } | ||
|
|
||
| static fromString(script: string) { | ||
| static fromString(host: System, script: string) { | ||
| var svc = new ScriptVersionCache(); | ||
| var snap = new LineIndexSnapshot(0, svc); | ||
| svc.versions[svc.currentVersion] = snap; | ||
| svc.host = host; | ||
| snap.index = new LineIndex(); | ||
| var lm = LineIndex.linesFromText(script); | ||
| snap.index.load(lm.lines); | ||
| return svc; | ||
| } | ||
| } | ||
|
|
||
| class LineIndexSnapshot implements ts.IScriptSnapshot { | ||
| export class LineIndexSnapshot implements ts.IScriptSnapshot { | ||
| index: LineIndex; | ||
| changesSincePreviousVersion: TextChange[] = []; | ||
|
|
||
|
|
@@ -1605,7 +1606,7 @@ module ts.server { | |
| } | ||
| } | ||
|
|
||
| class LineNode implements LineCollection { | ||
| export class LineNode implements LineCollection { | ||
| totalChars = 0; | ||
| totalLines = 0; | ||
| children: LineCollection[] = []; | ||
|
|
@@ -1891,7 +1892,7 @@ module ts.server { | |
| } | ||
| } | ||
|
|
||
| class LineLeaf implements LineCollection { | ||
| export class LineLeaf implements LineCollection { | ||
| udata: any; | ||
|
|
||
| constructor(public text: string) { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| /// <reference path="node.d.ts" /> | ||
| module ts.server { | ||
| export class NodeEnvironment implements Environment { | ||
| byteLength = Buffer.byteLength; | ||
|
Contributor
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. these are only used in the session object, i do not see the point of the additional abstraction, just pass them as constructor paramters.
Member
Author
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. That's pretty much what this is doing, it was just bundling the two parameters into one argument. I'll split it out into multiple arguments. |
||
| hrtime = process.hrtime; | ||
| } | ||
| } | ||
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.
i do not think you need the extra file if we pass the values as a constructor parameter.