Added a types.js file to support cross-module types
Also cleaned up some TODOs related to types Change-Id: I93b77d7af238bfd19ba09c30ceb0d9fc5e67abd3
This commit is contained in:
@@ -19,35 +19,6 @@
|
||||
|
||||
const PARENT = 'PARENT';
|
||||
|
||||
const Defs = {};
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* basePatchNum: (string|number),
|
||||
* patchNum: (number),
|
||||
* }}
|
||||
*/
|
||||
Defs.patchRange;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* changeNum: number,
|
||||
* path: string,
|
||||
* patchRange: !Defs.patchRange,
|
||||
* projectConfig: (Object|undefined),
|
||||
* }}
|
||||
*/
|
||||
Defs.commentMeta;
|
||||
|
||||
/**
|
||||
* @typedef {{
|
||||
* meta: !Defs.commentMeta,
|
||||
* left: !Array,
|
||||
* right: !Array,
|
||||
* }}
|
||||
*/
|
||||
Defs.commentsBySide;
|
||||
|
||||
/**
|
||||
* Construct a change comments object, which can be data-bound to child
|
||||
* elements of that which uses the gr-comment-api.
|
||||
@@ -92,7 +63,7 @@
|
||||
* Paths with comments are mapped to true, whereas paths without comments
|
||||
* are not mapped.
|
||||
*
|
||||
* @param {Defs.patchRange=} opt_patchRange The patch-range object containing
|
||||
* @param {Gerrit.PatchRange=} opt_patchRange The patch-range object containing
|
||||
* patchNum and basePatchNum properties to represent the range.
|
||||
* @return {!Object}
|
||||
*/
|
||||
@@ -251,11 +222,11 @@
|
||||
* arrays of comments in on either side of the patch range for that path.
|
||||
*
|
||||
* @param {!string} path
|
||||
* @param {!Defs.patchRange} patchRange The patch-range object containing patchNum
|
||||
* @param {!Gerrit.PatchRange} patchRange The patch-range object containing patchNum
|
||||
* and basePatchNum properties to represent the range.
|
||||
* @param {Object=} opt_projectConfig Optional project config object to
|
||||
* include in the meta sub-object.
|
||||
* @return {!Defs.commentsBySide}
|
||||
* @return {!Gerrit.CommentsBySide}
|
||||
*/
|
||||
ChangeComments.prototype.getCommentsBySideForPath = function(path,
|
||||
patchRange, opt_projectConfig) {
|
||||
@@ -438,7 +409,7 @@
|
||||
* Whether the given comment should be included in the base side of the
|
||||
* given patch range.
|
||||
* @param {!Object} comment
|
||||
* @param {!Defs.patchRange} range
|
||||
* @param {!Gerrit.PatchRange} range
|
||||
* @return {boolean}
|
||||
*/
|
||||
ChangeComments.prototype._isInBaseOfPatchRange = function(comment, range) {
|
||||
@@ -469,7 +440,7 @@
|
||||
* Whether the given comment should be included in the revision side of the
|
||||
* given patch range.
|
||||
* @param {!Object} comment
|
||||
* @param {!Defs.patchRange} range
|
||||
* @param {!Gerrit.PatchRange} range
|
||||
* @return {boolean}
|
||||
*/
|
||||
ChangeComments.prototype._isInRevisionOfPatchRange = function(comment,
|
||||
@@ -481,7 +452,7 @@
|
||||
/**
|
||||
* Whether the given comment should be included in the given patch range.
|
||||
* @param {!Object} comment
|
||||
* @param {!Defs.patchRange} range
|
||||
* @param {!Gerrit.PatchRange} range
|
||||
* @return {boolean|undefined}
|
||||
*/
|
||||
ChangeComments.prototype._isInPatchRange = function(comment, range) {
|
||||
|
||||
@@ -19,6 +19,7 @@ limitations under the License.
|
||||
<dom-module id="gr-coverage-layer">
|
||||
<template>
|
||||
</template>
|
||||
<script src="../../../types/types.js"></script>
|
||||
<script src="../gr-diff-highlight/gr-annotation.js"></script>
|
||||
<script src="gr-coverage-layer.js"></script>
|
||||
</dom-module>
|
||||
|
||||
@@ -17,27 +17,6 @@
|
||||
(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.'],
|
||||
@@ -45,15 +24,6 @@
|
||||
[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',
|
||||
|
||||
|
||||
@@ -203,9 +203,7 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* TODO(brohlfs): Replace Object type by Gerrit.CoverageRange.
|
||||
*
|
||||
* @type {!Array<!Object>}
|
||||
* @type {!Array<!Gerrit.CoverageRange>}
|
||||
*/
|
||||
_coverageRanges: {
|
||||
type: Array,
|
||||
|
||||
@@ -19,44 +19,6 @@
|
||||
|
||||
const WHOLE_FILE = -1;
|
||||
|
||||
const Defs = {};
|
||||
|
||||
/**
|
||||
* The DiffIntralineInfo entity contains information about intraline edits in a
|
||||
* file.
|
||||
*
|
||||
* The information consists of a list of <skip length, mark length> pairs, where
|
||||
* the skip length is the number of characters between the end of the previous
|
||||
* edit and the start of this edit, and the mark length is the number of edited
|
||||
* characters following the skip. The start of the edits is from the beginning
|
||||
* of the related diff content lines.
|
||||
*
|
||||
* Note that the implied newline character at the end of each line is included
|
||||
* in the length calculation, and thus it is possible for the edits to span
|
||||
* newlines.
|
||||
* @typedef {!Array<number>}
|
||||
*/
|
||||
Defs.IntralineInfo;
|
||||
|
||||
/**
|
||||
* A portion of the diff that is treated the same.
|
||||
*
|
||||
* Called `DiffContent` in the API, see
|
||||
* https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#diff-content
|
||||
*
|
||||
* @typedef {{
|
||||
* ab: ?Array<!string>,
|
||||
* a: ?Array<!string>,
|
||||
* b: ?Array<!string>,
|
||||
* skip: ?number,
|
||||
* edit_a: ?Array<!Defs.IntralineInfo>,
|
||||
* edit_b: ?Array<!Defs.IntralineInfo>,
|
||||
* due_to_rebase: ?boolean,
|
||||
* common: ?boolean
|
||||
* }}
|
||||
*/
|
||||
Defs.Chunk;
|
||||
|
||||
const DiffSide = {
|
||||
LEFT: 'left',
|
||||
RIGHT: 'right',
|
||||
@@ -171,7 +133,7 @@
|
||||
/**
|
||||
* Asynchronously process the diff chunks into groups. As it processes, it
|
||||
* will splice groups into the `groups` property of the component.
|
||||
* @param {!Array<!Defs.Chunk>} chunks
|
||||
* @param {!Array<!Gerrit.DiffChunk>} chunks
|
||||
* @param {boolean} isBinary
|
||||
* @return {!Promise<!Array<!Object>>} A promise that resolves with an
|
||||
* array of GrDiffGroups when the diff is completely processed.
|
||||
@@ -411,7 +373,7 @@
|
||||
* @param {string} lineType (GrDiffLine.Type)
|
||||
* @param {!Array<string>} rows
|
||||
* @param {number} offset
|
||||
* @param {?Array<!Defs.IntralineInfo>=} opt_intralineInfos
|
||||
* @param {?Array<!Gerrit.IntralineInfo>=} opt_intralineInfos
|
||||
* @return {!Array<!Object>} (GrDiffLine)
|
||||
*/
|
||||
_linesFromRows(lineType, rows, offset, opt_intralineInfos) {
|
||||
@@ -464,8 +426,8 @@
|
||||
* into 2 chunks, one max sized one and the rest (for reasons that are
|
||||
* unclear to me).
|
||||
*
|
||||
* @param {!Array<!Defs.Chunk>} chunks Chunks as returned from the server
|
||||
* @return {!Array<!Defs.Chunk>} Finer grained chunks.
|
||||
* @param {!Array<!Gerrit.DiffChunk>} chunks Chunks as returned from the server
|
||||
* @return {!Array<!Gerrit.DiffChunk>} Finer grained chunks.
|
||||
*/
|
||||
_splitLargeChunks(chunks) {
|
||||
const newChunks = [];
|
||||
@@ -592,7 +554,7 @@
|
||||
* for rendering.
|
||||
*
|
||||
* @param {!Array<string>} rows
|
||||
* @param {!Array<!Defs.IntralineInfo>} intralineInfos
|
||||
* @param {!Array<!Gerrit.IntralineInfo>} intralineInfos
|
||||
* @return {!Array<!Object>} (GrDiffLine.Highlight)
|
||||
*/
|
||||
_convertIntralineInfos(rows, intralineInfos) {
|
||||
@@ -641,7 +603,7 @@
|
||||
* If a group is an addition or a removal, break it down into smaller groups
|
||||
* of that type using the MAX_GROUP_SIZE. If the group is a shared chunk
|
||||
* or a delta it is returned as the single element of the result array.
|
||||
* @param {!Defs.Chunk} chunk A raw chunk from a diff response.
|
||||
* @param {!Gerrit.DiffChunk} chunk A raw chunk from a diff response.
|
||||
* @return {!Array<!Array<!Object>>}
|
||||
*/
|
||||
_breakdownChunk(chunk) {
|
||||
|
||||
@@ -21,31 +21,6 @@ limitations under the License.
|
||||
|
||||
<dom-module id="gr-diff-selection">
|
||||
<template>
|
||||
<style include="shared-styles">
|
||||
/** Select and copy for Polymer 1*/
|
||||
.contentWrapper ::content .content,
|
||||
.contentWrapper ::content .contextControl,
|
||||
.contentWrapper ::content .blame {
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
:host-context(.selected-left:not(.selected-comment)) .contentWrapper ::content .side-by-side .left + .content .contentText,
|
||||
:host-context(.selected-right:not(.selected-comment)) .contentWrapper ::content .side-by-side .right + .content .contentText,
|
||||
:host-context(.selected-left:not(.selected-comment)) .contentWrapper ::content .unified .left.lineNum ~ .content:not(.both) .contentText,
|
||||
:host-context(.selected-right:not(.selected-comment)) .contentWrapper ::content .unified .right.lineNum ~ .content .contentText,
|
||||
:host-context(.selected-left.selected-comment) .contentWrapper ::content .side-by-side .left + .content .message,
|
||||
:host-context(.selected-right.selected-comment) .contentWrapper ::content .side-by-side .right + .content .message :not(.collapsedContent),
|
||||
:host-context(.selected-comment) .contentWrapper ::content .unified .message :not(.collapsedContent),
|
||||
:host-context(.selected-blame) .contentWrapper ::content .blame {
|
||||
-webkit-user-select: text;
|
||||
-moz-user-select: text;
|
||||
-ms-user-select: text;
|
||||
user-select: text;
|
||||
}
|
||||
</style>
|
||||
<div class="contentWrapper">
|
||||
<slot></slot>
|
||||
</div>
|
||||
|
||||
@@ -35,26 +35,10 @@
|
||||
RIGHT: 'right',
|
||||
};
|
||||
|
||||
const Defs = {};
|
||||
|
||||
/**
|
||||
* Special line number which should not be collapsed into a shared region.
|
||||
*
|
||||
* @typedef {{
|
||||
* number: number,
|
||||
* leftSide: boolean
|
||||
* }}
|
||||
*/
|
||||
Defs.LineOfInterest;
|
||||
|
||||
const LARGE_DIFF_THRESHOLD_LINES = 10000;
|
||||
const FULL_CONTEXT = -1;
|
||||
const LIMITED_CONTEXT = 10;
|
||||
|
||||
/** @typedef {{start_line: number, start_character: number,
|
||||
* end_line: number, end_character: number}} */
|
||||
Gerrit.Range;
|
||||
|
||||
/**
|
||||
* Compare two ranges. Either argument may be falsy, but will only return
|
||||
* true if both are falsy or if neither are falsy and have the same position
|
||||
@@ -185,7 +169,7 @@
|
||||
observer: '_viewModeObserver',
|
||||
},
|
||||
|
||||
/** @type ?Defs.LineOfInterest */
|
||||
/** @type ?Gerrit.LineOfInterest */
|
||||
lineOfInterest: Object,
|
||||
|
||||
loading: {
|
||||
|
||||
@@ -23,9 +23,6 @@
|
||||
const RANGE_HIGHLIGHT = 'style-scope gr-diff range';
|
||||
const HOVER_HIGHLIGHT = 'style-scope gr-diff rangeHighlight';
|
||||
|
||||
/** @typedef {{side: string, range: Gerrit.Range, hovering: boolean}} */
|
||||
Gerrit.HoveredRange;
|
||||
|
||||
Polymer({
|
||||
is: 'gr-ranged-comment-layer',
|
||||
|
||||
|
||||
Reference in New Issue
Block a user