@Override public void annotationBoundary(AnnotationBoundaryMap map) { int changeSize = map.changeSize(); for (int i = 0; i < changeSize; ++i) { startAnnotation(map.getChangeKey(i), map.getOldValue(i), map.getNewValue(i)); } int endSize = map.endSize(); for (int i = 0; i < endSize; ++i) { endAnnotation(map.getEndKey(i)); } }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { annotationUpdates = annotationUpdates.composeWith(map); for (int i = 0; i < map.changeSize(); i++) { knownAnnotationKeys.add(map.getChangeKey(i)); } }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { for (int i = 0; i < map.changeSize(); i++) { String key = map.getChangeKey(i); String oldValue = map.getOldValue(i); String newValue = map.getNewValue(i); if (!ValueUtils.equal(oldValue, newValue) && !key.startsWith(AnnotationConstants.USER_PREFIX) && !key.startsWith(AnnotationConstants.SPELLY_PREFIX) && !key.startsWith(AnnotationConstants.LINK_PREFIX) && !key.startsWith(AnnotationConstants.ROSY_PREFIX) && !key.startsWith(AnnotationConstants.LANGUAGE_PREFIX)) { throw TRUE; } } } };
@Override public String getEndKey(int endIndex) { return map.getEndKey(endIndex); }
@Override public String getOldValue(int changeIndex) { return map.getNewValue(changeIndex); }
@Override public String getNewValue(int changeIndex) { return map.getOldValue(changeIndex); }
@Override public int endSize() { return map.endSize(); }
@Override public int changeSize() { return map.changeSize(); }
@Override public String getChangeKey(int changeIndex) { return map.getChangeKey(changeIndex); }
void register(AnnotationBoundaryMap map) { for (int i = 0; i < map.endSize(); ++i) { tracked.remove(map.getEndKey(i)); } for (int i = 0; i < map.changeSize(); ++i) { tracked.put(map.getChangeKey(i), new ValueUpdate(map.getOldValue(i), map.getNewValue(i))); } process(map); }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { for (int i = 0; i < map.endSize(); i++) { b.endAnnotation(map.getEndKey(i)); } for (int i = 0; i < map.changeSize(); i++) { b.startAnnotation(map.getChangeKey(i), map.getNewValue(i)); } }
public static AnnotationBoundaryMap scrubAnnotationBoundary(AnnotationBoundaryMap unscrubbed, ScrubCache nameScrubber) { String[] ends = new String[unscrubbed.endSize()]; String[] changeTriplets = new String[unscrubbed.changeSize() * 3]; for (int i = 0; i < unscrubbed.endSize(); i++) { ends[i] = nameScrubber.scrubUniquely(unscrubbed.getEndKey(i)); } for (int i = 0; i < unscrubbed.changeSize(); i++) { changeTriplets[i * 3] = nameScrubber.scrubUniquely(unscrubbed.getChangeKey(i)); changeTriplets[i * 3 + 1] = scrubMostString(unscrubbed.getOldValue(i)); changeTriplets[i * 3 + 2] = scrubMostString(unscrubbed.getNewValue(i)); } return new UncheckedAnnotationBoundary(changeTriplets, ends); }
public int computeCost(AnnotationBoundaryMap map) { int accu = 0; for (int i = 0; i < map.changeSize(); i++) { accu += objectOverhead + computeCost(map.getChangeKey(i)) + computeCostNullable(map.getOldValue(i)) + computeCostNullable(map.getNewValue(i)); } for (int i = 0; i < map.endSize(); i++) { accu += objectOverhead + computeCost(map.getEndKey(i)); } return accu; }
private boolean equal(AnnotationBoundaryMap a, AnnotationBoundaryMap b) { int changeSize = a.changeSize(); if (changeSize != b.changeSize()) { return false; } for (int i = 0; i < changeSize; ++i) { if (!equal(a.getChangeKey(i), b.getChangeKey(i))) { return false; } if (!equalNullable(a.getOldValue(i), b.getOldValue(i))) { return false; } if (!equalNullable(a.getNewValue(i), b.getNewValue(i))) { return false; } } int endSize = a.endSize(); if (endSize != b.endSize()) { return false; } for (int i = 0; i < endSize; ++i) { if (!equal(a.getEndKey(i), b.getEndKey(i))) { return false; } } return true; }
void commit(AnnotationBoundaryMap map) { for (int i = 0; i < map.endSize(); ++i) { String key = map.getEndKey(i); if (!propagating.containsKey(key)) { propagating.put(key, active.get(key)); } active.remove(key); } for (int i = 0; i < map.changeSize(); ++i) { String key = map.getChangeKey(i); ValueUpdate oldActive = active.get(key); if (oldActive == null || !ValueUtils.equal(oldActive.oldValue, map.getOldValue(i)) || !ValueUtils.equal(oldActive.newValue, map.getNewValue(i))) { if (!propagating.containsKey(key)) { propagating.put(key, active.get(key)); } active.put(key, new ValueUpdate(map.getOldValue(i), map.getNewValue(i))); } } output.annotationBoundary(map); }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { for (int i = 0; i < map.endSize(); ++i) { activeAnnotations.remove(map.getEndKey(i)); } for (int i = 0; i < map.changeSize(); ++i) { activeAnnotations.add(map.getChangeKey(i)); } }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { for (int i = 0; i < map.endSize(); ++i) { activeAnnotations.remove(map.getEndKey(i)); } for (int i = 0; i < map.changeSize(); ++i) { activeAnnotations.add(map.getChangeKey(i)); } }
public static String toConciseString(AnnotationBoundaryMap map) { StringBuilder b = new StringBuilder(); b.append("{ "); boolean notEmpty = false; for (int i = 0; i < map.endSize(); ++i) { if (notEmpty) { b.append(", "); } else { notEmpty = true; } b.append(literalString(map.getEndKey(i))); } for (int i = 0; i < map.changeSize(); ++i) { if (notEmpty) { b.append(", "); } else { notEmpty = true; } b.append(literalString(map.getChangeKey(i))); b.append(": "); b.append(literalString(map.getOldValue(i))); b.append(" -> "); b.append(literalString(map.getNewValue(i))); } b.append(" }"); return notEmpty ? b.toString() : "{}"; }
@Override public void annotationBoundary(AnnotationBoundaryMap map) { ProtocolDocumentOperation.Component.AnnotationBoundary.Builder a = ProtocolDocumentOperation.Component.AnnotationBoundary.newBuilder(); if (map.endSize() == 0 && map.changeSize() == 0) { a.setEmpty(true); } else { for (int i = 0; i < map.endSize(); i++) { a.addEnd(map.getEndKey(i)); } for (int i = 0; i < map.changeSize(); i++) { a.addChange(makeKeyValueUpdate( map.getChangeKey(i), map.getOldValue(i), map.getNewValue(i))); } } output.addComponent(newComponentBuilder().setAnnotationBoundary(a.build()).build()); }
List<String> changeOldValues = new ArrayList<String>(); List<String> changeNewValues = new ArrayList<String>(); for (int i = 0; i < map.endSize(); ++i) { String key = map.getEndKey(i); ValueUpdate postValues = postAnnotations.get(key); if (postValues != null) { for (int i = 0; i < map.changeSize(); ++i) { String key = map.getChangeKey(i); String oldValue = map.getOldValue(i); String newValue = map.getNewValue(i); ValueUpdate postValues = postAnnotations.get(key); changeKeys.add(key);