-
Notifications
You must be signed in to change notification settings - Fork 97
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
extension mechanism for ignore white space action of the compare view #429
Conversation
team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java
Outdated
Show resolved
Hide resolved
@tobiasmelcher Thanks for the contribution. |
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.
LGTM
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.
LGTM
@tobiasmelcher |
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.
Please
- Squash all commits to one.
- Add tests for new API.
This can be done at the point-in-time when merging the PR. |
Yes please. |
Yes, it could, but there will be 4 commit messages to re-write by committer. Why not provide a proper commit with proper commit message written by contributor? |
I think that multiple commits make it easier to follow the code review flow. A force push after a first code review makes it impossible to follow the code review comment - or I did not find the possibility. |
private static boolean isSignificantWhitespace(String line, int columnNumber, char character, int lineNumber, | ||
DocLineComparator comparator) { | ||
boolean isWhitespace = Character.isWhitespace(character); | ||
if (isWhitespace && comparator.fIgnoreWhitespaceContributor != null |
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.
May I suggest to avoid == false
comparision and instead something like
IIgnoreWhitespaceContributor ignoreWhitespaceContributor = comparator.fIgnoreWhitespaceContributor;
if (isWhitespace && ignoreWhitespaceContributor != null
&& !ignoreWhitespaceContributor.isIgnoredWhitespace(lineNumber, columnNumber)) {
isWhitespace = false; // whitespace should be included and not ignored
}
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.
please take a look at 9f6f105
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.
please take a look at 9f6f105
@iloveeclipse: Can you review again? Are you fine with Tobias change?
...dles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
Outdated
Show resolved
Hide resolved
unit tests are implemented with c16b8f2. Could you please review? Thanks. |
...pse.compare/compare/org/eclipse/compare/contentmergeviewer/IIgnoreWhitespaceContributor.java
Outdated
Show resolved
Hide resolved
...pse.compare/compare/org/eclipse/compare/contentmergeviewer/IIgnoreWhitespaceContributor.java
Outdated
Show resolved
Hide resolved
...g.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java
Outdated
Show resolved
Hide resolved
...g.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java
Outdated
Show resolved
Hide resolved
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.
See my change proposals
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Outdated
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Outdated
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Outdated
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Outdated
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Outdated
Show resolved
Hide resolved
...g.eclipse.compare.tests/src/org/eclipse/compare/tests/SimpleIgnoreWhitespaceContributor.java
Outdated
Show resolved
Hide resolved
team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java
Outdated
Show resolved
Hide resolved
team/bundles/org.eclipse.compare/compare/org/eclipse/compare/internal/DocLineComparator.java
Outdated
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Show resolved
Hide resolved
team/tests/org.eclipse.compare.tests/src/org/eclipse/compare/tests/DocLineComparatorTest.java
Show resolved
Hide resolved
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.
Please also squash all commits to one and provide one commit with a clear commit message and description what APi was added etc.
...dles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
Show resolved
Hide resolved
The "Ignore White Space" context menu action in the eclipse compare view is ignoring all whitespaces in the source code, including the significant ones. Whitespace differences in string literals in programming languages like Java for example are quite important and should not simply be ignored. Allow tool implementers to hook into the ignore whitespace algorithm by providing an implementation of interface IIgnoreWhitespaceContributor; similar to TextMergeViewer#createTokenComparator, a new method TextMergeViewer#createIgnoreWhitespaceContributor is introduced which can be overridden when creating the TextMergeViewer in the IViewerCreator#createViewer extension.
Thanks @tobiasmelcher for this nice addition. |
Do we need a new and noteworthy for this API addition? |
Would be nice |
How do I do that? If you give me a hint I ill provide some. |
Here's a recent example that I did: |
Thanks. I added a N&N entry (see eclipse-platform/www.eclipse.org-eclipse-news#96) |
The "Ignore White Space" context menu action in the eclipse compare view is ignoring all whitespaces in the source code, including the significant ones. Whitespace differences in string literals in programming languages like Java or ABAP for example are quite important and should not simply be ignored. We got at least this feedback from our users of the ABAP Development Tools here at SAP.
The changes in this pull request allow tool implementers to hook into the ignore whitespace algorithm by providing an implementation of interface IIgnoreWhitespaceContributor; similar to TextMergeViewer#createTokenComparator, a new method TextMergeViewer#createIgnoreWhitespaceContributor is introduced which can be overriden when creating the TextMergeViewer in the IViewerCreator#createViewer extension.
IIgnoreWhitespaceContributor#isIgnoredWhitespace is called in the "Ignore White Space" action run for each found whitespace and the implementer can decide whether the whitespace can be really ignored or not if it is part of a string literal.
The "Text Compare" IViewerCreator implementation will ignore all whitespaces because it cannot have any knowledge about the programming language. Language specific IViewerCreator implementations like "Java Compare" or "ABAP Compare" can now influence the ignore whitespace behavior and include all programming language relevant whitespaces inside string literals or elsewhere.
I worked on this pull request as part of the "Contributing to Eclipse" Hackathon here at SAP and it would be great if you could take a look and review it? Feedback is very welcome.