/** * @license * Copyright (C) 2019 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ (function() { 'use strict'; /** @enum {string} */ Gerrit.CoverageType = { /** * start_character and end_character of the range will be ignored for this * type. */ COVERED: 'COVERED', /** * start_character and end_character of the range will be ignored for this * type. */ NOT_COVERED: 'NOT_COVERED', PARTIALLY_COVERED: 'PARTIALLY_COVERED', /** * You don't have to use this. If there is no coverage information for a * range, then it implicitly means NOT_INSTRUMENTED. start_character and * end_character of the range will be ignored for this type. */ NOT_INSTRUMENTED: 'NOT_INSTRUMENTED', }; const TOOLTIP_MAP = new Map([ [Gerrit.CoverageType.COVERED, 'Covered by tests.'], [Gerrit.CoverageType.NOT_COVERED, 'Not covered by tests.'], [Gerrit.CoverageType.PARTIALLY_COVERED, 'Partially covered by tests.'], [Gerrit.CoverageType.NOT_INSTRUMENTED, 'Not instrumented by any tests.'], ]); /** * @typedef {{ * side: string, * type: Gerrit.CoverageType, * code_range: Gerrit.Range, * }} */ Gerrit.CoverageRange; Polymer({ is: 'gr-coverage-layer', properties: { /** * Must be sorted by code_range.start_line. * Must only contain ranges that match the side. * * @type {!Array} */ coverageRanges: Array, side: String, /** * We keep track of the line number from the previous annotate() call, * and also of the index of the coverage range that had matched. * annotate() calls are coming in with increasing line numbers and * coverage ranges are sorted by line number. So this is a very simple * and efficient way for finding the coverage range that matches a given * line number. */ _lineNumber: { type: Number, value: 0, }, _index: { type: Number, value: 0, }, }, /** * Layer method to add annotations to a line. * * @param {!HTMLElement} el Not used for this layer. * @param {!HTMLElement} lineNumberEl The