-
Notifications
You must be signed in to change notification settings - Fork 16
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
Showing
3 changed files
with
42 additions
and
2 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
39 changes: 39 additions & 0 deletions
39
com.wamas.ide.launching/src/com/wamas/ide/launching/validation/InternalApiCalls.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 com.wamas.ide.launching.validation; | ||
|
||
import java.lang.reflect.InvocationTargetException; | ||
import java.lang.reflect.Method; | ||
import java.util.Map; | ||
import java.util.stream.Stream; | ||
|
||
import org.eclipse.core.runtime.NullProgressMonitor; | ||
import org.eclipse.pde.internal.core.PDECore; | ||
import org.eclipse.pde.internal.core.TracingOptionsManager; | ||
|
||
public class InternalApiCalls { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static Map<String, String> pdeCoreGetTemplateTable(String pluginId) { | ||
if (pluginId == null) { | ||
return Map.of(); | ||
} | ||
TracingOptionsManager tracingOptionsManager = PDECore.getDefault().getTracingOptionsManager(); | ||
|
||
Method candidate = Stream.of(TracingOptionsManager.class.getMethods()) | ||
.filter(mth -> mth.getName().equals("getTemplateTable")).findFirst().orElseThrow(); | ||
try { | ||
if (candidate.getParameterCount() == 1) { | ||
return (Map<String, String>) candidate.invoke(tracingOptionsManager, pluginId); | ||
} else if (candidate.getParameterCount() == 2) { | ||
// getTemplateTable changed signature by adding a progress monitor parameter | ||
return (Map<String, String>) candidate.invoke(tracingOptionsManager, pluginId, | ||
new NullProgressMonitor()); | ||
} else { | ||
throw new IllegalStateException( | ||
"Method PdeCore.getTracingManager.getTemplateTable was not found with needed signature"); | ||
} | ||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { | ||
throw new IllegalStateException("Exception when calling PdeCore.getTracingManager.getTemplateTable", e); | ||
} | ||
} | ||
|
||
} |
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