Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLars Vogel2019-06-14 05:20:16 -0400
committerLars Vogel2019-06-14 05:28:57 -0400
commite88d686c1fc682507b0246d04249afa81bdb6146 (patch)
treee277717f5e273ac4d8175534cdf68c80527bba73 /org.eclipse.text
parent45c0a30d7027df909b78fa167cf3da83488581d9 (diff)
downloadeclipse.platform.text-e88d686c1fc682507b0246d04249afa81bdb6146.tar.gz
eclipse.platform.text-e88d686c1fc682507b0246d04249afa81bdb6146.tar.xz
eclipse.platform.text-e88d686c1fc682507b0246d04249afa81bdb6146.zip
Use isEmpty() instead of length() to check if collection is emptyI20190615-1800I20190614-1800
Change-Id: I0106dd0c2ddfa318375877d4562068d82aa9ac5f Signed-off-by: Lars Vogel <Lars.Vogel@vogella.com>
Diffstat (limited to 'org.eclipse.text')
-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
9 files changed, 17 insertions, 17 deletions
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 5fad7d961..71b13baa1 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 a2db834da..4a8d7b540 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 495616f8a..333ba53ba 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 204430a7c..d9ec0f998 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 602545e49..a12f19356 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 99a95508b..58f50cc08 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 926ec91c7..30a3ed634 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 08e804981..0ae02e68e 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 ec9e8ce32..4794b626e 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;
}

Back to the top