1 /* *******************************************************************
2 * Copyright (c) 2003 Contributors.
4 * This program and the accompanying materials are made available
5 * under the terms of the Common Public License v1.0
6 * which accompanies this distribution and is available at
7 * http://www.eclipse.org/legal/cpl-v10.html
10 * Mik Kersten initial implementation
11 * ******************************************************************/
13 package org.aspectj.ajdt.internal.compiler.lookup;
17 import org.aspectj.asm.*;
18 import org.aspectj.asm.internal.Relationship;
19 import org.aspectj.weaver.*;
24 public class AsmInterTypeRelationshipProvider {
26 public static final String INTER_TYPE_DECLARES = "declares on";
27 public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
29 public static void addRelationship(
31 EclipseTypeMunger munger) {
33 IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
34 if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
35 kind = IProgramElement.Kind.INTER_TYPE_FIELD;
36 } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
37 kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
38 } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
39 kind = IProgramElement.Kind.INTER_TYPE_METHOD;
40 } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
41 kind = IProgramElement.Kind.INTER_TYPE_PARENT;
44 if (munger.getSourceLocation() != null
45 && munger.getSourceLocation() != null) {
47 munger.getSourceLocation().getSourceFile().getAbsolutePath() + IProgramElement.ID_DELIM
48 + munger.getSourceLocation().getLine() + IProgramElement.ID_DELIM
49 + munger.getSourceLocation().getColumn();
52 onType.getSourceLocation().getSourceFile().getAbsolutePath() + IProgramElement.ID_DELIM
53 + onType.getSourceLocation().getLine() + IProgramElement.ID_DELIM
54 + onType.getSourceLocation().getColumn();
56 IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
57 if (sourceHandle != null && targetHandle != null) {
58 IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.ADVICE, INTER_TYPE_DECLARES);
59 foreward.getTargets().add(targetHandle);
61 IRelationship back = mapper.get(targetHandle, IRelationship.Kind.ADVICE, INTER_TYPE_DECLARED_BY);
62 back.getTargets().add(sourceHandle);