-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Supporting @suppress annotation on class nodes #1147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
SuppressDocWarningsGuard wasn't observing class nodes when looking for @Suppress, as needed for missingRequire on class X extends Y.
It's always been true that |
You mean documentation in the code / javadoc, or wiki / elsewhere? |
We'll also want to add some tests to make sure that we handle
and
On Wed, Sep 16, 2015 at 9:27 AM, Tyler Breisacher [email protected]
|
SuppressDocWarningsGuard is devoid of tests, I think |
If we find anything in the Javadoc or code comments then we should fix it as part of this PR. There's also the Github wiki (which anyone can edit), https://developers.google.com/closure/compiler/ (which only Googlers can edit, unfortunately), and probably one or two other spots I'm forgetting. |
I see @blickly has revealed the test cases, so I'll look at adding one. But shouldn't // Suppress just this warning precisely (on NAME or GETPROP):
class X extends /** @suppress {missingRequires} */ React.Component {}
// Suppress just this warning anywhere on or in the class definition
/** @suppress {missingRequires} */
class X extends React.Component {} The same goes for other suppress options, you should be able to disable any of the non-mutating checks at any level in the AST. Except for the Rhino ones which presumably could at some point become Node aware. You might want to disable all warnings in particular files. A bit like you can for js/eslint. Perhaps this is dangerous and could be done using a I'm getting off track, right here all I need is to fix the warnings for extends React.Component. If you prefer I'll remove my class level suppression and replace it with a suppression exclusively on the NAME or GETPROP of the extends clause (first example in code snippet above). This should be easier to apply precisely. With a test. Let me know. |
In terms of docs:
I think that's all relevant places needing an update. The wiki page is pretty good, it's a shame I missed it and had to look at the source code to figure out how it works :-) Really it could do with a better and auto-generated list of warnings and errors, a table that matches up command line options with suppress values and Java API properties etc.. Some other time... |
Also, question: where is source for the debugger (https://closure-compiler-debugger.appspot.com)? How do options in the debugger match up to options in the Java API? I am often hunting through the debugger to find the equivalent of things like language-in. |
We tried to open-source the debugger but it turned out to be hard to do, unfortunately. We will probably manage to get it done someday (or we'll just write a new one that is open from the beginning) but I can't promise any ETA, unfortunately. As for language-in in particular, the checkbox is called LANG_IN_IS_ES6. Checked is ES6, unchecked is ES5. |
@supersteves It's hard to discern intent for For instance, on an ES6 class: /** @suppress {uselessCode} */
class foo {
constructor() {
document.body.offsetWidth;
}
}
foo.prototype.bar = function() {
document.body.offsetWidth; //should the useless code warning be suppressed here?
}; |
@ChadKillingsworth How about if I rework it as specifically just: // Suppress just this warning precisely (on NAME or GETPROP):
class X extends /** @suppress {missingRequires} */ React.Component {} ? |
Closing in anticipation of #1192 |
SuppressDocWarningsGuard wasn't observing class nodes when looking for
@Suppress, as needed for missingRequire on class X extends Y:
Without this:
See #1143
and #1145