mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 780791 - WebConsole autocompletion doesn't autocomplete on string literals; r=msucan
This commit is contained in:
parent
4de57b3515
commit
6bd78774af
@ -909,48 +909,63 @@ function JSPropertyProvider(aScope, aInputValue)
|
||||
return null;
|
||||
}
|
||||
|
||||
let properties = completionPart.split(".");
|
||||
let matchProp;
|
||||
if (properties.length > 1) {
|
||||
matchProp = properties.pop().trimLeft();
|
||||
for (let i = 0; i < properties.length; i++) {
|
||||
let prop = properties[i].trim();
|
||||
if (!prop) {
|
||||
return null;
|
||||
}
|
||||
let matches = null;
|
||||
let matchProp = "";
|
||||
|
||||
// If obj is undefined or null (which is what "== null" does),
|
||||
// then there is no chance to run completion on it. Exit here.
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
let lastDot = completionPart.lastIndexOf(".");
|
||||
if (lastDot > 0 &&
|
||||
(completionPart[0] == "'" || completionPart[0] == '"') &&
|
||||
completionPart[lastDot - 1] == completionPart[0]) {
|
||||
// We are completing a string literal.
|
||||
obj = obj.String.prototype;
|
||||
matchProp = completionPart.slice(lastDot + 1);
|
||||
|
||||
// Check if prop is a getter function on obj. Functions can change other
|
||||
// stuff so we can't execute them to get the next object. Stop here.
|
||||
if (WCU.isNonNativeGetter(obj, prop)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
obj = obj[prop];
|
||||
}
|
||||
catch (ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
matchProp = properties[0].trimLeft();
|
||||
}
|
||||
// We are completing a variable / a property lookup.
|
||||
|
||||
// If obj is undefined or null (which is what "== null" does),
|
||||
// then there is no chance to run completion on it. Exit here.
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
let properties = completionPart.split(".");
|
||||
if (properties.length > 1) {
|
||||
matchProp = properties.pop().trimLeft();
|
||||
for (let i = 0; i < properties.length; i++) {
|
||||
let prop = properties[i].trim();
|
||||
if (!prop) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Skip Iterators and Generators.
|
||||
if (WCU.isIteratorOrGenerator(obj)) {
|
||||
return null;
|
||||
// If obj is undefined or null (which is what "== null" does),
|
||||
// then there is no chance to run completion on it. Exit here.
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Check if prop is a getter function on obj. Functions can change other
|
||||
// stuff so we can't execute them to get the next object. Stop here.
|
||||
if (WCU.isNonNativeGetter(obj, prop)) {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
obj = obj[prop];
|
||||
}
|
||||
catch (ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
matchProp = properties[0].trimLeft();
|
||||
}
|
||||
|
||||
// If obj is undefined or null (which is what "== null" does),
|
||||
// then there is no chance to run completion on it. Exit here.
|
||||
if (obj == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Skip Iterators and Generators.
|
||||
if (WCU.isIteratorOrGenerator(obj)) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
let matches = Object.keys(getMatchedProps(obj, {matchProp:matchProp}));
|
||||
|
@ -105,6 +105,13 @@ function testCompletion(hud) {
|
||||
|
||||
is(jsterm.completeNode.value, " ice", "non-object completion");
|
||||
|
||||
// Test string literal autocompletion.
|
||||
input.value = "'Asimov'.sl";
|
||||
jsterm.complete(jsterm.COMPLETE_HINT_ONLY, testNext);
|
||||
yield;
|
||||
|
||||
is(jsterm.completeNode.value, " ice", "string literal completion");
|
||||
|
||||
testDriver = jsterm = input = null;
|
||||
executeSoon(finishTest);
|
||||
yield;
|
||||
|
Loading…
Reference in New Issue
Block a user