Merge "Notify all coverage listeners when coverage data is available"

This commit is contained in:
Tao Zhou
2019-12-04 10:25:34 +00:00
committed by Gerrit Code Review
4 changed files with 25 additions and 6 deletions

View File

@@ -77,7 +77,6 @@ limitations under the License.
properties: {
diff: Object,
diffPath: String,
changeNum: String,
patchNum: String,
viewMode: String,

View File

@@ -301,7 +301,7 @@
const layers = [this.$.syntaxLayer];
// Get layers from plugins (if any).
for (const pluginLayer of this.$.jsAPI.getDiffLayers(
this.diffPath, this.changeNum, this.patchNum)) {
this.path, this.changeNum, this.patchNum)) {
layers.push(pluginLayer);
}
this._layers = layers;
@@ -313,7 +313,9 @@
this._coverageRanges = [];
const {changeNum, path, patchRange: {basePatchNum, patchNum}} = this;
this.$.jsAPI.getCoverageRanges(changeNum, path, basePatchNum, patchNum).
this.$.jsAPI.getCoverageRanges(
changeNum, path, basePatchNum, patchNum
).
then(coverageRanges => {
if (changeNum !== this.changeNum ||
path !== this.path ||
@@ -344,6 +346,8 @@
return this._loadDiffAssets(diff);
});
// Not waiting for getCoverageRanges intentionally as
// plugin loading should not block the content rendering
return Promise.all([diffRequest, assetRequest])
.then(results => {
const diff = results[0];

View File

@@ -373,7 +373,7 @@ limitations under the License.
coverage-ranges="[[coverageRanges]]"
project-name="[[projectName]]"
diff="[[diff]]"
diff-path="[[path]]"
path="[[path]]"
change-num="[[changeNum]]"
patch-num="[[patchRange.patchNum]]"
view-mode="[[viewMode]]"

View File

@@ -270,10 +270,26 @@
// Only one coverage provider makes sense. If there are more, then we
// simply ignore them.
if (provider) {
return provider(changeNum, path, basePatchNum, patchNum);
return annotationApi;
}
}
return [];
return null;
}).then(annotationApi => {
if (!annotationApi) return [];
const provider = annotationApi.getCoverageProvider();
return provider(changeNum, path, basePatchNum, patchNum)
.then(ranges => {
ranges = ranges || [];
// Notify with the coverage data.
ranges.forEach(range => {
annotationApi.notify(
path,
range.code_range.start_line,
range.code_range.end_line,
range.side);
});
return ranges;
});
});
}