Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from marcphilipp/better-markers
Markers on method names
- Loading branch information
Showing
5 changed files
with
51 additions
and
22 deletions.
There are no files selected for viewing
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
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
41 changes: 41 additions & 0 deletions
41
unused.methods/test/unused/methods/core/LineNumbersPdeTest.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,41 @@ | ||
package unused.methods.core; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.junit.Assert.assertThat; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.runtime.CoreException; | ||
import org.eclipse.jdt.core.IMethod; | ||
import org.eclipse.jdt.core.ISourceRange; | ||
import org.eclipse.jdt.core.SourceRange; | ||
import org.junit.Test; | ||
|
||
public class LineNumbersPdeTest extends PdeTestCaseWithTestProject { | ||
|
||
@Test | ||
public void findUnusedMethodsInProject() throws CoreException, IOException { | ||
List<IMethod> unusedMethods = calculateUnusedMethods(); | ||
|
||
IMethod lonelyMethod = findMethodByName(unusedMethods, "lonelyMethod"); | ||
assertThat(lonelyMethod.getNameRange(), is((ISourceRange) new SourceRange(128, 12))); | ||
|
||
IMethod lonelyStaticMethod = findMethodByName(unusedMethods, "lonelyStaticMethod"); | ||
assertThat(lonelyStaticMethod.getNameRange(), is((ISourceRange) new SourceRange(182, 18))); | ||
} | ||
|
||
private IMethod findMethodByName(List<IMethod> unusedMethods, String name) { | ||
for (IMethod method : unusedMethods) { | ||
if (name.equals(method.getElementName())) { | ||
return method; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
@Override | ||
protected String[] getTestFiles() { | ||
return new String[] { "/test/Movie.java", "/test/Actor.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