From c8e951296c5f95e82d4c7c3f8eb9b0a647014e20 Mon Sep 17 00:00:00 2001 From: Andy Clement Date: Mon, 6 Oct 2014 17:35:51 -0700 Subject: Fix 436653: conditional aspect activation plus various polish Modified test expectation system so it is possible to say the test cares about one particular message and the rest do not matter (prefix message string with '*') - crude but quick. Polished many places to exploit generics Upgraded all the tests to work on Java8 - some serious changes regarding ajdoc on Java8. Hopefully it has stayed backwards compatible with earlier JDK versions (e.g. if using AspectJ 1.8.3+ with a JDK less than 8) but no explicit testing done for this. --- .../src/org/aspectj/tools/ajdoc/HtmlDecorator.java | 28 +++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'ajdoc/src') diff --git a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java index bad35529f..04af19f2d 100644 --- a/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java +++ b/ajdoc/src/org/aspectj/tools/ajdoc/HtmlDecorator.java @@ -224,7 +224,20 @@ class HtmlDecorator { classStartIndex = fileContents.toString().indexOf("

\nClass "); br = false; } - if (classStartIndex != -1) { + if (classStartIndex == -1) { + // Java8 looks more like this: + //

Class A

+ classStartIndex = fileContents.toString().indexOf("

", classStartIndex); + if (classEndIndex != -1) { + // Convert it to "

Aspect A

" + String classLine = fileContents.toString().substring(classStartIndex, classEndIndex); + String aspectLine = classLine.replaceAll("Class ","Aspect "); + fileContents.delete(classStartIndex, classEndIndex); + fileContents.insert(classStartIndex, aspectLine); + } + } + else if (classStartIndex != -1) { int classEndIndex = fileContents.toString().indexOf("", classStartIndex); if (classStartIndex != -1 && classEndIndex != -1) { String classLine = fileContents.toString().substring(classStartIndex, classEndIndex); @@ -249,6 +262,19 @@ class HtmlDecorator { fileContents.insert(secondClassStartIndex, sb.toString()); } } + else { + // Java8: + //
static class ClassA.InnerAspect
+					classStartIndex = fileContents.toString().indexOf("class ");
+					int classEndIndex = fileContents.toString().indexOf("", classStartIndex);
+					if (classEndIndex != -1) {
+						// Convert it to "aspect ClassA.InnerAspect"
+						String classLine = fileContents.toString().substring(classStartIndex, classEndIndex);
+						String aspectLine = "aspect"+fileContents.substring(classStartIndex+5,classEndIndex);
+						fileContents.delete(classStartIndex, classEndIndex);
+						fileContents.insert(classStartIndex, aspectLine);
+					}
+				}
 			}
 		}
 		file.delete();
-- 
cgit v1.2.3