Search in sources :

Example 1 with RangeInfo

use of com.google.gerrit.client.RangeInfo in project gerrit by GerritCodeReview.

the class Extras method setAnnotations.

public final void setAnnotations(JsArray<BlameInfo> blameInfos) {
    if (blameInfos.length() > 0) {
        setBlameInfo(blameInfos);
        JsArrayString gutters = ((JsArrayString) JsArrayString.createArray());
        gutters.push(ANNOTATION_GUTTER_ID);
        cm.setOption("gutters", gutters);
        annotated = true;
        DateTimeFormat format = DateTimeFormat.getFormat(DateTimeFormat.PredefinedFormat.DATE_SHORT);
        JsArray<LintLine> annotations = JsArray.createArray().cast();
        for (BlameInfo blameInfo : Natives.asList(blameInfos)) {
            for (RangeInfo range : Natives.asList(blameInfo.ranges())) {
                Date commitTime = new Date(blameInfo.time() * 1000L);
                String shortId = blameInfo.id().substring(0, 8);
                String shortBlame = C.shortBlameMsg(shortId, format.format(commitTime), blameInfo.author());
                String detailedBlame = C.detailedBlameMsg(blameInfo.id(), blameInfo.author(), FormatUtil.mediumFormat(commitTime), blameInfo.commitMsg());
                annotations.push(LintLine.create(shortBlame, detailedBlame, shortId, Pos.create(range.start() - 1)));
            }
        }
        cm.setOption("lint", getAnnotation(annotations));
    }
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) RangeInfo(com.google.gerrit.client.RangeInfo) JsArrayString(com.google.gwt.core.client.JsArrayString) Date(java.util.Date) DateTimeFormat(com.google.gwt.i18n.client.DateTimeFormat) BlameInfo(com.google.gerrit.client.blame.BlameInfo)

Aggregations

RangeInfo (com.google.gerrit.client.RangeInfo)1 BlameInfo (com.google.gerrit.client.blame.BlameInfo)1 JsArrayString (com.google.gwt.core.client.JsArrayString)1 DateTimeFormat (com.google.gwt.i18n.client.DateTimeFormat)1 Date (java.util.Date)1