mirror of
https://github.com/SkinnyMind/libgit2dart.git
synced 2025-05-04 20:29:08 -04:00
refactor: use private constructors with internal classes
This commit is contained in:
parent
77a34c3335
commit
2ceead3917
7 changed files with 19 additions and 19 deletions
|
@ -83,7 +83,7 @@ class Blame with IterableMixin<BlameHunk> {
|
||||||
///
|
///
|
||||||
/// Throws [RangeError] if index out of range.
|
/// Throws [RangeError] if index out of range.
|
||||||
BlameHunk operator [](int index) {
|
BlameHunk operator [](int index) {
|
||||||
return BlameHunk(
|
return BlameHunk._(
|
||||||
bindings.getHunkByIndex(
|
bindings.getHunkByIndex(
|
||||||
blamePointer: _blamePointer,
|
blamePointer: _blamePointer,
|
||||||
index: index,
|
index: index,
|
||||||
|
@ -96,7 +96,7 @@ class Blame with IterableMixin<BlameHunk> {
|
||||||
///
|
///
|
||||||
/// Throws [RangeError] if [lineNumber] is out of range.
|
/// Throws [RangeError] if [lineNumber] is out of range.
|
||||||
BlameHunk forLine(int lineNumber) {
|
BlameHunk forLine(int lineNumber) {
|
||||||
return BlameHunk(
|
return BlameHunk._(
|
||||||
bindings.getHunkByLine(
|
bindings.getHunkByLine(
|
||||||
blamePointer: _blamePointer,
|
blamePointer: _blamePointer,
|
||||||
lineNumber: lineNumber,
|
lineNumber: lineNumber,
|
||||||
|
@ -123,7 +123,7 @@ final _finalizer = Finalizer<Pointer<git_blame>>(
|
||||||
class BlameHunk {
|
class BlameHunk {
|
||||||
/// Initializes a new instance of the [BlameHunk] class from
|
/// Initializes a new instance of the [BlameHunk] class from
|
||||||
/// provided pointer to blame hunk object in memory.
|
/// 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.
|
/// Pointer to memory address for allocated blame hunk object.
|
||||||
final Pointer<git_blame_hunk> _blameHunkPointer;
|
final Pointer<git_blame_hunk> _blameHunkPointer;
|
||||||
|
@ -203,7 +203,7 @@ class _BlameIterator implements Iterator<BlameHunk> {
|
||||||
if (index == count) {
|
if (index == count) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
currentHunk = BlameHunk(
|
currentHunk = BlameHunk._(
|
||||||
bindings.getHunkByIndex(
|
bindings.getHunkByIndex(
|
||||||
blamePointer: _blamePointer,
|
blamePointer: _blamePointer,
|
||||||
index: index,
|
index: index,
|
||||||
|
|
|
@ -498,10 +498,10 @@ class DiffDelta {
|
||||||
int get numberOfFiles => _diffDeltaPointer.ref.nfiles;
|
int get numberOfFiles => _diffDeltaPointer.ref.nfiles;
|
||||||
|
|
||||||
/// Represents the "from" side of the diff.
|
/// 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.
|
/// Represents the "to" side of the diff.
|
||||||
DiffFile get newFile => DiffFile(_diffDeltaPointer.ref.new_file);
|
DiffFile get newFile => DiffFile._(_diffDeltaPointer.ref.new_file);
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String toString() {
|
String toString() {
|
||||||
|
@ -518,7 +518,7 @@ class DiffDelta {
|
||||||
class DiffFile {
|
class DiffFile {
|
||||||
/// Initializes a new instance of [DiffFile] class from provided diff file
|
/// Initializes a new instance of [DiffFile] class from provided diff file
|
||||||
/// object.
|
/// object.
|
||||||
const DiffFile(this._diffFile);
|
const DiffFile._(this._diffFile);
|
||||||
|
|
||||||
final git_diff_file _diffFile;
|
final git_diff_file _diffFile;
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,7 @@ class Odb {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
OdbObject read(Oid oid) {
|
OdbObject read(Oid oid) {
|
||||||
return OdbObject(
|
return OdbObject._(
|
||||||
bindings.read(
|
bindings.read(
|
||||||
odbPointer: _odbPointer,
|
odbPointer: _odbPointer,
|
||||||
oidPointer: oid.pointer,
|
oidPointer: oid.pointer,
|
||||||
|
@ -108,7 +108,7 @@ final _finalizer = Finalizer<Pointer<git_odb>>(
|
||||||
class OdbObject {
|
class OdbObject {
|
||||||
/// Initializes a new instance of the [OdbObject] class from
|
/// Initializes a new instance of the [OdbObject] class from
|
||||||
/// provided pointer to odbObject object in memory.
|
/// provided pointer to odbObject object in memory.
|
||||||
OdbObject(this._odbObjectPointer) {
|
OdbObject._(this._odbObjectPointer) {
|
||||||
_objectfinalizer.attach(this, _odbObjectPointer, detach: this);
|
_objectfinalizer.attach(this, _odbObjectPointer, detach: this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -154,7 +154,7 @@ class Patch {
|
||||||
PatchStats get stats {
|
PatchStats get stats {
|
||||||
final result = bindings.lineStats(_patchPointer);
|
final result = bindings.lineStats(_patchPointer);
|
||||||
|
|
||||||
return PatchStats(
|
return PatchStats._(
|
||||||
context: result['context']!,
|
context: result['context']!,
|
||||||
insertions: result['insertions']!,
|
insertions: result['insertions']!,
|
||||||
deletions: result['deletions']!,
|
deletions: result['deletions']!,
|
||||||
|
@ -266,7 +266,7 @@ final _finalizer = Finalizer<Pointer<git_patch>>(
|
||||||
|
|
||||||
/// Line counts of each type in a patch.
|
/// Line counts of each type in a patch.
|
||||||
class PatchStats {
|
class PatchStats {
|
||||||
const PatchStats({
|
const PatchStats._({
|
||||||
required this.context,
|
required this.context,
|
||||||
required this.insertions,
|
required this.insertions,
|
||||||
required this.deletions,
|
required this.deletions,
|
||||||
|
|
|
@ -55,7 +55,7 @@ class Rebase {
|
||||||
rebase: _rebasePointer,
|
rebase: _rebasePointer,
|
||||||
index: i,
|
index: i,
|
||||||
);
|
);
|
||||||
result.add(RebaseOperation(operation));
|
result.add(RebaseOperation._(operation));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
|
@ -99,7 +99,7 @@ class Rebase {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
RebaseOperation next() {
|
RebaseOperation next() {
|
||||||
return RebaseOperation(bindings.next(_rebasePointer));
|
return RebaseOperation._(bindings.next(_rebasePointer));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Commits the current patch. You must have resolved any conflicts that were
|
/// Commits the current patch. You must have resolved any conflicts that were
|
||||||
|
@ -151,7 +151,7 @@ final _finalizer = Finalizer<Pointer<git_rebase>>(
|
||||||
class RebaseOperation {
|
class RebaseOperation {
|
||||||
/// Initializes a new instance of the [RebaseOperation] class from
|
/// Initializes a new instance of the [RebaseOperation] class from
|
||||||
/// provided pointer to rebase operation object in memory.
|
/// 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.
|
/// Pointer to memory address for allocated rebase operation object.
|
||||||
final Pointer<git_rebase_operation> _rebaseOperationPointer;
|
final Pointer<git_rebase_operation> _rebaseOperationPointer;
|
||||||
|
|
|
@ -46,7 +46,7 @@ class RefLog with IterableMixin<RefLogEntry> {
|
||||||
/// Requesting the reflog entry with an index of 0 will return the most
|
/// Requesting the reflog entry with an index of 0 will return the most
|
||||||
/// recently created entry.
|
/// recently created entry.
|
||||||
RefLogEntry operator [](int index) {
|
RefLogEntry operator [](int index) {
|
||||||
return RefLogEntry(
|
return RefLogEntry._(
|
||||||
bindings.getByIndex(
|
bindings.getByIndex(
|
||||||
reflogPointer: _reflogPointer,
|
reflogPointer: _reflogPointer,
|
||||||
index: index,
|
index: index,
|
||||||
|
@ -106,7 +106,7 @@ final _finalizer = Finalizer<Pointer<git_reflog>>(
|
||||||
class RefLogEntry {
|
class RefLogEntry {
|
||||||
/// Initializes a new instance of [RefLogEntry] class from provided
|
/// Initializes a new instance of [RefLogEntry] class from provided
|
||||||
/// pointer to RefLogEntry object in memory.
|
/// pointer to RefLogEntry object in memory.
|
||||||
const RefLogEntry(this._entryPointer);
|
const RefLogEntry._(this._entryPointer);
|
||||||
|
|
||||||
/// Pointer to memory address for allocated reflog entry object.
|
/// Pointer to memory address for allocated reflog entry object.
|
||||||
final Pointer<git_reflog_entry> _entryPointer;
|
final Pointer<git_reflog_entry> _entryPointer;
|
||||||
|
@ -149,7 +149,7 @@ class _RefLogIterator implements Iterator<RefLogEntry> {
|
||||||
if (_index == _count) {
|
if (_index == _count) {
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
_currentEntry = RefLogEntry(
|
_currentEntry = RefLogEntry._(
|
||||||
bindings.getByIndex(
|
bindings.getByIndex(
|
||||||
reflogPointer: _reflogPointer,
|
reflogPointer: _reflogPointer,
|
||||||
index: _index,
|
index: _index,
|
||||||
|
|
|
@ -75,7 +75,7 @@ class RevParse {
|
||||||
///
|
///
|
||||||
/// Throws a [LibGit2Error] if error occured.
|
/// Throws a [LibGit2Error] if error occured.
|
||||||
static RevSpec range({required Repository repo, required String spec}) {
|
static RevSpec range({required Repository repo, required String spec}) {
|
||||||
return RevSpec(
|
return RevSpec._(
|
||||||
bindings.revParse(
|
bindings.revParse(
|
||||||
repoPointer: repo.pointer,
|
repoPointer: repo.pointer,
|
||||||
spec: spec,
|
spec: spec,
|
||||||
|
@ -92,7 +92,7 @@ class RevParse {
|
||||||
class RevSpec {
|
class RevSpec {
|
||||||
/// Initializes a new instance of [RevSpec] class from provided
|
/// Initializes a new instance of [RevSpec] class from provided
|
||||||
/// pointer to revspec object in memory.
|
/// pointer to revspec object in memory.
|
||||||
const RevSpec(this._revSpecPointer);
|
const RevSpec._(this._revSpecPointer);
|
||||||
|
|
||||||
/// Pointer to memory address for allocated revspec object.
|
/// Pointer to memory address for allocated revspec object.
|
||||||
final Pointer<git_revspec> _revSpecPointer;
|
final Pointer<git_revspec> _revSpecPointer;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue