in lib/parameter_popup.dart [71:131]
void _lookupParameterInfo() {
var offset = editor.document.indexFromPos(editor.document.cursor);
final source = editor.document.value;
var parInfo = _parameterInfo(source, offset);
if (parInfo == null) {
remove();
return;
}
final openingParenIndex = parInfo['openingParenIndex']!;
final parameterIndex = parInfo['parameterIndex'];
offset = openingParenIndex - 1;
// We request documentation info of what is before the parenthesis.
final input = SourceRequest()
..source = source
..offset = offset;
dartServices
.document(input)
.timeout(serviceCallTimeout)
.then((DocumentResponse result) {
if (!result.info.containsKey('parameters')) {
remove();
return;
}
final parameterInfo = result.info['parameters']!;
var outputString = '';
if (parameterInfo.isEmpty) {
outputString += '<code><no parameters></code>';
} else if (parameterInfo.length < parameterIndex! + 1) {
outputString += '<code>too many parameters listed</code>';
} else {
outputString += '<code>';
for (var i = 0; i < parameterInfo.length; i++) {
if (i == parameterIndex) {
outputString += '<em>${sanitizer.convert(parameterInfo[i])}</em>';
} else {
outputString +=
'<span>${sanitizer.convert(parameterInfo[i])}</span>';
}
if (i != parameterInfo.length - 1) {
outputString += ', ';
}
}
outputString += '</code>';
}
// Check if cursor is still in parameter position
parInfo = _parameterInfo(editor.document.value,
editor.document.indexFromPos(editor.document.cursor));
if (parInfo == null) {
remove();
return;
}
_showParameterPopup(outputString, offset);
});
}