google / google/j2cl

Generate closure @suppress jsdoc tag on method when @SuppressWarning present in java

Open
#50 8 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
1.4k
Forks
161
PR merge metrics
No merged PRs in 30d

Description

I would like J2CL to generate `@suppress` jsdoc tags when a specially formatted `@SuppressWarning()` is present in java code. To start with the simplest option would be to detect the `@SuppressWarning()` on the java method and then translate to a `@suppress` on the corresponding method implementation - while detecting appropriate `@SuppressWarning()` in other contexts may be possible, it would also be more complex.

For now let us assume that any SuppressWarnings key that had a prefix of `CL:` should be translated into a closure suppression.

So we could easily imagine code such as:

```java
@SuppressWarnings( "CL:checkDebuggerStatement" )
public static void pauseIfInDebugger() {
Js.debugger();
}
```

Generating the following javascript code:

```javascript
/**
* @return {void}
* @public
* @suppress {checkDebuggerStatement}
*/
static void pauseIfInDebugger() {
debugger;
}
```

A few questions:
* Would a PR containing this be accepted?
* Should I wait until JDT is eliminated or is it acceptable to start with what is present now?
* Do you expect it to be possible for me to write tests in the OSS variant of the library or should I look at that first?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.