| 1 19 20 21 package ca.mcgill.sable.soot.attributes; 22 23 import java.util.*; 24 25 import org.eclipse.core.resources.*; 26 import org.eclipse.core.runtime.CoreException; 27 import org.eclipse.ui.texteditor.MarkerUtilities; 28 29 30 public class SootAttrJavaIconGenerator implements Runnable { 31 32 private IFile rec; 33 private SootAttributesHandler handler; 34 35 public void run(){ 36 removeOldMarkers(); 37 addSootAttributeMarkers(); 38 } 39 40 private boolean typesContainsOneOf(ArrayList list){ 41 boolean result = false; 42 Iterator it = list.iterator(); 43 while (it.hasNext()){ 44 if (getHandler().getTypesToShow().contains(it.next())) { 45 result = true; 46 break; 47 } 48 } 49 return result; 50 } 51 52 public void addSootAttributeMarkers(){ 54 if (getHandler().getAttrList() == null) return; 55 Iterator it = getHandler().getAttrList().iterator(); 56 HashMap markerAttr = new HashMap(); 57 58 while (it.hasNext()) { 59 SootAttribute sa = (SootAttribute)it.next(); 60 if (getHandler().isShowAllTypes() || typesContainsOneOf(sa.getAnalysisTypes())) { 61 if (((sa.getAllTextAttrs("<br>") == null) || (sa.getAllTextAttrs("<br>").length() == 0)) && 62 ((sa.getAllLinkAttrs() == null) || (sa.getAllLinkAttrs().size() ==0))) continue; 63 markerAttr.put(IMarker.LINE_NUMBER, new Integer (sa.getJavaStartLn())); 64 try { 65 MarkerUtilities.createMarker(getRec(), markerAttr, "ca.mcgill.sable.soot.sootattributemarker"); 66 } 67 catch(CoreException e) { 68 System.out.println(e.getMessage()); 69 } 70 } 71 } 72 } 73 public void removeOldMarkers(){ try{ 75 getRec().deleteMarkers("ca.mcgill.sable.soot.sootattributemarker", true, IResource.DEPTH_INFINITE); 76 } 77 catch(CoreException e){ 78 } 79 } 80 83 public SootAttributesHandler getHandler() { 84 return handler; 85 } 86 87 90 public IFile getRec() { 91 return rec; 92 } 93 94 97 public void setHandler(SootAttributesHandler handler) { 98 this.handler = handler; 99 } 100 101 104 public void setRec(IFile file) { 105 rec = file; 106 } 107 108 } 109 | Popular Tags |