]> source.dussan.org Git - aspectj.git/commitdiff
Use static import for HtmlDecorator.TYPE_NAME_LABEL
authorAlexander Kriegisch <Alexander@Kriegisch.name>
Sun, 14 Mar 2021 16:41:11 +0000 (23:41 +0700)
committerAlexander Kriegisch <Alexander@Kriegisch.name>
Tue, 16 Mar 2021 01:25:27 +0000 (08:25 +0700)
Mini refactoring, making the code a bit less verbose

Signed-off-by: Alexander Kriegisch <Alexander@Kriegisch.name>
ajdoc/src/main/java/org/aspectj/tools/ajdoc/HtmlDecorator.java
ajdoc/src/test/java/org/aspectj/tools/ajdoc/CoverageTestCase.java

index 3e3a05c072b49c2384502c4abf9dc060f2601a80..0c519f0eb4f3cd0d30c45cf23205e238e206f203 100644 (file)
@@ -275,7 +275,7 @@ class HtmlDecorator {
                                        // Java15: <pre>static class <span class="type-name-label">ClassA.InnerAspect</span>
                                        // Java8: <pre>static class <span class="typeNameLabel">ClassA.InnerAspect</span>
                                        // Java7 (464604): <pre>public class <span class="strong">Azpect</span>
-                                       classStartIndex = fileContents.toString().indexOf("class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">");
+                                       classStartIndex = fileContents.toString().indexOf("class <span class=\"" + TYPE_NAME_LABEL + "\">");
                                        int classEndIndex = fileContents.toString().indexOf("</span>", classStartIndex);
                                        if (classEndIndex != -1) {
                                                // Convert it to "aspect <span class="TYPE_NAME_LABEL">ClassA.InnerAspect</span>"
index 3be1009988e898af20b56fd6434a2da5e848cfe4..17f0bc9c4bd4106898f09361a811c91acde057e7 100644 (file)
@@ -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",
-                       "<pre>static aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>",
+                       "<pre>static aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>",
                        "Class ClassA.InnerAspect",
-                       "<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>"};
+                       "<pre>static class <span class=\"" + TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>"};
                List<String> 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("<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>"));
+                               missingStrings.contains("<pre>static class <span class=\"" + TYPE_NAME_LABEL + "\">ClassA.InnerAspect</span>"));
 
                // 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</h1>",
-                               "public abstract class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>",
+                               "public abstract class <span class=\"" + TYPE_NAME_LABEL + "\">ClassA</span>",
                                "Aspect ClassA</H2>",
-                               "public abstract aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>"};
+                               "public abstract aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassA</span>"};
                } else {
                        classStrings = new String[] {
                                "Class ClassA</h2>",
-                               "public abstract class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>",
+                               "public abstract class <span class=\"" + TYPE_NAME_LABEL + "\">ClassA</span>",
                                "Aspect ClassA</H2>",
-                               "public abstract aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>"};
+                               "public abstract aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassA</span>"};
                }
                List<String> 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</H2>"));
                assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
-                               classMissing.contains("public abstract aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassA</span>"));
+                               classMissing.contains("public abstract aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassA</span>"));
        }
 
     /**
@@ -657,9 +659,9 @@ public class CoverageTestCase extends AjdocTestCase {
                String[] strings = null;
                strings = new String[] {
                                "Aspect PkgVisibleClass.NestedAspect",
-                               "<pre>static aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>",
+                               "<pre>static aspect <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>",
                                "Class PkgVisibleClass.NestedAspect",
-                               "<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>"};
+                               "<pre>static class <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>"};
                List<String> 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("<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>"));
+                               missingStrings.contains("<pre>static class <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass.NestedAspect</span>"));
                // 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</h1>",
-                               "<pre>class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
+                               "<pre>class <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
                                "Aspect PkgVisibleClass</h2>",
-                               "<pre>aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"};
+                               "<pre>aspect <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"};
                } else {
                        classStrings = new String[] {
                                "Class PkgVisibleClass</h2>",
-                               "<pre>class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
+                               "<pre>class <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass</span>",
                                "Aspect PkgVisibleClass</h2>",
-                               "<pre>aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"};
+                               "<pre>aspect <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"};
                }
                List<String> 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</h2>"));
                assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
-                               classMissing.contains("<pre>aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"));
+                               classMissing.contains("<pre>aspect <span class=\"" + TYPE_NAME_LABEL + "\">PkgVisibleClass</span>"));
        }
 
        /**
@@ -721,9 +723,9 @@ public class CoverageTestCase extends AjdocTestCase {
                String[] strings = null;
                strings = new String [] {
                        "Aspect ClassWithNestedAspect.NestedAspect",
-                       "<pre>static aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>",
+                       "<pre>static aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>",
                        "Class ClassWithNestedAspect.NestedAspect",
-                       "<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>"};
+                       "<pre>static class <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>"};
                List<String> 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("<pre>static class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>"));
+                               missingStrings.contains("<pre>static class <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect.NestedAspect</span>"));
 
                // 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</h1>",
-                               "public class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
+                               "public class <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
                                "Aspect ClassWithNestedAspect</h2>",
-                               "public aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"};
+                               "public aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"};
                } else {
                        classStrings = new String[] {
                                "Class ClassWithNestedAspect</h2>",
-                               "public class <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
+                               "public class <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>",
                                "Aspect ClassWithNestedAspect</h2>",
-                               "public aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"};
+                               "public aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"};
                }
                List<String> 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</h2>"));
                assertTrue(htmlFileClass.getName() + " should not have aspect in its subtitle",
-                               classMissing.contains("public aspect <span class=\"" + HtmlDecorator.TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"));
+                               classMissing.contains("public aspect <span class=\"" + TYPE_NAME_LABEL + "\">ClassWithNestedAspect</span>"));
        }
 
        /**