mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-02-05 08:11:30 -06:00
Removed file mapping compression technique due to brittleness of
approach. As necessary, will substitute grouping or paging approaches.
This commit is contained in:
parent
32e2f4d95d
commit
d2712dd793
@ -69,22 +69,6 @@ module ts.server {
|
||||
};
|
||||
}
|
||||
|
||||
private decodeEncodedFileId(fileId: ts.server.protocol.EncodedFile): string {
|
||||
var fileName: string;
|
||||
if (typeof fileId === "object") {
|
||||
fileName = (<ts.server.protocol.IdFile>fileId).file;
|
||||
this.fileMapping[(<ts.server.protocol.IdFile>fileId).id] = fileName;
|
||||
}
|
||||
else if (typeof fileId === "number") {
|
||||
fileName = ts.lookUp(this.fileMapping, fileId.toString());
|
||||
Debug.assert(!!fileName, "Did not find filename in previous fileID mappings.");
|
||||
}
|
||||
else {
|
||||
Debug.fail("Got unexpedted fileId type.");
|
||||
}
|
||||
return fileName;
|
||||
}
|
||||
|
||||
private processRequest<T extends ts.server.protocol.Request>(command: string, arguments?: any): T {
|
||||
var request: ts.server.protocol.Request = {
|
||||
seq: this.sequence++,
|
||||
@ -232,7 +216,7 @@ module ts.server {
|
||||
var response = this.processResponse<ts.server.protocol.NavtoResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = this.decodeEncodedFileId(entry.file);
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
|
||||
@ -299,7 +283,7 @@ module ts.server {
|
||||
var response = this.processResponse<ts.server.protocol.DefinitionResponse>(request);
|
||||
|
||||
return response.body.map(entry => {
|
||||
var fileName = this.decodeEncodedFileId(entry.file);
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
return {
|
||||
@ -325,7 +309,7 @@ module ts.server {
|
||||
var response = this.processResponse<ts.server.protocol.ReferencesResponse>(request);
|
||||
|
||||
return response.body.refs.map(entry => {
|
||||
var fileName = this.decodeEncodedFileId(entry.file);
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
return {
|
||||
@ -378,7 +362,7 @@ module ts.server {
|
||||
findInStrings: findInStrings,
|
||||
findInComments: findInComments,
|
||||
locations: response.body.locs.map((entry) => {
|
||||
var fileName = this.decodeEncodedFileId(entry.file);
|
||||
var fileName = entry.file;
|
||||
var start = this.lineColToPosition(fileName, entry.start);
|
||||
var end = this.lineColToPosition(fileName, entry.end);
|
||||
return {
|
||||
|
||||
40
src/server/protocol.d.ts
vendored
40
src/server/protocol.d.ts
vendored
@ -153,11 +153,9 @@ declare module ts.server.protocol {
|
||||
*/
|
||||
export interface CodeSpan extends TextSpan {
|
||||
/**
|
||||
* File containing the definition; the value of this
|
||||
* field will always be a string, number of a mapping between
|
||||
* a string and a number.
|
||||
* File containing text span.
|
||||
*/
|
||||
file: EncodedFile;
|
||||
file: string;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -675,11 +673,9 @@ declare module ts.server.protocol {
|
||||
kindModifiers?: string;
|
||||
|
||||
/**
|
||||
* The file in which the symbol is found; the value of this
|
||||
* field will always be a string, number of a mapping between
|
||||
* a string and a number.
|
||||
* The file in which the symbol is found.
|
||||
*/
|
||||
file: EncodedFile;
|
||||
file: string;
|
||||
|
||||
/**
|
||||
* The location within file at which the symbol is found.
|
||||
@ -736,34 +732,6 @@ declare module ts.server.protocol {
|
||||
arguments: ChangeRequestArgs;
|
||||
}
|
||||
|
||||
/**
|
||||
* If an object of this type is returned in place of a string as
|
||||
* the value of a file field in a response message, add the
|
||||
* mapping id => file to the client's cache of file id mappings,
|
||||
* and interpret the value as if it was the string in the 'file'
|
||||
* field.
|
||||
*/
|
||||
export interface IdFile {
|
||||
/**
|
||||
* Id to assign to file.
|
||||
*/
|
||||
id: number;
|
||||
|
||||
/**
|
||||
* File name that will correspond to id.
|
||||
*/
|
||||
file: string;
|
||||
}
|
||||
|
||||
/**
|
||||
* The type of an encoded file name. If of type number, the value
|
||||
* is a file id. If of type IdFile, the value is interpreted as
|
||||
* 'file' and in addition the mapping 'id' to 'file' is
|
||||
* established. If of type string, the value is simply the file
|
||||
* name.
|
||||
*/
|
||||
export type EncodedFile = number | IdFile | string;
|
||||
|
||||
/**
|
||||
* Response to "brace" request.
|
||||
*/
|
||||
|
||||
@ -5,10 +5,6 @@
|
||||
/// <reference path="editorServices.ts" />
|
||||
|
||||
module ts.server {
|
||||
var paddedLength = 8;
|
||||
|
||||
var typeNames = ["interface", "class", "enum", "module", "alias", "type"];
|
||||
|
||||
var spaceCache = [" ", " ", " ", " "];
|
||||
|
||||
interface StackTraceError extends Error {
|
||||
@ -27,7 +23,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
interface FileStart {
|
||||
file: ts.server.protocol.EncodedFile;
|
||||
file: string;
|
||||
start: ILineInfo;
|
||||
}
|
||||
|
||||
@ -204,18 +200,6 @@ module ts.server {
|
||||
this.send(res);
|
||||
}
|
||||
|
||||
encodeFileName(fileName: string): ts.server.protocol.EncodedFile {
|
||||
var id = ts.lookUp(this.fileHash, fileName);
|
||||
if (!id) {
|
||||
id = this.nextFileId++;
|
||||
this.fileHash[fileName] = id;
|
||||
return { id: id, file: fileName };
|
||||
}
|
||||
else {
|
||||
return id;
|
||||
}
|
||||
}
|
||||
|
||||
output(body: any, commandName: string, requestSequence = 0, errorMessage?: string) {
|
||||
this.response(body, commandName, requestSequence, errorMessage);
|
||||
}
|
||||
@ -224,7 +208,7 @@ module ts.server {
|
||||
var diags = project.compilerService.languageService.getSemanticDiagnostics(file);
|
||||
if (diags) {
|
||||
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: this.encodeFileName(file), diagnostics: bakedDiags }, "semanticDiag");
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "semanticDiag");
|
||||
}
|
||||
}
|
||||
|
||||
@ -232,7 +216,7 @@ module ts.server {
|
||||
var diags = project.compilerService.languageService.getSyntacticDiagnostics(file);
|
||||
if (diags) {
|
||||
var bakedDiags = diags.map((diag) => formatDiag(file, project, diag));
|
||||
this.event({ file: this.encodeFileName(file), diagnostics: bakedDiags }, "syntaxDiag");
|
||||
this.event({ file: file, diagnostics: bakedDiags }, "syntaxDiag");
|
||||
}
|
||||
}
|
||||
|
||||
@ -293,7 +277,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
return definitions.map(def => ({
|
||||
file: this.encodeFileName(def.fileName),
|
||||
file: def.fileName,
|
||||
start: compilerService.host.positionToLineCol(def.fileName, def.textSpan.start),
|
||||
end: compilerService.host.positionToLineCol(def.fileName, ts.textSpanEnd(def.textSpan))
|
||||
}));
|
||||
@ -326,7 +310,7 @@ module ts.server {
|
||||
}
|
||||
|
||||
var bakedRenameLocs = renameLocations.map(location => (<ts.server.protocol.CodeSpan>{
|
||||
file: this.encodeFileName(location.fileName),
|
||||
file: location.fileName,
|
||||
start: compilerService.host.positionToLineCol(location.fileName, location.textSpan.start),
|
||||
end: compilerService.host.positionToLineCol(location.fileName, ts.textSpanEnd(location.textSpan)),
|
||||
}));
|
||||
@ -366,7 +350,7 @@ module ts.server {
|
||||
var snap = compilerService.host.getScriptSnapshot(ref.fileName);
|
||||
var lineText = snap.getText(refLineSpan.start, ts.textSpanEnd(refLineSpan)).replace(/\r|\n/g, "");
|
||||
return {
|
||||
file: this.encodeFileName(ref.fileName),
|
||||
file: ref.fileName,
|
||||
start: start,
|
||||
lineText: lineText,
|
||||
end: compilerService.host.positionToLineCol(ref.fileName, ts.textSpanEnd(ref.textSpan)),
|
||||
@ -633,7 +617,7 @@ module ts.server {
|
||||
var bakedItem: ts.server.protocol.NavtoItem = {
|
||||
name: navItem.name,
|
||||
kind: navItem.kind,
|
||||
file: this.encodeFileName(navItem.fileName),
|
||||
file: navItem.fileName,
|
||||
start: start,
|
||||
end: end,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user