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

In Surround with try-catch hint add/default to System.Logger. #8253

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

Conversation

errael
Copy link
Contributor

@errael errael commented Feb 16, 2025

This default is also used by Generate > Logger.... Addresses some issues in raised in #8240.
New feature Use existing declared Logger. Fix Logging hints to handle System.Logger.
Add "Put string concatenation in lambda" hint fix. Adjust tests; new tests.

trycatch


Click to collapse/expand PR instructions

By opening a pull request you confirm that, unless explicitly stated otherwise, the changes -

  • are all your own work, and you have the right to contribute them.
  • are contributed solely under the terms and conditions of the Apache License 2.0 (see section 5 of the license for more information).

Please make sure (eg. git log) that all commits have a valid name and email address for you in the Author field.

If you're a first time contributor, see the Contributing guidelines for more information.

If you're a committer, please label the PR before pressing "Create pull request" so that the right test jobs can run.

PR approval and merge checklist:

  1. Was this PR correctly labeled, did the right tests run? When did they run?
  2. Is this PR squashed?
  3. Are author name / email address correct? Are co-authors correctly listed? Do the commit messages need updates?
  4. Does the PR title and description still fit after the Nth iteration? Is the description sufficient to appear in the release notes?

If this PR targets the delivery branch: don't merge. (full wiki article)

This default is also used by `Generate > Logger...`.
Addresses some issues in raised in apache#8240.
New feature `Use existing declared Logger`.
Fix "Logging" hints to handle System.Logger.
@errael errael marked this pull request as draft February 16, 2025 22:32
@errael
Copy link
Contributor Author

errael commented Feb 16, 2025

Notes/issues/questions about this PR.

"java.lang.System.Logger" is used directly because:

System.Logger.class.getName() is "java.lang.System$Logger", note '$',
and "...getQualifiedName().contentEquals" fails, so use litteral class name.

Generate > Logger... requires knowing which kind of logger. That information is only specified in Hints > ErrorFixes > SurroundWithTryCatch. It's weird to be looking into the hints this way, but otherwise some entirely new UI is required. The PR uses FileHintPreferences to grab this info, I've never used it before so this code should be carefully reviewed.
See org.netbeans.modules.java.editor.codegen.LoggerGenerator.isUseSystemLogger

Using System.Logger with code that currently uses java.util.logging works seamlessly when using the default System.LoggerFinder. Agree?

// NOI18N doesn't seem to be used consistently; assuming it's no longer required.

@mbien mbien added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests hints labels Feb 16, 2025
@errael errael force-pushed the SystemLogger branch 2 times, most recently from b25ef0a to 4cdd426 Compare February 18, 2025 20:50
@errael errael marked this pull request as ready for review February 18, 2025 20:54
@errael errael marked this pull request as draft February 18, 2025 23:43
@errael

This comment was marked as outdated.

@errael errael marked this pull request as ready for review February 19, 2025 01:44
@errael errael force-pushed the SystemLogger branch 3 times, most recently from 5d06f2f to 7d026d2 Compare February 20, 2025 01:09
@errael
Copy link
Contributor Author

errael commented Feb 26, 2025

@lahodaj The code for this PR is all about Hints and Generate>Logger; java.compiler and NB's ...api.java.source stuff (relatively unfamiliar to me). The small OP and 1st comment mention possible issues; any comments about these appreciated. (of course a review would be terrific)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hints Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants