1 19 20 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 33 public class SootAttrJimpleIconGenerator implements Runnable { 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(){ 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 (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(){ try{ 79 getRec().deleteMarkers("ca.mcgill.sable.soot.sootattributemarker", true, IResource.DEPTH_INFINITE); 80 } 81 catch(CoreException e){ 82 } 83 } 84 87 public SootAttributesHandler getHandler() { 88 return handler; 89 } 90 91 94 public IFile getRec() { 95 return rec; 96 } 97 98 101 public void setHandler(SootAttributesHandler handler) { 102 this.handler = handler; 103 } 104 105 108 public void setRec(IFile file) { 109 rec = file; 110 } 111 112 } 113 | Popular Tags |