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 424361
Collapse All | Expand All

(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/outliner.js (+2 lines)
Lines 133-138 Link Here
133
			if(sig) {
133
			if(sig) {
134
				var item = {
134
				var item = {
135
					label: sig.sig,
135
					label: sig.sig,
136
					labelPost: sig.details,
137
//					classNamePost: "status",  //$NON-NLS-0$
136
					start: sig.range[0],
138
					start: sig.range[0],
137
					end: sig.range[1]
139
					end: sig.range[1]
138
				};
140
				};
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/signatures.js (-12 / +64 lines)
Lines 32-38 Link Here
32
				}
32
				}
33
				var val = this.getNameFrom(astnode);
33
				var val = this.getNameFrom(astnode);
34
				return {
34
				return {
35
					sig: val,
35
					sig: val.name,
36
					details: val.details,
36
					range: this.getSignatureSourceRangeFrom(astnode)
37
					range: this.getSignatureSourceRangeFrom(astnode)
37
				};
38
				};
38
			}
39
			}
Lines 74-90 Link Here
74
		},
75
		},
75
		
76
		
76
		/**
77
		/**
78
		 * @name getPropertyListFrom
79
		 * @description Retrieves the properties from the given AST node iff it a object declaration.
80
		 * @function
81
		 * @public
82
		 * @memberof javascript.Signatures.prototype
83
		 * @param {Object} astnode The AST node to compute the parameters from
84
		 * @param {Integer} maximum length of string to return, must be >= 5, defaults to 50
85
		 * @returns {String} A list of named properties, comma separated in source defined order, surrounded by {}. 
86
		 * 			Ellipsis will be added if properties are available or max length reached.
87
		 */
88
		getPropertyListFrom: function(astnode, maxLength) {
89
			if (!maxLength){
90
				maxLength = 50;
91
			}
92
			if (maxLength < 5){
93
				maxLength = 5;
94
			}
95
			if(astnode) {
96
				var props = astnode.properties;
97
				if(props && props.length > 0) {
98
					var length = props.length;
99
					var value = '{';  //$NON-NLS-0$
100
					for(var i = 0; i < length; i++) {
101
						if(props[i].key && props[i].key.name) {
102
							value += props[i].key.name;
103
						} else {
104
							value += 'Object';  //$NON-NLS-0$
105
						}
106
						if(i < length -1) {
107
							value += ', ';  //$NON-NLS-0$
108
						}
109
						if (value.length > (maxLength-4)){
110
							value = value.substring(0, maxLength);
111
							value += '...'; //$NON-NLS-0$
112
							break;
113
						}
114
						
115
					}
116
					value += '}';  //$NON-NLS-0$
117
					return value;
118
				}
119
			}
120
			return '{...}';  //$NON-NLS-0$
121
		},
122
		
123
		/**
77
		 * @name getNameFrom
124
		 * @name getNameFrom
78
		 * @description Returns the name to display for the given AST node. If there is an attached doc node it
125
		 * @description Returns an object describing what to display for the given AST node. If there is an attached doc node it
79
		 * will be consulted to help compute the name to display
126
		 * will be consulted to help compute the name to display
80
		 * @function
127
		 * @function
81
		 * @public
128
		 * @public
82
		 * @memberof javascript.Signatures.prototype
129
		 * @memberof javascript.Signatures.prototype
83
		 * @param {Object} astnode The AST node to compute the name from
130
		 * @param {Object} astnode The AST node to compute the name from
84
		 * @returns {String} The computed name to display for the node or <code>null</code> if one could not be computed
131
		 * @returns {String} An object containing 'name', the computed name to display for the node or <code>null</code> if one could not be 
132
		 * 					computed and possibly 'details' if optional display information is computed
85
		 */
133
		 */
86
		getNameFrom: function(astnode) {
134
		getNameFrom: function(astnode) {
87
			var name = "Anonyous " + astnode.type;  //$NON-NLS-0$
135
			var name = "Anonyous " + astnode.type;  //$NON-NLS-0$
136
			var details;
88
			if(astnode && astnode.type) {
137
			if(astnode && astnode.type) {
89
				if(astnode.type === 'FunctionDeclaration') {  //$NON-NLS-0$
138
				if(astnode.type === 'FunctionDeclaration') {  //$NON-NLS-0$
90
					//TODO with the attached doc node we can augment this infos
139
					//TODO with the attached doc node we can augment this infos
Lines 95-101 Link Here
95
							name += fparams;
144
							name += fparams;
96
						}
145
						}
97
						name += ')';  //$NON-NLS-0$
146
						name += ')';  //$NON-NLS-0$
98
						return name;
99
					}
147
					}
100
				}
148
				}
101
				else if(astnode.type === 'FunctionExpression') {  //$NON-NLS-0$
149
				else if(astnode.type === 'FunctionExpression') {  //$NON-NLS-0$
Lines 105-114 Link Here
105
						name += feparams;
153
						name += feparams;
106
					}
154
					}
107
					name += ')';  //$NON-NLS-0$
155
					name += ')';  //$NON-NLS-0$
108
					return name;
109
				}
156
				}
110
				else if(astnode.type === 'ObjectExpression') {  //$NON-NLS-0$
157
				else if(astnode.type === 'ObjectExpression') {  //$NON-NLS-0$
111
					name = 'closure {...}';  //$NON-NLS-0$
158
					name = 'closure ';  //$NON-NLS-0$
159
					details = this.getPropertyListFrom(astnode);
112
				}
160
				}
113
				else if(astnode.type === 'Property') {  //$NON-NLS-0$
161
				else if(astnode.type === 'Property') {  //$NON-NLS-0$
114
					if(astnode.value) {
162
					if(astnode.value) {
Lines 133-143 Link Here
133
						else if(astnode.value.type === 'ObjectExpression') {  //$NON-NLS-0$
181
						else if(astnode.value.type === 'ObjectExpression') {  //$NON-NLS-0$
134
							if(astnode.key) {
182
							if(astnode.key) {
135
								if(astnode.key.name) {
183
								if(astnode.key.name) {
136
									name = astnode.key.name + ' {...}';  //$NON-NLS-0$
184
									name = astnode.key.name + ' ';  //$NON-NLS-0$
137
								}
185
								}
138
								else if(astnode.key.value) {
186
								else if(astnode.key.value) {
139
									name = astnode.key.value + ' {...}';  //$NON-NLS-0$
187
									name = astnode.key.value + ' ';  //$NON-NLS-0$
140
								}
188
								}
189
								details = this.getPropertyListFrom(astnode.value);
141
							}
190
							}
142
						}
191
						}
143
						else if(astnode.key) {
192
						else if(astnode.key) {
Lines 154-160 Link Here
154
					if(astnode.init) {
203
					if(astnode.init) {
155
						if(astnode.init.type === 'ObjectExpression') {  //$NON-NLS-0$
204
						if(astnode.init.type === 'ObjectExpression') {  //$NON-NLS-0$
156
							if(astnode.id && astnode.id.name) {
205
							if(astnode.id && astnode.id.name) {
157
								name = 'var '+astnode.id.name+ ' = {...}';  //$NON-NLS-0$  //$NON-NLS-1$
206
								name = 'var '+astnode.id.name+ ' ';  //$NON-NLS-0$  //$NON-NLS-1$
207
								details = this.getPropertyListFrom(astnode.init);
158
							}
208
							}
159
						}
209
						}
160
						else if(astnode.init.type === 'FunctionExpression') {  //$NON-NLS-0$
210
						else if(astnode.init.type === 'FunctionExpression') {  //$NON-NLS-0$
Lines 185-191 Link Here
185
							if(name) {
235
							if(name) {
186
								//append the right stuff
236
								//append the right stuff
187
								if(isobject) {
237
								if(isobject) {
188
									name += ' {...}';  //$NON-NLS-0$
238
									name += ' ';  //$NON-NLS-0$
239
									details = this.getPropertyListFrom(astnode.right); 
189
								}
240
								}
190
								else {
241
								else {
191
									name += '(';  //$NON-NLS-0$
242
									name += '(';  //$NON-NLS-0$
Lines 206-217 Link Here
206
					if(astnode.argument) {
257
					if(astnode.argument) {
207
						if(astnode.argument.type === 'ObjectExpression' ||  //$NON-NLS-0$
258
						if(astnode.argument.type === 'ObjectExpression' ||  //$NON-NLS-0$
208
							astnode.argument.type === 'FunctionExpression') {  //$NON-NLS-0$
259
							astnode.argument.type === 'FunctionExpression') {  //$NON-NLS-0$
209
								name = 'return {...}';  //$NON-NLS-0$
260
								name = 'return ';  //$NON-NLS-0$
261
								details = this.getPropertyListFrom(astnode.argument);
210
						}
262
						}
211
					}
263
					}
212
				}
264
				}
213
			}
265
			}
214
			return name;
266
			return {name: name, details: details};
215
		},
267
		},
216
		
268
		
217
		/**
269
		/**

Return to bug 424361