-
Notifications
You must be signed in to change notification settings - Fork 83
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
refix: quick-fix for extraneous empty line(s) in manifest editor #573
base: master
Are you sure you want to change the base?
refix: quick-fix for extraneous empty line(s) in manifest editor #573
Conversation
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
Since this change seems to be non trivial could you please add some tests for it? |
I was looking for prior arts in manifest compiler test cases. I came across 2 types and both pose challenges to my scenario, so I thought I will ask here:
Are there better options that does these?
|
I will propose to do this (PDE compiler errors/warning) via a separate issue. API tools do have test case for API tool scenarios ( however there too , we don't have tests for quickfixes). In JDT, we have tests for JDT compiler errors and warnings. It will be good to have a set of test case for PDE compiler problems as well( not only extra lines but all of the other ones) ( we could look at both JDT as well as API tool test scenarios to get started with this work). |
@gireeshpunathil Can you please update this patch wrt master? |
538fe5f
to
1b98fb8
Compare
@vik-chand @HannesWell @iloveeclipse - pushed a change to improve the parsing, pls have a look. I have tested locally and everything looks ok; will continue to look for ways to add test scenarios in subsequent PR(s). |
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.
OK, last state is definitely better.
Please don't create multiple commits for this feature and squash previous commits with the next commit that would handle requested changes in one commit.
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/ExtraneousLinesResolution.java
Show resolved
Hide resolved
@gireeshpunathil For multi-fix, we may need to override public IMarker[] findOtherMarkers(IMarker[] markers) { |
ok - multi-fix is new to me. when I debugged, what I could see is:
any suggestions? |
If I remember correctly, you can override a method to get all markers at once somehow to handle them as one batch. |
For multi-fix of adding since tag ( in API Tools), after adding each since tag, the line number does change. It will be worth seeing what is done there to overcome this issue. |
did not find another resolver that does a similar thing. I tried a hack by persisting the state across so one reasonable approach I see is to aggregate all the warnings in one marker, and resolve it atomically. Might look little odd from the ui perspective, but I think it is the right thing to do from a use case point of view too: no one would want to fix one extraneous line and leave another untouched, do they? WDYT? |
Would work, sure. Just create a marker pointing to very first line. In theory one could simply avoid storing any line info (except first) and simply go over file and remove every empty line. |
ed64e15
to
32c7e04
Compare
@iloveeclipse - pushed a change to this effect. please have a look! |
sure, will follow that in future. (in the previous project I worked, we leave the review commits separate for sometime, so that the reviewers can |
d3090bd
to
10ee1c3
Compare
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.
Should be mostly OK now, just few smaller nitpicks.
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/ExtraneousLinesResolution.java
Outdated
Show resolved
Hide resolved
ui/org.eclipse.pde.ui/src/org/eclipse/pde/internal/ui/correction/ExtraneousLinesResolution.java
Outdated
Show resolved
Hide resolved
...rg.eclipse.pde.core/src/org/eclipse/pde/internal/core/builders/JarManifestErrorReporter.java
Outdated
Show resolved
Hide resolved
@iloveeclipse - I have been on vacation for almost a month, will address the review comments sometime this week. |
10ee1c3
to
a1b95bc
Compare
@iloveeclipse - apologies for the delay, was stuck with split priorities. I have addressed all the comments, pls have a look. thanks! |
I also found a strange thing while testing this. If I add empty lines between I tested with master and can see it is a pre-existing scenario. Looks like the first fatal error caused skipping of the rest of the parsing, including the |
a1b95bc
to
b4bd5e2
Compare
@jukzi - did you add / modify any commits to this PR? I do see some actions above but do not see any files changed, so just wondering what it could have been! thanks. @iloveeclipse - when you get some time, pls review this PR, or else let me know if you still have |
i only rebased |
I don't know what is the usual practices in this situation for this project; this PR is waiting for more than a month for review or cancellation of previously set X mark. @iloveeclipse @HannesWell @vik-chand - pls advise. |
@iloveeclipse Can you please review the latest change? |
@@ -2353,6 +2353,8 @@ NoLineTerminationResolutionCreate_description=Adds a line break at the end of th | |||
NoLineTerminationResolutionCreate_label=Add a line break after the header | |||
NoLineTerminationResolutionRemove_description=Removes all whitespace characters from the last line of the manifest | |||
NoLineTerminationResolutionRemove_label=Remove excess whitespace from the end of the manifest | |||
ExtraneousLineResolutionRemove_label=Remove extraneous lines |
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.
Would be more clear to add "empty" before "lines". That's even more explanatory then "extraneous"
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 add a Juni Test that shows removing multiple lines works as expected.
None of the quickfixes in Manifest file has JUnit. It will be a good idea to create a separate issue to create Junit test for quickfixes. |
@vik-chand then please you finish review. |
Sure, I will review this |
My review comments -
Based on this, either JUnit for quickfixes of PDE ( on similar lines of JDT UI - I believe JDT UI has one) is a good idea. In any case, we should also create an issue for this so as to not lose this work item. |
thanks @vik-chand for the review. IMO, the problem is with the current design of quick-fix resolution framework in the empty lines context. we could very well attach one marker per error. But when it comes to the resolution site, applying of the fix poses challenge. When one fix is applied, it renders the rest of the markers invalid - due to the fact that the line numbers stored in those markers are changed due to the first resolution. Depending on relative position of the marker that is being resolved, the other markers may contain valid or invalid data. I can go back to single-fix (from where we started originally), but that again may look a weak feature from end user perspective? let me dig a little more to see if there is a way to synchronize multiple markers w.r.t resolutions. If it proves to be impossible, I am happy to fall back to single fix. Ideas welcome! |
ok, I was doing a little digging around how to develop multi-fix in a fool-proof manner, and looked at how similar quick-fix implementations are doing.
I stopped looking further after these 3. In short, the multi-fix is already inconsistent, and looks like we went to and fro a couple of times in this PR in search of ideal behaviour. I can invest more time on this, but would like to know if it makes sense to land this as is, given the prior arts. I can then spend time on implementing a marker aggregator function in the |
You can open a bug for RemoveRequireBundleResolution & RemoveImportPackageResolution So with this PR we are mimicking this behavior ( RemoveUnknownExecEnvironments). I think in the quickfix if you make make it explicit( via text) that all extraneous lines will be deleted. What do you think @HannesWell ? |
I haven't follow the discussion closely, but in general I agree that it would be good if the quick-fix removes all extraneous empty lines on the first run. And I also think that it should be consistent and other quick-fixes in a similar situation should behave the same. IMHO it would be worth to invest some time into this. :) |
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.
Also please open an issue for junits for quickfixes
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.
Just tried out this change and I get errors when there are entries outside the main section (which is valid):
Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Host
Bundle-SymbolicName: host;singleton:=true
Bundle-Version: 1.0.0.qualifier
Bundle-RequiredExecutionEnvironment: JavaSE-11
Name: com/ibm/icu/text/TitlecaseTransliterator.class
SHA-256-Digest: bGXIJlHHRm7FZikT6z4B1DZw87oPajgDwhHlAojb5a0=
You can see these extra entries for example in all jar-signed artifacts in the TP. So I think an error in this case is a false-positive.
4003eb8
to
fd1420e
Compare
@HannesWell - pushed a change to fix this issue, can you please have a look? thanks! |
fd1420e
to
5d84758
Compare
5d84758
to
4430347
Compare
@HannesWell anything left here? |
I'll have to check it again in the next days, have to familiaries myself again with this change. |
Extraneous lines are errneous to the manifest compiler, but it does not recommend / provide a resolution. Add a quick fix to remove extraneous line. Takes care of the empty valid empty lines at the end of manifests. In the main iteration loop, identify empty lines and push into a list. At the end of the loop, aggregate all the empty lines into one single marker. This way, we address issues that can arise from race conditions when two threas try to manipulate the document context simultaneously. Fixes: eclipse-pde#563
4430347
to
eb404d3
Compare
Any updates here? |
Extraneous lines are erroneous to the manifest compiler, but it does not recommend / provide a resolution. Add a quick fix to remove extraneous line. takes care of the empty valid empty lines at the end of manifests.
Fixes: #563
Refs: #564
Refs: #572
/cc @iloveeclipse @vik-chand - please review. The issue with the previous one was that I was checking whether the pertinent line is the last one or not (in which case we ignore it, as the last line can be empty as per the spec), but that logic did not cater to multiple last lines.
The new version addresses this by getting the rest of the content in the file and trim it to see if those are empty. I tested it and looks like it works.
Also, I converted this as a warning, and removed the return statement, so that this does not block the build.