aboutsummaryrefslogtreecommitdiffstats
path: root/ajdoc/src
diff options
context:
space:
mode:
authorLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:11:12 +0200
committerLars Grefer <eclipse@larsgrefer.de>2020-08-08 03:11:12 +0200
commitc1c373f4278426308689db61f7758185e8f0401b (patch)
tree9e03af2feb69782c50464fc1e1e2ce0d6b6bb8c5 /ajdoc/src
parenta508fd5315c6330f2057c219aebc35b15d0ea497 (diff)
downloadaspectj-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 'ajdoc/src')
-rw-r--r--ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java8
-rw-r--r--ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java2
-rw-r--r--ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java38
3 files changed, 24 insertions, 24 deletions
diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java
index 35e84ca5a..44708bb01 100644
--- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java
+++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java
@@ -192,7 +192,7 @@ class HtmlDecorator {
}
// only add aspect documentation if we're in the correct
// file for the given IProgramElement
- if (file.getName().indexOf(fullname + ".html") != -1) {
+ if (file.getName().contains(fullname + ".html")) {
addAspectDocumentation(decl, fileContents, index);
}
} else {
@@ -202,7 +202,7 @@ class HtmlDecorator {
// moved this here because then can use the IProgramElement.Kind
// rather than checking to see if there's advice - this fixes
// the case with an inner aspect not having the title "Aspect"
- if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().indexOf(decl.toSignatureString()) != -1) {
+ if (decl.getKind().equals(IProgramElement.Kind.ASPECT) && file.getName().contains(decl.toSignatureString())) {
// only want to change "Class" to "Aspect" if we're in the
// file corresponding to the IProgramElement
String fullname = "";
@@ -212,7 +212,7 @@ class HtmlDecorator {
} else {
fullname += decl.toSignatureString();
}
- if (file.getName().indexOf(fullname + ".html") == -1) {
+ if (!file.getName().contains(fullname + ".html")) {
// we're still in the file for a parent IPE
continue;
}
@@ -746,7 +746,7 @@ class HtmlDecorator {
*/
private static String getRelativePathFromHere(String packagePath) {
StringBuffer result = new StringBuffer("");
- if (packagePath != null && (packagePath.indexOf("/") != -1)) {
+ if (packagePath != null && (packagePath.contains("/"))) {
StringTokenizer sTok = new StringTokenizer(packagePath, "/", false);
while (sTok.hasMoreTokens()) {
sTok.nextToken(); // don't care about the token value
diff --git a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java
index cd8a01e26..4b9301ce8 100644
--- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java
+++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/StubFileGenerator.java
@@ -153,7 +153,7 @@ class StubFileGenerator {
if (member.getKind().equals(IProgramElement.Kind.METHOD)
|| member.getKind().equals(IProgramElement.Kind.CONSTRUCTOR)) {
- if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.indexOf("abstract ") != -1) {
+ if (member.getParent().getKind().equals(IProgramElement.Kind.INTERFACE) || signature.contains("abstract ")) {
writer.println(";");
} else {
writer.println(" { }");
diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
index b22d1250d..797c76660 100644
--- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
+++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/AjdocOutputChecker.java
@@ -41,7 +41,7 @@ public class AjdocOutputChecker {
BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
String line = reader.readLine();
while (line != null) {
- if (line.indexOf(requiredString) != -1) {
+ if (line.contains(requiredString)) {
reader.close();
return true;
}
@@ -89,11 +89,11 @@ public class AjdocOutputChecker {
BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
String line = reader.readLine();
while (line != null) {
- if (line.indexOf(sectionHeader) != -1) {
+ if (line.contains(sectionHeader)) {
String nextLine = reader.readLine();
while (nextLine != null &&
- (nextLine.indexOf("========") == -1)) {
- if (nextLine.indexOf(requiredString) != -1) {
+ (!nextLine.contains("========"))) {
+ if (nextLine.contains(requiredString)) {
reader.close();
return true;
}
@@ -151,11 +151,11 @@ public class AjdocOutputChecker {
BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
String line = reader.readLine();
while (line != null) {
- if (line.indexOf("START OF CLASS DATA") != -1) {
+ if (line.contains("START OF CLASS DATA")) {
// found the required class data section
String subLine = reader.readLine();
while(subLine != null
- && (subLine.indexOf("========") == -1)){
+ && (!subLine.contains("========"))){
int relIndex = subLine.indexOf(relationship.toString());
int targetIndex = subLine.indexOf(target);
if ((relIndex != -1) && (targetIndex != -1)) {
@@ -195,24 +195,24 @@ public class AjdocOutputChecker {
if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
return false;
}
- if (sectionHeader.indexOf("DETAIL") == -1) {
+ if (!sectionHeader.contains("DETAIL")) {
return false;
}
BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
String line = reader.readLine();
while (line != null) {
- if (line.indexOf(sectionHeader) != -1) {
+ if (line.contains(sectionHeader)) {
// found the required main section
String nextLine = reader.readLine();
- while (nextLine != null && (nextLine.indexOf("========") == -1)) {
+ while (nextLine != null && (!nextLine.contains("========"))) {
// On JDK11 it looks like <a id="doIt()"> on earlier JDKs it can look like <a name="doit">
- if ((LangUtil.is11VMOrGreater() && nextLine.indexOf("ID=\""+source+"\"") != -1 || nextLine.indexOf("id=\""+source+"\"") != -1) ||
- nextLine.indexOf("NAME=\""+source+"\"") != -1 || nextLine.indexOf("name=\""+source+"\"") != -1) {
+ if ((LangUtil.is11VMOrGreater() && nextLine.contains("ID=\"" + source + "\"") || nextLine.contains("id=\"" + source + "\"")) ||
+ nextLine.contains("NAME=\"" + source + "\"") || nextLine.contains("name=\"" + source + "\"")) {
// found the required subsection
String subLine = reader.readLine();
while(subLine != null
- && (subLine.indexOf("========") == -1)
- && (subLine.indexOf("NAME") == -1 && subLine.indexOf("name") == -1)) {
+ && (!subLine.contains("========"))
+ && (!subLine.contains("NAME") && !subLine.contains("name"))) {
int relIndex = subLine.indexOf(relationship.toString());
int targetIndex = subLine.indexOf(target);
if ((relIndex != -1) && (targetIndex != -1)) {
@@ -259,22 +259,22 @@ public class AjdocOutputChecker {
if (((htmlFile == null) || !htmlFile.getAbsolutePath().endsWith("html"))) {
return false;
}
- if (sectionHeader.indexOf("SUMMARY") == -1) {
+ if (!sectionHeader.contains("SUMMARY")) {
return false;
}
BufferedReader reader = new BufferedReader(new FileReader(htmlFile));
String line = reader.readLine();
while (line != null) {
- if (line.indexOf(sectionHeader) != -1) {
+ if (line.contains(sectionHeader)) {
// found the required main section
String nextLine = reader.readLine();
- while (nextLine != null && (nextLine.indexOf("========") == -1)) {
- if (nextLine.indexOf(source) != -1) {
+ while (nextLine != null && (!nextLine.contains("========"))) {
+ if (nextLine.contains(source)) {
// found the required subsection
String subLine = nextLine;
while(subLine != null
- && (subLine.indexOf("========") == -1)
- && (subLine.indexOf("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">") == -1)) {
+ && (!subLine.contains("========"))
+ && (!subLine.contains("<TR BGCOLOR=\"white\" CLASS=\"TableRowColor\">"))) {
int relIndex = subLine.indexOf(relationship.toString());
int targetIndex = subLine.indexOf(target);
if ((relIndex != -1) && (targetIndex != -1)) {