convert default pruning policy into public singleton
This commit is contained in:
parent
30d6a458c3
commit
dcfd813ced
|
@ -0,0 +1,34 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2007 IBM Corporation.
|
||||
* All rights reserved. This program and the accompanying materials
|
||||
* are made available under the terms of the Eclipse Public License v1.0
|
||||
* which accompanies this distribution, and is available at
|
||||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* IBM Corporation - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package com.ibm.wala.ipa.callgraph.pruned;
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
|
||||
/**
|
||||
* Keeps a given CGNode if it stems from application code
|
||||
* @author Martin Mohr
|
||||
*
|
||||
*/
|
||||
public class ApplicationLoaderPolicy implements PruningPolicy {
|
||||
|
||||
public static final ApplicationLoaderPolicy INSTANCE = new ApplicationLoaderPolicy();
|
||||
|
||||
private ApplicationLoaderPolicy() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean check(CGNode n) {
|
||||
return n.getMethod().getDeclaringClass().getClassLoader().getName().equals(AnalysisScope.APPLICATION);
|
||||
}
|
||||
|
||||
}
|
|
@ -6,28 +6,13 @@ import java.util.LinkedList;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import com.ibm.wala.ipa.callgraph.AnalysisScope;
|
||||
import com.ibm.wala.ipa.callgraph.CGNode;
|
||||
import com.ibm.wala.ipa.callgraph.CallGraph;
|
||||
|
||||
|
||||
public final class CallGraphPruning {
|
||||
|
||||
/**
|
||||
* Keeps a given CGNode if it stems from application code
|
||||
* @author Martin Mohr
|
||||
*
|
||||
*/
|
||||
private class ApplicationLoaderPolicy implements PruningPolicy {
|
||||
|
||||
@Override
|
||||
public boolean check(CGNode n) {
|
||||
return n.getMethod().getDeclaringClass().getClassLoader().getName().equals(AnalysisScope.APPLICATION);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public CallGraphPruning(CallGraph cg) {
|
||||
public CallGraphPruning(CallGraph cg) {
|
||||
this.cg = cg;
|
||||
}
|
||||
|
||||
|
@ -58,7 +43,7 @@ public final class CallGraphPruning {
|
|||
* @return Set of relevant callgraph nodes.
|
||||
*/
|
||||
public Set<CGNode> findApplicationNodes(final int depth) {
|
||||
return findNodes(depth, new ApplicationLoaderPolicy());
|
||||
return findNodes(depth, ApplicationLoaderPolicy.INSTANCE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue