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

(-)a/bundles/org.eclipse.orion.client.core/web/orion/metatype.js (+4 lines)
Lines 138-143 Link Here
138
				}
138
				}
139
			});
139
			});
140
		}
140
		}
141
		this.dependsOn = attrJson.dependsOn || null;
141
	};
142
	};
142
	AttributeDefinitionImpl.prototype = {
143
	AttributeDefinitionImpl.prototype = {
143
		getId: function() {
144
		getId: function() {
Lines 161-166 Link Here
161
		},
162
		},
162
		getDefaultValue: function() {
163
		getDefaultValue: function() {
163
			return this.defaultValue;
164
			return this.defaultValue;
165
		},
166
		getDependsOn: function() {
167
			return this.dependsOn;
164
		}
168
		}
165
	};
169
	};
166
170
(-)a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/load-rules-async.js (-63 / +65 lines)
Lines 35-43 Link Here
35
'./rules/no-obj-calls',
35
'./rules/no-obj-calls',
36
'./rules/no-self-compare',
36
'./rules/no-self-compare',
37
'./rules/no-irregular-whitespace',
37
'./rules/no-irregular-whitespace',
38
'./rules/quotes',
38
], function(util, Logger, Finder, ProblemMessages, Estraverse, JsSyntax, 
39
], function(util, Logger, Finder, ProblemMessages, Estraverse, JsSyntax, 
39
		accessorPairs, noControlRegex, noDuplicateCase, noElseReturn, noEmptyCharClasses, 
40
		accessorPairs, noControlRegex, noDuplicateCase, noElseReturn, noEmptyCharClasses, 
40
		noEmptyLabel, noEqNull, noExtraBoolCast, noExtraParens, noInvalidRegExp, noNegatedInLhs, noObjCalls, noSelfCompare, noIrregularWhitespace) {
41
		noEmptyLabel, noEqNull, noExtraBoolCast, noExtraParens, noInvalidRegExp, noNegatedInLhs, noObjCalls, noSelfCompare, noIrregularWhitespace, quotes) {
41
42
42
    var rules = {
43
    var rules = {
43
        "curly": function(context) {
44
        "curly": function(context) {
Lines 1758-1764 Link Here
1758
						}
1759
						}
1759
					}
1760
					}
1760
				};
1761
				};
1761
			}
1762
			},
1763
		'quotes': quotes,
1762
	};
1764
	};
1763
1765
1764
	function _mapCallees(arr, obj) {
1766
	function _mapCallees(arr, obj) {
Lines 1772-1838 Link Here
1772
	'removeEventListener'], _callees);  //$NON-NLS-1$
1774
	'removeEventListener'], _callees);  //$NON-NLS-1$
1773
    
1775
    
1774
    function _collectLinesWithStringLiterals(node, lineMap){
1776
    function _collectLinesWithStringLiterals(node, lineMap){
1775
    	
1777
	    	
1776
    	// Create a map of line numbers to a list of literal nodes
1778
	    	// Create a map of line numbers to a list of literal nodes
1777
    	if (typeof node.value === 'string' && node.value.length > 0){
1779
	    	if (typeof node.value === 'string' && node.value.length > 0){
1778
    		if (node.value.toLowerCase() === 'use strict'){
1780
	    		if (node.value.toLowerCase() === 'use strict'){
1779
    			return;
1781
	    			return;
1780
    		}
1782
	    		}
1781
    		if(/^(?:[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]\+])$/.test(node.value)) {
1783
	    		if(/^(?:[\.,-\/#!$%\^&\*;:{}=\-_`~()@\+\?><\[\]\+])$/.test(node.value)) {
1782
    			return; //don't nag about punctuation
1784
	    			return; //don't nag about punctuation
1783
    		} else if(/^(?:==|!=|===|!==|=>)$/.test(node.value)) {
1785
	    		} else if(/^(?:==|!=|===|!==|=>)$/.test(node.value)) {
1784
    			return; //don't nag about operators
1786
	    			return; //don't nag about operators
1785
    		}
1787
	    		}
1786
    		if (node.parent){
1788
	    		if (node.parent){
1787
    			switch(node.parent.type) {
1789
	    			switch(node.parent.type) {
1788
    				case 'UnaryExpression':
1790
	    				case 'UnaryExpression':
1789
    				case 'MemberExpression':
1791
	    				case 'MemberExpression':
1790
    				case 'SwitchCase': {
1792
	    				case 'SwitchCase': {
1791
    					return;
1793
	    					return;
1792
    				}
1794
	    				}
1793
    				case 'BinaryExpression': {
1795
	    				case 'BinaryExpression': {
1794
    					if(node.parent.operator !== '+') {
1796
	    					if(node.parent.operator !== '+') {
1795
    						return;
1797
	    						return;
1796
    					}
1798
	    					}
1797
    					break;
1799
	    					break;
1798
    				}
1800
	    				}
1799
    				case 'Property': {
1801
	    				case 'Property': {
1800
    					if(node.parent.key === node) {
1802
	    					if(node.parent.key === node) {
1801
    						return;
1803
	    						return;
1802
    					}
1804
	    					}
1803
						var _p = node.parent.parent.parent;
1805
							var _p = node.parent.parent.parent;
1804
						if(_p && _p.type === 'CallExpression' && _p.callee && _p.callee.name === 'define') {
1806
							if(_p && _p.type === 'CallExpression' && _p.callee && _p.callee.name === 'define') {
1805
							return;
1807
								return;
1806
						}
1808
							}
1807
    					break;
1809
	    					break;
1808
    				}
1810
	    				}
1809
    				case 'NewExpression':
1811
	    				case 'NewExpression':
1810
    				case 'CallExpression': {
1812
	    				case 'CallExpression': {
1811
    					var callee = node.parent.callee;
1813
	    					var callee = node.parent.callee;
1812
    					if(callee) {
1814
	    					if(callee) {
1813
    						if(callee.type === 'MemberExpression' && callee.property && _callees[callee.property.name]) {
1815
	    						if(callee.type === 'MemberExpression' && callee.property && _callees[callee.property.name]) {
1814
    							return;
1816
	    							return;
1815
    						} else if(_callees[callee.name]) {
1817
	    						} else if(_callees[callee.name]) {
1816
    							return;
1818
	    							return;
1817
    						}
1819
	    						}
1818
    					}
1820
	    					}
1819
    					break;
1821
	    					break;
1820
    				}
1822
	    				}
1821
    				case 'ArrayExpression': {
1823
	    				case 'ArrayExpression': {
1822
    					_p = node.parent.parent;
1824
	    					_p = node.parent.parent;
1823
    					if(_p.type === 'CallExpression' && (_p.callee.name === 'define' || _p.callee.name === 'require' || _p.callee.name === 'requirejs')) {
1825
	    					if(_p.type === 'CallExpression' && (_p.callee.name === 'define' || _p.callee.name === 'require' || _p.callee.name === 'requirejs')) {
1824
    						return;
1826
	    						return;
1825
    					}
1827
	    					}
1826
    					break;
1828
	    					break;
1827
    				}
1829
	    				}
1828
    			}
1830
	    			}
1829
    		}
1831
	    		}
1830
    		var lineNum = node.loc.end.line;
1832
	    		var lineNum = node.loc.end.line;
1831
    		if (!lineMap[lineNum]){
1833
	    		if (!lineMap[lineNum]){
1832
    			lineMap[lineNum] = [];
1834
	    			lineMap[lineNum] = [];
1833
    		}
1835
	    		}
1834
    		lineMap[lineNum].push(node);
1836
	    		lineMap[lineNum].push(node);
1835
    	}
1837
	    	}
1836
    }
1838
    }
1837
1839
1838
	return {
1840
	return {
(-)a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/rules/quotes.js (+198 lines)
Added Link Here
1
/*eslint-env amd */
2
define([
3
 '../util',
4
 'module'
5
], function (utils, module) {/**
6
 * @fileoverview A rule to choose between single and double quote marks
7
 * @author Matt DuVall <http://www.mattduvall.com/>, Brandon Payton
8
 * @copyright 2013 Matt DuVall. All rights reserved.
9
 * See LICENSE file in root directory for full license.
10
 */
11
12
"use strict";
13
14
//------------------------------------------------------------------------------
15
// Constants
16
//------------------------------------------------------------------------------
17
18
var QUOTE_SETTINGS = {
19
    "double": {
20
        quote: "\"",
21
        alternateQuote: "'",
22
        description: "doublequote",
23
        convert: function(str) {
24
            return str.replace(/(?:\\*)?'([^'\\]*\\.)*[^']*'/g, function (match) {
25
				return match
26
					// unescape single-quotes
27
					.replace(/\\'/g, '\'')
28
					// escape escapes
29
					.replace(/(^|[^\\])(\\+)"/g, '$1$2\\\"')
30
					// escape double-quotes
31
					.replace(/([^\\])"/g, '$1\\\"')
32
					// convert
33
					.replace(/^'|'$/g, '"');
34
			});
35
        }
36
    },
37
    "single": {
38
        quote: "'",
39
        alternateQuote: "\"",
40
        description: "singlequote",
41
        convert: function(str) {
42
            return str.replace(/(?:\\*)?"([^"\\]*\\.)*[^"]*"/g, function (match) {
43
				return match
44
					// unescape double-quotes
45
					.replace(/\\"/g, '"')
46
					// escape escapes
47
					.replace(/(^|[^\\])(\\+)'/g, '$1$2\\\'')
48
					// escape single-quotes - round 1
49
					.replace(/([^\\])'/g, '$1\\\'')
50
					// escape single-quotes - round 2 (for consecutive single-quotes)
51
					.replace(/([^\\])'/g, '$1\\\'')
52
					// convert
53
					.replace(/^"|"$/g, '\'');
54
			});
55
        }
56
    },
57
    "backtick": {
58
        quote: "`",
59
        alternateQuote: "\"",
60
        description: "backtick",
61
        convert: function(str) {
62
            return str.replace(/`/g, "\`").replace(/^(?:\\*)["']|(?:\\*)["']$/g, "`");
63
        }
64
    }
65
};
66
67
var AVOID_ESCAPE = "avoid-escape",
68
    FUNCTION_TYPE = /^(?:Arrow)?Function(?:Declaration|Expression)$/;
69
70
//------------------------------------------------------------------------------
71
// Rule Definition
72
//------------------------------------------------------------------------------
73
74
module.exports = function(context) {
75
    /**
76
     * Determines if a given node is part of JSX syntax.
77
     * @param {ASTNode} node The node to check.
78
     * @returns {boolean} True if the node is a JSX node, false if not.
79
     * @private
80
     */
81
    function isJSXElement(node) {
82
        return node.type.indexOf("JSX") === 0;
83
    }
84
85
    /**
86
     * Checks whether or not a given node is a directive.
87
     * The directive is a `ExpressionStatement` which has only a string literal.
88
     * @param {ASTNode} node - A node to check.
89
     * @returns {boolean} Whether or not the node is a directive.
90
     * @private
91
     */
92
    function isDirective(node) {
93
        return node.type === "ExpressionStatement" &&
94
            node.expression.type === "Literal" &&
95
            typeof node.expression.value === "string";
96
    }
97
98
    /**
99
     * Checks whether or not a given node is a part of directive prologues.
100
     * See also: http://www.ecma-international.org/ecma-262/6.0/#sec-directive-prologues-and-the-use-strict-directive
101
     * @param {ASTNode} node - A node to check.
102
     * @returns {boolean} Whether or not the node is a part of directive prologues.
103
     * @private
104
     */
105
    function isPartOfDirectivePrologue(node) {
106
        var block = node.parent.parent;
107
        if (block.type !== "Program" && (block.type !== "BlockStatement" || !FUNCTION_TYPE.test(block.parent.type))) {
108
            return false;
109
        }
110
111
        // Check the node is at a prologue.
112
        for (var i = 0; i < block.body.length; ++i) {
113
            var statement = block.body[i];
114
115
            if (statement === node.parent) {
116
                return true;
117
            }
118
            if (!isDirective(statement)) {
119
                break;
120
            }
121
        }
122
123
        return false;
124
    }
125
126
    /**
127
     * Checks whether or not a given node is allowed as non backtick.
128
     * @param {ASTNode} node - A node to check.
129
     * @returns {boolean} Whether or not the node is allowed as non backtick.
130
     * @private
131
     */
132
    function isAllowedAsNonBacktick(node) {
133
        var parent = node.parent;
134
135
        switch (parent.type) {
136
            // Directive Prologues.
137
            case "ExpressionStatement":
138
                return isPartOfDirectivePrologue(node);
139
140
            // LiteralPropertyName.
141
            case "Property":
142
                return parent.key === node && !parent.computed;
143
144
            // ModuleSpecifier.
145
            case "ImportDeclaration":
146
            case "ExportNamedDeclaration":
147
            case "ExportAllDeclaration":
148
                return parent.source === node;
149
150
            // Others don't allow.
151
            default:
152
                return false;
153
        }
154
    }
155
156
    return {
157
158
        "Literal": function(node) {
159
            var val = node.value,
160
                rawVal = node.raw,
161
                quoteOption = context.options[0],
162
                settings = QUOTE_SETTINGS[quoteOption || "double"],
163
                avoidEscape = context.options[1] === AVOID_ESCAPE,
164
                isValid;
165
166
            if (settings && typeof val === "string") {
167
                isValid = (quoteOption === "backtick" && isAllowedAsNonBacktick(node)) || isJSXElement(node.parent) || utils.isSurroundedBy(rawVal, settings.quote);
168
169
                if (!isValid && avoidEscape) {
170
                    isValid = utils.isSurroundedBy(rawVal, settings.alternateQuote) && rawVal.indexOf(settings.quote) >= 0;
171
                }
172
173
                if (!isValid) {
174
                    context.report({
175
                        node: node,
176
                        message: "Strings must use " + settings.description + ".",
177
                        fix: function(fixer) {
178
                            return fixer.replaceText(node, settings.convert(node.raw));
179
                        }
180
                    });
181
                }
182
            }
183
        }
184
    };
185
186
};
187
188
module.exports.schema = [
189
    {
190
        "enum": ["single", "double", "backtick"]
191
    },
192
    {
193
        "enum": ["avoid-escape"]
194
    }
195
];
196
197
return module.exports;
198
});
(-)a/bundles/org.eclipse.orion.client.javascript/web/eslint/lib/util.js (+11 lines)
Lines 134-138 Link Here
134
    return false;
134
    return false;
135
};
135
};
136
136
137
/**
138
 * Validate that a string passed in is surrounded by the specified character
139
 * @param  {string} val The text to check.
140
 * @param  {string} character The character to see if it's surrounded by.
141
 * @returns {boolean} True if the text is surrounded by the character, false if not.
142
 * @private
143
 */
144
exports.isSurroundedBy = function(val, character) {
145
	return val[0] === character && val[val.length - 1] === character;
146
};
147
137
    return exports;
148
    return exports;
138
});
149
});
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/messages.js (-1 / +9 lines)
Lines 192-196 Link Here
192
	'no-irregular-whitespace' : 'Disallow irregular whitespace:',
192
	'no-irregular-whitespace' : 'Disallow irregular whitespace:',
193
	'no-self-assign' : 'Disallow self assignment:',
193
	'no-self-assign' : 'Disallow self assignment:',
194
	'noShadowFixName' : 'Rename in scope',
194
	'noShadowFixName' : 'Rename in scope',
195
	'type-checked-consistent-return' : 'Discouraged inconsistent returns:'
195
	'type-checked-consistent-return' : 'Discouraged inconsistent returns:',
196
	'quote-style' : 'Enforce quote style:',
197
	'quote-value' : 'Quoting options:',
198
	'quote-noescape' : 'Ignore strings that require escaping existing quotes',
199
	'double' : 'double',
200
	'single' : 'single',
201
	'backtick' : 'backtick',
202
	'_false' : 'false',
203
	'_true' : 'true'
196
});
204
});
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/nls/root/problems.js (+1 lines)
Lines 125-130 Link Here
125
	'no-self-assign' : 'Assigning to itself is pointless.',
125
	'no-self-assign' : 'Assigning to itself is pointless.',
126
	'type-checked-consistent-return-description' : 'Detect inconsistent return values',
126
	'type-checked-consistent-return-description' : 'Detect inconsistent return values',
127
	'inconsistent-return' : 'Inconsistent return types: \'{{type1}}\', \'{{type2}}\'',
127
	'inconsistent-return' : 'Inconsistent return types: \'{{type1}}\', \'{{type2}}\'',
128
	'quotes-description' : 'Ensure consistency for the quote style',
128
129
129
	//.tern-project file validation messages
130
	//.tern-project file validation messages
130
	'notNum': "'${0}' must be a number",
131
	'notNum': "'${0}' must be a number",
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/plugins/javascriptPlugin.js (-5 / +34 lines)
Lines 212-221 Link Here
212
								response.args.path = rel[0].path;
212
								response.args.path = rel[0].path;
213
								ternWorker.postMessage(response);
213
								ternWorker.postMessage(response);
214
							});
214
							});
215
						} else {
216
							response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l);
217
							ternWorker.postMessage(response);
218
						}
215
						}
216
						response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l);
217
						ternWorker.postMessage(response);
219
					} else {
218
					} else {
220
						response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l);
219
						response.args.error = i18nUtil.formatMessage(javascriptMessages['failedToReadFile'], _l);
221
						ternWorker.postMessage(response);
220
						ternWorker.postMessage(response);
Lines 1464-1471 Link Here
1464
				 	        	                	type: "number",  //$NON-NLS-1$
1463
				 	        	                	type: "number",  //$NON-NLS-1$
1465
				 	        	                	defaultValue: warning,
1464
				 	        	                	defaultValue: warning,
1466
				 	        	                	options: severities
1465
				 	        	                	options: severities
1467
				 	        	                }
1466
				 	        	                },
1468
]
1467
				 	        	                	{
1468
				 	        	                		id: "quotes",  //$NON-NLS-1$
1469
					 	        	                	name: javascriptMessages["quote-style"],
1470
					 	        	                	type: "number",  //$NON-NLS-1$
1471
					 	        	                	defaultValue: ignore,
1472
					 	        	                	options: severities
1473
				 	        	                	},
1474
				 	        	                	{
1475
				 	        	                		id: "quote-value",  //$NON-NLS-1$
1476
					 	        	                	name: javascriptMessages["quote-value"],
1477
					 	        	                	type: "string",  //$NON-NLS-1$
1478
					 	        	                	defaultValue: "single",
1479
					 	        	                	options: [
1480
					 	        	                		{label: javascriptMessages.double,  value: "double"},
1481
					 	        	                		{label: javascriptMessages.single,  value: "single"},
1482
					 	        	                		{label: javascriptMessages.backtick,  value: "backtick"}
1483
					 	        	                	],
1484
					 	        	                	dependsOn: "quotes"
1485
				 	        	                	},
1486
				 	        	                	{
1487
				 	        	                		id: "quote-noescape",  //$NON-NLS-1$
1488
					 	        	                	name: javascriptMessages["quote-noescape"],
1489
					 	        	                	type: "boolean",  //$NON-NLS-1$
1490
					 	        	                	defaultValue: false,
1491
					 	        	                	options: [
1492
					 	        	                		{label: javascriptMessages._false,  value: false},
1493
					 	        	                		{label: javascriptMessages._true,  value: true}
1494
					 	        	                	],
1495
					 	        	                	dependsOn: "quotes"
1496
				 	        	                	},
1497
			 	        	                	]
1469
				 	        	}]
1498
				 	        	}]
1470
    			});
1499
    			});
1471
1500
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/ruleData.js (-46 / +51 lines)
Lines 71-76 Link Here
71
			"no-unused-vars" : 1,
71
			"no-unused-vars" : 1,
72
			"no-use-before-define" : 1,
72
			"no-use-before-define" : 1,
73
			"no-with" : 1,
73
			"no-with" : 1,
74
			"quotes": [1, "double", "avoid-escape"],
74
			"radix" : 1,
75
			"radix" : 1,
75
			"semi" : 1,
76
			"semi" : 1,
76
			"type-checked-consistent-return" : 0,
77
			"type-checked-consistent-return" : 0,
Lines 86-128 Link Here
86
			},
87
			},
87
			"curly" : {
88
			"curly" : {
88
				description: Messages['curly-description'],
89
				description: Messages['curly-description'],
89
	            url: 'http://eslint.org/docs/rules/curly'
90
				url: 'http://eslint.org/docs/rules/curly'
90
			},
91
			},
91
			"eqeqeq": {
92
			"eqeqeq": {
92
				description: Messages['eqeqeq-description'],
93
				description: Messages['eqeqeq-description'],
93
			    url: "http://eslint.org/docs/rules/eqeqeq"
94
				url: "http://eslint.org/docs/rules/eqeqeq"
94
			},
95
			},
95
	
96
	
96
			"missing-doc" : {
97
			"missing-doc" : {
97
				description: Messages['missing-doc-description'],
98
				description: Messages['missing-doc-description'],
98
			    url: 'http://eslint.org/docs/rules/valid-jsdoc'
99
				url: 'http://eslint.org/docs/rules/valid-jsdoc'
99
			},
100
			},
100
			"missing-nls" : {
101
			"missing-nls" : {
101
				description: Messages['missing-nls-description']
102
				description: Messages['missing-nls-description']
102
			},
103
			},
103
			"new-parens" : {
104
			"new-parens" : {
104
				description: Messages['new-parens-description'],
105
				description: Messages['new-parens-description'],
105
			    url: 'http://eslint.org/docs/rules/new-parens'
106
				url: 'http://eslint.org/docs/rules/new-parens'
106
			},
107
			},
107
			"no-caller": {
108
			"no-caller": {
108
				description: Messages['no-caller-description'],
109
				description: Messages['no-caller-description'],
109
	            url: 'http://eslint.org/docs/rules/no-caller'
110
				url: 'http://eslint.org/docs/rules/no-caller'
110
	        },
111
			},
111
			"no-comma-dangle" : {
112
			"no-comma-dangle" : {
112
				description: Messages['no-comma-dangle-description'],
113
				description: Messages['no-comma-dangle-description'],
113
	            url: 'http://eslint.org/docs/rules/no-comma-dangle'
114
				url: 'http://eslint.org/docs/rules/no-comma-dangle'
114
	        },
115
			},
115
			"no-cond-assign" : {
116
			"no-cond-assign" : {
116
				description: Messages['no-cond-assign-description'],
117
				description: Messages['no-cond-assign-description'],
117
	            url: 'http://eslint.org/docs/rules/no-cond-assign'
118
				url: 'http://eslint.org/docs/rules/no-cond-assign'
118
	        },
119
			},
119
			"no-console" : {
120
			"no-console" : {
120
				description: Messages['no-console-description'],
121
				description: Messages['no-console-description'],
121
	            url: 'http://eslint.org/docs/rules/no-console'
122
				url: 'http://eslint.org/docs/rules/no-console'
122
			}, 
123
			},
123
			"no-constant-condition" : {
124
			"no-constant-condition" : {
124
				description: Messages['no-constant-condition-description'],
125
				description: Messages['no-constant-condition-description'],
125
	            url: 'http://eslint.org/docs/rules/no-constant-condition'
126
				url: 'http://eslint.org/docs/rules/no-constant-condition'
126
			},
127
			},
127
			"no-control-regex" : {
128
			"no-control-regex" : {
128
				description: Messages['no-control-regex-description'],
129
				description: Messages['no-control-regex-description'],
Lines 130-140 Link Here
130
			},
131
			},
131
			"no-debugger" : {
132
			"no-debugger" : {
132
				description: Messages['no-debugger-description'],
133
				description: Messages['no-debugger-description'],
133
		    	url: 'http://eslint.org/docs/rules/no-debugger'
134
				url: 'http://eslint.org/docs/rules/no-debugger'
134
			},
135
			},
135
			"no-dupe-keys" : {
136
			"no-dupe-keys" : {
136
				description: Messages['no-dupe-keys-description'],
137
				description: Messages['no-dupe-keys-description'],
137
			    url: 'http://eslint.org/docs/rules/no-dupe-keys'
138
				url: 'http://eslint.org/docs/rules/no-dupe-keys'
138
			},
139
			},
139
			"no-duplicate-case": {
140
			"no-duplicate-case": {
140
				description: Messages['no-duplicate-case-description'],
141
				description: Messages['no-duplicate-case-description'],
Lines 146-152 Link Here
146
			},
147
			},
147
			"no-empty-block" : {
148
			"no-empty-block" : {
148
				description: Messages['no-empty-block-description'],
149
				description: Messages['no-empty-block-description'],
149
			    url: 'http://eslint.org/docs/rules/no-empty'
150
				url: 'http://eslint.org/docs/rules/no-empty'
150
			},
151
			},
151
			"no-empty-character-class" : {
152
			"no-empty-character-class" : {
152
				description: Messages['no-empty-character-class-description'],
153
				description: Messages['no-empty-character-class-description'],
Lines 162-168 Link Here
162
			},
163
			},
163
			"no-eval" : {
164
			"no-eval" : {
164
				description: Messages['no-eval-description'],
165
				description: Messages['no-eval-description'],
165
		    	url: 'http://eslint.org/docs/rules/no-eval'
166
				url: 'http://eslint.org/docs/rules/no-eval'
166
			},
167
			},
167
			"no-extra-boolean-cast" : {
168
			"no-extra-boolean-cast" : {
168
				description: Messages['no-extra-boolean-cast-description'],
169
				description: Messages['no-extra-boolean-cast-description'],
Lines 174-188 Link Here
174
			},
175
			},
175
			"no-extra-semi": {
176
			"no-extra-semi": {
176
				description: Messages['no-extra-semi-description'],
177
				description: Messages['no-extra-semi-description'],
177
		    	url: 'http://eslint.org/docs/rules/no-extra-semi'
178
				url: 'http://eslint.org/docs/rules/no-extra-semi'
178
			},
179
			},
179
			"no-fallthrough" : {
180
			"no-fallthrough" : {
180
				description: Messages['no-fallthrough-description'],
181
				description: Messages['no-fallthrough-description'],
181
			    url: 'http://eslint.org/docs/rules/no-fallthrough'
182
				url: 'http://eslint.org/docs/rules/no-fallthrough'
182
			}, 
183
			},
183
			"no-implied-eval" : {
184
			"no-implied-eval" : {
184
				description: Messages['no-implied-eval-description'],
185
				description: Messages['no-implied-eval-description'],
185
        		url: 'http://eslint.org/docs/rules/no-implied-eval'
186
				url: 'http://eslint.org/docs/rules/no-implied-eval'
186
			},
187
			},
187
			"no-invalid-regexp": {
188
			"no-invalid-regexp": {
188
				description: Messages['no-invalid-regexp-description'],
189
				description: Messages['no-invalid-regexp-description'],
Lines 194-204 Link Here
194
			},
195
			},
195
			"no-iterator": {
196
			"no-iterator": {
196
				description: Messages['no-iterator-description'],
197
				description: Messages['no-iterator-description'],
197
            	url: 'http://eslint.org/docs/rules/no-iterator'
198
				url: 'http://eslint.org/docs/rules/no-iterator'
198
			}, 
199
			},
199
			"no-jslint" : {
200
			"no-jslint" : {
200
				description: Messages['no-jslint-description']
201
				description: Messages['no-jslint-description']
201
			}, 
202
			},
202
			"no-mixed-spaces-and-tabs" : {
203
			"no-mixed-spaces-and-tabs" : {
203
				description: Messages['no-mixed-spaces-and-tabs-description'],
204
				description: Messages['no-mixed-spaces-and-tabs-description'],
204
				url: 'http://eslint.org/docs/rules/no-mixed-spaces-and-tabs'
205
				url: 'http://eslint.org/docs/rules/no-mixed-spaces-and-tabs'
Lines 213-227 Link Here
213
			},
214
			},
214
			"no-new-func" : {
215
			"no-new-func" : {
215
				description: Messages['no-new-func-description'],
216
				description: Messages['no-new-func-description'],
216
			    url: 'http://eslint.org/docs/rules/no-new-func'
217
				url: 'http://eslint.org/docs/rules/no-new-func'
217
			},
218
			},
218
			"no-new-object" : {
219
			"no-new-object" : {
219
				description: Messages['no-new-object-description'],
220
				description: Messages['no-new-object-description'],
220
			    url: 'http://eslint.org/docs/rules/no-new-object'
221
				url: 'http://eslint.org/docs/rules/no-new-object'
221
			},
222
			},
222
			"no-new-wrappers" : {
223
			"no-new-wrappers" : {
223
				description: Messages['no-new-wrappers-description'],
224
				description: Messages['no-new-wrappers-description'],
224
			    url: 'http://eslint.org/docs/rules/no-new-wrappers'
225
				url: 'http://eslint.org/docs/rules/no-new-wrappers'
225
			},
226
			},
226
			"no-obj-calls" : {
227
			"no-obj-calls" : {
227
				description: Messages['no-obj-calls-description'],
228
				description: Messages['no-obj-calls-description'],
Lines 229-247 Link Here
229
			},
230
			},
230
			"no-proto" : {
231
			"no-proto" : {
231
				description: Messages['no-proto-description'],
232
				description: Messages['no-proto-description'],
232
	            url: 'http://eslint.org/docs/rules/no-proto.html'
233
				url: 'http://eslint.org/docs/rules/no-proto.html'
233
			}, 
234
			}, 
234
			"no-redeclare" : {
235
			"no-redeclare" : {
235
				description: Messages['no-redeclare-description'],
236
				description: Messages['no-redeclare-description'],
236
			    url: 'http://eslint.org/docs/rules/no-redeclare'
237
				url: 'http://eslint.org/docs/rules/no-redeclare'
237
			},
238
			},
238
			"no-regex-spaces" : {
239
			"no-regex-spaces" : {
239
				description: Messages['no-regex-spaces-description'],
240
				description: Messages['no-regex-spaces-description'],
240
	            url: 'http://eslint.org/docs/rules/no-regex-spaces'
241
				url: 'http://eslint.org/docs/rules/no-regex-spaces'
241
			},
242
			},
242
			"no-reserved-keys" : {
243
			"no-reserved-keys" : {
243
				description: Messages['no-reserved-keys-description'],
244
				description: Messages['no-reserved-keys-description'],
244
	            url: 'http://eslint.org/docs/rules/no-reserved-keys'
245
				url: 'http://eslint.org/docs/rules/no-reserved-keys'
245
			},
246
			},
246
			"no-self-compare" : {
247
			"no-self-compare" : {
247
				description: Messages['no-self-compare-description'],
248
				description: Messages['no-self-compare-description'],
Lines 253-319 Link Here
253
			},
254
			},
254
			"no-shadow" : {
255
			"no-shadow" : {
255
				description: Messages['no-shadow-description'],
256
				description: Messages['no-shadow-description'],
256
	            url: 'http://eslint.org/docs/rules/no-shadow'
257
				url: 'http://eslint.org/docs/rules/no-shadow'
257
			},
258
			},
258
			"no-shadow-global" : {
259
			"no-shadow-global" : {
259
				description: Messages['no-shadow-global-description']
260
				description: Messages['no-shadow-global-description']
260
			},
261
			},
261
			"no-sparse-arrays" : {
262
			"no-sparse-arrays" : {
262
				description: Messages['no-sparse-arrays-description'],
263
				description: Messages['no-sparse-arrays-description'],
263
			    url: 'http://eslint.org/docs/rules/no-sparse-arrays'
264
				url: 'http://eslint.org/docs/rules/no-sparse-arrays'
264
			}, 
265
			},
265
			"no-throw-literal" : {
266
			"no-throw-literal" : {
266
				description: Messages['no-throw-literal-description'],
267
				description: Messages['no-throw-literal-description'],
267
	            url: 'http://eslint.org/docs/rules/no-throw-literal'
268
				url: 'http://eslint.org/docs/rules/no-throw-literal'
268
			},
269
			},
269
			"no-undef" : {
270
			"no-undef" : {
270
				description: Messages['no-undef-description'],
271
				description: Messages['no-undef-description'],
271
			    url: 'http://eslint.org/docs/rules/no-undef'
272
				url: 'http://eslint.org/docs/rules/no-undef'
272
			},
273
			},
273
			"no-undef-init" : {
274
			"no-undef-init" : {
274
				description: Messages['no-undef-init-description'],
275
				description: Messages['no-undef-init-description'],
275
	        	url: 'http://eslint.org/docs/rules/no-undef-init.html'
276
				url: 'http://eslint.org/docs/rules/no-undef-init.html'
276
			},
277
			},
277
			"no-unreachable" : {
278
			"no-unreachable" : {
278
				description: Messages['no-unreachable-description'],
279
				description: Messages['no-unreachable-description'],
279
			    url: 'http://eslint.org/docs/rules/no-unreachable'
280
				url: 'http://eslint.org/docs/rules/no-unreachable'
280
			}, 
281
			},
281
			"no-unused-params" : {
282
			"no-unused-params" : {
282
				description: Messages['no-unused-params-description']
283
				description: Messages['no-unused-params-description']
283
			},
284
			},
284
			"no-unused-vars" : {
285
			"no-unused-vars" : {
285
				description: Messages['no-unused-vars-description'],
286
				description: Messages['no-unused-vars-description'],
286
			    url: 'http://eslint.org/docs/rules/no-unused-vars'
287
				url: 'http://eslint.org/docs/rules/no-unused-vars'
287
			},
288
			},
288
			"no-use-before-define" : {
289
			"no-use-before-define" : {
289
				description: Messages['no-use-before-define-description'],
290
				description: Messages['no-use-before-define-description'],
290
			    url: 'http://eslint.org/docs/rules/no-use-before-define'
291
				url: 'http://eslint.org/docs/rules/no-use-before-define'
291
			},
292
			},
292
			"no-with" : {
293
			"no-with" : {
293
				description: Messages['no-with-description'],
294
				description: Messages['no-with-description'],
294
	        	url: 'http://eslint.org/docs/rules/no-with'
295
				url: 'http://eslint.org/docs/rules/no-with'
295
			},
296
			},
296
			"radix" : {
297
			"radix" : {
297
				description: Messages['radix-description'],
298
				description: Messages['radix-description'],
298
	            url: 'http://eslint.org/docs/rules/radix'
299
				url: 'http://eslint.org/docs/rules/radix'
299
			},
300
			},
300
			"semi" : {
301
			"semi" : {
301
				description: Messages['semi-description'],
302
				description: Messages['semi-description'],
302
			    url: 'http://eslint.org/docs/rules/semi'
303
				url: 'http://eslint.org/docs/rules/semi'
303
			},
304
			},
304
			"unnecessary-nls" : {
305
			"unnecessary-nls" : {
305
				description: Messages['unnecessary-nls-description']
306
				description: Messages['unnecessary-nls-description']
306
			},
307
			},
307
			"use-isnan" : {
308
			"use-isnan" : {
308
				description: Messages['use-isnan-description'],
309
				description: Messages['use-isnan-description'],
309
			    url: 'http://eslint.org/docs/rules/use-isnan'
310
				url: 'http://eslint.org/docs/rules/use-isnan'
310
			},
311
			},
311
			"valid-typeof" : {
312
			"valid-typeof" : {
312
				description: Messages['valid-typeof-description'],
313
				description: Messages['valid-typeof-description'],
313
			    url: 'http://eslint.org/docs/rules/valid-typeof'
314
				url: 'http://eslint.org/docs/rules/valid-typeof'
314
			},
315
			},
315
			"type-checked-consistent-return" : {
316
			"type-checked-consistent-return" : {
316
				description: Messages['type-checked-consistent-return-description']
317
				description: Messages['type-checked-consistent-return-description']
318
			},
319
			"quotes" : {
320
				description: Messages['quotes-description'],
321
				url: 'http://eslint.org/docs/rules/quotes'
317
			}
322
			}
318
		}
323
		}
319
	};
324
	};
(-)a/bundles/org.eclipse.orion.client.javascript/web/javascript/validator.js (-18 / +70 lines)
Lines 43-49 Link Here
43
				else {
43
				else {
44
					this.rules[ruleId] = value;
44
					this.rules[ruleId] = value;
45
				}
45
				}
46
			} else if (Array.isArray(value)) {
47
				this.rules[ruleId] = value;
46
			}
48
			}
49
		},
50
		
51
		getOption: function(ruleId, key) {
52
			if(Array.isArray(this.rules[ruleId])) {
53
				var ruleConfig = this.rules[ruleId];
54
				if (key) {
55
					if (ruleConfig[1]) {
56
						return ruleConfig[1][key] || null;
57
					}
58
					return null;
59
				}
60
				return ruleConfig[0] || null;
61
			}
62
			return this.rules[ruleId];
47
		},
63
		},
48
		
64
		
49
		setDefaults: function setDefaults() {
65
		setDefaults: function setDefaults() {
Lines 261-286 Link Here
261
			if (!properties) {
277
			if (!properties) {
262
				return;
278
				return;
263
			}
279
			}
264
			var oldconfig = properties.pid === 'eslint.config';
265
			var keys = Object.keys(properties);
266
			var seen = Object.create(null);
280
			var seen = Object.create(null);
267
			for(var i = 0; i < keys.length; i++) {
281
			var keys = Object.keys(properties);
268
			    var key = keys[i];
282
			var key, ruleId, legacy, index, len;
269
			    var ruleId = key;
283
			if (properties.pid === 'eslint.config.codestyle') {
270
			    if(oldconfig && config.rules[key] !== config.defaults[key]) {
284
				// handle dependent options for quotes
271
			        //don't overwrite a new setting with an old one
285
				for(index = 0, len = keys.length; index < len; index++) {
272
		            continue;
286
					key = keys[index];
273
			    }
287
					ruleId = key;
274
			    var legacy = this._legacy[ruleId];
288
					if (key === 'quotes') {
275
			    if(typeof legacy === 'string') {
289
						// create the options array for quotes settings
276
			        ruleId = legacy;
290
						if (properties[key] !== 0) {
277
			        if(seen[ruleId]) {
291
							var options = [properties[key]];
278
			            //don't overwrite a new pref name with a legacy one
292
							options.push(properties['quote-value']);
293
							if (properties['quote-noescape']) {
294
								options.push("noescape");
295
							}
296
							config.setOption(ruleId, options);
297
						} else {
298
							config.setOption(ruleId, 0);
299
						}
300
					} else if (key === 'quote-value' || key === 'quote-noescape') {
301
						// these keys are handled by 'quotes' as dependents
302
						continue;
303
					} else {
304
						legacy = this._legacy[ruleId];
305
						if(typeof legacy === 'string') {
306
							ruleId = legacy;
307
							if(seen[ruleId]) {
308
								//don't overwrite a new pref name with a legacy one
309
								continue;
310
							}
311
						}
312
						seen[ruleId] = true;
313
						config.setOption(ruleId, properties[key]);
314
					}
315
				}
316
			} else {
317
				var oldconfig = properties.pid === 'eslint.config';
318
				for(index = 0, len = keys.length; index < len; index++) {
319
				    key = keys[index];
320
				    ruleId = key;
321
				    if(oldconfig && config.rules[key] !== config.defaults[key]) {
322
				        //don't overwrite a new setting with an old one
279
			            continue;
323
			            continue;
280
			        }
324
				    }
281
			    }
325
				    legacy = this._legacy[ruleId];
282
			    seen[ruleId] = true;
326
				    if(typeof legacy === 'string') {
283
			    config.setOption(ruleId, properties[key]);
327
				        ruleId = legacy;
328
				        if(seen[ruleId]) {
329
				            //don't overwrite a new pref name with a legacy one
330
				            continue;
331
				        }
332
				    }
333
				    seen[ruleId] = true;
334
				    config.setOption(ruleId, properties[key]);
335
				}
284
			}
336
			}
285
		},
337
		},
286
		
338
		
(-)a/bundles/org.eclipse.orion.client.ui/web/orion/settings/settingsRegistry.js (-58 / +60 lines)
Lines 17-23 Link Here
17
	var SETTINGS_PROP = 'settings'; //$NON-NLS-0$
17
	var SETTINGS_PROP = 'settings'; //$NON-NLS-0$
18
	var DEFAULT_CATEGORY = 'unsorted'; //$NON-NLS-0$
18
	var DEFAULT_CATEGORY = 'unsorted'; //$NON-NLS-0$
19
19
20
	var hasOwnProperty = Object.prototype.hasOwnProperty;
20
	var _hasOwnProperty = Object.prototype.hasOwnProperty;
21
21
22
	/**
22
	/**
23
	 * @param {String} type
23
	 * @param {String} type
Lines 27-34 Link Here
27
	function equals(type, value, defaultValue) {
27
	function equals(type, value, defaultValue) {
28
		if (type === 'string') //$NON-NLS-0$
28
		if (type === 'string') //$NON-NLS-0$
29
			return value === defaultValue || (value === '' && defaultValue === null);
29
			return value === defaultValue || (value === '' && defaultValue === null);
30
		else
30
		return value === defaultValue;
31
			return value === defaultValue;
32
	}
31
	}
33
32
34
	function getStringOrNull(obj, property) {
33
	function getStringOrNull(obj, property) {
Lines 40-94 Link Here
40
	 * @class Represents the definition of a setting.
39
	 * @class Represents the definition of a setting.
41
	 * @description Represents the definition of a setting.
40
	 * @description Represents the definition of a setting.
42
	 */
41
	 */
43
		/**
42
	/**
44
		 * @name orion.settings.Setting#isDefaults
43
	 * @name orion.settings.Setting#isDefaults
45
		 * @function
44
	 * @function
46
		 * @param {Object} properties A map of AttributeDefinition IDs to values.
45
	 * @param {Object} properties A map of AttributeDefinition IDs to values.
47
		 * @param {Object} [defaultProperties] If provided, gives a map of effective default values to compare properties
46
	 * @param {Object} [defaultProperties] If provided, gives a map of effective default values to compare properties
48
		 * against. If not provided, the default values defined in the <tt>AttributeDefinition</tt>s are used.
47
	 * against. If not provided, the default values defined in the <tt>AttributeDefinition</tt>s are used.
49
		 * @description Returns whether a given properties map is equivalent to the default value of this setting.
48
	 * @description Returns whether a given properties map is equivalent to the default value of this setting.
50
		 * Default values are drawn either from <tt>defaultProperties</tt> if provided, otherwise from the <tt>AttributeDefinition</tt>.
49
	 * Default values are drawn either from <tt>defaultProperties</tt> if provided, otherwise from the <tt>AttributeDefinition</tt>.
51
		 * </ul>
50
	 * </ul>
52
		 * @returns {Boolean} <code>true</code> if the given <code>properties</code> map equals the defaults.
51
	 * @returns {Boolean} <code>true</code> if the given <code>properties</code> map equals the defaults.
53
		 */
52
	 */
54
		/**
53
	/**
55
		 * @name orion.settings.Setting#getCategory
54
	 * @name orion.settings.Setting#getCategory
56
		 * @function
55
	 * @function
57
		 * @description Returns the category.
56
	 * @description Returns the category.
58
		 * @returns {String} The category. May be <code>null</code>.
57
	 * @returns {String} The category. May be <code>null</code>.
59
		 */
58
	 */
60
		/**
59
	/**
61
		 * @name orion.settings.Setting#getCategoryLabel
60
	 * @name orion.settings.Setting#getCategoryLabel
62
		 * @function
61
	 * @function
63
		 * @description Returns the category label.
62
	 * @description Returns the category label.
64
		 * @returns {String} The category label. May be <code>null</code>.
63
	 * @returns {String} The category label. May be <code>null</code>.
65
		 */
64
	 */
66
		/**
65
	/**
67
		 * @name orion.settings.Setting#getPid
66
	 * @name orion.settings.Setting#getPid
68
		 * @function
67
	 * @function
69
		 * @returns {String}
68
	 * @returns {String}
70
		 */
69
	 */
71
		/**
70
	/**
72
		 * @name orion.settings.Setting#getObjectClassDefinitionId
71
	 * @name orion.settings.Setting#getObjectClassDefinitionId
73
		 * @function
72
	 * @function
74
		 * @returns {String}
73
	 * @returns {String}
75
		 */
74
	 */
76
		/**
75
	/**
77
		 * @name orion.settings.Setting#getName
76
	 * @name orion.settings.Setting#getName
78
		 * @function
77
	 * @function
79
		 * @description Returns the name.
78
	 * @description Returns the name.
80
		 * @returns {String} The name. May be <code>null</code>.
79
	 * @returns {String} The name. May be <code>null</code>.
81
		 */
80
	 */
82
		/**
81
	/**
83
		 * @name orion.settings.Setting#getAttributeDefinitions
82
	 * @name orion.settings.Setting#getAttributeDefinitions
84
		 * @function
83
	 * @function
85
		 * @returns {orion.metatype.AttributeDefinition[]}
84
	 * @returns {orion.metatype.AttributeDefinition[]}
86
		 */
85
	 */
87
		/**
86
	/**
88
		 * @name orion.settings.Setting#getTags
87
	 * @name orion.settings.Setting#getTags
89
		 * @function
88
	 * @function
90
		 * @returns {String[]}
89
	 * @returns {String[]}
91
		 */
90
	 */
92
	function SettingImpl(json) {
91
	function SettingImpl(json) {
93
		this.pid = json.pid;
92
		this.pid = json.pid;
94
		this.isRef = getStringOrNull(json, 'classId'); //$NON-NLS-0$
93
		this.isRef = getStringOrNull(json, 'classId'); //$NON-NLS-0$
Lines 98-104 Link Here
98
		this.category = json.category || null;
97
		this.category = json.category || null;
99
		this.categoryLabel = json.categoryLabel || null;
98
		this.categoryLabel = json.categoryLabel || null;
100
		this.tags = json.tags;
99
		this.tags = json.tags;
101
		this.order = typeof(json.order) === 'number' && json.order > -1 ? json.order : 0;
100
		this.order = typeof json.order === 'number' && json.order > -1 ? json.order : 0;
102
		if (!this.pid) { throw new Error('Missing "pid" property'); } //$NON-NLS-0$
101
		if (!this.pid) { throw new Error('Missing "pid" property'); } //$NON-NLS-0$
103
	}
102
	}
104
	SettingImpl.prototype = {
103
	SettingImpl.prototype = {
Lines 124-130 Link Here
124
			return this.tags || [];
123
			return this.tags || [];
125
		},
124
		},
126
		/**
125
		/**
127
		 * Allow settings to declare thier relative ordering on the generated page
126
		 * Allow settings to declare their relative ordering on the generated page
128
		 * @since 9.0
127
		 * @since 9.0
129
		 */
128
		 */
130
		getOrder: function getOrder() {
129
		getOrder: function getOrder() {
Lines 134-143 Link Here
134
			defaultProperties = defaultProperties || {};
133
			defaultProperties = defaultProperties || {};
135
			return this.getAttributeDefinitions().every(function(attributeDefinition) {
134
			return this.getAttributeDefinitions().every(function(attributeDefinition) {
136
				var attributeId = attributeDefinition.getId();
135
				var attributeId = attributeDefinition.getId();
137
				if (!(hasOwnProperty.call(properties, attributeId)))
136
				if (!_hasOwnProperty.call(properties, attributeId))
138
					return true; // Attribute not set, so consider as equal to default
137
					return true; // Attribute not set, so consider as equal to default
139
				var value = properties[attributeId], defaultValue;
138
				var value = properties[attributeId], defaultValue;
140
				if (hasOwnProperty.call(defaultProperties, attributeId))
139
				if (_hasOwnProperty.call(defaultProperties, attributeId))
141
					defaultValue = defaultProperties[attributeId];
140
					defaultValue = defaultProperties[attributeId];
142
				else
141
				else
143
					defaultValue = attributeDefinition.getDefaultValue();
142
					defaultValue = attributeDefinition.getDefaultValue();
Lines 174-180 Link Here
174
			setting.properties = ocd.getAttributeDefinitions();
173
			setting.properties = ocd.getAttributeDefinitions();
175
			settingsMap[setting.getPid()] = setting;
174
			settingsMap[setting.getPid()] = setting;
176
			var category = setting.getCategory() || DEFAULT_CATEGORY;
175
			var category = setting.getCategory() || DEFAULT_CATEGORY;
177
			if (!hasOwnProperty.call(categoriesMap, category)) {
176
			if (!_hasOwnProperty.call(categoriesMap, category)) {
178
				categoriesMap[category] = [];
177
				categoriesMap[category] = [];
179
			}
178
			}
180
			categoriesMap[category].push(setting.getPid());
179
			categoriesMap[category].push(setting.getPid());
Lines 203-208 Link Here
203
			}
202
			}
204
			return ServiceTracker.prototype.addingService.call(this, serviceRef);
203
			return ServiceTracker.prototype.addingService.call(this, serviceRef);
205
		};
204
		};
205
		/**
206
		 * @callback
207
		 */
206
		this.removedService = function(serviceRef, service) {
208
		this.removedService = function(serviceRef, service) {
207
			var settings = serviceRef.getProperty(SETTINGS_PROP);
209
			var settings = serviceRef.getProperty(SETTINGS_PROP);
208
			for (var i=0; i < settings.length; i++) {
210
			for (var i=0; i < settings.length; i++) {
Lines 232-238 Link Here
232
		 */
234
		 */
233
		getSettings: function(category) {
235
		getSettings: function(category) {
234
			var settingsMap = this.settingsMap;
236
			var settingsMap = this.settingsMap;
235
			var pids = (typeof category === 'string') ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$
237
			var pids = typeof category === 'string' ? this.categories[category] : Object.keys(settingsMap); //$NON-NLS-0$
236
			if (!pids) {
238
			if (!pids) {
237
				return [];
239
				return [];
238
			}
240
			}
(-)a/bundles/org.eclipse.orion.client.ui/web/orion/settings/ui/PluginSettings.js (-27 / +39 lines)
Lines 20-36 Link Here
20
	'orion/widgets/input/SettingsSelect',
20
	'orion/widgets/input/SettingsSelect',
21
	'i18n!orion/settings/nls/messages',
21
	'i18n!orion/settings/nls/messages',
22
	'orion/i18nUtil',
22
	'orion/i18nUtil',
23
	'orion/metrics',
24
	'orion/commands'
23
	'orion/commands'
25
], function(mExplorer, mSection, Deferred, objects, mConfirmDialog, SettingsCheckbox, SettingsTextfield, 
24
], function(mExplorer, mSection, Deferred, objects, mConfirmDialog, SettingsCheckbox, SettingsTextfield, 
26
		SettingsSelect, messages, i18nUtil, mMetrics, Commands) {
25
		SettingsSelect, messages, i18nUtil, Commands) {
27
	var Explorer = mExplorer.Explorer,
26
	var Explorer = mExplorer.Explorer,
28
	    SelectionRenderer = mExplorer.SelectionRenderer,
27
	    SelectionRenderer = mExplorer.SelectionRenderer,
29
	    Section = mSection.Section,
28
	    Section = mSection.Section,
30
	    Command = Commands.Command,
29
	    Command = Commands.Command,
31
	    ConfirmDialog = mConfirmDialog.ConfirmDialog;
30
	    ConfirmDialog = mConfirmDialog.ConfirmDialog;
32
33
	var METRICS_MAXLENGTH = 256;
34
31
35
	/**
32
	/**
36
	 * @name orion.settings.ui.PropertyWidget
33
	 * @name orion.settings.ui.PropertyWidget
Lines 73-78 Link Here
73
70
74
	/**
71
	/**
75
	 * Widget displaying a string-typed plugin setting. Mixes in SettingsTextfield and PropertyWidget.
72
	 * Widget displaying a string-typed plugin setting. Mixes in SettingsTextfield and PropertyWidget.
73
	 * @callback
76
	 */
74
	 */
77
	var PropertyTextField = function(options) {
75
	var PropertyTextField = function(options) {
78
		PropertyWidget.apply(this, arguments);
76
		PropertyWidget.apply(this, arguments);
Lines 89-95 Link Here
89
				this.textfield.type = 'text'; //$NON-NLS-0$
87
				this.textfield.type = 'text'; //$NON-NLS-0$
90
			}
88
			}
91
		},
89
		},
92
		change: function(event) {
90
		/**
91
		 * @callback
92
		 */
93
		change: function(_event) {
93
			this.changeProperty(this.textfield.value);
94
			this.changeProperty(this.textfield.value);
94
		},
95
		},
95
		updateField: function(value) {
96
		updateField: function(value) {
Lines 99-112 Link Here
99
100
100
	/**
101
	/**
101
	 * Widget displaying a boolean-typed plugin setting. Mixes in SettingsCheckbox and PropertyWidget.
102
	 * Widget displaying a boolean-typed plugin setting. Mixes in SettingsCheckbox and PropertyWidget.
103
	 * @callback
102
	 */
104
	 */
103
	var PropertyCheckbox = function(options) {
105
	var PropertyCheckbox = function(options) {
104
		PropertyWidget.apply(this, arguments);
106
		PropertyWidget.apply(this, arguments);
105
		SettingsCheckbox.apply(this, arguments);
107
		SettingsCheckbox.apply(this, arguments);
106
	};
108
	};
107
	objects.mixin(PropertyCheckbox.prototype, SettingsCheckbox.prototype, PropertyWidget.prototype, {
109
	objects.mixin(PropertyCheckbox.prototype, SettingsCheckbox.prototype, PropertyWidget.prototype, {
108
		change: function(event) {
110
		change: function(_event) {
109
			this.changeProperty(event.target.checked); //$NON-NLS-0$
111
			this.changeProperty(_event.target.checked); //$NON-NLS-0$
110
		},
112
		},
111
		postCreate: function() {
113
		postCreate: function() {
112
			PropertyWidget.prototype.postCreate.call(this);
114
			PropertyWidget.prototype.postCreate.call(this);
Lines 119-124 Link Here
119
121
120
	/**
122
	/**
121
	 * Widget displaying a plugin setting whose value is restricted to an enumerated set (options). Mixes in SettingsSelect and PropertyWidget.
123
	 * Widget displaying a plugin setting whose value is restricted to an enumerated set (options). Mixes in SettingsSelect and PropertyWidget.
124
	 * @callback
122
	 */
125
	 */
123
	var PropertySelect = function(options) {
126
	var PropertySelect = function(options) {
124
		PropertyWidget.apply(this, arguments);
127
		PropertyWidget.apply(this, arguments);
Lines 129-141 Link Here
129
			var values = this.property.getOptionValues();
132
			var values = this.property.getOptionValues();
130
			var labels = this.property.getOptionLabels(); // TODO nls
133
			var labels = this.property.getOptionLabels(); // TODO nls
131
			this.options = values.map(function(value, i) {
134
			this.options = values.map(function(value, i) {
132
				var label = (typeof labels[i] === 'string' ? labels[i] : value); //$NON-NLS-0$
135
				var label = typeof labels[i] === 'string' ? labels[i] : value; //$NON-NLS-0$
133
				return {value: label, label: label};
136
				return {value: label, label: label};
134
			});
137
			});
135
			SettingsSelect.prototype.postCreate.apply(this, arguments);
138
			SettingsSelect.prototype.postCreate.apply(this, arguments);
136
			PropertyWidget.prototype.postCreate.apply(this, arguments);
139
			PropertyWidget.prototype.postCreate.apply(this, arguments);
137
		},
140
		},
138
		change: function(event) {
141
		/**
142
		 * @callback
143
		 */
144
		change: function(_event) {
139
			SettingsSelect.prototype.change.apply(this, arguments);
145
			SettingsSelect.prototype.change.apply(this, arguments);
140
			var selectedOptionValue = this.property.getOptionValues()[this.getSelectedIndex()];
146
			var selectedOptionValue = this.property.getOptionValues()[this.getSelectedIndex()];
141
			if (typeof selectedOptionValue !== 'undefined') { //$NON-NLS-0$
147
			if (typeof selectedOptionValue !== 'undefined') { //$NON-NLS-0$
Lines 166-175 Link Here
166
	};
172
	};
167
	objects.mixin(PropertiesWidget.prototype, { //$NON-NLS-0$
173
	objects.mixin(PropertiesWidget.prototype, { //$NON-NLS-0$
168
		createElements: function() {
174
		createElements: function() {
169
			var self = this;
175
			var _self = this;
170
			this.children = [];
176
			this.children = [];
171
			this.initConfiguration().then(function(configuration) {
177
			this.initConfiguration().then(function(configuration) {
172
				self.createChildren(configuration);
178
				_self.createChildren(configuration);
173
			});
179
			});
174
		},
180
		},
175
		startup: function() {
181
		startup: function() {
Lines 188-200 Link Here
188
			childWidget.show();
194
			childWidget.show();
189
		},
195
		},
190
		createChildren: function(configuration) {
196
		createChildren: function(configuration) {
191
			var self = this;
197
			var _self = this;
192
			this.setting.getAttributeDefinitions().forEach(function(property) {
198
			this.setting.getAttributeDefinitions().forEach(function(property) {
193
				var options = {
199
				var options = {
194
					config: configuration,
200
					config: configuration,
195
					property: property,
201
					property: property,
196
					changeProperty: self.changeProperty.bind(self, property) ,
202
					changeProperty: _self.changeProperty.bind(_self, property) ,
197
					serviceRegistry: self.serviceRegistry
203
					serviceRegistry: _self.serviceRegistry
198
				};
204
				};
199
				var widget;
205
				var widget;
200
				if (property.getOptionValues()) {
206
				if (property.getOptionValues()) {
Lines 211-217 Link Here
211
							break;
217
							break;
212
					}
218
					}
213
				}
219
				}
214
				self.addChild(widget);
220
				_self.addChild(widget);
215
			});
221
			});
216
		},
222
		},
217
		initConfiguration: function() {
223
		initConfiguration: function() {
Lines 239-253 Link Here
239
		initConfiguration: function() {
245
		initConfiguration: function() {
240
			var configuration = this.config;
246
			var configuration = this.config;
241
			if (!configuration) {
247
			if (!configuration) {
242
				var pid = this.pid, self = this;
248
				var pid = this.pid, _self = this;
243
				this.configPromise = this.configPromise ||
249
				this.configPromise = this.configPromise ||
244
					Deferred.all([
250
					Deferred.all([
245
						this.configAdmin.getDefaultConfiguration(pid),
251
						this.configAdmin.getDefaultConfiguration(pid),
246
						this.configAdmin.getConfiguration(pid)
252
						this.configAdmin.getConfiguration(pid)
247
					]).then(function(result) {
253
					]).then(function(result) {
248
						self.defaultConfig = result[0];
254
						_self.defaultConfig = result[0];
249
						self.config = result[1];
255
						_self.config = result[1];
250
						return self.config;
256
						return _self.config;
251
					});
257
					});
252
				return this.configPromise;
258
				return this.configPromise;
253
			}
259
			}
Lines 331-338 Link Here
331
		rowElement.appendChild(settingSection);
337
		rowElement.appendChild(settingSection);
332
//		mNavUtils.addNavGrid(this.explorer.getNavDict(), setting, link);
338
//		mNavUtils.addNavGrid(this.explorer.getNavDict(), setting, link);
333
	};
339
	};
334
	SettingsRenderer.prototype.createPropertiesWidget = function(parent, setting, serviceRegistry) {
340
	/**
335
		return new PropertiesWidget({serviceRegistry: this.serviceRegistry, setting: setting, categoryTitle: this.explorer.categoryTitle}, parent);
341
	 * @callback
342
	 */
343
	SettingsRenderer.prototype.createPropertiesWidget = function(_parent, setting, serviceRegistry) {
344
		return new PropertiesWidget({serviceRegistry: this.serviceRegistry, setting: setting, categoryTitle: this.explorer.categoryTitle}, _parent);
336
	};
345
	};
337
	/** @callback */
346
	/** @callback */
338
	SettingsRenderer.prototype.renderTableHeader = function(tableNode) {
347
	SettingsRenderer.prototype.renderTableHeader = function(tableNode) {
Lines 387-394 Link Here
387
				});
396
				});
388
				dialog.show();
397
				dialog.show();
389
				var _self = this;
398
				var _self = this;
390
				dialog.addEventListener("dismiss", function(event) { //$NON-NLS-0$
399
				dialog.addEventListener("dismiss", function(_event) { //$NON-NLS-0$
391
					if (event.value) {
400
					if (_event.value) {
392
					    if(data.items) {
401
					    if(data.items) {
393
						    _self.restore(data.items.pid);
402
						    _self.restore(data.items.pid);
394
						} else {
403
						} else {
Lines 404-411 Link Here
404
		this.render(this.parent, this.serviceRegistry, this.settings, this.title);
413
		this.render(this.parent, this.serviceRegistry, this.settings, this.title);
405
	}
414
	}
406
	SettingsList.prototype = {
415
	SettingsList.prototype = {
407
		_makeSection: function(parent, sectionId, setting, title, hasMultipleSections) {
416
		/**
408
			var section = new Section(parent, { id: sectionId, title: title, useAuxStyle: true,
417
		 * @callback
418
		 */
419
		_makeSection: function(_parent, sectionId, setting, title, hasMultipleSections) {
420
			var section = new Section(_parent, { id: sectionId, title: title, useAuxStyle: true,
409
				canHide: hasMultipleSections, onExpandCollapse: true});
421
				canHide: hasMultipleSections, onExpandCollapse: true});
410
			return section;
422
			return section;
411
		},
423
		},
Lines 434-447 Link Here
434
    			}.bind(this));
446
    			}.bind(this));
435
			}
447
			}
436
		},
448
		},
437
		render: function(parent, serviceRegistry, settings, categoryTitle) {
449
		render: function(_parent, serviceRegistry, settings, categoryTitle) {
438
			// FIXME Section forces a singleton id, bad
450
			// FIXME Section forces a singleton id, bad
439
			var idPrefix = 'pluginsettings-'; //$NON-NLS-0$
451
			var idPrefix = 'pluginsettings-'; //$NON-NLS-0$
440
			
452
			
441
			for (var i=0; i<settings.length; i++) {
453
			for (var i=0; i<settings.length; i++) {
442
				var sectionId = idPrefix + 'section' + i; //$NON-NLS-0$
454
				var sectionId = idPrefix + 'section' + i; //$NON-NLS-0$
443
				var setting = settings[i];
455
				var setting = settings[i];
444
				var section = this._makeSection(parent, sectionId, setting, setting.getName() || "Unnamed", settings.length > 1); //$NON-NLS-0$
456
				var section = this._makeSection(_parent, sectionId, setting, setting.getName() || "Unnamed", settings.length > 1); //$NON-NLS-0$
445
				this.commandRegistry.renderCommands("restoreDefaults", section.getActionElement(), settings[i], this, "button"); //$NON-NLS-1$ //$NON-NLS-0$
457
				this.commandRegistry.renderCommands("restoreDefaults", section.getActionElement(), settings[i], this, "button"); //$NON-NLS-1$ //$NON-NLS-0$
446
				
458
				
447
				// Add a class name based on the category (all settings on the page have the same category currently)
459
				// Add a class name based on the category (all settings on the page have the same category currently)

Return to bug 482619