本文整理汇总了Java中org.eclipse.jgit.diff.Edit.getBeginB方法的典型用法代码示例。如果您正苦于以下问题:Java Edit.getBeginB方法的具体用法?Java Edit.getBeginB怎么用?Java Edit.getBeginB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jgit.diff.Edit
的用法示例。
在下文中一共展示了Edit.getBeginB方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mapA2B
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private int mapA2B(int a) {
if (edits.isEmpty()) {
// Magic special case of an unmodified file.
//
return a;
}
for (int i = 0; i < edits.size(); i++) {
final Edit e = edits.get(i);
if (a < e.getBeginA()) {
if (i == 0) {
// Special case of context at start of file.
//
return a;
}
return e.getBeginB() - (e.getBeginA() - a);
}
if (e.getBeginA() <= a && a <= e.getEndA()) {
return -1;
}
}
final Edit last = edits.get(edits.size() - 1);
return last.getEndB() + (a - last.getEndA());
}
示例2: mapB2A
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private int mapB2A(int b) {
if (edits.isEmpty()) {
// Magic special case of an unmodified file.
//
return b;
}
for (int i = 0; i < edits.size(); i++) {
final Edit e = edits.get(i);
if (b < e.getBeginB()) {
if (i == 0) {
// Special case of context at start of file.
//
return b;
}
return e.getBeginA() - (e.getBeginB() - b);
}
if (e.getBeginB() <= b && b <= e.getEndB()) {
return -1;
}
}
final Edit last = edits.get(edits.size() - 1);
return last.getEndA() + (b - last.getEndB());
}
示例3: getNewLineGivenOld
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
/**
* Return a range of the possible line positions of the old line number in
* the new file.
*
* @param declarationLineNumber
* @param editList
* @return
*/
private Range<Integer> getNewLineGivenOld(final int oldLineNumber,
final EditList editList) {
int offsetAbove = 0;
for (final Edit edit : editList) {
if (edit.getBeginA() < oldLineNumber
&& edit.getEndA() < oldLineNumber) {
offsetAbove += -(edit.getEndA() - edit.getBeginA())
+ (edit.getEndB() - edit.getBeginB());
} else if (edit.getBeginA() <= oldLineNumber
&& edit.getEndA() >= oldLineNumber) {
// if it was in the old range, it is now in the new range
checkArgument(
edit.getBeginA() + offsetAbove == edit.getBeginB(),
"Beggining was %s but expected %s", edit.getBeginB(),
edit.getBeginA() + offsetAbove);
return Range.closed(edit.getBeginB(), edit.getEndB());
} else {
return Range.closed(oldLineNumber + offsetAbove, oldLineNumber
+ offsetAbove);
}
}
return Range.closed(oldLineNumber + offsetAbove, oldLineNumber
+ offsetAbove);
}
示例4: combineLineEdits
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private static void combineLineEdits(List<Edit> edits, Text a, Text b) {
for (int j = 0; j < edits.size() - 1; ) {
Edit c = edits.get(j);
Edit n = edits.get(j + 1);
// Combine edits that are really close together. Right now our rule
// is, coalesce two line edits which are only one line apart if that
// common context line is either a "pointless line", or is identical
// on both sides and starts a new block of code. These are mostly
// block reindents to add or remove control flow operators.
//
final int ad = n.getBeginA() - c.getEndA();
final int bd = n.getBeginB() - c.getEndB();
if ((1 <= ad && isBlankLineGap(a, c.getEndA(), n.getBeginA()))
|| (1 <= bd && isBlankLineGap(b, c.getEndB(), n.getBeginB()))
|| (ad == 1 && bd == 1 && isControlBlockStart(a, c.getEndA()))) {
int ab = c.getBeginA();
int ae = n.getEndA();
int bb = c.getBeginB();
int be = n.getEndB();
edits.set(j, new Edit(ab, ae, bb, be));
edits.remove(j + 1);
continue;
}
j++;
}
}
示例5: safeAdd
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private void safeAdd(List<Edit> empty, Edit toAdd) {
final int a = toAdd.getBeginA();
final int b = toAdd.getBeginB();
for (Edit e : edits) {
if (e.getBeginA() <= a && a <= e.getEndA()) {
return;
}
if (e.getBeginB() <= b && b <= e.getEndB()) {
return;
}
}
empty.add(toAdd);
}
示例6: addDiff
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
void addDiff(int endA, int endB, List<Edit> internalEdit, boolean dueToRebase) {
int lenA = endA - nextA;
int lenB = endB - nextB;
checkState(lenA > 0 || lenB > 0);
ContentEntry e = entry();
if (lenA > 0) {
e.a = Lists.newArrayListWithCapacity(lenA);
for (; nextA < endA; nextA++) {
e.a.add(fileA.get(nextA));
}
}
if (lenB > 0) {
e.b = Lists.newArrayListWithCapacity(lenB);
for (; nextB < endB; nextB++) {
e.b.add(fileB.get(nextB));
}
}
if (internalEdit != null && !internalEdit.isEmpty()) {
e.editA = Lists.newArrayListWithCapacity(internalEdit.size() * 2);
e.editB = Lists.newArrayListWithCapacity(internalEdit.size() * 2);
int lastA = 0;
int lastB = 0;
for (Edit edit : internalEdit) {
if (edit.getBeginA() != edit.getEndA()) {
e.editA.add(
ImmutableList.of(edit.getBeginA() - lastA, edit.getEndA() - edit.getBeginA()));
lastA = edit.getEndA();
}
if (edit.getBeginB() != edit.getEndB()) {
e.editB.add(
ImmutableList.of(edit.getBeginB() - lastB, edit.getEndB() - edit.getBeginB()));
lastB = edit.getEndB();
}
}
}
e.dueToRebase = dueToRebase ? true : null;
}
示例7: createFileDiff
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private FileDiff createFileDiff(final DiffEntry elem,
final FileHeader header,
final Edit edit) {
try {
final String changeType = header.getChangeType().toString();
final int startA = edit.getBeginA();
final int endA = edit.getEndA();
final int startB = edit.getBeginB();
final int endB = edit.getEndB();
String pathA = header.getOldPath();
String pathB = header.getNewPath();
final List<String> linesA = getLines(elem.getOldId().toObjectId(),
startA,
endA);
final List<String> linesB = getLines(elem.getNewId().toObjectId(),
startB,
endB);
return new FileDiff(pathA,
pathB,
startA,
endA,
startB,
endB,
changeType,
linesA,
linesB);
} catch (IOException e) {
throw new GitException("A problem occurred when trying to obtain diffs between files",
e);
}
}
示例8: getChangeChurn
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
/**
* Get the line change churn for the given edit list.
*
* @param editList
* @return
*/
public static long getChangeChurn(final EditList editList) {
long lineChurn = 0;
for (final Edit edit : editList) {
final int nALines = edit.getEndA() - edit.getBeginA();
final int nBLines = edit.getEndB() - edit.getBeginB();
if (nALines > nBLines) {
lineChurn += nALines;
} else {
lineChurn += nBLines;
}
}
return lineChurn;
}
示例9: createParentRelation
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private void createParentRelation(RepositoryModelFactory factory, Rev childModel, Rev parentModel, List<DiffEntry> diffs) {
ParentRelation parentRelationModel = factory.createParentRelation();
childModel.getParentRelations().add(parentRelationModel);
parentRelationModel.setParent(parentModel);
for (DiffEntry diffEntry : diffs) {
int linesAdded = 0;
int linesRemoved = 0;
try {
FileHeader fileHeader = df.toFileHeader(diffEntry);
for(HunkHeader hunk: fileHeader.getHunks()) {
for(Edit edit: hunk.toEditList()) {
linesAdded += edit.getEndB() - edit.getBeginB();
linesRemoved += edit.getEndA() - edit.getBeginA();
}
}
} catch (Exception e) {
linesAdded = -1;
linesRemoved = -1;
SrcRepoActivator.INSTANCE.warning("Could not determine added/removed lines for " + diffEntry, e);
}
Diff diffModel = null;
String path = diffEntry.getNewPath();
diffModel = factory.createDiff();
diffModel.setNewPath(path);
diffModel.setOldPath(diffEntry.getOldPath());
diffModel.setType(diffEntry.getChangeType());
diffModel.setLinesAdded(linesAdded);
diffModel.setLinesRemoved(linesRemoved);
parentRelationModel.getDiffs().add(diffModel);
}
}
示例10: PatchListEntry
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
PatchListEntry(
FileHeader hdr, List<Edit> editList, Set<Edit> editsDueToRebase, long size, long sizeDelta) {
changeType = toChangeType(hdr);
patchType = toPatchType(hdr);
switch (changeType) {
case DELETED:
oldName = null;
newName = hdr.getOldPath();
break;
case ADDED:
case MODIFIED:
case REWRITE:
oldName = null;
newName = hdr.getNewPath();
break;
case COPIED:
case RENAMED:
oldName = hdr.getOldPath();
newName = hdr.getNewPath();
break;
default:
throw new IllegalArgumentException("Unsupported type " + changeType);
}
header = compact(hdr);
if (hdr instanceof CombinedFileHeader || hdr.getHunks().isEmpty()) {
edits = ImmutableList.of();
} else {
edits = ImmutableList.copyOf(editList);
}
this.editsDueToRebase = ImmutableSet.copyOf(editsDueToRebase);
int ins = 0;
int del = 0;
for (Edit e : editList) {
if (!editsDueToRebase.contains(e)) {
del += e.getEndA() - e.getBeginA();
ins += e.getEndB() - e.getBeginB();
}
}
insertions = ins;
deletions = del;
this.size = size;
this.sizeDelta = sizeDelta;
}
示例11: copy
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private static Edit copy(Edit edit) {
if (edit instanceof ReplaceEdit) {
return copy((ReplaceEdit) edit);
}
return new Edit(edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB());
}
示例12: copy
import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private static Edit copy(Edit edit) {
return new Edit(edit.getBeginA(), edit.getEndA(), edit.getBeginB(), edit.getEndB());
}