Here is the best way I've found. I hope there will be a better way.
First check if there is a default value:
bool hasDefaultValue = _parameter.defaultValueRange != null && _parameter.defaultValueRange != SourceRange.EMPTY;
Then you can use ParameterElement defaultValueRange .
SourceRange range = _parameter.defaultValueRange; return _parameter.source.contents.data.substring(range.offset, range.end);
In English:
Get the data source item of the source content.
source share