-
Notifications
You must be signed in to change notification settings - Fork 4
Refactor: Replace magic strings with ICompareUIConstants #39
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
Conversation
Summary of ChangesHello @vogella, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances code maintainability by refactoring the Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request successfully refactors the code to use constants from ICompareUIConstants, which improves maintainability. It also includes a significant update to the repository's AI agent instructions, making them more comprehensive and generic. My main feedback concerns the hardcoding of colors in the AsciidocMergeViewer. While the intent is likely to provide specific styling, it overrides user-configured preferences and can negatively impact accessibility. I've suggested removing the hardcoded colors to allow the viewer to inherit the standard, user-configurable Eclipse compare colors.
| configuration.setProperty(ICompareUIConstants.INCOMING_COLOR, new RGB(0, 255, 0)); | ||
| configuration.setProperty(ICompareUIConstants.OUTGOING_COLOR, new RGB(255, 0, 0)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While using constants for property keys is a good practice, hardcoding the RGB color values here overrides any user-defined color preferences for the compare editor. This can lead to an inconsistent user experience and may cause accessibility issues (e.g., for users with color blindness who have configured specific high-contrast colors).
It's generally better to let the TextMergeViewer use the default colors provided by the Eclipse platform, which are derived from the current theme and can be configured by the user in the preferences.
I recommend removing these lines to ensure your merge viewer respects the user's color settings.
Replace hardcoded property key strings with constants from ICompareUIConstants interface for better maintainability and to avoid typos in property keys. Changes: - Add import for org.eclipse.compare.ICompareUIConstants - Use ICompareUIConstants.INCOMING_COLOR instead of string literal - Use ICompareUIConstants.OUTGOING_COLOR instead of string literal 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Remove hardcoded RGB color values for incoming/outgoing changes to respect user-configured color preferences and theme settings. This improves accessibility and maintains consistency with Eclipse platform conventions. Changes: - Remove setProperty calls for INCOMING_COLOR and OUTGOING_COLOR - Remove unused ICompareUIConstants and RGB imports - Let TextMergeViewer use default platform colors Addresses review feedback from gemini-code-assist regarding accessibility concerns and user preference overrides. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
6dfdc84 to
38bc9c6
Compare
|
/gemini review |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request aims to refactor magic strings by using constants from ICompareUIConstants. However, the current implementation incorrectly removes the functionality for setting custom colors in the AsciidocMergeViewer instead of refactoring it. This introduces a functional regression. My review includes a critical comment with a code suggestion to correctly implement the intended refactoring. Please address this to ensure the custom colors are still applied using the proper constants.
| public class AsciidocMergeViewer extends TextMergeViewer { | ||
|
|
||
| public AsciidocMergeViewer(Composite parent, int style, CompareConfiguration configuration) { | ||
| super(parent, style, configuration); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pull request description states that the goal is to replace magic strings with constants from ICompareUIConstants. However, the implementation removes the lines that set the custom colors for the merge viewer entirely. This results in a functional regression, as the custom colors will no longer be applied.
To fix this, you should re-add the property setting logic, but use the constants from ICompareUIConstants as intended. Please note that you will also need to add the necessary imports for ICompareUIConstants and RGB.
super(parent, style, configuration);
configuration.setProperty(org.eclipse.compare.ICompareUIConstants.INCOMING_COLOR, new org.eclipse.swt.graphics.RGB(0, 255, 0));
configuration.setProperty(org.eclipse.compare.ICompareUIConstants.OUTGOING_COLOR, new org.eclipse.swt.graphics.RGB(255, 0, 0));This commit fixes a regression introduced in the previous commit. The functionality for setting custom colors in the AsciidocMergeViewer was incorrectly removed. This change restores the functionality by using the constants from ICompareUIConstants.
This commit reverts the usage of the internal class ICompareUIConstants and uses string literals instead. This fixes the build failure.
Summary
ICompareUIConstantsinterfaceorg.eclipse.compare.ICompareUIConstantsChanges
AsciidocMergeViewer.java: UseICompareUIConstants.INCOMING_COLORandICompareUIConstants.OUTGOING_COLORconstants instead of string literalsTest plan
🤖 Generated with Claude Code