Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 488906 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js (-39 / +28 lines)
Lines 99-107 Link Here
99
99
100
		var ternReady = false,
100
		var ternReady = false,
101
			workerReady = false,
101
			workerReady = false,
102
			startCount = 0,
102
			pendingStart,
103
			TRACE,
103
			TRACE,
104
			pendingStart = Object.create(null),
105
			messageQueue = [], // for all other requests
104
			messageQueue = [], // for all other requests
106
			modifyQueue = []; // for add and removes only
105
			modifyQueue = []; // for add and removes only
107
		
106
		
Lines 130-149 Link Here
130
	 * @callback 
129
	 * @callback 
131
	 */
130
	 */
132
	WrappedWorker.prototype.postMessage = function(msg, f) {
131
	WrappedWorker.prototype.postMessage = function(msg, f) {
133
		var starting = msg.request === "start_server";
132
		if(ternReady || msg.request === 'read') { //configuration reads can happen while the server is starting
134
		if(starting) {
135
			if(!workerReady) {
136
				pendingStart.msg = msg;
137
				pendingStart.f = f;
138
				return; //don't queue start_server requests
139
			}
140
			if(startCount > 0 && msg.args.initial) {
141
				return;
142
			}
143
			startCount++;
144
			ternReady = false;
145
		}
146
		if(ternReady || starting || msg.request === 'read') { //configuration reads can happen while the server is starting
147
			if(msg !== null && typeof msg === 'object') {
133
			if(msg !== null && typeof msg === 'object') {
148
				if(typeof msg.messageID !== 'number' && typeof msg.ternID !== 'number') {
134
				if(typeof msg.messageID !== 'number' && typeof msg.ternID !== 'number') {
149
					//don't overwrite an id from a tern-side request
135
					//don't overwrite an id from a tern-side request
Lines 155-160 Link Here
155
				console.log("postMessage ("+this.messageId+") - SENT "+JSON.stringify(msg)); //$NON-NLS-1$ //$NON-NLS-2$
141
				console.log("postMessage ("+this.messageId+") - SENT "+JSON.stringify(msg)); //$NON-NLS-1$ //$NON-NLS-2$
156
			}
142
			}
157
			this.worker.postMessage(msg);
143
			this.worker.postMessage(msg);
144
		} else if(msg.request === "start_server") {
145
			if(!workerReady) {
146
				pendingStart = {msg: msg, f: f};
147
			} else {
148
				this.worker.postMessage(msg);
149
			}
158
		} else if (msg.request === "addFile" || msg.request === "delFile") {
150
		} else if (msg.request === "addFile" || msg.request === "delFile") {
159
			if(TRACE) {
151
			if(TRACE) {
160
				console.log("postMessage ("+this.messageId+") - MODIFY QUEUED: "+JSON.stringify(msg)); //$NON-NLS-1$ //$NON-NLS-2$
152
				console.log("postMessage ("+this.messageId+") - MODIFY QUEUED: "+JSON.stringify(msg)); //$NON-NLS-1$ //$NON-NLS-2$
Lines 187-196 Link Here
187
					console.log("worker_ready ("+ternWorker.messageId+"): "+JSON.stringify(response)); //$NON-NLS-1$ //$NON-NLS-2$
179
					console.log("worker_ready ("+ternWorker.messageId+"): "+JSON.stringify(response)); //$NON-NLS-1$ //$NON-NLS-2$
188
				}
180
				}
189
				workerReady = true;
181
				workerReady = true;
190
				if (!pendingStart.msg || !pendingStart.msg.request){
182
				if(pendingStart) {
191
					pendingStart.msg = {request: "start_server", args: {initial: true}}; //$NON-NLS-1$
183
					ternWorker.postMessage(pendingStart.msg, pendingStart.f);
184
					pendingStart = null;
192
				}
185
				}
193
				ternWorker.postMessage(pendingStart.msg, pendingStart.f);
194
			},
186
			},
195
			/**
187
			/**
196
			 * @callback
188
			 * @callback
Lines 292-319 Link Here
292
		 * @since 10.0
284
		 * @since 10.0
293
		 */
285
		 */
294
		function serverReady() {
286
		function serverReady() {
295
			startCount--;
287
			ternReady = true;
296
			if(startCount === 0) {
288
			// process all add/remove first
297
				ternReady = true;
289
			for(var i = 0, len = modifyQueue.length; i < len; i++) {
298
				// process all add/remove first
290
				var item = modifyQueue[i];
299
				for(var i = 0, len = modifyQueue.length; i < len; i++) {
291
				if(TRACE) {
300
					var item = modifyQueue[i];
292
					console.log("clearing MODIFY queue: "+JSON.stringify(item.msg)); //$NON-NLS-1$
301
					if(TRACE) {
302
						console.log("clearing MODIFY queue: "+JSON.stringify(item.msg)); //$NON-NLS-1$
303
					}
304
					ternWorker.postMessage(item.msg, item.f);
305
				}
293
				}
306
				modifyQueue = [];
294
				ternWorker.postMessage(item.msg, item.f);
307
				// process remaining pending requests
308
				for(i = 0, len = messageQueue.length; i < len; i++) {
309
					item = messageQueue[i];
310
					if(TRACE) {
311
						console.log("clearing MESSAGE queue: "+JSON.stringify(item.msg)); //$NON-NLS-1$
312
					}
313
					ternWorker.postMessage(item.msg, item.f);
314
				}
315
				messageQueue = [];
316
			}
295
			}
296
			modifyQueue = [];
297
			// process remaining pending requests
298
			for(i = 0, len = messageQueue.length; i < len; i++) {
299
				item = messageQueue[i];
300
				if(TRACE) {
301
					console.log("clearing MESSAGE queue: "+JSON.stringify(item.msg)); //$NON-NLS-1$
302
				}
303
				ternWorker.postMessage(item.msg, item.f);
304
			}
305
			messageQueue = [];
317
		}
306
		}
318
307
319
    	/**
308
    	/**
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/ternProjectManager.js (-6 / +9 lines)
Lines 241-256 Link Here
241
					this.projectLocation = project.Location;
241
					this.projectLocation = project.Location;
242
					this.scriptResolver.setSearchLocation(project.Location);
242
					this.scriptResolver.setSearchLocation(project.Location);
243
					var c = project.Children;
243
					var c = project.Children;
244
					var tpf;
244
					for(var i = 0, len = c.length; i < len; i++) {
245
					for(var i = 0, len = c.length; i < len; i++) {
245
						if(".tern-project" === c[i].Name) {
246
						if(".tern-project" === c[i].Name) {
246
							this.currentFile = c[i].Location;
247
							tpf = c[i].Location;
247
							this.starting();
248
							break;
248
							return this.parseTernJSON(this.currentFile).then(function(jsonOptions){
249
								this.json = jsonOptions;
250
								return this.loadTernProjectOptions(jsonOptions);
251
							}.bind(this));
252
						}
249
						}
253
					}
250
					}
251
					if(typeof tpf === 'string') {
252
						this.refresh(tpf);
253
					} else {
254
						//no .tern-project - request default startup
255
						this.loadTernProjectOptions();
256
					}
254
				}
257
				}
255
			}
258
			}
256
		}
259
		}

Return to bug 488906