Skip to content

update: Fix BreadCrumbComponent use of double #8583

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

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

Conversation

BradWalker
Copy link
Member

@BradWalker BradWalker commented Jun 14, 2025

update: Fix BreadCrumbComponent use of double

desc: The code in BreadCrumbComponent reads the fields from the Dimension class. These fields are integers. So the code encounters an implicit case. This is problematic for several reasons:

1 - casting leads to an error
[repeat] /home/bwalker/src/netbeans/ide/editor.breadcrumbs/src/org/netbeans/modules/editor/breadcrumbs/BreadCrumbComponent.java:166: warning: [lossy-conversions] implicit cast from double to int in compound assignment is possibly lossy
[repeat] xTotal += sizes[i] = preferedSize.width;
[repeat] ^
[repeat] /home/bwalker/src/netbeans/ide/editor.breadcrumbs/src/org/netbeans/modules/editor/breadcrumbs/BreadCrumbComponent.java:193: warning: [lossy-conversions] implicit cast from double to int in compound assignment is possibly lossy
[repeat] elemX += sizes[i];
[repeat] ^

2 - There is no need for floating point precision here.

testing: built and executed with no issues.


^Add meaningful description above

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)

desc: The code in BreadCrumbComponent reads the fields from the Dimension class. These fields are integers. So the code encounters
an implicit case. This is problematic for several reasons:

1 - casting leads to an error
   [repeat] /home/bwalker/src/netbeans/ide/editor.breadcrumbs/src/org/netbeans/modules/editor/breadcrumbs/BreadCrumbComponent.java:166: warning: [lossy-conversions] implicit cast from double to int in compound assignment is possibly lossy
   [repeat]             xTotal += sizes[i] = preferedSize.width;
   [repeat]                                ^
   [repeat] /home/bwalker/src/netbeans/ide/editor.breadcrumbs/src/org/netbeans/modules/editor/breadcrumbs/BreadCrumbComponent.java:193: warning: [lossy-conversions] implicit cast from double to int in compound assignment is possibly lossy
   [repeat]             elemX += sizes[i];
   [repeat]                           ^

2 - There is no need for floating point precision here.

testing: built and executed with no issues.
@BradWalker BradWalker added this to the NB27 milestone Jun 14, 2025
@BradWalker BradWalker self-assigned this Jun 14, 2025
@BradWalker
Copy link
Member Author

Also, this eliminates any remaining "warnings" related to double.. FYI.

@mbien mbien added the Editor label Jun 20, 2025
Copy link
Member

@mbien mbien left a comment

Choose a reason for hiding this comment

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

looked through the usages using NB and everything dealt with int - fix makes sense to me, thanks brad!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants