From: Andy Clement Date: Wed, 23 Oct 2013 20:16:20 +0000 (-0700) Subject: 420210: additional message keys for declare warning or error X-Git-Tag: V1_7_4~2 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=9319e343d54a65bcfc4a8c19e4305147ce9e27b8;p=aspectj.git 420210: additional message keys for declare warning or error --- 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 @@ + + + + + + + + + + +