Skip to content

Conversation

@sgdxbc
Copy link
Contributor

@sgdxbc sgdxbc commented Dec 6, 2024

The .settings/org.eclipse.jdt.core.prefs is read by VS Code Java extension. The content is three fold: the first part is auto-generated by extension so I keep it as is. The second part is for suppress "unused" warnings on the handleXX and onXX private methods which are actually used through reflection. The last part is for formatter. I figure out a set of options that are "backward compatible" i.e. it would not modify an empty solution.

The settings are mostly for handout (though dslabs develop may also benefit), so Makefile is also updated to copy it into handout bundle. This should improve development experience when working on solutions with VS Code. For example, now can hit "format document" without messing any comment in the skeleton.

@sgdxbc
Copy link
Contributor Author

sgdxbc commented Jan 17, 2025

Updated with a settings file dedicated for handout.

@emichael
Copy link
Owner

The .vscode folder makes sense to me. Do you need the .settings folder to get up and running? Could vscode generate something sensible automatically? I'm hesitant to add yet another settings file into this repo, as they're a pain to maintain as the IDE, Java version, and library versions change.

@sgdxbc
Copy link
Contributor Author

sgdxbc commented Jan 21, 2025

That is understandable concern. I have removed the .settings directory, and solved the formatting issue in another way.

Notice that currently IDE would still report that almost all methods as unused in solution template. This hinders identifying actual unused methods (and quite annoying). One possible fix would be changing the visibility of all methods that are accessed through reflection. Do you think that is an acceptable approach? If so I will open another PR for that.

@@ -0,0 +1,6 @@
{
"recommendations": [
Copy link
Owner

Choose a reason for hiding this comment

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

These don't automatically install then, right? redhat.java seems fine but I don't love installing for students some plugin maintained by a random guy.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No it just trigger a popup on the corner like this
image

I agree that install unpopular extension is concerned, but it's the most efficient (and probably the minimal) way to prevent hitting formatting document shortcut to mess up the template's format (because redhat extension format the code differently from google-java-format, and there's no way to configure it to match the style).

There are multiple VS Code extensions that integrate google-java-format to VS Code, I tried some and found this one is the most recent one and works fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

By the way, if student chooses to not install the formatting extension, a dialog will show up when formatting the document
image

Then the student is free to configure the formatter back to redhat (although that is probably not helpful).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

And the student can always opt-out formatting through VS Code at all and run make format directly.

@emichael
Copy link
Owner

Thanks!

Are the dead code warnings noisy/do they get in the way of other warnings?

I'm not super concerned about students dealing with dead code warnings in general. (I typically only look at dead code warnings in particular just before submission, as during development, you naturally have lots of dead code.) It is an unfortunate side-effect of the message/timer delivery reflection magic.

@sgdxbc
Copy link
Contributor Author

sgdxbc commented Jan 22, 2025

In an empty solution template there are around 20 dead code warnings because of reflection. Well it's probably "tolerable" annoying. Just I personally follow "treat warnings as errors" rule :) It's fine for me to leave it as is.

@emichael
Copy link
Owner

Ack, thanks!

I guess the other solution is to change (and force) all of the message handlers to be public. That is probably the correct approach, actually. They're methods other code "calls" into. Not sure why I made them private in the first place.

@emichael emichael merged commit 8ca44f1 into emichael:master Jan 22, 2025
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants