mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Cosmetics.
This commit is contained in:
parent
3dbeea6a38
commit
13645705f8
1 changed files with 17 additions and 14 deletions
|
@ -88,8 +88,10 @@ public final class ToggleCommentAction extends TextEditorAction {
|
||||||
|
|
||||||
Shell shell= editor.getSite().getShell();
|
Shell shell= editor.getSite().getShell();
|
||||||
if (!fOperationTarget.canDoOperation(operationCode)) {
|
if (!fOperationTarget.canDoOperation(operationCode)) {
|
||||||
if (shell != null)
|
if (shell != null) {
|
||||||
MessageDialog.openError(shell, CEditorMessages.ToggleComment_error_title, CEditorMessages.ToggleComment_error_message);
|
MessageDialog.openError(shell, CEditorMessages.ToggleComment_error_title,
|
||||||
|
CEditorMessages.ToggleComment_error_message);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,9 +155,10 @@ public final class ToggleCommentAction extends TextEditorAction {
|
||||||
// Perform the check
|
// Perform the check
|
||||||
for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
|
for (int i = 0, j = 0; i < regions.length; i++, j += 2) {
|
||||||
String[] prefixes= fPrefixesMap.get(regions[i].getType());
|
String[] prefixes= fPrefixesMap.get(regions[i].getType());
|
||||||
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0)
|
if (prefixes != null && prefixes.length > 0 && lines[j] >= 0 && lines[j + 1] >= 0 &&
|
||||||
if (!isBlockCommented(lines[j], lines[j + 1], prefixes, document))
|
!isBlockCommented(lines[j], lines[j + 1], prefixes, document)) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
} catch (BadLocationException e) {
|
} catch (BadLocationException e) {
|
||||||
|
@ -223,7 +226,7 @@ public final class ToggleCommentAction extends TextEditorAction {
|
||||||
*/
|
*/
|
||||||
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
|
private boolean isBlockCommented(int startLine, int endLine, String[] prefixes, IDocument document) {
|
||||||
try {
|
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++) {
|
for (int i= startLine; i <= endLine; i++) {
|
||||||
IRegion line= document.getLineInformation(i);
|
IRegion line= document.getLineInformation(i);
|
||||||
String text= document.get(line.getOffset(), line.getLength());
|
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);
|
int[] found= TextUtilities.indexOf(prefixes, text, 0);
|
||||||
|
|
||||||
if (found[0] == -1) {
|
if (found[0] == -1) {
|
||||||
// found a line which is not commented
|
// Found a line which is not commented
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String s= document.get(line.getOffset(), found[0]);
|
String s= document.get(line.getOffset(), found[0]);
|
||||||
s= s.trim();
|
s= s.trim();
|
||||||
if (s.length() != 0) {
|
if (s.length() != 0) {
|
||||||
// found a line which is not commented
|
// Found a line which is not commented
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue