diff options
author | Andy Clement <aclement@gopivotal.com> | 2013-10-23 13:16:20 -0700 |
---|---|---|
committer | Andy Clement <aclement@gopivotal.com> | 2013-10-23 13:16:20 -0700 |
commit | 9319e343d54a65bcfc4a8c19e4305147ce9e27b8 (patch) | |
tree | 87de18a1a36b08dab7a59e2fdf1922a9d8659067 | |
parent | b2cd5fa175facc39bd0d1af5a4646b9b39c8bcda (diff) | |
download | aspectj-9319e343d54a65bcfc4a8c19e4305147ce9e27b8.tar.gz aspectj-9319e343d54a65bcfc4a8c19e4305147ce9e27b8.zip |
420210: additional message keys for declare warning or error
-rw-r--r-- | org.aspectj.matcher/src/org/aspectj/weaver/Checker.java | 16 | ||||
-rw-r--r-- | tests/bugs174/extra_inserts/Code.java | 18 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java | 4 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc174/ajc174.xml | 11 |
4 files changed, 49 insertions, 0 deletions
diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/Checker.java b/org.aspectj.matcher/src/org/aspectj/weaver/Checker.java index 384c5d6cd..4a765a9e5 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/Checker.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/Checker.java @@ -222,6 +222,22 @@ public class Checker extends ShadowMunger { return shadow.toString(); } else if (key.equalsIgnoreCase("joinpoint.kind")) { return shadow.getKind().getName(); + } else if (key.equalsIgnoreCase("joinpoint.enclosingclass")) { + return shadow.getEnclosingType().getName(); + } else if (key.equalsIgnoreCase("joinpoint.enclosingmember.name")) { + Member member = shadow.getEnclosingCodeSignature(); + if (member==null) { + return ""; + } else { + return member.getName(); + } + } else if (key.equalsIgnoreCase("joinpoint.enclosingmember")) { + Member member = shadow.getEnclosingCodeSignature(); + if (member==null) { + return ""; + } else { + return member.toString(); + } } else if (key.equalsIgnoreCase("joinpoint.signature")) { return shadow.getSignature().toString(); } else if (key.equalsIgnoreCase("joinpoint.signature.declaringtype")) { diff --git a/tests/bugs174/extra_inserts/Code.java b/tests/bugs174/extra_inserts/Code.java new file mode 100644 index 000000000..fa4d85990 --- /dev/null +++ b/tests/bugs174/extra_inserts/Code.java @@ -0,0 +1,18 @@ +public aspect Code { + declare warning: call(* foo(..)): "Call to foo made inside class {joinpoint.enclosingclass}"; + declare warning: call(* foo(..)): "Call to foo made inside member {joinpoint.enclosingmember.name}"; + declare warning: call(* foo(..)): "Call to foo made inside member {joinpoint.enclosingmember}"; +} +class Bar { + public void booble() { + foo(); + } + public void foo() {} +} + +class Boo { + public void m() { + foo(); + } + public void foo() {} +} diff --git a/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java b/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java index bf7a49825..e492c5646 100644 --- a/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc174/Ajc174Tests.java @@ -21,6 +21,10 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Ajc174Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + public void testExtraInserts() throws Exception { + runTest("extra inserts"); + } + public void testMoreConfigurableLint_419279() throws Exception { runTest("more configurable lint"); } diff --git a/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml b/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml index 09a6c2957..5440b4bad 100644 --- a/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml +++ b/tests/src/org/aspectj/systemtest/ajc174/ajc174.xml @@ -2,6 +2,17 @@ <suite> + <ajc-test dir="bugs174/extra_inserts" title="extra inserts"> + <compile files="Code.java" options="-1.5"> + <message kind="warning" line="8" text="Call to foo made inside class Bar"/> + <message kind="warning" line="15" text="Call to foo made inside class Boo"/> + <message kind="warning" line="8" text="Call to foo made inside member booble"/> + <message kind="warning" line="15" text="Call to foo made inside member m"/> + <message kind="warning" line="8" text="Call to foo made inside member void Bar.booble()"/> + <message kind="warning" line="15" text="Call to foo made inside member void Boo.m()"/> + </compile> + </ajc-test> + <ajc-test dir="bugs174/pr419279" title="more configurable lint"> <compile files="Code.java" options="-1.5"> <message kind="warning" text="advice defined in Code has not been applied [Xlint:adviceDidNotMatch]"/> |