Skip to content

Commit c00d882

Browse files
committed
Add outline.outlineSync()
1 parent af83ccb commit c00d882

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

plugins-client/ext.jslanguage/outline.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ outlineHandler.handlesLanguage = function(language) {
2626
outlineHandler.outline = function(doc, ast, callback) {
2727
if (!ast)
2828
return callback();
29-
callback({ body : extractOutline(doc, ast) });
29+
callback({ body : outlineSync(doc, ast) });
3030
};
3131

3232
function fargsToString(fargs) {
@@ -87,7 +87,7 @@ function fixStringPos(doc, node) {
8787
}
8888

8989
// This is where the fun stuff happens
90-
function extractOutline(doc, node) {
90+
var outlineSync = outlineHandler.outlineSync = function(doc, node) {
9191
var results = [];
9292
node.traverseTopDown(
9393
// e.x = function(...) { ... } -> name is x
@@ -99,7 +99,7 @@ function extractOutline(doc, node) {
9999
name: name + fargsToString(b.fargs),
100100
pos: this[1].getPos(),
101101
displayPos: b.e.cons === 'PropAccess' && getIdentifierPosBefore(doc, this[1].getPos()) || b.e.getPos(),
102-
items: extractOutline(doc, b.body)
102+
items: outlineSync(doc, b.body)
103103
});
104104
return this;
105105
},
@@ -110,7 +110,7 @@ function extractOutline(doc, node) {
110110
name: b.x.value + fargsToString(b.fargs),
111111
pos: this[1].getPos(),
112112
displayPos: b.x.getPos(),
113-
items: extractOutline(doc, b.body)
113+
items: outlineSync(doc, b.body)
114114
});
115115
return this;
116116
},
@@ -121,7 +121,7 @@ function extractOutline(doc, node) {
121121
name: b.x.value + fargsToString(b.fargs),
122122
pos: this[1].getPos(),
123123
displayPos: getIdentifierPosBefore(doc, this.getPos()),
124-
items: extractOutline(doc, b.body)
124+
items: outlineSync(doc, b.body)
125125
});
126126
return this;
127127
},
@@ -137,7 +137,7 @@ function extractOutline(doc, node) {
137137
},
138138
*/
139139
'VarDeclInit(x, e)', 'ConstDeclInit(x, e)', function(b) {
140-
var items = extractOutline(doc, b.e);
140+
var items = outlineSync(doc, b.e);
141141
if (items.length === 0)
142142
return this;
143143
results.push({
@@ -150,7 +150,7 @@ function extractOutline(doc, node) {
150150
return this;
151151
},
152152
'PropertyInit(x, e)', function(b) {
153-
var items = extractOutline(doc, b.e);
153+
var items = outlineSync(doc, b.e);
154154
if (items.length === 0)
155155
return this;
156156
results.push({
@@ -166,7 +166,7 @@ function extractOutline(doc, node) {
166166
var name = expressionToName(b.x);
167167
if (!name)
168168
return false;
169-
var items = extractOutline(doc, b.e);
169+
var items = outlineSync(doc, b.e);
170170
if (items.length === 0)
171171
return this;
172172
results.push({
@@ -188,7 +188,7 @@ function extractOutline(doc, node) {
188188
name: eventHandler.s[0].value,
189189
pos: this.getPos(),
190190
displayPos: fixStringPos(doc, eventHandler.s),
191-
items: eventHandler.body && extractOutline(doc, eventHandler.body)
191+
items: eventHandler.body && outlineSync(doc, eventHandler.body)
192192
});
193193
return this;
194194
},
@@ -207,7 +207,7 @@ function extractOutline(doc, node) {
207207
icon: 'method',
208208
name: name + '[callback]' + fargsToString(b.fargs),
209209
pos: this.getPos(),
210-
items: extractOutline(doc, b.body)
210+
items: outlineSync(doc, b.body)
211211
});
212212
foundFunction = true;
213213
}
@@ -223,13 +223,13 @@ function extractOutline(doc, node) {
223223
name: b.name.value + fargsToString(b.fargs),
224224
pos: this.getPos(),
225225
displayPos: b.name.getPos(),
226-
items: extractOutline(doc, b.body)
226+
items: outlineSync(doc, b.body)
227227
});
228228
return this;
229229
}
230230
);
231231
return results;
232-
}
232+
};
233233

234234
var tryExtractEventHandler = outlineHandler.tryExtractEventHandler = function(node, ignoreBind) {
235235
var result;

0 commit comments

Comments
 (0)