// ??? duplicates some of super's code
public void completeTypeBindings() {
AsmManager.setCompletingTypeBindings(true);
- ContextToken completeTypeBindingsToken = CompilationAndWeavingContext
- .enteringPhase(
- CompilationAndWeavingContext.COMPLETING_TYPE_BINDINGS,
- "");
+ ContextToken completeTypeBindingsToken = CompilationAndWeavingContext.enteringPhase(
+ CompilationAndWeavingContext.COMPLETING_TYPE_BINDINGS, "");
// builtInterTypesAndPerClauses = false;
// pendingTypesToWeave = new ArrayList();
stepCompleted = BUILD_TYPE_HIERARCHY;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.CHECK_AND_SET_IMPORTS,
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CHECK_AND_SET_IMPORTS,
units[i].compilationResult.fileName);
units[i].scope.checkAndSetImports();
CompilationAndWeavingContext.leavingPhase(tok);
stepCompleted = CHECK_AND_SET_IMPORTS;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY,
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.CONNECTING_TYPE_HIERARCHY,
units[i].compilationResult.fileName);
units[i].scope.connectTypeHierarchy();
CompilationAndWeavingContext.leavingPhase(tok);
stepCompleted = CONNECT_TYPE_HIERARCHY;
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS,
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.BUILDING_FIELDS_AND_METHODS,
units[i].compilationResult.fileName);
// units[i].scope.checkParameterizedTypes(); do this check a little
// later, after ITDs applied to stbs
while (typesToProcess.size() > 0) {
// A side effect of weaveIntertypes() is that the processed type
// is removed from the collection
- weaveIntertypes(typesToProcess,
- (SourceTypeBinding) typesToProcess.get(0), typeMungers,
- declareParents, declareAnnotationOnTypes);
+ weaveIntertypes(typesToProcess, (SourceTypeBinding) typesToProcess.get(0), typeMungers, declareParents,
+ declareAnnotationOnTypes);
}
} else {
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
// System.err.println("Working on "+new
// String(units[i].getFileName()));
- weaveInterTypeDeclarations(units[i].scope, typeMungers,
- declareParents, declareAnnotationOnTypes);
+ weaveInterTypeDeclarations(units[i].scope, typeMungers, declareParents, declareAnnotationOnTypes);
}
}
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
for (int j = 0; j < b.length; j++) {
- ContextToken tok = CompilationAndWeavingContext
- .enteringPhase(
- CompilationAndWeavingContext.RESOLVING_POINTCUT_DECLARATIONS,
- b[j].sourceName);
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(
+ CompilationAndWeavingContext.RESOLVING_POINTCUT_DECLARATIONS, b[j].sourceName);
resolvePointcutDeclarations(b[j].scope);
CompilationAndWeavingContext.leavingPhase(tok);
}
for (int i = lastCompletedUnitIndex + 1; i <= lastUnitIndex; i++) {
SourceTypeBinding[] b = units[i].scope.topLevelTypes;
for (int j = 0; j < b.length; j++) {
- ContextToken tok = CompilationAndWeavingContext
- .enteringPhase(
- CompilationAndWeavingContext.ADDING_DECLARE_WARNINGS_AND_ERRORS,
- b[j].sourceName);
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(
+ CompilationAndWeavingContext.ADDING_DECLARE_WARNINGS_AND_ERRORS, b[j].sourceName);
addAdviceLikeDeclares(b[j].scope);
CompilationAndWeavingContext.leavingPhase(tok);
}
// new Integer(i+1),
// typeVariables[i].getDisplayName(),
// superType.getGenericType().getName());
- //factory.getWorld().getMessageHandler().handleMessage(MessageUtil.error(msg
+ // factory.getWorld().getMessageHandler().handleMessage(MessageUtil.error(msg
// ,onType.getSourceLocation()));
// }
// }
} else if (rb instanceof ParameterizedTypeBinding) {
// If its a PTB we need to pull the SourceTypeBinding out of it.
ParameterizedTypeBinding ptb = (ParameterizedTypeBinding) rb;
- if (ptb.type instanceof SourceTypeBinding
- && yetToProcess.contains(ptb.type)) {
- collectAllITDsAndDeclares((SourceTypeBinding) ptb.type,
- yetToProcess);
+ if (ptb.type instanceof SourceTypeBinding && yetToProcess.contains(ptb.type)) {
+ collectAllITDsAndDeclares((SourceTypeBinding) ptb.type, yetToProcess);
}
}
}
/**
- * Find all the ITDs and Declares, but it is important we do this from the
- * supertypes down to the subtypes.
+ * Find all the ITDs and Declares, but it is important we do this from the supertypes down to the subtypes.
*
* @param sourceType
* @param yetToProcess
*/
private void collectAllITDsAndDeclares(SourceTypeBinding sourceType, Collection yetToProcess) {
// Look at the supertype first
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.COLLECTING_ITDS_AND_DECLARES,
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.COLLECTING_ITDS_AND_DECLARES,
sourceType.sourceName);
yetToProcess.remove(sourceType);
}
/**
- * Weave the parents and intertype decls into a given type. This method
- * looks at the supertype and superinterfaces for the specified type and
- * recurses to weave those first if they are in the full list of types we
- * are going to process during this compile... it stops recursing the first
- * time it hits a type we aren't going to process during this compile. This
- * could cause problems if you supply 'pieces' of a hierarchy, i.e. the
- * bottom and the top, but not the middle - but what the hell are you doing
- * if you do that?
+ * Weave the parents and intertype decls into a given type. This method looks at the supertype and superinterfaces for the
+ * specified type and recurses to weave those first if they are in the full list of types we are going to process during this
+ * compile... it stops recursing the first time it hits a type we aren't going to process during this compile. This could cause
+ * problems if you supply 'pieces' of a hierarchy, i.e. the bottom and the top, but not the middle - but what the hell are you
+ * doing if you do that?
*/
- private void weaveIntertypes(List typesToProcess,
- SourceTypeBinding typeToWeave, Collection typeMungers,
+ private void weaveIntertypes(List typesToProcess, SourceTypeBinding typeToWeave, Collection typeMungers,
Collection declareParents, Collection declareAnnotationOnTypes) {
// Look at the supertype first
ReferenceBinding superType = typeToWeave.superclass();
- if (typesToProcess.contains(superType)
- && superType instanceof SourceTypeBinding) {
+ if (typesToProcess.contains(superType) && superType instanceof SourceTypeBinding) {
// System.err.println("Recursing to supertype "+new
// String(superType.getFileName()));
- weaveIntertypes(typesToProcess, (SourceTypeBinding) superType,
- typeMungers, declareParents, declareAnnotationOnTypes);
+ weaveIntertypes(typesToProcess, (SourceTypeBinding) superType, typeMungers, declareParents, declareAnnotationOnTypes);
}
// Then look at the superinterface list
ReferenceBinding[] interfaceTypes = typeToWeave.superInterfaces();
for (int i = 0; i < interfaceTypes.length; i++) {
ReferenceBinding binding = interfaceTypes[i];
- if (typesToProcess.contains(binding)
- && binding instanceof SourceTypeBinding) {
+ if (typesToProcess.contains(binding) && binding instanceof SourceTypeBinding) {
// System.err.println("Recursing to superinterface "+new
// String(binding.getFileName()));
- weaveIntertypes(typesToProcess, (SourceTypeBinding) binding,
- typeMungers, declareParents, declareAnnotationOnTypes);
+ weaveIntertypes(typesToProcess, (SourceTypeBinding) binding, typeMungers, declareParents, declareAnnotationOnTypes);
}
}
- weaveInterTypeDeclarations(typeToWeave, typeMungers, declareParents,
- declareAnnotationOnTypes, false);
+ weaveInterTypeDeclarations(typeToWeave, typeMungers, declareParents, declareAnnotationOnTypes, false);
typesToProcess.remove(typeToWeave);
}
}
/**
- * Return true if the declaration has @Aspect annotation. Called 'couldBe'
- * rather than 'is' because someone else may have defined an annotation
- * called Aspect - we can't verify the full name (including package name)
- * because it may not have been resolved just yet and rather going through
- * expensive resolution when we dont have to, this gives us a cheap check
- * that tells us whether to bother.
+ * Return true if the declaration has @Aspect annotation. Called 'couldBe' rather than 'is' because someone else may have
+ * defined an annotation called Aspect - we can't verify the full name (including package name) because it may not have been
+ * resolved just yet and rather going through expensive resolution when we dont have to, this gives us a cheap check that tells
+ * us whether to bother.
*/
private boolean couldBeAnnotationStyleAspectDeclaration(TypeDeclaration dec) {
Annotation[] annotations = dec.annotations;
private void weaveInterTypeDeclarations(SourceTypeBinding sourceType, Collection typeMungers, Collection declareParents,
Collection declareAnnotationOnTypes, boolean skipInners) {
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS,
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.WEAVING_INTERTYPE_DECLARATIONS,
sourceType.sourceName);
ResolvedType onType = factory.fromEclipse(sourceType);
// Check if the type we are looking at is the topMostImplementor of a
// dangerous interface -
// report a problem if it is.
- for (Iterator i = dangerousInterfaces.entrySet().iterator(); i
- .hasNext();) {
+ for (Iterator i = dangerousInterfaces.entrySet().iterator(); i.hasNext();) {
Map.Entry entry = (Map.Entry) i.next();
ResolvedType interfaceType = (ResolvedType) entry.getKey();
if (onType.isTopmostImplementor(interfaceType)) {
- factory.showMessage(IMessage.ERROR, onType + ": "
- + entry.getValue(), onType.getSourceLocation(), null);
+ factory.showMessage(IMessage.ERROR, onType + ": " + entry.getValue(), onType.getSourceLocation(), null);
}
}
}
/**
- * Called when we discover we are weaving intertype declarations on some
- * type that has an existing 'WeaverStateInfo' object - this is typically
- * some previously woven type that has been passed on the inpath.
+ * Called when we discover we are weaving intertype declarations on some type that has an existing 'WeaverStateInfo' object -
+ * this is typically some previously woven type that has been passed on the inpath.
*
* sourceType and onType are the 'same type' - the former is the 'Eclipse' version and the latter is the 'Weaver' version.
*/
- private void processTypeMungersFromExistingWeaverState(
- SourceTypeBinding sourceType, ResolvedType onType) {
- Collection previouslyAppliedMungers = onType.getWeaverState()
- .getTypeMungers(onType);
+ private void processTypeMungersFromExistingWeaverState(SourceTypeBinding sourceType, ResolvedType onType) {
+ Collection previouslyAppliedMungers = onType.getWeaverState().getTypeMungers(onType);
for (Iterator i = previouslyAppliedMungers.iterator(); i.hasNext();) {
ConcreteTypeMunger m = (ConcreteTypeMunger) i.next();
ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_PARENTS,
sourceType.sourceName);
ResolvedType resolvedSourceType = factory.fromEclipse(sourceType);
- List newParents = declareParents.findMatchingNewParents(
- resolvedSourceType, false);
+ List newParents = declareParents.findMatchingNewParents(resolvedSourceType, false);
if (!newParents.isEmpty()) {
for (Iterator i = newParents.iterator(); i.hasNext();) {
ResolvedType parent = (ResolvedType) i.next();
if (dangerousInterfaces.containsKey(parent)) {
ResolvedType onType = factory.fromEclipse(sourceType);
- factory.showMessage(IMessage.ERROR, onType + ": "
- + dangerousInterfaces.get(parent), onType
- .getSourceLocation(), null);
+ factory.showMessage(IMessage.ERROR, onType + ": " + dangerousInterfaces.get(parent),
+ onType.getSourceLocation(), null);
}
if (Modifier.isFinal(parent.getModifiers())) {
factory.showMessage(IMessage.ERROR, "cannot extend final class " + parent.getClassName(), declareParents
return sb.toString();
}
- private boolean doDeclareAnnotations(DeclareAnnotation decA,
- SourceTypeBinding sourceType, boolean reportProblems) {
+ private boolean doDeclareAnnotations(DeclareAnnotation decA, SourceTypeBinding sourceType, boolean reportProblems) {
ResolvedType rtx = factory.fromEclipse(sourceType);
if (!decA.matches(rtx))
return false;
if (!rtx.isExposedToWeaver())
return false;
- ContextToken tok = CompilationAndWeavingContext.enteringPhase(
- CompilationAndWeavingContext.PROCESSING_DECLARE_ANNOTATIONS,
+ ContextToken tok = CompilationAndWeavingContext.enteringPhase(CompilationAndWeavingContext.PROCESSING_DECLARE_ANNOTATIONS,
sourceType.sourceName);
// Get the annotation specified in the declare
if (reportProblems) {
if (decA.isExactPattern()) {
- factory
- .showMessage(
- IMessage.ERROR,
- WeaverMessages
- .format(
- WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION,
- rtx.getName(),
- toAdd[0].type,
- stringifyTargets(abits)),
- decA.getSourceLocation(), null);
+ factory.showMessage(IMessage.ERROR, WeaverMessages.format(
+ WeaverMessages.INCORRECT_TARGET_FOR_DECLARE_ANNOTATION, rtx.getName(), toAdd[0].type,
+ stringifyTargets(abits)), decA.getSourceLocation(), null);
}
// dont put out the lint - the weaving process will do
// that
// else {
// if (factory.getWorld().getLint().
// invalidTargetForAnnotation.isEnabled()) {
- //factory.getWorld().getLint().invalidTargetForAnnotation
+ // factory.getWorld().getLint().invalidTargetForAnnotation
// .signal(new
// String[]{rtx.getName(),toAdd[0].type.toString(),
// stringifyTargets
if (currentAnnotations != null)
for (int i = 0; i < currentAnnotations.length; i++) {
Annotation annotation = currentAnnotations[i];
- String a = CharOperation
- .toString(annotation.type.getTypeName());
+ String a = CharOperation.toString(annotation.type.getTypeName());
String b = CharOperation.toString(toAdd[0].type.getTypeName());
// FIXME asc we have a lint for attempting to add an annotation
// twice to a method,
}
/**
- * Transform an annotation from its AJ form to an eclipse form. We *DONT*
- * care about the values of the annotation. that is because it is only being
- * stuck on a type during type completion to allow for other constructs
- * (decps, decas) that might be looking for it - when the class actually
- * gets to disk it wont have this new annotation on it and during weave time
- * we will do the right thing copying across values too.
+ * Transform an annotation from its AJ form to an eclipse form. We *DONT* care about the values of the annotation. that is
+ * because it is only being stuck on a type during type completion to allow for other constructs (decps, decas) that might be
+ * looking for it - when the class actually gets to disk it wont have this new annotation on it and during weave time we will do
+ * the right thing copying across values too.
*/
- private static Annotation createAnnotationFromBcelAnnotation(
- AnnotationAJ annX, int pos, EclipseFactory factory) {
+ private static Annotation createAnnotationFromBcelAnnotation(AnnotationAJ annX, int pos, EclipseFactory factory) {
String name = annX.getTypeName();
TypeBinding tb = factory.makeTypeBinding(annX.getType());
// String theName = annX.getSignature().getBaseName();
- char[][] typeName = CharOperation.splitOn('.', name.replace('$', '.')
- .toCharArray()); // pr149293 - not bulletproof...
+ char[][] typeName = CharOperation.splitOn('.', name.replace('$', '.').toCharArray()); // pr149293 - not bulletproof...
long[] positions = new long[typeName.length];
for (int i = 0; i < positions.length; i++)
positions[i] = pos;
ReferenceType rt = (ReferenceType) onType;
ReferenceTypeDelegate rtd = rt.getDelegate();
if (rtd instanceof BcelObjectType) {
- ((BcelObjectType) rtd).addParent(parent);
+ rt.addParent(parent);
+ // ((BcelObjectType) rtd).addParent(parent);
}
}
}
/**
- * Callback driven when the compiler detects an anonymous type during block
- * resolution. We need to add it to the weaver so that we don't trip up
- * later.
+ * Callback driven when the compiler detects an anonymous type during block resolution. We need to add it to the weaver so that
+ * we don't trip up later.
*
* @param aBinding
*/
// System.arraycopy(currentlyHas,0,newset,1,currentlyHas.length);
// }
// methodDecl.annotations = newset;
-//System.err.println("New set on "+CharOperation.charToString(sourceMb.selector)
+// System.err.println("New set on "+CharOperation.charToString(sourceMb.selector)
// +" is "+newset);
// } else
// System.err.println("NO MATCH");
import org.aspectj.weaver.patterns.Pointcut;
/**
- * Supports viewing eclipse TypeDeclarations/SourceTypeBindings as a
- * ResolvedType
+ * Supports viewing eclipse TypeDeclarations/SourceTypeBindings as a ResolvedType
*
* @author Jim Hugunin
*/
}
/**
- * This method may not return all fields, for example it may not include the
- * ajc$initFailureCause or ajc$perSingletonInstance fields - see bug 129613
+ * This method may not return all fields, for example it may not include the ajc$initFailureCause or ajc$perSingletonInstance
+ * fields - see bug 129613
*/
public ResolvedMember[] getDeclaredFields() {
if (declaredFields == null)
}
/**
- * This method may not return all methods, for example it may not include
- * clinit, aspectOf, hasAspect or ajc$postClinit methods - see bug 129613
+ * This method may not return all methods, for example it may not include clinit, aspectOf, hasAspect or ajc$postClinit methods
+ * - see bug 129613
*/
public ResolvedMember[] getDeclaredMethods() {
if (declaredMethods == null)
public boolean isEnum() {
return (binding.getAccessFlags() & ACC_ENUM) != 0;
- }
+ }
public boolean isAnnotation() {
return (binding.getAccessFlags() & ACC_ANNOTATION) != 0;
}
- public void addAnnotation(AnnotationAJ annotationX) {
- // XXX Big hole here - annotationX holds a BCEL annotation but
- // we need an Eclipse one here, we haven't written the conversion utils
- // yet. Not sure if this method will be called in practice...
- throw new RuntimeException("EclipseSourceType.addAnnotation() not implemented");
- }
public boolean isAnnotationWithRuntimeRetention() {
if (!isAnnotation()) {
/**
* WARNING: This method does not have a complete implementation.
*
- * The aim is that it converts Eclipse annotation objects to the AspectJ
- * form of annotations (the type AnnotationAJ). The AnnotationX objects
- * returned are wrappers over either a Bcel annotation type or the AspectJ
- * AnnotationAJ type. The minimal implementation provided here is for
- * processing the RetentionPolicy and Target annotation types - these are
- * the only ones which the weaver will attempt to process from an
- * EclipseSourceType.
+ * The aim is that it converts Eclipse annotation objects to the AspectJ form of annotations (the type AnnotationAJ). The
+ * AnnotationX objects returned are wrappers over either a Bcel annotation type or the AspectJ AnnotationAJ type. The minimal
+ * implementation provided here is for processing the RetentionPolicy and Target annotation types - these are the only ones
+ * which the weaver will attempt to process from an EclipseSourceType.
*
- * More notes: The pipeline has required us to implement this. With the
- * pipeline we can be weaving a type and asking questions of annotations
- * before they have been turned into Bcel objects - ie. when they are still
- * in EclipseSourceType form. Without the pipeline we would have converted
- * everything to Bcel objects before proceeding with weaving. Because the
- * pipeline won't start weaving until all aspects have been compiled and the
- * fact that no AspectJ constructs match on the values within annotations,
- * this code only needs to deal with converting system annotations that the
- * weaver needs to process (RetentionPolicy, Target).
+ * More notes: The pipeline has required us to implement this. With the pipeline we can be weaving a type and asking questions
+ * of annotations before they have been turned into Bcel objects - ie. when they are still in EclipseSourceType form. Without
+ * the pipeline we would have converted everything to Bcel objects before proceeding with weaving. Because the pipeline won't
+ * start weaving until all aspects have been compiled and the fact that no AspectJ constructs match on the values within
+ * annotations, this code only needs to deal with converting system annotations that the weaver needs to process
+ * (RetentionPolicy, Target).
*/
public AnnotationAJ[] getAnnotations() {
if (annotations != null)
}
/**
- * Convert one eclipse annotation into an AnnotationX object containing an
- * AnnotationAJ object.
+ * Convert one eclipse annotation into an AnnotationX object containing an AnnotationAJ object.
*
- * This code and the helper methods used by it will go *BANG* if they
- * encounter anything not currently supported - this is safer than limping
- * along with a malformed annotation. When the *BANG* is encountered the bug
- * reporter should indicate the kind of annotation they were working with
- * and this code can be enhanced to support it.
+ * This code and the helper methods used by it will go *BANG* if they encounter anything not currently supported - this is safer
+ * than limping along with a malformed annotation. When the *BANG* is encountered the bug reporter should indicate the kind of
+ * annotation they were working with and this code can be enhanced to support it.
*/
public AnnotationAJ convertEclipseAnnotation(Annotation eclipseAnnotation, World w) {
// TODO if it is sourcevisible, we shouldn't let it through!!!!!!!!!
}
/**
- * Use the information in the supplied eclipse based annotation to fill in
- * the standard annotation.
+ * Use the information in the supplied eclipse based annotation to fill in the standard annotation.
*
* @param annotation eclipse based annotation representation
* @param annotationAJ AspectJ based annotation representation
return tv;
}
- public void ensureDelegateConsistent() {
- // do nothing, currently these can't become inconsistent (phew)
- }
-
}