Skip to content

Commit

Permalink
Use @closurePrimitive annotations and remove getAssertionFunctions ov…
Browse files Browse the repository at this point in the history
…erride
  • Loading branch information
rsimha committed May 22, 2019
1 parent edfead3 commit 5ebcee3
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 26 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
},
"additionalTagNames": {
"customTags": [
"closurePrimitive",
"deprecated",
"export",
"final",
Expand Down
1 change: 1 addition & 0 deletions build-system/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ module.exports = {
'!validator/webui/node_modules/**/*.*',
'!build-system/tasks/e2e/node_modules/**/*.*',
'!build-system/tasks/presubmit-checks.js',
'!build-system/runner/build/**/*.*',
'!build-system/tasks/visual-diff/node_modules/**/*.*',
'!build-system/tasks/visual-diff/snippets/*.js',
'!build/polyfills.js',
Expand Down
Binary file modified build-system/runner/dist/runner.jar
Binary file not shown.
20 changes: 0 additions & 20 deletions build-system/runner/src/org/ampproject/AmpCodingConvention.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,26 +44,6 @@ public AmpCodingConvention(CodingConvention convention) {
super(convention);
}

@Override
public ImmutableCollection<AssertionFunctionSpec> getAssertionFunctions() {
return ImmutableList.of(
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"module$src$log.devAssert").build(),
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"devAssert$$module$src$log").build(),
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"module$src$log.userAssert").build(),
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"userAssert$$module$src$log").build(),
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"assertService$$module$src$element_service").build(),
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"module$src$layout.assertLength").build(),
AssertionFunctionSpec.forMatchesReturn().setFunctionName(
"assertLength$$module$src$layout").build()
);
}

/**
* {@inheritDoc}
* Because AMP objects can travel between compilation units, we consider
Expand Down
1 change: 1 addition & 0 deletions src/element-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ export function getElementServiceIfAvailableForDocInEmbedScope(
* @param {string} extension
* @return {!Object}
* @private
* @closurePrimitive {asserts.matchesReturn}
*/
function assertService(service, id, extension) {
return /** @type {!Object} */ (userAssert(
Expand Down
2 changes: 2 additions & 0 deletions src/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ export function parseLength(s) {
* Asserts that the supplied value is a non-percent CSS Length value.
* @param {!LengthDef|string|null|undefined} length
* @return {!LengthDef}
* @closurePrimitive {asserts.matchesReturn}
*/
export function assertLength(length) {
userAssert(
Expand All @@ -209,6 +210,7 @@ export function assertLength(length) {
* (including percent unit).
* @param {!LengthDef|string} length
* @return {!LengthDef}
* @closurePrimitive {asserts.matchesReturn}
*/
export function assertLengthOrPercent(length) {
userAssert(
Expand Down
15 changes: 9 additions & 6 deletions src/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ export class Log {
* @param {...*} var_args Arguments substituted into %s in the message.
* @return {T} The value of shouldBeTrueish.
* @template T
* eslint "google-camelcase/google-camelcase": 0
* @closurePrimitive {asserts.matchesReturn}
*/
assert(shouldBeTrueish, opt_message, var_args) {
let firstElement;
Expand Down Expand Up @@ -360,7 +360,7 @@ export class Log {
* @param {string=} opt_message The assertion message
* @return {!Element} The value of shouldBeTrueish.
* @template T
* eslint "google-camelcase/google-camelcase": 2
* @closurePrimitive {asserts.matchesReturn}
*/
assertElement(shouldBeElement, opt_message) {
const shouldBeTrueish = shouldBeElement && shouldBeElement.nodeType == 1;
Expand All @@ -381,7 +381,7 @@ export class Log {
* @param {*} shouldBeString
* @param {string=} opt_message The assertion message
* @return {string} The string value. Can be an empty string.
* eslint "google-camelcase/google-camelcase": 2
* @closurePrimitive {asserts.matchesReturn}
*/
assertString(shouldBeString, opt_message) {
this.assert(
Expand All @@ -402,6 +402,7 @@ export class Log {
* @param {string=} opt_message The assertion message
* @return {number} The number value. The allowed values include `0`
* and `NaN`.
* @closurePrimitive {asserts.matchesReturn}
*/
assertNumber(shouldBeNumber, opt_message) {
this.assert(
Expand All @@ -419,6 +420,7 @@ export class Log {
* @param {*} shouldBeArray
* @param {string=} opt_message The assertion message
* @return {!Array} The array value
* @closurePrimitive {asserts.matchesReturn}
*/
assertArray(shouldBeArray, opt_message) {
this.assert(
Expand All @@ -437,6 +439,7 @@ export class Log {
* @param {*} shouldBeBoolean
* @param {string=} opt_message The assertion message
* @return {boolean} The boolean value.
* @closurePrimitive {asserts.matchesReturn}
*/
assertBoolean(shouldBeBoolean, opt_message) {
this.assert(
Expand All @@ -456,7 +459,7 @@ export class Log {
* @param {string=} opt_enumName
* @return {T}
* @template T
* eslint "google-camelcase/google-camelcase": 2
* @closurePrimitive {asserts.matchesReturn}
*/
assertEnumValue(enumObj, s, opt_enumName) {
if (isEnumValue(enumObj, s)) {
Expand Down Expand Up @@ -731,7 +734,7 @@ export function isFromEmbed(win, opt_element) {
* @param {*=} opt_9 Optional argument
* @return {T} The value of shouldBeTrueish.
* @template T
* eslint "google-camelcase/google-camelcase": 0
* @closurePrimitive {asserts.matchesReturn}
*/
export function devAssert(
shouldBeTrueish,
Expand Down Expand Up @@ -790,7 +793,7 @@ export function devAssert(
* @param {*=} opt_9 Optional argument
* @return {T} The value of shouldBeTrueish.
* @template T
* eslint "google-camelcase/google-camelcase": 0
* @closurePrimitive {asserts.matchesReturn}
*/
export function userAssert(
shouldBeTrueish,
Expand Down

1 comment on commit 5ebcee3

@cramforce
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is sooooo much better!

Please sign in to comment.