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
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>
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ConvertLineDelimitersOperation.java2
-rw-r--r--org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassImplementationsCodeMiningProvider.java2
-rw-r--r--org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassReferenceCodeMiningProvider.java2
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java4
-rw-r--r--org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java6
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java8
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java2
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java4
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java2
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java4
-rw-r--r--org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java4
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java2
-rw-r--r--org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java4
-rw-r--r--org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java4
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java8
-rw-r--r--org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java8
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java6
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java2
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java2
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java4
-rw-r--r--org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java2
-rw-r--r--org.eclipse.text/src/org/eclipse/text/templates/TemplateStoreCore.java2
-rw-r--r--org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManager.java8
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java8
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java10
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java2
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java6
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChangeEncodingAction.java4
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java56
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java4
-rw-r--r--org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/codemining/ProjectReferencesCodeMiningProvider.java2
-rw-r--r--org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/IndentFoldingStrategy.java6
-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
82 files changed, 175 insertions, 175 deletions
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ConvertLineDelimitersOperation.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ConvertLineDelimitersOperation.java
index 77cb80da0fe..32779c32d03 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ConvertLineDelimitersOperation.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/manipulation/ConvertLineDelimitersOperation.java
@@ -64,7 +64,7 @@ public class ConvertLineDelimitersOperation extends TextFileBufferOperation {
for (int i= 0; i < lineCount; i++) {
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);
multiEdit.addChild(new ReplaceEdit(region.getOffset() + region.getLength(), delimiter.length(), fLineDelimiter));
}
diff --git a/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassImplementationsCodeMiningProvider.java b/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassImplementationsCodeMiningProvider.java
index 065dc22beaf..1b450797c0d 100644
--- a/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassImplementationsCodeMiningProvider.java
+++ b/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassImplementationsCodeMiningProvider.java
@@ -56,7 +56,7 @@ public class ClassImplementationsCodeMiningProvider extends AbstractCodeMiningPr
if (index != -1) {
className = className.substring(0, index);
}
- if (className.length() > 0) {
+ if (!className.isEmpty()) {
try {
lenses.add(new ClassImplementationCodeMining(className, lineIndex, document, this));
} catch (BadLocationException e) {
diff --git a/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassReferenceCodeMiningProvider.java b/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassReferenceCodeMiningProvider.java
index 203c0a54728..2a168e95c86 100644
--- a/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassReferenceCodeMiningProvider.java
+++ b/org.eclipse.jface.text.examples/src/org/eclipse/jface/text/examples/codemining/ClassReferenceCodeMiningProvider.java
@@ -44,7 +44,7 @@ public class ClassReferenceCodeMiningProvider extends AbstractCodeMiningProvider
int index = line.indexOf("class ");
if (index == 0) {
String className = line.substring(index + "class ".length(), line.length()).trim();
- if (className.length() > 0) {
+ if (!className.isEmpty()) {
try {
lenses.add(new ClassReferenceCodeMining(className, i, document, this));
} catch (BadLocationException e) {
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
index 15bdd8ac944..b930c66cc5e 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionSummary.java
@@ -186,7 +186,7 @@ class ProjectionSummary {
return;
}
- if (bags != null && bags.size() > 0) {
+ if (bags != null && !bags.isEmpty()) {
Annotation[] deletions= new Annotation[bags.size()];
bags.toArray(deletions);
if (!isCanceled(monitor))
@@ -220,7 +220,7 @@ class ProjectionSummary {
return;
}
- if (additions.size() > 0) {
+ if (!additions.isEmpty()) {
if (visualAnnotationModel instanceof IAnnotationModelExtension) {
IAnnotationModelExtension extension= (IAnnotationModelExtension)visualAnnotationModel;
if (!isCanceled(monitor))
diff --git a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
index 403af6398b0..316a78702c6 100644
--- a/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
+++ b/org.eclipse.jface.text/projection/org/eclipse/jface/text/source/projection/ProjectionViewer.java
@@ -1028,7 +1028,7 @@ public class ProjectionViewer extends SourceViewer implements ITextViewerExtensi
}
}
- if (annotations.size() > 0) {
+ if (!annotations.isEmpty()) {
ProjectionAnnotation[] result= new ProjectionAnnotation[annotations.size()];
annotations.toArray(result);
return result;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java
index e74a7da32d0..d5d1c605f02 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/SelectionProcessor.java
@@ -432,7 +432,7 @@ public final class SelectionProcessor {
for (int offset= 0; offset < lineLength; offset++) {
if (startColumn == -1) {
if (visual == visualStartColumn)
- if (!delete && isWider(content.charAt(offset), visual) && replacement.length() == 0)
+ if (!delete && isWider(content.charAt(offset), visual) && replacement.isEmpty())
startColumn= offset - 1;
else
startColumn= offset;
@@ -458,7 +458,7 @@ public final class SelectionProcessor {
visual+= visualSizeIncrement(content.charAt(offset), visual);
}
if (startColumn == -1) {
- boolean materializeVirtualSpace= replacement.length() != 0;
+ boolean materializeVirtualSpace= !replacement.isEmpty();
if (materializeVirtualSpace) {
int spaces= Math.max(0, visualStartColumn - visual);
char[] array= new char[spaces];
@@ -469,7 +469,7 @@ public final class SelectionProcessor {
}
if (endColumn == -1)
endColumn= lineLength;
- if (replacement.length() == 0)
+ if (replacement.isEmpty())
return new DeleteEdit(info.getOffset() + startColumn, endColumn - startColumn);
return new ReplaceEdit(info.getOffset() + startColumn, endColumn - startColumn, replacement);
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
index 4d7c78ba543..727d0114115 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/codemining/CodeMiningManager.java
@@ -250,7 +250,7 @@ public class CodeMiningManager implements Runnable {
Position pos= new Position(g.getKey().offset, g.getKey().length);
List<ICodeMining> minings= g.getValue();
- boolean inLineHeader= minings.size() > 0 ? (minings.get(0) instanceof LineHeaderCodeMining) : true;
+ boolean inLineHeader= !minings.isEmpty() ? (minings.get(0) instanceof LineHeaderCodeMining) : true;
// Try to find existing annotation
AbstractInlinedAnnotation ann= fInlinedAnnotationSupport.findExistingAnnotation(pos);
if (ann == null) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
index e0c31edb89f..3bcaab28954 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
@@ -280,7 +280,7 @@ public class BrowserInformationControl extends AbstractInformationControl implem
if (fInput != null)
content= fInput.getHtml();
- fBrowserHasContent= content != null && content.length() > 0;
+ fBrowserHasContent= content != null && !content.isEmpty();
if (!fBrowserHasContent)
content= "<html><body ></html>"; //$NON-NLS-1$
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
index 3331c95d772..c148f497594 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/HTML2TextReader.java
@@ -195,7 +195,7 @@ public class HTML2TextReader extends SubstitutionTextReader {
private String html2Text(String html) {
- if (html == null || html.length() == 0)
+ if (html == null || html.isEmpty())
return EMPTY_STRING;
html= html.toLowerCase();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java
index dea4d1d26f8..dad34e718ef 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/SubstitutionTextReader.java
@@ -118,7 +118,7 @@ public abstract class SubstitutionTextReader extends SingleCharReader {
String s= computeSubstitution(c);
if (s == null)
break;
- if (s.length() > 0)
+ if (!s.isEmpty())
fBuffer.insert(0, s);
c= nextChar();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
index 5dda118d83c..2d2b8a52a29 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/link/contentassist/ContextInformationPopup2.java
@@ -600,7 +600,7 @@ class ContextInformationPopup2 implements IContentAssistListener2 {
* @param e the verify event describing the key stroke
*/
private void contextInfoPopupProcessEvent(VerifyEvent e) {
- if (e.start != e.end && (e.text == null || e.text.length() == 0))
+ if (e.start != e.end && (e.text == null || e.text.isEmpty()))
validateContextInformation();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
index 710beacbbca..181e79cf20b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/AbstractInformationControlManager.java
@@ -1112,7 +1112,7 @@ abstract public class AbstractInformationControlManager {
protected void presentInformation() {
boolean hasContents= false;
if (fInformation instanceof String)
- hasContents= ((String)fInformation).trim().length() > 0;
+ hasContents= !((String)fInformation).trim().isEmpty();
else
hasContents= (fInformation != null);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
index a02d9b8af4f..cf417ce4d71 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultDocumentAdapter.java
@@ -319,7 +319,7 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
TextChangedEvent event= new TextChangedEvent(this);
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
+ if (fTextChangeListeners != null && !fTextChangeListeners.isEmpty()) {
Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
e.next().textChanged(event);
@@ -336,7 +336,7 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
TextChangedEvent event = new TextChangedEvent(this);
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
+ if (fTextChangeListeners != null && !fTextChangeListeners.isEmpty()) {
Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
e.next().textSet(event);
@@ -364,7 +364,7 @@ class DefaultDocumentAdapter implements IDocumentAdapter, IDocumentListener, IDo
event.newCharCount= (fEvent.fText == null ? 0 : fEvent.fText.length());
event.newLineCount= (fEvent.fText == null ? 0 : document.computeNumberOfLines(fEvent.fText));
- if (fTextChangeListeners != null && fTextChangeListeners.size() > 0) {
+ if (fTextChangeListeners != null && !fTextChangeListeners.isEmpty()) {
Iterator<TextChangeListener> e= new ArrayList<>(fTextChangeListeners).iterator();
while (e.hasNext())
e.next().textChanging(event);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
index dd19345c8ae..73c1c4ebff1 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultTextHover.java
@@ -61,7 +61,7 @@ public class DefaultTextHover implements ITextHover {
Position p= model.getPosition(a);
if (p != null && p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
String msg= a.getText();
- if (msg != null && msg.trim().length() > 0)
+ if (msg != null && !msg.trim().isEmpty())
return msg;
}
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
index eae94c20c0f..34d2052678b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/DefaultUndoManager.java
@@ -544,7 +544,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
@Override
protected boolean isValid() {
if (isConnected())
- return (fStart > -1 || fCommands.size() > 0);
+ return (fStart > -1 || !fCommands.isEmpty());
return false;
}
@@ -558,7 +558,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
protected long getUndoModificationStamp() {
if (fStart > -1)
return super.getUndoModificationStamp();
- else if (fCommands.size() > 0)
+ else if (!fCommands.isEmpty())
return fCommands.get(0).getUndoModificationStamp();
return fUndoModificationStamp;
@@ -574,7 +574,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
protected long getRedoModificationStamp() {
if (fStart > -1)
return super.getRedoModificationStamp();
- else if (fCommands.size() > 0)
+ else if (!fCommands.isEmpty())
return fCommands.get(fCommands.size()-1).getRedoModificationStamp();
return fRedoModificationStamp;
@@ -988,7 +988,7 @@ public class DefaultUndoManager implements IUndoManager, IUndoManagerExtension {
*/
private boolean isWhitespaceText(String text) {
- if (text == null || text.length() == 0)
+ if (text == null || text.isEmpty())
return false;
String[] delimiters= fTextViewer.getDocument().getLegalLineDelimiters();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
index 2c266dcea06..9b412ebf101 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/TextViewer.java
@@ -4315,7 +4315,7 @@ public class TextViewer extends Viewer implements
if (ignoreWhitespace) {
String s= d.get(line.getOffset(), found[0]);
s= s.trim();
- if (s.length() == 0)
+ if (s.isEmpty())
index= line.getOffset() + found[0];
} else if (found[0] == 0)
index= line.getOffset();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
index 8d909ab49a5..3c1a8100422 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/AsyncCompletionProposalPopup.java
@@ -274,7 +274,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
fFutures= buildCompletionFuturesOrJobs(fInvocationOffset);
fFilteredProposals= runFutures(fInvocationOffset, (List<ICompletionProposal> proposals) -> {
ensureDocumentListenerInstalled();
- if (proposals.size() > 0 && completeCommonPrefix()) {
+ if (!proposals.isEmpty() && completeCommonPrefix()) {
hide();
} else {
fFilteredProposals= proposals;
@@ -311,7 +311,7 @@ class AsyncCompletionProposalPopup extends CompletionProposalPopup {
@Override
protected List<ICompletionProposal> computeFilteredProposals(int offset, DocumentEvent event) {
- if(fComputedProposals != null && fComputedProposals.size() > 0 && fComputedProposals.get(0) instanceof ComputingProposal) {
+ if(fComputedProposals != null && !fComputedProposals.isEmpty() && fComputedProposals.get(0) instanceof ComputingProposal) {
Set<CompletableFuture<List<ICompletionProposal>>> remaining = Collections.synchronizedSet(new HashSet<>(fFutures));
for (CompletableFuture<List<ICompletionProposal>> future : fFutures) {
future.thenRun(() -> {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
index 364b6707941..24ca3e733ed 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/CompletionProposalPopup.java
@@ -369,7 +369,7 @@ class CompletionProposalPopup implements IContentAssistListener {
}
fFilterOffset= offset;
- if (proposals != null && proposals.size() > 0)
+ if (proposals != null && !proposals.isEmpty())
setProposals(proposals, fIsFilteredSubset);
else {
hide();
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
index 6f8b9e9f2ec..7b8de9855a1 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/contentassist/ContextInformationPopup.java
@@ -859,7 +859,7 @@ class ContextInformationPopup implements IContentAssistListener {
* @param e the verify event describing the key stroke
*/
private void contextInfoPopupProcessEvent(VerifyEvent e) {
- if (e.start != e.end && (e.text == null || e.text.length() == 0))
+ if (e.start != e.end && (e.text == null || e.text.isEmpty()))
validateContextInformation();
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
index 46f9e15c531..062d093494f 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/link/LinkedModeUI.java
@@ -677,7 +677,7 @@ public class LinkedModeUI {
Assert.isNotNull(model);
Assert.isNotNull(targets);
Assert.isTrue(targets.length > 0);
- Assert.isTrue(model.getTabStopSequence().size() > 0);
+ Assert.isTrue(!model.getTabStopSequence().isEmpty());
fModel= model;
fTargets= targets;
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
index c23974546dc..8b61857ba42 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/reconciler/AbstractReconciler.java
@@ -502,7 +502,7 @@ abstract public class AbstractReconciler implements IReconciler {
// Insert
fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getText().length(), DirtyRegion.INSERT, e.getText()));
- } else if (e.getText() == null || e.getText().length() == 0) {
+ } else if (e.getText() == null || e.getText().isEmpty()) {
// Remove
fDirtyRegionQueue.addDirtyRegion(new DirtyRegion(e.getOffset(), e.getLength(), DirtyRegion.REMOVE, null));
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
index 45f177595f0..3e2da3958c3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/rules/PatternRule.java
@@ -95,7 +95,7 @@ public class PatternRule implements IPredicateRule {
* @param breaksOnEOL indicates whether the end of the line also terminates the pattern
*/
public PatternRule(String startSequence, String endSequence, IToken token, char escapeCharacter, boolean breaksOnEOL) {
- Assert.isTrue(startSequence != null && startSequence.length() > 0);
+ Assert.isTrue(startSequence != null && !startSequence.isEmpty());
Assert.isTrue(endSequence != null || breaksOnEOL);
Assert.isNotNull(token);
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
index 40b37db2c56..c3de3fae821 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/source/DefaultAnnotationHover.java
@@ -69,7 +69,7 @@ public class DefaultAnnotationHover implements IAnnotationHover {
// optimization
Annotation annotation= javaAnnotations.get(0);
String message= annotation.getText();
- if (message != null && message.trim().length() > 0)
+ if (message != null && !message.trim().isEmpty())
return formatSingleMessage(message);
} else {
@@ -80,7 +80,7 @@ public class DefaultAnnotationHover implements IAnnotationHover {
while (e.hasNext()) {
Annotation annotation= e.next();
String message= annotation.getText();
- if (message != null && message.trim().length() > 0)
+ if (message != null && !message.trim().isEmpty())
messages.add(message.trim());
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
index c02a6294191..c96ef35029b 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/text/templates/persistence/TemplateStore.java
@@ -211,7 +211,7 @@ public class TemplateStore extends TemplateStoreCore {
private void loadCustomTemplates() throws IOException {
String pref= fPreferenceStore.getString(getKey());
- if (pref != null && pref.trim().length() > 0) {
+ if (pref != null && !pref.trim().isEmpty()) {
Reader input= new StringReader(pref);
TemplateReaderWriter reader= new TemplateReaderWriter();
TemplatePersistenceData[] datas= reader.read(input);
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
index d3a7cd1dc54..55932b916d8 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/AbstractTextSearchViewPage.java
@@ -1245,7 +1245,7 @@ public abstract class AbstractTextSearchViewPage extends Page implements ISearch
}
private synchronized boolean hasMoreUpdates() {
- return fBatchedClearAll || fBatchedUpdates.size() > 0;
+ return fBatchedClearAll || !fBatchedUpdates.isEmpty();
}
private boolean isQueryRunning() {
diff --git a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
index 712b89c48a1..c526a26e35e 100644
--- a/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
+++ b/org.eclipse.search/new search/org/eclipse/search/ui/text/FileTextSearchScope.java
@@ -250,7 +250,7 @@ public final class FileTextSearchScope extends TextSearchScope {
if (negativeMatcher) {
pattern= pattern.substring(FileTypeEditor.FILE_PATTERN_NEGATOR.length()).trim();
}
- if (pattern.length() > 0) {
+ if (!pattern.isEmpty()) {
patterns.add(pattern);
}
}
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
index e2ccdd20944..e36c96738b4 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/SearchView.java
@@ -460,7 +460,7 @@ public class SearchView extends PageBookView implements ISearchResultViewPart, I
label= LegacyActionTools.escapeMnemonics(page.getLabel());
}
if (!fPageContent.isDisposed()) {
- if (label.length() == 0) {
+ if (label.isEmpty()) {
if (fDescriptionComposite != null) {
fDescriptionComposite.dispose();
fDescriptionComposite= null;
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java
index 556d742435f..42662b0045b 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/RetrieverAction.java
@@ -71,7 +71,7 @@ abstract public class RetrieverAction extends Action {
}
TextSearchQueryProvider provider= TextSearchQueryProvider.getPreferred();
String searchForString= getSearchForString(page);
- if (searchForString.length() == 0) {
+ if (searchForString.isEmpty()) {
MessageDialog.openInformation(getShell(), SearchMessages.RetrieverAction_dialog_title, SearchMessages.RetrieverAction_empty_selection);
return;
}
@@ -310,7 +310,7 @@ abstract public class RetrieverAction extends Action {
protected String getSearchForString(IWorkbenchPage page) {
String searchFor= extractSearchTextFromSelection(page.getSelection());
- if (searchFor == null || searchFor.length() == 0) {
+ if (searchFor == null || searchFor.isEmpty()) {
IWorkbenchPart activePart= page.getActivePart();
if (activePart instanceof IEditorPart) {
searchFor= extractSearchTextFromEditor((IEditorPart) activePart);
diff --git a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
index 9d29b05308b..9459d72d7a7 100644
--- a/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
+++ b/org.eclipse.search/new search/org/eclipse/search2/internal/ui/text2/TextSearchQueryProviderRegistry.java
@@ -55,7 +55,7 @@ public class TextSearchQueryProviderRegistry {
private void updateProvider(String preferredId) {
fPreferredProviderId= preferredId;
fPreferredProvider= null;
- if (preferredId.length() != 0) { // empty string: default engine
+ if (!preferredId.isEmpty()) { // empty string: default engine
fPreferredProvider= createFromExtension(preferredId);
}
if (fPreferredProvider == null) {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
index b6ec7fd983c..3dec102d717 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchEngineRegistry.java
@@ -53,7 +53,7 @@ public class TextSearchEngineRegistry {
}
private void updateEngine(String preferredId) {
- if (preferredId.length() != 0) { // empty string: default engine
+ if (!preferredId.isEmpty()) { // empty string: default engine
TextSearchEngine engine= createFromExtension(preferredId);
if (engine != null) {
fPreferredEngineId= preferredId;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
index d54ca7c8626..6a23335415a 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/core/text/TextSearchVisitor.java
@@ -210,7 +210,7 @@ public class TextSearchVisitor {
public IStatus processFile(IFile file, IProgressMonitor monitor) {
// A natural cleanup after the change to use JobGroups is accepted would be to move these
// methods to the TextSearchJob class.
- Matcher matcher= fSearchPattern.pattern().length() == 0 ? null : fSearchPattern.matcher(""); //$NON-NLS-1$
+ Matcher matcher= fSearchPattern.pattern().isEmpty() ? null : fSearchPattern.matcher(""); //$NON-NLS-1$
try {
if (!fCollector.acceptFile(file) || matcher == null) {
@@ -377,7 +377,7 @@ public class TextSearchVisitor {
};
try {
- String taskName= fSearchPattern.pattern().length() == 0
+ String taskName= fSearchPattern.pattern().isEmpty()
? SearchMessages.TextSearchVisitor_filesearch_task_label
: Messages.format(SearchMessages.TextSearchVisitor_textsearch_task_label, fSearchPattern.pattern());
fProgressMonitor.beginTask(taskName, fNumberOfFilesToScan);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
index a6a1bc821da..48011ecb199 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/CopyToClipboardAction.java
@@ -90,7 +90,7 @@ public class CopyToClipboardAction extends Action {
sel= text.getSelectionText();
}
if (sel != null) {
- if (sel.length() > 0) {
+ if (!sel.isEmpty()) {
copyToClipboard(sel, shell);
}
return;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
index 14a3fe8760a..f07113fc3bf 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/ScopePart.java
@@ -124,7 +124,7 @@ public class ScopePart {
}
private IWorkingSet getWorkingSet(IWorkingSetManager workingSetManager, String storedName) {
- if (storedName.length() == 0) {
+ if (storedName.isEmpty()) {
IWorkbenchPage page= fSearchDialog.getWorkbenchWindow().getActivePage();
if (page != null) {
return page.getAggregateWorkingSet();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
index 316279d2eca..cc996bbd7e9 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchDialog.java
@@ -492,7 +492,7 @@ public class SearchDialog extends ExtendedDialogWindow implements ISearchPageCon
fReplaceButton= createActionButton(composite, REPLACE_ID, SearchMessages.SearchDialog_replaceAction, true);
fReplaceButton.setVisible(fCurrentPage instanceof IReplacePage);
Button searchButton= createActionButton(composite, SEARCH_ID, SearchMessages.SearchDialog_searchAction, true);
- searchButton.setEnabled(fDescriptors.size() > 0);
+ searchButton.setEnabled(!fDescriptors.isEmpty());
super.createButtonsForButtonBar(composite); // cancel button
return composite;
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
index 7e868698d10..bc8fd238658 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/SearchPreferencePage.java
@@ -209,7 +209,7 @@ public class SearchPreferencePage extends FieldEditorPreferencePage implements I
handleDeletedPerspectives();
IPreferenceStore store= SearchPlugin.getDefault().getPreferenceStore();
String id= store.getString(DEFAULT_PERSPECTIVE);
- if (id == null || id.length() == 0 || id.equals(NO_DEFAULT_PERSPECTIVE))
+ if (id == null || id.isEmpty() || id.equals(NO_DEFAULT_PERSPECTIVE))
return null;
else if (PlatformUI.getWorkbench().getPerspectiveRegistry().findPerspectiveWithId(id) == null) {
store.putValue(DEFAULT_PERSPECTIVE, id);
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
index b396c04c4bf..00228697fde 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchPage.java
@@ -270,7 +270,7 @@ public class FileSearchPage extends AbstractTextSearchViewPage implements IAdapt
fActionGroup.setContext(new ActionContext(getSite().getSelectionProvider().getSelection()));
fActionGroup.fillContextMenu(mgr);
FileSearchQuery query= (FileSearchQuery) getInput().getQuery();
- if (query.getSearchString().length() > 0) {
+ if (!query.getSearchString().isEmpty()) {
IStructuredSelection selection = getViewer().getStructuredSelection();
if (!selection.isEmpty()) {
ReplaceAction replaceSelection= new ReplaceAction(getSite().getShell(), (FileSearchResult)getInput(), selection.toArray());
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
index 01d9a59151c..721662cd70d 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/FileSearchQuery.java
@@ -282,7 +282,7 @@ public class FileSearchQuery implements ISearchQuery {
public String getResultLabel(int nMatches) {
String searchString= getSearchString();
- if (searchString.length() > 0) {
+ if (!searchString.isEmpty()) {
// text search
if (isScopeAllFileTypes()) {
// search all file extensions
@@ -330,7 +330,7 @@ public class FileSearchQuery implements ISearchQuery {
}
public boolean isFileNameSearch() {
- return fSearchText.length() == 0;
+ return fSearchText.isEmpty();
}
public boolean isRegexSearch() {
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
index e07c3653509..ad1ab219fa8 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/text/ReplaceRefactoring.java
@@ -206,7 +206,7 @@ public class ReplaceRefactoring extends Refactoring {
@Override
public RefactoringStatus checkInitialConditions(IProgressMonitor pm) throws CoreException, OperationCanceledException {
String searchString= getQuery().getSearchString();
- if (searchString.length() == 0) {
+ if (searchString.isEmpty()) {
return RefactoringStatus.createFatalErrorStatus(SearchMessages.ReplaceRefactoring_error_illegal_search_string);
}
fMatches.clear();
diff --git a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java
index 0dea1ab343a..bbbf3ad3abd 100644
--- a/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java
+++ b/org.eclipse.search/search/org/eclipse/search/internal/ui/util/ExceptionHandler.java
@@ -116,7 +116,7 @@ public class ExceptionHandler {
perform((CoreException)target, shell, title, message);
} else {
SearchPlugin.log(e);
- if (e.getMessage() != null && e.getMessage().length() > 0) {
+ if (e.getMessage() != null && !e.getMessage().isEmpty()) {
displayMessageDialog(e.getMessage(), shell, title, message);
} else {
displayMessageDialog(target.getMessage(), shell, title, message);
@@ -140,7 +140,7 @@ public class ExceptionHandler {
msg.write(message);
msg.write("\n\n"); //$NON-NLS-1$
}
- if (exceptionMessage == null || exceptionMessage.length() == 0)
+ if (exceptionMessage == null || exceptionMessage.isEmpty())
msg.write(SearchMessages.ExceptionDialog_seeErrorLogMessage);
else
msg.write(exceptionMessage);
diff --git a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
index 94e676a6a85..83d414bfcee 100644
--- a/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
+++ b/org.eclipse.text.tests/projection/org/eclipse/text/tests/ProjectionDocumentTest.java
@@ -1630,8 +1630,8 @@ public class ProjectionDocumentTest {
assertSame(expected.getDocument(), received.getDocument());
Assert.assertEquals(expected.getOffset(), received.getOffset());
Assert.assertEquals(expected.getLength(), received.getLength());
- if (expected.getText() == null || expected.getText().length() == 0)
- assertTrue(received.getText() == null || received.getText().length() == 0);
+ if (expected.getText() == null || expected.getText().isEmpty())
+ assertTrue(received.getText() == null || received.getText().isEmpty());
else
Assert.assertEquals(expected.getText(), received.getText());
}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
index 7682e0e7d8b..ef9c863ba81 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/AnnotationModelStressTest.java
@@ -1374,7 +1374,7 @@ public class AnnotationModelStressTest {
i++;
}
- while (added.size() > 0) {
+ while (!added.isEmpty()) {
assertRemove(added);
assertExist(added);
}
@@ -1405,7 +1405,7 @@ public class AnnotationModelStressTest {
i++;
}
- while (added.size() > 0) {
+ while (!added.isEmpty()) {
assertRemove(added);
assertExistNew(added);
}
@@ -1440,7 +1440,7 @@ public class AnnotationModelStressTest {
i++;
}
- while (added.size() > 0) {
+ while (!added.isEmpty()) {
assertRemove(added);
assertExist(added);
}
@@ -1475,7 +1475,7 @@ public class AnnotationModelStressTest {
i++;
}
- while (added.size() > 0) {
+ while (!added.isEmpty()) {
assertRemove(added);
assertExist(added);
}
diff --git a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
index b05ea551e35..e4a1c99236e 100644
--- a/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
+++ b/org.eclipse.text.tests/src/org/eclipse/text/tests/DocumentExtensionTest.java
@@ -158,7 +158,7 @@ public class DocumentExtensionTest {
@Override
protected Replace getReplace(DocumentEvent e) {
String t= e.getText();
- if (t != null && t.length() > 0) {
+ if (t != null && !t.isEmpty()) {
Replace r= new Replace();
r.fOffset= (e.getOffset() + t.length());
r.fLength= 0;
@@ -189,7 +189,7 @@ public class DocumentExtensionTest {
@Override
protected Replace getReplace(DocumentEvent e) {
String t= e.getText();
- if (t == null || t.length() == 0) {
+ if (t == null || t.isEmpty()) {
Replace r= new Replace();
r.fOffset= e.getOffset();
r.fLength= 0;
@@ -220,7 +220,7 @@ public class DocumentExtensionTest {
@Override
protected Replace getReplace(DocumentEvent e) {
String t= e.getText();
- if (t != null && t.length() > 0) {
+ if (t != null && !t.isEmpty()) {
Replace r= new Replace();
r.fOffset= (e.getOffset() + t.length());
r.fLength= 0;
@@ -288,7 +288,7 @@ public class DocumentExtensionTest {
@Override
protected Replace getReplace(DocumentEvent e) {
String t= e.getText();
- if (t != null && t.length() > 0) {
+ if (t != null && !t.isEmpty()) {
Replace r= new Replace();
r.fOffset= (e.getOffset() + t.length());
r.fLength= 0;
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java b/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java
index 5fad7d961fc..71b13baa154 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/AbstractDocument.java
@@ -682,7 +682,7 @@ public abstract class AbstractDocument implements IDocument, IDocumentExtension,
}
}
- if (fPositions.size() > 0)
+ if (!fPositions.isEmpty())
updatePositions(event);
}
@@ -1117,7 +1117,7 @@ public abstract class AbstractDocument implements IDocument, IDocumentExtension,
@Override
public void replace(int pos, int length, String text) throws BadLocationException {
- if (length == 0 && (text == null || text.length() == 0))
+ if (length == 0 && (text == null || text.isEmpty()))
replace(pos, length, text, getModificationStamp());
else
replace(pos, length, text, getNextModificationStamp());
@@ -1431,7 +1431,7 @@ public abstract class AbstractDocument implements IDocument, IDocumentExtension,
* @since 3.1
*/
protected void fireRewriteSessionChanged(DocumentRewriteSessionEvent event) {
- if (fDocumentRewriteSessionListeners.size() > 0) {
+ if (!fDocumentRewriteSessionListeners.isEmpty()) {
List<IDocumentRewriteSessionListener> list= new ArrayList<>(fDocumentRewriteSessionListeners);
Iterator<IDocumentRewriteSessionListener> e= list.iterator();
while (e.hasNext()) {
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
index a2db834daaf..4a8d7b54071 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/FindReplaceDocumentAdapter.java
@@ -152,7 +152,7 @@ public class FindReplaceDocumentAdapter implements CharSequence {
if (operationCode == FIND_FIRST) {
// Reset
- if (findString == null || findString.length() == 0)
+ if (findString == null || findString.isEmpty())
return null;
// Validate start offset
@@ -233,7 +233,7 @@ public class FindReplaceDocumentAdapter implements CharSequence {
if (operationCode == REPLACE_FIND_NEXT)
fFindReplaceState= FIND_NEXT;
- if (found && fFindReplaceMatcher.group().length() > 0)
+ if (found && !fFindReplaceMatcher.group().isEmpty())
return new Region(fFindReplaceMatcher.start(), fFindReplaceMatcher.group().length());
return null;
}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java
index 495616f8ab9..333ba53ba27 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedModeManager.java
@@ -211,7 +211,7 @@ class LinkedModeManager {
}
} finally {
// if we remove any, make sure the new one got inserted
- Assert.isTrue(fEnvironments.size() > 0);
+ Assert.isTrue(!fEnvironments.isEmpty());
}
}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java
index 204430a7c71..d9ec0f9989d 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/link/LinkedPositionGroup.java
@@ -140,7 +140,7 @@ public class LinkedPositionGroup {
* @throws BadLocationException if the position is invalid
*/
private void checkContent(LinkedPosition position) throws BadLocationException {
- if (fPositions.size() > 0) {
+ if (!fPositions.isEmpty()) {
LinkedPosition groupPosition= fPositions.get(0);
String groupContent= groupPosition.getContent();
String positionContent= position.getContent();
@@ -304,7 +304,7 @@ public class LinkedPositionGroup {
Assert.isTrue(!fIsSealed);
fIsSealed= true;
- if (fHasCustomIteration == false && fPositions.size() > 0) {
+ if (fHasCustomIteration == false && !fPositions.isEmpty()) {
fPositions.get(0).setSequenceNumber(0);
}
}
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java
index 602545e49dc..a12f1935638 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java
@@ -604,7 +604,7 @@ public class AnnotationModel implements IAnnotationModel, IAnnotationModelExtens
* @param modelInitiated indicates whether this changes has been initiated by this model
*/
protected void removeAnnotations(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) {
- if (annotations.size() > 0) {
+ if (!annotations.isEmpty()) {
Iterator<? extends Annotation> e= annotations.iterator();
while (e.hasNext())
removeAnnotation(e.next(), false);
diff --git a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java
index 99a95508bda..58f50cc0847 100644
--- a/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/templates/GlobalTemplateVariables.java
@@ -81,7 +81,7 @@ public class GlobalTemplateVariables {
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
List<String> params= variable.getVariableType().getParams();
- if (params.size() >= 1 && params.get(0) != null) {
+ if (!params.isEmpty() && params.get(0) != null) {
resolveWithParams(variable, context, params);
} else {
// No parameter, use default:
@@ -166,7 +166,7 @@ public class GlobalTemplateVariables {
@Override
public void resolve(TemplateVariable variable, TemplateContext context) {
List<String> params= variable.getVariableType().getParams();
- if (params.size() >= 1 && params.get(0) != null) {
+ if (!params.isEmpty() && params.get(0) != null) {
resolveWithParams(variable, context, params);
} else {
// No parameter, use default format:
diff --git a/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java b/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java
index 926ec91c718..30a3ed63433 100644
--- a/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java
+++ b/org.eclipse.text/src/org/eclipse/text/edits/MoveSourceEdit.java
@@ -329,7 +329,7 @@ public final class MoveSourceEdit extends TextEdit {
}
private void insertEdits(TextEdit root, List<ReplaceEdit> edits) {
- while(edits.size() > 0) {
+ while(!edits.isEmpty()) {
ReplaceEdit edit= edits.remove(0);
insert(root, edit, edits);
}
diff --git a/org.eclipse.text/src/org/eclipse/text/templates/TemplateStoreCore.java b/org.eclipse.text/src/org/eclipse/text/templates/TemplateStoreCore.java
index 08e80498154..0ae02e68ee2 100644
--- a/org.eclipse.text/src/org/eclipse/text/templates/TemplateStoreCore.java
+++ b/org.eclipse.text/src/org/eclipse/text/templates/TemplateStoreCore.java
@@ -428,7 +428,7 @@ public class TemplateStoreCore {
private void loadCustomTemplates() throws IOException {
String pref= fPreferenceStore.get(fKey, null);
- if (pref != null && pref.trim().length() > 0) {
+ if (pref != null && !pref.trim().isEmpty()) {
Reader input= new StringReader(pref);
TemplateReaderWriter reader= new TemplateReaderWriter();
TemplatePersistenceData[] datas= reader.read(input);
diff --git a/org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManager.java b/org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManager.java
index ec9e8ce3272..4794b626eee 100644
--- a/org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManager.java
+++ b/org.eclipse.text/src/org/eclipse/text/undo/DocumentUndoManager.java
@@ -532,14 +532,14 @@ public class DocumentUndoManager implements IDocumentUndoManager {
@Override
protected boolean isValid() {
- return fStart > -1 || fChanges.size() > 0;
+ return fStart > -1 || !fChanges.isEmpty();
}
@Override
protected long getUndoModificationStamp() {
if (fStart > -1) {
return super.getUndoModificationStamp();
- } else if (fChanges.size() > 0) {
+ } else if (!fChanges.isEmpty()) {
return fChanges.get(0)
.getUndoModificationStamp();
}
@@ -551,7 +551,7 @@ public class DocumentUndoManager implements IDocumentUndoManager {
protected long getRedoModificationStamp() {
if (fStart > -1) {
return super.getRedoModificationStamp();
- } else if (fChanges.size() > 0) {
+ } else if (!fChanges.isEmpty()) {
return fChanges.get(fChanges.size() - 1)
.getRedoModificationStamp();
}
@@ -953,7 +953,7 @@ public class DocumentUndoManager implements IDocumentUndoManager {
*/
private boolean isWhitespaceText(String text) {
- if (text == null || text.length() == 0) {
+ if (text == null || text.isEmpty()) {
return false;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
index 79ff070644f..01eb46f7207 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
@@ -268,7 +268,7 @@ public class EncodingActionGroup extends ActionGroup {
IInputValidator inputValidator = new IInputValidator() {
@Override
public String isValid(String newText) {
- return (newText == null || newText.length() == 0) ? " " : null; //$NON-NLS-1$
+ return (newText == null || newText.isEmpty()) ? " " : null; //$NON-NLS-1$
}
};
@@ -354,7 +354,7 @@ public class EncodingActionGroup extends ActionGroup {
public void fillActionBars(IActionBars actionBars) {
IMenuManager menuManager= actionBars.getMenuManager();
IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null && fRetargetActions.size() > 0) {
+ if (editMenu != null && !fRetargetActions.isEmpty()) {
MenuManager subMenu= new MenuManager(TextEditorMessages.Editor_ConvertEncoding_submenu_label);
subMenu.addMenuListener(new IMenuListener() {
@Override
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
index ca60027da1a..3c752f03644 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
@@ -322,7 +322,7 @@ public class TextSourceViewerConfiguration extends SourceViewerConfiguration {
if (modifiers == null)
return -1;
- if (modifiers.length() == 0)
+ if (modifiers.isEmpty())
return SWT.NONE;
int stateMask= 0;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
index 5b81e1d3147..b5b6e80061b 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
@@ -242,7 +242,7 @@ public class ContributionTemplateStore extends TemplateStore {
}
private static boolean isValidTemplateId(String id) {
- return id != null && id.trim().length() != 0; // TODO test validity?
+ return id != null && !id.trim().isEmpty(); // TODO test validity?
}
@Override
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
index e3667a55c19..af158874609 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AccessibilityPreferencePage.java
@@ -161,7 +161,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
@Override
public IStatus validate(Object value) {
StatusInfo status= new StatusInfo();
- if (value instanceof String && ((String)value).length() == 0) {
+ if (value instanceof String && ((String)value).isEmpty()) {
status.setError(TextEditorMessages.TextEditorPreferencePage_emptyInput);
return status;
}
@@ -258,7 +258,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
@Override
public IStatus validate(Object value) {
StatusInfo status= new StatusInfo();
- if (value instanceof String && ((String)value).length() == 0) {
+ if (value instanceof String && ((String)value).isEmpty()) {
status.setError(TextEditorMessages.TextEditorPreferencePage_emptyInput);
return status;
}
@@ -286,7 +286,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
@Override
public IStatus validate(Object value) {
StatusInfo status= new StatusInfo();
- if (value instanceof String && ((String)value).length() == 0) {
+ if (value instanceof String && ((String)value).isEmpty()) {
status.setError(TextEditorMessages.TextEditorPreferencePage_emptyInput);
return status;
}
@@ -570,7 +570,7 @@ public class AccessibilityPreferencePage extends PreferencePage implements IWork
page.setErrorMessage(null);
break;
default:
- if (message.length() == 0) {
+ if (message.isEmpty()) {
message= null;
}
page.setMessage(null);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
index 770021d8ab5..020c7e4982d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/HyperlinkDetectorsConfigurationBlock.java
@@ -590,7 +590,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
if (modifiers == null)
return -1;
- if (modifiers.length() == 0)
+ if (modifiers.isEmpty())
return SWT.NONE;
int stateMask= 0;
@@ -663,7 +663,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
if (modifierString == null)
modifierString= ""; //$NON-NLS-1$
String newModifierString= Action.findModifierString(modifier);
- if (modifierString.length() == 0)
+ if (modifierString.isEmpty())
return newModifierString;
return NLSUtility.format(TextEditorMessages.HyperlinkKeyModifier_concatModifierStrings, new String[] {modifierString, newModifierString});
}
@@ -689,7 +689,7 @@ class HyperlinkDetectorsConfigurationBlock implements IPreferenceConfigurationBl
fPreferencePage.setErrorMessage(null);
break;
default:
- if (message.length() == 0) {
+ if (message.isEmpty()) {
message= null;
}
fPreferencePage.setMessage(null);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
index dc429846b1d..cc409450fbb 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SelectResourcesBlock.java
@@ -549,7 +549,7 @@ class SelectResourcesBlock implements ICheckStateListener, ISelectionChangedList
}
//Update the list with the selections if there are any
- if (checkedListItems.size() > 0)
+ if (!checkedListItems.isEmpty())
checkedStateStore.put(currentTreeSelection, checkedListItems);
if (updatingFromSelection)
grayUpdateHierarchy(currentTreeSelection);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java
index c9cd6b850f7..7fc514f771c 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusUtil.java
@@ -84,7 +84,7 @@ public class StatusUtil {
page.setErrorMessage(null);
break;
default:
- if (message.length() == 0) {
+ if (message.isEmpty()) {
message= null;
}
page.setMessage(null);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
index 43a5380a7bf..143f7825d58 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorDefaultsPreferencePage.java
@@ -208,7 +208,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
@Override
public IStatus validate(Object value) {
StatusInfo status= new StatusInfo();
- if (value instanceof String && ((String)value).length() == 0) {
+ if (value instanceof String && ((String)value).isEmpty()) {
status.setError(TextEditorMessages.TextEditorPreferencePage_emptyInput);
return status;
}
@@ -304,7 +304,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
@Override
public IStatus validate(Object value) {
StatusInfo status= new StatusInfo();
- if (value instanceof String && ((String)value).length() == 0) {
+ if (value instanceof String && ((String)value).isEmpty()) {
status.setError(TextEditorMessages.TextEditorPreferencePage_emptyInput);
return status;
}
@@ -339,7 +339,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
@Override
public IStatus validate(Object value) {
StatusInfo status= new StatusInfo();
- if (value instanceof String && ((String)value).length() == 0) {
+ if (value instanceof String && ((String)value).isEmpty()) {
status.setError(TextEditorMessages.TextEditorPreferencePage_emptyInput);
return status;
}
@@ -571,7 +571,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
public void setErrorMessage(String errorMessage) {
if (errorMessageText != null && !errorMessageText.isDisposed()) {
errorMessageText.setText(errorMessage == null ? " " : errorMessage); //$NON-NLS-1$
- boolean hasError= errorMessage != null && (StringConverter.removeWhiteSpaces(errorMessage)).length() > 0;
+ boolean hasError= errorMessage != null && !(StringConverter.removeWhiteSpaces(errorMessage)).isEmpty();
errorMessageText.setEnabled(hasError);
errorMessageText.setVisible(hasError);
errorMessageText.getParent().update();
@@ -1396,7 +1396,7 @@ public class TextEditorDefaultsPreferencePage extends PreferencePage implements
page.setErrorMessage(null);
break;
default:
- if (message.length() == 0) {
+ if (message.isEmpty()) {
message= null;
}
page.setMessage(null);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
index b45d305610a..88c647be4d1 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
@@ -73,7 +73,7 @@ public final class AnnotationTypeHierarchy {
}
private void append(List<String> list, String string) {
- if (string == null || string.trim().length() == 0)
+ if (string == null || string.trim().isEmpty())
return;
if (!list.contains(string))
@@ -94,11 +94,11 @@ public final class AnnotationTypeHierarchy {
IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
for (IConfigurationElement element : elements) {
String name= element.getAttribute("name"); //$NON-NLS-1$
- if (name == null || name.trim().length() == 0)
+ if (name == null || name.trim().isEmpty())
continue;
String parent= element.getAttribute("super"); //$NON-NLS-1$
- if (parent == null || parent.trim().length() == 0)
+ if (parent == null || parent.trim().isEmpty())
parent= ""; //$NON-NLS-1$
allTypes.put(name, parent);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
index 96f2f1c404f..25f7c48640c 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
@@ -782,7 +782,7 @@ public class AbstractDecoratedTextEditorPreferenceConstants {
if (modifiers == null)
return -1;
- if (modifiers.length() == 0)
+ if (modifiers.isEmpty())
return SWT.NONE;
int stateMask= 0;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index 4cecc2c9f8c..49612303d76 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -398,7 +398,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
@Override
protected void removeAnnotations(List<? extends Annotation> annotations, boolean fireModelChanged, boolean modelInitiated) {
- if (annotations != null && annotations.size() > 0) {
+ if (annotations != null && !annotations.isEmpty()) {
List<Annotation> markerAnnotations= new ArrayList<>();
for (Annotation a : annotations) {
@@ -409,7 +409,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
removeAnnotation(a, false);
}
- if (markerAnnotations.size() > 0) {
+ if (!markerAnnotations.isEmpty()) {
if (modelInitiated) {
// if model initiated also remove it from the marker manager
@@ -620,7 +620,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel impl
IAnnotationMap annotationMap= getAnnotationMap();
- if (annotationMap.size() == 0 && fDeletedAnnotations.isEmpty())
+ if (annotationMap.isEmpty() && fDeletedAnnotations.isEmpty())
return;
if (fMarkerUpdaterSpecifications == null)
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
index 988415a4d41..2161baf3f73 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
@@ -182,7 +182,7 @@ public class AddMarkerAction extends TextEditorAction {
IInputValidator inputValidator= new IInputValidator() {
@Override
public String isValid(String newText) {
- return (newText == null || newText.trim().length() == 0) ? " " : null; //$NON-NLS-1$
+ return (newText == null || newText.trim().isEmpty()) ? " " : null; //$NON-NLS-1$
}
};
InputDialog dialog= new InputDialog(getTextEditor().getSite().getShell(), title, message, proposal, inputValidator);
@@ -195,7 +195,7 @@ public class AddMarkerAction extends TextEditorAction {
return false;
label= label.trim();
- if (label.length() == 0)
+ if (label.isEmpty())
return false;
attributes.put("message", label); //$NON-NLS-1$
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
index 996737dc17f..29f5b8ece70 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
@@ -201,15 +201,15 @@ public final class AnnotationTypeLookup {
AnnotationTypeMapping mapping= new AnnotationTypeMapping();
String s= element.getAttribute(typeAttributeName);
- if (s == null || s.trim().length() == 0) return null;
+ if (s == null || s.trim().isEmpty()) return null;
mapping.fAnnotationType= s;
s= element.getAttribute("markerType"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
+ if (s == null || s.trim().isEmpty()) return null;
mapping.fMarkerType= s;
s= element.getAttribute("markerSeverity"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
mapping.fMarkerSeverity= StringConverter.asInt(s, AnnotationTypeMapping.UNDEFINED);
return mapping;
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChangeEncodingAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChangeEncodingAction.java
index 1d467fd985a..36515a9e052 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChangeEncodingAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChangeEncodingAction.java
@@ -87,7 +87,7 @@ public class ChangeEncodingAction extends TextEditorAction {
super(bundle, prefix, editor);
String key= "dialog.title"; //$NON-NLS-1$;
- if (prefix != null && prefix.length() > 0)
+ if (prefix != null && !prefix.isEmpty())
key= prefix + key;
fDialogTitle= getString(bundle, key, null);
@@ -161,7 +161,7 @@ public class ChangeEncodingAction extends TextEditorAction {
fEncodingEditor.setPage(page);
fEncodingEditor.load();
- if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0)
+ if (encoding == null || encoding.equals(defaultEncoding) || encoding.isEmpty())
fEncodingEditor.loadDefault();
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
index d2c66462ff8..52d70072eb1 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
@@ -368,137 +368,137 @@ public class MarkerAnnotationPreferences {
ReadOnlyAnnotationPreference info= new ReadOnlyAnnotationPreference();
s= element.getAttribute("annotationType"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
+ if (s == null || s.trim().isEmpty()) return null;
info.setAnnotationType(s);
s= element.getAttribute("label"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setPreferenceLabel(s);
s= element.getAttribute("markerType"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setMarkerType(s);
s= element.getAttribute("markerSeverity"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
i= StringConverter.asInt(s, IMarker.SEVERITY_INFO);
info.setSeverity(i);
}
s= element.getAttribute("textPreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setTextPreferenceKey(s);
s= element.getAttribute("textPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setTextPreferenceValue(b);
}
s= element.getAttribute("highlightPreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setHighlightPreferenceKey(s);
s= element.getAttribute("highlightPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setHighlightPreferenceValue(b);
}
s= element.getAttribute("overviewRulerPreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setOverviewRulerPreferenceKey(s);
s= element.getAttribute("overviewRulerPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setOverviewRulerPreferenceValue(b);
}
s= element.getAttribute("verticalRulerPreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setVerticalRulerPreferenceKey(s);
s= element.getAttribute("verticalRulerPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, true);
info.setVerticalRulerPreferenceValue(b);
}
s= element.getAttribute("colorPreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setColorPreferenceKey(s);
s= element.getAttribute("colorPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
RGB rgb= StringConverter.asRGB(s);
info.setColorPreferenceValue(rgb == null ? new RGB(0,0,0) : rgb);
}
s= element.getAttribute("presentationLayer"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
i= StringConverter.asInt(s, 0);
info.setPresentationLayer(i);
}
s= element.getAttribute("contributesToHeader"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setContributesToHeader(b);
}
s= element.getAttribute("showInNextPrevDropdownToolbarActionKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setShowInNextPrevDropdownToolbarActionKey(s);
s= element.getAttribute("showInNextPrevDropdownToolbarAction"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setShowInNextPrevDropdownToolbarAction(b);
}
s= element.getAttribute("isGoToNextNavigationTargetKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setIsGoToNextNavigationTargetKey(s);
s= element.getAttribute("isGoToNextNavigationTarget"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setIsGoToNextNavigationTarget(b);
}
s= element.getAttribute("isGoToPreviousNavigationTargetKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setIsGoToPreviousNavigationTargetKey(s);
s= element.getAttribute("isGoToPreviousNavigationTarget"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
b= StringConverter.asBoolean(s, false);
info.setIsGoToPreviousNavigationTarget(b);
}
s= element.getAttribute("symbolicIcon"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setSymbolicImageName(s);
s= element.getAttribute("icon"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setImageDescriptor(getImageDescriptor(s, element));
s= element.getAttribute("quickFixIcon"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setQuickFixImageDescriptor(getImageDescriptor(s, element));
s= element.getAttribute("annotationImageProvider"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setAnnotationImageProviderData(element, "annotationImageProvider"); //$NON-NLS-1$
s= element.getAttribute("textStylePreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && !s.trim().isEmpty())
info.setTextStylePreferenceKey(s);
s= element.getAttribute("textStylePreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
+ if (s != null && !s.trim().isEmpty()) {
if (AnnotationPreference.STYLE_BOX.equals(s)
|| AnnotationPreference.STYLE_DASHED_BOX.equals(s)
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
index 41aaed68b22..cee66714461 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
@@ -409,7 +409,7 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
IInputValidator inputValidator= new IInputValidator() {
@Override
public String isValid(String newText) {
- return (newText == null || newText.trim().length() == 0) ? " " : null; //$NON-NLS-1$
+ return (newText == null || newText.trim().isEmpty()) ? " " : null; //$NON-NLS-1$
}
};
AddBookmarkDialog dialog= new AddBookmarkDialog(fTextEditor.getSite().getShell(), title, message, proposal, inputValidator, addButtonText);
@@ -422,7 +422,7 @@ public class MarkerRulerAction extends ResourceAction implements IUpdate {
return false;
label= label.trim();
- if (label.length() == 0)
+ if (label.isEmpty())
return false;
MarkerUtilities.setMessage(attributes, label);
diff --git a/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/codemining/ProjectReferencesCodeMiningProvider.java b/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/codemining/ProjectReferencesCodeMiningProvider.java
index 98e07c4f733..f4d0eea8417 100644
--- a/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/codemining/ProjectReferencesCodeMiningProvider.java
+++ b/org.eclipse.ui.genericeditor.examples/src/org/eclipse/ui/genericeditor/examples/dotproject/codemining/ProjectReferencesCodeMiningProvider.java
@@ -48,7 +48,7 @@ public class ProjectReferencesCodeMiningProvider extends AbstractCodeMiningProvi
if (endIndex > startIndex) {
// Check if parent element is projectDescription
String projectName = line.substring(startIndex, endIndex);
- if (projectName.length() > 0) {
+ if (!projectName.isEmpty()) {
try {
minings.add(new ProjectReferenceCodeMining(projectName, i, document, this));
} catch (BadLocationException e) {
diff --git a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/IndentFoldingStrategy.java b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/IndentFoldingStrategy.java
index 19a56b9e6c7..730070d9694 100644
--- a/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/IndentFoldingStrategy.java
+++ b/org.eclipse.ui.genericeditor/src/org/eclipse/ui/internal/genericeditor/folding/IndentFoldingStrategy.java
@@ -266,7 +266,7 @@ public class IndentFoldingStrategy implements IReconcilingStrategy, IReconciling
// be sure projection has not been disabled
if (projectionAnnotationModel != null) {
- if (existing.size() > 0) {
+ if (!existing.isEmpty()) {
deletions.addAll(existing);
}
// send the calculated updates to the annotations to the
@@ -305,7 +305,7 @@ public class IndentFoldingStrategy implements IReconcilingStrategy, IReconciling
// The line starts with the given keyword (ex: starts with "import")
return LineState.StartWithKeyWord;
}
- if (lastLineForKeyword != null && (lineContent == null || lineContent.trim().length() == 0)) {
+ if (lastLineForKeyword != null && (lineContent == null || lineContent.trim().isEmpty())) {
// a last line for keyword was defined, line is empty
return LineState.EmptyLine;
}
@@ -377,7 +377,7 @@ public class IndentFoldingStrategy implements IReconcilingStrategy, IReconciling
int startOffset = document.getLineOffset(line);
int endOffset = document.getLineOffset(endLineNumber) + document.getLineLength(endLineNumber);
Position newPos = new Position(startOffset, endOffset - startOffset);
- if (existing.size() > 0) {
+ if (!existing.isEmpty()) {
FoldingAnnotation existingAnnotation = existing.remove(existing.size() - 1);
updateAnnotations(existingAnnotation, newPos, modifications, deletions);
} else {
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