Skip to content

Commit

Permalink
Support Eclipse 2024-06, fixes #86
Browse files Browse the repository at this point in the history
  • Loading branch information
Frank Benoit authored and haubi committed Sep 5, 2024
1 parent c365a18 commit 2839d30
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"),
Expand Down
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);
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -521,7 +521,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)) {
Expand Down

0 comments on commit 2839d30

Please sign in to comment.