KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ca > mcgill > sable > soot > attributes > SootAttrJimpleIconGenerator


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2004 Jennifer Lhotak
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Created on Nov 7, 2003
22  */

23 package ca.mcgill.sable.soot.attributes;
24 import java.util.*;
25
26 import org.eclipse.core.resources.*;
27 import org.eclipse.core.runtime.CoreException;
28 import org.eclipse.ui.texteditor.MarkerUtilities;
29
30 /**
31  * @author jlhotak
32  */

33 public class SootAttrJimpleIconGenerator implements Runnable JavaDoc {
34     private IFile rec;
35     private SootAttributesHandler handler;
36     
37     public void run(){
38         removeOldMarkers();
39         addSootAttributeMarkers();
40     }
41     
42     private boolean typesContainsOneOf(ArrayList list){
43         boolean result = false;
44         Iterator it = list.iterator();
45         while (it.hasNext()){
46             if (getHandler().getTypesToShow().contains(it.next())) {
47                 result = true;
48                 break;
49             }
50         }
51         return result;
52     }
53     
54     public void addSootAttributeMarkers(){//SootAttributesHandler handler, IFile rec) {
55

56         if (getHandler().getAttrList() == null) return;
57         Iterator it = getHandler().getAttrList().iterator();
58         HashMap markerAttr = new HashMap();
59
60         while (it.hasNext()) {
61             SootAttribute sa = (SootAttribute)it.next();
62             if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())){
63                 if (((sa.getAllTextAttrs("") == null) || (sa.getAllTextAttrs("").length() == 0)) &&
64                     ((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue;
65                 markerAttr.put(IMarker.LINE_NUMBER, new Integer JavaDoc(sa.getJimpleStartLn()));
66
67                 try {
68                     MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker");
69                 }
70                 catch(CoreException e) {
71                     System.out.println(e.getMessage());
72                 }
73             }
74         }
75     }
76     
77     public void removeOldMarkers(){//IFile file){
78
try{
79             getRec().deleteMarkers("ca.mcgill.sable.soot.sootattributemarker", true, IResource.DEPTH_INFINITE);
80         }
81         catch(CoreException e){
82         }
83     }
84     /**
85      * @return
86      */

87     public SootAttributesHandler getHandler() {
88         return handler;
89     }
90
91     /**
92      * @return
93      */

94     public IFile getRec() {
95         return rec;
96     }
97
98     /**
99      * @param handler
100      */

101     public void setHandler(SootAttributesHandler handler) {
102         this.handler = handler;
103     }
104
105     /**
106      * @param file
107      */

108     public void setRec(IFile file) {
109         rec = file;
110     }
111
112 }
113
Popular Tags