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;
15 //import java.io.IOException;
17 import org.aspectj.asm.*;
18 import org.aspectj.asm.internal.ProgramElement;
19 import org.aspectj.weaver.*;
22 * !!! is this class still being used?
26 public class AsmInterTypeRelationshipProvider {
28 protected static AsmInterTypeRelationshipProvider INSTANCE = new AsmInterTypeRelationshipProvider();
30 public static final String INTER_TYPE_DECLARES = "declared on";
31 public static final String INTER_TYPE_DECLARED_BY = "aspect declarations";
33 public void addRelationship(
35 EclipseTypeMunger munger) {
37 // IProgramElement.Kind kind = IProgramElement.Kind.ERROR;
38 // if (munger.getMunger().getKind() == ResolvedTypeMunger.Field) {
39 // kind = IProgramElement.Kind.INTER_TYPE_FIELD;
40 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Constructor) {
41 // kind = IProgramElement.Kind.INTER_TYPE_CONSTRUCTOR;
42 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Method) {
43 // kind = IProgramElement.Kind.INTER_TYPE_METHOD;
44 // } else if (munger.getMunger().getKind() == ResolvedTypeMunger.Parent) {
45 // kind = IProgramElement.Kind.INTER_TYPE_PARENT;
48 if (munger.getSourceLocation() != null
49 && munger.getSourceLocation() != null) {
50 String sourceHandle = ProgramElement.createHandleIdentifier(
51 munger.getSourceLocation().getSourceFile(),
52 munger.getSourceLocation().getLine(),
53 munger.getSourceLocation().getColumn());
55 String targetHandle = ProgramElement.createHandleIdentifier(
56 onType.getSourceLocation().getSourceFile(),
57 onType.getSourceLocation().getLine(),
58 onType.getSourceLocation().getColumn());
60 IRelationshipMap mapper = AsmManager.getDefault().getRelationshipMap();
61 if (sourceHandle != null && targetHandle != null) {
62 IRelationship foreward = mapper.get(sourceHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARES,false,true);
63 foreward.addTarget(targetHandle);
65 IRelationship back = mapper.get(targetHandle, IRelationship.Kind.DECLARE_INTER_TYPE, INTER_TYPE_DECLARED_BY,false,true);
66 back.addTarget(sourceHandle);
71 public static AsmInterTypeRelationshipProvider getDefault() {
76 * Reset the instance of this class, intended for extensibility.
77 * This enables a subclass to become used as the default instance.
79 public static void setDefault(AsmInterTypeRelationshipProvider instance) {