Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@
import org.eclipse.jdt.debug.tests.ui.JavaSnippetEditorTest;
import org.eclipse.jdt.debug.tests.ui.NoLineNumberAttributesStatusHandlerTest;
import org.eclipse.jdt.debug.tests.ui.OpenFromClipboardTests;
import org.eclipse.jdt.debug.tests.ui.TemplateRegistryTests;
import org.eclipse.jdt.debug.tests.ui.ViewManagementTests;
import org.eclipse.jdt.debug.tests.ui.VirtualThreadsDebugViewTests;
import org.eclipse.jdt.debug.tests.ui.presentation.ModelPresentationTests;
Expand Down Expand Up @@ -354,6 +355,7 @@ public AutomatedSuite() {

// Scrapbook editor tests
addTest(new TestSuite(JavaSnippetEditorTest.class));
addTest(new TestSuite(TemplateRegistryTests.class));

// No Line Number Attributes Status Handler tests
addTest(new TestSuite(NoLineNumberAttributesStatusHandlerTest.class));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*******************************************************************************
* Copyright (c) 2026 Carsten Hammer and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*******************************************************************************/
package org.eclipse.jdt.debug.tests.ui;

import org.eclipse.jdt.internal.debug.ui.contentassist.CurrentFrameContext;
import org.eclipse.jdt.internal.debug.ui.contentassist.JavaDebugContentAssistProcessor;
import org.eclipse.jdt.internal.debug.ui.snippeteditor.JavaSnippetCompletionProcessor;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.Bundle;
import org.osgi.framework.Constants;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.Version;
import org.osgi.framework.VersionRange;

import junit.framework.TestCase;

/**
* Checks the registry linkage used when the debugger creates content assist.
*/
public class TemplateRegistryTests extends TestCase {

public void testDebugContentAssistCanBeCreated() {
JavaDebugContentAssistProcessor processor = new JavaDebugContentAssistProcessor(new CurrentFrameContext());
assertNotNull(processor.getContextInformationValidator());
assertNull(processor.getErrorMessage());
}

public void testSnippetContentAssistCanBeCreated() {
// The editor is not used until completion is requested. Registry linkage
// must already succeed when the processor is constructed.
JavaSnippetCompletionProcessor processor = new JavaSnippetCompletionProcessor(null);
assertNotNull(processor.getContextInformationValidator());
assertNull(processor.getErrorMessage());
}

public void testRequiresJdtWithCoreRegistryAccessors() throws Exception {
Bundle bundle = FrameworkUtil.getBundle(JavaDebugContentAssistProcessor.class);
ManifestElement[] required = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE,
bundle.getHeaders().get(Constants.REQUIRE_BUNDLE));
for (ManifestElement dependency : required) {
if ("org.eclipse.jdt.ui".equals(dependency.getValue())) {
VersionRange range = new VersionRange(dependency.getAttribute(Constants.BUNDLE_VERSION_ATTRIBUTE));
assertFalse("Must reject the JDT version without the Core accessors", range.includes(new Version("3.40.0")));
assertTrue("Must accept the version introducing the Core accessors", range.includes(new Version("3.40.100")));
return;
}
}
fail("Missing dependency on org.eclipse.jdt.ui");
}
}
2 changes: 1 addition & 1 deletion org.eclipse.jdt.debug.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Require-Bundle: org.eclipse.ui.ide;bundle-version="[3.5.0,4.0.0)",
org.eclipse.debug.ui;bundle-version="[3.13.400,4.0.0)",
org.eclipse.jdt.debug;bundle-version="[3.23.0,4.0.0)",
org.eclipse.jdt.launching;bundle-version="[3.23.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.33.0,4.0.0)",
org.eclipse.jdt.ui;bundle-version="[3.40.100,4.0.0)",
org.eclipse.core.runtime;bundle-version="[3.30.0,4.0.0)",
org.eclipse.ltk.core.refactoring;bundle-version="[3.5.0,4.0.0)",
org.eclipse.ui.console;bundle-version="[3.4.0,4.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1893,7 +1893,7 @@ private static String getCodeTemplate(ITextSelection textSelection, JavaEditor p
if (viewer == null) {
return null;
}
TemplateContextType contextType = JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(JavaContextType.ID_STATEMENTS);
TemplateContextType contextType = JavaPlugin.getDefault().getTemplateContextRegistryCore().getContextType(JavaContextType.ID_STATEMENTS);
final AtomicReference<String> templateBuffer = new AtomicReference<>();
Display.getDefault().syncExec(() -> doGetCodeTemplate(textSelection, part, viewer, contextType, templateBuffer));
return templateBuffer.get();
Expand Down Expand Up @@ -1923,7 +1923,7 @@ private static void doGetCodeTemplate(ITextSelection textSelection, JavaEditor p
for (TemplateProposal templateProposal : templateProposals) {
Template template = templateProposal.getTemplate();
if (template.getName().equals("systrace")) { //$NON-NLS-1$
CompilationUnitContextType cuContextType = (CompilationUnitContextType) JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(template.getContextTypeId());
CompilationUnitContextType cuContextType = (CompilationUnitContextType) JavaPlugin.getDefault().getTemplateContextRegistryCore().getContextType(template.getContextTypeId());
DocumentTemplateContext context = cuContextType.createContext(document, line.getOffset(), 0, cunit);
context.setVariable("selection", EMPTY_STRING); //$NON-NLS-1$
((CompilationUnitContext) context).setForceEvaluation(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ public class JavaDebugContentAssistProcessor implements IContentAssistProcessor

public JavaDebugContentAssistProcessor(IJavaDebugContentAssistContext context) {
fContext = context;
TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(JavaContextType.ID_ALL);
TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistryCore().getContextType(JavaContextType.ID_ALL);
if (contextType != null) {
fJavaEngine= new TemplateEngine(contextType);
}
contextType = JavaPlugin.getDefault().getTemplateContextRegistry().getContextType(JavaContextType.ID_STATEMENTS);
contextType = JavaPlugin.getDefault().getTemplateContextRegistryCore().getContextType(JavaContextType.ID_STATEMENTS);
if (contextType != null) {
fStatementEngine= new TemplateEngine(contextType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public class JavaSnippetCompletionProcessor implements IContentAssistProcessor {

public JavaSnippetCompletionProcessor(JavaSnippetEditor editor) {
fEditor= editor;
TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistry().getContextType("java"); //$NON-NLS-1$
TemplateContextType contextType= JavaPlugin.getDefault().getTemplateContextRegistryCore().getContextType("java"); //$NON-NLS-1$
if (contextType != null) {
fTemplateEngine= new TemplateEngine(contextType);
}
Expand Down
Loading