forked from davidburkhart/Unused-methods-eclipse-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
531a619
commit 81904dd
Showing
6 changed files
with
76 additions
and
4 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
unused.methods/pdetestsrc/test/SuperClassWithExplicitlyUsedConstructor.java_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package test; | ||
|
||
public class SuperClassWithExplicitlyUsedConstructor { | ||
|
||
public static void main(String args) { | ||
new Subclass(); | ||
} | ||
|
||
public SuperClassWithExplicitlyUsedConstructor() { | ||
} | ||
|
||
class Subclass extends SuperClassWithExplicitlyUsedConstructor { | ||
Subclass() { | ||
super(); | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
unused.methods/pdetestsrc/test/SuperClassWithUnusedConstructor.java_
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package test; | ||
|
||
public class SuperClassWithUnusedConstructor { | ||
|
||
public SuperClassWithUnusedConstructor() { | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
unused.methods/test/unused/methods/FindUnusedContructorsPdeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package unused.methods; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.CoreMatchers.not; | ||
import static org.junit.Assert.assertThat; | ||
import static org.junit.matchers.JUnitMatchers.hasItem; | ||
import static unused.methods.MethodWithName.methodWithName; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.jdt.core.IMethod; | ||
import org.eclipse.jdt.core.JavaModelException; | ||
import org.junit.Test; | ||
|
||
public class FindUnusedContructorsPdeTest extends PdeTestCaseWithTestProject { | ||
|
||
@Test | ||
public void findUnusedConstructorsInProject() throws CoreException, IOException { | ||
List<IMethod> result = calculateUnusedMethods(); | ||
assertThat(result, not(hasItem(methodWithName("SuperClassWithExplicitlyUsedConstructor")))); | ||
assertThat(result, hasItem(methodWithName("SuperClassWithUnusedConstructor"))); | ||
assertThat(result.size(), is(1)); | ||
} | ||
|
||
private List<IMethod> calculateUnusedMethods() throws JavaModelException { | ||
FindUnusedMethodsInJavaProject finder = new FindUnusedMethodsInJavaProject(project.asJavaProject()); | ||
finder.run(new NullProgressMonitor()); | ||
return finder.getUnusedMethods(); | ||
} | ||
|
||
@Override | ||
protected String[] getTestFiles() { | ||
return new String[] { "/test/SuperClassWithExplicitlyUsedConstructor.java", | ||
"/test/SuperClassWithUnusedConstructor.java" }; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters