google / jsinterop-generator

Generates Java annotated with JsInterop from JavaScript extern sources
Apache License 2.0
78 stars 24 forks source link

Add @Override annotation where appropriate #27

Closed realityforge closed 5 years ago

realityforge commented 5 years ago

It serves no real purpose in generated code other than communicating to the developer reading the source code. However this seems worth it, particularly if it is not hard to do. Presumably this will simply be adding annotation in java where the equivalent is present in closure.

jDramaix commented 5 years ago

Hi Peter, it seems to be a good idea (translating @override closure to @Override java annotations). Do you plan to work on that?

realityforge commented 5 years ago

It is on my radar but not in the near future. I did the initial implementation but ran into a few issues:

I do plan to get back to it but not sure when so feel free to pick it up.

The short term plan is to cleanup the closure externs and our usage of it so that there is no warnings. Looking at my code spike it seems I increased the warnings in jsinterop-generator at https://github.com/google/jsinterop-generator/blob/586803654200b235dd54d8478f6dfebcf59d9d6c/java/jsinterop/generator/closure/ClosureJsInteropGenerator.java#L188-L190 by adding some code:

    options.setWarningLevel(DiagnosticGroups.MISSING_CONST_PROPERTY, CheckLevel.ERROR);
    options.setWarningLevel(DiagnosticGroups.MISSING_OVERRIDE, CheckLevel.ERROR);
    options.setWarningLevel(DiagnosticGroups.LINT_CHECKS, CheckLevel.ERROR);
    options.setWarningLevel(DiagnosticGroups.ANALYZER_CHECKS, CheckLevel.ERROR);
    options.setWarningLevel(DiagnosticGroups.forName( "checkTypes" ), CheckLevel.ERROR);

(I am not sure which of these overlap - I was just poking around when I was adding these in).

I then made any of these warnings/errors into fatal for the tool. (Ultimately based off #31).

Once that was done, my plan was to do #25 and then take another swing at this issue

gkdn commented 5 years ago

I would not invest much time for this unless this is as simple as converting @override without adding new requirement to Closure. i.e. pls avoid adding complexity to generator and putting extra constraints to Closure externs for this,

realityforge commented 5 years ago

I don't believe it is possible to do this without adding complexity to the generator so I will close this issue. I still plan on fixing the other issues above but they can be tracked independently