Add more jsdoc for closure checks

1. add `@extends` for all polymer elements
2. add `@override` for all lifecycle methods
3. fix a wrong type in gr-auth

Change-Id: Id9dea76b169197084d2e0b5f267459cdc4aaec3e
This commit is contained in:
Tao Zhou
2020-01-12 15:20:39 +01:00
parent c4409bd739
commit ab57ce3744
168 changed files with 294 additions and 4 deletions

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrAccountChip extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -63,6 +64,7 @@
};
}
/** @override */
ready() {
super.ready();
this._getHasAvatars().then(hasAvatars => {

View File

@@ -20,6 +20,8 @@
/**
* gr-account-entry is an element for entering account
* and/or group with autocomplete support.
*
* @extends Polymer.Element
*/
class GrAccountEntry extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(

View File

@@ -20,6 +20,7 @@
/**
* @appliesMixin Gerrit.DisplayNameMixin
* @appliesMixin Gerrit.TooltipMixin
* @extends Polymer.Element
*/
class GrAccountLabel extends Polymer.mixinBehaviors( [
Gerrit.DisplayNameBehavior,
@@ -61,6 +62,7 @@
};
}
/** @override */
ready() {
super.ready();
if (!this.additionalText) { this.additionalText = ''; }

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.BaseUrlMixin
* @extends Polymer.Element
*/
class GrAccountLink extends Polymer.mixinBehaviors( [
Gerrit.BaseUrlBehavior,

View File

@@ -21,6 +21,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrAccountList extends Polymer.mixinBehaviors( [
// Used in the tests for gr-account-list and other elements tests.
@@ -113,6 +114,7 @@
};
}
/** @override */
created() {
super.created();
this.addEventListener('remove',

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrAlert extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@@ -52,11 +53,13 @@
};
}
/** @override */
attached() {
super.attached();
this.addEventListener('transitionend', this._boundTransitionEndHandler);
}
/** @override */
detached() {
super.detached();
this.removeEventListener('transitionend',

View File

@@ -21,6 +21,7 @@
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @appliesMixin Polymer.IronFitMixin
* @extends Polymer.Element
*/
class GrAutocompleteDropdown extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,

View File

@@ -23,6 +23,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @extends Polymer.Element
*/
class GrAutocomplete extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -192,11 +193,13 @@
return this.$.input.$.nativeInput || this.$.input.inputElement;
}
/** @override */
attached() {
super.attached();
this.listen(document.body, 'click', '_handleBodyClick');
}
/** @override */
detached() {
super.detached();
this.unlisten(document.body, 'click', '_handleBodyClick');

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.BaseUrlMixin
* @extends Polymer.Element
*/
class GrAvatar extends Polymer.mixinBehaviors( [
Gerrit.BaseUrlBehavior,
@@ -44,6 +45,7 @@
};
}
/** @override */
attached() {
super.attached();
Promise.all([

View File

@@ -20,6 +20,7 @@
/**
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @appliesMixin Gerrit.TooltipMixin
* @extends Polymer.Element
*/
class GrButton extends Polymer.mixinBehaviors( [
Gerrit.KeyboardShortcutBehavior,
@@ -68,6 +69,7 @@
];
}
/** @override */
created() {
super.created();
this.addEventListener('click',
@@ -76,6 +78,7 @@
e => this._handleKeydown(e));
}
/** @override */
ready() {
super.ready();
this._ensureAttribute('role', 'button');

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrChangeStar extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -36,6 +36,7 @@
const PRIVATE_TOOLTIP = 'This change is only visible to its owner and ' +
'current reviewers (or anyone with "View Private Changes" permission).';
/** @extends Polymer.Element */
class GrChangeStatus extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -24,6 +24,7 @@
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @appliesMixin Gerrit.PathListMixin
* @extends Polymer.Element
*/
class GrCommentThread extends Polymer.mixinBehaviors( [
/**
@@ -157,12 +158,14 @@
};
}
/** @override */
created() {
super.created();
this.addEventListener('comment-update',
e => this._handleCommentUpdate(e));
}
/** @override */
attached() {
super.attached();
this._getLoggedIn().then(loggedIn => {

View File

@@ -34,6 +34,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @extends Polymer.Element
*/
class GrComment extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -186,6 +187,7 @@
};
}
/** @override */
attached() {
super.attached();
if (this.editing) {
@@ -198,6 +200,7 @@
});
}
/** @override */
detached() {
super.detached();
this.cancelDebouncer('fire-update');

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrConfirmDeleteCommentDialog extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,

View File

@@ -19,6 +19,7 @@
const COPY_TIMEOUT_MS = 1000;
/** @extends Polymer.Element */
class GrCopyClipboard extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -22,6 +22,7 @@
KEEP_VISIBLE: 'keep-visible',
};
/** @extends Polymer.Element */
class GrCursorManager extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@@ -91,6 +92,7 @@
};
}
/** @override */
detached() {
super.detached();
this.unsetCursor();

View File

@@ -33,6 +33,7 @@
/**
* @appliesMixin Gerrit.TooltipMixin
* @extends Polymer.Element
*/
class GrDateFormatter extends Polymer.mixinBehaviors( [
Gerrit.TooltipBehavior,
@@ -73,6 +74,7 @@
};
}
/** @override */
attached() {
super.attached();
this._loadPreferences();

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrDialog extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -60,6 +61,7 @@
};
}
/** @override */
ready() {
super.ready();
this._ensureAttribute('role', 'dialog');

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrDiffPreferences extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.RESTClientMixin
* @extends Polymer.Element
*/
class GrDownloadCommands extends Polymer.mixinBehaviors( [
Gerrit.RESTClientBehavior,
@@ -43,6 +44,7 @@
};
}
/** @override */
attached() {
super.attached();
this._getLoggedIn().then(loggedIn => {

View File

@@ -45,6 +45,7 @@
*/
Defs.item;
/** @extends Polymer.Element */
class GrDropdownList extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -23,6 +23,7 @@
/**
* @appliesMixin Gerrit.BaseUrlMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @extends Polymer.Element
*/
class GrDropdown extends Polymer.mixinBehaviors( [
Gerrit.BaseUrlBehavior,

View File

@@ -22,6 +22,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrEditableContent extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,

View File

@@ -23,6 +23,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @extends Polymer.Element
*/
class GrEditableLabel extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -76,6 +77,7 @@
};
}
/** @override */
ready() {
super.ready();
this._ensureAttribute('tabindex', '0');

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrFixedPanel extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@@ -61,6 +62,7 @@
};
}
/** @override */
attached() {
super.attached();
if (this.floatingDisabled) {
@@ -76,6 +78,7 @@
this._observer.observe(this.$.header, {childList: true, subtree: true});
}
/** @override */
detached() {
super.detached();
this.unlisten(window, 'scroll', '_updateOnScroll');

View File

@@ -20,6 +20,7 @@
// eslint-disable-next-line no-unused-vars
const QUOTE_MARKER_PATTERN = /\n\s?>\s/g;
/** @extends Polymer.Element */
class GrFormattedText extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@@ -45,6 +46,7 @@
];
}
/** @override */
ready() {
super.ready();
if (this.noTrailingMargin) {

View File

@@ -25,6 +25,7 @@
*/
const DIAGONAL_OVERFLOW = 15;
/** @extends Polymer.Element */
class GrHovercard extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@@ -91,6 +92,7 @@
};
}
/** @override */
attached() {
super.attached();
if (!this._target) { this._target = this.target; }
@@ -101,12 +103,14 @@
this.listen(this._target, 'click', 'hide');
}
/** @override */
created() {
super.created();
this.addEventListener('mouseleave',
e => this.hide(e));
}
/** @override */
ready() {
super.ready();
// First, check to see if the container has already been created.

View File

@@ -39,6 +39,7 @@
/**
* @appliesMixin Gerrit.PatchSetMixin
* @extends Polymer.Element
*/
class GrJsApiInterface extends Polymer.mixinBehaviors( [
Gerrit.PatchSetBehavior,

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrLabelInfo extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.TooltipMixin
* @extends Polymer.Element
*/
class GrLabel extends Polymer.mixinBehaviors( [
Gerrit.TooltipBehavior,

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrLabeledAutocomplete extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -20,6 +20,7 @@
const HLJS_PATH = 'bower_components/highlightjs/highlight.min.js';
const DARK_THEME_PATH = 'styles/themes/dark-theme.html';
/** @extends Polymer.Element */
class GrLibLoader extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -18,13 +18,13 @@
'use strict';
/**
* @appliesMixin Gerrit.TooltipMixin
*/
/*
* The gr-limited-text element is for displaying text with a maximum length
* (in number of characters) to display. If the length of the text exceeds the
* configured limit, then an ellipsis indicates that the text was truncated
* and a tooltip containing the full text is enabled.
*
* @appliesMixin Gerrit.TooltipMixin
* @extends Polymer.Element
*/
class GrLimitedText extends Polymer.mixinBehaviors( [
Gerrit.TooltipBehavior,

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrLinkedChip extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrLinkedText extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -23,6 +23,7 @@
* @appliesMixin Gerrit.BaseUrlMixin
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.URLEncodingMixin
* @extends Polymer.Element
*/
class GrListView extends Polymer.mixinBehaviors( [
Gerrit.BaseUrlBehavior,
@@ -48,6 +49,7 @@
};
}
/** @override */
detached() {
super.detached();
this.cancelDebouncer('reload');

View File

@@ -23,6 +23,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrOverlay extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -52,6 +53,7 @@
};
}
/** @override */
created() {
super.created();
this.addEventListener('iron-overlay-closed',

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrPageNav extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {
@@ -28,11 +29,13 @@
};
}
/** @override */
attached() {
super.attached();
this.listen(window, 'scroll', '_handleBodyScroll');
}
/** @override */
detached() {
super.detached();
this.unlisten(window, 'scroll', '_handleBodyScroll');

View File

@@ -22,6 +22,7 @@
/**
* @appliesMixin Gerrit.URLEncodingMixin
* @extends Polymer.Element
*/
class GrRepoBranchPicker extends Polymer.mixinBehaviors( [
Gerrit.URLEncodingBehavior,
@@ -57,6 +58,7 @@
};
}
/** @override */
attached() {
super.attached();
if (this.repo) {
@@ -64,6 +66,7 @@
}
}
/** @override */
ready() {
super.ready();
this._branchDisabled = !this.repo;

View File

@@ -76,7 +76,7 @@
}
/**
* @param {string} status
* @param {Auth.STATUS} status
*/
_setStatus(status) {
if (this._status === status) return;
@@ -252,6 +252,7 @@
ACCESS_TOKEN: 'access_token',
};
/** @enum {number} */
Auth.STATUS = {
UNDETERMINED: 0,
AUTHED: 1,

View File

@@ -44,6 +44,7 @@
* @appliesMixin Gerrit.PathListMixin
* @appliesMixin Gerrit.PatchSetMixin
* @appliesMixin Gerrit.RESTClientMixin
* @extends Polymer.Element
*/
class GrRestApiInterface extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -105,6 +106,7 @@
};
}
/** @override */
created() {
super.created();
this._auth = Gerrit.Auth;

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @extends Polymer.Element
*/
class GrSelect extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -63,6 +64,7 @@
this.nativeSelect.focus();
}
/** @override */
created() {
super.created();
this.addEventListener('change',
@@ -71,6 +73,7 @@
() => this._updateValue());
}
/** @override */
ready() {
super.ready();
// If not set via the property, set bind-value to the element value.

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrShellCommand extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -28,6 +28,7 @@
'editablecontent:',
];
/** @extends Polymer.Element */
class GrStorage extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {

View File

@@ -55,6 +55,7 @@
/**
* @appliesMixin Gerrit.FireMixin
* @appliesMixin Gerrit.KeyboardShortcutMixin
* @extends Polymer.Element
*/
class GrTextarea extends Polymer.mixinBehaviors( [
Gerrit.FireBehavior,
@@ -125,6 +126,7 @@
};
}
/** @override */
ready() {
super.ready();
if (this.monospace) {

View File

@@ -19,6 +19,7 @@
/**
* @appliesMixin Gerrit.TooltipMixin
* @extends Polymer.Element
*/
class GrTooltipContent extends Polymer.mixinBehaviors( [
Gerrit.TooltipBehavior,

View File

@@ -17,6 +17,7 @@
(function() {
'use strict';
/** @extends Polymer.Element */
class GrTooltip extends Polymer.GestureEventListeners(
Polymer.LegacyElementMixin(
Polymer.Element)) {