refactor: use private constructors with internal classes

This commit is contained in:
Aleksey Kulikov 2022-04-22 14:39:13 +03:00
parent 77a34c3335
commit 2ceead3917
7 changed files with 19 additions and 19 deletions

View file

@ -83,7 +83,7 @@ class Blame with IterableMixin<BlameHunk> {
///
/// Throws [RangeError] if index out of range.
BlameHunk operator [](int index) {
return BlameHunk(
return BlameHunk._(
bindings.getHunkByIndex(
blamePointer: _blamePointer,
index: index,
@ -96,7 +96,7 @@ class Blame with IterableMixin<BlameHunk> {
///
/// Throws [RangeError] if [lineNumber] is out of range.
BlameHunk forLine(int lineNumber) {
return BlameHunk(
return BlameHunk._(
bindings.getHunkByLine(
blamePointer: _blamePointer,
lineNumber: lineNumber,
@ -123,7 +123,7 @@ final _finalizer = Finalizer<Pointer<git_blame>>(
class BlameHunk {
/// Initializes a new instance of the [BlameHunk] class from
/// provided pointer to blame hunk object in memory.
const BlameHunk(this._blameHunkPointer);
const BlameHunk._(this._blameHunkPointer);
/// Pointer to memory address for allocated blame hunk object.
final Pointer<git_blame_hunk> _blameHunkPointer;
@ -203,7 +203,7 @@ class _BlameIterator implements Iterator<BlameHunk> {
if (index == count) {
return false;
} else {
currentHunk = BlameHunk(
currentHunk = BlameHunk._(
bindings.getHunkByIndex(
blamePointer: _blamePointer,
index: index,

View file

@ -498,10 +498,10 @@ class DiffDelta {
int get numberOfFiles => _diffDeltaPointer.ref.nfiles;
/// Represents the "from" side of the diff.
DiffFile get oldFile => DiffFile(_diffDeltaPointer.ref.old_file);
DiffFile get oldFile => DiffFile._(_diffDeltaPointer.ref.old_file);
/// Represents the "to" side of the diff.
DiffFile get newFile => DiffFile(_diffDeltaPointer.ref.new_file);
DiffFile get newFile => DiffFile._(_diffDeltaPointer.ref.new_file);
@override
String toString() {
@ -518,7 +518,7 @@ class DiffDelta {
class DiffFile {
/// Initializes a new instance of [DiffFile] class from provided diff file
/// object.
const DiffFile(this._diffFile);
const DiffFile._(this._diffFile);
final git_diff_file _diffFile;

View file

@ -60,7 +60,7 @@ class Odb {
///
/// Throws a [LibGit2Error] if error occured.
OdbObject read(Oid oid) {
return OdbObject(
return OdbObject._(
bindings.read(
odbPointer: _odbPointer,
oidPointer: oid.pointer,
@ -108,7 +108,7 @@ final _finalizer = Finalizer<Pointer<git_odb>>(
class OdbObject {
/// Initializes a new instance of the [OdbObject] class from
/// provided pointer to odbObject object in memory.
OdbObject(this._odbObjectPointer) {
OdbObject._(this._odbObjectPointer) {
_objectfinalizer.attach(this, _odbObjectPointer, detach: this);
}

View file

@ -154,7 +154,7 @@ class Patch {
PatchStats get stats {
final result = bindings.lineStats(_patchPointer);
return PatchStats(
return PatchStats._(
context: result['context']!,
insertions: result['insertions']!,
deletions: result['deletions']!,
@ -266,7 +266,7 @@ final _finalizer = Finalizer<Pointer<git_patch>>(
/// Line counts of each type in a patch.
class PatchStats {
const PatchStats({
const PatchStats._({
required this.context,
required this.insertions,
required this.deletions,

View file

@ -55,7 +55,7 @@ class Rebase {
rebase: _rebasePointer,
index: i,
);
result.add(RebaseOperation(operation));
result.add(RebaseOperation._(operation));
}
return result;
@ -99,7 +99,7 @@ class Rebase {
///
/// Throws a [LibGit2Error] if error occured.
RebaseOperation next() {
return RebaseOperation(bindings.next(_rebasePointer));
return RebaseOperation._(bindings.next(_rebasePointer));
}
/// Commits the current patch. You must have resolved any conflicts that were
@ -151,7 +151,7 @@ final _finalizer = Finalizer<Pointer<git_rebase>>(
class RebaseOperation {
/// Initializes a new instance of the [RebaseOperation] class from
/// provided pointer to rebase operation object in memory.
const RebaseOperation(this._rebaseOperationPointer);
const RebaseOperation._(this._rebaseOperationPointer);
/// Pointer to memory address for allocated rebase operation object.
final Pointer<git_rebase_operation> _rebaseOperationPointer;

View file

@ -46,7 +46,7 @@ class RefLog with IterableMixin<RefLogEntry> {
/// Requesting the reflog entry with an index of 0 will return the most
/// recently created entry.
RefLogEntry operator [](int index) {
return RefLogEntry(
return RefLogEntry._(
bindings.getByIndex(
reflogPointer: _reflogPointer,
index: index,
@ -106,7 +106,7 @@ final _finalizer = Finalizer<Pointer<git_reflog>>(
class RefLogEntry {
/// Initializes a new instance of [RefLogEntry] class from provided
/// pointer to RefLogEntry object in memory.
const RefLogEntry(this._entryPointer);
const RefLogEntry._(this._entryPointer);
/// Pointer to memory address for allocated reflog entry object.
final Pointer<git_reflog_entry> _entryPointer;
@ -149,7 +149,7 @@ class _RefLogIterator implements Iterator<RefLogEntry> {
if (_index == _count) {
return false;
} else {
_currentEntry = RefLogEntry(
_currentEntry = RefLogEntry._(
bindings.getByIndex(
reflogPointer: _reflogPointer,
index: _index,

View file

@ -75,7 +75,7 @@ class RevParse {
///
/// Throws a [LibGit2Error] if error occured.
static RevSpec range({required Repository repo, required String spec}) {
return RevSpec(
return RevSpec._(
bindings.revParse(
repoPointer: repo.pointer,
spec: spec,
@ -92,7 +92,7 @@ class RevParse {
class RevSpec {
/// Initializes a new instance of [RevSpec] class from provided
/// pointer to revspec object in memory.
const RevSpec(this._revSpecPointer);
const RevSpec._(this._revSpecPointer);
/// Pointer to memory address for allocated revspec object.
final Pointer<git_revspec> _revSpecPointer;