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

Mark RequiresDirective's name as MANDATORY #3479

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

datho7561
Copy link
Contributor

@datho7561 datho7561 commented Dec 18, 2024

Elsewhere in the code, it's treated as a mandatory property (for instance in AST rewrites), so it makes sense to update the property descriptor and Javadoc to reflect this.

What it does

  • Mark RequiresDirective's name field as MANDATORY
  • Switch the value of the lazily initialized name to be a SimpleName
  • Document that RequiredDirective.setName(Name name) throws an IllegalArgumentException when attempting to set the name to null

How to test

  • Write an integration test

Author checklist

@datho7561 datho7561 force-pushed the requires-should-allow-deleting-name branch 2 times, most recently from 2d24df1 to 1405884 Compare January 2, 2025 15:27
@datho7561 datho7561 marked this pull request as ready for review January 2, 2025 15:27
@datho7561
Copy link
Contributor Author

@mpalat could you please review this code once you have a chance? From my understanding, you implemented RequiresDirective, so you probably have the best understanding of it. I don't understand why the name was being lazily initialized, and I don't understand why a qualified name was used in the lazy initalization.

Copy link
Contributor

@mpalat mpalat left a comment

Choose a reason for hiding this comment

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

@mpalat could you please review this code once you have a chance? From my understanding, you implemented RequiresDirective, so you probably have the best understanding of it. I don't understand why the name was being lazily initialized, and I don't understand why a qualified name was used in the lazy initalization.

hmm.. well, let me scratch my old memory :)

Looking at the specs, I believe the name should have been MANDATORY rather than optional while it was modifiers that had to be optional - referring section - referring Section 7.7 of JLS :
requires {RequiresModifier} ModuleName. So it's best to change the name to mandatory and leave lazy initialization in tact.

And to answer your second question on why a qualified name was used - I don't see why it should not be used. Guess that it so coded since this mimics import. We can use either a Simple name or a QualifiedName since the ModuleName can be one of those - ref: Section 6.5. Am open for a change to SimpleName if it makes life easier in any case - but modules names tend to be qualified names mostly [no, I don;t have any statistics to prove that].

So I believe the name should be made mandatory and Javadoc updated rather than allowing null.

@datho7561
Copy link
Contributor Author

Okay sounds good. I'll update this PR to mark the name as MANDATORY and update the Javadoc

@datho7561
Copy link
Contributor Author

I've added a new commit that marks the name as MANDATORY and switches the default name over to a SimpleName. I'm going to wait for the CI results before removing the first commit

@datho7561 datho7561 force-pushed the requires-should-allow-deleting-name branch from 09ae75c to 892faa8 Compare January 3, 2025 15:47
@datho7561 datho7561 changed the title Allow setting name of RequiresDirective to null Mark RequiresDirective's name as MANDATORY Jan 3, 2025
- Switch the value of the lazily initialized name to be a `SimpleName`
- Document that `RequiredDirective.setName(Name name)` throws an
  `IllegalArgumentException` when attempting to set the name to `null`

Signed-off-by: David Thompson <davthomp@redhat.com>
@datho7561 datho7561 force-pushed the requires-should-allow-deleting-name branch from 892faa8 to 4dba344 Compare January 3, 2025 16:09
@datho7561 datho7561 requested a review from mpalat January 3, 2025 16:09
@datho7561
Copy link
Contributor Author

Alright, it should be good to review: I've cleaned up the commit and added a test.

datho7561 added a commit to datho7561/eclipse.jdt.core that referenced this pull request Jan 3, 2025
This is new Java 23 syntax.
This PR should make 6 new tests pass
(mostly from the java 23 completion suite)
This PR also incorporates
eclipse-jdt#3479,
I forget specifically why, but it's needed.

- Fixes to the javac AST converter
  - I did a hack in the converter to recover the following case,
    since javac doesn't handle it currently:

```java
import module

public class HelloWorld {
}
```

- Adjust module completion relevance based on if it's required by the current
  module

Signed-off-by: David Thompson <davthomp@redhat.com>
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