Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the main class isn't unique issue #241

Merged
merged 1 commit into from
Nov 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.eclipse.core.runtime.Status;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.search.IJavaSearchConstants;
import org.eclipse.jdt.core.search.IJavaSearchScope;
import org.eclipse.jdt.core.search.SearchEngine;
Expand Down Expand Up @@ -97,7 +98,7 @@ public static List<IJavaProject> getJavaProjectFromType(String fullyQualifiedTyp
fullyQualifiedTypeName = splitItems[1];
}
final String moduleName = splitItems.length == 2 ? splitItems[0] : null;

final String className = fullyQualifiedTypeName;
SearchPattern pattern = SearchPattern.createPattern(
fullyQualifiedTypeName,
IJavaSearchConstants.TYPE,
Expand All @@ -109,9 +110,11 @@ public static List<IJavaProject> getJavaProjectFromType(String fullyQualifiedTyp
@Override
public void acceptSearchMatch(SearchMatch match) {
Object element = match.getElement();
if (element instanceof IJavaElement) {
IJavaProject project = ((IJavaElement) element).getJavaProject();
if (moduleName == null || moduleName.equals(JdtUtils.getModuleName(project))) {
if (element instanceof IType) {
IType type = (IType) element;
IJavaProject project = type.getJavaProject();
if (className.equals(type.getFullyQualifiedName())
&& (moduleName == null || moduleName.equals(JdtUtils.getModuleName(project)))) {
projects.add(project);
}
}
Expand Down