SourceElement constructor
SourceElement(
- SourceElementType type,
- String name,
- int startPos, {
- required File file,
- String className = '',
- List<
SourceLine> ? comment, - int startLine = -1,
- List<
CodeSample> ? samples, - bool override = false,
A factory constructor for SourceElements.
This uses a factory so that the default for the comment
and samples
lists can be modifiable lists.
Implementation
factory SourceElement(
SourceElementType type,
String name,
int startPos, {
required File file,
String className = '',
List<SourceLine>? comment,
int startLine = -1,
List<CodeSample>? samples,
bool override = false,
}) {
comment ??= <SourceLine>[];
samples ??= <CodeSample>[];
final List<String> commentLines =
comment.map<String>((SourceLine line) => line.text).toList();
final String commentString = commentLines.join('\n');
return SourceElement._(
type,
name,
startPos,
file: file,
className: className,
comment: comment,
startLine: startLine,
samples: samples,
override: override,
commentString: commentString,
commentStringWithoutTools: _getCommentStringWithoutTools(commentString),
commentStringWithoutCode: _getCommentStringWithoutCode(commentString),
commentLines: commentLines,
);
}