Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-14 09:20:16 +0000
committerLars Vogel2019-06-14 09:28:57 +0000
commite88d686c1fc682507b0246d04249afa81bdb6146 (patch)
treee277717f5e273ac4d8175534cdf68c80527bba73 /org.eclipse.ui.workbench.texteditor
parent45c0a30d7027df909b78fa167cf3da83488581d9 (diff)
downloadeclipse.platform.text-e88d686c1fc682507b0246d04249afa81bdb6146.tar.gz
eclipse.platform.text-e88d686c1fc682507b0246d04249afa81bdb6146.tar.xz
eclipse.platform.text-e88d686c1fc682507b0246d04249afa81bdb6146.zip
Use isEmpty() instead of length() to check if collection is emptyI20190615-1800I20190614-1800
Change-Id: I0106dd0c2ddfa318375877d4562068d82aa9ac5f Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java8
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java20
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java4
13 files changed, 29 insertions, 29 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java
index 2c192d9ce0b..0a311599c14 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/codemining/CodeMiningProviderRegistry.java
@@ -114,6 +114,6 @@ public class CodeMiningProviderRegistry {
}
}
}
- return providers.size() > 0 ? providers.toArray(new ICodeMiningProvider[providers.size()]) : null;
+ return !providers.isEmpty() ? providers.toArray(new ICodeMiningProvider[providers.size()]) : null;
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
index 698911bdb04..eaf3d69a94d 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
@@ -159,7 +159,7 @@ public class ConvertLineDelimitersAction extends TextEditorAction {
throw new InterruptedException();
final String delimiter= document.getLineDelimiter(i);
- if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(fLineDelimiter)) {
+ if (delimiter != null && !delimiter.isEmpty() && !delimiter.equals(fLineDelimiter)) {
IRegion region= document.getLineInformation(i);
document.replace(region.getOffset() + region.getLength(), delimiter.length(), fLineDelimiter);
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java
index 1bcf74e1793..1c31bd0399a 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java
@@ -111,7 +111,7 @@ class EditorStatusLine implements IEditorStatusLine {
* @return <code>true</code> if the string is <code>null</code>, has 0 length or only white space characters.
*/
private static boolean isMessageEmpty(String message) {
- return message == null || message.trim().length() == 0;
+ return message == null || message.trim().isEmpty();
}
/**
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
index 6346beb22a5..d247e6f4857 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java
@@ -132,9 +132,9 @@ public class FindNextAction extends ResourceAction implements IUpdate {
private String getFindString() {
String fullSelection= fTarget.getSelectionText();
String firstLine= getFirstLine(fullSelection);
- if ((firstLine.length() == 0 || fRegExSearch && fullSelection.equals(fSelection)) && !fFindHistory.isEmpty())
+ if ((firstLine.isEmpty() || fRegExSearch && fullSelection.equals(fSelection)) && !fFindHistory.isEmpty())
return fFindHistory.get(0);
- else if (fRegExSearch && fullSelection.length() > 0)
+ else if (fRegExSearch && !fullSelection.isEmpty())
return FindReplaceDocumentAdapter.escapeForRegExPattern(fullSelection);
else
return firstLine;
@@ -208,7 +208,7 @@ public class FindNextAction extends ResourceAction implements IUpdate {
* @since 3.2
*/
private boolean isWord(String str) {
- if (str == null || str.length() == 0)
+ if (str == null || str.isEmpty())
return false;
for (int i= 0; i < str.length(); i++) {
@@ -394,7 +394,7 @@ public class FindNextAction extends ResourceAction implements IUpdate {
* @return the first line of the selection
*/
private String getFirstLine(String selection) {
- if (selection.length() > 0) {
+ if (!selection.isEmpty()) {
int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0);
if (info[0] > 0)
return selection.substring(0, info[0]);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
index b163592db5b..75ce2910462 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java
@@ -1044,7 +1044,7 @@ class FindReplaceDialog extends Dialog {
* @return the first line of the selection
*/
private String getFirstLine(String selection) {
- if (selection.length() > 0) {
+ if (!selection.isEmpty()) {
int[] info= TextUtilities.indexOf(TextUtilities.DELIMITERS, selection, 0);
if (info[0] > 0)
return selection.substring(0, info[0]);
@@ -1130,7 +1130,7 @@ class FindReplaceDialog extends Dialog {
String fullSelection= fTarget.getSelectionText();
boolean isRegEx= isRegExSearchAvailableAndChecked();
fFindField.removeModifyListener(fFindModifyListener);
- if (fullSelection.length() > 0) {
+ if (!fullSelection.isEmpty()) {
String firstLine= getFirstLine(fullSelection);
String pattern= isRegEx ? FindReplaceDocumentAdapter.escapeForRegExPattern(fullSelection) : firstLine;
fFindField.setText(pattern);
@@ -1143,7 +1143,7 @@ class FindReplaceDialog extends Dialog {
}
} else {
if ("".equals(fFindField.getText())) { //$NON-NLS-1$
- if (fFindHistory.size() > 0)
+ if (!fFindHistory.isEmpty())
fFindField.setText(fFindHistory.get(0));
else
fFindField.setText(""); //$NON-NLS-1$
@@ -1360,7 +1360,7 @@ class FindReplaceDialog extends Dialog {
final String replaceString= getReplaceString();
final String findString= getFindString();
- if (findString != null && findString.length() > 0) {
+ if (findString != null && !findString.isEmpty()) {
class ReplaceAllRunnable implements Runnable {
public int numberOfOccurrences;
@@ -1477,7 +1477,7 @@ class FindReplaceDialog extends Dialog {
String findString= getFindString();
boolean somethingFound= false;
- if (findString != null && findString.length() > 0) {
+ if (findString != null && !findString.isEmpty()) {
try {
somethingFound= findNext(findString, forwardSearch, isCaseSensitiveSearch(), isWrapSearch(), isWholeWordSearch(), isIncrementalSearch() && !isRegExSearchAvailableAndChecked(), isRegExSearchAvailableAndChecked(), beep);
@@ -1604,11 +1604,11 @@ class FindReplaceDialog extends Dialog {
boolean selection= false;
if (fTarget != null)
- selection= fTarget.getSelectionText().length() > 0;
+ selection= !fTarget.getSelectionText().isEmpty();
boolean enable= fTarget != null && (fActiveShell == fParentShell || fActiveShell == getShell());
String str= getFindString();
- boolean findString= str != null && str.length() > 0;
+ boolean findString= str != null && !str.isEmpty();
fWholeWordCheckBox.setEnabled(isWord(str) && !isRegExSearchAvailableAndChecked());
@@ -1627,7 +1627,7 @@ class FindReplaceDialog extends Dialog {
* @since 3.0
*/
private boolean isWord(String str) {
- if (str == null || str.length() == 0)
+ if (str == null || str.isEmpty())
return false;
for (int i= 0; i < str.length(); i++) {
@@ -1855,13 +1855,13 @@ class FindReplaceDialog extends Dialog {
List<String> history= getFindHistory();
String findString= getFindString();
- if (findString.length() > 0)
+ if (!findString.isEmpty())
history.add(0, findString);
writeHistory(history, s, "findhistory"); //$NON-NLS-1$
history= getReplaceHistory();
String replaceString= getReplaceString();
- if (replaceString.length() > 0)
+ if (!replaceString.isEmpty())
history.add(0, replaceString);
writeHistory(history, s, "replacehistory"); //$NON-NLS-1$
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java
index 4e90be89e3b..74481f8cf88 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java
@@ -73,7 +73,7 @@ public class GotoLineAction extends TextEditorAction {
@Override
public String isValid(String input) {
- if (input == null || input.length() == 0)
+ if (input == null || input.isEmpty())
return " "; //$NON-NLS-1$
try {
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java
index 3008b543dd8..b56388224bf 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieCompleteAction.java
@@ -364,7 +364,7 @@ final class HippieCompleteAction extends TextEditorAction {
List<IDocument> documents= HippieCompletionEngine.computeDocuments(getTextEditor());
- if (documents.size() > 0) {
+ if (!documents.isEmpty()) {
fDocument= documents.remove(0);
Iterator<String> suggestions;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java
index 703928a1701..3f9561015ae 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/HippieProposalProcessor.java
@@ -207,7 +207,7 @@ public final class HippieProposalProcessor implements IContentAssistProcessor {
public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
try {
String prefix= getPrefix(viewer, offset);
- if (prefix == null || prefix.length() == 0)
+ if (prefix == null || prefix.isEmpty())
return NO_PROPOSALS;
List<String> suggestions= getSuggestions(viewer, offset, prefix);
@@ -215,7 +215,7 @@ public final class HippieProposalProcessor implements IContentAssistProcessor {
List<ICompletionProposal> result= new ArrayList<>();
for (Iterator<String> it= suggestions.iterator(); it.hasNext();) {
String string= it.next();
- if (string.length() > 0)
+ if (!string.isEmpty())
result.add(createProposal(string, prefix, offset));
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java
index 6bea0347d49..62cc49a080d 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java
@@ -412,7 +412,7 @@ class IncrementalFindTarget implements IFindReplaceTarget, IFindReplaceTargetExt
String pattern= EditorMessages.Editor_FindIncremental_not_found_pattern;
statusError(NLSUtility.format(pattern, new Object[] { reversePrefix, wrapPrefix, string }));
- } else if (string.length() == 0) {
+ } else if (string.isEmpty()) {
if (fForward)
statusMessage(FIELD_NAME);
else
@@ -511,7 +511,7 @@ class IncrementalFindTarget implements IFindReplaceTarget, IFindReplaceTargetExt
}
String string= fFindString.toString();
- if (string.length() == 0) {
+ if (string.isEmpty()) {
fFound= true;
return true;
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java
index 8932fb38e56..3334814446a 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java
@@ -272,7 +272,7 @@ public class MoveLinesAction extends TextEditorAction {
* <code>null</code>, <code>false</code> otherwise
*/
private boolean isWhitespace(String string) {
- return string == null ? true : string.trim().length() == 0;
+ return string == null ? true : string.trim().isEmpty();
}
/*
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
index 3f84654a14a..316a7188021 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java
@@ -140,7 +140,7 @@ public abstract class ResourceAction extends Action {
String imageKey= "image"; //$NON-NLS-1$
String descriptionKey= "description"; //$NON-NLS-1$
- if (prefix != null && prefix.length() > 0) {
+ if (prefix != null && !prefix.isEmpty()) {
labelKey= prefix + labelKey;
tooltipKey= prefix + tooltipKey;
imageKey= prefix + imageKey;
@@ -152,7 +152,7 @@ public abstract class ResourceAction extends Action {
setDescription(getString(bundle, descriptionKey, null));
String file= getString(bundle, imageKey, null);
- if (file != null && file.trim().length() > 0)
+ if (file != null && !file.trim().isEmpty())
setImageDescriptor(ImageDescriptor.createFromFile(getClass(), file));
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java
index 3ea340f9724..4880e467d3a 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java
@@ -241,7 +241,7 @@ public class StatusLineContributionItem extends ContributionItem implements ISta
private void updateMessageLabel() {
if (fLabel != null && !fLabel.isDisposed()) {
Display display= fLabel.getDisplay();
- if ((fErrorText != null && fErrorText.length() > 0) || fErrorImage != null) {
+ if ((fErrorText != null && !fErrorText.isEmpty()) || fErrorImage != null) {
String escapedErrorText= escape(fErrorText);
fLabel.setForeground(JFaceColors.getErrorText(display));
fLabel.setText(escapedErrorText);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
index 095b8607694..6b2e08d731a 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
@@ -275,7 +275,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
public void create() {
super.create();
// update initial OK button to be disabled for new templates
- boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
+ boolean valid= fNameText == null || !fNameText.getText().trim().isEmpty();
if (!valid) {
StatusInfo status = new StatusInfo();
status.setError(TemplatesMessages.EditTemplateDialog_error_noname);
@@ -636,7 +636,7 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
private void updateButtons() {
StatusInfo status;
- boolean valid= fNameText == null || fNameText.getText().trim().length() != 0;
+ boolean valid= fNameText == null || !fNameText.getText().trim().isEmpty();
if (!valid) {
status = new StatusInfo();
if (!fSuppressError)

Back to the top