mirror of
https://github.com/microsoft/TypeScript.git
synced 2025-11-18 17:21:48 +00:00
Merge branch 'master' into pvb/codeaction/api
# Conflicts: # src/compiler/diagnosticMessages.json # src/services/services.ts
This commit is contained in:
+16
-1
@@ -216,7 +216,18 @@ namespace ts.server {
|
||||
return {
|
||||
isMemberCompletion: false,
|
||||
isNewIdentifierLocation: false,
|
||||
entries: response.body
|
||||
entries: response.body.map(entry => {
|
||||
|
||||
if (entry.replacementSpan !== undefined) {
|
||||
const { name, kind, kindModifiers, sortText, replacementSpan} = entry;
|
||||
|
||||
const convertedSpan = createTextSpanFromBounds(this.lineOffsetToPosition(fileName, replacementSpan.start),
|
||||
this.lineOffsetToPosition(fileName, replacementSpan.end));
|
||||
return { name, kind, kindModifiers, sortText, replacementSpan: convertedSpan };
|
||||
}
|
||||
|
||||
return entry as { name: string, kind: string, kindModifiers: string, sortText: string };
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
@@ -235,6 +246,10 @@ namespace ts.server {
|
||||
return response.body[0];
|
||||
}
|
||||
|
||||
getCompletionEntrySymbol(fileName: string, position: number, entryName: string): Symbol {
|
||||
throw new Error("Not Implemented Yet.");
|
||||
}
|
||||
|
||||
getNavigateToItems(searchValue: string): NavigateToItem[] {
|
||||
const args: protocol.NavtoRequestArgs = {
|
||||
searchValue,
|
||||
|
||||
@@ -275,7 +275,7 @@ namespace ts.server {
|
||||
removeRoot(info: ScriptInfo) {
|
||||
if (this.filenameToScript.contains(info.path)) {
|
||||
this.filenameToScript.remove(info.path);
|
||||
this.roots = copyListRemovingItem(info, this.roots);
|
||||
unorderedRemoveItem(this.roots, info);
|
||||
this.resolvedModuleNames.remove(info.path);
|
||||
this.resolvedTypeReferenceDirectives.remove(info.path);
|
||||
}
|
||||
@@ -306,11 +306,6 @@ namespace ts.server {
|
||||
throw new Error("No script with name '" + filename + "'");
|
||||
}
|
||||
|
||||
resolvePath(path: string): string {
|
||||
const result = this.host.resolvePath(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
fileExists(path: string): boolean {
|
||||
const result = this.host.fileExists(path);
|
||||
return result;
|
||||
@@ -324,6 +319,14 @@ namespace ts.server {
|
||||
return this.host.getDirectories(path);
|
||||
}
|
||||
|
||||
readDirectory(path: string, extensions?: string[], exclude?: string[], include?: string[]): string[] {
|
||||
return this.host.readDirectory(path, extensions, exclude, include);
|
||||
}
|
||||
|
||||
readFile(path: string, encoding?: string): string {
|
||||
return this.host.readFile(path, encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param line 1 based index
|
||||
*/
|
||||
@@ -585,16 +588,6 @@ namespace ts.server {
|
||||
project?: Project;
|
||||
}
|
||||
|
||||
function copyListRemovingItem<T>(item: T, list: T[]) {
|
||||
const copiedList: T[] = [];
|
||||
for (let i = 0, len = list.length; i < len; i++) {
|
||||
if (list[i] != item) {
|
||||
copiedList.push(list[i]);
|
||||
}
|
||||
}
|
||||
return copiedList;
|
||||
}
|
||||
|
||||
/**
|
||||
* This helper funciton processes a list of projects and return the concatenated, sortd and deduplicated output of processing each project.
|
||||
*/
|
||||
@@ -880,7 +873,7 @@ namespace ts.server {
|
||||
project.directoryWatcher.close();
|
||||
forEachProperty(project.directoriesWatchedForWildcards, watcher => { watcher.close(); });
|
||||
delete project.directoriesWatchedForWildcards;
|
||||
this.configuredProjects = copyListRemovingItem(project, this.configuredProjects);
|
||||
unorderedRemoveItem(this.configuredProjects, project);
|
||||
}
|
||||
else {
|
||||
for (const directory of project.directoriesWatchedForTsconfig) {
|
||||
@@ -892,7 +885,7 @@ namespace ts.server {
|
||||
delete project.projectService.directoryWatchersForTsconfig[directory];
|
||||
}
|
||||
}
|
||||
this.inferredProjects = copyListRemovingItem(project, this.inferredProjects);
|
||||
unorderedRemoveItem(this.inferredProjects, project);
|
||||
}
|
||||
|
||||
const fileNames = project.getFileNames();
|
||||
@@ -1017,7 +1010,7 @@ namespace ts.server {
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
|
||||
unorderedRemoveItem(this.openFilesReferenced, info);
|
||||
}
|
||||
info.close();
|
||||
}
|
||||
@@ -1524,13 +1517,13 @@ namespace ts.server {
|
||||
// openFileRoots or openFileReferenced.
|
||||
if (info.isOpen) {
|
||||
if (this.openFileRoots.indexOf(info) >= 0) {
|
||||
this.openFileRoots = copyListRemovingItem(info, this.openFileRoots);
|
||||
unorderedRemoveItem(this.openFileRoots, info);
|
||||
if (info.defaultProject && !info.defaultProject.isConfiguredProject()) {
|
||||
this.removeProject(info.defaultProject);
|
||||
}
|
||||
}
|
||||
if (this.openFilesReferenced.indexOf(info) >= 0) {
|
||||
this.openFilesReferenced = copyListRemovingItem(info, this.openFilesReferenced);
|
||||
unorderedRemoveItem(this.openFilesReferenced, info);
|
||||
}
|
||||
this.openFileRootsConfigured.push(info);
|
||||
info.defaultProject = project;
|
||||
@@ -1601,8 +1594,10 @@ namespace ts.server {
|
||||
InsertSpaceAfterFunctionKeywordForAnonymousFunctions: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingNonemptyBraces: true,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces: false,
|
||||
InsertSpaceAfterOpeningAndBeforeClosingJsxExpressionBraces: false,
|
||||
InsertSpaceAfterTypeAssertion: false,
|
||||
PlaceOpenBraceOnNewLineForFunctions: false,
|
||||
PlaceOpenBraceOnNewLineForControlBlocks: false,
|
||||
});
|
||||
|
||||
Vendored
+5
@@ -773,6 +773,11 @@ declare namespace ts.server.protocol {
|
||||
* is often the same as the name but may be different in certain circumstances.
|
||||
*/
|
||||
sortText: string;
|
||||
/**
|
||||
* An optional span that indicates the text to be replaced by this completion item. If present,
|
||||
* this span should be used instead of the default one.
|
||||
*/
|
||||
replacementSpan?: TextSpan;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -204,7 +204,7 @@ namespace ts.server {
|
||||
// average async stat takes about 30 microseconds
|
||||
// set chunk size to do 30 files in < 1 millisecond
|
||||
function createPollingWatchedFileSet(interval = 2500, chunkSize = 30) {
|
||||
let watchedFiles: WatchedFile[] = [];
|
||||
const watchedFiles: WatchedFile[] = [];
|
||||
let nextFileToCheck = 0;
|
||||
let watchTimer: any;
|
||||
|
||||
@@ -267,7 +267,7 @@ namespace ts.server {
|
||||
}
|
||||
|
||||
function removeFile(file: WatchedFile) {
|
||||
watchedFiles = copyListRemovingItem(file, watchedFiles);
|
||||
unorderedRemoveItem(watchedFiles, file);
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
+11
-1
@@ -778,7 +778,17 @@ namespace ts.server {
|
||||
|
||||
return completions.entries.reduce((result: protocol.CompletionEntry[], entry: ts.CompletionEntry) => {
|
||||
if (completions.isMemberCompletion || (entry.name.toLowerCase().indexOf(prefix.toLowerCase()) === 0)) {
|
||||
result.push(entry);
|
||||
const { name, kind, kindModifiers, sortText, replacementSpan } = entry;
|
||||
|
||||
let convertedSpan: protocol.TextSpan = undefined;
|
||||
if (replacementSpan) {
|
||||
convertedSpan = {
|
||||
start: compilerService.host.positionToLineOffset(fileName, replacementSpan.start),
|
||||
end: compilerService.host.positionToLineOffset(fileName, replacementSpan.start + replacementSpan.length)
|
||||
};
|
||||
}
|
||||
|
||||
result.push({ name, kind, kindModifiers, sortText, replacementSpan: convertedSpan });
|
||||
}
|
||||
return result;
|
||||
}, []).sort((a, b) => a.name.localeCompare(b.name));
|
||||
|
||||
Reference in New Issue
Block a user