From 798ee65035142594c43c8c154baaafd557d5d11e Mon Sep 17 00:00:00 2001 From: Alexander Kriegisch Date: Sun, 14 Mar 2021 23:41:11 +0700 Subject: [PATCH] Use static import for HtmlDecorator.TYPE_NAME_LABEL Mini refactoring, making the code a bit less verbose Signed-off-by: Alexander Kriegisch --- .../aspectj/tools/ajdoc/HtmlDecorator.java | 2 +- .../aspectj/tools/ajdoc/CoverageTestCase.java | 50 ++++++++++--------- 2 files changed, 27 insertions(+), 25 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 3e3a05c07..0c519f0eb 100644 --- a/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -275,7 +275,7 @@ class HtmlDecorator { // Java15:
static class ClassA.InnerAspect
 					// Java8: 
static class ClassA.InnerAspect
 					// Java7 (464604): 
public class Azpect
-					classStartIndex = fileContents.toString().indexOf("class ");
+					classStartIndex = fileContents.toString().indexOf("class ");
 					int classEndIndex = fileContents.toString().indexOf("", classStartIndex);
 					if (classEndIndex != -1) {
 						// Convert it to "aspect ClassA.InnerAspect"
diff --git a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java
index 3be100998..17f0bc9c4 100644
--- a/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java
+++ b/ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java
@@ -16,6 +16,8 @@ import java.util.List;
 
 import org.aspectj.util.LangUtil;
 
+import static org.aspectj.tools.ajdoc.HtmlDecorator.TYPE_NAME_LABEL;
+
 /**
  * A long way to go until full coverage, but this is the place to add more.
  *
@@ -131,9 +133,9 @@ public class CoverageTestCase extends AjdocTestCase {
 		String[] strings = null;
 		strings = new String[] {
 			"Aspect ClassA.InnerAspect",
-			"
static aspect ClassA.InnerAspect",
+			"
static aspect ClassA.InnerAspect",
 			"Class ClassA.InnerAspect",
-			"
static class ClassA.InnerAspect"};
+			"
static class ClassA.InnerAspect"};
 		List missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
 		StringBuilder buf = new StringBuilder();
 		for (String str:missingStrings) {
@@ -144,7 +146,7 @@ public class CoverageTestCase extends AjdocTestCase {
 		assertTrue(htmlFile.getName() + " should not have Class as it's title",
 				missingStrings.contains("Class ClassA.InnerAspect"));
 		assertTrue(htmlFile.getName() + " should not have class in its subtitle",
-				missingStrings.contains("
static class ClassA.InnerAspect"));
+				missingStrings.contains("
static class ClassA.InnerAspect"));
 
 		// get the html file for the enclosing class
         File htmlFileClass = new File(getAbsolutePathOutdir() + "/foo/ClassA.html");
@@ -160,21 +162,21 @@ public class CoverageTestCase extends AjdocTestCase {
 		if (LangUtil.is13VMOrGreater()) {
 			classStrings = new String[] {
 				"Class ClassA",
-				"public abstract class ClassA",
+				"public abstract class ClassA",
 				"Aspect ClassA",
-				"public abstract aspect ClassA"};
+				"public abstract aspect ClassA"};
 		} else {
 			classStrings = new String[] {
 				"Class ClassA",
-				"public abstract class ClassA",
+				"public abstract class ClassA",
 				"Aspect ClassA",
-				"public abstract aspect ClassA"};
+				"public abstract aspect ClassA"};
 		}
 		List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
 		assertEquals("There should be 2 missing strings:\n"+classMissing,2,classMissing.size());
 		assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",classMissing.contains("Aspect ClassA"));
 		assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
-				classMissing.contains("public abstract aspect ClassA"));
+				classMissing.contains("public abstract aspect ClassA"));
 	}
 
     /**
@@ -657,9 +659,9 @@ public class CoverageTestCase extends AjdocTestCase {
 		String[] strings = null;
 		strings = new String[] {
 				"Aspect PkgVisibleClass.NestedAspect",
-				"
static aspect PkgVisibleClass.NestedAspect",
+				"
static aspect PkgVisibleClass.NestedAspect",
 				"Class PkgVisibleClass.NestedAspect",
-				"
static class PkgVisibleClass.NestedAspect"};
+				"
static class PkgVisibleClass.NestedAspect"};
 		List missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
 		StringBuilder buf = new StringBuilder();
 		for (String str:missingStrings) {
@@ -669,7 +671,7 @@ public class CoverageTestCase extends AjdocTestCase {
 		assertEquals("There should be 2 missing strings",2,missingStrings.size());
 		assertTrue(htmlFile.getName() + " should not have Class as it's title",missingStrings.contains("Class PkgVisibleClass.NestedAspect"));
 		assertTrue(htmlFile.getName() + " should not have class in its subtitle",
-				missingStrings.contains("
static class PkgVisibleClass.NestedAspect"));
+				missingStrings.contains("
static class PkgVisibleClass.NestedAspect"));
 		// get the html file for the enclosing class
         File htmlFileClass = new File(getAbsolutePathOutdir() + "/PkgVisibleClass.html");
 		if (!htmlFileClass.exists()) {
@@ -683,22 +685,22 @@ public class CoverageTestCase extends AjdocTestCase {
 		if (LangUtil.is13VMOrGreater()) {
 			classStrings = new String[] {
 				"Class PkgVisibleClass",
-				"
class PkgVisibleClass",
+				"
class PkgVisibleClass",
 				"Aspect PkgVisibleClass",
-				"
aspect PkgVisibleClass"};
+				"
aspect PkgVisibleClass"};
 		} else {
 			classStrings = new String[] {
 				"Class PkgVisibleClass",
-				"
class PkgVisibleClass",
+				"
class PkgVisibleClass",
 				"Aspect PkgVisibleClass",
-				"
aspect PkgVisibleClass"};
+				"
aspect PkgVisibleClass"};
 		}
 		List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
 		assertEquals("There should be 2 missing strings",2,classMissing.size());
 		assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
 				classMissing.contains("Aspect PkgVisibleClass"));
 		assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
-				classMissing.contains("
aspect PkgVisibleClass"));
+				classMissing.contains("
aspect PkgVisibleClass"));
 	}
 
 	/**
@@ -721,9 +723,9 @@ public class CoverageTestCase extends AjdocTestCase {
 		String[] strings = null;
 		strings = new String [] {
 			"Aspect ClassWithNestedAspect.NestedAspect",
-			"
static aspect ClassWithNestedAspect.NestedAspect",
+			"
static aspect ClassWithNestedAspect.NestedAspect",
 			"Class ClassWithNestedAspect.NestedAspect",
-			"
static class ClassWithNestedAspect.NestedAspect"};
+			"
static class ClassWithNestedAspect.NestedAspect"};
 		List missingStrings = AjdocOutputChecker.getMissingStringsInFile(htmlFile,strings);
 		StringBuilder buf = new StringBuilder();
 		for (String str:missingStrings) {
@@ -733,7 +735,7 @@ public class CoverageTestCase extends AjdocTestCase {
 		assertEquals("There should be 2 missing strings",2,missingStrings.size());
 		assertTrue(htmlFile.getName() + " should not have Class as it's title",missingStrings.contains("Class ClassWithNestedAspect.NestedAspect"));
 		assertTrue(htmlFile.getName() + " should not have class in its subtitle",
-				missingStrings.contains("
static class ClassWithNestedAspect.NestedAspect"));
+				missingStrings.contains("
static class ClassWithNestedAspect.NestedAspect"));
 
 		// get the html file for the enclosing class
         File htmlFileClass = new File(getAbsolutePathOutdir() + "/pkg/ClassWithNestedAspect.html");
@@ -748,22 +750,22 @@ public class CoverageTestCase extends AjdocTestCase {
 		if (LangUtil.is13VMOrGreater()) {
 			classStrings = new String[] {
 				"Class ClassWithNestedAspect",
-				"public class ClassWithNestedAspect",
+				"public class ClassWithNestedAspect",
 				"Aspect ClassWithNestedAspect",
-				"public aspect ClassWithNestedAspect"};
+				"public aspect ClassWithNestedAspect"};
 		} else {
 			classStrings = new String[] {
 				"Class ClassWithNestedAspect",
-				"public class ClassWithNestedAspect",
+				"public class ClassWithNestedAspect",
 				"Aspect ClassWithNestedAspect",
-				"public aspect ClassWithNestedAspect"};
+				"public aspect ClassWithNestedAspect"};
 		}
 		List classMissing = AjdocOutputChecker.getMissingStringsInFile(htmlFileClass,classStrings);
 		assertEquals("There should be 2 missing strings",2,classMissing.size());
 		assertTrue(htmlFileClass.getName() + " should not have Aspect as it's title",
 				classMissing.contains("Aspect ClassWithNestedAspect"));
 		assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
-				classMissing.contains("public aspect ClassWithNestedAspect"));
+				classMissing.contains("public aspect ClassWithNestedAspect"));
 	}
 
 	/**
-- 
2.39.5