KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > aspectj > asm > associations > Introduction


1
2 /* -*- Mode: Java; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
3  *
4  * This file is part of the IDE support for the AspectJ(tm)
5  * programming language; see http://aspectj.org
6  *
7  * The contents of this file are subject to the Mozilla Public License
8  * Version 1.1 (the "License"); you may not use this file except in
9  * compliance with the License. You may obtain a copy of the License at
10  * either http://www.mozilla.org/MPL/ or http://aspectj.org/MPL/.
11  *
12  * Software distributed under the License is distributed on an "AS IS" basis,
13  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
14  * for the specific language governing rights and limitations under the
15  * License.
16  *
17  * The Original Code is AspectJ.
18  *
19  * The Initial Developer of the Original Code is Xerox Corporation. Portions
20  * created by Xerox Corporation are Copyright (C) 1999-2002 Xerox Corporation.
21  * All Rights Reserved.
22  *
23  * Contributor(s):
24  */

25
26 package org.aspectj.asm.associations;
27
28 import java.util.*;
29 import org.aspectj.compiler.base.*;
30 import org.aspectj.compiler.base.ast.*;
31 import org.aspectj.compiler.base.cst.*;
32 import org.aspectj.compiler.crosscuts.*;
33 import org.aspectj.compiler.crosscuts.ast.*;
34 import org.aspectj.asm.*;
35 import org.aspectj.asm.internal.*;
36
37 /**
38  * @author Mik Kersten
39  */

40 public class Introduction implements Association {
41     public static final String JavaDoc NAME = "Introduction";
42     public static final Relation INTRODUCES_RELATION = new Relation("declares member on", "inter-type declared members", NAME, true, false);
43     private List relations = new ArrayList();
44
45     public Introduction() {
46         relations.add(INTRODUCES_RELATION);
47     }
48
49     public List getRelations() {
50         return relations;
51     }
52
53     public List getRelationNodes(ASTObject astObject) {
54         List relations = new ArrayList();
55         List introduces = new ArrayList();
56         Set forwardCorrs = StructureModelManager.correspondences.getAffects(astObject);
57         Set backCorrs = StructureModelManager.correspondences.getAffectedBy(astObject);
58         if (astObject instanceof IntroducedDec) {
59             for (Iterator it = forwardCorrs.iterator(); it.hasNext(); ) {
60                 ASTObject node = (ASTObject)it.next();
61                 LinkNode link = StructureNodeFactory.makeLink(node, false);
62                 if (node instanceof TypeDec) {
63                     introduces.add(link);
64                 }
65             }
66             if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getForwardNavigationName(), introduces));
67         } else {
68             for (Iterator it = backCorrs.iterator(); it.hasNext(); ) {
69                 ASTObject node = (ASTObject)it.next();
70                 if (astObject instanceof TypeDec) {
71                     if (node instanceof IntroducedDec) {
72                         introduces.add(StructureNodeFactory.makeLink(node, false));
73                     }
74                 }
75             }
76             if (!introduces.isEmpty()) relations.add(new RelationNode(INTRODUCES_RELATION, INTRODUCES_RELATION.getBackNavigationName(), introduces));
77         }
78         return relations;
79     }
80
81     public String JavaDoc getName() {
82         return NAME;
83     }
84 }
85
Popular Tags