DNW-depmap is an Eclipse plug-in to create Java code dependency map, which can be used by developers to help them easily find the influence of arbitrary code modifications.
- JDK 1.7 (Neo4j graph database's prerequisites)
- Eclipse 3.7 (code name Indigo)
- Import codetemplates.xml into
Preferences|Java|Code Style|Code Templates
. - Import codestyle.xml into
Preferences|Java|Code Style|Formatter
. - Format the code before commit. Thanks.
- Import codetemplates.xml into
- Download Neo4j v2.1.5 from the Neo4j site.
- Follow these instructions to install and deploy a local Neo4j server. But do NOT start the server at now!
- Fork this project and import it into Eclipse (the first Eclipse).
- Configure the value of variable
DBPATH
in filecom.dnw.depmap.Activator.java
to the database store directory of the local Neo4j server. - Build and run this project as an
Eclipse Application
(the second Eclipse). - In the second Eclipse, import a Java project which will be analyzed into the workspace.
- Build the imported Java project to make sure these's no syntax error.
- In the
Package Explorer
window, select one or more Java elements (may be Java files, packages, or even the Java project), right click on them and selectAnalyze Dependency
from the pop-up context menu. - Wait for done. (If there are a lot of Java files in the selection, it may be a long moment.)
- Startup the local Neo4j server, open a browser and navigate to http://localhost:7474/browser.
- Write Neo4j Cypher queries to manipulate the data generated by this program.
e.g.
match p=((:Class)-[:Declares]->(:Method)-[:Invokes]->(:Method)<-[:Declares]-(:Class {name:"java.lang.Object"})) return p
. (Refer to Neo4j Cypher Refcard 2.1.5.) - If you want to select some other Java files and re-generating the map data, please shutdown the local Neo4j server first, when generating is done, you can restart the Neo4j server and do some manipulations.
- Before generating a new map, this program will try to clear all data in the database, to avoid the newly generated data be mixed with the old data. But if the data is too huge, sometimes it will cause a memory overflow error. If this happens, please clear the database manully, excute some appropriate Cypher statements in browser, like
match ()-[r]-() match (n) delete r, n
.
- Node labeled
Type
will also be labeled eitherClass
orInterface
. - Node labeled
Class
denotes a Java class.- Property
name
: The qualified name of the class without type parameter. e.g.'java.util.ArrayList'
. - Property
caption
: The simple name (no package name) of the class without type parameter. e.g.'ArrayList'
. - Property
extends
: The qualified name of its superclass. e.g.'java.lang.Object'
. - Property
implements
: An array contains all names of interfaces which the class implements. e.g.['java.util.List']
. - Property
isAbstract
: Indicates if this is an abstract class.
- Property
- Node labeled
Interface
denotes a Java interface.- Property
name
: The qualified name of the interface without type parameter. e.g.'java.util.List'
. - Property
caption
: The simple name (no package name) of the interface without type parameter. e.g.'List'
. - Property
extends
: An array contains all names of interfaces which extends. e.g.['java.util.Collection']
.
- Property
- Relation type
Extends
denotes the class inheritance happened between twoClass
nodes, or the interface inheritance happened between twoInterface
nodes. - Relation type
Implements
denotes the interface implementation between aClass
node and aInterface
node. - Node labeled
Method
denotes a Java method.- Property
name
: Which consists of two parts: 1) the qualified name of its declaring class, 2) the method declaring, made by the method name and all the arguments' type names in parentheses.- For a static method, uses
'/'
as the delimiter. e.g.'java.util.Arrays/asList(java.lang.Object[])'
. - For a non-static method, uses
'#'
as the delimiter. e.g.'java.lang.Object#wait()'
.
- For a static method, uses
- Property
caption
: Which concatenates the method name and a pair of parentheses. e.g.'asList()'
. - Property
isAbstract
: Indicates if this is an abstract method.
- Property
- Relation type
Declares
denotes the method declaration, the from side should be aType
node, and the to side should be aMethod
node. - Relation type
Invokes
denotes the method invocation, it happens between twoMethod
nodes. - Relation type
Overrides
denotes the method override, it happens between twoMethod
nodes. There are two kinds of override: Superclass override and Interface override.- Superclass override: The method overrides a method which exists in the superclass of the declaring class.
- Interface override: The method overrides a method which exists in one or more interfaces that the declaring class implements.
Copyright (c) 2014 DNW Technologies and others.
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