Compare commits
2 commits
Author | SHA1 | Date | |
---|---|---|---|
605f60cd4f | |||
9ba85fba04 |
|
@ -2374,7 +2374,7 @@ namespace ts.projectSystem {
|
|||
});
|
||||
projectService.checkNumberOfProjects({ externalProjects: 1 });
|
||||
const typeAcquisition = projectService.externalProjects[0].getTypeAcquisition();
|
||||
assert.isTrue(typeAcquisition.enable, "Typine acquisition should be enabled");
|
||||
assert.isTrue(typeAcquisition.enable, "Type acquisition should be enabled");
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -2738,7 +2738,7 @@ namespace ts.projectSystem {
|
|||
});
|
||||
|
||||
describe("watching @types", () => {
|
||||
it("works correctly when typings are added or removed", () => {
|
||||
it("works correctly when typings are added or removed", () => { //!
|
||||
const f1 = {
|
||||
path: "/a/b/app.ts",
|
||||
content: "let x = 1;"
|
||||
|
|
|
@ -10,11 +10,17 @@
|
|||
namespace ts.server {
|
||||
export const maxProgramSizeForNonTsFiles = 20 * 1024 * 1024;
|
||||
|
||||
export const TypingsInstalledEvent = "typingsInstalled";
|
||||
export const ContextEvent = "context";
|
||||
export const ConfigFileDiagEvent = "configFileDiag";
|
||||
export const ProjectLanguageServiceStateEvent = "projectLanguageServiceState";
|
||||
export const ProjectInfoTelemetryEvent = "projectInfo";
|
||||
|
||||
export interface TypingsInstalledEvent {
|
||||
eventName: typeof TypingsInstalledEvent;
|
||||
data: { project: Project };
|
||||
}
|
||||
|
||||
export interface ContextEvent {
|
||||
eventName: typeof ContextEvent;
|
||||
data: { project: Project; fileName: NormalizedPath };
|
||||
|
@ -77,7 +83,7 @@ namespace ts.server {
|
|||
readonly dts: number;
|
||||
}
|
||||
|
||||
export type ProjectServiceEvent = ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent;
|
||||
export type ProjectServiceEvent = TypingsInstalledEvent | ContextEvent | ConfigFileDiagEvent | ProjectLanguageServiceStateEvent | ProjectInfoTelemetryEvent;
|
||||
|
||||
export interface ProjectServiceEventHandler {
|
||||
(event: ProjectServiceEvent): void;
|
||||
|
@ -405,6 +411,7 @@ namespace ts.server {
|
|||
this.throttleWaitMilliseconds = opts.throttleWaitMilliseconds;
|
||||
this.eventHandler = opts.eventHandler;
|
||||
this.globalPlugins = opts.globalPlugins || emptyArray;
|
||||
this.logger.info(`GLOBAL PLUGINS: ${opts.globalPlugins}`);
|
||||
this.pluginProbeLocations = opts.pluginProbeLocations || emptyArray;
|
||||
this.allowLocalPluginLoads = !!opts.allowLocalPluginLoads;
|
||||
|
||||
|
@ -450,7 +457,9 @@ namespace ts.server {
|
|||
});
|
||||
}
|
||||
|
||||
//!
|
||||
updateTypingsForProject(response: SetTypings | InvalidateCachedTypings): void {
|
||||
debugger; //!
|
||||
const project = this.findProject(response.projectName);
|
||||
if (!project) {
|
||||
return;
|
||||
|
@ -463,7 +472,14 @@ namespace ts.server {
|
|||
this.typingsCache.deleteTypingsForProject(response.projectName);
|
||||
break;
|
||||
}
|
||||
|
||||
//Also send new errors...
|
||||
project.updateGraph();
|
||||
|
||||
//this.eventHandler(<ContextEvent>{
|
||||
// eventName: ContextEvent,
|
||||
// data: { project, fileName: response.proje }
|
||||
//});
|
||||
}
|
||||
|
||||
setCompilerOptionsForInferredProjects(projectCompilerOptions: protocol.ExternalProjectCompilerOptions): void {
|
||||
|
|
|
@ -5,6 +5,9 @@
|
|||
/// <reference path="typingsCache.ts"/>
|
||||
/// <reference path="builder.ts"/>
|
||||
|
||||
interface Console { [x: string]: any; }
|
||||
declare var console: Console;
|
||||
|
||||
namespace ts.server {
|
||||
|
||||
export enum ProjectKind {
|
||||
|
@ -115,7 +118,7 @@ namespace ts.server {
|
|||
// wrapper over the real language service that will suppress all semantic operations
|
||||
protected languageService: LanguageService;
|
||||
|
||||
public languageServiceEnabled = true;
|
||||
public languageServiceEnabled = true; //If this is false, why even have a Project?
|
||||
|
||||
protected lsHost: LSHost;
|
||||
|
||||
|
@ -530,7 +533,7 @@ namespace ts.server {
|
|||
* Updates set of files that contribute to this project
|
||||
* @returns: true if set of files in the project stays the same and false - otherwise.
|
||||
*/
|
||||
updateGraph(): boolean {
|
||||
updateGraph(): boolean { //!
|
||||
this.lsHost.startRecordingFilesWithChangedResolutions();
|
||||
|
||||
let hasChanges = this.updateGraphWorker();
|
||||
|
@ -566,7 +569,7 @@ namespace ts.server {
|
|||
// update builder only if language service is enabled
|
||||
// otherwise tell it to drop its internal state
|
||||
if (this.languageServiceEnabled) {
|
||||
this.builder.onProjectUpdateGraph();
|
||||
this.builder.onProjectUpdateGraph(); //important?
|
||||
}
|
||||
else {
|
||||
this.builder.clear();
|
||||
|
@ -963,7 +966,7 @@ namespace ts.server {
|
|||
return this.getProjectName();
|
||||
}
|
||||
|
||||
enablePlugins() {
|
||||
private enablePlugins() {
|
||||
const host = this.projectService.host;
|
||||
const options = this.getCompilerOptions();
|
||||
|
||||
|
@ -995,6 +998,7 @@ namespace ts.server {
|
|||
// Skip already-locally-loaded plugins
|
||||
if (options.plugins && options.plugins.some(p => p.name === globalPluginName)) continue;
|
||||
|
||||
//For some reason, we have global plugins...
|
||||
// Provide global: true so plugins can detect why they can't find their config
|
||||
this.enablePlugin({ name: globalPluginName, global: true } as PluginImport, searchPaths);
|
||||
}
|
||||
|
|
|
@ -116,8 +116,6 @@ namespace ts.server {
|
|||
birthtime: Date;
|
||||
}
|
||||
|
||||
type RequireResult = { module: {}, error: undefined } | { module: undefined, error: {} };
|
||||
|
||||
const readline: {
|
||||
createInterface(options: ReadLineOptions): NodeJS.EventEmitter;
|
||||
} = require("readline");
|
||||
|
@ -333,62 +331,59 @@ namespace ts.server {
|
|||
this.logger.info(`Received response: ${JSON.stringify(response)}`);
|
||||
}
|
||||
|
||||
if (response.kind === EventInitializationFailed) {
|
||||
if (!this.eventSender) {
|
||||
return;
|
||||
}
|
||||
const body: protocol.TypesInstallerInitializationFailedEventBody = {
|
||||
message: response.message
|
||||
};
|
||||
const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed";
|
||||
this.eventSender.event(body, eventName);
|
||||
return;
|
||||
}
|
||||
switch (response.kind) {
|
||||
case EventInitializationFailed:
|
||||
if (this.eventSender) {
|
||||
const body: protocol.TypesInstallerInitializationFailedEventBody = {
|
||||
message: response.message
|
||||
};
|
||||
const eventName: protocol.TypesInstallerInitializationFailedEventName = "typesInstallerInitializationFailed";
|
||||
this.eventSender.event(body, eventName);
|
||||
}
|
||||
break;
|
||||
|
||||
if (response.kind === EventBeginInstallTypes) {
|
||||
if (!this.eventSender) {
|
||||
return;
|
||||
}
|
||||
const body: protocol.BeginInstallTypesEventBody = {
|
||||
eventId: response.eventId,
|
||||
packages: response.packagesToInstall,
|
||||
};
|
||||
const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes";
|
||||
this.eventSender.event(body, eventName);
|
||||
case EventBeginInstallTypes:
|
||||
if (this.eventSender) {
|
||||
const body: protocol.BeginInstallTypesEventBody = {
|
||||
eventId: response.eventId,
|
||||
packages: response.packagesToInstall,
|
||||
};
|
||||
const eventName: protocol.BeginInstallTypesEventName = "beginInstallTypes";
|
||||
this.eventSender.event(body, eventName);
|
||||
}
|
||||
break;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (response.kind === EventEndInstallTypes) {
|
||||
if (!this.eventSender) {
|
||||
return;
|
||||
}
|
||||
if (this.telemetryEnabled) {
|
||||
const body: protocol.TypingsInstalledTelemetryEventBody = {
|
||||
telemetryEventName: "typingsInstalled",
|
||||
payload: {
|
||||
installedPackages: response.packagesToInstall.join(","),
|
||||
installSuccess: response.installSuccess,
|
||||
typingsInstallerVersion: response.typingsInstallerVersion
|
||||
case EventEndInstallTypes:
|
||||
debugger; //kill
|
||||
if (this.eventSender) {
|
||||
if (this.telemetryEnabled) {
|
||||
const body: protocol.TypingsInstalledTelemetryEventBody = {
|
||||
telemetryEventName: "typingsInstalled",
|
||||
payload: {
|
||||
installedPackages: response.packagesToInstall.join(","),
|
||||
installSuccess: response.installSuccess,
|
||||
typingsInstallerVersion: response.typingsInstallerVersion
|
||||
}
|
||||
};
|
||||
const eventName: protocol.TelemetryEventName = "telemetry";
|
||||
this.eventSender.event(body, eventName);
|
||||
}
|
||||
};
|
||||
const eventName: protocol.TelemetryEventName = "telemetry";
|
||||
this.eventSender.event(body, eventName);
|
||||
}
|
||||
|
||||
const body: protocol.EndInstallTypesEventBody = {
|
||||
eventId: response.eventId,
|
||||
packages: response.packagesToInstall,
|
||||
success: response.installSuccess,
|
||||
};
|
||||
const eventName: protocol.EndInstallTypesEventName = "endInstallTypes";
|
||||
this.eventSender.event(body, eventName);
|
||||
return;
|
||||
}
|
||||
const body: protocol.EndInstallTypesEventBody = {
|
||||
eventId: response.eventId,
|
||||
packages: response.packagesToInstall,
|
||||
success: response.installSuccess,
|
||||
};
|
||||
const eventName: protocol.EndInstallTypesEventName = "endInstallTypes";
|
||||
this.eventSender.event(body, eventName);
|
||||
}
|
||||
break;
|
||||
|
||||
this.projectService.updateTypingsForProject(response);
|
||||
if (response.kind === ActionSet && this.socket) {
|
||||
this.sendEvent(0, "setTypings", response);
|
||||
default:
|
||||
this.projectService.updateTypingsForProject(response);//uh, when does this happen?
|
||||
if (response.kind === ActionSet && this.socket) {
|
||||
this.sendEvent(0, "setTypings", response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -340,8 +340,15 @@ namespace ts.server {
|
|||
|
||||
private defaultEventHandler(event: ProjectServiceEvent) {
|
||||
switch (event.eventName) {
|
||||
case TypingsInstalledEvent: {
|
||||
const { project } = event.data;
|
||||
this.projectService.logger.info(`new typings installed, updating diagnostics`);
|
||||
const files = project.getFileNames(); //TODO: only open files
|
||||
this.errorCheck.startNew(next => this.getDiagnostics(next, /*delay*/ 0, files));
|
||||
break;
|
||||
}
|
||||
case ContextEvent:
|
||||
const { project, fileName } = event.data;
|
||||
const { project, fileName } = event.data;//!
|
||||
this.projectService.logger.info(`got context event, updating diagnostics for ${fileName}`);
|
||||
this.errorCheck.startNew(next => this.updateErrorCheck(next, [{ fileName, project }], this.changeSeq, (n) => n === this.changeSeq, 100));
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue