diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java index 11dee52a0..50a7788f0 100644 --- a/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.dash/src/org/springframework/ide/eclipse/boot/dash/model/BootProjectDashElement.java @@ -86,7 +86,7 @@ public class BootProjectDashElement extends AbstractLaunchConfigurationsDashElem if (p != null && p.exists()) { IJavaProject jp = JavaCore.create(p); if (jp != null) { - IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[]{jp}, IJavaSearchScope.SOURCES); + IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(new IJavaElement[]{jp}, IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES); MainMethodSearchEngine engine = new MainMethodSearchEngine(); IType[] types = null; try { diff --git a/eclipse-extensions/org.springframework.ide.eclipse.boot.launch/src/org/springframework/ide/eclipse/boot/launch/MainTypeLaunchTabSection.java b/eclipse-extensions/org.springframework.ide.eclipse.boot.launch/src/org/springframework/ide/eclipse/boot/launch/MainTypeLaunchTabSection.java index 192fbcdfe..c56289c2f 100644 --- a/eclipse-extensions/org.springframework.ide.eclipse.boot.launch/src/org/springframework/ide/eclipse/boot/launch/MainTypeLaunchTabSection.java +++ b/eclipse-extensions/org.springframework.ide.eclipse.boot.launch/src/org/springframework/ide/eclipse/boot/launch/MainTypeLaunchTabSection.java @@ -164,7 +164,7 @@ public class MainTypeLaunchTabSection extends DelegatingLaunchConfigurationTabSe if (elements == null) { elements = new IJavaElement[]{}; } - int constraints = IJavaSearchScope.SOURCES; + int constraints = IJavaSearchScope.SOURCES | IJavaSearchScope.APPLICATION_LIBRARIES; IJavaSearchScope searchScope = SearchEngine.createJavaSearchScope(elements, constraints); MainMethodSearchEngine engine = new MainMethodSearchEngine(); IType[] types = null; diff --git a/eclipse-language-servers/org.springsource.ide.eclipse.commons.frameworks.core/src/org/springsource/ide/eclipse/commons/frameworks/core/maintype/MainTypeFinder.java b/eclipse-language-servers/org.springsource.ide.eclipse.commons.frameworks.core/src/org/springsource/ide/eclipse/commons/frameworks/core/maintype/MainTypeFinder.java index ebf45ec74..76787db07 100644 --- a/eclipse-language-servers/org.springsource.ide.eclipse.commons.frameworks.core/src/org/springsource/ide/eclipse/commons/frameworks/core/maintype/MainTypeFinder.java +++ b/eclipse-language-servers/org.springsource.ide.eclipse.commons.frameworks.core/src/org/springsource/ide/eclipse/commons/frameworks/core/maintype/MainTypeFinder.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2012, 2013 Pivotal Software, Inc. + * Copyright (c) 2012, 2025 Pivotal Software, Inc. * 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 @@ -96,18 +96,20 @@ public class MainTypeFinder { // confidence that they are the types requested. Each confidence itself also has a priority // order, with more authoritative finders listed first. this.algos.put(Confidence.CERTAIN, new IMainTypeFinder[] { - // add in order of which is more authoritative - }); - - this.algos.put(Confidence.HIGH, new IMainTypeFinder[] { // add more here if they should be considered more authorative new FindInPom() // add more here if they should be considered less authorative }); + this.algos.put(Confidence.HIGH, new IMainTypeFinder[] { + // add more here if they should be considered more authorative + new FindInSource(), + // add more here if they should be considered less authorative + }); + this.algos.put(Confidence.LOW, new IMainTypeFinder[] { // add more here if they should be considered more authorative - new FindInSource() + new FindInLibs() // add more here if they should be considered less authorative }); @@ -241,6 +243,33 @@ public class MainTypeFinder { ); } } + + public static class FindInLibs implements IMainTypeFinder { + + public IType[] findMain(IJavaProject javaProject, + IProgressMonitor monitor) throws Exception { + monitor.beginTask("Search main types in project source", 1); + try { + + MainMethodSearchEngine engine = new MainMethodSearchEngine(); + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(true, new IJavaElement[] { javaProject }, IJavaSearchScope.APPLICATION_LIBRARIES); + + boolean includeSubtypes = true; + IType[] types = engine + .searchMainMethods(monitor, scope, includeSubtypes); + if (types == null) { + types = EMPTY; + } + return types; + } catch (Exception e) { + FrameworkCoreActivator.log(e); + } finally { + monitor.done(); + } + return EMPTY; + } + + } /** * Confidence that a search result for main types in a project is what is expected.