repo
stringlengths 1
191
⌀ | file
stringlengths 23
351
| code
stringlengths 0
5.32M
| file_length
int64 0
5.32M
| avg_line_length
float64 0
2.9k
| max_line_length
int64 0
288k
| extension_type
stringclasses 1
value |
|---|---|---|---|---|---|---|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/CFGGraphEditPart.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import org.eclipse.draw2d.*;
import org.eclipse.gef.editparts.*;
import org.eclipse.draw2d.graph.*;
import org.eclipse.gef.*;
import org.eclipse.draw2d.geometry.*;
import java.util.*;
import ca.mcgill.sable.soot.cfg.model.*;
import java.beans.*;
public class CFGGraphEditPart extends AbstractGraphicalEditPart
implements PropertyChangeListener {
private int figureWidth = 20000;
private int figureHeight = 20000;
public CFGGraphEditPart() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
IFigure f = new Figure() {
public void setBound(Rectangle rect){
int x = bounds.x;
int y = bounds.y;
boolean resize = (rect.width != bounds.width) || (rect.height != bounds.height),
translate = (rect.x != x) || (rect.y != y);
if (isVisible() && (resize || translate))
erase();
if (translate) {
int dx = rect.x - x;
int dy = rect.y - y;
primTranslate(dx, dy);
}
bounds.width = rect.width;
bounds.height = rect.height;
if (resize || translate) {
fireMoved();
repaint();
}
}
};
f.setLayoutManager(new CFGGraphLayoutManager(this));
return f;
}
protected void setFigure(IFigure figure){
figure.getBounds().setSize(getFigureWidth(),getFigureHeight());
super.setFigure(figure);
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
*/
protected void createEditPolicies() {
}
public void contributeNodesToGraph(DirectedGraph graph, HashMap map){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof CFGNodeEditPart){
((CFGNodeEditPart)next).contributeNodesToGraph(graph, map);
}
}
}
public void contributeEdgesToGraph(DirectedGraph graph, HashMap map){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof CFGNodeEditPart){
((CFGNodeEditPart)next).contributeEdgesToGraph(graph, map);
}
}
}
public void applyGraphResults(DirectedGraph graph, HashMap map){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof CFGNodeEditPart){
((CFGNodeEditPart)next).applyGraphResults(graph, map);
}
}
determineGraphBounds(graph);
}
public void resetChildColors(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof CFGNodeEditPart){
((CFGNodeEditPart)next).resetColors();
}
}
}
private void determineGraphBounds(DirectedGraph graph){
Iterator it = graph.nodes.iterator();
int width = 0;
int height = 0;
while (it.hasNext()){
Node n = (Node)it.next();
if (width < n.x){
width = n.x + 300;
}
height = max(height, n.height);
}
setFigureWidth(width);
setFigureHeight(height);
}
private int max(int i, int j){
return i < j ? j : i;
}
public CFGGraph getGraph(){
return (CFGGraph)getModel();
}
public List getModelChildren(){
return getGraph().getChildren();
}
public void activate(){
super.activate();
getGraph().addPropertyChangeListener(this);
}
public void deactivate(){
super.deactivate();
getGraph().removePropertyChangeListener(this);
}
public void propertyChange(PropertyChangeEvent event){
if (event.getPropertyName().equals(CFGElement.CHILDREN)){
refreshChildren();
}
else if (event.getPropertyName().equals(CFGElement.NEW_FLOW_DATA)){
resetChildColors();
}
((GraphicalEditPart)(getViewer().getContents())).getFigure().revalidate();
}
/**
* @return
*/
public int getFigureHeight() {
return figureHeight;
}
/**
* @return
*/
public int getFigureWidth() {
return figureWidth;
}
/**
* @param i
*/
public void setFigureHeight(int i) {
figureHeight = i;
}
/**
* @param i
*/
public void setFigureWidth(int i) {
figureWidth = i;
}
public void handleClickEvent(Object evt){
((CFGGraph)getModel()).handleClickEvent(evt);
}
}
| 4,963
| 23.097087
| 84
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/CFGGraphLayoutManager.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import org.eclipse.draw2d.AbstractLayout;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.*;
import org.eclipse.draw2d.graph.*;
import java.util.*;
public class CFGGraphLayoutManager extends AbstractLayout {
private CFGGraphEditPart graphPart;
public CFGGraphLayoutManager(CFGGraphEditPart graphPart) {
setGraphPart(graphPart);
}
/* (non-Javadoc)
* @see org.eclipse.draw2d.AbstractLayout#calculatePreferredSize(org.eclipse.draw2d.IFigure, int, int)
*/
protected Dimension calculatePreferredSize(
IFigure arg0,
int arg1,
int arg2) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.draw2d.LayoutManager#layout(org.eclipse.draw2d.IFigure)
*/
public void layout(IFigure arg0) {
DirectedGraph graph = new DirectedGraph();
HashMap map = new HashMap();
// add nodes and edges to graph
// retrieve them from CFGGraphEditPart
getGraphPart().contributeNodesToGraph(graph, map);
getGraphPart().contributeEdgesToGraph(graph, map);
if (graph.nodes.size() != 0){
DirectedGraphLayout layout = new DirectedGraphLayout();
layout.visit(graph);
getGraphPart().applyGraphResults(graph, map);
}
}
/**
* @return
*/
public CFGGraphEditPart getGraphPart() {
return graphPart;
}
/**
* @param part
*/
public void setGraphPart(CFGGraphEditPart part) {
graphPart = part;
}
}
| 2,229
| 26.530864
| 103
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/CFGNodeEditPart.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import org.eclipse.draw2d.ChopboxAnchor;
import org.eclipse.draw2d.ConnectionAnchor;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.geometry.Rectangle;
import org.eclipse.draw2d.graph.DirectedGraph;
import org.eclipse.draw2d.graph.Node;
import org.eclipse.gef.ConnectionEditPart;
import org.eclipse.gef.EditPartViewer;
import org.eclipse.gef.EditPolicy;
import org.eclipse.gef.NodeEditPart;
import org.eclipse.gef.Request;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.swt.widgets.Display;
import ca.mcgill.sable.soot.cfg.editpolicies.FlowSelectPolicy;
import ca.mcgill.sable.soot.cfg.figures.CFGNodeFigure;
import ca.mcgill.sable.soot.cfg.model.CFGElement;
import ca.mcgill.sable.soot.cfg.model.CFGFlowData;
import ca.mcgill.sable.soot.cfg.model.CFGFlowInfo;
import ca.mcgill.sable.soot.cfg.model.CFGNode;
import ca.mcgill.sable.soot.cfg.model.CFGPartialFlowData;
public class CFGNodeEditPart
extends AbstractGraphicalEditPart
implements NodeEditPart, PropertyChangeListener {
/**
*
*/
public CFGNodeEditPart() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
return new CFGNodeFigure();
}
public void contributeNodesToGraph(DirectedGraph graph, HashMap map){
Node node = new Node(this);
node.width = getFigure().getBounds().width;//getNode().getWidth();
int height = 22;
if (((CFGNode)getModel()).getBefore() != null){
height += ((CFGNode)getModel()).getBefore().getChildren().size() * 22;
}
if (((CFGNode)getModel()).getAfter() != null){
height += ((CFGNode)getModel()).getAfter().getChildren().size() * 22;
}
node.height = height;//getFigure().getBounds().height;
graph.nodes.add(node);
map.put(this, node);
}
public void contributeEdgesToGraph(DirectedGraph graph, HashMap map) {
List outgoing = getSourceConnections();
for (int i = 0; i < outgoing.size(); i++){
CFGEdgeEditPart edge = (CFGEdgeEditPart)outgoing.get(i);
edge.contributeToGraph(graph, map);
}
}
public void applyGraphResults(DirectedGraph graph, HashMap map){
Node node = (Node)map.get(this);
((CFGNodeFigure)getFigure()).setBounds(new Rectangle(node.x, node.y, node.width, node.height));//getFigure().getBounds().height));//getFigure().getBounds().height));
List outgoing = getSourceConnections();
for (int i = 0; i < outgoing.size(); i++){
CFGEdgeEditPart edge = (CFGEdgeEditPart)outgoing.get(i);
edge.applyGraphResults(graph, map);
}
}
public void resetColors(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof FlowDataEditPart){
((FlowDataEditPart)next).resetChildColors();
}
else if (next instanceof NodeDataEditPart){
((NodeDataEditPart)next).resetColors();
}
}
((CFGNodeFigure)getFigure()).removeIndicator();
}
public CFGNode getNode(){
return (CFGNode)getModel();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
*/
protected void createEditPolicies() {
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,new FlowSelectPolicy());
}
public List getModelSourceConnections(){
return getNode().getOutputs();
}
public List getModelTargetConnections(){
return getNode().getInputs();
}
/* (non-Javadoc)
* @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*/
public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart arg0) {
return new ChopboxAnchor(getFigure());
}
/* (non-Javadoc)
* @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
*/
public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart arg0) {
return new ChopboxAnchor(getFigure());
}
/* (non-Javadoc)
* @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
*/
public ConnectionAnchor getSourceConnectionAnchor(Request arg0) {
return new ChopboxAnchor(getFigure());
}
/* (non-Javadoc)
* @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
*/
public ConnectionAnchor getTargetConnectionAnchor(Request arg0) {
return new ChopboxAnchor(getFigure());
}
public void activate(){
super.activate();
getNode().addPropertyChangeListener(this);
}
public void deactivate(){
super.deactivate();
getNode().removePropertyChangeListener(this);
}
public List getModelChildren(){
return getNode().getChildren();
}
public void propertyChange(PropertyChangeEvent event){
if (event.getPropertyName().equals(CFGElement.NODE_DATA)){
refreshChildren();
refreshVisuals();
}
else if (event.getPropertyName().equals(CFGElement.BEFORE_INFO)){
refreshChildren();
refreshVisuals();
final EditPartViewer viewer = getViewer();
final CFGNodeEditPart thisPart = this;
Display.getDefault().syncExec(new Runnable(){
public void run(){
viewer.reveal(thisPart);
};
});
}
else if (event.getPropertyName().equals(CFGElement.AFTER_INFO)){
refreshChildren();
refreshVisuals();
final EditPartViewer viewer = getViewer();
final CFGNodeEditPart thisPart = this;
Display.getDefault().syncExec(new Runnable(){
public void run(){
viewer.reveal(thisPart);
};
});
}
else if (event.getPropertyName().equals(CFGElement.INPUTS)){
refreshTargetConnections();
}
else if (event.getPropertyName().equals(CFGElement.OUTPUTS)){
refreshSourceConnections();
}
else if (event.getPropertyName().equals(CFGElement.REVEAL)){
revealThis();
resetColors();
}
else if (event.getPropertyName().equals(CFGElement.HIGHLIGHT)){
highlightThis();
revealThis();
}
}
private void revealThis(){
final EditPartViewer viewer = getViewer();
final CFGNodeEditPart thisPart = this;
Display.getDefault().syncExec(new Runnable(){
public void run(){
viewer.reveal(thisPart);
viewer.select(thisPart);
};
});
}
protected void highlightThis(){
if (((CFGNode)getModel()).getBefore() == null){
CFGFlowData data = new CFGFlowData();
CFGFlowInfo info = new CFGFlowInfo();
info.setText("");
CFGPartialFlowData pInfo = new CFGPartialFlowData();
pInfo.addChild(info);
data.addChild(pInfo);
((CFGNode)getModel()).setBefore(data);
}
Iterator it = this.getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof NodeDataEditPart){
((NodeDataEditPart)next).addIndicator();
}
}
((CFGNodeFigure)getFigure()).addIndicator();
}
protected void refreshVisuals(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof FlowDataEditPart){
((CFGNodeFigure)getFigure()).add(((FlowDataEditPart)next).getFigure());
}
else if (next instanceof NodeDataEditPart){
((CFGNodeFigure)getFigure()).add(((NodeDataEditPart)next).getFigure());
}
}
}
public void updateSize(AbstractGraphicalEditPart part, IFigure child, Rectangle rect){
this.setLayoutConstraint(part, child, rect);
}
public void updateSize(int width, int height){
int w = ((CFGNodeFigure)getFigure()).getBounds().width;
int h = ((CFGNodeFigure)getFigure()).getBounds().height;
h += height;
if (width > w){
((CFGNodeFigure)getFigure()).setSize(width, h);
((CFGNodeFigure)getFigure()).revalidate();
}
}
public void handleClickEvent(Object evt){
((CFGGraphEditPart)getParent()).handleClickEvent(evt);
}
}
| 8,613
| 28.703448
| 167
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/CFGPartFactory.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import org.eclipse.gef.EditPart;
import org.eclipse.gef.EditPartFactory;
import ca.mcgill.sable.soot.cfg.model.*;
public class CFGPartFactory implements EditPartFactory {
public CFGPartFactory() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
*/
public EditPart createEditPart(EditPart arg0, Object arg1) {
EditPart part = null;
if (arg1 instanceof CFGGraph){
part = new CFGGraphEditPart();
}
else if (arg1 instanceof CFGNode){
part = new CFGNodeEditPart();
}
else if (arg1 instanceof CFGEdge){
part = new CFGEdgeEditPart();
}
else if (arg1 instanceof CFGFlowData){
part = new FlowDataEditPart();
}
else if (arg1 instanceof CFGPartialFlowData){
part = new PartialFlowDataEditPart();
}
else if (arg1 instanceof CFGFlowInfo){
part = new FlowInfoEditPart();
}
else if (arg1 instanceof CFGNodeData){
part = new NodeDataEditPart();
}
part.setModel(arg1);
return part;
}
}
| 1,893
| 27.69697
| 99
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/FlowDataEditPart.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.eclipse.draw2d.*;
import ca.mcgill.sable.soot.cfg.figures.*;
import ca.mcgill.sable.soot.cfg.model.*;
import java.util.*;
import org.eclipse.draw2d.geometry.*;
public class FlowDataEditPart
extends AbstractGraphicalEditPart
implements PropertyChangeListener {
/* (non-Javadoc)
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(CFGElement.FLOW_CHILDREN)){
refreshChildren();
refreshVisuals();
}
}
protected void refreshVisuals(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof PartialFlowDataEditPart){
((CFGFlowFigure)getFigure()).add(((PartialFlowDataEditPart)next).getFigure());
}
}
}
public void updateSize(FlowInfoEditPart childEdit, IFigure child, Rectangle rect){
this.setLayoutConstraint(childEdit, child, rect);
((CFGNodeEditPart)getParent()).setLayoutConstraint(this, getFigure(), new Rectangle(getFigure().getBounds().x, getFigure().getBounds().y, getFigure().getBounds().width, getFigure().getBounds().height));//.updateSize(getFigure(), getFigure().getBounds());
}
public void updateSize(int width){
int w = ((CFGFlowFigure)getFigure()).getBounds().width;
if (width > w){
w = width;
}
int height = getChildren().size() * 20;
((CFGNodeEditPart)getParent()).updateSize(w+10, height);
((CFGFlowFigure)getFigure()).setSize(w+10, height);
}
public void resetChildColors(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof PartialFlowDataEditPart){
((PartialFlowDataEditPart)next).resetChildColors();
}
}
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
return new CFGFlowFigure();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
*/
protected void createEditPolicies() {
}
public List getModelChildren(){
return getFlowData().getChildren();
}
public void activate(){
super.activate();
getFlowData().addPropertyChangeListener(this);
}
public void deactivate(){
super.deactivate();
getFlowData().removePropertyChangeListener(this);
}
/**
* @return
*/
public CFGFlowData getFlowData() {
return (CFGFlowData)getModel();
}
public void handleClickEvent(Object evt){
((CFGNodeEditPart)getParent()).handleClickEvent(evt);
}
}
| 3,591
| 27.0625
| 256
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/FlowInfoEditPart.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.eclipse.draw2d.*;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import org.eclipse.gef.*;
import ca.mcgill.sable.soot.cfg.editpolicies.*;
import ca.mcgill.sable.soot.cfg.model.*;
import ca.mcgill.sable.soot.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.*;
public class FlowInfoEditPart
extends AbstractGraphicalEditPart
implements PropertyChangeListener {
Font f = new Font(null, "Arial", 8, SWT.NORMAL);
public FlowInfoEditPart() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
return new Label();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
*/
protected void createEditPolicies() {
installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE,new FlowSelectPolicy());
}
/* (non-Javadoc)
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(CFGElement.FLOW_INFO)){
((Label)getFigure()).setText(evt.getNewValue().toString());
((Label)getFigure()).setFont(f);
((Label)getFigure()).setForegroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0,153,0)));
((Label)getFigure()).setSize(evt.getNewValue().toString().length()*7, getFigure().getBounds().height);
((PartialFlowDataEditPart)getParent()).updateSize(evt.getNewValue().toString().length()*7+10);
}
}
public void resetColors(){
((Label)getFigure()).setForegroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0, 0, 0)));
}
/**
* @return
*/
public CFGFlowInfo getFlowInfo() {
return (CFGFlowInfo)getModel();
}
public void activate(){
super.activate();
getFlowInfo().addPropertyChangeListener(this);
}
public void deactivate(){
super.deactivate();
getFlowInfo().removePropertyChangeListener(this);
}
public void handleClickEvent(Object evt){
System.out.println(getParent().getClass());
((PartialFlowDataEditPart)getParent()).handleClickEvent(evt);
}
}
| 3,101
| 28.826923
| 113
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/NodeDataEditPart.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.eclipse.draw2d.IFigure;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import ca.mcgill.sable.soot.cfg.model.*;
import ca.mcgill.sable.soot.cfg.figures.*;
import java.util.*;
import ca.mcgill.sable.soot.*;
import org.eclipse.swt.graphics.*;
public class NodeDataEditPart
extends AbstractGraphicalEditPart
implements PropertyChangeListener {
public NodeDataEditPart() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
return new CFGNodeDataFigure();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
*/
protected void createEditPolicies() {
}
/* (non-Javadoc)
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(CFGElement.TEXT)){
((CFGNodeDataFigure)getFigure()).setData((ArrayList)evt.getNewValue());
((CFGNodeDataFigure)getFigure()).updateFigure();
((CFGNodeEditPart)getParent()).updateSize(getFigure().getBounds().width, getFigure().getBounds().height);
}
else if (evt.getPropertyName().equals(CFGElement.HEAD)){
((CFGNodeDataFigure)getFigure()).getRect().setBackgroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0,45,200)));
}
else if (evt.getPropertyName().equals(CFGElement.TAIL)){
((CFGNodeDataFigure)getFigure()).getRect().setBackgroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(0,200,45)));
}
}
/**
* @return
*/
public CFGNodeData getNodeData() {
return (CFGNodeData)getModel();
}
public void activate(){
super.activate();
getNodeData().addPropertyChangeListener(this);
}
public void deactivate(){
super.deactivate();
getNodeData().removePropertyChangeListener(this);
}
public void markStop(){
ArrayList list = getNodeData().getText();
((CFGNodeDataFigure)getFigure()).addStopIcon();
// send event marking this unit
soot.toolkits.graph.interaction.InteractionHandler.v().addToStopUnitList(((CFGNodeDataFigure)getFigure()).getUnit());
}
public void unMarkStop(){
((CFGNodeDataFigure)getFigure()).removeStopIcon();
soot.toolkits.graph.interaction.InteractionHandler.v().removeFromStopUnitList(((CFGNodeDataFigure)getFigure()).getUnit());
}
public void resetColors(){
removeIndicator();
}
public void addIndicator(){
((CFGNodeDataFigure)getFigure()).addIndicator();
}
public void removeIndicator(){
((CFGNodeDataFigure)getFigure()).removeIndicator();
}
}
| 3,568
| 30.034783
| 136
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editParts/PartialFlowDataEditPart.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editParts;
import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import org.eclipse.draw2d.*;
import ca.mcgill.sable.soot.cfg.figures.*;
import ca.mcgill.sable.soot.cfg.model.*;
import java.util.*;
import org.eclipse.draw2d.geometry.*;
public class PartialFlowDataEditPart
extends AbstractGraphicalEditPart
implements PropertyChangeListener {
/* (non-Javadoc)
* @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
*/
public void propertyChange(PropertyChangeEvent evt) {
if (evt.getPropertyName().equals(CFGElement.PART_FLOW_CHILDREN)){
refreshChildren();
refreshVisuals();
}
}
protected void refreshVisuals(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof FlowInfoEditPart){
((CFGPartialFlowFigure)getFigure()).add(((FlowInfoEditPart)next).getFigure());
}
}
}
public void updateSize(int width){
int w = ((CFGPartialFlowFigure)getFigure()).getBounds().width;
w += width;
((FlowDataEditPart)getParent()).updateSize(w+10);
((CFGPartialFlowFigure)getFigure()).setSize(w+10, getFigure().getBounds().height);
}
public void resetChildColors(){
Iterator it = getChildren().iterator();
while (it.hasNext()){
Object next = it.next();
if (next instanceof FlowInfoEditPart){
((FlowInfoEditPart)next).resetColors();
}
}
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
*/
protected IFigure createFigure() {
return new CFGPartialFlowFigure();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
*/
protected void createEditPolicies() {
}
public List getModelChildren(){
return getPartialFlowData().getChildren();
}
public void activate(){
super.activate();
getPartialFlowData().addPropertyChangeListener(this);
}
public void deactivate(){
super.deactivate();
getPartialFlowData().removePropertyChangeListener(this);
}
/**
* @return
*/
public CFGPartialFlowData getPartialFlowData() {
return (CFGPartialFlowData)getModel();
}
public void handleClickEvent(Object evt){
System.out.println(getParent().getClass());
((FlowDataEditPart)getParent()).handleClickEvent(evt);
}
}
| 3,243
| 25.809917
| 89
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/editpolicies/FlowSelectPolicy.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.editpolicies;
import org.eclipse.gef.editpolicies.SelectionEditPolicy;
import org.eclipse.draw2d.*;
import org.eclipse.gef.*;
import org.eclipse.gef.requests.*;
import ca.mcgill.sable.soot.cfg.figures.*;
import ca.mcgill.sable.soot.cfg.editParts.*;
public class FlowSelectPolicy extends SelectionEditPolicy {
public FlowSelectPolicy() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.gef.editpolicies.SelectionEditPolicy#hideSelection()
*/
protected void hideSelection() {
}
/* (non-Javadoc)
* @see org.eclipse.gef.editpolicies.SelectionEditPolicy#showSelection()
*/
protected void showSelection() {
}
public void showTargetFeedback(Request request){
}
}
| 1,550
| 26.696429
| 73
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/figures/CFGFigureFactory.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.figures;
import ca.mcgill.sable.soot.cfg.model.*;
import org.eclipse.draw2d.widgets.*;
import org.eclipse.draw2d.*;
public class CFGFigureFactory {
}
| 1,012
| 33.931034
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/figures/CFGFlowFigure.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.figures;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.*;
public class CFGFlowFigure extends Figure {
Panel background;
public CFGFlowFigure() {
super();
FlowLayout layout = new FlowLayout(false);
layout.setMinorAlignment(FlowLayout.ALIGN_CENTER);
layout.setMajorAlignment(FlowLayout.ALIGN_CENTER);
this.setLayoutManager(layout);
}
}
| 1,230
| 29.775
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/figures/CFGNodeDataFigure.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.figures;
import org.eclipse.draw2d.*;
import java.util.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import ca.mcgill.sable.soot.*;
import org.eclipse.draw2d.text.*;
import ca.mcgill.sable.soot.editors.*;
import org.eclipse.draw2d.geometry.*;
import org.eclipse.jface.resource.*;
public class CFGNodeDataFigure extends Figure {
private Panel nodeFigure;//RectangleFigure rect;
private RectangleFigure rect;
private ArrayList data;
Font f = new Font(null, "Arial", 8, SWT.NORMAL);
public CFGNodeDataFigure() {
super();
setRect(new RectangleFigure());
this.add(getRect());
getRect().setBackgroundColor(SootPlugin.getDefault().getColorManager().getColor(new RGB(255, 255 ,255)));
ToolbarLayout layout = new ToolbarLayout();
layout.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
layout.setVertical(false);
this.setLayoutManager(layout);
getRect().setLayoutManager(layout);
}
private soot.Unit unit;
public void updateFigure(){
if (getData() == null) return;
int height = 0;
int width = 0;
Iterator it = getData().iterator();
while (it.hasNext()){
unit = (soot.Unit)it.next();
String next = unit.toString();
Label l = new Label(next);
l.setFont(f);
l.getInsets().top = 1;
l.getInsets().bottom = 1;
l.getInsets().right = 1;
l.getInsets().left = 1;
height = height + l.getSize().height/2;
int length = next.length()*7;
width = length > width ? length : width;
getRect().add(l);
}
getRect().setSize(width+10, height+10);
this.setSize(width+10, height+10);
}
/**
* @return
*/
public RectangleFigure getRect() {
return rect;
}
Image stopImage = null;
Image highlightImage = null;
public void addStopIcon(){
if (stopImage == null){
ImageDescriptor desc = SootPlugin.getImageDescriptor("stop_icon.gif");
stopImage = desc.createImage();
}
((Label)getRect().getChildren().get(0)).setIcon(stopImage);
}
Label indicatorLabel;
public void addIndicator(){
if (highlightImage == null){
ImageDescriptor desc = SootPlugin.getImageDescriptor("indicator.gif");
highlightImage = desc.createImage();
}
indicatorLabel = new Label(highlightImage);
this.add(indicatorLabel, 0);
}
public void removeIndicator(){
if (this.getChildren().get(0).equals(indicatorLabel)){
this.remove(indicatorLabel);
}
}
public void removeStopIcon(){
((Label)getRect().getChildren().get(0)).setIcon(null);
}
/**
* @return
*/
public ArrayList getData() {
return data;
}
/**
* @param list
*/
public void setData(ArrayList list) {
data = list;
}
/**
* @param figure
*/
public void setRect(RectangleFigure figure) {
rect = figure;
}
/**
* @return
*/
public soot.Unit getUnit() {
return unit;
}
/**
* @param unit
*/
public void setUnit(soot.Unit unit) {
this.unit = unit;
}
}
| 3,754
| 20.959064
| 107
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/figures/CFGNodeFigure.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.figures;
import org.eclipse.draw2d.*;
import java.util.*;
import org.eclipse.swt.*;
import org.eclipse.swt.graphics.*;
import ca.mcgill.sable.soot.*;
import org.eclipse.draw2d.text.*;
import ca.mcgill.sable.soot.editors.*;
import org.eclipse.jface.resource.*;
public class CFGNodeFigure extends Figure {
private Panel nodeFigure;//RectangleFigure rect;
private XYAnchor srcAnchor;
private XYAnchor tgtAnchor;
private CFGNodeDataFigure data;
private CFGFlowFigure before;
private CFGFlowFigure after;
private boolean hasBefore;
private boolean hasAfter;
Font f = new Font(null, "Arial", 8, SWT.NORMAL);
/**
*
*/
public CFGNodeFigure() {
super();
ToolbarLayout layout2 = new ToolbarLayout();
layout2.setMinorAlignment(ToolbarLayout.ALIGN_CENTER);
this.setLayoutManager(layout2);
layout2.setStretchMinorAxis(false);
}
private int getLineBreak(String text){
return text.lastIndexOf(" ", 50);
}
/**
* @return
*/
public Panel getNodeFigure() {
return nodeFigure;
}
/**
* @param panel
*/
public void setNodeFigure(Panel panel) {
nodeFigure = panel;
}
/**
* @param figure
*/
public void setAfter(CFGFlowFigure figure) {
after = figure;
}
/**
* @param figure
*/
public void setBefore(CFGFlowFigure figure) {
before = figure;
}
/**
* @param figure
*/
public void setData(CFGNodeDataFigure figure) {
data = figure;
}
/**
* @return
*/
public CFGFlowFigure getAfter() {
return after;
}
/**
* @return
*/
public CFGFlowFigure getBefore() {
return before;
}
/**
* @return
*/
public CFGNodeDataFigure getData() {
return data;
}
/**
* @return
*/
public XYAnchor getSrcAnchor() {
int x = this.getBounds().x;
int y = this.getBounds().y;
int width = this.getBounds().width;
int height = this.getBounds().height;
org.eclipse.draw2d.geometry.Point p = new org.eclipse.draw2d.geometry.Point(x+width/2, y+height);
return new XYAnchor(p);
}
/**
* @return
*/
public XYAnchor getTgtAnchor() {
return tgtAnchor;
}
Image indicatorImage = null;
Label indicatorFigure = null;
public void addIndicator(){
}
public void removeIndicator(){
}
}
| 3,068
| 17.713415
| 99
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/figures/CFGPartialFlowFigure.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.figures;
import org.eclipse.draw2d.Figure;
import org.eclipse.draw2d.*;
public class CFGPartialFlowFigure extends Figure {
Panel background;
public CFGPartialFlowFigure() {
super();
FlowLayout layout = new FlowLayout(true);
layout.setMinorAlignment(FlowLayout.ALIGN_CENTER);
this.setLayoutManager(layout);
}
}
| 1,187
| 30.263158
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGEdge.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
public class CFGEdge extends CFGElement {
private CFGNode from;
private CFGNode to;
public CFGEdge(CFGNode from, CFGNode to) {
setFrom(from);
setTo(to);
getFrom().addOutput(this);
getTo().addInput(this);
}
/**
* @return
*/
public CFGNode getFrom() {
return from;
}
/**
* @return
*/
public CFGNode getTo() {
return to;
}
/**
* @param node
*/
public void setFrom(CFGNode node) {
from = node;
}
/**
* @param node
*/
public void setTo(CFGNode node) {
to = node;
}
public String toString(){
return "from: "+getFrom()+" to: "+getTo();
}
}
| 1,465
| 20.558824
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGElement.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
import java.beans.*;
public class CFGElement implements IPropertySource {
public static final String TEXT = "node text";
public static final String CHILDREN = "children";
public static final String INPUTS = "inputs";
public static final String OUTPUTS = "outputs";
public static final String HEAD = "head";
public static final String TAIL = "tail";
public static final String BEFORE_INFO = "before";
public static final String AFTER_INFO = "after";
public static final String NEW_FLOW_DATA = "new_flow_data";
public static final String FLOW_INFO = "flow_info";
public static final String FLOW_CHILDREN = "flow_children";
public static final String PART_FLOW_CHILDREN = "part flow_children";
public static final String NODE_DATA = "node_data";
public static final String REVEAL = "reveal";
public static final String HIGHLIGHT = "highlight";
protected PropertyChangeSupport listeners = new PropertyChangeSupport(this);
public void addPropertyChangeListener(PropertyChangeListener l){
listeners.addPropertyChangeListener(l);
}
protected void firePropertyChange(String name, Object oldVal, Object newVal){
listeners.firePropertyChange(name, oldVal, newVal);
}
protected void firePropertyChange(String name, Object newVal){
firePropertyChange(name, null, newVal);
}
public void removePropertyChangeListener(PropertyChangeListener l){
listeners.removePropertyChangeListener(l);
}
public void fireStructureChange(String name, Object newVal){
firePropertyChange(name, null, newVal);
}
/**
*
*/
public CFGElement() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
*/
public Object getEditableValue() {
return this;
}
/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
*/
public IPropertyDescriptor[] getPropertyDescriptors() {
return new IPropertyDescriptor[1];
}
/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
*/
public Object getPropertyValue(Object id) {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
*/
public boolean isPropertySet(Object id) {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
*/
public void resetPropertyValue(Object id) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
*/
public void setPropertyValue(Object id, Object value) {
}
}
| 3,651
| 29.433333
| 109
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGFlowData.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
import java.util.*;
public class CFGFlowData extends CFGElement {
private ArrayList children = new ArrayList();
public CFGFlowData() {
super();
}
public void addChild(CFGPartialFlowData child){
children.add(child);
fireStructureChange(FLOW_CHILDREN, child);
}
/**
* @return
*/
public ArrayList getChildren() {
return children;
}
/**
* @param list
*/
public void setChildren(ArrayList list) {
children = list;
}
}
| 1,318
| 23.886792
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGFlowInfo.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
public class CFGFlowInfo extends CFGElement {
private String text;
public CFGFlowInfo() {
super();
}
/**
* @return
*/
public String getText() {
return text;
}
/**
* @param string
*/
public void setText(String string) {
text = string;
firePropertyChange(FLOW_INFO, text);
}
}
| 1,176
| 24.042553
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGGraph.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
import java.util.*;
import org.eclipse.ui.*;
import org.eclipse.jface.resource.*;
import org.eclipse.core.runtime.*;
import org.eclipse.draw2d.graph.*;
import org.eclipse.core.resources.*;
public class CFGGraph extends CFGElement implements IEditorInput {
private String name;
private ArrayList children = new ArrayList();
private IResource resource;
public CFGGraph() {
}
public void addChild(CFGNode child){
children.add(child);
fireStructureChange(CHILDREN, child);
}
/**
* @return
*/
public String getName() {
return name;
}
/**
* @param string
*/
public void setName(String string) {
name = string;
}
public boolean exists(){
return false;
}
public ImageDescriptor getImageDescriptor(){
return null;
}
public IPersistableElement getPersistable(){
return null;
}
public String getToolTipText(){
return getName();
}
public Object getAdapter(Class c){
if (c == IResource.class){
return getResource();
}
return null;
}
/**
* @return
*/
public ArrayList getChildren() {
return children;
}
/**
* @param list
*/
public void setChildren(ArrayList list) {
children = list;
}
/**
* @return
*/
public IResource getResource() {
return resource;
}
/**
* @param resource
*/
public void setResource(IResource resource) {
this.resource = resource;
}
public void newFlowData(){
firePropertyChange(CFGElement.NEW_FLOW_DATA, null);
}
public void handleClickEvent(Object evt){
Iterator it = getChildren().iterator();
while (it.hasNext()){
CFGNode child = (CFGNode)it.next();
ArrayList list = child.getData().getText();
if (list.size() == 1){
if (list.get(0).equals(evt)){
child.handleClickEvent(evt);
}
}
}
}
}
| 2,633
| 18.954545
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGNode.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
import java.util.*;
import org.eclipse.draw2d.graph.*;
public class CFGNode extends CFGElement {
private ArrayList inputs = new ArrayList();
private ArrayList outputs = new ArrayList();
private CFGFlowData before;
private CFGFlowData after;
private CFGNodeData data;
private ArrayList children = new ArrayList();
public CFGNode() {
super();
}
public void addInput(CFGEdge input){
getInputs().add(input);
fireStructureChange(CFGElement.INPUTS, input);
}
public void addOutput(CFGEdge output){
getOutputs().add(output);
fireStructureChange(CFGElement.OUTPUTS, output);
}
/**
* @return
*/
public ArrayList getInputs() {
return inputs;
}
/**
* @return
*/
public ArrayList getOutputs() {
return outputs;
}
/**
* @param list
*/
public void setInputs(ArrayList list) {
inputs = list;
}
/**
* @param list
*/
public void setOutputs(ArrayList list) {
outputs = list;
}
/**
* @return
*/
public CFGFlowData getAfter() {
return after;
}
/**
* @return
*/
public CFGFlowData getBefore() {
return before;
}
/**
* @param string
*/
public void setAfter(CFGFlowData data) {
after = data;
int last = getChildren().size() - 1;
if (getChildren().get(last) instanceof CFGFlowData){
getChildren().remove(last);
}
getChildren().add(after);
firePropertyChange(AFTER_INFO, after);
}
/**
* @param string
*/
public void setBefore(CFGFlowData data) {
before = data;
if (getChildren().get(0) instanceof CFGFlowData){
getChildren().remove(0);
}
getChildren().add(0, before);
firePropertyChange(BEFORE_INFO, before);
}
/**
* @return
*/
public CFGNodeData getData() {
return data;
}
/**
* @param data
*/
public void setData(CFGNodeData data) {
this.data = data;
getChildren().add(data);
firePropertyChange(NODE_DATA, data);
}
/**
* @return
*/
public ArrayList getChildren() {
return children;
}
/**
* @param list
*/
public void setChildren(ArrayList list) {
children = list;
}
public void handleClickEvent(Object evt){
firePropertyChange(REVEAL, this);
}
public void handleHighlightEvent(Object evt){
firePropertyChange(HIGHLIGHT, this);
}
}
| 3,074
| 18.585987
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGNodeData.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
import java.util.*;
public class CFGNodeData extends CFGElement {
private ArrayList text;
private boolean head;
private boolean tail;
public CFGNodeData() {
super();
}
/**
* @return
*/
public ArrayList getText() {
return text;
}
/**
* @param list
*/
public void setText(ArrayList list) {
text = list;
firePropertyChange(TEXT, text);
}
/**
* @return
*/
public boolean isHead() {
return head;
}
/**
* @return
*/
public boolean isTail() {
return tail;
}
/**
* @param b
*/
public void setHead(boolean b) {
head = b;
firePropertyChange(HEAD, new Boolean(head));
}
/**
* @param b
*/
public void setTail(boolean b) {
tail = b;
firePropertyChange(TAIL, new Boolean(tail));
}
}
| 1,617
| 18.731707
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/cfg/model/CFGPartialFlowData.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.cfg.model;
import java.util.*;
public class CFGPartialFlowData extends CFGElement {
private ArrayList children = new ArrayList();
public CFGPartialFlowData() {
super();
}
public void addChild(CFGFlowInfo child){
children.add(child);
fireStructureChange(PART_FLOW_CHILDREN, child);
}
/**
* @return
*/
public ArrayList getChildren() {
return children;
}
/**
* @param list
*/
public void setChildren(ArrayList list) {
children = list;
}
}
| 1,332
| 23.685185
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/ColorManager.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.Display;
public class ColorManager {
protected Map fColorTable = new HashMap(10);
public void dispose() {
if (fColorTable.values() == null) return;
Iterator e= fColorTable.values().iterator();
while (e.hasNext())
((Color) e.next()).dispose();
}
public Color getColor(RGB rgb) {
Color color= (Color) fColorTable.get(rgb);
if (color == null) {
color= new Color(Display.getCurrent(), rgb);
fColorTable.put(rgb, color);
}
return color;
}
}
| 1,520
| 28.25
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/IJimpleColorConstants.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.swt.graphics.RGB;
public interface IJimpleColorConstants {
RGB JIMPLE_DOC = new RGB(0,0,0);
RGB JIMPLE_BACKGROUND = new RGB(220,220,220);
RGB JIMPLE_MULTI_COMMENT= new RGB(0,0,0);
RGB JIMPLE_SINGLE_COMMENT= new RGB(0,0,0);
RGB JIMPLE_DEFAULT= new RGB(0,0,0);
RGB JIMPLE_KEYWORD= new RGB(131,111,255);
RGB JIMPLE_STRING= new RGB(200,100,0);
RGB JIMPLE_ATTRIBUTE_GOOD = new RGB(90,200,100);
}
| 1,324
| 34.810811
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleConfiguration.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextDoubleClickStrategy;
import org.eclipse.jface.text.ITextHover;
import org.eclipse.jface.text.TextAttribute;
import org.eclipse.jface.text.contentassist.*;
import org.eclipse.jface.text.presentation.IPresentationReconciler;
import org.eclipse.jface.text.presentation.PresentationReconciler;
import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
import org.eclipse.jface.text.rules.Token;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
import ca.mcgill.sable.soot.attributes.SootAttributesJimpleHover;
public class JimpleConfiguration extends SourceViewerConfiguration {
private JimpleDoubleClickStrategy doubleClickStrategy;
private JimpleScanner scanner;
private ColorManager colorManager;
private JimpleEditor editor;
public JimpleConfiguration(ColorManager colorManager, JimpleEditor editor) {
this.colorManager = colorManager;
setEditor(editor);
}
public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
return new String[] {
IDocument.DEFAULT_CONTENT_TYPE};
}
public ITextDoubleClickStrategy getDoubleClickStrategy(
ISourceViewer sourceViewer,
String contentType) {
if (doubleClickStrategy == null)
doubleClickStrategy = new JimpleDoubleClickStrategy();
return doubleClickStrategy;
}
protected JimpleScanner getJimpleScanner() {
if (scanner == null) {
scanner = new JimpleScanner(colorManager);
scanner.setDefaultReturnToken(
new Token(
new TextAttribute(colorManager.getColor(IJimpleColorConstants.JIMPLE_DEFAULT))));
}
return scanner;
}
/**
* This is what causes Jimple keywords to be highlighted
*/
public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
PresentationReconciler reconciler= new PresentationReconciler();
DefaultDamagerRepairer dr= new DefaultDamagerRepairer(getJimpleScanner());
reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
dr= new DefaultDamagerRepairer(getJimpleScanner());
reconciler.setDamager(dr, JimplePartitionScanner.JIMPLE_STRING);
reconciler.setRepairer(dr, JimplePartitionScanner.JIMPLE_STRING);
return reconciler;
}
/**
* This allows text hover on Jimple Editor
*/
public ITextHover getTextHover(ISourceViewer sourceViewer, String contentType) {
return new SootAttributesJimpleHover(getEditor());
}
public IContentAssistant getContentAssistant(ISourceViewer sourceViewer){
IContentAssistant ca = new ContentAssistant();
ca.install(sourceViewer);
return ca;
}
/**
* Returns the editor.
* @return JimpleEditor
*/
public JimpleEditor getEditor() {
return editor;
}
/**
* Sets the editor.
* @param editor The editor to set
*/
public void setEditor(JimpleEditor editor) {
this.editor = editor;
}
}
| 3,820
| 31.65812
| 90
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleContentOutlinePage.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import java.io.*;
import java.util.ArrayList;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.views.contentoutline.*;
import ca.mcgill.sable.soot.editors.parser.JimpleFile;
public class JimpleContentOutlinePage extends ContentOutlinePage implements ISelectionChangedListener {
private IFile input;
private JimpleEditor ed;
private JimpleFile jimpleFileParser;
private TreeViewer viewer;
public JimpleContentOutlinePage(IFile file, JimpleEditor ed) {
super();
setInput(file);
setEd(ed);
}
public void createControl(Composite parent) {
super.createControl(parent);
setViewer(getTreeViewer());
getViewer().setContentProvider(new JimpleOutlineContentProvider());
getViewer().setLabelProvider(new JimpleOutlineLabelProvider());
getViewer().setInput(getContentOutline());
getViewer().expandAll();
getViewer().addSelectionChangedListener(this);
}
public JimpleOutlineObject getContentOutline(){
setJimpleFileParser(new JimpleFile(getInput()));
return getJimpleFileParser().getOutline();
}
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection selection = (IStructuredSelection)event.getSelection();
if (!selection.isEmpty()) {
Object elem = selection.getFirstElement();
if (elem instanceof JimpleOutlineObject) {
String toHighlight = ((JimpleOutlineObject)elem).getLabel();
int start = getJimpleFileParser().getStartOfSelected(toHighlight);
int length = getJimpleFileParser().getLength(toHighlight);
getEd().selectAndReveal(start, length);
}
}
}
/**
* @return IFile
*/
public IFile getInput() {
return input;
}
/**
* Sets the input.
* @param input The input to set
*/
public void setInput(IFile input) {
this.input = input;
}
/**
* @return
*/
public JimpleEditor getEd() {
return ed;
}
/**
* @param editor
*/
public void setEd(JimpleEditor editor) {
ed = editor;
}
/**
* @return
*/
public JimpleFile getJimpleFileParser() {
return jimpleFileParser;
}
/**
* @param file
*/
public void setJimpleFileParser(JimpleFile file) {
jimpleFileParser = file;
}
/**
* @return
*/
public TreeViewer getViewer() {
return viewer;
}
/**
* @param viewer
*/
public void setViewer(TreeViewer viewer) {
this.viewer = viewer;
}
}
| 3,492
| 23.598592
| 104
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleDocumentProvider.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentPartitioner;
import org.eclipse.jface.text.rules.DefaultPartitioner;
import org.eclipse.ui.editors.text.FileDocumentProvider;
public class JimpleDocumentProvider extends FileDocumentProvider {
public JimpleDocumentProvider() {
super();
}
/* (non-Javadoc)
* Method declared on AbstractDocumentProvider
*/
protected IDocument createDocument(Object element) throws CoreException {
IDocument document = super.createDocument(element);
if (document != null) {
IDocumentPartitioner partitioner =
new DefaultPartitioner(
new JimplePartitionScanner(),
new String[] { JimplePartitionScanner.JIMPLE_STRING});
partitioner.connect(document);
document.setDocumentPartitioner(partitioner);
}
return document;
}
}
| 1,737
| 32.423077
| 74
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleDoubleClickStrategy.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.jface.text.*;
public class JimpleDoubleClickStrategy implements ITextDoubleClickStrategy {
protected ITextViewer fText;
public JimpleDoubleClickStrategy() {
super();
}
public void doubleClicked(ITextViewer part) {
int pos = part.getSelectedRange().x;
if (pos < 0)
return;
fText = part;
if (!selectComment(pos)) {
selectWord(pos);
}
}
protected boolean selectComment(int caretPos) {
IDocument doc = fText.getDocument();
int startPos, endPos;
try {
int pos = caretPos;
char c = ' ';
while (pos >= 0) {
c = doc.getChar(pos);
if (c == '\\') {
pos -= 2;
continue;
}
if (c == Character.LINE_SEPARATOR || c == '\"')
break;
--pos;
}
if (c != '\"')
return false;
startPos = pos;
pos = caretPos;
int length = doc.getLength();
c = ' ';
while (pos < length) {
c = doc.getChar(pos);
if (c == Character.LINE_SEPARATOR || c == '\"')
break;
++pos;
}
if (c != '\"')
return false;
endPos = pos;
int offset = startPos +1;
int len = endPos - offset;
fText.setSelectedRange(offset, len);
return true;
} catch (BadLocationException x) {
}
return false;
}
protected boolean selectWord(int caretPos) {
IDocument doc = fText.getDocument();
int startPos, endPos;
try {
int pos = caretPos;
char c;
while (pos >= 0) {
c = doc.getChar(pos);
if (!Character.isJavaIdentifierPart(c))
break;
--pos;
}
startPos = pos;
pos = caretPos;
int length = doc.getLength();
while (pos < length) {
c = doc.getChar(pos);
if (!Character.isJavaIdentifierPart(c))
break;
++pos;
}
endPos = pos;
selectRange(startPos, endPos);
return true;
} catch (BadLocationException x) {
}
return false;
}
private void selectRange(int startPos, int stopPos) {
int offset = startPos+1;
int length = stopPos - offset;
fText.setSelectedRange(offset, length);
}
}
| 2,851
| 19.817518
| 76
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleEditor.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.editors.text.TextEditor;
import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
import ca.mcgill.sable.soot.SootPlugin;
public class JimpleEditor extends TextEditor {
private ColorManager colorManager;
protected JimpleContentOutlinePage page;
private ISourceViewer viewer;
/**
* Constructor for JimpleEditor.
*/
public JimpleEditor() {
super();
colorManager = SootPlugin.getDefault().getColorManager();
setSourceViewerConfiguration(new JimpleConfiguration(colorManager, this));
setDocumentProvider(new JimpleDocumentProvider());
setViewer(this.getSourceViewer());
}
/**
* This method is what creates the Jimple Content Outliner
*/
public Object getAdapter(Class key) {
if (key.equals(IContentOutlinePage.class)) {
//System.out.println("in getAdapter of editor");
IEditorInput input = getEditorInput();
if (input instanceof IFileEditorInput) {
setPage(new JimpleContentOutlinePage(((IFileEditorInput)input).getFile(), this));
return getPage();
}
}
return super.getAdapter(key);
}
public void dispose() {
super.dispose();
}
/**
* @return
*/
public JimpleContentOutlinePage getPage() {
return page;
}
/**
* @param page
*/
public void setPage(JimpleContentOutlinePage page) {
this.page = page;
}
protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
setViewer(super.createSourceViewer(parent, ruler, styles));
SootPlugin.getDefault().addEditorViewer(getViewer());
return getViewer();
}
/**
* @return
*/
public ISourceViewer getViewer() {
return viewer;
}
/**
* @param viewer
*/
public void setViewer(ISourceViewer viewer) {
this.viewer = viewer;
}
}
| 2,834
| 25.495327
| 97
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleOutlineContentProvider.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
public class JimpleOutlineContentProvider implements ITreeContentProvider {
protected static final Object[] EMPTY_ARRAY = new Object[0];
/**
* Constructor for OptionsTreeContentProvider.
*/
public JimpleOutlineContentProvider() {
super();
}
/**
* @see org.eclipse.jface.viewers.ITreeContentProvider#getChildren(Object)
*/
public Object[] getChildren(Object parentElement) {
if (parentElement instanceof JimpleOutlineObject) {
JimpleOutlineObject opt = (JimpleOutlineObject)parentElement;
if (opt.getChildren() != null) {
return opt.getChildren().toArray();
}
else {
return EMPTY_ARRAY;
}
}
else {
return EMPTY_ARRAY;
}
}
/**
* @see org.eclipse.jface.viewers.ITreeContentProvider#getParent(Object)
*/
public Object getParent(Object element) {
return ((JimpleOutlineObject)element).getParent();
}
/**
* @see org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(Object)
*/
public boolean hasChildren(Object element) {
if (element instanceof JimpleOutlineObject) {
if (((JimpleOutlineObject)element).getChildren() != null) {
return true;
}
else {
return false;
}
}
else {
return false;
}
}
/**
* @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(Object)
*/
public Object[] getElements(Object inputElement) {
return getChildren(inputElement);
}
/**
* @see org.eclipse.jface.viewers.IContentProvider#dispose()
*/
public void dispose() {
}
/**
* @see org.eclipse.jface.viewers.IContentProvider#inputChanged(Viewer, Object, Object)
*/
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
}
}
| 2,638
| 23.896226
| 88
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleOutlineLabelProvider.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import java.util.*;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import ca.mcgill.sable.soot.SootPlugin;
public class JimpleOutlineLabelProvider implements ILabelProvider {
private HashMap imageCache;
/**
* Constructor for OptionsTreeLabelProvider.
*/
public JimpleOutlineLabelProvider() {
super();
}
/**
* @see org.eclipse.jface.viewers.ILabelProvider#getImage(Object)
*/
public Image getImage(Object element) {
ImageDescriptor descriptor = null;
if (element instanceof JimpleOutlineObject){
switch (((JimpleOutlineObject)element).getType()){
case JimpleOutlineObject.CLASS: {
descriptor = SootPlugin.getImageDescriptor("class_obj.gif");
break;
}
case JimpleOutlineObject.INTERFACE: {
descriptor = SootPlugin.getImageDescriptor("int_obj.gif");
break;
}
case JimpleOutlineObject.PUBLIC_METHOD:{
descriptor = SootPlugin.getImageDescriptor("public_co.gif");
break;
}
case JimpleOutlineObject.PROTECTED_METHOD:{
descriptor = SootPlugin.getImageDescriptor("protected_co.gif");
break;
}
case JimpleOutlineObject.PRIVATE_METHOD:{
descriptor = SootPlugin.getImageDescriptor("private_co.gif");
break;
}
case JimpleOutlineObject.NONE_METHOD: {
descriptor = SootPlugin.getImageDescriptor("default_co.gif");
break;
}
case JimpleOutlineObject.PUBLIC_FIELD: {
descriptor = SootPlugin.getImageDescriptor("field_public_obj.gif");
break;
}
case JimpleOutlineObject.PROTECTED_FIELD: {
descriptor = SootPlugin.getImageDescriptor("field_protected_obj.gif");
break;
}
case JimpleOutlineObject.PRIVATE_FIELD: {
descriptor = SootPlugin.getImageDescriptor("field_private_obj.gif");
break;
}
case JimpleOutlineObject.NONE_FIELD: {
descriptor = SootPlugin.getImageDescriptor("field_default_obj.gif");
break;
}
default:{
return null;
}
}
}
if (getImageCache() == null){
setImageCache(new HashMap());
}
Image image = (Image)getImageCache().get(descriptor);
if (image == null) {
image = descriptor.createImage();
getImageCache().put(descriptor, image);
}
return image;
}
/**
* @see org.eclipse.jface.viewers.ILabelProvider#getText(Object)
*/
public String getText(Object element) {
return ((JimpleOutlineObject)element).getLabel();
}
/**
* @see org.eclipse.jface.viewers.IBaseLabelProvider#addListener(ILabelProviderListener)
*/
public void addListener(ILabelProviderListener listener) {
}
/**
* @see org.eclipse.jface.viewers.IBaseLabelProvider#dispose()
*/
public void dispose() {
if (getImageCache() != null){
Iterator it = getImageCache().values().iterator();
while (it.hasNext()){
((Image)it.next()).dispose();
}
getImageCache().clear();
}
}
/**
* @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(Object, String)
*/
public boolean isLabelProperty(Object element, String property) {
return false;
}
/**
* @see org.eclipse.jface.viewers.IBaseLabelProvider#removeListener(ILabelProviderListener)
*/
public void removeListener(ILabelProviderListener listener) {
}
/**
* @return
*/
public HashMap getImageCache() {
return imageCache;
}
/**
* @param map
*/
public void setImageCache(HashMap map) {
imageCache = map;
}
}
| 4,487
| 24.942197
| 92
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleOutlineObject.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import java.util.*;
public class JimpleOutlineObject {
private Vector children;
private String label;
private JimpleOutlineObject parent;
private int type;
private BitSet decorators;
public static final int NONE = 100;
public static final int CLASS = 10;
public static final int INTERFACE = 11;
public static final int METHOD = 1;
public static final int PUBLIC_METHOD = 2;
public static final int PRIVATE_METHOD = 3;
public static final int PROTECTED_METHOD = 4;
public static final int NONE_METHOD = 30;
public static final int FIELD = 5;
public static final int PUBLIC_FIELD = 6;
public static final int PRIVATE_FIELD = 7;
public static final int PROTECTED_FIELD = 8;
public static final int NONE_FIELD = 31;
public static final int FINAL_DEC = 20;
public static final int STATIC_DEC = 21;
public static final int SYNCHRONIZED_DEC = 22;
public static final int ABSTRACT_DEC = 23;
public JimpleOutlineObject(String label, int type, BitSet dec){
setLabel(label);
setType(type);
setDecorators(dec);
}
public void addChild(JimpleOutlineObject t) {
if (getChildren() == null) {
setChildren(new Vector());
}
t.setParent(this);
getChildren().add(t);
}
/**
* @return
*/
public Vector getChildren() {
return children;
}
/**
* @return
*/
public String getLabel() {
return label;
}
/**
* @return
*/
public JimpleOutlineObject getParent() {
return parent;
}
/**
* @param vector
*/
public void setChildren(Vector vector) {
children = vector;
}
/**
* @param string
*/
public void setLabel(String string) {
label = string;
}
/**
* @param object
*/
public void setParent(JimpleOutlineObject object) {
parent = object;
}
/**
* @return
*/
public int getType() {
return type;
}
/**
* @param i
*/
public void setType(int i) {
type = i;
}
/**
* @return
*/
public BitSet getDecorators() {
return decorators;
}
/**
* @param list
*/
public void setDecorators(BitSet list) {
decorators = list;
}
}
| 2,900
| 19.870504
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimplePartitionScanner.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.jface.text.rules.*;
public class JimplePartitionScanner extends RuleBasedPartitionScanner {
public final static String JIMPLE_STRING = "__jimple_string";
public final static String SKIP = "__skip";
public JimplePartitionScanner() {
List rules = new ArrayList();
IToken string = new Token(JIMPLE_STRING);
IToken skip = new Token(SKIP);
rules.add(new SingleLineRule("\"", "\"", string, '\\'));
rules.add(new SingleLineRule("'", "'", skip, '\\'));
IPredicateRule[] result= new IPredicateRule[rules.size()];
rules.toArray(result);
setPredicateRules(result);
}
}
| 1,523
| 32.866667
| 71
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleScanner.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import java.util.*;
import org.eclipse.jface.text.rules.*;
import org.eclipse.jface.text.*;
public class JimpleScanner extends RuleBasedScanner {
private static String[] keywords= {
"ignored",
"abstract",
"final",
"native",
"public",
"protected",
"private",
"static",
"synchronized",
"transient",
"volatile",
"class",
"interface",
"void",
"boolean",
"byte",
"short",
"char",
"int",
"long",
"float",
"double",
"null_type",
"unknown",
"extends",
"implements",
"breakpoint",
"case",
"catch",
"cmp",
"cmpg",
"cmpl",
"default",
"entermonitor",
"exitmonitor",
"goto",
"if",
"instanceof",
"interfaceinvoke",
"lengthof",
"lookupswitch",
"neg",
"new",
"newarray",
"newmultiarray",
"nop",
"ret",
"return",
"specialinvoke",
"staticinvoke",
"tableswitch",
"throw",
"throws",
"virtualinvoke",
"null",
"from",
"to",
"with",
"annotation",
"enum"
};
public JimpleScanner(ColorManager manager) {
List rules = new ArrayList();
IToken string = new Token(new TextAttribute(manager.getColor(IJimpleColorConstants.JIMPLE_STRING)));
IToken def= new Token(new TextAttribute(manager.getColor(IJimpleColorConstants.JIMPLE_DEFAULT)));
IToken key= new Token(new TextAttribute(manager.getColor(IJimpleColorConstants.JIMPLE_KEYWORD)));
rules.add(new SingleLineRule("\"", "\"", string, '\\'));
rules.add(new SingleLineRule("'", "'", string, '\\'));
WordRule wordRule= new WordRule(new JimpleWordDetector(), def);
for (int i=0; i<keywords.length; i++)
wordRule.addWord(keywords[i], key);
rules.add(wordRule);
// Add generic whitespace rule.
rules.add(new WhitespaceRule(new JimpleWhitespaceDetector()));
IRule[] result = new IRule[rules.size()];
rules.toArray(result);
setRules(result);
}
}
| 2,782
| 22.191667
| 104
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleWhitespaceDetector.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.jface.text.rules.IWhitespaceDetector;
/**
* @author jlhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
public class JimpleWhitespaceDetector implements IWhitespaceDetector {
public boolean isWhitespace(char c) {
return (c == ' ' || c == '\t' || c == '\n' || c == '\r');
}
}
| 1,869
| 37.958333
| 70
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/JimpleWordDetector.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors;
import org.eclipse.jface.text.rules.IWordDetector;
public class JimpleWordDetector implements IWordDetector {
public boolean isWordStart(char c) {
return Character.isJavaIdentifierStart(c);
}
public boolean isWordPart(char c) {
return Character.isJavaIdentifierPart(c);
}
}
| 1,155
| 34.030303
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/parser/JimpleBody.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors.parser;
import java.util.*;
public class JimpleBody {
private String text;
private ArrayList textArr;
private ArrayList methods;
private ArrayList fields;
public JimpleBody(String text, ArrayList textArr){
setText(text);
setTextArr(textArr);
}
public boolean isJimpleBody() {
return true;
}
public void parseBody(){
// getTextArr().get(1) -> class line
// ignore empty lines, first line with { and last
// line with }
setFields(new ArrayList());
setMethods(new ArrayList());
Iterator it = getTextArr().iterator();
int counter = 0;
boolean inMethod = false;
while (it.hasNext()){
String temp = (String)it.next();
if ((temp.trim().equals("}")) && (inMethod)){
inMethod = false;
}
if (!inMethod){
if (counter < 2){
}
else if (JimpleField.isField(temp)){
getFields().add(temp);
}
else if (JimpleMethod.isMethod(temp)){
getMethods().add(temp);
if (temp.indexOf(";") != -1){
}
else{
inMethod = true;
}
}
}
counter++;
}
}
/**
* @return String
*/
public String getText() {
return text;
}
/**
* Sets the text.
* @param text The text to set
*/
public void setText(String text) {
this.text = text;
}
/**
* @return
*/
public ArrayList getTextArr() {
return textArr;
}
/**
* @param list
*/
public void setTextArr(ArrayList list) {
textArr = list;
}
/**
* @param list
*/
public void setFields(ArrayList list) {
fields = list;
}
/**
* @param list
*/
public void setMethods(ArrayList list) {
methods = list;
}
/**
* @return
*/
public ArrayList getFields() {
return fields;
}
/**
* @return
*/
public ArrayList getMethods() {
return methods;
}
}
| 2,619
| 17.985507
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/parser/JimpleField.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors.parser;
import java.util.*;
import ca.mcgill.sable.soot.editors.JimpleOutlineObject;
public class JimpleField {
private String val;
private String label;
private String type;
private ArrayList modifiers;
private int imageType;
public JimpleField(String val){
setVal(val);
}
public void parseField(){
StringTokenizer st = new StringTokenizer(getVal());
int numTokens = st.countTokens();
int counter = 1;
String tempType = "";
while (st.hasMoreTokens()){
String next = st.nextToken();
if (JimpleModifier.isModifier(next)) {
if (getModifiers() == null){
setModifiers(new ArrayList());
}
getModifiers().add(next);
}
if (!JimpleModifier.isModifier(next) && (counter != numTokens)){
tempType = tempType + next;
}
if (counter == numTokens){
setType(tempType);
setLabel(next.substring(0, next.indexOf(";"))+" : "+getType());
}
counter++;
}
}
public void findImageType(){
if (getModifiers() == null){
setImageType(JimpleOutlineObject.NONE_FIELD);
return;
}
if (getModifiers().contains("public")) {
setImageType(JimpleOutlineObject.PUBLIC_FIELD);
}
else if (getModifiers().contains("protected")) {
setImageType(JimpleOutlineObject.PROTECTED_FIELD);
}
else if (getModifiers().contains("private")) {
setImageType(JimpleOutlineObject.PRIVATE_FIELD);
}
else {
setImageType(JimpleOutlineObject.NONE_FIELD);
}
}
public BitSet findDecorators() {
BitSet bits = new BitSet();
if (getModifiers() == null) return bits;
if (getModifiers().contains("abstract")){
bits.set(JimpleOutlineObject.ABSTRACT_DEC);
}
if (getModifiers().contains("final")){
bits.set(JimpleOutlineObject.FINAL_DEC);
}
if (getModifiers().contains("static")){
bits.set(JimpleOutlineObject.STATIC_DEC);
}
if (getModifiers().contains("synchronized")){
bits.set(JimpleOutlineObject.SYNCHRONIZED_DEC);
}
return bits;
}
public static boolean isField(String val){
if ((val.indexOf("(") != -1) || (val.indexOf(")") != -1)) return false;
if (val.indexOf(";") == -1) return false;
return true;
}
/**
* @return
*/
public String getLabel() {
return label;
}
/**
* @return
*/
public ArrayList getModifiers() {
return modifiers;
}
/**
* @return
*/
public String getVal() {
return val;
}
/**
* @param string
*/
public void setLabel(String string) {
label = string;
}
/**
* @param list
*/
public void setModifiers(ArrayList list) {
modifiers = list;
}
/**
* @param string
*/
public void setVal(String string) {
val = string;
}
/**
* @return
*/
public String getType() {
return type;
}
/**
* @param string
*/
public void setType(String string) {
type = string;
}
/**
* @return
*/
public int getImageType() {
return imageType;
}
/**
* @param i
*/
public void setImageType(int i) {
imageType = i;
}
}
| 3,776
| 20.338983
| 73
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/parser/JimpleFile.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors.parser;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
import ca.mcgill.sable.soot.editors.JimpleOutlineObject;
@SuppressWarnings("rawtypes")
public class JimpleFile {
private String file;
private IFile input;
private ArrayList arr;
private ArrayList fields;
private ArrayList methods;
private ArrayList modifiers;
private int imageType;
public static final String LEFT_BRACE = "{";
public static final String RIGHT_BRACE = "}";
public JimpleFile(IFile file){
setInput(file);
BufferedReader br;
try {
br = new BufferedReader(new InputStreamReader(getInput().getContents()));
StringBuffer sb = new StringBuffer();
String line;
try {
while ((line = br.readLine()) != null) {
sb.append(line + "\n");
}
} catch (IOException e) {
e.printStackTrace();
}
setFile(sb.toString());
} catch (CoreException e1) {
e1.printStackTrace();
}
}
public boolean isJimpleFile() throws IOException, CoreException{
// handles body section
StringBuffer sb = new StringBuffer(getFile());
int leftBracePos = getFile().indexOf(LEFT_BRACE);
int rightBracePos = getFile().lastIndexOf(RIGHT_BRACE);
JimpleBody jBody = new JimpleBody(sb.subSequence(leftBracePos, rightBracePos).toString(), getArr());
if (!jBody.isJimpleBody()) return false;
return true;
}
private int findImageType() {
if (getModifiers() == null) return JimpleOutlineObject.CLASS;
else {
if (getModifiers().contains("interface")) return JimpleOutlineObject.INTERFACE;
else return JimpleOutlineObject.CLASS;
}
}
private BitSet findDecorators() {
BitSet bits = new BitSet();
if (getModifiers() == null) return bits;
if (getModifiers().contains("abstract")){
bits.set(JimpleOutlineObject.ABSTRACT_DEC);
}
if (getModifiers().contains("final")){
bits.set(JimpleOutlineObject.FINAL_DEC);
}
if (getModifiers().contains("static")){
bits.set(JimpleOutlineObject.STATIC_DEC);
}
if (getModifiers().contains("synchronized")){
bits.set(JimpleOutlineObject.SYNCHRONIZED_DEC);
}
return bits;
}
public JimpleOutlineObject getOutline() {
StringBuffer sb = new StringBuffer(getFile());
int leftBracePos = getFile().indexOf(LEFT_BRACE);
int rightBracePos = getFile().lastIndexOf(RIGHT_BRACE);
// get key - class name
StringTokenizer st = new StringTokenizer(sb.substring(0, leftBracePos));
String className = null;
while (true) {
String token = st.nextToken();
if (JimpleModifier.isModifier(token)) {
if (getModifiers() == null){
setModifiers(new ArrayList());
}
getModifiers().add(token);
continue;
}
if (isFileType(token)) {
if (getModifiers() == null){
setModifiers(new ArrayList());
}
getModifiers().add(token);
continue;
}
className = token;
break;
}
JimpleOutlineObject outline = new JimpleOutlineObject("", JimpleOutlineObject.NONE, null);
JimpleOutlineObject file = new JimpleOutlineObject(className, findImageType(), findDecorators());
outline.addChild(file);
// gets methods
JimpleBody jBody = new JimpleBody(sb.substring(leftBracePos, rightBracePos), getArr());
jBody.parseBody();
ArrayList fieldLabels = jBody.getFields();
Iterator itF = fieldLabels.iterator();
while (itF.hasNext()){
JimpleField field = new JimpleField(itF.next().toString());
field.parseField();
field.findImageType();
if (getFields() == null){
setFields(new ArrayList());
}
getFields().add(field);
file.addChild(new JimpleOutlineObject(field.getLabel(), field.getImageType(), field.findDecorators() ));
}
ArrayList methodLabels =jBody.getMethods();
Iterator it = methodLabels.iterator();
while (it.hasNext()){
JimpleMethod method = new JimpleMethod(it.next().toString());
method.parseMethod();
method.findImageType();
if (getMethods() == null){
setMethods(new ArrayList());
}
getMethods().add(method);
file.addChild(new JimpleOutlineObject(method.getLabel(), method.getImageType(), method.findDecorators()));
}
return outline;
}
public String getSearch(String val){
Iterator it;
String search = val;
if (getFields() != null) {
it = getFields().iterator();
while (it.hasNext()) {
JimpleField next = (JimpleField)it.next();
if (val.equals(next.getLabel())){
search = next.getVal();
}
}
}
if (getMethods() != null) {
it = getMethods().iterator();
while (it.hasNext()) {
JimpleMethod next = (JimpleMethod)it.next();
if (val.equals(next.getLabel())){
search = next.getVal();
}
}
}
return search;
}
public int getStartOfSelected(String val) {
BufferedReader in;
try {
in = new BufferedReader(new InputStreamReader(getInput().getContents()));
} catch (CoreException e1) {
e1.printStackTrace();
return 0;
}
String search = getSearch(val).trim();
int count = 0;
int cur;
String line = "";
try {
while ((cur = in.read()) != -1) {
char c = (char) cur;
if (c == '\n' || ("" + c).equals(System.getProperty("line.separator"))) {
int index = line.indexOf(search);
if (index != -1) {
return count - line.length() + index;
}
line = "";
}
line += c;
count += 1;
}
} catch (IOException e) {
e.printStackTrace();
}
return 0;
}
public int getLength(String val){
String search = getSearch(val);
search = search.trim();
return search.length();
}
private boolean isFileType(String token) {
HashSet filetypes = new HashSet();
filetypes.add("class");
filetypes.add("interface");
if (filetypes.contains(token)) return true;
else return false;
}
/**
* @return String
*/
public String getFile() {
return file;
}
/**
* Sets the file.
* @param file The file to set
*/
public void setFile(String file) {
this.file = file;
}
/**
* @return
*/
public IFile getInput() {
return input;
}
public ArrayList getArr() {
if (arr == null)
initArr();
return arr;
}
private void initArr() {
ArrayList text = new ArrayList();
try {
BufferedReader br = new BufferedReader(new InputStreamReader(getInput().getContents()));
while (true) {
String nextLine = null;
try {
nextLine = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
if (nextLine == null) break;// || (nextLine.length() == 0)) break;
text.add(nextLine);
}
} catch (CoreException e) {
e.printStackTrace();
}
arr = text;
}
/**
* @param list
*/
public void setInput(IFile file) {
input = file;
}
/**
* @return
*/
public ArrayList getFields() {
return fields;
}
/**
* @return
*/
public ArrayList getMethods() {
return methods;
}
/**
* @param list
*/
public void setFields(ArrayList list) {
fields = list;
}
/**
* @param list
*/
public void setMethods(ArrayList list) {
methods = list;
}
/**
* @return
*/
public ArrayList getModifiers() {
return modifiers;
}
/**
* @param list
*/
public void setModifiers(ArrayList list) {
modifiers = list;
}
/**
* @return
*/
public int getImageType() {
return imageType;
}
/**
* @param i
*/
public void setImageType(int i) {
imageType = i;
}
}
| 8,453
| 21.188976
| 109
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/parser/JimpleMethod.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors.parser;
import java.util.*;
import ca.mcgill.sable.soot.editors.JimpleOutlineObject;
public class JimpleMethod {
private String val;
private String label;
private String type;
private ArrayList modifiers;
private int imageType;
public static boolean isMethod(String val){
if ((val.indexOf("(") != -1) && (val.indexOf(")") != -1)) return true;
return false;
}
public JimpleMethod(String val){
setVal(val);
}
public void parseMethod(){
StringTokenizer st = new StringTokenizer(getVal());
int numTokens = st.countTokens();
String tempLabel = "";
boolean addLabel = false;
while (st.hasMoreTokens()){
String next = st.nextToken();
if (JimpleModifier.isModifier(next)) {
if (getModifiers() == null){
setModifiers(new ArrayList());
}
getModifiers().add(next);
}
if (next.indexOf("(") != -1){
addLabel = true;
}
if (addLabel){
tempLabel = tempLabel + next;
tempLabel = tempLabel + " ";
}
}
setLabel(tempLabel);
}
public void findImageType(){
if (getModifiers() == null){
setImageType(JimpleOutlineObject.NONE_METHOD);
return;
}
if (getModifiers().contains("public")) {
setImageType(JimpleOutlineObject.PUBLIC_METHOD);
}
else if (getModifiers().contains("protected")) {
setImageType(JimpleOutlineObject.PROTECTED_METHOD);
}
else if (getModifiers().contains("private")) {
setImageType(JimpleOutlineObject.PRIVATE_METHOD);
}
else {
setImageType(JimpleOutlineObject.NONE_METHOD);
}
}
public BitSet findDecorators() {
BitSet bits = new BitSet();
if (getModifiers() == null) return bits;
if (getModifiers().contains("abstract")){
bits.set(JimpleOutlineObject.ABSTRACT_DEC);
}
if (getModifiers().contains("final")){
bits.set(JimpleOutlineObject.FINAL_DEC);
}
if (getModifiers().contains("static")){
bits.set(JimpleOutlineObject.STATIC_DEC);
}
if (getModifiers().contains("synchronized")){
bits.set(JimpleOutlineObject.SYNCHRONIZED_DEC);
}
return bits;
}
/**
* @return
*/
public int getImageType() {
return imageType;
}
/**
* @return
*/
public String getLabel() {
return label;
}
/**
* @return
*/
public ArrayList getModifiers() {
return modifiers;
}
/**
* @return
*/
public String getType() {
return type;
}
/**
* @return
*/
public String getVal() {
return val;
}
/**
* @param i
*/
public void setImageType(int i) {
imageType = i;
}
/**
* @param string
*/
public void setLabel(String string) {
label = string;
}
/**
* @param list
*/
public void setModifiers(ArrayList list) {
modifiers = list;
}
/**
* @param string
*/
public void setType(String string) {
type = string;
}
/**
* @param string
*/
public void setVal(String string) {
val = string;
}
}
| 3,684
| 19.702247
| 73
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/editors/parser/JimpleModifier.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.editors.parser;
import java.util.HashSet;
public class JimpleModifier {
public static boolean isModifier(String token) {
HashSet modifiers = new HashSet();
modifiers.add("abstract");
modifiers.add("final");
modifiers.add("native");
modifiers.add("public");
modifiers.add("protected");
modifiers.add("private");
modifiers.add("static");
modifiers.add("synchronized");
modifiers.add("transient");
modifiers.add("volatile");
if (modifiers.contains(token)) return true;
else return false;
}
}
| 1,381
| 30.409091
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/examples/NewAnnotateClassWizard.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2008 Eric Bodden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.examples;
/**
*
* @author Eric Bodden
*/
public class NewAnnotateClassWizard extends NewSootExampleWizard {
public NewAnnotateClassWizard() {
super("AnnotateClass.java","MyMain.java");
}
}
| 1,050
| 31.84375
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/examples/NewBodyTransformerWizard.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2008 Eric Bodden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.examples;
/**
*
* @author Eric Bodden
*/
public class NewBodyTransformerWizard extends NewSootExampleWizard {
public NewBodyTransformerWizard() {
super("BodyTransformer.java","MyMain.java");
}
}
| 1,056
| 32.03125
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/examples/NewCreateSootClassWizard.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2008 Eric Bodden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.examples;
/**
*
* @author Eric Bodden
*/
public class NewCreateSootClassWizard extends NewSootExampleWizard {
public NewCreateSootClassWizard() {
super("AnnotateClass.java","MyMain.java");
}
}
| 1,054
| 31.96875
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/examples/NewGotoInstrumenterWizard.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2008 Eric Bodden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.examples;
/**
*
* @author Eric Bodden
*/
public class NewGotoInstrumenterWizard extends NewSootExampleWizard {
public NewGotoInstrumenterWizard() {
super("GotoInstrumenter.java","MyMain.java");
}
}
| 1,059
| 32.125
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/examples/NewSootExampleWizard.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2008 Eric Bodden
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.examples;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.internal.ui.JavaPlugin;
import org.eclipse.jdt.internal.ui.wizards.JavaProjectWizard;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.PartInitException;
import org.eclipse.ui.ide.IDE;
import ca.mcgill.sable.soot.SootClasspathVariableInitializer;
import ca.mcgill.sable.soot.SootPlugin;
public abstract class NewSootExampleWizard extends JavaProjectWizard {
protected final String fromFile;
protected final String toFile;
protected NewSootExampleWizard(String fromFile, String toFile) {
this.fromFile = fromFile;
this.toFile = toFile;
}
@Override
public boolean performFinish() {
boolean performFinish = super.performFinish();
if(performFinish) {
IJavaProject newProject = (IJavaProject) getCreatedElement();
try {
IClasspathEntry[] originalCP = newProject.getRawClasspath();
IClasspathEntry ajrtLIB = JavaCore.newVariableEntry(
new Path(SootClasspathVariableInitializer.VARIABLE_NAME_CLASSES),
new Path(SootClasspathVariableInitializer.VARIABLE_NAME_SOURCE),
null);
// Update the raw classpath with the new entry
int originalCPLength = originalCP.length;
IClasspathEntry[] newCP = new IClasspathEntry[originalCPLength + 1];
System.arraycopy(originalCP, 0, newCP, 0, originalCPLength);
newCP[originalCPLength] = ajrtLIB;
newProject.setRawClasspath(newCP, new NullProgressMonitor());
} catch (JavaModelException e) {
}
String templateFilePath = fromFile;
InputStream is = null;
FileOutputStream fos = null;
try {
is = SootPlugin.getDefault().getBundle().getResource(templateFilePath).openStream();
if(is==null) {
new RuntimeException("Resource "+templateFilePath+" not found!").printStackTrace();
} else {
IClasspathEntry[] resolvedClasspath = newProject.getResolvedClasspath(true);
IClasspathEntry firstSourceEntry = null;
for (IClasspathEntry classpathEntry : resolvedClasspath) {
if(classpathEntry.getEntryKind()==IClasspathEntry.CPE_SOURCE) {
firstSourceEntry = classpathEntry;
break;
}
}
if(firstSourceEntry!=null) {
IPath path = SootPlugin.getWorkspace().getRoot().getFile(firstSourceEntry.getPath()).getLocation();
String srcPath = path.toString();
String newfileName = toFile;
final IPath newFilePath = firstSourceEntry.getPath().append(newfileName);
fos = new FileOutputStream(srcPath + File.separator + newfileName);
int temp = is.read();
while(temp>-1) {
fos.write(temp);
temp = is.read();
}
fos.close();
//refresh project
newProject.getProject().refreshLocal(IResource.DEPTH_INFINITE, new NullProgressMonitor());
final IWorkbenchPage activePage= JavaPlugin.getActivePage();
if (activePage != null) {
final Display display= getShell().getDisplay();
if (display != null) {
display.asyncExec(new Runnable() {
public void run() {
try {
IResource newResource = SootPlugin.getWorkspace().getRoot().findMember(newFilePath);
IDE.openEditor(activePage, (IFile) newResource, true);
} catch (PartInitException e) {
JavaPlugin.log(e);
}
}
});
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
if(is!=null) is.close();
if(fos!=null) fos.close();
} catch (IOException e) {
}
}
}
return performFinish;
}
@Override
public void addPages() {
addPage(new FirstPage());
super.addPages();
}
protected static class FirstPage extends WizardPage {
private FirstPage() {
super("ca.mcgill.sable.soot.examples.NewExamplePage");
}
public void createControl(Composite parent) {
final Composite composite= new Composite(parent, SWT.NULL);
composite.setFont(parent.getFont());
composite.setLayout(new FillLayout());
setControl(composite);
Label label = new Label(composite, SWT.WRAP);
setControl(composite);
label.setText("Please create a new Java project using the following Wizard " +
"pages. Soot will then create the example source files in the project's source folder.");
setTitle("Create example Soot extension");
setMessage("This wizard will help you create a new example Soot extension.");
}
}
}
| 5,955
| 33.034286
| 105
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/interaction/DataKeeper.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.interaction;
import soot.toolkits.graph.interaction.*;
import java.util.*;
public class DataKeeper {
private List flowInfoList;
private FlowInfo current;
private int total;
private int repeat;
private InteractionController controller;
public DataKeeper(InteractionController controller){
setController(controller);
}
public void stepBack(){
// this will be called from InteractionStepBack
// it will cause the most recent flow info data
// to be removed resulting in a blank if on iteration
// 0 or the results at this node from the
// previous iteration
// if it is the very fist node and
// very first iteration nothing will happen
// no where to go back to
if (getCurrent() == null) return;
int index = getFlowInfoList().indexOf(getCurrent());
FlowInfo previous;
FlowInfo clearTo;
// on first iter need to replace with empty
if (index > 0) {
previous = (FlowInfo)getFlowInfoList().get(index-1);
}
else {
// at first node and want to go back
previous = null;
}
clearTo = findLast();
setCurrent(previous);
getController().setEvent(new InteractionEvent(IInteractionConstants.CLEARTO, clearTo));
getController().handleEvent();
if (previous != null){
getController().setEvent(new InteractionEvent(IInteractionConstants.REPLACE, previous));
getController().handleEvent();
}
}
private FlowInfo findLast(){
Iterator it = getFlowInfoList().iterator();
FlowInfo retInfo = new FlowInfo("", getCurrent().unit(), getCurrent().isBefore());
while (it.hasNext()){
FlowInfo next = (FlowInfo)it.next();
if (getCurrent().equals(next)) break;
if (getCurrent().unit().equals(next.unit()) && (getCurrent().isBefore() == next.isBefore())){
retInfo = next;
}
}
return retInfo;
}
public void addFlowInfo(Object fi){
if (getFlowInfoList() == null){
setFlowInfoList(new ArrayList());
}
getFlowInfoList().add(fi);
setCurrent((FlowInfo)fi);
}
public boolean inMiddle(){
if (getFlowInfoList() == null) return false;
if (getFlowInfoList().indexOf(getCurrent()) == getFlowInfoList().size()-1) return false;
return true;
}
public boolean canGoBack(){
if (getFlowInfoList() == null) return false;
if (getFlowInfoList().size() == 0) return false;
if (getCurrent().equals(getFlowInfoList().get(0))) return false;
return true;
}
public void stepForward(){
int index = getFlowInfoList().indexOf(getCurrent());
FlowInfo next = (FlowInfo)getFlowInfoList().get(index+1);
getController().setEvent(new InteractionEvent(IInteractionConstants.REPLACE, next));
getController().handleEvent();
setCurrent(next);
}
public void stepForwardAuto(){
int index = getFlowInfoList().indexOf(getCurrent());
for (int i = index + 1; i < getFlowInfoList().size(); i++){
FlowInfo next = (FlowInfo)getFlowInfoList().get(i);
getController().setEvent(new InteractionEvent(IInteractionConstants.REPLACE, next));
getController().handleEvent();
setCurrent(next);
}
}
/**
* @return
*/
public FlowInfo getCurrent() {
return current;
}
/**
* @return
*/
public List getFlowInfoList() {
return flowInfoList;
}
/**
* @return
*/
public int getRepeat() {
return repeat;
}
/**
* @return
*/
public int getTotal() {
return total;
}
/**
* @param info
*/
public void setCurrent(FlowInfo info) {
current = info;
}
/**
* @param list
*/
public void setFlowInfoList(List list) {
flowInfoList = list;
}
/**
* @param i
*/
public void setRepeat(int i) {
repeat = i;
}
/**
* @param i
*/
public void setTotal(int i) {
total = i;
}
/**
* @return
*/
public InteractionController getController() {
return controller;
}
/**
* @param controller
*/
public void setController(InteractionController controller) {
this.controller = controller;
}
}
| 4,797
| 22.635468
| 96
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/interaction/InteractionBackStepper.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.interaction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import ca.mcgill.sable.soot.*;
public class InteractionBackStepper implements IWorkbenchWindowActionDelegate {
public InteractionBackStepper() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public synchronized void run(IAction action) {
SootPlugin.getDefault().getDataKeeper().stepBack();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
}
| 1,929
| 31.166667
| 128
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/interaction/InteractionContinuer.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.interaction;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import soot.toolkits.graph.interaction.*;
import ca.mcgill.sable.soot.*;
public class InteractionContinuer implements IWorkbenchWindowActionDelegate {
public InteractionContinuer() {
super();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
*/
public void dispose() {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
*/
public void init(IWorkbenchWindow window) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public synchronized void run(IAction action) {
if (SootPlugin.getDefault().getDataKeeper().inMiddle()){
SootPlugin.getDefault().getDataKeeper().stepForward();
}
else {
InteractionHandler.v().setInteractionCon();
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged(IAction action, ISelection selection) {
}
}
| 2,094
| 30.742424
| 128
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/interaction/InteractionController.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.interaction;
import soot.AbstractTrap;
import soot.toolkits.graph.interaction.*;
import java.util.*;
import org.eclipse.ui.*;
import ca.mcgill.sable.soot.launching.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.jface.dialogs.*;
import org.eclipse.swt.*;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.callgraph.*;
import ca.mcgill.sable.soot.cfg.*;
import soot.jimple.toolkits.annotation.callgraph.*;
import soot.*;
public class InteractionController implements IInteractionController, IInteractionListener {
private ArrayList listeners;
private Thread sootThread;
private boolean available;
private InteractionEvent event;
private Display display;
private SootRunner parent;
private soot.toolkits.graph.DirectedGraph currentGraph;
private ModelCreator mc;
private CallGraphGenerator generator;
public InteractionController() {
}
public void addListener(IInteractionListener listener){
if (listeners == null){
listeners = new ArrayList();
}
listeners.add(listener);
}
public void removeListener(IInteractionListener listener){
if (listeners == null) return;
if (listeners.contains(listener)) {
listeners.remove(listener);
}
}
public void handleEvent(){
if (getEvent().type() == IInteractionConstants.NEW_ANALYSIS){
handleNewAnalysisEvent(event.info());
}
else if (getEvent().type() == IInteractionConstants.NEW_CFG){
handleCfgEvent(getEvent().info());
// process and update graph
}
else if (getEvent().type() == IInteractionConstants.NEW_BEFORE_ANALYSIS_INFO){
handleBeforeFlowEvent(getEvent().info());
// process and update graph ui
}
else if (getEvent().type() == IInteractionConstants.NEW_AFTER_ANALYSIS_INFO){
handleAfterFlowEvent(getEvent().info());
// process and update graph ui
}
else if (getEvent().type() == IInteractionConstants.NEW_BEFORE_ANALYSIS_INFO_AUTO){
handleBeforeFlowEventAuto(getEvent().info());
// process and update graph ui
}
else if (getEvent().type() == IInteractionConstants.NEW_AFTER_ANALYSIS_INFO_AUTO){
handleAfterFlowEventAuto(getEvent().info());
// process and update graph ui
}
else if (getEvent().type() == IInteractionConstants.DONE){
// remove controller and listener from soot
waitForContinue();
}
else if (getEvent().type() == IInteractionConstants.STOP_AT_NODE){
handleStopAtNodeEvent(getEvent().info());
}
else if (getEvent().type() == IInteractionConstants.CLEARTO){
handleClearEvent(getEvent().info());
}
else if (getEvent().type() == IInteractionConstants.REPLACE){
handleReplaceEvent(getEvent().info());
}
else if (getEvent().type() == IInteractionConstants.CALL_GRAPH_START){
handleCallGraphStartEvent(getEvent().info());
}
else if (getEvent().type() == IInteractionConstants.CALL_GRAPH_NEXT_METHOD){
handleCallGraphNextMethodEvent(getEvent().info());
}
else if (getEvent().type() == IInteractionConstants.CALL_GRAPH_PART){
handleCallGraphPartEvent(getEvent().info());
}
}
private Shell getShell(){
IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
final Shell [] shell = new Shell [1];
getDisplay().syncExec(new Runnable(){
public void run(){
shell[0] = getDisplay().getDefault().getActiveShell();
}
});
return shell[0];
}
private void handleNewAnalysisEvent(Object info){
SootPlugin.getDefault().setDataKeeper(new DataKeeper(this));
InteractionHandler.v().setInteractThisAnalysis(true);
}
private void handleCfgEvent(Object info){
soot.toolkits.graph.DirectedGraph cfg = (soot.toolkits.graph.DirectedGraph)info;
setCurrentGraph(cfg);
setMc(new ModelCreator());
getMc().setSootGraph(getCurrentGraph());
String editorName = "CFG Editor";
if (cfg instanceof soot.toolkits.graph.UnitGraph){
soot.Body body = ((soot.toolkits.graph.UnitGraph)cfg).getBody();
editorName = body.getMethod().getDeclaringClass().getName()+"."+body.getMethod().getName();
}
mc.setEditorName(editorName);
final ModelCreator mc = getMc();
getDisplay().syncExec(new Runnable(){
public void run(){
mc.displayModel();
}
});
InteractionHandler.v().autoCon(false);
waitForContinue();
}
private void waitForContinue(){
soot.toolkits.graph.interaction.InteractionHandler.v().waitForContinue();
}
private void handleBeforeFlowEvent(Object info){
handleBeforeEvent(info);
waitForContinue();
}
private void handleBeforeEvent(Object info){
FlowInfo fi = (FlowInfo)info;
SootPlugin.getDefault().getDataKeeper().addFlowInfo(info);
Iterator it = getCurrentGraph().iterator();
final Shell myShell = getShell();
final FlowInfo flowBefore = fi;
final ModelCreator mc = getMc();
getDisplay().syncExec(new Runnable() {
public void run(){
mc.updateNode(flowBefore);
};
});
}
private void handleBeforeFlowEventAuto(Object info){
handleBeforeEvent(info);
}
private void handleAfterFlowEvent(Object fi){
handleAfterEvent(fi);
waitForContinue();
}
private void handleAfterEvent(Object fi){
final Shell myShell = getShell();
SootPlugin.getDefault().getDataKeeper().addFlowInfo(fi);
final FlowInfo flowAfter = (FlowInfo)fi;
final ModelCreator mc = getMc();
getDisplay().syncExec(new Runnable() {
public void run(){
mc.updateNode(flowAfter);
};
});
}
private void handleAfterFlowEventAuto(Object fi){
handleAfterEvent(fi);
}
private void handleStopAtNodeEvent(Object info){
// highlight box being waited on
InteractionHandler.v().autoCon(false);
final soot.Unit stopUnit = (soot.Unit)info;
final ModelCreator mc = getMc();
getDisplay().syncExec(new Runnable() {
public void run(){
mc.highlightNode(stopUnit);
};
});
// then wait
waitForContinue();
}
private void handleClearEvent(Object info){
final FlowInfo fi = (FlowInfo)info;
final ModelCreator mc = getMc();
getDisplay().syncExec(new Runnable() {
public void run(){
mc.updateNode(fi);
};
});
}
private void handleReplaceEvent(Object info){
final FlowInfo fi = (FlowInfo)info;
final ModelCreator mc = getMc();
getDisplay().syncExec(new Runnable() {
public void run(){
mc.updateNode(fi);
};
});
}
private void handleCallGraphStartEvent(Object info){
if (getGenerator() == null){
setGenerator(new CallGraphGenerator());
}
getGenerator().setInfo((CallGraphInfo)info);
getGenerator().setController(this);
final CallGraphGenerator cgg = getGenerator();
getDisplay().syncExec(new Runnable(){
public void run(){
cgg.run();
}
});
waitForContinue();
}
private void handleCallGraphNextMethodEvent(Object info){
SootMethod meth = (SootMethod)info;
InteractionHandler.v().setNextMethod(meth);
InteractionHandler.v().setInteractionCon();
}
private void handleCallGraphPartEvent(Object info){
final CallGraphGenerator cgg = getGenerator();
final Object cgInfo = info;
getDisplay().asyncExec(new Runnable(){
public void run(){
cgg.addToGraph(cgInfo);
}
});
waitForContinue();
}
/**
* @return
*/
public Thread getSootThread() {
return sootThread;
}
/**
* @param thread
*/
public void setSootThread(Thread thread) {
sootThread = thread;
}
/**
* @return
*/
public boolean isAvailable() {
return available;
}
/**
* @return
*/
public InteractionEvent getEvent() {
return event;
}
/**
* @param event
*/
public void setEvent(InteractionEvent event) {
this.event = event;
}
/**
* @return
*/
public Display getDisplay() {
return display;
}
/**
* @param display
*/
public void setDisplay(Display display) {
this.display = display;
}
/**
* @return
*/
public SootRunner getParent() {
return parent;
}
/**
* @param runner
*/
public void setParent(SootRunner runner) {
parent = runner;
}
/**
* @return
*/
public soot.toolkits.graph.DirectedGraph getCurrentGraph() {
return currentGraph;
}
/**
* @return
*/
public ArrayList getListeners() {
return listeners;
}
/**
* @param graph
*/
public void setCurrentGraph(soot.toolkits.graph.DirectedGraph graph) {
currentGraph = graph;
}
/**
* @param list
*/
public void setListeners(ArrayList list) {
listeners = list;
}
/**
* @return
*/
public ModelCreator getMc() {
return mc;
}
/**
* @param creator
*/
public void setMc(ModelCreator creator) {
mc = creator;
}
/**
* @return
*/
public CallGraphGenerator getGenerator() {
return generator;
}
/**
* @param generator
*/
public void setGenerator(CallGraphGenerator generator) {
this.generator = generator;
}
}
| 9,572
| 22.012019
| 94
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/DavaDecompileAppFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import org.eclipse.jface.action.IAction;
import java.util.*;
/**
* Launches Soot with --app --f dava on selected file
*/
public class DavaDecompileAppFileLauncher extends SootFileLauncher {
/**
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run(IAction action) {
super.run(action);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
setCmd();
runSootDirectly();
runFinish();
}
/**
* Method getCmd.
* @return String
*/
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
// I think we need these two options here for consistency
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
if (isExtraCmd()) {
getSootCommandList().addSingleOpt("--"+getExtraCmd());
}
if (isSrcPrec()) {
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, getSrcPrec());
}
getSootCommandList().addSingleOpt("--"+LaunchCommands.APP);
getSootCommandList().addSingleOpt("--"+LaunchCommands.DAVA);
Iterator it = getToProcessList().iterator();
while(it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 2,327
| 29.631579
| 90
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/DavaDecompileAppFromJavaFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import org.eclipse.jface.action.IAction;
import java.util.*;
/**
* Launches Soot with --app --f dava on selected file
*/
public class DavaDecompileAppFromJavaFileLauncher extends SootFileLauncher {
/**
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run(IAction action) {
super.run(action);
super.setIsSrcPrec(true);
super.setSrcPrec(LaunchCommands.JAVA_IN);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
setCmd();
runSootDirectly();
runFinish();
}
/**
* Method getCmd.
* @return String
*/
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
// I think we need these two options here for consistency
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
if (isExtraCmd()) {
getSootCommandList().addSingleOpt("--"+getExtraCmd());
}
if (isSrcPrec()) {
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, getSrcPrec());
}
getSootCommandList().addSingleOpt("--"+LaunchCommands.APP);
getSootCommandList().addSingleOpt("--"+LaunchCommands.DAVA);
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 2,420
| 30.038462
| 90
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/DavaDecompileFolderLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f dava on all class files in selected folder
*/
public class DavaDecompileFolderLauncher extends SootFolderLauncher {
/**
* @see org.eclipse.ui.IActionDelegate#run(IAction)
*/
public void run(IAction action) {
super.run(action);
setCmd();
runSootDirectly();
runFinish();
}
/**
* Method getCmd.
* @return String
*/
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getProcessPath()+getSootClasspath().getSeparator()+getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
commands.add("--"+LaunchCommands.PROCESS_PATH);
commands.add(getProcessPath());
getSootCommandList().addSingleOpt("--"+LaunchCommands.DAVA);
getSootCommandList().addSingleOpt(commands);
}
}
| 1,955
| 29.5625
| 88
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/DavaDecompileJavaProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f dava on all classes in output dir of project
*/
public class DavaDecompileJavaProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
Iterator it = getJavaProcessPath().iterator();
String cp = (String)it.next();
while (it.hasNext()){
cp = cp + getSootClasspath().getSeparator() + (String)it.next();
}
cp = cp + getSootClasspath().getSeparator()+ getClasspathAppend();
commands.add(cp);
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, "java");
Iterator it2 = getJavaProcessPath().iterator();
while (it2.hasNext()){
commands.add("--"+LaunchCommands.PROCESS_PATH);
commands.add((String)it2.next());
}
getSootCommandList().addSingleOpt("--"+LaunchCommands.DAVA);
getSootCommandList().addSingleOpt(commands);
}
}
| 2,225
| 29.493151
| 75
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/DavaDecompileProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f dava on all classes in output dir of project
*/
public class DavaDecompileProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getProcess_path()+getSootClasspath().getSeparator()+getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
commands.add("--"+LaunchCommands.PROCESS_PATH);
commands.add(getProcess_path());
getSootCommandList().addSingleOpt("--"+LaunchCommands.DAVA);
getSootCommandList().addSingleOpt(commands);
}
}
| 1,856
| 29.442623
| 89
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/DavaHandler.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import ca.mcgill.sable.soot.*;
import org.eclipse.jface.dialogs.*;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.jdt.core.*;
/**
* After Soot runs handles any new dava files by either
* copying them to an already existing "Dava Project" or
* creating a "Dava Project" and copying the files there
*
* Currently disabled
*/
public class DavaHandler {
private IFolder sootOutputFolder;
private boolean davaBefore;
private ArrayList beforeList;
private String davaProjName;
private IJavaProject davaProj;
private IFolder srcFolder;
public DavaHandler(){
setDavaProjName(Messages.getString("DavaHandler.Dava_Project"));
}
public boolean isDava(){
if (!getSootOutputFolder().getFolder(Messages.getString("DavaHandler.dava")).exists()) return false;
return true;
}
// creates list of Dava files before Soot runs
public void handleBefore() {
if (isDava()){
createBeforeList();
}
}
private void createBeforeList(){
try {
IResource [] elems = getSootOutputFolder().getFolder(Messages.getString("DavaHandler.dava")).getFolder(Messages.getString("DavaHandler.src")).members();
for (int i = 0; i < elems.length; i++) {
if (getBeforeList() == null){
setBeforeList(new ArrayList());
}
getBeforeList().add(elems[i]);
}
}
catch(CoreException e){
}
}
// handles two things:
// 1. if new dava files exist
// 2. if already existing dava files have changed
// if one of those two things is true then:
// if no dava project exists asks to create one else
// asks to copy files
public void handleAfter() {
ArrayList newMembers = new ArrayList();
IPath jreLibPath = null;
try {
IResource [] elems = getSootOutputFolder().getFolder(Messages.getString("DavaHandler.dava")).getFolder(Messages.getString("DavaHandler.src")).members();
for (int i = 0; i < elems.length; i++) {
if (getBeforeList() == null){
newMembers.add(elems[i]);
if (elems[i] instanceof IFile){
SootPlugin.getDefault().getManager().setToFalseRemove((IFile)elems[i]);
}
}
else if (getBeforeList().contains(elems[i])) {
if (elems[i] instanceof IFile){
if (SootPlugin.getDefault().getManager().isFileMarkersRemove((IFile)elems[i])){
newMembers.add(elems[i]);
// this sets changed bit to 0 - so file doesn't stay on list indefinitely
SootPlugin.getDefault().getManager().setToFalseRemove((IFile)elems[i]);
}
}
}
else if (!getBeforeList().contains(elems[i])){
if (SootPlugin.getDefault().getManager().getChangedResources() == null){
}
else if (SootPlugin.getDefault().getManager().getChangedResources().containsKey(elems[i])){
newMembers.add(elems[i]);
// this sets changed bit to 0 - so file doesn't stay on list indefinitely
if (elems[i] instanceof IFile){
SootPlugin.getDefault().getManager().setToFalseRemove((IFile)elems[i]);
}
}
}
}
// testing class lib copying
IProject proj = getSootOutputFolder().getProject();
IResource [] elements = proj.members();
IJavaProject jProj = JavaCore.create(proj);
IClasspathEntry [] paths = jProj.getRawClasspath();
for (int i = 0; i < paths.length; i++){
switch(paths[i].getEntryKind()){
case IClasspathEntry.CPE_CONTAINER:{
jreLibPath = paths[i].getPath();
break;
}
}
}
}
catch(CoreException e){
}
if (!newMembers.isEmpty()){
// if is special dava project add src files there
if (davaProjectExists()){
setDavaProj(JavaCore.create(SootPlugin.getWorkspace().getRoot().getProject(getDavaProjName())));
if (getDavaProj().isOpen()){
if (shouldCopyFiles()){
copyFiles(newMembers);
}
}
else {
openProject();
if (shouldCopyFiles()){
copyFiles(newMembers);
}
}
}
// if not special dava project ask user to create and add files there
else {
boolean result = createSpecialDavaProject(jreLibPath);
if (result){
copyFiles(newMembers);
}
}
}
}
private boolean createSpecialDavaProject(IPath jreLibPath){
IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
MessageDialog create = new MessageDialog(window.getShell(), Messages.getString("DavaHandler.Soot_Question"), null, Messages.getString("DavaHandler.Would_you_like_to_create_a_new_Dava_Project_with_generated_Dava_src_files"), 0, new String [] {Messages.getString("DavaHandler.OK"), Messages.getString("DavaHandler.Cancel")}, 0);
create.open();
if (create.getReturnCode() == Dialog.OK){
// create proj
IProject proj = SootPlugin.getWorkspace().getRoot().getProject(getDavaProjName());
if (!proj.exists()){
try {
proj.create(null);
proj.open(null);
IProjectDescription pd = proj.getDescription();
String [] natures = new String [] {Messages.getString("org.eclipse.jdt.core.javanature")};
pd.setNatureIds(natures);
proj.setDescription(pd, null);
setDavaProj(JavaCore.create(proj));
IFolder folder = proj.getFolder(Messages.getString("DavaHandler.src")); //$NON-NLS-1$
if (!folder.exists()){
folder.create(false, true, null);
}
setSrcFolder(folder);
IFolder out = proj.getFolder(Messages.getString("DavaHandler.bin")); //$NON-NLS-1$
if (!folder.exists()){
folder.create(false, true, null);
}
getDavaProj().setOutputLocation(out.getFullPath(), null);
IClasspathEntry [] entries = new IClasspathEntry [2];
entries[0] = JavaCore.newSourceEntry(folder.getFullPath());
if (jreLibPath != null){
entries[1] = JavaCore.newContainerEntry(jreLibPath);
}
getDavaProj().setRawClasspath(entries, null);
return true;
}
catch (CoreException e) {
e.printStackTrace();
return false;
}
}
}
return false;
}
private boolean shouldCopyFiles() {
IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
MessageDialog copy = new MessageDialog(window.getShell(), Messages.getString("DavaHandler.Soot_Question"), null, Messages.getString("DavaHandler.Would_you_like_to_copy_Dava_src_files_to_the_Dava_Project"), 0, new String [] {Messages.getString("DavaHandler.OK"), Messages.getString("DavaHandler.Cancel")}, 0); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
copy.open();
if (copy.getReturnCode() == Dialog.OK) return true;
return false;
}
private void copyFiles(ArrayList newFiles){
// copy new files
Iterator it = newFiles.iterator();
IPath srcPath = getDavaProj().getProject().getFolder(Messages.getString("DavaHandler.src")).getFullPath();
while (it.hasNext()){
try {
IResource next = (IResource)it.next();
IPath copyTo = srcPath.append(System.getProperty("file.separator")+next.getName()); //$NON-NLS-1$
if (getDavaProj().getProject().getFolder(Messages.getString("DavaHandler.src")).getFile(next.getName()).exists()) { //$NON-NLS-1$
getDavaProj().getProject().getFolder(Messages.getString("DavaHandler.src")).getFile(next.getName()).delete(false, null);
}
next.copy(copyTo, false, null);
}
catch (CoreException e) {
e.printStackTrace();
}
}
}
private void openProject(){
try {
getDavaProj().open(null);
}
catch (CoreException e) {
e.printStackTrace();
}
}
private boolean davaProjectExists() {
if (SootPlugin.getWorkspace().getRoot().getProject(getDavaProjName()).exists()) return true;
return false;
}
public void updateDavaProject(){
}
/**
* @return
*/
public IFolder getSootOutputFolder() {
return sootOutputFolder;
}
/**
* @param folder
*/
public void setSootOutputFolder(IFolder folder) {
sootOutputFolder = folder;
}
/**
* @return
*/
public boolean isDavaBefore() {
return davaBefore;
}
/**
* @param b
*/
public void setDavaBefore(boolean b) {
davaBefore = b;
}
/**
* @return
*/
public ArrayList getBeforeList() {
return beforeList;
}
/**
* @param list
*/
public void setBeforeList(ArrayList list) {
beforeList = list;
}
/**
* @return
*/
public String getDavaProjName() {
return davaProjName;
}
/**
* @param string
*/
public void setDavaProjName(String string) {
davaProjName = string;
}
/**
* @return
*/
public IJavaProject getDavaProj() {
return davaProj;
}
/**
* @param project
*/
public void setDavaProj(IJavaProject project) {
davaProj = project;
}
/**
* @return
*/
public IFolder getSrcFolder() {
return srcFolder;
}
/**
* @param folder
*/
public void setSrcFolder(IFolder folder) {
srcFolder = folder;
}
}
| 9,744
| 26.450704
| 366
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/ISootOutputEventConstants.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
/**
* Constants for Soot Output View events
*/
public interface ISootOutputEventConstants {
public static final int SOOT_CLEAR_EVENT = 0;
public static final int SOOT_NEW_TEXT_EVENT = 1;
}
| 1,061
| 34.4
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/ISootOutputEventListener.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
/**
* Listener interface for handling a Soot Output Event
*/
public interface ISootOutputEventListener {
public void handleSootOutputEvent(SootOutputEvent event);
}
| 1,036
| 34.758621
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/LaunchCommands.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
/**
* A bunch of Soot commands (used in the plugin). It is possible to break
* these by changing soot_options.xml but at least only have to change
* here.
*/
public class LaunchCommands {
private static final String RESOURCE_BUNDLE= "ca.mcgill.sable.soot.launching.launchingCmds";//$NON-NLS-1$
private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
public static final String SOOT_CLASSPATH = "cp";
public static final String XML_ATTRIBUTES = "xml-attributes";
public static final String KEEP_LINE_NUMBER = "keep-line-number";
public static final String OUTPUT = "f ";
public static final String JIMPLE_OUT = "J";
public static final String PROCESS_PATH = "process-dir";
public static final String DAVA = "f dava";
public static final String APP = "app ";
public static final String OUTPUT_DIR = "d";
public static final String INTRA_PROC = "O --p jop.cse disabled:false --f J ";
public static final String EVERYTHING = "W --O --p wjop.si insert-null-checks:false --p jop.cse disabled:false --app --f dava ";
public static final String SRC_PREC = "src-prec";
public static final String JIMPLE_IN = "J";
public static final String CLASS_IN = "class ";
public static final String GRIMP_OUT = "g";
public static final String INLINING = "--W --app --f grimp ";
public static final String STATIC = "--W --app --p wjop.smb diasabled:false --p wjop.si disabled:true --f grimp ";
public static final String JAVA_IN = "java";
private LaunchCommands() {
// prevent instantiation of class
}
/**
* Returns the resource object with the given key in
* the resource bundle. If there isn't any value under
* the given key, the key is returned, surrounded by '!'s.
*
* @param key the resource name
* @return the string
*/
public static String getString(String key) {
try {
return fgResourceBundle.getString(key);
} catch (MissingResourceException e) {
return "";
}
}
}
| 2,901
| 36.688312
| 129
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/Messages.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* Handles externalized strings.
*/
package ca.mcgill.sable.soot.launching;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "ca.mcgill.sable.soot.launching.launching"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(BUNDLE_NAME);
/**
*
*/
private Messages() {
}
/**
* @param key
* @return
*/
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}
| 1,459
| 27.076923
| 100
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SavedConfigManager.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
import org.eclipse.jface.dialogs.IDialogSettings;
import ca.mcgill.sable.soot.*;
/**
* Handles saving of Soot configurations, adding, updating and
* deleting
*/
public class SavedConfigManager {
/**
* Constructor for SavedConfigManager.
*/
public SavedConfigManager() {
super();
}
public void handleDeletes() {
if (getDeleteList() != null) {
Iterator it = getDeleteList().iterator();
while (it.hasNext()) {
String name = (String)it.next();
remove(name);
}
}
}
private void remove(String name) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
int count = 0;
try {
count = settings.getInt("config_count");
}
catch (NumberFormatException e){
}
String [] pointers = new String [count];
for (int i = 1; i <= count; i++) {
pointers[i-1] = settings.get("soot_run_config_"+i);
}
int i = 1;
int j = 0;
while (j < count) {
if (!pointers[j].equals(name)) {
settings.put("soot_run_config_"+i, pointers[j]);
i++;
}
j++;
}
settings.put("soot_run_config_"+count, (String)null);
count--;
if (count < 0) {
count = 0;
}
settings.put("config_count", count);
settings.put(name, (String)null);
}
public void handleEdits() {
if (getEditMap() != null) {
Iterator it = getEditMap().keySet().iterator();
while (it.hasNext()) {
String name = (String)it.next();
if (alreadyInList(name)) {
update(name, (ArrayList)getEditMap().get(name));
}
else {
add(name, (ArrayList)getEditMap().get(name));
}
}
}
}
private boolean alreadyInList(String name) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
int count = 0;
try {
count = settings.getInt("config_count");
}
catch (NumberFormatException e){
}
for (int i = 1; i <= count; i++){
if (settings.get("soot_run_config_"+i).equals(name)){
return true;
}
}
return false;
}
// TODO use this instead of with String, String
private void update(String name, ArrayList val){
String [] temp = new String [val.size()];
val.toArray(temp);
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
settings.put(name, temp);
}
// TODO use this instead of with String, String
private void update(String name, String [] val){
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
settings.put(name, val);
}
// TODO stop using this
private void update(String name, String val) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
if (val != null) {
settings.put(name, val);
}
else {
settings.put(name, "default");
}
}
// TODO use this instead of String, String
private void add(String name, ArrayList val){
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
int count = 0;
try {
count = settings.getInt("config_count");
}
catch(NumberFormatException e) {
}
count++;
settings.put("config_count", count);
settings.put("soot_run_config_"+count, name);
update(name, val);
}
// TODO stop using this
private void add(String name, String val) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
int count = 0;
try {
count = settings.getInt("config_count");
}
catch(NumberFormatException e) {
}
count++;
settings.put("config_count", count);
settings.put("soot_run_config_"+count, name);
update(name, val);
}
private HashMap editMap;
private ArrayList deleteList;
/**
* Returns the deleteList.
* @return ArrayList
*/
public ArrayList getDeleteList() {
return deleteList;
}
/**
* Returns the editMap.
* @return HashMap
*/
public HashMap getEditMap() {
return editMap;
}
/**
* Sets the deleteList.
* @param deleteList The deleteList to set
*/
public void setDeleteList(ArrayList deleteList) {
this.deleteList = deleteList;
}
/**
* Sets the editMap.
* @param editMap The editMap to set
*/
public void setEditMap(HashMap editMap) {
this.editMap = editMap;
}
}
| 4,951
| 22.469194
| 73
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootClasspath.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.jdt.core.IClasspathEntry;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaModelException;
import ca.mcgill.sable.soot.SootPlugin;
/**
* Determines the soot-classpath for running Soot
*/
public class SootClasspath {
private String separator = File.pathSeparator;
protected URL[] urls = new URL[0];
public void initialize(IJavaProject javaProject) {
this.urls = projectClassPath(javaProject);
}
public static URL[] projectClassPath(IJavaProject javaProject) {
IWorkspace workspace = SootPlugin.getWorkspace();
IClasspathEntry[] cp;
try {
cp = javaProject.getResolvedClasspath(true);
List<URL> urls = new ArrayList<URL>();
String uriString = workspace.getRoot().getFile(
javaProject.getOutputLocation()).getLocationURI().toString()
+ "/";
urls.add(new URI(uriString).toURL());
for (IClasspathEntry entry : cp) {
File file = entry.getPath().toFile();
URL url = file.toURI().toURL();
urls.add(url);
}
URL[] array = new URL[urls.size()];
urls.toArray(array);
return array;
} catch (JavaModelException e) {
e.printStackTrace();
return new URL[0];
} catch (MalformedURLException e) {
e.printStackTrace();
return new URL[0];
} catch (URISyntaxException e) {
e.printStackTrace();
return new URL[0];
}
}
public String getSootClasspath() {
return urlsToString(urls);
}
public static String urlsToString(URL[] urls) {
StringBuffer cp = new StringBuffer();
for (URL url : urls) {
cp.append(url.getPath());
cp.append(File.pathSeparator);
}
return cp.toString();
}
/**
* Returns the separator.
* @return String
*/
public String getSeparator() {
return separator;
}
}
| 2,839
| 26.307692
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootCommandList.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
/**
* Handles command list by making Strings separated by spaces into
* list
*/
public class SootCommandList {
private ArrayList list;
private static final String SPACE = " ";
/**
* Constructor for SootCommandList.
*/
public SootCommandList() {
setList(new ArrayList());
}
/**
* @param key
*/
public void addSingleOpt(ArrayList key){
getList().addAll(key);
}
/**
* Method addSingleOpt.
* @param key
*/
public void addSingleOpt(String key) {
StringTokenizer st = new StringTokenizer(key);
while (st.hasMoreTokens()) {
String token = st.nextToken();
getList().add(token);
}
}
/**
* Method addDoubleOpt.
* @param key
* @param val
*/
public void addDoubleOpt(String key, String val) {
addSingleOpt(key);
addSingleOpt(val);
}
public void addDashes(){
ArrayList withDashes = new ArrayList();
Iterator it = getList().iterator();
while (it.hasNext()) {
String temp = (String)it.next();
temp = "-- "+temp;
withDashes.add(temp);
}
setList(withDashes);
}
public void printList(){
Iterator it = list.iterator();
while (it.hasNext()){
System.out.println(it.next());
}
}
/**
* Returns the list.
* @return ArrayList
*/
public ArrayList getList() {
return list;
}
/**
* Sets the list.
* @param list The list to set
*/
public void setList(ArrayList list) {
this.list = list;
}
}
| 2,291
| 20.622642
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootConfigFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.jface.action.IAction;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.SootConfigManagerDialog;
import org.eclipse.jface.dialogs.*;
/**
* Launches a saved Soot configuration on the selected file
*/
public class SootConfigFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
SootConfigManagerDialog manager = new SootConfigManagerDialog(window.getShell());
manager.setEclipseDefList(setEclipseDefs());
manager.setLauncher(this);
manager.open();
}
public void launch(String name, String mainClass) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
setSootCommandList(new SootCommandList());
SootSavedConfiguration ssc = new SootSavedConfiguration(name, settings.getArray(name));
ssc.setEclipseDefs(setEclipseDefs());
getSootCommandList().addSingleOpt(ssc.toRunArray());
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
getSootCommandList().addSingleOpt((String)it.next());
}
getSootCommandList().printList();
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
}
private HashMap setEclipseDefs() {
HashMap defs = new HashMap();
defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
defs.put(LaunchCommands.SOOT_CLASSPATH, getClasspathAppend());
if (isSrcPrec()) {
defs.put(LaunchCommands.SRC_PREC, getSrcPrec());
}
defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
return defs;
}
}
| 2,757
| 26.58
| 89
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootConfigFromJavaFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.jface.action.IAction;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.SootConfigManagerDialog;
import org.eclipse.jface.dialogs.*;
/**
* Launches a saved Soot configuration on the selected file
*/
public class SootConfigFromJavaFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.setIsSrcPrec(true);
super.setSrcPrec(LaunchCommands.JAVA_IN);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
SootConfigManagerDialog manager = new SootConfigManagerDialog(window.getShell());
manager.setEclipseDefList(setEclipseDefs());
manager.setLauncher(this);
manager.open();
}
public void launch(String name, String mainClass) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
setSootCommandList(new SootCommandList());
SootSavedConfiguration ssc = new SootSavedConfiguration(name, settings.getArray(name));
ssc.setEclipseDefs(setEclipseDefs());
getSootCommandList().addSingleOpt(ssc.toRunArray());
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
getSootCommandList().addSingleOpt((String)it.next());
}
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
}
private HashMap setEclipseDefs() {
HashMap defs = new HashMap();
defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
defs.put(LaunchCommands.SOOT_CLASSPATH, getClasspathAppend());
if (isSrcPrec()) {
defs.put(LaunchCommands.SRC_PREC, getSrcPrec());
}
defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
return defs;
}
}
| 2,805
| 27.343434
| 89
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootConfigJavaProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.HashMap;
import java.util.Iterator;
import org.eclipse.jface.action.IAction;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.SootConfigManagerDialog;
import org.eclipse.jface.dialogs.*;
/**
* Launches a saved Soot configuration on the all the
* class files in the output dir of the selected project
*/
public class SootConfigJavaProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
SootConfigManagerDialog manager = new SootConfigManagerDialog(getWindow().getShell());
manager.setEclipseDefList(setEclipseDefs());
manager.setLauncher(this);
manager.open();
}
public void launch(String name, String mainClass) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
setSootCommandList(new SootCommandList());
SootSavedConfiguration ssc = new SootSavedConfiguration(name, settings.getArray(name));
ssc.setEclipseDefs(setRunEclipseDefs());
getSootCommandList().addSingleOpt(ssc.toRunArray());
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
}
private HashMap setEclipseDefs() {
HashMap defs = new HashMap();
defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
Iterator it = getJavaProcessPath().iterator();
String cp = (String)it.next();
while (it.hasNext()){
cp = cp + getSootClasspath().getSeparator() + (String)it.next();
}
cp = cp + getSootClasspath().getSeparator() + getClasspathAppend();
defs.put(LaunchCommands.SOOT_CLASSPATH, cp);
defs.put(LaunchCommands.PROCESS_PATH, getJavaProcessPath());
defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
defs.put(LaunchCommands.SRC_PREC, "java");
return defs;
}
private HashMap setRunEclipseDefs() {
HashMap defs = new HashMap();
defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
Iterator it = getJavaProcessPath().iterator();
String cp = (String)it.next();
while (it.hasNext()){
cp = cp + getSootClasspath().getSeparator() + (String)it.next();
}
cp = cp + getSootClasspath().getSeparator() + getClasspathAppend();
defs.put(LaunchCommands.SOOT_CLASSPATH, cp);
Iterator it2 = getJavaProcessPath().iterator();
String pPath = "";
while (it2.hasNext()){
String next = (String)it2.next();
if (pPath.equals("")){
pPath = next;
}
else {
pPath = pPath + "\r\n" + next;
}
}
defs.put(LaunchCommands.PROCESS_PATH, pPath);
defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
defs.put(LaunchCommands.SRC_PREC, "java");
return defs;
}
}
| 3,658
| 28.991803
| 89
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootConfigNameInputValidator.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import org.eclipse.jface.dialogs.IInputValidator;
/**
* Manages disallowing of duplicate names for saving Soot configurations
*/
public class SootConfigNameInputValidator implements IInputValidator {
private ArrayList alreadyUsed;
/**
* Constructor for SootConfigNameInputValidator.
*/
public SootConfigNameInputValidator() {
super();
}
/**
* @see org.eclipse.jface.dialogs.IInputValidator#isValid(String)
*/
public String isValid(String newText) {
if (newText.equals("")){
return "You must enter a name!";
}
else if (newText == null) {
return "Must not be null!";
}
else if (getAlreadyUsed().contains(newText)) {
return "A configuration with that name already exists!";
}
return null;
}
/**
* Returns the alreadyUsed.
* @return ArrayList
*/
public ArrayList getAlreadyUsed() {
return alreadyUsed;
}
/**
* Sets the alreadyUsed.
* @param alreadyUsed The alreadyUsed to set
*/
public void setAlreadyUsed(ArrayList alreadyUsed) {
this.alreadyUsed = alreadyUsed;
}
}
| 1,931
| 25.465753
| 72
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootConfigProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.HashMap;
import org.eclipse.jface.action.IAction;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.SootConfigManagerDialog;
import org.eclipse.jface.dialogs.*;
/**
* Launches a saved Soot configuration on the all the
* class files in the output dir of the selected project
*/
public class SootConfigProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
SootConfigManagerDialog manager = new SootConfigManagerDialog(getWindow().getShell());
manager.setEclipseDefList(setEclipseDefs());
manager.setLauncher(this);
manager.open();
}
public void launch(String name, String mainClass) {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
setSootCommandList(new SootCommandList());
SootSavedConfiguration ssc = new SootSavedConfiguration(name, settings.getArray(name));
ssc.setEclipseDefs(setEclipseDefs());
getSootCommandList().addSingleOpt(ssc.toRunArray());
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
}
private HashMap setEclipseDefs() {
HashMap defs = new HashMap();
defs.put(LaunchCommands.OUTPUT_DIR, getOutputLocation());
defs.put(LaunchCommands.SOOT_CLASSPATH, getProcess_path()+getSootClasspath().getSeparator()+getClasspathAppend());
defs.put(LaunchCommands.PROCESS_PATH, getProcess_path());
defs.put(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
defs.put(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
return defs;
}
}
| 2,488
| 28.987952
| 116
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootConfiguration.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
public class SootConfiguration {
private Vector children;
private String label;
private SootConfiguration parent;
/**
* Constructor for SootConfiguration.
*/
public SootConfiguration(HashMap aliasValPairs, String name) {
super();
setAliasValPairs(aliasValPairs);
setName(name);
}
public SootConfiguration(String label) {
setLabel(label);
}
private HashMap aliasValPairs;
private String name;
public void addChild(SootConfiguration t) {
if (getChildren() == null) {
setChildren(new Vector());
}
t.setParent(this);
getChildren().add(t);
}
public void removeChild(String name) {
Iterator it = getChildren().iterator();
SootConfiguration toRemove = null;
while (it.hasNext()) {
SootConfiguration temp = (SootConfiguration)it.next();
if (temp.getLabel().equals(name)) {
toRemove = temp;
}
}
if (toRemove != null) {
getChildren().remove(toRemove);
}
}
public void renameChild(String oldName, String newName){
Iterator it = getChildren().iterator();
while (it.hasNext()){
SootConfiguration temp = (SootConfiguration)it.next();
if (temp.getLabel().equals(oldName)){
temp.setLabel(newName);
}
}
}
/**
* Returns the aliasValPairs.
* @return HashMap
*/
public HashMap getAliasValPairs() {
return aliasValPairs;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Sets the aliasValPairs.
* @param aliasValPairs The aliasValPairs to set
*/
public void setAliasValPairs(HashMap aliasValPairs) {
this.aliasValPairs = aliasValPairs;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the children.
* @return Vector
*/
public Vector getChildren() {
return children;
}
/**
* Returns the label.
* @return String
*/
public String getLabel() {
return label;
}
/**
* Returns the parent.
* @return SootConfiguration
*/
public SootConfiguration getParent() {
return parent;
}
/**
* Sets the children.
* @param children The children to set
*/
public void setChildren(Vector children) {
this.children = children;
}
/**
* Sets the label.
* @param label The label to set
*/
public void setLabel(String label) {
this.label = label;
}
/**
* Sets the parent.
* @param parent The parent to set
*/
public void setParent(SootConfiguration parent) {
this.parent = parent;
}
}
| 3,365
| 20.0375
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootDefaultCommands.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import ca.mcgill.sable.soot.ui.PhaseOptionsDialog;
/**
* Sets Soot commands needed by Eclipse in Options Dialog
* (ex output directory)
*/
public class SootDefaultCommands {
private PhaseOptionsDialog dialog;
/**
* Constructor for SootDefaultCommands.
*/
public SootDefaultCommands(PhaseOptionsDialog dialog) {
setDialog(dialog);
}
public void setSootClassPath(String val) {
getDialog().addToEclipseDefList(LaunchCommands.SOOT_CLASSPATH, val);
}
public void setProcessPath(String val) {
ArrayList list = new ArrayList();
list.add(val);
getDialog().addToEclipseDefList(LaunchCommands.PROCESS_PATH, list);
}
public void setProcessPath(ArrayList list){
getDialog().addToEclipseDefList(LaunchCommands.PROCESS_PATH, list);
}
public void setOutputDir(String val) {
getDialog().addToEclipseDefList(LaunchCommands.OUTPUT_DIR, val);
}
public void setKeepLineNum() {
getDialog().addToEclipseDefList(LaunchCommands.KEEP_LINE_NUMBER, new Boolean(true));
}
public void setPrintTags() {
getDialog().addToEclipseDefList(LaunchCommands.XML_ATTRIBUTES, new Boolean(true));
}
public void setSrcPrec(String val) {
getDialog().addToEclipseDefList(LaunchCommands.SRC_PREC, val);
}
public void setSootMainClass(){
getDialog().addToEclipseDefList("sootMainClass", "soot.Main");
}
/**
* Returns the dialog.
* @return PhaseOptionsDialog
*/
public PhaseOptionsDialog getDialog() {
return dialog;
}
/**
* Sets the dialog.
* @param dialog The dialog to set
*/
public void setDialog(PhaseOptionsDialog dialog) {
this.dialog = dialog;
}
}
| 2,502
| 25.62766
| 86
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootDocument.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.io.PrintStream;
import org.eclipse.jface.text.*;
import org.eclipse.ui.*;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.*;
/**
* Document for SootOutputView
*/
public class SootDocument extends Document implements ISootOutputEventListener {
private SootOutputView viewer;
private int newStreamWriteEnd = 0;
private int oldStreamWriteEnd = 0;
private boolean viewShown = false;
protected PrintStream consoleStream;
public SootDocument() {
consoleStream = new PrintStream(SootPlugin.getDefault().getConsole().newMessageStream());
}
public void startUp() {
SootPlugin.getDefault().addSootOutputEventListener(this);
}
public void handleSootOutputEvent(SootOutputEvent event) {
if (!viewShown) {
showSootOutputView();
notifySootOutputView();
getViewer().getTextViewer().setDocument(this);
viewShown = true;
}
switch (event.getEventType()) {
case ISootOutputEventConstants.SOOT_CLEAR_EVENT:
clearText();
break;
case ISootOutputEventConstants.SOOT_NEW_TEXT_EVENT:
appendText(event.getTextToAppend());
break;
default:
break;
}
}
private void notifySootOutputView() {
IWorkbench workbench= PlatformUI.getWorkbench();
IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
for (int i = 0; i < windows.length; i++) {
IWorkbenchWindow iWorkbenchWindow = windows[i];
IWorkbenchPage[] pages= iWorkbenchWindow.getPages();
for (int j = 0; j < pages.length; j++) {
IWorkbenchPage iWorkbenchPage = pages[j];
IViewPart part= iWorkbenchPage.findView(ISootConstants.SOOT_OUTPUT_VIEW_ID);
if (part == null) {
IViewReference refs [] = iWorkbenchPage.getViewReferences();
}
if (part instanceof SootOutputView) {
setViewer((SootOutputView)part);
this.addDocumentListener(getViewer());
}
}
}
}
private void clearText() {
// set(new String());
// setNewStreamWriteEnd(0);
// setOldStreamWriteEnd(0);
// showSootOutputView();
SootPlugin.getDefault().getConsole().clearConsole();
}
private void appendText(final String text) {
update(new Runnable() {
public void run() {
// int appendedLength= text.length();
// setNewStreamWriteEnd(getOldStreamWriteEnd() + appendedLength);
// replace0(getOldStreamWriteEnd(), 0, text);
// setOldStreamWriteEnd(getNewStreamWriteEnd());
// getViewer().getTextViewer().setTopIndex(getNumberOfLines());
consoleStream.print(text);
SootPlugin.getDefault().showConsole();
}
});
}
protected void replace0(int pos, int replaceLength, String text) {
try {
super.replace(pos, replaceLength, text);
} catch (BadLocationException ble) {
}
}
private void showSootOutputView() {
IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
if (window != null) {
IWorkbenchPage page= window.getActivePage();
if (page != null) {
try {
IViewPart sootOutputViewer = page.findView("ca.mcgill.sable.soot.ui.sootoutputview.view");
if(sootOutputViewer == null) {
IWorkbenchPart activePart= page.getActivePart();
page.showView("ca.mcgill.sable.soot.ui.sootoutputview.view");
//restore focus stolen by the creation of the console
page.activate(activePart);
sootOutputViewer = page.findView("ca.mcgill.sable.soot.ui.sootoutputview.view");
}
else {
page.bringToTop(sootOutputViewer);
}
}
catch (PartInitException pie) {
System.out.println(pie.getMessage());
}
}
}
}
private void update(Runnable runnable) {
if (getViewer().getTextViewer() != null && getViewer().getTextViewer().getControl() != null && getViewer().getControl().getDisplay() != null) {
getViewer().getTextViewer().getControl().getDisplay().asyncExec(runnable);
}
}
/**
* Returns the viewer.
* @return SootOutputView
*/
public SootOutputView getViewer() {
return viewer;
}
/**
* Sets the viewer.
* @param viewer The viewer to set
*/
public void setViewer(SootOutputView viewer) {
this.viewer = viewer;
}
/**
* Returns the newStreamWriteEnd.
* @return int
*/
public int getNewStreamWriteEnd() {
return newStreamWriteEnd;
}
/**
* Returns the oldStreamWriteEnd.
* @return int
*/
public int getOldStreamWriteEnd() {
return oldStreamWriteEnd;
}
/**
* Sets the newStreamWriteEnd.
* @param newStreamWriteEnd The newStreamWriteEnd to set
*/
public void setNewStreamWriteEnd(int newStreamWriteEnd) {
this.newStreamWriteEnd = newStreamWriteEnd;
}
/**
* Sets the oldStreamWriteEnd.
* @param oldStreamWriteEnd The oldStreamWriteEnd to set
*/
public void setOldStreamWriteEnd(int oldStreamWriteEnd) {
this.oldStreamWriteEnd = oldStreamWriteEnd;
}
}
| 5,629
| 26.598039
| 145
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jdt.core.*;
import soot.coffi.*;
import java.io.*;
import java.util.*;
import ca.mcgill.sable.soot.SootPlugin;
/**
* Soot Launcher for files. Determines file type, project
* classpath, src-precedence
*/
public class SootFileLauncher extends SootLauncher {
private String classpathAppend;
private ArrayList toProcessList;
private String extraCmd;
private boolean isExtraCmd;
private String srcPrec;
private boolean isSrcPrec;
private boolean doNotContinue = false;
public void handleMultipleFiles() {
setToProcessList(new ArrayList());
Iterator it = getSootSelection().getFileList().iterator();
while (it.hasNext()){
handleFiles(it.next());
// must set multiple toProcess but also classpaths and
// ouptut directories
}
}
public void run(IAction action){
super.run(action);
classpathAppend = null;
}
public void handleFiles(Object toProcess){
setDoNotContinue(false);
if (toProcess instanceof IClassFile){
IClassFile cf = (IClassFile)toProcess;
IPackageFragmentRoot pfr = (IPackageFragmentRoot) cf.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
IPackageFragment pf = (IPackageFragment) cf.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
if (pfr.getResource() != null){
setClasspathAppend(platform_location+pfr.getPath().toOSString());
}
else {
setClasspathAppend(pfr.getPath().toOSString());
}
addJars();
if (pf.isDefaultPackage()) {
getToProcessList().add(removeFileExt(cf.getElementName()));
}
else {
getToProcessList().add(pf.getElementName()+"."+removeFileExt(cf.getElementName()));
}
}
else if (toProcess instanceof IFile){
IFile file = (IFile)toProcess;
String fileExtension = file.getFileExtension();
if (fileExtension != null) {
if (fileExtension.compareTo("jimple") == 0) {
setClasspathAppend(platform_location+file.getParent().getFullPath().toOSString());
addJars();
setIsSrcPrec(true);
setSrcPrec(LaunchCommands.JIMPLE_IN);
getToProcessList().add(removeFileExt(file.getName()));
}
else if (fileExtension.equals("java")){
try {
handleSourceFile(JavaCore.createCompilationUnitFrom(file));
}
catch(Exception e){
System.out.println("problem creating CompilationUnit");
}
}
else if (fileExtension.equals("class")) {
try {
handleClassFile(file);
}
catch(Exception e){
System.out.println("not a class file");
}
}
}
}
else if (toProcess instanceof ICompilationUnit){
ICompilationUnit cu = (ICompilationUnit)toProcess;
handleSourceFile(cu);
}
}
private String dotsToSlashes(String name) {
name = name.replaceAll("\\.", System.getProperty("file.separator"));
return name;
}
private void handleSourceFile(ICompilationUnit cu){
IPackageFragmentRoot pfr = (IPackageFragmentRoot) cu.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
IPackageFragment pf = (IPackageFragment) cu.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
if (isSrcPrec() && getSrcPrec().equals("java")){
setClasspathAppend(platform_location+pfr.getPath().toOSString());
}
else{
try {
IProject proj = cu.getJavaProject().getProject();
IFolder output = proj.getFolder(cu.getJavaProject().getOutputLocation().lastSegment());
IPackageFragment pkf = (IPackageFragment)cu.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
IFile exists = null;
if (pkf.isDefaultPackage()) {
exists = output.getFile(removeFileExt(cu.getElementName())+".class");
}
else {
IFolder pkg = output.getFolder(dotsToSlashes(pf.getElementName()));
exists = pkg.getFile(removeFileExt(cu.getElementName())+".class");
}
if (!exists.exists()){
window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
MessageDialog noClassFound = new MessageDialog(window.getShell(), "Soot Information", null, "No underlying class file was found, maybe build project.", 0, new String [] {"OK"}, 0);
noClassFound.open();
setDoNotContinue(true);
}
setClasspathAppend(platform_location+cu.getJavaProject().getOutputLocation().toOSString());
}
catch (CoreException e){
}
}
addJars();
if (pf.isDefaultPackage()) {
getToProcessList().add(removeFileExt(cu.getElementName()));
}
else {
getToProcessList().add(pf.getElementName()+"."+removeFileExt(cu.getElementName()));
}
}
private void handleClassFile(IFile file) {
ClassFile cf = new ClassFile( file.getLocation().toOSString());
FileInputStream fis = null;
try {
fis = new FileInputStream( file.getLocation().toOSString() );
}
catch( FileNotFoundException e ) {
}
if (!cf.loadClassFile( fis )){
MessageDialog noClassFound = new MessageDialog(window.getShell(), "Soot Information", null, "Could not determine package for class file will not continue.", 0, new String [] {"OK"}, 0);
noClassFound.open();
setDoNotContinue(true);
}
getToProcessList().add(replaceWithDot(cf.toString()));
setClasspathAppend(file.getLocation().toOSString().substring(0, file.getLocation().toOSString().indexOf(cf.toString())));
addJars();
}
private String replaceWithDot(String in){
String separator = System.getProperty("file.separator");
in = in.replaceAll(separator, ".");
return in;
}
private String removeFileExt(String filename) {
int dot = filename.lastIndexOf('.');
filename = filename.substring(0, dot);
return filename;
}
/**
* Returns the classpathAppend.
* @return String
*/
public String getClasspathAppend() {
return getSootClasspath().getSootClasspath() + getSootClasspath().getSeparator() + classpathAppend;
}
/**
* Sets the classpathAppend.
* @param classpathAppend The classpathAppend to set
*/
public void setClasspathAppend(String ca) {
if ((this.classpathAppend == null) || (this.classpathAppend.equals(""))){
this.classpathAppend = ca;
}
else {
if (this.classpathAppend.indexOf(ca) == -1){
this.classpathAppend = this.classpathAppend+getSootClasspath().getSeparator()+ca;
}
}
}
/**
* Returns the extraCmd.
* @return String
*/
public String getExtraCmd() {
return extraCmd;
}
/**
* Sets the extraCmd.
* @param extraCmd The extraCmd to set
*/
public void setExtraCmd(String extraCmd) {
this.extraCmd = extraCmd;
}
/**
* Returns the isExtraCmd.
* @return boolean
*/
public boolean isExtraCmd() {
return isExtraCmd;
}
/**
* Sets the isExtraCmd.
* @param isExtraCmd The isExtraCmd to set
*/
public void setIsExtraCmd(boolean isExtraCmd) {
this.isExtraCmd = isExtraCmd;
}
/**
* Returns the isSrcPrec.
* @return boolean
*/
public boolean isSrcPrec() {
return isSrcPrec;
}
/**
* Returns the srcPrec.
* @return String
*/
public String getSrcPrec() {
return srcPrec;
}
/**
* Sets the isSrcPrec.
* @param isSrcPrec The isSrcPrec to set
*/
public void setIsSrcPrec(boolean isSrcPrec) {
this.isSrcPrec = isSrcPrec;
}
/**
* Sets the srcPrec.
* @param srcPrec The srcPrec to set
*/
public void setSrcPrec(String srcPrec) {
this.srcPrec = srcPrec;
}
/**
* @return
*/
public boolean isDoNotContinue() {
return doNotContinue;
}
/**
* @param b
*/
public void setDoNotContinue(boolean b) {
doNotContinue = b;
}
/**
* @return
*/
public ArrayList getToProcessList() {
return toProcessList;
}
/**
* @param list
*/
public void setToProcessList(ArrayList list) {
toProcessList = list;
}
}
| 8,864
| 26.361111
| 188
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootFolderLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import org.eclipse.jface.action.*;
/**
* Soot Launcher for folders.
*/
public class SootFolderLauncher extends SootLauncher {
private String processPath;
private String classpathAppend = null;
public void run(IAction action) {
super.run(action);
classpathAppend = null;
if (getSootSelection().getType() == SootSelection.PACKAGEROOT_SELECTED_TYPE){
addJars();
if (getSootSelection().getPackageFragmentRoot().getResource() != null){
setProcessPath(platform_location+getSootSelection().getPackageFragmentRoot().getPath().toOSString());
}
else {
setProcessPath(getSootSelection().getPackageFragmentRoot().getPath().toOSString());
}
}
}
/**
* Sets the classpathAppend.
* @param classpathAppend The classpathAppend to set
*/
public void setClasspathAppend(String ca) {
if (this.classpathAppend == null){
this.classpathAppend = ca;
}
else {
this.classpathAppend = this.classpathAppend+getSootClasspath().getSeparator()+ca;
}
}
/**
* Returns the processPath.
* @return String
*/
public String getProcessPath() {
return processPath;
}
/**
* Sets the processPath.
* @param processPath The processPath to set
*/
public void setProcessPath(String processPath) {
this.processPath = processPath;
}
/**
* @return
*/
public String getClasspathAppend() {
return getSootClasspath().getSootClasspath() + getSootClasspath().getSeparator() + classpathAppend;
}
}
| 2,316
| 25.632184
| 105
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootGrimpFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.IAction;
/**
* Launches Soot with -f g on selected files.
*/
public class SootGrimpFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
getSootCommandList().addDoubleOpt("--"+LaunchCommands.OUTPUT, LaunchCommands.GRIMP_OUT);
if (isExtraCmd()) {
getSootCommandList().addSingleOpt("--"+getExtraCmd());
}
if (isSrcPrec()) {
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, getSrcPrec());
}
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 2,151
| 29.309859
| 90
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootGrimpFromJavaFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.IAction;
/**
* Launches Soot with -f g on selected files.
*/
public class SootGrimpFromJavaFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.setIsSrcPrec(true);
super.setSrcPrec(LaunchCommands.JAVA_IN);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
getSootCommandList().addDoubleOpt("--"+LaunchCommands.OUTPUT, LaunchCommands.GRIMP_OUT);
if (isExtraCmd()) {
getSootCommandList().addSingleOpt("--"+getExtraCmd());
}
if (isSrcPrec()) {
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, getSrcPrec());
}
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 2,228
| 31.304348
| 90
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootJimpleFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f J for selected files.
*/
public class SootJimpleFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
getSootCommandList().addDoubleOpt("--"+LaunchCommands.OUTPUT, LaunchCommands.JIMPLE_OUT);
if (isExtraCmd()) {
getSootCommandList().addSingleOpt("--"+getExtraCmd());
}
if (isSrcPrec()) {
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, getSrcPrec());
}
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 2,122
| 29.768116
| 91
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootJimpleFromJavaFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f J for selected files.
*/
public class SootJimpleFromJavaFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.setIsSrcPrec(true);
super.setSrcPrec(LaunchCommands.JAVA_IN);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
getSootCommandList().addDoubleOpt("--"+LaunchCommands.OUTPUT, LaunchCommands.JIMPLE_OUT);
if (isExtraCmd()) {
getSootCommandList().addSingleOpt("--"+getExtraCmd());
}
if (isSrcPrec()) {
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC, getSrcPrec());
}
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 2,226
| 30.366197
| 91
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootJimpleJavaProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f J for all classes in output dir of
* selected project
*/
public class SootJimpleJavaProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
Iterator it = getJavaProcessPath().iterator();
String cp = (String)it.next();
while (it.hasNext()){
cp = cp + getSootClasspath().getSeparator() + (String)it.next();
}
cp = cp + getSootClasspath().getSeparator() + getClasspathAppend();
commands.add(cp);
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
Iterator it2 = getJavaProcessPath().iterator();
while (it2.hasNext()){
commands.add("--"+LaunchCommands.PROCESS_PATH);
commands.add((String)it2.next());
}
getSootCommandList().addDoubleOpt("--"+LaunchCommands.OUTPUT, LaunchCommands.JIMPLE_OUT);
getSootCommandList().addDoubleOpt("--"+LaunchCommands.SRC_PREC,"java");
getSootCommandList().addSingleOpt(commands);
}
}
| 2,246
| 31.565217
| 91
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootJimpleProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import org.eclipse.jface.action.*;
/**
* Launches Soot with -f J for all classes in output dir of
* selected project
*/
public class SootJimpleProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
setCmd();
runSootDirectly();
runFinish();
}
private void setCmd() {
ArrayList commands = new ArrayList();
commands.add("--"+LaunchCommands.SOOT_CLASSPATH);
commands.add(getProcess_path()+getSootClasspath().getSeparator()+getClasspathAppend());
commands.add("--"+LaunchCommands.OUTPUT_DIR);
commands.add(getOutputLocation());
getSootCommandList().addSingleOpt("--"+LaunchCommands.KEEP_LINE_NUMBER);
getSootCommandList().addSingleOpt("--"+LaunchCommands.XML_ATTRIBUTES);
commands.add("--"+LaunchCommands.PROCESS_PATH);
commands.add(getProcess_path());
getSootCommandList().addDoubleOpt("--"+LaunchCommands.OUTPUT, LaunchCommands.JIMPLE_OUT);
getSootCommandList().addSingleOpt(commands);
}
}
| 1,877
| 31.947368
| 91
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.jdt.core.IPackageFragmentRoot;
import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.operation.ModalContext;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import soot.jimple.toolkits.annotation.callgraph.CallData;
import ca.mcgill.sable.graph.GraphPlugin;
import ca.mcgill.sable.graph.testing.GraphGenerator;
import ca.mcgill.sable.graph.testing.TestNode;
import ca.mcgill.sable.soot.SootPlugin;
/**
* Main Soot Launcher. Handles running Soot directly (or as a
* process)
*/
public abstract class SootLauncher implements IWorkbenchWindowActionDelegate {
private IWorkbenchPart part;
protected IWorkbenchWindow window;
private ISelection selection;
private IStructuredSelection structured;
protected String platform_location;
protected String external_jars_location;
public SootClasspath sootClasspath = new SootClasspath();
public SootSelection sootSelection;
private SootCommandList sootCommandList;
private String outputLocation;
private SootDefaultCommands sdc;
private SootOutputFilesHandler fileHandler;
private DavaHandler davaHandler;
private ArrayList cfgList;
public void run(IAction action) {
setSootSelection(new SootSelection(structured));
getSootSelection().initialize();
setFileHandler(new SootOutputFilesHandler(window));
getFileHandler().resetSootOutputFolder(getSootSelection().getProject());
setDavaHandler(new DavaHandler());
getDavaHandler().setSootOutputFolder(getFileHandler().getSootOutputFolder());
getDavaHandler().handleBefore();
initPaths();
initCommandList();
}
private void initCommandList() {
setSootCommandList(new SootCommandList());
}
protected void runSootDirectly(){
runSootDirectly("soot.Main");
}
private void sendSootClearEvent(){
Display.getCurrent().syncExec(new Runnable(){
public void run() {
SootPlugin.getDefault().fireSootOutputEvent(new SootOutputEvent(SootLauncher.this, ISootOutputEventConstants.SOOT_CLEAR_EVENT));
};
});
}
private void sendSootOutputEvent(String toSend){
SootOutputEvent send = new SootOutputEvent(this, ISootOutputEventConstants.SOOT_NEW_TEXT_EVENT);
send.setTextToAppend(toSend);
final SootOutputEvent sendFinal = send;
Display.getCurrent().asyncExec(new Runnable(){
public void run() {
SootPlugin.getDefault().fireSootOutputEvent(sendFinal);
};
});
}
protected void runSootDirectly(String mainClass) {
int length = getSootCommandList().getList().size();
String temp [] = new String [length];
getSootCommandList().getList().toArray(temp);
String mainProject;
String realMainClass;
if(mainClass.contains(":")) {
String[] split = mainClass.split(":");
mainProject = split[0];
realMainClass = split[1];
} else {
mainProject = null;
realMainClass = mainClass;
}
newProcessStarting(realMainClass,mainProject);
sendSootOutputEvent(realMainClass);
sendSootOutputEvent(" ");
for (int i = 0; i < temp.length; i++) {
sendSootOutputEvent(temp[i]);
sendSootOutputEvent(" ");
}
sendSootOutputEvent("\n");
IRunnableWithProgress op;
try {
op = new SootRunner(temp, Display.getCurrent(), mainClass);
((SootRunner)op).setParent(this);
ModalContext.run(op, true, new NullProgressMonitor(), Display.getCurrent());
}
catch (InvocationTargetException e1) {
// handle exception
System.out.println("InvocationTargetException: "+e1.getMessage());
System.out.println("InvocationTargetException: "+e1.getTargetException());
System.out.println(e1.getStackTrace());
}
catch (InterruptedException e2) {
// handle cancelation
System.out.println("InterruptedException: "+e2.getMessage());
}
}
private void newProcessStarting(String mainClass, String mainProject) {
if(mainProject == null) {
mainProject = " from Soot's class library";
} else {
mainProject = " from project "+mainProject;
}
sendSootClearEvent();
sendSootOutputEvent("Starting"+mainProject+":\n");
}
private void initPaths() {
sootClasspath.initialize(getSootSelection().getJavaProject());
// platform location
platform_location = getSootSelection().getJavaProject().getProject().getLocation().toOSString();
platform_location = platform_location.substring(0, platform_location.lastIndexOf(System.getProperty("file.separator")));
// external jars location - may need to change don't think I use this anymore
setOutputLocation(platform_location+getFileHandler().getSootOutputFolder().getFullPath().toOSString());
}
protected void addJars(){
try {
IPackageFragmentRoot [] roots = getSootSelection().getJavaProject().getAllPackageFragmentRoots();
for (int i = 0; i < roots.length; i++){
if (roots[i].isArchive()){
if (roots[i].getResource() != null){
setClasspathAppend(platform_location+roots[i].getPath().toOSString());
}
else {
setClasspathAppend(roots[i].getPath().toOSString());
}
}
}
}
catch (JavaModelException e){
}
}
public abstract void setClasspathAppend(String ca);
public void runFinish() {
getFileHandler().refreshFolder();
getFileHandler().refreshAll(getSootSelection().getProject());
//for updating markers
SootPlugin.getDefault().getManager().updateSootRanFlag();
final IEditorPart activeEdPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
// run cfgviewer
if (getCfgList() != null){
// currently this is the call graph list of pkgs
GraphGenerator generator = new GraphGenerator();
generator.setChildren(convertPkgList(getCfgList()));
GraphPlugin.getDefault().setGenerator(generator);
generator.run(null);
}
}
HashMap alreadyDone = new HashMap();
private ArrayList convertPkgList(ArrayList pkgList){
ArrayList conList = new ArrayList();
Iterator it = pkgList.iterator();
while(it.hasNext()){
CallData cd = (CallData)it.next();
TestNode tn = null;
if (alreadyDone.containsKey(cd)){
tn = (TestNode)alreadyDone.get(cd);
}
else {
tn = new TestNode();
tn.setData(cd.getData());
alreadyDone.put(cd, tn);
if (cd.getChildren().size() != 0){
tn.setChildren(convertPkgList(cd.getChildren()));
}
if (cd.getOutputs().size() != 0){
tn.setOutputs(convertPkgList(cd.getOutputs()));
}
}
conList.add(tn);
}
return conList;
}
public IStructuredSelection getStructured() {
return structured;
}
private void setStructured(IStructuredSelection struct) {
structured = struct;
}
public void init(IWorkbenchWindow window) {
this.window = window;
}
public void dispose() {
}
public void selectionChanged(IAction action, ISelection selection) {
this.selection = selection;
if (selection instanceof IStructuredSelection){
setStructured((IStructuredSelection)selection);
}
}
/**
* Returns the sootClasspath.
* @return SootClasspath
*/
public SootClasspath getSootClasspath() {
return sootClasspath;
}
/**
* Sets the sootClasspath.
* @param sootClasspath The sootClasspath to set
*/
public void setSootClasspath(SootClasspath sootClasspath) {
this.sootClasspath = sootClasspath;
}
/**
* Returns the sootSelection.
* @return SootSelection
*/
public SootSelection getSootSelection() {
return sootSelection;
}
/**
* Sets the sootSelection.
* @param sootSelection The sootSelection to set
*/
public void setSootSelection(SootSelection sootSelection) {
this.sootSelection = sootSelection;
}
/**
* Returns the window.
* @return IWorkbenchWindow
*/
public IWorkbenchWindow getWindow() {
return window;
}
/**
* Returns the sootCommandList.
* @return SootCommandList
*/
public SootCommandList getSootCommandList() {
return sootCommandList;
}
/**
* Sets the sootCommandList.
* @param sootCommandList The sootCommandList to set
*/
public void setSootCommandList(SootCommandList sootCommandList) {
this.sootCommandList = sootCommandList;
}
/**
* Returns the output_location.
* @return String
*/
public String getOutputLocation() {
return outputLocation;
}
/**
* Sets the output_location.
* @param output_location The output_location to set
*/
public void setOutputLocation(String outputLocation) {
this.outputLocation = outputLocation;
}
/**
* Returns the sdc.
* @return SootDefaultCommands
*/
public SootDefaultCommands getSdc() {
return sdc;
}
/**
* Sets the sdc.
* @param sdc The sdc to set
*/
public void setSdc(SootDefaultCommands sdc) {
this.sdc = sdc;
}
/**
* Returns the fileHandler.
* @return SootOutputFilesHandler
*/
public SootOutputFilesHandler getFileHandler() {
return fileHandler;
}
/**
* Sets the fileHandler.
* @param fileHandler The fileHandler to set
*/
public void setFileHandler(SootOutputFilesHandler fileHandler) {
this.fileHandler = fileHandler;
}
/**
* @return
*/
public DavaHandler getDavaHandler() {
return davaHandler;
}
/**
* @param handler
*/
public void setDavaHandler(DavaHandler handler) {
davaHandler = handler;
}
/**
* @return
*/
public ArrayList getCfgList() {
return cfgList;
}
/**
* @param list
*/
public void setCfgList(ArrayList list) {
cfgList = list;
}
}
| 10,992
| 25.489157
| 135
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootLauncherThread.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
/**
* A thread for launching Soot a J*va application from within
* Eclispe another J*va application.
*/
public class SootLauncherThread extends Thread {
/**
* Constructor for SootLauncherThread.
*/
public SootLauncherThread() {
super();
}
/**
* Constructor for SootLauncherThread.
* @param target
*/
public SootLauncherThread(Runnable target) {
super(target);
}
/**
* Constructor for SootLauncherThread.
* @param group
* @param target
*/
public SootLauncherThread(ThreadGroup group, Runnable target) {
super(group, target);
}
/**
* Constructor for SootLauncherThread.
* @param name
*/
public SootLauncherThread(String name) {
super(name);
}
/**
* Constructor for SootLauncherThread.
* @param group
* @param name
*/
public SootLauncherThread(ThreadGroup group, String name) {
super(group, name);
}
/**
* Constructor for SootLauncherThread.
* @param target
* @param name
*/
public SootLauncherThread(Runnable target, String name) {
super(target, name);
}
/**
* Constructor for SootLauncherThread.
* @param group
* @param target
* @param name
*/
public SootLauncherThread(
ThreadGroup group,
Runnable target,
String name) {
super(group, target, name);
}
/**
* Constructor for SootLauncherThread.
* @param group
* @param target
* @param name
* @param stackSize
*/
public SootLauncherThread(
ThreadGroup group,
Runnable target,
String name,
long stackSize) {
super(group, target, name, stackSize);
}
}
| 2,392
| 21.364486
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOptionsFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.*;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.PhaseOptionsDialog;
/**
* Displays the Soot Options dialog and launches Soot with
* selected options on selected file.
*/
public class SootOptionsFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
// sometimes window needs to be reset (not sure why)
window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
setSdc(new SootDefaultCommands(dialog));
presetDialog();
dialog.open();
if (dialog.getReturnCode() == Dialog.CANCEL) {
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
else {
SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
ssc.toSaveArray();
setCmd(ssc.toRunArray());
String mainClass = dialog.getSootMainClass();
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
// save config if nessesary
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
}
private void presetDialog() {
getSdc().setOutputDir(getOutputLocation());
getSdc().setSootClassPath(getClasspathAppend());
if (isSrcPrec()) {
getSdc().setSrcPrec(getSrcPrec());
}
getSdc().setKeepLineNum();
getSdc().setPrintTags();
getSdc().setSootMainClass();
}
// TODO use this instead of String one
private void setCmd(ArrayList user_cmd){
getSootCommandList().addSingleOpt(user_cmd);
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
getSootCommandList().addSingleOpt((String)it.next());
}
}
private void setCmd(String user_cmd) {
getSootCommandList().addSingleOpt(user_cmd);
ArrayList commands = new ArrayList();
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 3,296
| 27.669565
| 92
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOptionsFolderLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.*;
import ca.mcgill.sable.soot.SootPlugin;
import ca.mcgill.sable.soot.ui.*;
/**
* Displays the Soot Options dialog and launches Soot with
* selected options on all class files in output dir of
* selected project.
*/
public class SootOptionsFolderLauncher extends SootFolderLauncher {
public void run(IAction action) {
super.run(action);
window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
setSdc(new SootDefaultCommands(dialog));
presetDialog();
dialog.open();
if (dialog.getReturnCode() == Dialog.CANCEL) {
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
else {
SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
ssc.toSaveArray();
setCmd(ssc.toRunArray());
String mainClass = dialog.getSootMainClass();
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
// save config if nessesary
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
}
private void presetDialog() {
getSdc().setOutputDir(getOutputLocation());
getSdc().setSootClassPath(getProcessPath()+getSootClasspath().getSeparator()+getClasspathAppend());
getSdc().setProcessPath(getProcessPath());
getSdc().setKeepLineNum();
getSdc().setPrintTags();
getSdc().setSootMainClass();
}
// TODO use this method instaed of one with String
private void setCmd(ArrayList user_cmd){
getSootCommandList().addSingleOpt(user_cmd);
}
private void setCmd(String user_cmd) {
getSootCommandList().addSingleOpt(user_cmd);
}
}
| 2,904
| 30.236559
| 101
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOptionsFromJavaFileLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.*;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.ui.PhaseOptionsDialog;
/**
* Displays the Soot Options dialog and launches Soot with
* selected options on selected file.
*/
public class SootOptionsFromJavaFileLauncher extends SootFileLauncher {
public void run(IAction action) {
super.run(action);
super.setIsSrcPrec(true);
super.setSrcPrec(LaunchCommands.JAVA_IN);
super.handleMultipleFiles();
if (isDoNotContinue()) return;
// sometimes window needs to be reset (not sure why)
window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
setSdc(new SootDefaultCommands(dialog));
presetDialog();
dialog.open();
if (dialog.getReturnCode() == Dialog.CANCEL) {
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
else {
SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
ssc.toSaveArray();
setCmd(ssc.toRunArray());
String mainClass = dialog.getSootMainClass();
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
// save config if nessesary
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
}
private void presetDialog() {
getSdc().setOutputDir(getOutputLocation());
getSdc().setSootClassPath(getClasspathAppend());
if (isSrcPrec()) {
getSdc().setSrcPrec(getSrcPrec());
}
getSdc().setKeepLineNum();
getSdc().setPrintTags();
getSdc().setSootMainClass();
}
// TODO use this instead of String one
private void setCmd(ArrayList user_cmd){
getSootCommandList().addSingleOpt(user_cmd);
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
getSootCommandList().addSingleOpt((String)it.next());
}
}
private void setCmd(String user_cmd) {
getSootCommandList().addSingleOpt(user_cmd);
ArrayList commands = new ArrayList();
Iterator it = getToProcessList().iterator();
while (it.hasNext()){
commands.add((String)it.next());
}
getSootCommandList().addSingleOpt(commands);
}
}
| 3,385
| 28.189655
| 92
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOptionsJavaProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.*;
import ca.mcgill.sable.soot.ui.*;
/**
* Displays the Soot Options dialog and launches Soot with
* selected options on all class files in output dir of
* selected project.
*/
public class SootOptionsJavaProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
setSdc(new SootDefaultCommands(dialog));
presetDialog();
dialog.open();
if (dialog.getReturnCode() == Dialog.CANCEL) {
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
else {
SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
ssc.toSaveArray();
setCmd(ssc.toRunArray());
String mainClass = dialog.getSootMainClass();
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
// save config if nessesary
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
}
private void presetDialog() {
getSdc().setOutputDir(getOutputLocation());
Iterator it = getJavaProcessPath().iterator();
String cp = (String)it.next();
while (it.hasNext()){
cp = cp + getSootClasspath().getSeparator() + (String)it.next();
}
cp = cp + getSootClasspath().getSeparator()+ getClasspathAppend();
getSdc().setSootClassPath(cp);
getSdc().setProcessPath(getJavaProcessPath());
getSdc().setKeepLineNum();
getSdc().setPrintTags();
getSdc().setSrcPrec("java");
getSdc().setSootMainClass();
}
// TODO use this method instaed of one with String
private void setCmd(ArrayList user_cmd){
getSootCommandList().addSingleOpt(user_cmd);
}
private void setCmd(String user_cmd) {
getSootCommandList().addSingleOpt(user_cmd);
}
}
| 3,034
| 29.35
| 92
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOptionsProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import org.eclipse.jface.action.*;
import org.eclipse.jface.dialogs.*;
import ca.mcgill.sable.soot.ui.*;
/**
* Displays the Soot Options dialog and launches Soot with
* selected options on all class files in output dir of
* selected project.
*/
public class SootOptionsProjectLauncher extends SootProjectLauncher {
public void run(IAction action) {
super.run(action);
PhaseOptionsDialog dialog = new PhaseOptionsDialog(window.getShell());
setSdc(new SootDefaultCommands(dialog));
presetDialog();
dialog.open();
if (dialog.getReturnCode() == Dialog.CANCEL) {
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
else {
SootSavedConfiguration ssc = new SootSavedConfiguration("Temp", dialog.getConfig());
ssc.toSaveArray();
setCmd(ssc.toRunArray());
String mainClass = dialog.getSootMainClass();
if ((mainClass == null) || (mainClass.length() == 0)){
runSootDirectly();
}
else {
runSootDirectly(mainClass);
}
runFinish();
// save config if nessesary
SavedConfigManager scm = new SavedConfigManager();
scm.setEditMap(dialog.getEditMap());
scm.handleEdits();
}
}
private void presetDialog() {
getSdc().setOutputDir(getOutputLocation());
getSdc().setSootClassPath(getProcess_path()+getSootClasspath().getSeparator()+getClasspathAppend());
getSdc().setProcessPath(getProcess_path());
getSdc().setKeepLineNum();
getSdc().setPrintTags();
getSdc().setSootMainClass();
}
// TODO use this method instaed of one with String
private void setCmd(ArrayList user_cmd){
getSootCommandList().addSingleOpt(user_cmd);
}
private void setCmd(String user_cmd) {
getSootCommandList().addSingleOpt(user_cmd);
}
}
| 2,790
| 29.67033
| 102
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOutputEvent.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.EventObject;
/**
* An event to contain output from Soot to be sent to Soot Output
* View.
*/
public class SootOutputEvent extends EventObject {
private int event_type;
private String textToAppend;
public void setTextToAppend(String text) {
textToAppend = text;
}
public String getTextToAppend() {
return textToAppend;
}
public SootOutputEvent(Object eventSource, int type) {
super(eventSource);
setEventType(type);
}
public void setEventType(int type) {
event_type = type;
}
public int getEventType() {
return event_type;
}
}
| 1,449
| 25.851852
| 69
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootOutputFilesHandler.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IFolder;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.part.*;
import ca.mcgill.sable.soot.SootPlugin;
/**
* Handles Soot ouptut dir. Potentially will do something with
* Soot generated files such as open them automatically.
*/
public class SootOutputFilesHandler {
private IFolder sootOutputFolder;
private ArrayList oldFilelist;
private ArrayList newFilelist;
private IWorkbenchWindow window;
private ArrayList beforeFileList;
/**
* Constructor for SootOutputFilesHandler.
*/
public SootOutputFilesHandler(IWorkbenchWindow window) {
super();
setWindow(window);
}
public void resetSootOutputFolder(IProject project) {
try {
setSootOutputFolder(project.getFolder("sootOutput"));
if (!getSootOutputFolder().exists()) {
getSootOutputFolder().create(false, true, null);
}
}
catch (Exception e1) {
System.out.println(e1.getMessage());
}
}
public void refreshAll(IProject project){
try{
project.refreshLocal(IResource.DEPTH_INFINITE, null);
}
catch(CoreException e){
System.out.println(e.getMessage());
}
}
public void refreshFolder() {
try {
getSootOutputFolder().refreshLocal(IResource.DEPTH_INFINITE, null);
}
catch (CoreException e1) {
System.out.println(e1.getMessage());
}
}
public void handleFilesChanged() {
// files that were showing close
if (getOldFilelist() != null) {
Iterator it = getOldFilelist().iterator();
while (it.hasNext()) {
Object temp = it.next();
if (temp instanceof IEditorPart) {
getWindow().getActivePage().closeEditor((IEditorPart)temp, true);
}
}
}
try {
IResource [] children = getSootOutputFolder().members();
IWorkbenchWindow window = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
}
catch (Exception e) {
System.out.println("Open Editor ex: "+e.getMessage());
System.out.println(e.getStackTrace());
}
// new files show
}
/**
* Returns the sootOuputFolder.
* @return IFolder
*/
public IFolder getSootOutputFolder() {
return sootOutputFolder;
}
/**
* Sets the sootOuputFolder.
* @param sootOuputFolder The sootOuputFolder to set
*/
public void setSootOutputFolder(IFolder sootOutputFolder) {
this.sootOutputFolder = sootOutputFolder;
}
/**
* Returns the newFilelist.
* @return ArrayList
*/
public ArrayList getNewFilelist() {
return newFilelist;
}
/**
* Returns the oldFilelist.
* @return ArrayList
*/
public ArrayList getOldFilelist() {
return oldFilelist;
}
/**
* Sets the newFilelist.
* @param newFilelist The newFilelist to set
*/
public void setNewFilelist(ArrayList newFilelist) {
this.newFilelist = newFilelist;
}
/**
* Sets the oldFilelist.
* @param oldFilelist The oldFilelist to set
*/
public void setOldFilelist(ArrayList oldFilelist) {
this.oldFilelist = oldFilelist;
}
/**
* Returns the window.
* @return IWorkbenchWindow
*/
public IWorkbenchWindow getWindow() {
return window;
}
/**
* Sets the window.
* @param window The window to set
*/
public void setWindow(IWorkbenchWindow window) {
this.window = window;
}
}
| 4,364
| 23.116022
| 97
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootProjectLauncher.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
import org.eclipse.jdt.core.*;
import org.eclipse.jface.action.*;
/**
* Handles launching Soot on project.
*/
public class SootProjectLauncher extends SootLauncher {
private String process_path;
private ArrayList javaProcessPath;
private String classpathAppend = null;
public void run(IAction action) {
super.run(action);
classpathAppend = null;
try {
setProcess_path(platform_location+getSootSelection().getJavaProject().getOutputLocation().toOSString());
IPackageFragmentRoot [] roots = getSootSelection().getJavaProject().getAllPackageFragmentRoots();
for (int i = 0; i < roots.length; i++){
if (!roots[i].isArchive() && roots[i].getKind() == IPackageFragmentRoot.K_SOURCE){
String next = platform_location+roots[i].getPath();
if (getJavaProcessPath() == null){
setJavaProcessPath(new ArrayList());
}
getJavaProcessPath().add(next);
}
}
addJars();
}
catch(Exception e1) {
System.out.println(e1.getMessage());
}
}
/**
* Sets the classpathAppend.
* @param classpathAppend The classpathAppend to set
*/
public void setClasspathAppend(String ca) {
if (this.classpathAppend == null){
this.classpathAppend = ca;
}
else {
this.classpathAppend = this.classpathAppend+getSootClasspath().getSeparator()+ca;
}
}
/**
* Returns the process_path.
* @return String
*/
public String getProcess_path() {
return process_path;
}
/**
* Sets the process_path.
* @param process_path The process_path to set
*/
public void setProcess_path(String process_path) {
this.process_path = process_path;
}
/**
* @return
*/
public String getClasspathAppend() {
return getSootClasspath().getSootClasspath() + getSootClasspath().getSeparator() + classpathAppend;
}
/**
* @return
*/
public ArrayList getJavaProcessPath() {
return javaProcessPath;
}
/**
* @param string
*/
public void setJavaProcessPath(ArrayList list) {
javaProcessPath = list;
}
}
| 2,887
| 23.896552
| 107
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootRunner.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.io.*;
import java.lang.reflect.InvocationTargetException;
import ca.mcgill.sable.soot.interaction.*;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.swt.widgets.Display;
import ca.mcgill.sable.soot.util.*;
import java.util.*;
import org.eclipse.jface.dialogs.*;
/**
* Runs Soot and creates Handler for Soot output.
*/
public class SootRunner implements IRunnableWithProgress {
Display display;
String [] cmd;
String mainClass;
ArrayList cfgList;
private SootLauncher parent;
/**
* Constructor for SootRunner.
*/
public SootRunner(String [] cmd, Display display , String mainClass) {
setDisplay(display);
setCmd(cmd);
setMainClass(mainClass);
}
/**
* @see org.eclipse.jface.operation.IRunnableWithProgress#run(IProgressMonitor)
*/
public void run(IProgressMonitor monitor)
throws InvocationTargetException, InterruptedException {
try {
final PipedInputStream pis = new PipedInputStream();
final PipedOutputStream pos = new PipedOutputStream(pis);
final PrintStream sootOut = new PrintStream(pos);
final String [] cmdFinal = getCmd();
SootThread sootThread = new SootThread(getDisplay(), getMainClass(), this);
sootThread.setCmd(cmdFinal);
sootThread.setSootOut(sootOut);
sootThread.start();
StreamGobbler out = new StreamGobbler(getDisplay(), pis, StreamGobbler.OUTPUT_STREAM_TYPE);
out.start();
sootThread.join();
getParent().setCfgList(getCfgList());
}
catch (Exception e) {
System.out.println(e.getStackTrace());
}
}
/**
* Returns the cmd.
* @return String[]
*/
public String[] getCmd() {
return cmd;
}
/**
* Returns the display.
* @return Display
*/
public Display getDisplay() {
return display;
}
/**
* Sets the cmd.
* @param cmd The cmd to set
*/
public void setCmd(String[] cmd) {
this.cmd = cmd;
}
/**
* Sets the display.
* @param display The display to set
*/
public void setDisplay(Display display) {
this.display = display;
}
/**
* @return
*/
public String getMainClass() {
return mainClass;
}
/**
* @param string
*/
public void setMainClass(String string) {
mainClass = string;
}
/**
* @return
*/
public ArrayList getCfgList() {
return cfgList;
}
/**
* @param list
*/
public void setCfgList(ArrayList list) {
cfgList = list;
}
/**
* @return
*/
public SootLauncher getParent() {
return parent;
}
/**
* @param launcher
*/
public void setParent(SootLauncher launcher) {
parent = launcher;
}
}
| 3,618
| 21.478261
| 100
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootSavedConfiguration.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
public class SootSavedConfiguration {
private HashMap config;
private String name;
private String saved;
private ArrayList saveArray;
private ArrayList runArray;
private HashMap eclipseDefs;
private static final String SPACE = " ";
private static final String COLON = ":";
private static final String DASH = "--";
/**
* Constructor for SootSavedConfiguration.
*/
public SootSavedConfiguration(String name, HashMap config) {
setName(name);
setConfig(config);
}
/**
* Constructor for SootSavedConfiguration.
*/
public SootSavedConfiguration(String name, String [] saveArray) {
setName(name);
setSaveArray(new ArrayList());
for (int i = 0; i < saveArray.length; i++){
getSaveArray().add(saveArray[i]);
}
}
/**
* Constructor for SootSavedConfiguration.
*/
public SootSavedConfiguration(String name, String saved) {
setName(name);
setSaved(saved);
}
// same as before (removes defs from HashMap)
private void removeEclipseDefs(){
if (getEclipseDefs() == null) return;
Iterator it = getEclipseDefs().keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
if (getConfig().containsKey(key)) {
String needsToMatch = "";
Object val = getEclipseDefs().get(key);
if (val instanceof String){
needsToMatch = (String)val;
}
else if (val instanceof ArrayList){
Iterator it2 = ((ArrayList)val).iterator();
while (it2.hasNext()){
if (needsToMatch.equals("")){
needsToMatch = (String)it2.next();
}
else {
needsToMatch = needsToMatch + "\r\n" + (String)it2.next();
}
}
}
if (getConfig().get(key).equals(needsToMatch) || getConfig().get(key).equals(val)) {
getConfig().remove(key);
}
}
else {
getConfig().put(key, getOppositeVal(getEclipseDefs().get(key)) );
}
}
}
private Object getOppositeVal(Object val) {
if (val instanceof Boolean) {
if (((Boolean)val).booleanValue()) return new Boolean(false);
else return new Boolean(true);
}
else {
return "";
}
}
// will use addEclipseDefs to Array instead
private void addEclipseDefs() {
if (getEclipseDefs() == null) return;
Iterator it = getEclipseDefs().keySet().iterator();
StringBuffer tempSaved = new StringBuffer(getSaved());
while (it.hasNext()) {
String key = (String)it.next();
if (getSaved().indexOf((DASH+key)) != -1) {
// already there don't add (implies user changed val)
}
else {
Object val = getEclipseDefs().get(key);
if (val instanceof String){
String res = (String)val;
tempSaved.append(SPACE);
tempSaved.append(DASH);
tempSaved.append(key);
tempSaved.append(SPACE);
tempSaved.append(val);
tempSaved.append(SPACE);
}
else {
Iterator it2 = ((ArrayList)val).iterator();
while (it2.hasNext()){
String nextVal = (String)it2.next();
tempSaved.append(SPACE);
tempSaved.append(DASH);
tempSaved.append(key);
tempSaved.append(SPACE);
tempSaved.append(nextVal);
tempSaved.append(SPACE);
}
}
}
}
setSaved(tempSaved.toString());
}
// will use this one in future and not addEclipseDefs
private void addEclipseDefsToArray() {
if (getEclipseDefs() == null) return;
Iterator it = getEclipseDefs().keySet().iterator();
while (it.hasNext()) {
String key = (String)it.next();
if (getSaveArray().contains(DASH+key)) {
// already there don't add (implies user changed val)
}
else {
Object val = getEclipseDefs().get(key);
if (val instanceof String){
String res = (String)val;
getSaveArray().add(DASH+key);
getSaveArray().add(res);
}
else if (val instanceof Boolean){
getSaveArray().add(DASH+key);
getSaveArray().add(val.toString());
}
}
}
}
public HashMap toHashMapFromArray(){
addEclipseDefsToArray();
HashMap config = new HashMap();
BitSet bits = new BitSet(getSaveArray().size());
for (int i = 0; i < getSaveArray().size(); i++){
if (((String)getSaveArray().get(i)).indexOf("--") != -1){
bits.set(i);
}
}
int counter = 0;
while (counter < getSaveArray().size()){
if ((bits.get(counter+2)) || ((counter+2) >= getSaveArray().size())){
// non phase opt
// if key is already in map val = val + \n\r newVal
String key = ((String)getSaveArray().get(counter)).substring(2);
String val = (String)getSaveArray().get(counter+1);
if (config.get(key) != null){
String tempVal = (String)config.get(key);
tempVal = tempVal + "\r\n" + val;
config.put(key, tempVal);
}
else {
config.put(key,val);
}
counter = counter + 2;
}
else if ((bits.get(counter+3)) || ((counter+3) >= getSaveArray().size())){
// phase opt
String key = getSaveArray().get(counter)+SPACE+getSaveArray().get(counter+1);
StringTokenizer valTemp = new StringTokenizer((String)getSaveArray().get(counter+2), ":");
key = key+SPACE+valTemp.nextToken();
String val = valTemp.nextToken();
config.put(key.substring(2), val);
counter = counter + 3;
}
}
return config;
}
// goes from save String to HashMap
public HashMap toHashMap() {
// first add eclipse defs
addEclipseDefs();
HashMap config = new HashMap();
String temp = getSaved();
temp = temp.replaceAll("--", "&&");
StringTokenizer st = new StringTokenizer(temp, "&&");
while (st.hasMoreTokens()) {
StringTokenizer next = new StringTokenizer((String)st.nextToken());
switch (next.countTokens()) {
case 2: {
config.put(next.nextToken(), next.nextToken());
break;
}
case 3: {
// phase options
String key = next.nextToken()+SPACE+next.nextToken();
StringTokenizer valTemp = new StringTokenizer(next.nextToken(), ":");
key = key+SPACE+valTemp.nextToken();
String val = valTemp.nextToken();
config.put(key, val);
break;
}
default: {
//unhandled
break;
}
}
}
return config;
}
// goes from save Array to run Array -
//will use this and not toRunString in future
public ArrayList toRunArray() {
addEclipseDefsToArray();
if (getRunArray() == null){
setRunArray(new ArrayList());
}
Iterator it = getSaveArray().iterator();
String lastKey = "";
while (it.hasNext()){
String test = (String)it.next();
String spliter = "\r\n";
if (test.indexOf("\r\n") != -1){
spliter = "\r\n";
}
else if (test.indexOf('\n') != -1){
spliter = "\n";
}
if (test.equals("true")){
// don't send
}
else if (test.equals("false")){
// don't send and also don't send key
int index = getRunArray().size() - 1;
getRunArray().remove(index);
}
else if (test.indexOf(spliter) != -1){
String [] tokens = test.split(spliter);
getRunArray().add(tokens[0]);
for (int i = 1; i < tokens.length; i++){
getRunArray().add(lastKey);
getRunArray().add(tokens[i]);
}
}
else {
getRunArray().add(test);
}
lastKey = test;
}
return getRunArray();
}
// goes from save String to run String
public String toRunString() {
// first add eclipse defs
addEclipseDefs();
StringBuffer toRun = new StringBuffer();
String temp = getSaved();
temp = temp.replaceAll("--", "&&");
StringTokenizer st = new StringTokenizer(temp, "&&");
while (st.hasMoreTokens()) {
StringTokenizer next = new StringTokenizer((String)st.nextToken());
switch (next.countTokens()) {
case 2: {
String key = next.nextToken();
String val = next.nextToken();
val = val.trim();
// if true its a boolean and want to send
if (val.equals("true")) {
toRun.append(DASH);
toRun.append(key);
toRun.append(SPACE);
}
// if false its a boolean but don't want to send
else if (val.equals("false")) {
}
// non boolean
else {
toRun.append(DASH);
toRun.append(key);
toRun.append(SPACE);
toRun.append(val);
toRun.append(SPACE);
}
break;
}
case 3: {
// phase options
String key = next.nextToken()+SPACE+next.nextToken()+SPACE+next.nextToken();
toRun.append(DASH);
toRun.append(key);
toRun.append(SPACE);
break;
}
default: {
//unhandled
break;
}
}
}
return toRun.toString();
}
// goes from HashMap to ArrayList -> will use this and
// not toSaveString in future
public ArrayList toSaveArray() {
if (getSaveArray() == null) {
setSaveArray(new ArrayList());
}
removeEclipseDefs();
Iterator keysIt = getConfig().keySet().iterator();
while (keysIt.hasNext()) {
String key = (String)keysIt.next();
StringTokenizer st = new StringTokenizer(key);
Object val = getConfig().get(key);
switch(st.countTokens()) {
case 1: {
String aliasName = st.nextToken();
if (aliasName.equals("sootMainClass")) continue;
if (val instanceof String) {
String test = (String)val;
if ((test == null) |(test.length() == 0)) { System.out.println("continuing" ); continue;}
}
getSaveArray().add(DASH+aliasName);
if (val instanceof Boolean) {
getSaveArray().add(val.toString());
}
else if (val instanceof String) {
String test = (String)val;
String spliter = "\r\n";
if (test.indexOf("\r\n") != -1){
spliter = "\r\n";
}
else if (test.indexOf('\n') != -1){
spliter = "\n";
}
if (test.indexOf(spliter) != -1){
String [] tokens = test.split(spliter);
getSaveArray().add(tokens[0]);
for (int i = 1; i < tokens.length; i++){
getSaveArray().add(DASH+aliasName);
getSaveArray().add(tokens[i]);
}
}
else {
getSaveArray().add(val);
}
}
break;
}
case 3: {
getSaveArray().add(DASH+st.nextToken());
getSaveArray().add(st.nextToken());
String realVal = st.nextToken()+COLON;
if (val instanceof Boolean) {
realVal = realVal + val.toString();
}
else if (val instanceof String) {
realVal = realVal + val;
}
getSaveArray().add(realVal);
break;
}
default: {
//unhandled non option
break;
}
}
}
return getSaveArray();
}
// goeas from HashMap to String - will use toSaveArray in future
public String toSaveString() {
// first remove eclipse defs
removeEclipseDefs();
StringBuffer toSave = new StringBuffer();
Iterator keysIt = getConfig().keySet().iterator();
while (keysIt.hasNext()) {
String key = (String)keysIt.next();
StringTokenizer st = new StringTokenizer(key);
Object val = getConfig().get(key);
switch(st.countTokens()) {
case 1: {
toSave.append(DASH);
String aliasName = st.nextToken();
toSave.append(aliasName);
toSave.append(SPACE);
if (val instanceof Boolean) {
toSave.append(val.toString());
}
else if (val instanceof String) {
if (((String)val).indexOf("\n") != -1){
StringTokenizer listOptTokenizer = new StringTokenizer((String)val, "\n");
while (listOptTokenizer.hasMoreTokens()){
String next = listOptTokenizer.nextToken();
toSave.append(next);
if (listOptTokenizer.hasMoreTokens()){
toSave.append(DASH);
toSave.append(aliasName);
toSave.append(SPACE);
}
}
}
else {
toSave.append(val);
}
}
toSave.append(SPACE);
break;
}
case 3: {
toSave.append(DASH);
toSave.append(st.nextToken());
toSave.append(SPACE);
toSave.append(st.nextToken());
toSave.append(SPACE);
toSave.append(st.nextToken());
toSave.append(COLON);
if (val instanceof Boolean) {
toSave.append(val.toString());
}
else if (val instanceof String) {
toSave.append(val);
}
toSave.append(SPACE);
break;
}
default: {
//unhandled non option
break;
}
}
}
setSaved(toSave.toString());
return toSave.toString();
}
/**
* Returns the config.
* @return HashMap
*/
public HashMap getConfig() {
return config;
}
/**
* Returns the name.
* @return String
*/
public String getName() {
return name;
}
/**
* Sets the config.
* @param config The config to set
*/
public void setConfig(HashMap config) {
this.config = config;
}
/**
* Sets the name.
* @param name The name to set
*/
public void setName(String name) {
this.name = name;
}
/**
* Returns the saved.
* @return String
*/
public String getSaved() {
return saved;
}
/**
* Sets the saved.
* @param saved The saved to set
*/
public void setSaved(String saved) {
this.saved = saved;
}
/**
* Returns the eclipseDefs.
* @return HashMap
*/
public HashMap getEclipseDefs() {
return eclipseDefs;
}
/**
* Sets the eclipseDefs.
* @param eclipseDefs The eclipseDefs to set
*/
public void setEclipseDefs(HashMap eclipseDefs) {
this.eclipseDefs = eclipseDefs;
}
/**
* @return
*/
public ArrayList getSaveArray() {
return saveArray;
}
/**
* @param list
*/
public void setSaveArray(ArrayList list) {
saveArray = list;
}
/**
* @return
*/
public ArrayList getRunArray() {
return runArray;
}
/**
* @param list
*/
public void setRunArray(ArrayList list) {
runArray = list;
}
}
| 14,373
| 23.57094
| 95
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootSelection.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.jdt.core.*;
import org.eclipse.jface.viewers.*;
import ca.mcgill.sable.soot.*;
public class SootSelection {
private IStructuredSelection structured;
private IResource resource;
private IProject project;
private IJavaProject javaProject;
private IFolder folder;
private IFile file;
private ArrayList fileList;
private IClassFile classFile;
private ArrayList classFileList;
private ICompilationUnit javaFile;
private ArrayList javaFileList;
private IPackageFragmentRoot packageFragmentRoot;
private int type;
public static final int FILE_SELECTED_TYPE = 0;
public static final int FOLDER_SELECTED_TYPE = 2;
public static final int PACKAGEROOT_SELECTED_TYPE = 3;
public static final int CLASSFILE_SELECTED_TYPE = 1;
public static final int CU_SELECTED_TYPE = 4;
public SootSelection(IStructuredSelection struct) {
setStructured(struct);
}
public void initialize() {
Iterator it = getStructured().iterator();
Object temp = it.next();
if (temp instanceof IResource) {
setResource((IResource)temp);
setProject(getResource().getProject());
SootPlugin.getDefault().setCurrentProject(getProject());
setJavaProject(JavaCore.create(getProject()));
}
else if (temp instanceof IJavaElement) {
IJavaElement jElem = (IJavaElement)temp;
setJavaProject(jElem.getJavaProject());
setProject(javaProject.getProject());
SootPlugin.getDefault().setCurrentProject(getProject());
}
if (temp instanceof IFolder) {
setFolder((IFolder)temp);
setType(FOLDER_SELECTED_TYPE);
}
else if (temp instanceof IFile) {
setFile((IFile)temp);
setType(FILE_SELECTED_TYPE);
}
else if (temp instanceof IClassFile) {
setClassFile((IClassFile)temp);
setType(CLASSFILE_SELECTED_TYPE);
}
else if (temp instanceof IPackageFragmentRoot) {
setPackageFragmentRoot((IPackageFragmentRoot)temp);
setType(PACKAGEROOT_SELECTED_TYPE);
}
else if (temp instanceof ICompilationUnit){
setJavaFile((ICompilationUnit)temp);
setType(CU_SELECTED_TYPE);
}
Iterator allFilesIt = getStructured().iterator();
while (allFilesIt.hasNext()){
if (getFileList() == null) {
setFileList(new ArrayList());
}
getFileList().add(allFilesIt.next());
}
}
/**
* Returns the folder.
* @return IFolder
*/
public IFolder getFolder() {
return folder;
}
/**
* Returns the javaProject.
* @return IJavaProject
*/
public IJavaProject getJavaProject() {
return javaProject;
}
/**
* Returns the project.
* @return IProject
*/
public IProject getProject() {
return project;
}
/**
* Returns the resource.
* @return IResource
*/
public IResource getResource() {
return resource;
}
/**
* Returns the structured.
* @return IStructuredSelection
*/
public IStructuredSelection getStructured() {
return structured;
}
/**
* Sets the folder.
* @param folder The folder to set
*/
public void setFolder(IFolder folder) {
this.folder = folder;
}
/**
* Sets the javaProject.
* @param javaProject The javaProject to set
*/
public void setJavaProject(IJavaProject javaProject) {
this.javaProject = javaProject;
}
/**
* Sets the project.
* @param project The project to set
*/
public void setProject(IProject project) {
this.project = project;
}
/**
* Sets the resource.
* @param resource The resource to set
*/
public void setResource(IResource resource) {
this.resource = resource;
}
/**
* Sets the structured.
* @param structured The structured to set
*/
public void setStructured(IStructuredSelection structured) {
this.structured = structured;
}
/**
* Returns the file.
* @return IFile
*/
public IFile getFile() {
return file;
}
/**
* Sets the file.
* @param file The file to set
*/
public void setFile(IFile file) {
this.file = file;
}
/**
* Returns the type.
* @return int
*/
public int getType() {
return type;
}
/**
* Sets the type.
* @param type The type to set
*/
public void setType(int type) {
this.type = type;
}
/**
* Returns the classfile.
* @return IClassFile
*/
public IClassFile getClassFile() {
return classFile;
}
/**
* Sets the classfile.
* @param classfile The classfile to set
*/
public void setClassFile(IClassFile classFile) {
this.classFile = classFile;
}
/**
* Returns the packageFragmentRoot.
* @return IPackageFragmentRoot
*/
public IPackageFragmentRoot getPackageFragmentRoot() {
return packageFragmentRoot;
}
/**
* Sets the packageFragmentRoot.
* @param packageFragmentRoot The packageFragmentRoot to set
*/
public void setPackageFragmentRoot(IPackageFragmentRoot packageFragmentRoot) {
this.packageFragmentRoot = packageFragmentRoot;
}
/**
* @return
*/
public ICompilationUnit getJavaFile() {
return javaFile;
}
/**
* @param unit
*/
public void setJavaFile(ICompilationUnit unit) {
javaFile = unit;
}
/**
* @return
*/
public ArrayList getClassFileList() {
return classFileList;
}
/**
* @return
*/
public ArrayList getFileList() {
return fileList;
}
/**
* @return
*/
public ArrayList getJavaFileList() {
return javaFileList;
}
/**
* @param list
*/
public void setClassFileList(ArrayList list) {
classFileList = list;
}
/**
* @param list
*/
public void setFileList(ArrayList list) {
fileList = list;
}
/**
* @param list
*/
public void setJavaFileList(ArrayList list) {
javaFileList = list;
}
}
| 6,605
| 20.80198
| 79
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/launching/SootThread.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.launching;
import java.io.PrintStream;
import java.lang.reflect.Method;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import org.eclipse.core.resources.IProject;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import soot.toolkits.graph.interaction.InteractionHandler;
import ca.mcgill.sable.soot.SootPlugin;
import ca.mcgill.sable.soot.interaction.InteractionController;
public class SootThread extends Thread {
private Display display;
private String mainClass;
private ArrayList cfgList;
private InteractionController listener;
private SootRunner parent;
private Shell activeShell;
/**
* Constructor for SootThread.
*/
public SootThread(Display display, String mainClass, SootRunner parent) {
super();
setDisplay(display);
setMainClass(mainClass);
InteractionController controller = new InteractionController();
controller.setDisplay(getDisplay());
controller.setSootThread(this);
setListener(controller);
setParent(parent);
this.setName("soot thread");
}
private String [] cmd;
private PrintStream sootOut;
public void run() {
final String [] cmdFinal = getCmd();
final PrintStream sootOutFinal = getSootOut();
try {
soot.G.reset();
soot.G.v().out = sootOutFinal;
InteractionController listener = getListener();
InteractionHandler.v().setInteractionListener(listener);
String mainClass = getMainClass();
String mainProject = null;
if(mainClass.contains(":")) {
String[] split = mainClass.split(":");
mainProject = split[0];
mainClass = split[1];
}
Class<?> toRun;
try {
ClassLoader loader;
if(mainProject!=null) {
IProject project = SootPlugin.getWorkspace().getRoot().getProject(mainProject);
if(project.exists() && project.isOpen() && project.hasNature("org.eclipse.jdt.core.javanature")) {
IJavaProject javaProject = JavaCore.create(project);
URL[] urls = SootClasspath.projectClassPath(javaProject);
loader = new URLClassLoader(urls,SootThread.class.getClassLoader());
} else {
final String mc = mainClass;
final Shell defaultShell = getShell();
getDisplay().syncExec(new Runnable() {
public void run() {
MessageDialog.openError(defaultShell, "Unable to find Soot Main Project", "Project "+mc+" does not exist," +
" is no Java project or is closed. Aborting...");
}
});
SootPlugin.getDefault().getConsole().clearConsole();
return;
}
} else {
loader = SootThread.class.getClassLoader();
}
toRun = loader.loadClass(mainClass);
} catch(final ClassNotFoundException e) {
final Shell defaultShell = getShell();
final String inProject = mainProject!=null ? (" in project "+mainProject):"";
getDisplay().syncExec(new Runnable() {
public void run() {
MessageDialog.openError(defaultShell, "Unable to find class", "Cannot find class"+inProject+". Aborting...\n"+e.getLocalizedMessage());
}
});
SootPlugin.getDefault().getConsole().clearConsole();
return;
}
Method [] meths = toRun.getDeclaredMethods();
Object [] args = new Object [1];
args[0] = cmdFinal;
for (int i = 0; i < meths.length; i++){
if (meths[i].getName().equals("main")){
Class<?>[] fields = meths[i].getParameterTypes();
if (fields.length == 1){
meths[i].invoke(toRun, args);
}
}
}
setCfgList(soot.Scene.v().getPkgList());
getParent().setCfgList(getCfgList());
}
catch (Exception e) {
System.out.println("Soot exception: "+e);
e.printStackTrace(sootOutFinal);
System.out.println(e.getCause());
}
}
private Shell getShell() {
getDisplay().syncExec(new Runnable() {
public void run() {
activeShell = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getShell();
}
});
return activeShell;
}
/**
* Returns the cmd.
* @return String
*/
public String [] getCmd() {
return cmd;
}
/**
* Returns the sootOut.
* @return PrintStream
*/
public PrintStream getSootOut() {
return sootOut;
}
/**
* Sets the cmd.
* @param cmd The cmd to set
*/
public void setCmd(String [] cmd) {
this.cmd = cmd;
}
/**
* Sets the sootOut.
* @param sootOut The sootOut to set
*/
public void setSootOut(PrintStream sootOut) {
this.sootOut = sootOut;
}
/**
* Returns the display.
* @return Display
*/
public Display getDisplay() {
return display;
}
/**
* Sets the display.
* @param display The display to set
*/
public void setDisplay(Display display) {
this.display = display;
}
/**
* @return
*/
public String getMainClass() {
return mainClass;
}
/**
* @param string
*/
public void setMainClass(String string) {
mainClass = string;
}
/**
* @return
*/
public ArrayList getCfgList() {
return cfgList;
}
/**
* @param list
*/
public void setCfgList(ArrayList list) {
cfgList = list;
}
/**
* @return
*/
public InteractionController getListener() {
return listener;
}
/**
* @param controller
*/
public void setListener(InteractionController controller) {
this.listener = controller;
}
/**
* @return
*/
public SootRunner getParent() {
return parent;
}
/**
* @param runner
*/
public void setParent(SootRunner runner) {
parent = runner;
}
}
| 6,667
| 23.880597
| 147
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/resources/EditorActivationListener.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.resources;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IPartListener;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import ca.mcgill.sable.soot.SootPlugin;
import ca.mcgill.sable.soot.attributes.*;
import org.eclipse.ui.texteditor.*;
public class EditorActivationListener implements IPartListener {
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
*/
public void partActivated(IWorkbenchPart part) {
if (!(part instanceof ITextEditor)) return;
IEditorPart activeEdPart = (IEditorPart)part;
SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
*/
public void partBroughtToTop(IWorkbenchPart part) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
*/
public void partClosed(IWorkbenchPart part) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
*/
public void partDeactivated(IWorkbenchPart part) {
// here not sure
}
/* (non-Javadoc)
* @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
*/
public void partOpened(IWorkbenchPart part) {
// maybe need to handle this as well
SootPlugin.getDefault().getPartManager().setUpdateForOpen(true);
}
}
| 2,577
| 32.480519
| 85
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/resources/Messages.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.resources;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
public class Messages {
private static final String BUNDLE_NAME = "ca.mcgill.sable.soot.resources.resources"; //$NON-NLS-1$
private static final ResourceBundle RESOURCE_BUNDLE =
ResourceBundle.getBundle(BUNDLE_NAME);
/**
*
*/
private Messages() {
}
/**
* @param key
* @return
*/
public static String getString(String key) {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}
}
| 1,417
| 28.541667
| 100
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/resources/SootDeltaVisitor.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.resources;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.*;
import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchWindow;
import ca.mcgill.sable.soot.*;
import ca.mcgill.sable.soot.editors.*;
public class SootDeltaVisitor implements IResourceDeltaVisitor {
/* (non-Javadoc)
* @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
*/
public boolean visit(IResourceDelta delta) throws CoreException {
switch (delta.getKind()) {
case IResourceDelta.CHANGED: {
int flags = delta.getFlags();
if ((flags & IResourceDelta.CONTENT) != 0) {
if (delta.getResource() instanceof IFile){
SootPlugin.getDefault().getManager().updateFileChangedFlag((IFile)delta.getResource());
String fileExtension = delta.getResource().getFullPath().getFileExtension();
if (fileExtension != null && fileExtension.equals(SootResourceManager.JIMPLE_FILE_EXT)){
updateJimpleOutline((IFile)delta.getResource());
}
}
}
break;
}
case IResourceDelta.ADDED: {
SootPlugin.getDefault().getManager().addToLists(delta.getResource());
if (delta.getResource() instanceof IFile){
String fileExtension = delta.getResource().getFullPath().getFileExtension();
if (fileExtension != null && fileExtension.equals(SootResourceManager.JIMPLE_FILE_EXT)){
updateJimpleOutline((IFile)delta.getResource());
}
}
}
}
return true;
}
// only updates after a save or Soot run
// (if editor is currently "dirty" the outline will be potenially incorrect
private void updateJimpleOutline(IFile file) {
IWorkbenchWindow activeWorkbenchWindow = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
if(activeWorkbenchWindow==null) return;
IEditorReference [] refs = activeWorkbenchWindow.getActivePage().getEditorReferences();
for (int i = 0; i < refs.length; i++){
if (refs[i] == null) continue;
if (refs[i].getName() == null) continue;
if (refs[i].getName().equals(file.getName())){
JimpleEditor ed = (JimpleEditor) refs[i].getEditor(true).getAdapter(JimpleEditor.class);
if (ed != null){
if (ed.getPage() != null){
ed.getPage().getContentOutline();
ed.getPage().getViewer().setInput(ed.getPage().getContentOutline());
ed.getPage().getViewer().refresh();
ed.getPage().getViewer().expandAll();
}
}
}
}
}
}
| 3,328
| 31.960396
| 109
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/resources/SootPartManager.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.resources;
import org.eclipse.ui.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.jdt.core.*;
import org.eclipse.jface.text.ITextOperationTarget;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.ui.*;
import org.eclipse.ui.texteditor.AbstractTextEditor;
import ca.mcgill.sable.soot.attributes.*;
import ca.mcgill.sable.soot.editors.JimpleEditor;
import ca.mcgill.sable.soot.ui.*;
import ca.mcgill.sable.soot.*;
import java.util.*;
public class SootPartManager {
private boolean updateForOpen;
public void updatePart(IEditorPart part){
if (part == null) return;
if (part instanceof JimpleEditor){
AbstractAttributesComputer aac = new JimpleAttributesComputer();
SootAttributesJimpleColorer sajc = new SootAttributesJimpleColorer();
SootAttrJimpleIconGenerator saji = new SootAttrJimpleIconGenerator();
SourceViewer viewer = (SourceViewer)((AbstractTextEditor)part).getAdapter(ITextOperationTarget.class);
SootAttributesHandler handler = aac.getAttributesHandler((AbstractTextEditor)part);
if (handler != null){
if (isUpdateForOpen() || handler.isUpdate()){
sajc.setEditorPart(part);
sajc.setViewer(viewer);
sajc.setHandler(handler);
Thread cThread = new Thread(sajc);
cThread.start();
saji.setHandler(handler);
saji.setRec((IFile)aac.getRec());
Thread iThread = new Thread(saji);
iThread.start();
handler.setUpdate(false);
}
}
handleKeys(handler);
handleTypes(handler, (IFile)aac.getRec());
}
else if (part instanceof AbstractTextEditor){
IEditorInput input= ((AbstractTextEditor)part).getEditorInput();
IJavaElement jElem = (IJavaElement) ((IAdaptable) input).getAdapter(IJavaElement.class);
if (!(jElem instanceof ICompilationUnit)) return;
AbstractAttributesComputer aac = new JavaAttributesComputer();
SootAttributesJavaColorer sajc = new SootAttributesJavaColorer();
SootAttrJavaIconGenerator saji = new SootAttrJavaIconGenerator();
SourceViewer viewer = (SourceViewer)((AbstractTextEditor)part).getAdapter(ITextOperationTarget.class);
SootAttributesHandler handler = aac.getAttributesHandler((AbstractTextEditor)part);
if (handler != null){
if (isUpdateForOpen() || handler.isUpdate()){
sajc.setEditorPart(part);
sajc.setViewer(viewer);
sajc.setHandler(handler);
Thread cThread = new Thread(sajc);
cThread.start();
saji.setHandler(handler);
saji.setRec((IFile)aac.getRec());
Thread iThread = new Thread(saji);
iThread.start();
handler.setUpdate(false);
}
}
handleKeys(handler);
handleTypes(handler, (IFile)aac.getRec());
}
setUpdateForOpen(false);
}
private void handleTypes(SootAttributesHandler handler, IFile file){
IWorkbenchPage page = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
ArrayList types = computeTypes(handler);
if (!types.isEmpty()){
IViewPart view = page.findView(ISootConstants.ANALYSIS_TYPES_VIEW_ID);
try {
if (view == null) {
IWorkbenchPart activePart = page.getActivePart();
page.showView(ISootConstants.ANALYSIS_TYPES_VIEW_ID);
//restore focus stolen by the creation of the console
IViewPart shownPart = page.findView(ISootConstants.ANALYSIS_TYPES_VIEW_ID);
if (shownPart != null){
((AnalysisTypeView)shownPart).setFile(file);
((AnalysisTypeView)shownPart).setAllTypesChecked(handler.isShowAllTypes());
((AnalysisTypeView)shownPart).setTypesChecked(handler.getTypesToShow());
((AnalysisTypeView)shownPart).setInputTypes(types);
}
page.activate(activePart);
}
else {
if (view != null){
((AnalysisTypeView)view).setFile(file);
((AnalysisTypeView)view).setAllTypesChecked(handler.isShowAllTypes());
((AnalysisTypeView)view).setTypesChecked(handler.getTypesToShow());
((AnalysisTypeView)view).setInputTypes(types);
}
}
}
catch (PartInitException pie) {
System.out.println(pie.getMessage());
}
}
}
private ArrayList computeTypes(SootAttributesHandler handler){
ArrayList types = new ArrayList();
if ((handler != null) && (handler.getAttrList() != null)){
Iterator attrsIt = handler.getAttrList().iterator();
while (attrsIt.hasNext()){
SootAttribute sa = (SootAttribute)attrsIt.next();
Iterator typesIt = sa.getAnalysisTypes().iterator();
while (typesIt.hasNext()){
String val = (String)typesIt.next();
if (!types.contains(val)){
types.add(val);
}
}
}
}
return types;
}
private void handleKeys(SootAttributesHandler handler){
// make a new view and put it in properties
// area (bring to top if necessary - make list of keys
IWorkbenchPage page = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage();
IViewPart viewPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ISootConstants.ANALYSIS_KEY_VIEW_ID);
try {
if (viewPart == null) {
IWorkbenchPart activePart = page.getActivePart();
page.showView(ISootConstants.ANALYSIS_KEY_VIEW_ID);
//restore focus stolen by the creation of the console
IViewPart shownPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().findView(ISootConstants.ANALYSIS_KEY_VIEW_ID);
if (shownPart != null){
((AnalysisKeyView)shownPart).setInputKeys(handler.getKeyList());
}
page.activate(activePart);
}
else {
if (viewPart != null){
((AnalysisKeyView)viewPart).setInputKeys(handler.getKeyList());
}
}
}
catch (PartInitException pie) {
System.out.println(pie.getMessage());
}
if (viewPart != null){
((AnalysisKeyView)viewPart).setInputKeys(handler.getKeyList());
}
}
/**
* @return
*/
public boolean isUpdateForOpen() {
return updateForOpen;
}
/**
* @param b
*/
public void setUpdateForOpen(boolean b) {
updateForOpen = b;
}
}
| 6,965
| 32.330144
| 155
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/resources/SootResourceManager.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.resources;
import java.util.*;
import org.eclipse.core.resources.*;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.jface.text.ITextListener;
import org.eclipse.jface.text.TextEvent;
import org.eclipse.jface.text.TextPresentation;
import ca.mcgill.sable.soot.attributes.SootAttributesHandler;
public class SootResourceManager implements IResourceChangeListener, ITextListener {
private static final String JAVA_FILE_EXT = Messages.getString("SootResourceManager.java"); //$NON-NLS-1$
public static final String JIMPLE_FILE_EXT = Messages.getString("SootResourceManager.jimple"); //$NON-NLS-1$
private static final int SOOT_RAN_BIT = 1;
private static final int CHANGED_BIT = 0;
private HashMap filesWithAttributes;
private HashMap changedResources;
private HashMap colorList;
public SootResourceManager() {
ResourcesPlugin.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.POST_CHANGE);
}
public void textChanged(TextEvent e){
}
public void updateSootRanFlag(){
if (getChangedResources() == null) return;
Iterator it = getChangedResources().keySet().iterator();
while (it.hasNext()){
BitSet bits = (BitSet)getChangedResources().get(it.next());
bits.set(SOOT_RAN_BIT);
bits.clear(CHANGED_BIT);
}
setColorList(null);
}
public void updateFileChangedFlag(IFile file){
if (file.getFileExtension() == null) return;
if ((file.getFileExtension().equals(JAVA_FILE_EXT)) ||
(file.getFileExtension().equals(JIMPLE_FILE_EXT))){
if (getChangedResources() == null){
addToLists(file);
}
else if (getChangedResources().get(file) == null){
addToLists(file);
}
((BitSet)getChangedResources().get(file)).set(CHANGED_BIT);
}
}
public void clearColors(){
// clear colors
if (getColorList() != null){
Iterator it = getColorList().keySet().iterator();
while (it.hasNext()){
((TextPresentation)getColorList().get(it.next())).clear();
}
}
}
public boolean isFileMarkersUpdate(IFile file){
if (getChangedResources() == null) return false;
if (getChangedResources().get(file) == null) return false;
return ((BitSet)getChangedResources().get(file)).get(SOOT_RAN_BIT);
}
public void setToFalseUpdate(IFile file){
if (getChangedResources() == null) return;
if (getChangedResources().get(file) == null) return;
((BitSet)getChangedResources().get(file)).clear(SOOT_RAN_BIT);
}
public void setToFalseRemove(IFile file){
if (getChangedResources() == null) return;
if (getChangedResources().get(file) == null) return;
((BitSet)getChangedResources().get(file)).clear(CHANGED_BIT);
}
public boolean isFileMarkersRemove(IFile file){
if (getChangedResources() == null) return false;
if (getChangedResources().get(file) == null) return false;
return ((BitSet)getChangedResources().get(file)).get(CHANGED_BIT);
}
public void addToLists(IResource res){
if (res instanceof IFile){
IFile file = (IFile)res;
if (file.getFileExtension() == null) return;
if ((file.getFileExtension().equals(JAVA_FILE_EXT)) ||
(file.getFileExtension().equals(JIMPLE_FILE_EXT))){
if (getChangedResources() == null){
setChangedResources(new HashMap());
}
getChangedResources().put(file, new BitSet(2));
}
}
}
/* (non-Javadoc)
* @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
*/
public void resourceChanged(IResourceChangeEvent event) {
switch(event.getType()){
case IResourceChangeEvent.POST_CHANGE:{
try {
event.getDelta().accept(new SootDeltaVisitor());
}
catch (CoreException e){
}
break;
}
}
}
public HashMap getChangedResources() {
return changedResources;
}
/**
* @param map
*/
public void setChangedResources(HashMap map) {
changedResources = map;
}
public void addToFileWithAttributes(IFile file, SootAttributesHandler handler){
if (getFilesWithAttributes() == null){
setFilesWithAttributes(new HashMap());
}
getFilesWithAttributes().put(file, handler);
}
public SootAttributesHandler getAttributesHandlerForFile(IFile file){
if (getFilesWithAttributes() == null) {
return null;
}
else return (SootAttributesHandler)getFilesWithAttributes().get(file);
}
// colors
public void addToColorList(IFile file, TextPresentation tp){
if (getColorList() == null){
setColorList(new HashMap());
}
getColorList().put(file, tp);
}
public boolean alreadyOnColorList(IFile file){
if (getColorList() == null) return false;
else return getColorList().containsKey(file);
}
/**
* @return
*/
public HashMap getFilesWithAttributes() {
return filesWithAttributes;
}
/**
* @param map
*/
public void setFilesWithAttributes(HashMap map) {
filesWithAttributes = map;
}
/**
* @return
*/
public HashMap getColorList() {
return colorList;
}
/**
* @param map
*/
public void setColorList(HashMap map) {
colorList = map;
}
}
| 5,891
| 25.421525
| 124
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/resources/SootWorkbenchListener.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2004 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
package ca.mcgill.sable.soot.resources;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWindowListener;
import org.eclipse.ui.IWorkbenchWindow;
import ca.mcgill.sable.soot.SootPlugin;
public class SootWorkbenchListener implements IWindowListener {
private boolean initialized = false;
/* (non-Javadoc)
* @see org.eclipse.ui.IWindowListener#windowActivated(org.eclipse.ui.IWorkbenchWindow)
*/
public void windowActivated(IWorkbenchWindow window) {
if (!initialized){
window.getActivePage().addPartListener(new EditorActivationListener());
IEditorPart activeEdPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
initialized = true;
}
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWindowListener#windowDeactivated(org.eclipse.ui.IWorkbenchWindow)
*/
public void windowDeactivated(IWorkbenchWindow window) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWindowListener#windowClosed(org.eclipse.ui.IWorkbenchWindow)
*/
public void windowClosed(IWorkbenchWindow window) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IWindowListener#windowOpened(org.eclipse.ui.IWorkbenchWindow)
*/
public void windowOpened(IWorkbenchWindow window) {
window.getActivePage().addPartListener(new EditorActivationListener());
IEditorPart activeEdPart = SootPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
SootPlugin.getDefault().getPartManager().updatePart(activeEdPart);
}
}
| 2,454
| 34.57971
| 133
|
java
|
soot
|
soot-master/eclipse/ca.mcgill.sable.soot/src/ca/mcgill/sable/soot/testing/OptionsDialog.java
|
/* Soot - a J*va Optimization Framework
* Copyright (C) 2003 Jennifer Lhotak
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* This class is generated automajically from xml - DO NO EDIT - as
* changes will be over written
*
* The purpose of this class is to automajically generate a options
* dialog in the event that options change
*
* Taking options away - should not damage the dialog
* Adding new sections of options - should not damage the dialog
* Adding new otpions to sections (of known option type) - should not
* damage the dialog
*
* Adding new option types will break the dialog (option type widgets
* will need to be created)
*
*/
package ca.mcgill.sable.soot.testing;
//import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.swt.widgets.*;
//import org.eclipse.swt.*;
//import org.eclipse.swt.layout.*;
//import ca.mcgill.sable.soot.SootPlugin;
public class OptionsDialog {//extends AbstractOptionsDialog {
public OptionsDialog(Shell parentShell) {
//super(parentShell);
}
/*/**
* each section gets initialize as a stack layer in pageContainer
* the area containing the options
*/
/*protected void initializePageContainer() {
Composite generalOptsChild = generalOptsCreate(getPageContainer());
Composite inputOptsChild = inputOptsCreate(getPageContainer());
Composite outputOptsChild = outputOptsCreate(getPageContainer());
Composite processingOptsChild = processingOptsCreate(getPageContainer());
Composite singleFileOptsChild = singleFileOptsCreate(getPageContainer());
Composite appOptsChild = appOptsCreate(getPageContainer());
Composite inputAttrOptsChild = inputAttrOptsCreate(getPageContainer());
Composite annotationOptsChild = annotationOptsCreate(getPageContainer());
Composite miscOptsChild = miscOptsCreate(getPageContainer());
}
/**
* all options get saved as <alias, value> pair
*/
/*protected void okPressed() {
IDialogSettings settings = SootPlugin.getDefault().getDialogSettings();
Control [] elements;
settings.put(gethelp_widget().getAlias(), gethelp_widget().getButton().getSelection());
settings.put(getversion_widget().getAlias(), getversion_widget().getButton().getSelection());
settings.put(getverbose_widget().getAlias(), getverbose_widget().getButton().getSelection());
settings.put(getappMode_widget().getAlias(), getappMode_widget().getButton().getSelection());
settings.put(getclasspath_widget().getAlias(), getclasspath_widget().getText().getText());
settings.put(getsrcPrec_widget().getAlias(), getsrcPrec_widget().getSelectedAlias());
settings.put(getoutputDir_widget().getAlias(), getoutputDir_widget().getText().getText());
settings.put(getoutputFormat_widget().getAlias(), getoutputFormat_widget().getSelectedAlias());
settings.put(getoptimize_widget().getAlias(), getoptimize_widget().getButton().getSelection());
settings.put(getwholeOptimize_widget().getAlias(), getwholeOptimize_widget().getButton().getSelection());
settings.put(getprocPath_widget().getAlias(), getprocPath_widget().getText().getText());
settings.put(getanalyzeContext_widget().getAlias(), getanalyzeContext_widget().getButton().getSelection());
settings.put(getincPackage_widget().getAlias(), getincPackage_widget().getText().getText());
settings.put(getexcPackage_widget().getAlias(), getexcPackage_widget().getText().getText());
settings.put(getdynClasses_widget().getAlias(), getdynClasses_widget().getText().getText());
settings.put(getdynPath_widget().getAlias(), getdynPath_widget().getText().getText());
settings.put(getdynPackage_widget().getAlias(), getdynPackage_widget().getText().getText());
settings.put(getkeepLineNum_widget().getAlias(), getkeepLineNum_widget().getButton().getSelection());
settings.put(getkeepByteOffset_widget().getAlias(), getkeepByteOffset_widget().getButton().getSelection());
settings.put(getnullPointerAnn_widget().getAlias(), getnullPointerAnn_widget().getButton().getSelection());
settings.put(getarrayBoundsAnn_widget().getAlias(), getarrayBoundsAnn_widget().getButton().getSelection());
settings.put(gettime_widget().getAlias(), gettime_widget().getButton().getSelection());
settings.put(getsubGC_widget().getAlias(), getsubGC_widget().getButton().getSelection());
super.okPressed();
}
/**
* the initial input of selection tree corresponds to each section
* at some point sections will have sub-sections which will be
* children of branches (ie phase - options)
*/
/*protected SootOption getInitialInput() {
SootOption root = new SootOption("");
SootOption generalOpts_branch = new SootOption("General Options");
root.addChild(generalOpts_branch);
SootOption inputOpts_branch = new SootOption("Input Options");
root.addChild(inputOpts_branch);
SootOption outputOpts_branch = new SootOption("Output Options");
root.addChild(outputOpts_branch);
SootOption processingOpts_branch = new SootOption("Processing Options");
root.addChild(processingOpts_branch);
SootOption singleFileOpts_branch = new SootOption("Single File Mode Options");
root.addChild(singleFileOpts_branch);
SootOption appOpts_branch = new SootOption("Application Mode Options");
root.addChild(appOpts_branch);
SootOption inputAttrOpts_branch = new SootOption("Input Attribute Options");
root.addChild(inputAttrOpts_branch);
SootOption annotationOpts_branch = new SootOption("Annotation Options");
root.addChild(annotationOpts_branch);
SootOption miscOpts_branch = new SootOption("Miscellaneous Options");
root.addChild(miscOpts_branch);
return root;
}
/**
* each setion gets initalized with a composite
* containing widgets of option type
*/
/*private BooleanOptionWidget help_widget;
private void sethelp_widget(BooleanOptionWidget widget) {
help_widget = widget;
}
private BooleanOptionWidget gethelp_widget() {
return help_widget;
}
private BooleanOptionWidget version_widget;
private void setversion_widget(BooleanOptionWidget widget) {
version_widget = widget;
}
private BooleanOptionWidget getversion_widget() {
return version_widget;
}
private BooleanOptionWidget verbose_widget;
private void setverbose_widget(BooleanOptionWidget widget) {
verbose_widget = widget;
}
private BooleanOptionWidget getverbose_widget() {
return verbose_widget;
}
private BooleanOptionWidget appMode_widget;
private void setappMode_widget(BooleanOptionWidget widget) {
appMode_widget = widget;
}
private BooleanOptionWidget getappMode_widget() {
return appMode_widget;
}
private Composite generalOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("General Options");
sethelp_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Help", "h", "display help and exit")));
setversion_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Version", "version", "output version information and exit")));
setverbose_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Verbose", "v", "verbose mode")));
setappMode_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Application Mode", "app", "runs in application mode")));
return editGroup;
}
private ListOptionWidget classpath_widget;
private void setclasspath_widget(ListOptionWidget widget) {
classpath_widget = widget;
}
private ListOptionWidget getclasspath_widget() {
return classpath_widget;
}
MultiOptionWidget srcPrec_widget;
private void setsrcPrec_widget(MultiOptionWidget widget) {
srcPrec_widget = widget;
}
private MultiOptionWidget getsrcPrec_widget() {
return srcPrec_widget;
}
private Composite inputOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Input Options");
OptionData [] data = new OptionData [] {
new OptionData("Class File",
"c",
"Use class for source of Soot",
true),
new OptionData("Jimple File",
"J",
"Use Jimple for source of Soot",
false),
};
setsrcPrec_widget(new MultiOptionWidget(editGroup, SWT.NONE, data, new OptionData("Input Source Precedence", "src-prec", "sets the source precedence for Soot")));
setclasspath_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Soot Classpath", "cp", "uses given PATH as the classpath for finding classes for Soot processing")));
return editGroup;
}
private StringOptionWidget outputDir_widget;
private void setoutputDir_widget(StringOptionWidget widget) {
outputDir_widget = widget;
}
private StringOptionWidget getoutputDir_widget() {
return outputDir_widget;
}
MultiOptionWidget outputFormat_widget;
private void setoutputFormat_widget(MultiOptionWidget widget) {
outputFormat_widget = widget;
}
private MultiOptionWidget getoutputFormat_widget() {
return outputFormat_widget;
}
private Composite outputOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Output Options");
OptionData [] data = new OptionData [] {
new OptionData("Jimp File",
"j",
"produce .jimp (abbreviated .jimple) files",
false),
new OptionData("Njimple File",
"njimple",
"produce .njimple files",
false),
new OptionData("Jimple File",
"J",
"produce .jimple code",
false),
new OptionData("Baf File",
"B",
"produce .baf code",
false),
new OptionData("Aggregated Baf File",
"b",
"produce .b (abbreviated .baf) files",
false),
new OptionData("Grimp File",
"g",
"produce .grimp (abbreviated .grimple) files",
false),
new OptionData("Grimple File",
"G",
"produce .grimple files",
false),
new OptionData("Xml File",
"X",
"produce .xml files",
false),
new OptionData("No Output File",
"n",
"produces no output",
false),
new OptionData("Jasmin File",
"s",
"produce .jasmin files",
false),
new OptionData("Jasmin Through Grimp File",
"jasmin-through-grimp",
"produce .jasmin files using grimp as final IR?",
false),
new OptionData("Class File",
"c",
"produce .class files",
true),
new OptionData("Class Through Grimp File",
"class-through-grimp",
"produce .class files using grimp as final IR?",
false),
new OptionData("Dava Decompiled File",
"d",
"produce dava decompiled .java files",
false),
};
setoutputFormat_widget(new MultiOptionWidget(editGroup, SWT.NONE, data, new OptionData("Output Format", "o", "sets the source precedence for Soot")));
setoutputDir_widget(new StringOptionWidget(editGroup, SWT.NONE, new OptionData("Output Directory", "d", "store produced files in PATH")));
return editGroup;
}
private BooleanOptionWidget optimize_widget;
private void setoptimize_widget(BooleanOptionWidget widget) {
optimize_widget = widget;
}
private BooleanOptionWidget getoptimize_widget() {
return optimize_widget;
}
private BooleanOptionWidget wholeOptimize_widget;
private void setwholeOptimize_widget(BooleanOptionWidget widget) {
wholeOptimize_widget = widget;
}
private BooleanOptionWidget getwholeOptimize_widget() {
return wholeOptimize_widget;
}
private Composite processingOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Processing Options");
setoptimize_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Optimize", "O", "perform scalar optimizations on the classfiles")));
setwholeOptimize_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Whole Program Optimize", "W", "perform whole program optimizations on the classfiles")));
return editGroup;
}
private ListOptionWidget procPath_widget;
private void setprocPath_widget(ListOptionWidget widget) {
procPath_widget = widget;
}
private ListOptionWidget getprocPath_widget() {
return procPath_widget;
}
private Composite singleFileOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Single File Mode Options");
setprocPath_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Process Path", "process-path", "process all classes on the PATH")));
return editGroup;
}
private BooleanOptionWidget analyzeContext_widget;
private void setanalyzeContext_widget(BooleanOptionWidget widget) {
analyzeContext_widget = widget;
}
private BooleanOptionWidget getanalyzeContext_widget() {
return analyzeContext_widget;
}
private ListOptionWidget incPackage_widget;
private void setincPackage_widget(ListOptionWidget widget) {
incPackage_widget = widget;
}
private ListOptionWidget getincPackage_widget() {
return incPackage_widget;
}
private ListOptionWidget excPackage_widget;
private void setexcPackage_widget(ListOptionWidget widget) {
excPackage_widget = widget;
}
private ListOptionWidget getexcPackage_widget() {
return excPackage_widget;
}
private ListOptionWidget dynClasses_widget;
private void setdynClasses_widget(ListOptionWidget widget) {
dynClasses_widget = widget;
}
private ListOptionWidget getdynClasses_widget() {
return dynClasses_widget;
}
private ListOptionWidget dynPath_widget;
private void setdynPath_widget(ListOptionWidget widget) {
dynPath_widget = widget;
}
private ListOptionWidget getdynPath_widget() {
return dynPath_widget;
}
private ListOptionWidget dynPackage_widget;
private void setdynPackage_widget(ListOptionWidget widget) {
dynPackage_widget = widget;
}
private ListOptionWidget getdynPackage_widget() {
return dynPackage_widget;
}
private Composite appOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE);
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Application Mode Options");
setanalyzeContext_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Analyze Context", "a", "label context classes as library")));
setincPackage_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Include Package", "i", "marks classfiles in PACKAGE (e.g. java.util.)as application classes")));
setexcPackage_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Exclude Package", "x", "marks classfiles in PACKAGE (e.g. java.) as context classes")));
setdynClasses_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Dynamic Classes", "dynamic-classes", "marks CLASSES (separated by colons) as potentially dynamic classes")));
setdynPath_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Dynamic Path", "dynamic-path", "marks all class files in PATH as potentially dynamic classes")));
setdynPackage_widget(new ListOptionWidget(editGroup, SWT.NONE, new OptionData("Dynamic Package", "dynamic-package", "marks classfiles in PACKAGES (separated by commas) as potentially dynamic classes")));
return editGroup;
}
private BooleanOptionWidget keepLineNum_widget;
private void setkeepLineNum_widget(BooleanOptionWidget widget) {
keepLineNum_widget = widget;
}
private BooleanOptionWidget getkeepLineNum_widget() {
return keepLineNum_widget;
}
private BooleanOptionWidget keepByteOffset_widget;
private void setkeepByteOffset_widget(BooleanOptionWidget widget) {
keepByteOffset_widget = widget;
}
private BooleanOptionWidget getkeepByteOffset_widget() {
return keepByteOffset_widget;
}
private Composite inputAttrOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE );
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Input Attribute Options");
setkeepLineNum_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Keep Line Number", "keep-line-number", "keep line number tables")));
setkeepByteOffset_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Keep Bytecode Offset", "keep-bytecode-offset", "attach bytecode offset to jimple statement")));
return editGroup;
}
private BooleanOptionWidget nullPointerAnn_widget;
private void setnullPointerAnn_widget(BooleanOptionWidget widget) {
nullPointerAnn_widget = widget;
}
private BooleanOptionWidget getnullPointerAnn_widget() {
return nullPointerAnn_widget;
}
private BooleanOptionWidget arrayBoundsAnn_widget;
private void setarrayBoundsAnn_widget(BooleanOptionWidget widget) {
arrayBoundsAnn_widget = widget;
}
private BooleanOptionWidget getarrayBoundsAnn_widget() {
return arrayBoundsAnn_widget;
}
private Composite annotationOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE );
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Annotation Options");
setnullPointerAnn_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Null Pointer Annotation", "annot-nullpointer", "turn on the annotation for null pointer")));
setarrayBoundsAnn_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Array Bounds Annotation", "annot-arraybounds", "turn on the annotation for array bounds check")));
return editGroup;
}
private BooleanOptionWidget time_widget;
private void settime_widget(BooleanOptionWidget widget) {
time_widget = widget;
}
private BooleanOptionWidget gettime_widget() {
return time_widget;
}
private BooleanOptionWidget subGC_widget;
private void setsubGC_widget(BooleanOptionWidget widget) {
subGC_widget = widget;
}
private BooleanOptionWidget getsubGC_widget() {
return subGC_widget;
}
private Composite miscOptsCreate(Composite parent) {
Group editGroup = new Group(parent, SWT.NONE );
GridLayout layout = new GridLayout();
editGroup.setLayout(layout);
editGroup.setText("Miscellaneous Options");
settime_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Time", "time", "print out time statistics about tranformations")));
setsubGC_widget(new BooleanOptionWidget(editGroup, SWT.NONE, new OptionData("Subtract Garbage Collection Time", "subtract-gc", "attempt to subtract the gc from the time stats")));
return editGroup;
}*/
}
| 20,384
| 27.590463
| 205
|
java
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.