diff options
author | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
---|---|---|
committer | Lars Grefer <eclipse@larsgrefer.de> | 2020-08-08 03:11:12 +0200 |
commit | c1c373f4278426308689db61f7758185e8f0401b (patch) | |
tree | 9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /ajde | |
parent | a508fd5315c6330f2057c219aebc35b15d0ea497 (diff) | |
download | aspectj-c1c373f4278426308689db61f7758185e8f0401b.tar.gz aspectj-c1c373f4278426308689db61f7758185e8f0401b.zip |
'String.indexOf()' expression is replaceable with 'contains()'
Reports any String.indexOf() expressions which can be replaced with a call to the String.contains() method available in Java 5 and newer.
Signed-off-by: Lars Grefer <eclipse@larsgrefer.de>
Diffstat (limited to 'ajde')
4 files changed, 7 insertions, 7 deletions
diff --git a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java index d9e9a0f52..8839b00da 100644 --- a/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java +++ b/ajde/src/main/java/org/aspectj/ajde/ui/StructureSearchManager.java @@ -45,7 +45,7 @@ public class StructureSearchManager { private List<IProgramElement> findMatchesHelper(IProgramElement node, String pattern, IProgramElement.Kind kind, List<IProgramElement> matches) { - if (node != null && node.getName().indexOf(pattern) != -1) { + if (node != null && node.getName().contains(pattern)) { if (kind == null || node.getKind().equals(kind)) { matches.add(node); } diff --git a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java index a8ce3d922..ce0269930 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/ExtensionTest.java @@ -79,7 +79,7 @@ public class ExtensionTest extends AjcTestCase { private IProgramElement getChild(IProgramElement parent, String s) { List<IProgramElement> kids = parent.getChildren(); for (IProgramElement element : kids) { - if (element.getName().indexOf(s) != -1) + if (element.getName().contains(s)) return element; } return null; @@ -90,7 +90,7 @@ public class ExtensionTest extends AjcTestCase { private void findChild(String s, IProgramElement ipe) { if (ipe == null) return; - if (ipe.getName().indexOf(s) != -1) { + if (ipe.getName().contains(s)) { foundNode = ipe; return; } diff --git a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java index c80f33bb6..fe642ff95 100644 --- a/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java +++ b/ajde/src/test/java/org/aspectj/ajde/internal/LstBuildConfigManagerTest.java @@ -53,7 +53,7 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { doBuild("bad-injar.lst"); messages = getMessages("bad-injar.lst"); message = (TestMessage)messages.get(0); - assertTrue(message.getContainedMessage().getMessage().indexOf("skipping missing, empty or corrupt inpath entry") != -1); + assertTrue(message.getContainedMessage().getMessage().contains("skipping missing, empty or corrupt inpath entry")); } public void testErrorMessages() throws IOException { @@ -63,7 +63,7 @@ public class LstBuildConfigManagerTest extends AjdeTestCase { List messages = getMessages("invalid-entry.lst"); TestMessage message = (TestMessage)messages.get(0); - assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().indexOf("aaa.bbb") != -1); + assertTrue(message.getContainedMessage().getMessage(), message.getContainedMessage().getMessage().contains("aaa.bbb")); } diff --git a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java index 6ccddefc0..09d794191 100644 --- a/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java +++ b/ajde/src/test/java/org/aspectj/ajde/ui/utils/TestBuildProgressMonitor.java @@ -55,7 +55,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { if (text.startsWith("woven class ")) numWovenClassMessages++; if (text.startsWith("compiled:")) numCompiledMessages++; if (programmableString != null - && text.indexOf(programmableString) != -1) { + && text.contains(programmableString)) { count--; if (count==0) { if (debugTests) System.out.println("Just got message '"+newText+"' - asking build to cancel"); @@ -80,7 +80,7 @@ public class TestBuildProgressMonitor implements IBuildProgressMonitor { for (Object o : messagesReceived) { String element = (String) o; if (element.startsWith(prefix) && - element.indexOf(distinguishingMarks) != -1) return true; + element.contains(distinguishingMarks)) return true; } return false; } |