|
1 | 1 | /*******************************************************************************
|
2 |
| - * Copyright (c) 2012, 2013 Pivotal Software, Inc. |
| 2 | + * Copyright (c) 2012, 2025 Pivotal Software, Inc. |
3 | 3 | * All rights reserved. This program and the accompanying materials
|
4 | 4 | * are made available under the terms of the Eclipse Public License v1.0
|
5 | 5 | * which accompanies this distribution, and is available at
|
@@ -96,18 +96,20 @@ private MainTypeFinder() {
|
96 | 96 | // confidence that they are the types requested. Each confidence itself also has a priority
|
97 | 97 | // order, with more authoritative finders listed first.
|
98 | 98 | this.algos.put(Confidence.CERTAIN, new IMainTypeFinder[] {
|
99 |
| - // add in order of which is more authoritative |
| 99 | + // add more here if they should be considered more authorative |
| 100 | + new FindInPom() |
| 101 | + // add more here if they should be considered less authorative |
100 | 102 | });
|
101 | 103 |
|
102 | 104 | this.algos.put(Confidence.HIGH, new IMainTypeFinder[] {
|
103 | 105 | // add more here if they should be considered more authorative
|
104 |
| - new FindInPom() |
| 106 | + new FindInSource(), |
105 | 107 | // add more here if they should be considered less authorative
|
106 | 108 | });
|
107 | 109 |
|
108 | 110 | this.algos.put(Confidence.LOW, new IMainTypeFinder[] {
|
109 | 111 | // add more here if they should be considered more authorative
|
110 |
| - new FindInSource() |
| 112 | + new FindInLibs() |
111 | 113 | // add more here if they should be considered less authorative
|
112 | 114 | });
|
113 | 115 |
|
@@ -241,6 +243,33 @@ private boolean isInteresting(IClasspathEntry cpe) {
|
241 | 243 | );
|
242 | 244 | }
|
243 | 245 | }
|
| 246 | + |
| 247 | + public static class FindInLibs implements IMainTypeFinder { |
| 248 | + |
| 249 | + public IType[] findMain(IJavaProject javaProject, |
| 250 | + IProgressMonitor monitor) throws Exception { |
| 251 | + monitor.beginTask("Search main types in project source", 1); |
| 252 | + try { |
| 253 | + |
| 254 | + MainMethodSearchEngine engine = new MainMethodSearchEngine(); |
| 255 | + IJavaSearchScope scope = SearchEngine.createJavaSearchScope(true, new IJavaElement[] { javaProject }, IJavaSearchScope.APPLICATION_LIBRARIES); |
| 256 | + |
| 257 | + boolean includeSubtypes = true; |
| 258 | + IType[] types = engine |
| 259 | + .searchMainMethods(monitor, scope, includeSubtypes); |
| 260 | + if (types == null) { |
| 261 | + types = EMPTY; |
| 262 | + } |
| 263 | + return types; |
| 264 | + } catch (Exception e) { |
| 265 | + FrameworkCoreActivator.log(e); |
| 266 | + } finally { |
| 267 | + monitor.done(); |
| 268 | + } |
| 269 | + return EMPTY; |
| 270 | + } |
| 271 | + |
| 272 | + } |
244 | 273 |
|
245 | 274 | /**
|
246 | 275 | * Confidence that a search result for main types in a project is what is expected.
|
|
0 commit comments