Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(497)

Side by Side Diff: chrome/browser/resources/chromeos/chromevox/speech_rules/speech_rule_functions.js

Issue 924083004: Shorten Closure template notation from Array.<*> to Array<*> in cvox. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * @fileoverview Classes for custom functions for the speech rule engine. 6 * @fileoverview Classes for custom functions for the speech rule engine.
7 * 7 *
8 */ 8 */
9 9
10 goog.provide('cvox.SpeechRuleFunctions'); 10 goog.provide('cvox.SpeechRuleFunctions');
11 goog.provide('cvox.SpeechRuleFunctions.ContextFunctions'); 11 goog.provide('cvox.SpeechRuleFunctions.ContextFunctions');
12 goog.provide('cvox.SpeechRuleFunctions.CustomQueries'); 12 goog.provide('cvox.SpeechRuleFunctions.CustomQueries');
13 goog.provide('cvox.SpeechRuleFunctions.CustomStrings'); 13 goog.provide('cvox.SpeechRuleFunctions.CustomStrings');
14 14
15 15
16 16
17 /** 17 /**
18 * @constructor 18 * @constructor
19 */ 19 */
20 cvox.SpeechRuleFunctions = function() { }; 20 cvox.SpeechRuleFunctions = function() { };
21 21
22 22
23 /** 23 /**
24 * Private superclass of all the custom function stores. 24 * Private superclass of all the custom function stores.
25 * @constructor 25 * @constructor
26 * @param {string} prefix A prefix string for the function names. 26 * @param {string} prefix A prefix string for the function names.
27 * @param {Object.<string, Function>} store Storage object. 27 * @param {Object<string, Function>} store Storage object.
28 * @private 28 * @private
29 */ 29 */
30 cvox.SpeechRuleFunctions.Store_ = function(prefix, store) { 30 cvox.SpeechRuleFunctions.Store_ = function(prefix, store) {
31 /** @private */ 31 /** @private */
32 this.prefix_ = prefix; 32 this.prefix_ = prefix;
33 /** @private */ 33 /** @private */
34 this.store_ = store; 34 this.store_ = store;
35 }; 35 };
36 36
37 37
(...skipping 14 matching lines...) Expand all
52 * @param {string} name A name. 52 * @param {string} name A name.
53 * @return {Function} The function if it exists. 53 * @return {Function} The function if it exists.
54 */ 54 */
55 cvox.SpeechRuleFunctions.Store_.prototype.lookup = function(name) { 55 cvox.SpeechRuleFunctions.Store_.prototype.lookup = function(name) {
56 return this.store_[name]; 56 return this.store_[name];
57 }; 57 };
58 58
59 59
60 /** 60 /**
61 * Context function for use in speech rules. 61 * Context function for use in speech rules.
62 * @typedef {function(!Node): Array.<Node>} 62 * @typedef {function(!Node): Array<Node>}
63 */ 63 */
64 cvox.SpeechRuleFunctions.CustomQuery; 64 cvox.SpeechRuleFunctions.CustomQuery;
65 65
66 66
67 /** 67 /**
68 * @constructor 68 * @constructor
69 * @extends {cvox.SpeechRuleFunctions.Store_} 69 * @extends {cvox.SpeechRuleFunctions.Store_}
70 */ 70 */
71 cvox.SpeechRuleFunctions.CustomQueries = function() { 71 cvox.SpeechRuleFunctions.CustomQueries = function() {
72 var store = 72 var store =
73 /** @type {Object.<string, cvox.SpeechRuleFunctions.CustomQuery>} */ ({}); 73 /** @type {Object<string, cvox.SpeechRuleFunctions.CustomQuery>} */ ({});
74 goog.base(this, 'CQF', store); 74 goog.base(this, 'CQF', store);
75 }; 75 };
76 goog.inherits(cvox.SpeechRuleFunctions.CustomQueries, 76 goog.inherits(cvox.SpeechRuleFunctions.CustomQueries,
77 cvox.SpeechRuleFunctions.Store_); 77 cvox.SpeechRuleFunctions.Store_);
78 78
79 79
80 /** 80 /**
81 * Context function for use in speech rules. 81 * Context function for use in speech rules.
82 * @typedef {function(!Node): string} 82 * @typedef {function(!Node): string}
83 */ 83 */
84 cvox.SpeechRuleFunctions.CustomString; 84 cvox.SpeechRuleFunctions.CustomString;
85 85
86 86
87 /** 87 /**
88 * @constructor 88 * @constructor
89 * @extends {cvox.SpeechRuleFunctions.Store_} 89 * @extends {cvox.SpeechRuleFunctions.Store_}
90 */ 90 */
91 cvox.SpeechRuleFunctions.CustomStrings = function() { 91 cvox.SpeechRuleFunctions.CustomStrings = function() {
92 var store = 92 var store =
93 /** @type {Object.<string, cvox.SpeechRuleFunctions.CustomString>} */ ({}); 93 /** @type {Object<string, cvox.SpeechRuleFunctions.CustomString>} */ ({});
94 goog.base(this, 'CSF', store); 94 goog.base(this, 'CSF', store);
95 }; 95 };
96 goog.inherits(cvox.SpeechRuleFunctions.CustomStrings, 96 goog.inherits(cvox.SpeechRuleFunctions.CustomStrings,
97 cvox.SpeechRuleFunctions.Store_); 97 cvox.SpeechRuleFunctions.Store_);
98 98
99 99
100 /** 100 /**
101 * Context function for use in speech rules. 101 * Context function for use in speech rules.
102 * @typedef {function(Array.<Node>, ?string): (function(): string)} 102 * @typedef {function(Array<Node>, ?string): (function(): string)}
103 */ 103 */
104 cvox.SpeechRuleFunctions.ContextFunction; 104 cvox.SpeechRuleFunctions.ContextFunction;
105 105
106 106
107 /** 107 /**
108 * @constructor 108 * @constructor
109 * @extends {cvox.SpeechRuleFunctions.Store_} 109 * @extends {cvox.SpeechRuleFunctions.Store_}
110 */ 110 */
111 cvox.SpeechRuleFunctions.ContextFunctions = function() { 111 cvox.SpeechRuleFunctions.ContextFunctions = function() {
112 var store = 112 var store =
113 /** @type {Object.<string, cvox.SpeechRuleFunctions.ContextFunction>} */ 113 /** @type {Object<string, cvox.SpeechRuleFunctions.ContextFunction>} */
114 ({}); 114 ({});
115 goog.base(this, 'CTXF', store); 115 goog.base(this, 'CTXF', store);
116 }; 116 };
117 goog.inherits(cvox.SpeechRuleFunctions.ContextFunctions, 117 goog.inherits(cvox.SpeechRuleFunctions.ContextFunctions,
118 cvox.SpeechRuleFunctions.Store_); 118 cvox.SpeechRuleFunctions.Store_);
119 119
120 120
121 /** 121 /**
122 * Checks validity for a custom function name. 122 * Checks validity for a custom function name.
123 * @param {string} name The name of the custom function. 123 * @param {string} name The name of the custom function.
124 * @return {!boolean} True if the name is valid. 124 * @return {!boolean} True if the name is valid.
125 * @private 125 * @private
126 */ 126 */
127 cvox.SpeechRuleFunctions.Store_.prototype. 127 cvox.SpeechRuleFunctions.Store_.prototype.
128 checkCustomFunctionSyntax_ = function(name) { 128 checkCustomFunctionSyntax_ = function(name) {
129 var reg = new RegExp('^' + this.prefix_); 129 var reg = new RegExp('^' + this.prefix_);
130 if (!name.match(reg)) { 130 if (!name.match(reg)) {
131 console.log( 131 console.log(
132 'FunctionError: Invalid function name. Expected prefix' + 132 'FunctionError: Invalid function name. Expected prefix' +
133 this.prefix_); 133 this.prefix_);
134 return false; 134 return false;
135 } 135 }
136 return true; 136 return true;
137 }; 137 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698