diff --git a/com.wamas.ide.launching.ui/src/com/wamas/ide/launching/ui/contentassist/LcDslProposalProvider.xtend b/com.wamas.ide.launching.ui/src/com/wamas/ide/launching/ui/contentassist/LcDslProposalProvider.xtend index a86f0ec..f2460b1 100644 --- a/com.wamas.ide.launching.ui/src/com/wamas/ide/launching/ui/contentassist/LcDslProposalProvider.xtend +++ b/com.wamas.ide.launching.ui/src/com/wamas/ide/launching/ui/contentassist/LcDslProposalProvider.xtend @@ -10,6 +10,7 @@ import com.wamas.ide.launching.lcDsl.LaunchConfig import com.wamas.ide.launching.lcDsl.PluginWithVersion import com.wamas.ide.launching.lcDsl.TraceEnablement import com.wamas.ide.launching.services.LcDslGrammarAccess +import com.wamas.ide.launching.validation.InternalApiCalls import com.wamas.ide.launching.validation.LcDslValidator import java.util.stream.Stream import org.eclipse.core.resources.IContainer @@ -184,7 +185,7 @@ class LcDslProposalProvider extends AbstractLcDslProposalProvider { val te = model as TraceEnablement val name = te.plugin - for (s : PDECore.^default.tracingOptionsManager.getTemplateTable(name).keySet) { + for (s : InternalApiCalls.pdeCoreGetTemplateTable(name).keySet) { val n = s.substring(s.indexOf('/') + 1) acceptor.accept( createCompletionProposal("'" + n + "'", new StyledString(n), ih.getImage("doc_section_obj.png"), diff --git a/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/InternalApiCalls.java b/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/InternalApiCalls.java new file mode 100644 index 0000000..00bf545 --- /dev/null +++ b/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/InternalApiCalls.java @@ -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 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) candidate.invoke(tracingOptionsManager, pluginId); + } else if (candidate.getParameterCount() == 2) { + // getTemplateTable changed signature by adding a progress monitor parameter + return (Map) 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); + } + } + +} diff --git a/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/LcDslValidator.xtend b/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/LcDslValidator.xtend index 658758f..3f53ebf 100644 --- a/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/LcDslValidator.xtend +++ b/com.wamas.ide.launching/src/com/wamas/ide/launching/validation/LcDslValidator.xtend @@ -538,7 +538,7 @@ class LcDslValidator extends AbstractLcDslValidator { @Check def checkTracingOptions(TraceEnablement e) { - val ok = PDECore.^default.tracingOptionsManager.getTemplateTable(e.plugin).keySet + val ok = InternalApiCalls.pdeCoreGetTemplateTable(e.plugin).keySet var idx = 0; for (w : e.what) { if (!ok.contains(e.plugin + "/" + w)) {