Merge "Notify all coverage listeners when coverage data is available"
This commit is contained in:
@@ -77,7 +77,6 @@ limitations under the License.
|
||||
|
||||
properties: {
|
||||
diff: Object,
|
||||
diffPath: String,
|
||||
changeNum: String,
|
||||
patchNum: String,
|
||||
viewMode: String,
|
||||
|
@@ -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];
|
||||
|
@@ -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]]"
|
||||
|
@@ -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;
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user