vscode-json-languageservice
Advanced tools
Comparing version 3.4.8 to 3.4.9
@@ -48,31 +48,42 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
var collectOutlineEntries = function (result, node, containerName) { | ||
if (limit >= 0) { | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node) { return collectOutlineEntries(result, node, containerName); }); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
if (limit >= 0) { | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
limit--; | ||
var location = Location.create(document.uri, getRange(document, property)); | ||
var childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value; | ||
result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName }); | ||
collectOutlineEntries(result, valueNode, childContainerName); | ||
} | ||
var toVisit = [ | ||
{ node: root, containerName: '' } | ||
]; | ||
var nextToVisit = 0; | ||
var limitExceeded = false; | ||
var result = []; | ||
var collectOutlineEntries = function (node, containerName) { | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node) { | ||
if (node) { | ||
toVisit.push({ node: node, containerName: containerName }); | ||
} | ||
}); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
if (limit > 0) { | ||
limit--; | ||
var location = Location.create(document.uri, getRange(document, property)); | ||
var childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value; | ||
result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName }); | ||
toVisit.push({ node: valueNode, containerName: childContainerName }); | ||
} | ||
}); | ||
} | ||
else { | ||
limitExceeded = true; | ||
} | ||
} | ||
}); | ||
} | ||
return result; | ||
}; | ||
var result = collectOutlineEntries([], root, void 0); | ||
if (limit < 0) { | ||
result.pop(); | ||
if (context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
// breath first traversal | ||
while (nextToVisit < toVisit.length) { | ||
var next = toVisit[nextToVisit++]; | ||
collectOutlineEntries(next.node, next.containerName); | ||
} | ||
if (limitExceeded && context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
return result; | ||
@@ -116,7 +127,13 @@ }; | ||
} | ||
var collectOutlineEntries = function (result, node) { | ||
if (limit >= 0) { // collect one more to know that limit got exceeded | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node, index) { | ||
if (node && limit >= 0) { | ||
var result = []; | ||
var toVisit = [ | ||
{ node: root, result: result } | ||
]; | ||
var nextToVisit = 0; | ||
var limitExceeded = false; | ||
var collectOutlineEntries = function (node, result) { | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node, index) { | ||
if (node) { | ||
if (limit > 0) { | ||
limit--; | ||
@@ -126,29 +143,39 @@ var range = getRange(document, node); | ||
var name = String(index); | ||
var children = collectOutlineEntries([], node); | ||
result.push({ name: name, kind: _this.getSymbolKind(node.type), range: range, selectionRange: selectionRange, children: children }); | ||
var symbol = { name: name, kind: _this.getSymbolKind(node.type), range: range, selectionRange: selectionRange, children: [] }; | ||
result.push(symbol); | ||
toVisit.push({ result: symbol.children, node: node }); | ||
} | ||
}); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
var valueNode = property.valueNode; | ||
if (valueNode && limit >= 0) { | ||
else { | ||
limitExceeded = true; | ||
} | ||
} | ||
}); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
if (limit > 0) { | ||
limit--; | ||
var range = getRange(document, property); | ||
var selectionRange = getRange(document, property.keyNode); | ||
var children = collectOutlineEntries([], valueNode); | ||
result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: children }); | ||
var symbol = { name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: [] }; | ||
result.push(symbol); | ||
toVisit.push({ result: symbol.children, node: valueNode }); | ||
} | ||
}); | ||
} | ||
else { | ||
limitExceeded = true; | ||
} | ||
} | ||
}); | ||
} | ||
return result; | ||
}; | ||
var result = collectOutlineEntries([], root); | ||
if (limit < 0) { | ||
result.pop(); | ||
if (context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
// breath first traversal | ||
while (nextToVisit < toVisit.length) { | ||
var next = toVisit[nextToVisit++]; | ||
collectOutlineEntries(next.node, next.result); | ||
} | ||
if (limitExceeded && context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
return result; | ||
@@ -155,0 +182,0 @@ }; |
@@ -59,31 +59,42 @@ /*--------------------------------------------------------------------------------------------- | ||
} | ||
var collectOutlineEntries = function (result, node, containerName) { | ||
if (limit >= 0) { | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node) { return collectOutlineEntries(result, node, containerName); }); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
if (limit >= 0) { | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
limit--; | ||
var location = jsonLanguageTypes_1.Location.create(document.uri, getRange(document, property)); | ||
var childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value; | ||
result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName }); | ||
collectOutlineEntries(result, valueNode, childContainerName); | ||
} | ||
var toVisit = [ | ||
{ node: root, containerName: '' } | ||
]; | ||
var nextToVisit = 0; | ||
var limitExceeded = false; | ||
var result = []; | ||
var collectOutlineEntries = function (node, containerName) { | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node) { | ||
if (node) { | ||
toVisit.push({ node: node, containerName: containerName }); | ||
} | ||
}); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
if (limit > 0) { | ||
limit--; | ||
var location = jsonLanguageTypes_1.Location.create(document.uri, getRange(document, property)); | ||
var childContainerName = containerName ? containerName + '.' + property.keyNode.value : property.keyNode.value; | ||
result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), location: location, containerName: containerName }); | ||
toVisit.push({ node: valueNode, containerName: childContainerName }); | ||
} | ||
}); | ||
} | ||
else { | ||
limitExceeded = true; | ||
} | ||
} | ||
}); | ||
} | ||
return result; | ||
}; | ||
var result = collectOutlineEntries([], root, void 0); | ||
if (limit < 0) { | ||
result.pop(); | ||
if (context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
// breath first traversal | ||
while (nextToVisit < toVisit.length) { | ||
var next = toVisit[nextToVisit++]; | ||
collectOutlineEntries(next.node, next.containerName); | ||
} | ||
if (limitExceeded && context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
return result; | ||
@@ -127,7 +138,13 @@ }; | ||
} | ||
var collectOutlineEntries = function (result, node) { | ||
if (limit >= 0) { // collect one more to know that limit got exceeded | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node, index) { | ||
if (node && limit >= 0) { | ||
var result = []; | ||
var toVisit = [ | ||
{ node: root, result: result } | ||
]; | ||
var nextToVisit = 0; | ||
var limitExceeded = false; | ||
var collectOutlineEntries = function (node, result) { | ||
if (node.type === 'array') { | ||
node.items.forEach(function (node, index) { | ||
if (node) { | ||
if (limit > 0) { | ||
limit--; | ||
@@ -137,29 +154,39 @@ var range = getRange(document, node); | ||
var name = String(index); | ||
var children = collectOutlineEntries([], node); | ||
result.push({ name: name, kind: _this.getSymbolKind(node.type), range: range, selectionRange: selectionRange, children: children }); | ||
var symbol = { name: name, kind: _this.getSymbolKind(node.type), range: range, selectionRange: selectionRange, children: [] }; | ||
result.push(symbol); | ||
toVisit.push({ result: symbol.children, node: node }); | ||
} | ||
}); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
var valueNode = property.valueNode; | ||
if (valueNode && limit >= 0) { | ||
else { | ||
limitExceeded = true; | ||
} | ||
} | ||
}); | ||
} | ||
else if (node.type === 'object') { | ||
node.properties.forEach(function (property) { | ||
var valueNode = property.valueNode; | ||
if (valueNode) { | ||
if (limit > 0) { | ||
limit--; | ||
var range = getRange(document, property); | ||
var selectionRange = getRange(document, property.keyNode); | ||
var children = collectOutlineEntries([], valueNode); | ||
result.push({ name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: children }); | ||
var symbol = { name: _this.getKeyLabel(property), kind: _this.getSymbolKind(valueNode.type), range: range, selectionRange: selectionRange, children: [] }; | ||
result.push(symbol); | ||
toVisit.push({ result: symbol.children, node: valueNode }); | ||
} | ||
}); | ||
} | ||
else { | ||
limitExceeded = true; | ||
} | ||
} | ||
}); | ||
} | ||
return result; | ||
}; | ||
var result = collectOutlineEntries([], root); | ||
if (limit < 0) { | ||
result.pop(); | ||
if (context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
// breath first traversal | ||
while (nextToVisit < toVisit.length) { | ||
var next = toVisit[nextToVisit++]; | ||
collectOutlineEntries(next.node, next.result); | ||
} | ||
if (limitExceeded && context && context.onResultLimitExceeded) { | ||
context.onResultLimitExceeded(resourceString); | ||
} | ||
return result; | ||
@@ -166,0 +193,0 @@ }; |
{ | ||
"name": "vscode-json-languageservice", | ||
"version": "3.4.8", | ||
"version": "3.4.9", | ||
"description": "Language service for JSON", | ||
@@ -5,0 +5,0 @@ "main": "./lib/umd/jsonLanguageService.js", |
476235
9200