1 /* *******************************************************************
2 * Copyright (c) 2003 Contributors.
4 * This program and the accompanying materials are made available
5 * under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * Mik Kersten initial implementation
11 * ******************************************************************/
13 package org.aspectj.ajdt.internal.compiler.lookup;
15 //import java.io.IOException;
17 import org.aspectj.asm.AsmManager;
18 import org.aspectj.asm.IProgramElement;
19 import org.aspectj.asm.IRelationship;
20 import org.aspectj.asm.IRelationshipMap;
21 import org.aspectj.weaver.ResolvedType;
24 * !!! is this class still being used?
28 public class AsmInterTypeRelationshipProvider {
30 protected static AsmInterTypeRelationshipProvider INSTANCE = new AsmInterTypeRelationshipProvider();
32 public static final String INTER_TYPE_DECLARES = "declared on";
33 public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
35 public void addRelationship(
37 EclipseTypeMunger munger) {
39 // IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
40 // if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
41 // kind = IProgramElement.Kind.INTER_TYPE_FIELD;
42 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
43 // kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
44 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
45 // kind = IProgramElement.Kind.INTER_TYPE_METHOD;
46 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
47 // kind = IProgramElement.Kind.INTER_TYPE_PARENT;
50 if (munger.getSourceLocation() != null
51 && munger.getSourceLocation() != null) {
52 IProgramElement sourceIPE = AsmManager.getDefault().getHierarchy()
53 .findElementForSourceLine(munger.getSourceLocation());
54 String sourceHandle = AsmManager.getDefault().getHandleProvider()
55 .createHandleIdentifier(sourceIPE);
57 IProgramElement targetIPE = AsmManager.getDefault().getHierarchy()
58 .findElementForSourceLine(onType.getSourceLocation());
59 String targetHandle = AsmManager.getDefault().getHandleProvider()
60 .createHandleIdentifier(targetIPE);
62 IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
63 if (sourceHandle != null && targetHandle != null) {
64 IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
65 foreward.addTarget(targetHandle);
67 IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
68 back.addTarget(sourceHandle);
73 public static AsmInterTypeRelationshipProvider getDefault() {
78 * Reset the instance of this class, intended for extensibility.
79 * This enables a subclass to become used as the default instance.
81 public static void setDefault(AsmInterTypeRelationshipProvider instance) {