sproutcore 0.9.13 → 0.9.14
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +19 -0
- data/Manifest.txt +103 -26
- data/app_generators/sproutcore/templates/README +1 -1
- data/bin/sc-build +1 -1
- data/bin/sc-gen +0 -0
- data/bin/sc-ide +278 -0
- data/bin/sc-init +38 -0
- data/bin/sc-install +96 -0
- data/bin/sc-remove +94 -0
- data/bin/sc-server +4 -0
- data/bin/sc-update +94 -0
- data/bin/sproutcore +3 -14
- data/clients/sc_docs/controllers/docs.js +1 -1
- data/clients/sc_docs/models/doc.js +6 -0
- data/clients/sc_docs/views/doc_frame.js +1 -1
- data/clients/sc_test_runner/english.lproj/icons/small/next.png +0 -0
- data/clients/sc_test_runner/english.lproj/icons/small/reset.png +0 -0
- data/frameworks/sproutcore/HISTORY +34 -2
- data/frameworks/sproutcore/controllers/array.js +1 -1
- data/frameworks/sproutcore/controllers/controller.js +1 -1
- data/frameworks/sproutcore/controllers/object.js +9 -6
- data/frameworks/sproutcore/core.js +19 -4
- data/frameworks/sproutcore/english.lproj/blank.gif +0 -0
- data/frameworks/sproutcore/english.lproj/core.css +1 -0
- data/frameworks/sproutcore/english.lproj/menu.css +1 -0
- data/frameworks/sproutcore/foundation/application.js +3 -3
- data/frameworks/sproutcore/foundation/benchmark.js +1 -1
- data/frameworks/sproutcore/foundation/node_descriptor.js +13 -1
- data/frameworks/sproutcore/foundation/page.js +3 -2
- data/frameworks/sproutcore/foundation/path_module.js +33 -16
- data/frameworks/sproutcore/foundation/run_loop.js +1 -1
- data/frameworks/sproutcore/foundation/server.js +68 -18
- data/frameworks/sproutcore/foundation/string.js +1 -1
- data/frameworks/sproutcore/globals/window.js +62 -15
- data/frameworks/sproutcore/lib/core_views.rb +1 -0
- data/frameworks/sproutcore/lib/index.rhtml +4 -3
- data/frameworks/sproutcore/lib/menu_views.rb +2 -2
- data/frameworks/sproutcore/models/collection.js +122 -107
- data/frameworks/sproutcore/models/record.js +2 -2
- data/frameworks/sproutcore/panes/manager.js +1 -1
- data/frameworks/sproutcore/panes/overlay.js +3 -3
- data/frameworks/sproutcore/tests/controllers/object.rhtml +26 -0
- data/frameworks/sproutcore/tests/views/collection/incremental_rendering.rhtml +2 -2
- data/frameworks/sproutcore/views/button/disclosure.js +1 -1
- data/frameworks/sproutcore/views/collection/collection.js +19 -15
- data/frameworks/sproutcore/views/collection/source_list.js +1 -1
- data/frameworks/sproutcore/views/collection/table.js +2 -2
- data/frameworks/sproutcore/views/error_explanation.js +1 -1
- data/frameworks/sproutcore/views/field/checkbox_field.js +1 -1
- data/frameworks/sproutcore/views/field/field.js +1 -1
- data/frameworks/sproutcore/views/field/radio_field.js +1 -1
- data/frameworks/sproutcore/views/field/select_field.js +1 -1
- data/frameworks/sproutcore/views/form.js +1 -1
- data/frameworks/sproutcore/views/image.js +1 -1
- data/frameworks/sproutcore/views/menu_item.js +1 -1
- data/frameworks/sproutcore/views/popup_button.js +1 -1
- data/frameworks/sproutcore/views/popup_menu.js +1 -1
- data/frameworks/sproutcore/views/progress.js +4 -2
- data/frameworks/sproutcore/views/radio_group.js +1 -1
- data/frameworks/sproutcore/views/scroll.js +1 -1
- data/frameworks/sproutcore/views/source_list_group.js +1 -1
- data/frameworks/sproutcore/views/split.js +1 -1
- data/frameworks/sproutcore/views/tab.js +3 -1
- data/frameworks/sproutcore/views/view.js +19 -3
- data/jsdoc/README.txt +89 -57
- data/jsdoc/app/frame/Chain.js +102 -0
- data/jsdoc/app/frame/Dumper.js +144 -0
- data/jsdoc/app/frame/Hash.js +47 -0
- data/jsdoc/app/frame/Link.js +142 -0
- data/jsdoc/app/frame/Namespace.js +10 -0
- data/jsdoc/app/frame/Opt.js +134 -0
- data/jsdoc/app/frame/Reflection.js +26 -0
- data/jsdoc/app/frame/String.js +93 -0
- data/jsdoc/app/frame/Testrun.js +129 -0
- data/jsdoc/app/frame.js +33 -0
- data/jsdoc/app/handlers/FOODOC.js +26 -0
- data/jsdoc/app/handlers/XMLDOC/DomReader.js +159 -0
- data/jsdoc/app/handlers/XMLDOC/XMLDoc.js +16 -0
- data/jsdoc/app/handlers/XMLDOC/XMLParse.js +292 -0
- data/jsdoc/app/handlers/XMLDOC.js +26 -0
- data/jsdoc/app/lib/JSDOC/DocComment.js +200 -0
- data/jsdoc/app/lib/JSDOC/DocTag.js +294 -0
- data/jsdoc/app/lib/JSDOC/JsDoc.js +180 -0
- data/jsdoc/app/lib/JSDOC/JsPlate.js +100 -0
- data/jsdoc/app/lib/JSDOC/Lang.js +144 -0
- data/jsdoc/app/lib/JSDOC/Parser.js +109 -0
- data/jsdoc/app/lib/JSDOC/PluginManager.js +33 -0
- data/jsdoc/app/lib/JSDOC/Symbol.js +600 -0
- data/jsdoc/app/lib/JSDOC/SymbolSet.js +220 -0
- data/jsdoc/app/lib/JSDOC/TextStream.js +41 -0
- data/jsdoc/app/lib/JSDOC/Token.js +18 -0
- data/jsdoc/app/lib/JSDOC/TokenReader.js +323 -0
- data/jsdoc/app/lib/JSDOC/TokenStream.js +133 -0
- data/jsdoc/app/lib/JSDOC/Util.js +32 -0
- data/jsdoc/app/lib/JSDOC/Walker.js +416 -0
- data/jsdoc/app/lib/JSDOC.js +97 -0
- data/jsdoc/app/main.js +74 -0
- data/jsdoc/app/plugins/commentSrcJson.js +19 -0
- data/jsdoc/app/plugins/frameworkPrototype.js +16 -0
- data/jsdoc/app/plugins/functionCall.js +10 -0
- data/jsdoc/app/plugins/publishSrcHilite.js +62 -0
- data/jsdoc/app/plugins/sproutcoreTags.js +26 -0
- data/jsdoc/app/plugins/symbolLink.js +9 -0
- data/jsdoc/app/plugins/tagParamConfig.js +31 -0
- data/jsdoc/app/plugins/tagSynonyms.js +43 -0
- data/jsdoc/app/run.js +339 -137
- data/jsdoc/changes.txt +47 -0
- data/jsdoc/conf/sample.conf +31 -0
- data/jsdoc/java/build.xml +36 -0
- data/jsdoc/java/build_1.4.xml +36 -0
- data/jsdoc/java/classes/js.jar +0 -0
- data/jsdoc/java/src/JsDebugRun.java +21 -0
- data/jsdoc/java/src/JsRun.java +21 -0
- data/jsdoc/jsdebug.jar +0 -0
- data/jsdoc/jsrun.jar +0 -0
- data/jsdoc/t/TestDoc.js +144 -0
- data/jsdoc/t/runner.js +13 -0
- data/jsdoc/templates/sproutcore/allclasses.tmpl +17 -0
- data/jsdoc/templates/sproutcore/allfiles.tmpl +56 -0
- data/jsdoc/templates/sproutcore/class.tmpl +408 -326
- data/jsdoc/templates/sproutcore/index.tmpl +30 -31
- data/jsdoc/templates/sproutcore/publish.js +173 -81
- data/jsdoc/templates/sproutcore/static/default.css +191 -0
- data/jsdoc/templates/sproutcore/static/header.html +2 -0
- data/jsdoc/templates/sproutcore/static/index.html +19 -0
- data/jsdoc/templates/sproutcore/symbol.tmpl +35 -0
- data/jsdoc/test/addon.js +24 -0
- data/jsdoc/test/anon_inner.js +14 -0
- data/jsdoc/test/augments.js +31 -0
- data/jsdoc/test/augments2.js +26 -0
- data/jsdoc/test/borrows.js +41 -0
- data/jsdoc/test/borrows2.js +23 -0
- data/jsdoc/test/config.js +22 -0
- data/jsdoc/test/constructs.js +18 -0
- data/jsdoc/test/encoding.js +10 -0
- data/jsdoc/test/encoding_other.js +12 -0
- data/jsdoc/test/functions_anon.js +39 -0
- data/jsdoc/test/functions_nested.js +33 -0
- data/jsdoc/test/global.js +13 -0
- data/jsdoc/test/globals.js +25 -0
- data/jsdoc/test/ignore.js +10 -0
- data/jsdoc/test/inner.js +16 -0
- data/jsdoc/test/jsdoc_test.js +477 -0
- data/jsdoc/test/lend.js +33 -0
- data/jsdoc/test/memberof.js +20 -0
- data/jsdoc/test/memberof_constructor.js +15 -0
- data/jsdoc/test/name.js +19 -0
- data/jsdoc/test/namespace_nested.js +23 -0
- data/jsdoc/test/nocode.js +13 -0
- data/jsdoc/test/oblit_anon.js +20 -0
- data/jsdoc/test/overview.js +20 -0
- data/jsdoc/test/param_inline.js +37 -0
- data/jsdoc/test/params_optional.js +8 -0
- data/jsdoc/test/prototype.js +17 -0
- data/jsdoc/test/prototype_nested.js +9 -0
- data/jsdoc/test/prototype_oblit.js +13 -0
- data/jsdoc/test/prototype_oblit_constructor.js +24 -0
- data/jsdoc/test/public.js +10 -0
- data/jsdoc/test/shared.js +42 -0
- data/jsdoc/test/shared2.js +2 -0
- data/jsdoc/test/shortcuts.js +22 -0
- data/jsdoc/test/static_this.js +13 -0
- data/jsdoc/test/synonyms.js +23 -0
- data/jsdoc/test/tosource.js +23 -0
- data/jsdoc/test/variable_redefine.js +14 -0
- data/jsdoc/test.js +304 -0
- data/lib/sproutcore/build_tools/resource_builder.rb +6 -1
- data/lib/sproutcore/bundle_installer.rb +268 -0
- data/lib/sproutcore/jsdoc.rb +7 -6
- data/lib/sproutcore/library.rb +38 -0
- data/lib/sproutcore/merb/bundle_controller.rb +8 -4
- data/lib/sproutcore/version.rb +1 -1
- data/lib/sproutcore.rb +1 -1
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/script/txt2html +0 -0
- metadata +117 -29
- data/clients/view_builder/core.js +0 -19
- data/clients/view_builder/english.lproj/body.css +0 -149
- data/clients/view_builder/english.lproj/body.rhtml +0 -18
- data/clients/view_builder/english.lproj/strings.js +0 -14
- data/clients/view_builder/main.js +0 -37
- data/jsdoc/app/DocFile.js +0 -137
- data/jsdoc/app/DocTag.js +0 -110
- data/jsdoc/app/Doclet.js +0 -63
- data/jsdoc/app/Dumper.js +0 -143
- data/jsdoc/app/JsDoc.js +0 -103
- data/jsdoc/app/JsHilite.js +0 -45
- data/jsdoc/app/JsIO.js +0 -163
- data/jsdoc/app/JsParse.js +0 -385
- data/jsdoc/app/JsPlate.js +0 -130
- data/jsdoc/app/JsTestrun.js +0 -129
- data/jsdoc/app/JsToke.js +0 -564
- data/jsdoc/app/Symbol.js +0 -298
- data/jsdoc/app/Transformer.js +0 -14
- data/jsdoc/app/Util.js +0 -97
- data/jsdoc/app/js.jar +0 -0
- data/jsdoc/plugins/min.js +0 -316
- data/jsdoc/plugins/strip.js +0 -20
- data/jsdoc/templates/sproutcore/default.css +0 -191
- data/jsdoc/templates/sproutcore/index.html +0 -13
- data/jsdoc/templates/sproutcore/prototype.js +0 -4186
- data/jsdoc/templates/sproutcore/splash.html +0 -7
@@ -0,0 +1,220 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/** @constructor */
|
4
|
+
JSDOC.SymbolSet = function() {
|
5
|
+
this.init();
|
6
|
+
}
|
7
|
+
|
8
|
+
JSDOC.SymbolSet.prototype.init = function() {
|
9
|
+
this._index = {};
|
10
|
+
}
|
11
|
+
|
12
|
+
JSDOC.SymbolSet.prototype.keys = function() {
|
13
|
+
var found = [];
|
14
|
+
for (var p in this._index) {
|
15
|
+
found.push(p);
|
16
|
+
}
|
17
|
+
return found;
|
18
|
+
}
|
19
|
+
|
20
|
+
JSDOC.SymbolSet.prototype.hasSymbol = function(alias) {
|
21
|
+
return this._index.hasOwnProperty(alias);
|
22
|
+
}
|
23
|
+
|
24
|
+
JSDOC.SymbolSet.prototype.addSymbol = function(symbol) {
|
25
|
+
if (this.hasSymbol(symbol.alias)) {
|
26
|
+
LOG.warn("Overwriting symbol documentation for: "+symbol.alias + ".");
|
27
|
+
}
|
28
|
+
this._index[symbol.alias] = symbol;
|
29
|
+
}
|
30
|
+
|
31
|
+
JSDOC.SymbolSet.prototype.getSymbol = function(alias) {
|
32
|
+
if (this.hasSymbol(alias)) return this._index[alias];
|
33
|
+
}
|
34
|
+
|
35
|
+
JSDOC.SymbolSet.prototype.getSymbolByName = function(name) {
|
36
|
+
for (var p in this._index) {
|
37
|
+
var symbol = this.getSymbol(p);
|
38
|
+
if (symbol.name == name) return symbol;
|
39
|
+
}
|
40
|
+
}
|
41
|
+
|
42
|
+
JSDOC.SymbolSet.prototype.toArray = function() {
|
43
|
+
var found = [];
|
44
|
+
for (var p in this._index) {
|
45
|
+
found.push(this._index[p]);
|
46
|
+
}
|
47
|
+
return found;
|
48
|
+
}
|
49
|
+
|
50
|
+
JSDOC.SymbolSet.prototype.deleteSymbol = function(alias) {
|
51
|
+
if (!this.hasSymbol(alias)) return;
|
52
|
+
delete this._index[alias];
|
53
|
+
}
|
54
|
+
|
55
|
+
JSDOC.SymbolSet.prototype.renameSymbol = function(oldName, newName) {
|
56
|
+
// todo: should check if oldname or newname already exist
|
57
|
+
this._index[newName] = this._index[oldName];
|
58
|
+
this.deleteSymbol(oldName);
|
59
|
+
this._index[newName].alias = newName;
|
60
|
+
return newName;
|
61
|
+
}
|
62
|
+
|
63
|
+
JSDOC.SymbolSet.prototype.relate = function() {
|
64
|
+
this.resolveBorrows();
|
65
|
+
this.resolveMemberOf();
|
66
|
+
this.resolveAugments();
|
67
|
+
}
|
68
|
+
|
69
|
+
JSDOC.SymbolSet.prototype.resolveBorrows = function() {
|
70
|
+
for (p in this._index) {
|
71
|
+
var symbol = this._index[p];
|
72
|
+
if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;
|
73
|
+
|
74
|
+
var borrows = symbol.inherits;
|
75
|
+
for (var i = 0; i < borrows.length; i++) {
|
76
|
+
var borrowed = this.getSymbol(borrows[i].alias);
|
77
|
+
if (!borrowed) {
|
78
|
+
LOG.warn("Can't borrow undocumented "+borrows[i].alias+".");
|
79
|
+
continue;
|
80
|
+
}
|
81
|
+
|
82
|
+
var borrowAsName = borrows[i].as;
|
83
|
+
var borrowAsAlias = borrowAsName;
|
84
|
+
if (!borrowAsName) {
|
85
|
+
LOG.warn("Malformed @borrow, 'as' is required.");
|
86
|
+
continue;
|
87
|
+
}
|
88
|
+
|
89
|
+
if (borrowAsName.length > symbol.alias.length && borrowAsName.indexOf(symbol.alias) == 0) {
|
90
|
+
borrowAsName = borrowAsName.replace(borrowed.alias, "")
|
91
|
+
}
|
92
|
+
else {
|
93
|
+
var joiner = "";
|
94
|
+
if (borrowAsName.charAt(0) != "#") joiner = ".";
|
95
|
+
borrowAsAlias = borrowed.alias + joiner + borrowAsName;
|
96
|
+
}
|
97
|
+
|
98
|
+
borrowAsName = borrowAsName.replace(/^[#.]/, "");
|
99
|
+
|
100
|
+
if (this.hasSymbol(borrowAsAlias)) continue;
|
101
|
+
|
102
|
+
var clone = borrowed.clone();
|
103
|
+
clone.name = borrowAsName;
|
104
|
+
clone.alias = borrowAsAlias;
|
105
|
+
this.addSymbol(clone);
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
JSDOC.SymbolSet.prototype.resolveMemberOf = function() {
|
111
|
+
for (var p in this._index) {
|
112
|
+
var symbol = this.getSymbol(p);
|
113
|
+
|
114
|
+
if (symbol.is("FILE") || symbol.is("GLOBAL")) continue;
|
115
|
+
|
116
|
+
// the memberOf value was provided in the @memberOf tag
|
117
|
+
else if (symbol.memberOf) {
|
118
|
+
var parts = symbol.alias.match(new RegExp("^("+symbol.memberOf+"[.#-])(.+)$"));
|
119
|
+
|
120
|
+
// like foo.bar is a memberOf foo
|
121
|
+
if (parts) {
|
122
|
+
symbol.memberOf = parts[1];
|
123
|
+
symbol.name = parts[2];
|
124
|
+
}
|
125
|
+
// like bar is a memberOf foo
|
126
|
+
else {
|
127
|
+
var joiner = symbol.memberOf.charAt(symbol.memberOf.length-1);
|
128
|
+
if (!/[.#-]/.test(joiner)) symbol.memberOf += ".";
|
129
|
+
|
130
|
+
this.renameSymbol(p, symbol.memberOf + symbol.name);
|
131
|
+
}
|
132
|
+
}
|
133
|
+
// the memberOf must be calculated
|
134
|
+
else {
|
135
|
+
var parts = symbol.alias.match(/^(.*[.#-])([^.#-]+)$/);
|
136
|
+
if (parts) {
|
137
|
+
symbol.memberOf = parts[1];
|
138
|
+
symbol.name = parts[2];
|
139
|
+
}
|
140
|
+
}
|
141
|
+
|
142
|
+
// set isStatic, isInner
|
143
|
+
if (symbol.memberOf) {
|
144
|
+
switch (symbol.memberOf.charAt(symbol.memberOf.length-1)) {
|
145
|
+
case '#' :
|
146
|
+
symbol.isStatic = false;
|
147
|
+
symbol.isInner = false;
|
148
|
+
break;
|
149
|
+
case '.' :
|
150
|
+
symbol.isStatic = true;
|
151
|
+
symbol.isInner = false;
|
152
|
+
break;
|
153
|
+
case '-' :
|
154
|
+
symbol.isStatic = false;
|
155
|
+
symbol.isInner = true;
|
156
|
+
break;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
|
160
|
+
// unowned methods and fields belong to the global object
|
161
|
+
if (!symbol.is("CONSTRUCTOR") && !symbol.isNamespace && symbol.memberOf == "") {
|
162
|
+
symbol.memberOf = "_global_";
|
163
|
+
}
|
164
|
+
|
165
|
+
// clean up
|
166
|
+
if (symbol.memberOf.match(/[.#-]$/)) {
|
167
|
+
symbol.memberOf = symbol.memberOf.substr(0, symbol.memberOf.length-1);
|
168
|
+
}
|
169
|
+
|
170
|
+
// add to parent's methods or properties list
|
171
|
+
if (symbol.memberOf) {
|
172
|
+
var container = this.getSymbol(symbol.memberOf);
|
173
|
+
if (!container) {
|
174
|
+
if (JSDOC.Lang.isBuiltin(symbol.memberOf)) container = JSDOC.Parser.addBuiltin(symbol.memberOf);
|
175
|
+
else {
|
176
|
+
LOG.warn("Can't document "+symbol.name +" as a member of undocumented symbol "+symbol.memberOf+".");
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
if (container) container.addMember(symbol);
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
|
185
|
+
JSDOC.SymbolSet.prototype.resolveAugments = function() {
|
186
|
+
for (var p in this._index) {
|
187
|
+
var symbol = this.getSymbol(p);
|
188
|
+
|
189
|
+
if (symbol.alias == "_global_" || symbol.is("FILE")) continue;
|
190
|
+
JSDOC.SymbolSet.prototype.walk.apply(this, [symbol]);
|
191
|
+
}
|
192
|
+
}
|
193
|
+
|
194
|
+
JSDOC.SymbolSet.prototype.walk = function(symbol) {
|
195
|
+
var augments = symbol.augments;
|
196
|
+
for(var i = 0; i < augments.length; i++) {
|
197
|
+
var contributer = this.getSymbol(augments[i]);
|
198
|
+
if (contributer) {
|
199
|
+
if (contributer.augments.length) {
|
200
|
+
JSDOC.SymbolSet.prototype.walk.apply(this, [contributer]);
|
201
|
+
}
|
202
|
+
|
203
|
+
symbol.inheritsFrom.push(contributer.alias);
|
204
|
+
if (!isUnique(symbol.inheritsFrom)) {
|
205
|
+
//LOG.warn("Can't resolve augments: Circular reference: "+symbol.alias+" inherits from "+contributer.alias+" more than once.");
|
206
|
+
}
|
207
|
+
else {
|
208
|
+
var cmethods = contributer.methods;
|
209
|
+
var cproperties = contributer.properties;
|
210
|
+
|
211
|
+
for (var ci = 0, cl = cmethods.length; ci < cl; ci++)
|
212
|
+
symbol.inherit(cmethods[ci]);
|
213
|
+
for (var ci = 0, cl = cproperties.length; ci < cl; ci++)
|
214
|
+
symbol.inherit(cproperties[ci]);
|
215
|
+
}
|
216
|
+
}
|
217
|
+
else LOG.warn("Can't augment contributer: "+augments[i]+", not found.");
|
218
|
+
}
|
219
|
+
}
|
220
|
+
|
@@ -0,0 +1,41 @@
|
|
1
|
+
|
2
|
+
/**
|
3
|
+
@constructor
|
4
|
+
*/
|
5
|
+
JSDOC.TextStream = function(text) {
|
6
|
+
if (typeof(text) == "undefined") text = "";
|
7
|
+
text = ""+text;
|
8
|
+
this.text = text;
|
9
|
+
this.cursor = 0;
|
10
|
+
}
|
11
|
+
|
12
|
+
JSDOC.TextStream.prototype.look = function(n) {
|
13
|
+
if (typeof n == "undefined") n = 0;
|
14
|
+
|
15
|
+
if (this.cursor+n < 0 || this.cursor+n >= this.text.length) {
|
16
|
+
var result = new String("");
|
17
|
+
result.eof = true;
|
18
|
+
return result;
|
19
|
+
}
|
20
|
+
return this.text.charAt(this.cursor+n);
|
21
|
+
}
|
22
|
+
|
23
|
+
JSDOC.TextStream.prototype.next = function(n) {
|
24
|
+
if (typeof n == "undefined") n = 1;
|
25
|
+
if (n < 1) return null;
|
26
|
+
|
27
|
+
var pulled = "";
|
28
|
+
for (var i = 0; i < n; i++) {
|
29
|
+
if (this.cursor+i < this.text.length) {
|
30
|
+
pulled += this.text.charAt(this.cursor+i);
|
31
|
+
}
|
32
|
+
else {
|
33
|
+
var result = new String("");
|
34
|
+
result.eof = true;
|
35
|
+
return result;
|
36
|
+
}
|
37
|
+
}
|
38
|
+
|
39
|
+
this.cursor += n;
|
40
|
+
return pulled;
|
41
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/**
|
4
|
+
@constructor
|
5
|
+
*/
|
6
|
+
JSDOC.Token = function(data, type, name) {
|
7
|
+
this.data = data;
|
8
|
+
this.type = type;
|
9
|
+
this.name = name;
|
10
|
+
}
|
11
|
+
|
12
|
+
JSDOC.Token.prototype.toString = function() {
|
13
|
+
return "<"+this.type+" name=\""+this.name+"\">"+this.data+"</"+this.type+">";
|
14
|
+
}
|
15
|
+
|
16
|
+
JSDOC.Token.prototype.is = function(what) {
|
17
|
+
return this.name === what || this.type === what;
|
18
|
+
}
|
@@ -0,0 +1,323 @@
|
|
1
|
+
if (typeof JSDOC == "undefined") JSDOC = {};
|
2
|
+
|
3
|
+
/**
|
4
|
+
@class Search a {@link JSDOC.TextStream} for language tokens.
|
5
|
+
*/
|
6
|
+
JSDOC.TokenReader = function() {
|
7
|
+
this.keepDocs = true;
|
8
|
+
this.keepWhite = false;
|
9
|
+
this.keepComments = false;
|
10
|
+
}
|
11
|
+
|
12
|
+
/**
|
13
|
+
@type {JSDOC.Token[]}
|
14
|
+
*/
|
15
|
+
JSDOC.TokenReader.prototype.tokenize = function(/**JSDOC.TextStream*/stream) {
|
16
|
+
var tokens = [];
|
17
|
+
/**@ignore*/ tokens.last = function() { return tokens[tokens.length-1]; }
|
18
|
+
|
19
|
+
while (!stream.look().eof) {
|
20
|
+
if (this.read_mlcomment(stream, tokens)) continue;
|
21
|
+
if (this.read_slcomment(stream, tokens)) continue;
|
22
|
+
if (this.read_dbquote(stream, tokens)) continue;
|
23
|
+
if (this.read_snquote(stream, tokens)) continue;
|
24
|
+
if (this.read_regx(stream, tokens)) continue;
|
25
|
+
if (this.read_numb(stream, tokens)) continue;
|
26
|
+
if (this.read_punc(stream, tokens)) continue;
|
27
|
+
if (this.read_space(stream, tokens)) continue;
|
28
|
+
if (this.read_newline(stream, tokens)) continue;
|
29
|
+
if (this.read_word(stream, tokens)) continue;
|
30
|
+
|
31
|
+
// if execution reaches here then an error has happened
|
32
|
+
tokens.push(new JSDOC.Token(stream.next(), "TOKN", "UNKNOWN_TOKEN"));
|
33
|
+
}
|
34
|
+
return tokens;
|
35
|
+
}
|
36
|
+
|
37
|
+
/**
|
38
|
+
@returns {Boolean} Was the token found?
|
39
|
+
*/
|
40
|
+
JSDOC.TokenReader.prototype.read_word = function(/**JSDOC.TokenStream*/stream, tokens) {
|
41
|
+
var found = "";
|
42
|
+
while (!stream.look().eof && JSDOC.Lang.isWordChar(stream.look())) {
|
43
|
+
found += stream.next();
|
44
|
+
}
|
45
|
+
|
46
|
+
if (found === "") {
|
47
|
+
return false;
|
48
|
+
}
|
49
|
+
else {
|
50
|
+
var name;
|
51
|
+
if ((name = JSDOC.Lang.keyword(found))) tokens.push(new JSDOC.Token(found, "KEYW", name));
|
52
|
+
else tokens.push(new JSDOC.Token(found, "NAME", "NAME"));
|
53
|
+
return true;
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
/**
|
58
|
+
@returns {Boolean} Was the token found?
|
59
|
+
*/
|
60
|
+
JSDOC.TokenReader.prototype.read_punc = function(/**JSDOC.TokenStream*/stream, tokens) {
|
61
|
+
var found = "";
|
62
|
+
var name;
|
63
|
+
while (!stream.look().eof && JSDOC.Lang.punc(found+stream.look())) {
|
64
|
+
found += stream.next();
|
65
|
+
}
|
66
|
+
|
67
|
+
if (found === "") {
|
68
|
+
return false;
|
69
|
+
}
|
70
|
+
else {
|
71
|
+
tokens.push(new JSDOC.Token(found, "PUNC", JSDOC.Lang.punc(found)));
|
72
|
+
return true;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
|
76
|
+
/**
|
77
|
+
@returns {Boolean} Was the token found?
|
78
|
+
*/
|
79
|
+
JSDOC.TokenReader.prototype.read_space = function(/**JSDOC.TokenStream*/stream, tokens) {
|
80
|
+
var found = "";
|
81
|
+
|
82
|
+
while (!stream.look().eof && JSDOC.Lang.isSpace(stream.look())) {
|
83
|
+
found += stream.next();
|
84
|
+
}
|
85
|
+
|
86
|
+
if (found === "") {
|
87
|
+
return false;
|
88
|
+
}
|
89
|
+
else {
|
90
|
+
if (this.collapseWhite) found = " ";
|
91
|
+
if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "SPACE"));
|
92
|
+
return true;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
/**
|
97
|
+
@returns {Boolean} Was the token found?
|
98
|
+
*/
|
99
|
+
JSDOC.TokenReader.prototype.read_newline = function(/**JSDOC.TokenStream*/stream, tokens) {
|
100
|
+
var found = "";
|
101
|
+
|
102
|
+
while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look())) {
|
103
|
+
found += stream.next();
|
104
|
+
}
|
105
|
+
|
106
|
+
if (found === "") {
|
107
|
+
return false;
|
108
|
+
}
|
109
|
+
else {
|
110
|
+
if (this.collapseWhite) found = "\n";
|
111
|
+
if (this.keepWhite) tokens.push(new JSDOC.Token(found, "WHIT", "NEWLINE"));
|
112
|
+
return true;
|
113
|
+
}
|
114
|
+
}
|
115
|
+
|
116
|
+
/**
|
117
|
+
@returns {Boolean} Was the token found?
|
118
|
+
*/
|
119
|
+
JSDOC.TokenReader.prototype.read_mlcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
|
120
|
+
if (stream.look() == "/" && stream.look(1) == "*") {
|
121
|
+
var found = stream.next(2);
|
122
|
+
|
123
|
+
while (!stream.look().eof && !(stream.look(-1) == "/" && stream.look(-2) == "*")) {
|
124
|
+
found += stream.next();
|
125
|
+
}
|
126
|
+
|
127
|
+
// to start doclet we allow /** or /*** but not /**/ or /****
|
128
|
+
if (/^\/\*\*([^\/]|\*[^*])/.test(found) && this.keepDocs) tokens.push(new JSDOC.Token(found, "COMM", "JSDOC"));
|
129
|
+
else if (this.keepComments) tokens.push(new JSDOC.Token(found, "COMM", "MULTI_LINE_COMM"));
|
130
|
+
return true;
|
131
|
+
}
|
132
|
+
return false;
|
133
|
+
}
|
134
|
+
|
135
|
+
/**
|
136
|
+
@returns {Boolean} Was the token found?
|
137
|
+
*/
|
138
|
+
JSDOC.TokenReader.prototype.read_slcomment = function(/**JSDOC.TokenStream*/stream, tokens) {
|
139
|
+
var found;
|
140
|
+
if (
|
141
|
+
(stream.look() == "/" && stream.look(1) == "/" && (found=stream.next(2)))
|
142
|
+
||
|
143
|
+
(stream.look() == "<" && stream.look(1) == "!" && stream.look(2) == "-" && stream.look(3) == "-" && (found=stream.next(4)))
|
144
|
+
) {
|
145
|
+
|
146
|
+
while (!stream.look().eof && !JSDOC.Lang.isNewline(stream.look())) {
|
147
|
+
found += stream.next();
|
148
|
+
}
|
149
|
+
|
150
|
+
if (this.keepComments) {
|
151
|
+
tokens.push(new JSDOC.Token(found, "COMM", "SINGLE_LINE_COMM"));
|
152
|
+
}
|
153
|
+
return true;
|
154
|
+
}
|
155
|
+
return false;
|
156
|
+
}
|
157
|
+
|
158
|
+
/**
|
159
|
+
@returns {Boolean} Was the token found?
|
160
|
+
*/
|
161
|
+
JSDOC.TokenReader.prototype.read_dbquote = function(/**JSDOC.TokenStream*/stream, tokens) {
|
162
|
+
if (stream.look() == "\"") {
|
163
|
+
// find terminator
|
164
|
+
var string = stream.next();
|
165
|
+
|
166
|
+
while (!stream.look().eof) {
|
167
|
+
if (stream.look() == "\\") {
|
168
|
+
if (JSDOC.Lang.isNewline(stream.look(1))) {
|
169
|
+
do {
|
170
|
+
stream.next();
|
171
|
+
} while (!stream.look().eof && JSDOC.Lang.isNewline(stream.look()));
|
172
|
+
string += "\\\n";
|
173
|
+
}
|
174
|
+
else {
|
175
|
+
string += stream.next(2);
|
176
|
+
}
|
177
|
+
}
|
178
|
+
else if (stream.look() == "\"") {
|
179
|
+
string += stream.next();
|
180
|
+
tokens.push(new JSDOC.Token(string, "STRN", "DOUBLE_QUOTE"));
|
181
|
+
return true;
|
182
|
+
}
|
183
|
+
else {
|
184
|
+
string += stream.next();
|
185
|
+
}
|
186
|
+
}
|
187
|
+
}
|
188
|
+
return false; // error! unterminated string
|
189
|
+
}
|
190
|
+
|
191
|
+
/**
|
192
|
+
@returns {Boolean} Was the token found?
|
193
|
+
*/
|
194
|
+
JSDOC.TokenReader.prototype.read_snquote = function(/**JSDOC.TokenStream*/stream, tokens) {
|
195
|
+
if (stream.look() == "'") {
|
196
|
+
// find terminator
|
197
|
+
var string = stream.next();
|
198
|
+
|
199
|
+
while (!stream.look().eof) {
|
200
|
+
if (stream.look() == "\\") { // escape sequence
|
201
|
+
string += stream.next(2);
|
202
|
+
}
|
203
|
+
else if (stream.look() == "'") {
|
204
|
+
string += stream.next();
|
205
|
+
tokens.push(new JSDOC.Token(string, "STRN", "SINGLE_QUOTE"));
|
206
|
+
return true;
|
207
|
+
}
|
208
|
+
else {
|
209
|
+
string += stream.next();
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
return false; // error! unterminated string
|
214
|
+
}
|
215
|
+
|
216
|
+
/**
|
217
|
+
@returns {Boolean} Was the token found?
|
218
|
+
*/
|
219
|
+
JSDOC.TokenReader.prototype.read_numb = function(/**JSDOC.TokenStream*/stream, tokens) {
|
220
|
+
if (stream.look() === "0" && stream.look(1) == "x") {
|
221
|
+
return this.read_hex(stream, tokens);
|
222
|
+
}
|
223
|
+
|
224
|
+
var found = "";
|
225
|
+
|
226
|
+
while (!stream.look().eof && JSDOC.Lang.isNumber(found+stream.look())){
|
227
|
+
found += stream.next();
|
228
|
+
}
|
229
|
+
|
230
|
+
if (found === "") {
|
231
|
+
return false;
|
232
|
+
}
|
233
|
+
else {
|
234
|
+
if (/^0[0-7]/.test(found)) tokens.push(new JSDOC.Token(found, "NUMB", "OCTAL"));
|
235
|
+
else tokens.push(new JSDOC.Token(found, "NUMB", "DECIMAL"));
|
236
|
+
return true;
|
237
|
+
}
|
238
|
+
}
|
239
|
+
/*t:
|
240
|
+
requires("../lib/JSDOC/TextStream.js");
|
241
|
+
requires("../lib/JSDOC/Token.js");
|
242
|
+
requires("../lib/JSDOC/Lang.js");
|
243
|
+
|
244
|
+
plan(3, "testing JSDOC.TokenReader.prototype.read_numb");
|
245
|
+
|
246
|
+
//// setup
|
247
|
+
var src = "function foo(num){while (num+8.0 >= 0x20 && num < 0777){}}";
|
248
|
+
var tr = new JSDOC.TokenReader();
|
249
|
+
var tokens = tr.tokenize(new JSDOC.TextStream(src));
|
250
|
+
|
251
|
+
var hexToken, octToken, decToken;
|
252
|
+
for (var i = 0; i < tokens.length; i++) {
|
253
|
+
if (tokens[i].name == "HEX_DEC") hexToken = tokens[i];
|
254
|
+
if (tokens[i].name == "OCTAL") octToken = tokens[i];
|
255
|
+
if (tokens[i].name == "DECIMAL") decToken = tokens[i];
|
256
|
+
}
|
257
|
+
////
|
258
|
+
|
259
|
+
is(decToken.data, "8.0", "decimal number is found in source.");
|
260
|
+
is(hexToken.data, "0x20", "hexdec number is found in source (issue #99).");
|
261
|
+
is(octToken.data, "0777", "octal number is found in source.");
|
262
|
+
*/
|
263
|
+
|
264
|
+
/**
|
265
|
+
@returns {Boolean} Was the token found?
|
266
|
+
*/
|
267
|
+
JSDOC.TokenReader.prototype.read_hex = function(/**JSDOC.TokenStream*/stream, tokens) {
|
268
|
+
var found = stream.next(2);
|
269
|
+
|
270
|
+
while (!stream.look().eof) {
|
271
|
+
if (JSDOC.Lang.isHexDec(found) && !JSDOC.Lang.isHexDec(found+stream.look())) { // done
|
272
|
+
tokens.push(new JSDOC.Token(found, "NUMB", "HEX_DEC"));
|
273
|
+
return true;
|
274
|
+
}
|
275
|
+
else {
|
276
|
+
found += stream.next();
|
277
|
+
}
|
278
|
+
}
|
279
|
+
return false;
|
280
|
+
}
|
281
|
+
|
282
|
+
/**
|
283
|
+
@returns {Boolean} Was the token found?
|
284
|
+
*/
|
285
|
+
JSDOC.TokenReader.prototype.read_regx = function(/**JSDOC.TokenStream*/stream, tokens) {
|
286
|
+
if (
|
287
|
+
stream.look() == "/"
|
288
|
+
&&
|
289
|
+
(
|
290
|
+
!tokens.last()
|
291
|
+
||
|
292
|
+
(
|
293
|
+
!tokens.last().is("NUMB")
|
294
|
+
&& !tokens.last().is("NAME")
|
295
|
+
&& !tokens.last().is("RIGHT_PAREN")
|
296
|
+
&& !tokens.last().is("RIGHT_BRACKET")
|
297
|
+
)
|
298
|
+
)
|
299
|
+
) {
|
300
|
+
var regex = stream.next();
|
301
|
+
|
302
|
+
while (!stream.look().eof) {
|
303
|
+
if (stream.look() == "\\") { // escape sequence
|
304
|
+
regex += stream.next(2);
|
305
|
+
}
|
306
|
+
else if (stream.look() == "/") {
|
307
|
+
regex += stream.next();
|
308
|
+
|
309
|
+
while (/[gmi]/.test(stream.look())) {
|
310
|
+
regex += stream.next();
|
311
|
+
}
|
312
|
+
|
313
|
+
tokens.push(new JSDOC.Token(regex, "REGX", "REGX"));
|
314
|
+
return true;
|
315
|
+
}
|
316
|
+
else {
|
317
|
+
regex += stream.next();
|
318
|
+
}
|
319
|
+
}
|
320
|
+
// error: unterminated regex
|
321
|
+
}
|
322
|
+
return false;
|
323
|
+
}
|