Top Fields Constructors Methods
org.aspectj.weaver.model

public Class AsmRelationshipProvider

extends Object
Class Inheritance
Imports
java.io.File, java.lang.reflect.Modifier, java.util.ArrayList, .Collection, .Collections, .List, org.aspectj.asm.AsmManager, .IHierarchy, .IProgramElement, .IRelationship, .IRelationshipMap, org.aspectj.asm.internal.HandleProviderDelimiter, .ProgramElement, org.aspectj.bridge.ISourceLocation, .SourceLocation, org.aspectj.weaver.Advice, .AdviceKind, .Checker, .Lint, .Member, .NewParentTypeMunger, .ReferenceType, .ResolvedMember, .ResolvedPointcutDefinition, .ResolvedType, .ResolvedTypeMunger, .ResolvedTypeMunger.Kind, .Shadow, .ShadowMunger, .UnresolvedType, .World, org.aspectj.weaver.bcel.BcelShadow, .BcelTypeMunger, org.aspectj.weaver.patterns.DeclareErrorOrWarning, .DeclareParents, .Pointcut, .TypePatternList

Field Summary

Modifier and TypeField and Description
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
public static final String
private static final String
public static final String
public static final String

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static void
addAdvisedRelationship(AsmManager model, Shadow matchedShadow, ShadowMunger munger)

private static void
private static void
public static void
addDeclareAnnotationFieldRelationship(AsmManager model, ISourceLocation declareLocation, String affectedTypeName, ResolvedMember affectedFieldName, boolean isRemove)

Add a relationship for a matching declare ATfield.

public static void
addDeclareAnnotationMethodRelationship(ISourceLocation sourceLocation, String affectedTypeName, ResolvedMember affectedMethod, AsmManager model)

Add a relationship for a matching declare annotation method or declare annotation constructor.

public static void
addDeclareAnnotationRelationship(AsmManager model, ISourceLocation declareAnnotationLocation, ISourceLocation annotatedLocation, boolean isRemove)

Adds a declare annotation relationship, sometimes entities don't have source locs (methods/fields) so use other variants of this method if that is the case as they will look the entities up in the structure model.

public static void
addDeclareErrorOrWarningRelationship(AsmManager model, Shadow affectedShadow, Checker deow)

Add a relationship for a declare error or declare warning

private static void
addPointcuts(AsmManager model, String sourcefilename, ResolvedType aspect, IProgramElement containingAspect, ResolvedMember[] pointcuts)

public static void
addRelationship(AsmManager model, ResolvedType onType, ResolvedTypeMunger typeTransformer, ResolvedType originatingAspect)

Add a relationship for a type transformation (declare parents, intertype method declaration, declare annotation on type).

private static IProgramElement
private static IProgramElement
private static IProgramElement
public static IProgramElement
private static void
createHierarchy(AsmManager model, ResolvedTypeMunger typeTransformer, ResolvedType aspect)

Create a basic hierarchy to represent an aspect only available in binary (from the aspectpath).

public static void
createHierarchyForBinaryAspect(AsmManager asm, ShadowMunger munger)

Creates the hierarchy for binary aspects

private static IProgramElement
createIntertypeDeclaredChild(AsmManager model, ResolvedType aspect, BcelTypeMunger itd)

Half baked implementation - will need completing if we go down this route rather than replacing it all for binary aspects.

private static ISourceLocation
private static IProgramElement
findOrCreateCodeNode(AsmManager asm, IProgramElement enclosingNode, Member shadowSig, Shadow shadow)

Finds or creates a code IProgramElement for the given shadow.

private static String
private static File
getBinaryFile(ResolvedType aspect)

Returns the File with pathname to the class file, for example either C:\temp \ajcSandbox\workspace\ajcTest16957.tmp\simple.jar!pkg\BinaryAspect.class if the class file is in a jar file, or C:\temp\ajcSandbox\workspace\ajcTest16957.tmp!pkg\BinaryAspect.class if the class file is in a directory

private static ISourceLocation
getBinarySourceLocation(ResolvedType aspect, ISourceLocation sl)

Returns the binarySourceLocation for the given sourcelocation.

public static String
protected static IProgramElement
getNode(AsmManager model, Shadow shadow)

private static String
private static boolean
private static boolean
private static IProgramElement
lookupMember(IHierarchy model, UnresolvedType declaringType, Member member)

private static void
private static void
private static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ADVISED_BYback to summary
public static final String ADVISED_BY
ADVISESback to summary
public static final String ADVISES
ANNOTATED_BYback to summary
public static final String ANNOTATED_BY
ANNOTATESback to summary
public static final String ANNOTATES
DECLAREDY_BYback to summary
public static final String DECLAREDY_BY
DECLARES_ONback to summary
public static final String DECLARES_ON
INTER_TYPE_DECLARED_BYback to summary
public static final String INTER_TYPE_DECLARED_BY
INTER_TYPE_DECLARESback to summary
public static final String INTER_TYPE_DECLARES
MATCHED_BYback to summary
public static final String MATCHED_BY
MATCHES_DECLAREback to summary
public static final String MATCHES_DECLARE
NO_COMMENTback to summary
private static final String NO_COMMENT
SOFTENED_BYback to summary
public static final String SOFTENED_BY
SOFTENSback to summary
public static final String SOFTENS

Constructor Detail

AsmRelationshipProviderback to summary
public AsmRelationshipProvider()

Method Detail

addAdvisedRelationshipback to summary
public static void addAdvisedRelationship(AsmManager model, Shadow matchedShadow, ShadowMunger munger)
addChildNodesback to summary
private static void addChildNodes(AsmManager asm, ResolvedType aspect, IProgramElement parent, ResolvedMember[] children)
addChildNodesback to summary
private static void addChildNodes(AsmManager asm, ResolvedType aspect, IProgramElement parent, Collection<?> children)
addDeclareAnnotationFieldRelationshipback to summary
public static void addDeclareAnnotationFieldRelationship(AsmManager model, ISourceLocation declareLocation, String affectedTypeName, ResolvedMember affectedFieldName, boolean isRemove)

Add a relationship for a matching declare ATfield. Locating the field is trickier than it might seem since we have no line number info for it, we have to dig through the structure model under the fields' type in order to locate it.

addDeclareAnnotationMethodRelationshipback to summary
public static void addDeclareAnnotationMethodRelationship(ISourceLocation sourceLocation, String affectedTypeName, ResolvedMember affectedMethod, AsmManager model)

Add a relationship for a matching declare annotation method or declare annotation constructor. Locating the method is a messy (for messy read 'fragile') bit of code that could break at any moment but it's working for my simple testcase.

addDeclareAnnotationRelationshipback to summary
public static void addDeclareAnnotationRelationship(AsmManager model, ISourceLocation declareAnnotationLocation, ISourceLocation annotatedLocation, boolean isRemove)

Adds a declare annotation relationship, sometimes entities don't have source locs (methods/fields) so use other variants of this method if that is the case as they will look the entities up in the structure model.

addDeclareErrorOrWarningRelationshipback to summary
public static void addDeclareErrorOrWarningRelationship(AsmManager model, Shadow affectedShadow, Checker deow)

Add a relationship for a declare error or declare warning

addPointcutsback to summary
private static void addPointcuts(AsmManager model, String sourcefilename, ResolvedType aspect, IProgramElement containingAspect, ResolvedMember[] pointcuts)
addRelationshipback to summary
public static void addRelationship(AsmManager model, ResolvedType onType, ResolvedTypeMunger typeTransformer, ResolvedType originatingAspect)

Add a relationship for a type transformation (declare parents, intertype method declaration, declare annotation on type).

createAdviceChildback to summary
private static IProgramElement createAdviceChild(AsmManager model, Advice advice)
createDeclareErrorOrWarningChildback to summary
private static IProgramElement createDeclareErrorOrWarningChild(AsmManager model, ResolvedType aspect, DeclareErrorOrWarning decl, int count)
createDeclareParentsChildback to summary
private static IProgramElement createDeclareParentsChild(AsmManager model, DeclareParents decp)
createFileStructureNodeback to summary
public static IProgramElement createFileStructureNode(AsmManager asm, String sourceFilePath)
createHierarchyback to summary
private static void createHierarchy(AsmManager model, ResolvedTypeMunger typeTransformer, ResolvedType aspect)

Create a basic hierarchy to represent an aspect only available in binary (from the aspectpath).

createHierarchyForBinaryAspectback to summary
public static void createHierarchyForBinaryAspect(AsmManager asm, ShadowMunger munger)

Creates the hierarchy for binary aspects

createIntertypeDeclaredChildback to summary
private static IProgramElement createIntertypeDeclaredChild(AsmManager model, ResolvedType aspect, BcelTypeMunger itd)

Half baked implementation - will need completing if we go down this route rather than replacing it all for binary aspects. Doesn't attempt to get parameter names correct - they may have been lost during (de)serialization of the munger, but the member could still be located so they might be retrievable.

createSourceLocationback to summary
private static ISourceLocation createSourceLocation(String sourcefilename, ResolvedType aspect, ISourceLocation sl)
findOrCreateCodeNodeback to summary
private static IProgramElement findOrCreateCodeNode(AsmManager asm, IProgramElement enclosingNode, Member shadowSig, Shadow shadow)

Finds or creates a code IProgramElement for the given shadow. The byteCodeName of the created node is set to 'shadowSig.getName() + "!" + counter', eg "println!3". The counter is the occurence count of children within the enclosingNode which have the same name. So, for example, if a method contains two System.out.println statements, the first one will have byteCodeName 'println!1' and the second will have byteCodeName 'println!2'. This is to ensure the two nodes have unique handles when the handles do not depend on sourcelocations. Currently the shadows are examined in the sequence they appear in the source file. This means that the counters are consistent over incremental builds. All aspects are compiled up front and any new aspect created will force a full build. Moreover, if the body of the enclosingShadow is changed, then the model for this is rebuilt from scratch.

findOrFakeUpNodeback to summary
private static String findOrFakeUpNode(AsmManager model, ResolvedType onType)
getBinaryFileback to summary
private static File getBinaryFile(ResolvedType aspect)

Returns the File with pathname to the class file, for example either C:\temp \ajcSandbox\workspace\ajcTest16957.tmp\simple.jar!pkg\BinaryAspect.class if the class file is in a jar file, or C:\temp\ajcSandbox\workspace\ajcTest16957.tmp!pkg\BinaryAspect.class if the class file is in a directory

getBinarySourceLocationback to summary
private static ISourceLocation getBinarySourceLocation(ResolvedType aspect, ISourceLocation sl)

Returns the binarySourceLocation for the given sourcelocation. This isn't cached because it's used when faulting in the binary nodes and is called with ISourceLocations for all advice, pointcuts and deows contained within the resolvedDeclaringAspect.

getHandleback to summary
public static String getHandle(AsmManager asm, Advice advice)
getNodeback to summary
protected static IProgramElement getNode(AsmManager model, Shadow shadow)
getSourceFileNameback to summary
private static String getSourceFileName(ResolvedType aspect)
isBinaryAspectback to summary
private static boolean isBinaryAspect(ResolvedType aspect)
isMixinRelatedback to summary
private static boolean isMixinRelated(ResolvedTypeMunger typeTransformer)
lookupMemberback to summary
private static IProgramElement lookupMember(IHierarchy model, UnresolvedType declaringType, Member member)
setParamsback to summary
private static void setParams(IProgramElement pe, ResolvedMember sig)
setParentTypesOnDeclareParentsNodeback to summary
private static void setParentTypesOnDeclareParentsNode(DeclareParents decp, IProgramElement decpElement)
sourceLinesMatchback to summary
private static boolean sourceLinesMatch(ISourceLocation location1, ISourceLocation location2)