-
Notifications
You must be signed in to change notification settings - Fork 120
Quick fix for adding a space after the colon #1629
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
Quick fix for adding a space after the colon #1629
Conversation
Can anyone please review this PR? |
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.
It generally looks quite fine to me. I've not had time to actually try it in the IDE. Maybe later today or tomorrow. Sorry no one has looked that is so far.
public static final int M_EXEC_ENV_TOO_LOW = 0x1029; // other problem | ||
public static final int M_CONFLICTING_AUTOMATIC_MODULE = 0x1030; // other | ||
// problem | ||
public static final int M_NO_SPACE_AFTER_COLON = 0x1032; // other problem |
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.
I wonder why this is 1032 and not 1031?
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.
I have raised PR for a few other quick fixes too. Still in review.
Adding the 1031 PR here: https://github.com/eclipse-pde/eclipse.pde/pull/1625/files
Hi @merks , |
bc5e11b
to
c006664
Compare
This pull request changes some projects for the first time in this development cycle.
An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch. Git patch
Further information are available in Common Build Issues - Missing version increments. |
e115ec2
to
baddcfa
Compare
return; | ||
} | ||
if (line.length() < colon + 2 || line.charAt(colon + 1) != ' ') { | ||
report(PDECoreMessages.BundleErrorReporter_noSpaceValue, lineNumber, CompilerFlags.ERROR, PDEMarkerFactory.CAT_FATAL); |
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.
Does BundleErrorReporter_noSpaceValue become unused as a result of this change?
It's defined as
BundleErrorReporter_noSpaceValue = Single space and a value is required after the header name
But the new property doesn't sound like a description of the error but rare a description of what the quick fix will do:
AddSpaceAfterColon_add=Add a space after the colon
report(PDECoreMessages.BundleErrorReporter_invalidHeaderName, lineNumber, CompilerFlags.ERROR, PDEMarkerFactory.CAT_FATAL); | ||
return; | ||
} | ||
if (line.length() >= colon + 2 && line.charAt(colon + 1) != ' ') { |
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.
It's not clear why you changing the condition under which an error is generated.
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.
This condition is added to check if there is a space after the ':' and just before the value part.
If not, error is thrown saying 'Single space is required after the
colon' via PDECoreMessages.BundleErrorReporter_noSpaceAfterColon
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.
Ah, silly me. It's an addition. Sorry.
} | ||
|
||
} catch (Exception e) { | ||
|
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.
I'm not sure it's a good idea to just catch any exception and then just ignore it. What exception might be of concern here? I guess BadLocationException, which shouldn't be possible given the guards, but better that's more clear.
ea36cfd
to
a8f0994
Compare
try { | ||
IDocument doc = model.getDocument(); | ||
int lineNum; | ||
lineNum = (int) marker.getAttribute(IMarker.LINE_NUMBER); |
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.
I was trying to figure out where the CoreException comes, and it's here. Probably better to use org.eclipse.core.resources.IMarker.getAttribute(String, int)` which doesn't throw an exception and returns an int.
I'm also not sure why you split the variable declaration from the variable initialization. That doesn't look so nice.
doc.replace(offset, colonInd + 1, userHeader); | ||
} | ||
} catch (BadLocationException e) { | ||
e.printStackTrace(); |
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.
Stack trace printing is almost always a bad idea because unless one monitoring the running IDE with a console, you want see this and then the operation quietly does nothing with no logged details about why.
BTW, what I find often very useful is to search the SDK workspace for similar things. I have a feeling from all the failures that this need to be rebased. If you properly test that the location cannot be bad, then it's okay to have just a comment saying the location has been checked to ensure that it cannot be a bad location. |
a8f0994
to
fc5b9fd
Compare
@merks |
815db17
to
af0ca90
Compare
Hi @merks |
} catch (BadLocationException e) { | ||
// the location has been checked to ensure that it cannot be a bad | ||
// location | ||
e.printStackTrace(); |
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.
Either this can never happen because guards or it should be logged, but not just printed to the console.
ba943e3
to
bd68815
Compare
Hi @merks |
ca6863f
to
7aedfb6
Compare
03a64a3
to
f51785a
Compare
60ea554
to
6f46999
Compare
ee3bde3
to
011febc
Compare
@merks kindly review this PR. |
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.
Mostly looks good. Needs the copyright/license header for the new file.
@@ -0,0 +1,50 @@ | |||
package org.eclipse.pde.internal.ui.correction; |
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.
Missing copyright/license header.
ee3bde3
to
fc9cc6b
Compare
fc9cc6b
to
0b900f2
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.
It generally looks fine, but I didn't have time to test it.
This is to provide a quick fix for situations when no space is added after the colon in the MANIFEST.MF file, and the value is entered by the user.
For example, in line 12, there is no space after the colon before the value 'test'. To address this, we are providing a quick fix to add a space there, as shown below:
Attaching the screenshot before and after applying the quick fix.