Skip to content
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

Enable NonNullByDefault for lspe4.plugin #1009

Merged
merged 15 commits into from
Aug 13, 2024
Merged

Conversation

sebthom
Copy link
Member

@sebthom sebthom commented May 21, 2024

I'd propose the introduction of NonNullByDefault Eclipse annotation on package level for improved null safety.
The current code base is very inconsistent regarding null value handling and contains hidden null pointer issues that e.g. result in issues like this #913

My goal is to progressively enable the NonNullByDefault on package level(s).

I have good experience in TM4E moving to NonNullByDefault. I found hidden bugs in the control flow and it now gives me increased confidence in working with the API and during refactorings.

@mickaelistria @rubenporras do you support this change?

Reference: https://help.eclipse.org/latest/topic/org.eclipse.jdt.doc.user/tasks/task-using_null_annotations.htm

@sebthom sebthom force-pushed the null-safety branch 4 times, most recently from 01484a1 to 562fd0c Compare May 22, 2024 10:32
@sebthom sebthom marked this pull request as draft May 22, 2024 11:38
@rubenporras
Copy link
Contributor

@mickaelistria @rubenporras do you support this change?

From my side, yes, I like the idea. I still need to go through the PR to have a better idea.

@mickaelistria
Copy link
Contributor

I'd be fine with @NonNullByDefault as much as possible. null is the worst thing in the Java language.

@sebthom sebthom force-pushed the null-safety branch 8 times, most recently from 8b8cd52 to 42620c8 Compare July 22, 2024 18:54
@sebthom sebthom marked this pull request as ready for review July 22, 2024 19:02
@sebthom sebthom requested a review from rubenporras July 22, 2024 19:02
@sebthom sebthom changed the title Enable NonNullByDefault for some packages Enable NonNullByDefault for lspe4.plugin Jul 22, 2024
@sebthom
Copy link
Member Author

sebthom commented Jul 22, 2024

@rubenporras I am aware that this is a huge PR. Enabling annotation based null analysis affects everything, so I had to adjust all classes of the plugin. I hope no other PRs are merged before this one, as that would lead to substantial effort in resolving merge conflicts.

@sebthom sebthom force-pushed the null-safety branch 4 times, most recently from de42a41 to 0753ef3 Compare August 8, 2024 12:32
@rubenporras
Copy link
Contributor

@sebthom , you just asked for the review at the beginning of my summer holidays ;) I will check it today.

@sebthom
Copy link
Member Author

sebthom commented Aug 13, 2024

@sebthom , you just asked for the review at the beginning of my summer holidays ;) I will check it today.

@rubenporras no worries, I hope you are well rested :)

@@ -21,12 +21,12 @@
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<name>org.eclipse.pde.ds.core.builder</name>
Copy link
Contributor

Choose a reason for hiding this comment

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

could we undo the changes in this file?

Copy link
Member Author

Choose a reason for hiding this comment

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

We could but evertime I checkout or switch a branch with Eclipse, the entries get modified/reordered, so I guessed that is how new Eclipse or m2e versions like it.

org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
org.eclipse.jdt.core.compiler.annotation.nullanalysis=enabled
org.eclipse.jdt.core.compiler.annotation.owning=org.eclipse.jdt.annotation.Owning
org.eclipse.jdt.core.compiler.annotation.resourceanalysis=disabled
Copy link
Contributor

Choose a reason for hiding this comment

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

Is resourceanalysis=disabled related to this PR? If so, how?

Copy link
Member Author

Choose a reason for hiding this comment

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

that is the default setting. it is set by eclipse 2024-06 automatically.

this.contextInformationLanguageServersFuture.get(CONTEXT_INFORMATION_TIMEOUT, TimeUnit.MILLISECONDS);
} catch (ResponseErrorException | ExecutionException e) {
if (!CancellationUtil.isRequestCancelledException(e)) { // do not report error if the server has cancelled the request
if (!CancellationUtil.isRequestCancelledException(e)) { // do not report error if the server has cancelled
Copy link
Contributor

Choose a reason for hiding this comment

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

the indentation of this comment is a bit weird now (at least on the GitHub review. Could we revert the change, or make it shorter so that the auto-format leaves it all in one line?

Copy link
Member Author

Choose a reason for hiding this comment

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

I could, but this is done by the current Eclipse formatter settings and I prefer to use the formatter settings because otherwise we have to manually update readjust the code everytime when we do code changes and use the formatter.

Copy link
Member Author

Choose a reason for hiding this comment

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

I would actually really appreciate if we could harmonize the formatter settings of all LSP4E modules (they currently differ) and in a single commit reformat the whole project with these settings.

} catch (OperationCanceledException | ResponseErrorException | ExecutionException | CancellationException e) {
if (!CancellationUtil.isRequestCancelledException(e)) { // do not report error if the server has cancelled the request
if (!CancellationUtil.isRequestCancelledException(e)) { // do not report error if the server has cancelled
// the request
Copy link
Contributor

Choose a reason for hiding this comment

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

same comment about the format of the comment

@rubenporras rubenporras merged commit 3ed68da into eclipse:main Aug 13, 2024
6 checks passed
@sebthom
Copy link
Member Author

sebthom commented Aug 13, 2024

@rubenporras thanks for the review and your trust!

@rubenporras
Copy link
Contributor

Let cross fingers 👍

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.

3 participants