1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-06 17:26:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2010-04-18 03:37:46 +00:00
parent 3dbeea6a38
commit 13645705f8

View file

@ -88,8 +88,10 @@ public final class ToggleCommentAction extends TextEditorAction {
Shell shell= editor.getSite().getShell();
if (!fOperationTarget.canDoOperation(operationCode)) {
if (shell != null)
MessageDialog.openError(shell, CEditorMessages.ToggleComment_error_title, CEditorMessages.ToggleComment_error_message);
if (shell != null) {
MessageDialog.openError(shell, CEditorMessages.ToggleComment_error_title,
CEditorMessages.ToggleComment_error_message);
}
return;
}
@ -153,10 +155,11 @@ public final class ToggleCommentAction extends TextEditorAction {
// Perform the check
for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
String[] prefixes= fPrefixesMap.get(regions[i].getType());
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0)
if (!isBlockCommented(lines[j], lines[j + 1], prefixes, document))
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0 &&
!isBlockCommented(lines[j], lines[j + 1], prefixes, document)) {
return false;
}
}
return true;
} catch (BadLocationException e) {
CUIPlugin.log(e); // Should not happen
@ -223,7 +226,7 @@ public final class ToggleCommentAction extends TextEditorAction {
*/
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
try {
// check for occurrences of prefixes in the given lines
// Check for occurrences of prefixes in the given lines
for (int i= startLine; i <= endLine; i++) {
IRegion line= document.getLineInformation(i);
String text= document.get(line.getOffset(), line.getLength());
@ -231,14 +234,14 @@ public final class ToggleCommentAction extends TextEditorAction {
int[] found= TextUtilities.indexOf(prefixes, text, 0);
if (found[0] == -1) {
// found a line which is not commented
// Found a line which is not commented
return false;
}
String s= document.get(line.getOffset(), found[0]);
s= s.trim();
if (s.length() != 0) {
// found a line which is not commented
// Found a line which is not commented
return false;
}
}