当前位置: 首页>>代码示例>>Java>>正文


Java Edit.getEndB方法代码示例

本文整理汇总了Java中org.eclipse.jgit.diff.Edit.getEndB方法的典型用法代码示例。如果您正苦于以下问题:Java Edit.getEndB方法的具体用法?Java Edit.getEndB怎么用?Java Edit.getEndB使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.jgit.diff.Edit的用法示例。


在下文中一共展示了Edit.getEndB方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:PatchScriptBuilder.java

示例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());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:26,代码来源:PatchScriptBuilder.java

示例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);
}
 
开发者ID:mast-group,项目名称:naturalize,代码行数:33,代码来源:ChangingIdentifiersRepositoryWalker.java

示例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++;
  }
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:31,代码来源:IntraLineLoader.java

示例5: transformEdits

import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private static List<ContextAwareEdit> transformEdits(
    SideStrategy sideStrategy,
    List<ContextAwareEdit> unorderedOriginalEdits,
    List<Edit> unorderedTransformingEdits,
    String adjustedFilePath) {
  List<ContextAwareEdit> originalEdits = new ArrayList<>(unorderedOriginalEdits);
  originalEdits.sort(comparing(sideStrategy::getBegin).thenComparing(sideStrategy::getEnd));
  List<Edit> transformingEdits = new ArrayList<>(unorderedTransformingEdits);
  transformingEdits.sort(comparing(Edit::getBeginA).thenComparing(Edit::getEndA));

  int shiftedAmount = 0;
  int transIndex = 0;
  int origIndex = 0;
  List<ContextAwareEdit> resultingEdits = new ArrayList<>(originalEdits.size());
  while (origIndex < originalEdits.size() && transIndex < transformingEdits.size()) {
    ContextAwareEdit originalEdit = originalEdits.get(origIndex);
    Edit transformingEdit = transformingEdits.get(transIndex);
    if (transformingEdit.getEndA() < sideStrategy.getBegin(originalEdit)) {
      shiftedAmount = transformingEdit.getEndB() - transformingEdit.getEndA();
      transIndex++;
    } else if (sideStrategy.getEnd(originalEdit) < transformingEdit.getBeginA()) {
      resultingEdits.add(sideStrategy.create(originalEdit, shiftedAmount, adjustedFilePath));
      origIndex++;
    } else {
      // Overlapping -> ignore.
      origIndex++;
    }
  }
  for (int i = origIndex; i < originalEdits.size(); i++) {
    resultingEdits.add(
        sideStrategy.create(originalEdits.get(i), shiftedAmount, adjustedFilePath));
  }
  return resultingEdits;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:35,代码来源:EditTransformer.java

示例6: 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);
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:14,代码来源:PatchScriptBuilder.java

示例7: 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;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:39,代码来源:GetDiff.java

示例8: 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);
    }
}
 
开发者ID:kiegroup,项目名称:appformer,代码行数:35,代码来源:DiffBranches.java

示例9: 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;
}
 
开发者ID:mast-group,项目名称:commitmining-tools,代码行数:20,代码来源:EditListRetriever.java

示例10: 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);
	}
}
 
开发者ID:markus1978,项目名称:srcrepo,代码行数:33,代码来源:GitSourceControlSystem.java

示例11: in

import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private boolean in(Edit edit) {
  return aCur < edit.getEndA() || bCur < edit.getEndB();
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:EditList.java

示例12: 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;
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:51,代码来源:PatchListEntry.java

示例13: 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());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:7,代码来源:IntraLineDiff.java

示例14: 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());
}
 
开发者ID:gerrit-review,项目名称:gerrit,代码行数:4,代码来源:IntraLineDiffArgs.java

示例15: end

import org.eclipse.jgit.diff.Edit; //导入方法依赖的package包/类
private static boolean end(final Edit edit, final int a, final int b) {
    return edit.getEndA() <= a && edit.getEndB() <= b;
}
 
开发者ID:m4rzEE1,项目名称:ninja_chic-,代码行数:4,代码来源:LineContextDiffer.java


注:本文中的org.eclipse.jgit.diff.Edit.getEndB方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。