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.IRelationship;
19 import org.aspectj.asm.IRelationshipMap;
20 import org.aspectj.weaver.ResolvedType;
23 * !!! is this class still being used?
27 public class AsmInterTypeRelationshipProvider {
29 protected static AsmInterTypeRelationshipProvider INSTANCE = new AsmInterTypeRelationshipProvider();
31 public static final String INTER_TYPE_DECLARES = "declared on";
32 public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
34 public void addRelationship(
36 EclipseTypeMunger munger) {
38 // IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
39 // if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
40 // kind = IProgramElement.Kind.INTER_TYPE_FIELD;
41 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
42 // kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
43 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
44 // kind = IProgramElement.Kind.INTER_TYPE_METHOD;
45 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
46 // kind = IProgramElement.Kind.INTER_TYPE_PARENT;
49 if (munger.getSourceLocation() != null
50 && munger.getSourceLocation() != null) {
51 String sourceHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(
52 munger.getSourceLocation().getSourceFile(),
53 munger.getSourceLocation().getLine(),
54 munger.getSourceLocation().getColumn(),
55 munger.getSourceLocation().getOffset());
57 String targetHandle = AsmManager.getDefault().getHandleProvider().createHandleIdentifier(
58 onType.getSourceLocation().getSourceFile(),
59 onType.getSourceLocation().getLine(),
60 onType.getSourceLocation().getColumn(),
61 onType.getSourceLocation().getOffset());
63 IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
64 if (sourceHandle != null && targetHandle != null) {
65 IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
66 foreward.addTarget(targetHandle);
68 IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
69 back.addTarget(sourceHandle);
74 public static AsmInterTypeRelationshipProvider getDefault() {
79 * Reset the instance of this class, intended for extensibility.
80 * This enables a subclass to become used as the default instance.
82 public static void setDefault(AsmInterTypeRelationshipProvider instance) {