From d532892d89865511ea39286e4ebd34fc20b96a5d Mon Sep 17 00:00:00 2001 From: aclement Date: Fri, 6 Oct 2006 16:29:03 +0000 Subject: tests and fixes for jdtlikehandleprovider, bug 159896 --- weaver/src/org/aspectj/weaver/ShadowMunger.java | 64 +++++++++++++++++----- .../weaver/patterns/DeclareErrorOrWarning.java | 14 +++++ 2 files changed, 63 insertions(+), 15 deletions(-) (limited to 'weaver') diff --git a/weaver/src/org/aspectj/weaver/ShadowMunger.java b/weaver/src/org/aspectj/weaver/ShadowMunger.java index a4ac3f8e1..a376187a6 100644 --- a/weaver/src/org/aspectj/weaver/ShadowMunger.java +++ b/weaver/src/org/aspectj/weaver/ShadowMunger.java @@ -273,31 +273,65 @@ public abstract class ShadowMunger implements PartialOrder.PartialComparable, IH } private void addChildNodes(IProgramElement parent, Collection children) { + int afterCtr = 1; + int aroundCtr = 1; + int beforeCtr = 1; + int deCtr = 1; + int dwCtr = 1; for (Iterator iter = children.iterator(); iter.hasNext();) { Object element = (Object) iter.next(); if (element instanceof DeclareErrorOrWarning) { DeclareErrorOrWarning decl = (DeclareErrorOrWarning)element; - IProgramElement deowNode = new ProgramElement( - decl.isError() ? "declare error" : "declare warning", - decl.isError() ? IProgramElement.Kind.DECLARE_ERROR : IProgramElement.Kind.DECLARE_WARNING, - getBinarySourceLocation(decl.getSourceLocation()), - decl.getDeclaringType().getModifiers(), - null,null); - deowNode.setDetails("\"" + AsmRelationshipUtils.genDeclareMessage(decl.getMessage()) + "\""); - parent.addChild(deowNode); + int counter = 0; + if (decl.isError()) { + counter = deCtr++; + } else { + counter = dwCtr++; + } + parent.addChild(createDeclareErrorOrWarningChild(decl,counter)); } else if (element instanceof BcelAdvice) { BcelAdvice advice = (BcelAdvice)element; - IProgramElement adviceNode = new ProgramElement( - advice.kind.getName(), - IProgramElement.Kind.ADVICE, - getBinarySourceLocation(advice.getSourceLocation()), - advice.signature.getModifiers(),null,Collections.EMPTY_LIST); - adviceNode.setDetails(AsmRelationshipUtils.genPointcutDetails(advice.getPointcut())); - parent.addChild(adviceNode); + int counter = 0; + if (advice.getKind().equals(AdviceKind.Before)) { + counter = beforeCtr++; + } else if (advice.getKind().equals(AdviceKind.Around)){ + counter = aroundCtr++; + } else { + counter = afterCtr++; + } + parent.addChild(createAdviceChild(advice,counter)); } } } + private IProgramElement createDeclareErrorOrWarningChild( + DeclareErrorOrWarning decl, int count) { + IProgramElement deowNode = new ProgramElement( + decl.getName(), + decl.isError() ? IProgramElement.Kind.DECLARE_ERROR : IProgramElement.Kind.DECLARE_WARNING, + getBinarySourceLocation(decl.getSourceLocation()), + decl.getDeclaringType().getModifiers(), + null,null); + deowNode.setDetails("\"" + AsmRelationshipUtils.genDeclareMessage(decl.getMessage()) + "\""); + if (count != -1) { + deowNode.setBytecodeName(decl.getName() + "_" + count); + } + return deowNode; + } + + private IProgramElement createAdviceChild(BcelAdvice advice, int counter ) { + IProgramElement adviceNode = new ProgramElement( + advice.kind.getName(), + IProgramElement.Kind.ADVICE, + getBinarySourceLocation(advice.getSourceLocation()), + advice.signature.getModifiers(),null,Collections.EMPTY_LIST); + adviceNode.setDetails(AsmRelationshipUtils.genPointcutDetails(advice.getPointcut())); + if (counter != 1) { + adviceNode.setBytecodeName(advice.getKind().getName() + "$" + counter + "$"); + } + return adviceNode; + } + /** * Returns the binarySourceLocation for the given sourcelocation. This * isn't cached because it's used when faulting in the binary nodes diff --git a/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java b/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java index c4a3948ba..c9b663728 100644 --- a/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java +++ b/weaver/src/org/aspectj/weaver/patterns/DeclareErrorOrWarning.java @@ -31,6 +31,9 @@ public class DeclareErrorOrWarning extends Declare { this.message = message; } + /** + * returns "declare warning: " or "declare error: " + */ public String toString() { StringBuffer buf = new StringBuffer(); buf.append("declare "); @@ -111,4 +114,15 @@ public class DeclareErrorOrWarning extends Declare { public String getNameSuffix() { return "eow"; } + + /** + * returns "declare warning" or "declare error" + */ + public String getName() { + StringBuffer buf = new StringBuffer(); + buf.append("declare "); + if (isError) buf.append("error"); + else buf.append("warning"); + return buf.toString(); + } } -- cgit v1.2.3