本文整理汇总了Java中jdepend.framework.JDepend类的典型用法代码示例。如果您正苦于以下问题:Java JDepend类的具体用法?Java JDepend怎么用?Java JDepend使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JDepend类属于jdepend.framework包,在下文中一共展示了JDepend类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: of
import jdepend.framework.JDepend; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public static PackageAnalyser of(File classDir, final String packagePrefix) {
final PackageFilter filter = new PackageFilter() {
@Override
public boolean accept(String name) {
return name.startsWith(packagePrefix);
}
};
final JDepend depend = new JDepend(filter);
try {
depend.addDirectory(classDir.getPath());
} catch (final IOException e) {
throw new RuntimeException(e);
}
final Collection<JavaPackage> packages = depend.analyze();
return new PackageAnalyser(packages);
}
示例2: runJDepend
import jdepend.framework.JDepend; //导入依赖的package包/类
/**
* @param treeObjects not null
* @return non null list
*/
protected List<JavaPackage> runJDepend(JDepend jdepend, TreeObject[] treeObjects) {
for (int i = 0; i < treeObjects.length; i++) {
try {
if(!treeObjects[i].isLeaf()){
TreeFolder folder = (TreeFolder)treeObjects[i];
// add roots
ArrayList<String> dirs = folder.getClassesLocation();
for (int j = 0; j < dirs.size(); j++) {
jdepend.addDirectory("" + dirs.get(j)); //$NON-NLS-1$
}
}
} catch (Exception e) {
// if directory doesn't exist, may be project need to be rebuild
JDepend4EclipsePlugin.handle(e);
}
}
final List<?> packages = new ArrayList<Object>(jdepend.analyze());
List<JavaPackage> filteredPackages = filterPackages(packages, jdepend);
Collections.sort(filteredPackages, new PackageComparator(PackageComparator.byName()));
return filteredPackages;
}
示例3: getJDependInstance
import jdepend.framework.JDepend; //导入依赖的package包/类
public static JDepend getJDependInstance() {
PackageFilter filter = new PackageFilter();
IPreferenceStore settings = getDefault().getPreferenceStore();
if (settings.getBoolean(JDependConstants.PREF_USE_FILTERS)) {
String[] strings =
parseList(settings.getString(JDependConstants.PREF_ACTIVE_FILTERS_LIST));
for (String name : strings) {
if (name.endsWith(".*")) {
name = name.substring(0, name.length()-2);
}
filter.addPackage(name);
}
}
JDepend jdepend = new JDepend(filter);
return jdepend;
}
示例4: jdependProvider
import jdepend.framework.JDepend; //导入依赖的package包/类
@DataProvider(name = "jdependProvider")
@SuppressWarnings("checkstyle:multiplestringliterals")
public Object[][] jdependProvider() throws IOException {
final String[] configs = {"main", "test", "regr", "integ", "task"};
final Object[][] jdepends = new Object[configs.length][2];
for (int i = 0; i < configs.length; i += 1) {
final String config = configs[i];
try {
final JDepend jdepend = new JDepend();
addConfigDir(jdepend, config);
if (!"main".equals(config) && !"task".equals(config)) {
addConfigDir(jdepend, "main");
}
jdepend.analyze();
jdepends[i][0] = jdepend;
jdepends[i][1] = config;
}
catch (final IOException exception) {
log.error("Failed to initialize config [{}]", config, exception);
throw exception;
}
}
return jdepends;
}
示例5: setUp
import jdepend.framework.JDepend; //导入依赖的package包/类
protected void setUp() {
jdepend = new JDepend();
try {
String dirs = System.getProperty(BUILD_DIRS_LIST_PROPERTY, ".");
StringTokenizer tok = new StringTokenizer(dirs, ",");
while (tok.hasMoreTokens()) {
String dir = tok.nextToken().trim();
System.out.println("Analyzing source from " + dir);
jdepend.addDirectory(dir);
}
jdepend.analyzeTestClasses(false);
} catch (IOException ioe) {
ioe.printStackTrace();
fail(ioe.getMessage());
}
}
示例6: JDependProcessor
import jdepend.framework.JDepend; //导入依赖的package包/类
/**
* Constructs a <code>JDependProcessor</code> instance with the specified
* writer.
*
* @param writer Writer.
*/
public JDependProcessor(PrintWriter writer) {
analyzer = new jdepend.framework.JDepend();
formatter = NumberFormat.getInstance();
formatter.setMaximumFractionDigits(2);
setWriter(writer);
}
示例7: addPackageDependencies
import jdepend.framework.JDepend; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addPackageDependencies(
JDepend jdepend, Map<String, PackageDoc> packages, Set<Edge> edgesToRender) {
Map<String, PackageDoc> allPackages = APIviz.getPackages(root);
for (String pname: allPackages.keySet()) {
if (isHidden(allPackages.get(pname))) {
continue;
}
JavaPackage pkg = jdepend.getPackage(pname);
if (pkg == null) {
continue;
}
packages.put(pname, allPackages.get(pname));
Collection<JavaPackage> epkgs = pkg.getEfferents();
if (epkgs == null) {
continue;
}
for (JavaPackage epkg: epkgs) {
if (isHidden(allPackages.get(epkg.getName()))) {
continue;
}
addPackageDependency(edgesToRender, allPackages.get(pname), allPackages.get(epkg.getName()));
}
}
}
示例8: analyze
import jdepend.framework.JDepend; //导入依赖的package包/类
/**
* @return result of JDepend run, never null
*/
public List<JavaPackage> analyze(TreeFolder newRoot, IResource[] resource) {
resourceMap.clear();
if (resource == null) {
return new ArrayList<JavaPackage>();
}
JDepend jdepend = JDepend4EclipsePlugin.getJDependInstance();
PackageFilter filter = jdepend.getFilter();
for (int i = 0; i < resource.length; i++) {
TreeFolder [] tp = createTree(resource[i], filter);
for (int j = 0; j < tp.length; j++) {
// tree object check if child is exist
if(tp[j].hasChildren()) {
newRoot.addChild(tp[j]);
}
}
}
List<JavaPackage> packages = runJDepend(jdepend, newRoot.getChildren());
// update cycle info
// set cycle to true, if one of packages is under the founded tree root
for (int j = 0; j < packages.size(); j++) {
JavaPackage jp = packages.get(j);
boolean cycle = jp.containsCycle();
if(cycle){
if(jp.getName().length() == 0){
newRoot.setContainsCycle(cycle);
continue;
}
TreeObject child = newRoot.findChild(jp);
if(child != null && !child.isLeaf()){
((TreeFolder)child).setContainsCycle(cycle);
}
}
}
return packages;
}
示例9: filterPackages
import jdepend.framework.JDepend; //导入依赖的package包/类
private static List<JavaPackage> filterPackages(List<?> packages, JDepend jdepend){
ArrayList<JavaPackage> filteredPackages = new ArrayList<JavaPackage>();
PackageFilter filter = jdepend.getFilter();
for (int i = 0; i < packages.size(); i++) {
JavaPackage tempPackage = (JavaPackage)packages.get(i);
if(filter.accept(tempPackage.getName())){
filteredPackages.add(tempPackage);
}
}
return filteredPackages;
}
示例10: setUp
import jdepend.framework.JDepend; //导入依赖的package包/类
@Override
protected void setUp() throws Exception {
super.setUp();
// Get the classes root directory
String rootDirectory = getClass().getResource("/").getFile();
// Setup the JDepend analysis
engine = new JDepend();
engine.addDirectory(rootDirectory);
engine.analyze();
}
示例11: testNoUnexpectedCycles
import jdepend.framework.JDepend; //导入依赖的package包/类
@SuppressWarnings("unchecked")
@Test(dataProvider = "jdependProvider")
public void testNoUnexpectedCycles(final JDepend jdepend, final String config) {
final List<JavaPackage> cycles = new ArrayList<>();
for (final JavaPackage pkg : (Collection<JavaPackage>) jdepend.getPackages()) {
if (pkg.getName().startsWith(BASE_PACKAGE)
&& pkg.collectAllCycles(cycles)
&& isDirectCycle(cycles)) {
final Iterator<JavaPackage> iter = cycles.iterator();
assertThat(iter).hasNext();
assertThat(iter.next().getName()).isEqualTo(pkg.getName());
Set<String> expectedDeps = depsFor(pkg, config);
JavaPackage prev = pkg;
while (iter.hasNext()) {
try {
final JavaPackage dep = iter.next();
assertThat(expectedDeps).contains(dep.getName());
expectedDeps = depsFor(dep, config);
prev = dep;
}
catch (final AssertionError error) {
final String message =
String.format("Failed to analyze dependencies for package [%s], config [%s]",
prev.getName(), config);
throw new AssertionError(message, error);
}
}
cycles.clear();
}
}
}
示例12: initJdepend
import jdepend.framework.JDepend; //导入依赖的package包/类
/**
* Initializes {@link #jdepend}.
*
* @throws IOException when initialization fails
*/
@Before
public void initJdepend() throws IOException {
jdepend = new JDepend();
jdepend.addDirectory("target/classes");
jdepend.analyze();
}
示例13: setUp
import jdepend.framework.JDepend; //导入依赖的package包/类
protected void setUp() {
jdepend = new JDepend();
try {
String dir = System.getProperty("build.dir", ".");
jdepend.addDirectory(dir);
jdepend.analyzeTestClasses(false);
} catch (IOException ioe) {
ioe.printStackTrace();
fail(ioe.getMessage());
}
}
示例14: initJdepend
import jdepend.framework.JDepend; //导入依赖的package包/类
/**
* Initializes {@link JDepend}.
*
* @throws IOException when initialization fails
*/
@Before
public void initJdepend() throws IOException {
jdepend = new JDepend();
jdepend.addDirectory("target/classes");
jdepend.analyze();
}
示例15: setUpClass
import jdepend.framework.JDepend; //导入依赖的package包/类
@BeforeClass
public static void setUpClass() throws Exception
{
jdepend = new JDepend();
jdepend.addDirectory("target/classes");
}