Skip to content
Open
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
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2006, 2015 IBM Corporation and others.
* Copyright (c) 2006, 2026 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -16,6 +16,7 @@
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IColumnPresentationFactory;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementEditor;
import org.eclipse.debug.ui.IWatchExpressionCellEditorFactory;

Check warning on line 19 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/ColumnPresentationAdapterFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Import

ERROR: The import org.eclipse.debug.ui.IWatchExpressionCellEditorFactory cannot be resolved
import org.eclipse.jdt.debug.core.IJavaStackFrame;
import org.eclipse.jdt.debug.core.IJavaVariable;

Expand All @@ -28,6 +29,7 @@

private static final IColumnPresentationFactory fgColumnPresentation = new JavaVariableColumnPresentationFactory();
private static final IElementEditor fgEEJavaVariable = new JavaVariableEditor();
private static final IWatchExpressionCellEditorFactory fgWatchExpressionCellEditorFactory = new JavaWatchExpressionCellEditorFactory();

Check warning on line 32 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/ColumnPresentationAdapterFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Type

ERROR: IWatchExpressionCellEditorFactory cannot be resolved to a type

/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
Expand All @@ -44,6 +46,9 @@
if (IColumnPresentationFactory.class.equals(adapterType)) {
return (T) fgColumnPresentation;
}
if (IWatchExpressionCellEditorFactory.class.equals(adapterType)) {

Check warning on line 49 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/ColumnPresentationAdapterFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Type

ERROR: IWatchExpressionCellEditorFactory cannot be resolved to a type
return (T) fgWatchExpressionCellEditorFactory;

Check warning on line 50 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/ColumnPresentationAdapterFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Type

ERROR: IWatchExpressionCellEditorFactory cannot be resolved to a type
}
}
return null;
}
Expand All @@ -55,7 +60,8 @@
public Class<?>[] getAdapterList() {
return new Class[]{
IColumnPresentationFactory.class,
IElementEditor.class};
IElementEditor.class,
IWatchExpressionCellEditorFactory.class};

Check warning on line 64 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/ColumnPresentationAdapterFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Type

ERROR: IWatchExpressionCellEditorFactory cannot be resolved to a type
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,196 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation.
*
* 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
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.debug.ui.variables;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.IHandler;
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
import org.eclipse.jdt.internal.debug.ui.JDISourceViewer;
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.display.DisplayViewerConfiguration;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.contentassist.ICompletionListener;
import org.eclipse.jface.text.contentassist.ICompletionProposal;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.source.ContentAssistantFacade;
import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.FocusAdapter;
import org.eclipse.swt.events.FocusEvent;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerActivation;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;

/**
* A {@link CellEditor} for the Expressions view that wraps a {@link JDISourceViewer} configured with Java content assist.
*/
public class JDISourceViewerCellEditor extends CellEditor {

private JDISourceViewer fViewer;
private String fValue = ""; //$NON-NLS-1$
/** Tracks whether the content-assist proposal popup is currently open. */
private boolean fProposalPopupOpen = false;
private IHandlerService fHandlerService;
private IHandler fContentAssistHandler;
private IHandlerActivation fContentAssistActivation;

public JDISourceViewerCellEditor(Composite parent) {
super(parent, SWT.NONE);
}

@Override
protected Control createControl(Composite parent) {
fViewer = new JDISourceViewer(parent, null, SWT.BORDER | SWT.SINGLE | SWT.LEFT_TO_RIGHT);

Document document = new Document();
JDIDebugUIPlugin.getDefault().getJavaTextTools().setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);

fViewer.setInput(document);
fViewer.configure(new DisplayViewerConfiguration() {
@Override
public IContentAssistProcessor getContentAssistantProcessor() {
return new JavaDebugContentAssistProcessor(new CurrentFrameContext());
}
});
fViewer.setEditable(true);

ContentAssistantFacade facade = fViewer.getContentAssistantFacade();
if (facade != null) {
facade.addCompletionListener(new ICompletionListener() {
@Override
public void assistSessionStarted(org.eclipse.jface.text.contentassist.ContentAssistEvent event) {
fProposalPopupOpen = true;
}
@Override
public void assistSessionEnded(org.eclipse.jface.text.contentassist.ContentAssistEvent event) {
fProposalPopupOpen = false;
}
@Override
public void selectionChanged(ICompletionProposal proposal, boolean smartToggle) {
// not needed
}
});
}

fContentAssistHandler = new AbstractHandler() {
@Override
public Object execute(ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
fViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
return null;
}
};
fHandlerService = PlatformUI.getWorkbench().getAdapter(IHandlerService.class);

fViewer.getTextWidget().addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
activateContentAssistHandler();
}
@Override
public void focusLost(FocusEvent e) {
deactivateContentAssistHandler();
if (!fProposalPopupOpen) {
JDISourceViewerCellEditor.this.focusLost();
}
}
});

fViewer.appendVerifyKeyListener(e -> {
if (!e.doit) {
return;
}
if (e.keyCode == ' ' && (e.stateMask & SWT.CTRL) != 0) {
fViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
e.doit = false;
} else if (!fProposalPopupOpen) {
if (e.keyCode == SWT.CR && (e.stateMask & SWT.SHIFT) == 0) {
fireApplyEditorValue();
deactivate();
e.doit = false;
} else if (e.keyCode == SWT.ESC) {
fireCancelEditor();
e.doit = false;
}
}
});

return fViewer.getControl();
}

@Override
protected Object doGetValue() {
if (fViewer != null && fViewer.getDocument() != null) {
return fViewer.getDocument().get();
}
return fValue;
}

@Override
protected boolean dependsOnExternalFocusListener() {
return false;
}

@Override
protected void doSetFocus() {
if (fViewer != null) {
fViewer.getTextWidget().setFocus();
}
}

@Override
protected void doSetValue(Object value) {
fValue = (value == null) ? "" : value.toString(); //$NON-NLS-1$
if (fViewer != null && fViewer.getDocument() != null) {
fViewer.getDocument().set(fValue);
// Move cursor to end
fViewer.getTextWidget().setCaretOffset(fValue.length());
}
}

@Override
public void deactivate() {
deactivateContentAssistHandler();
super.deactivate();
}

@Override
public void dispose() {
deactivateContentAssistHandler();
if (fViewer != null) {
fViewer.dispose();
}
super.dispose();
}

private void activateContentAssistHandler() {
if (fHandlerService != null && fContentAssistActivation == null) {
fContentAssistActivation = fHandlerService.activateHandler(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, fContentAssistHandler);
}
}

private void deactivateContentAssistHandler() {
if (fHandlerService != null && fContentAssistActivation != null) {
fHandlerService.deactivateHandler(fContentAssistActivation);
fContentAssistActivation = null;
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
* Copyright (c) 2026 IBM Corporation.
*
* 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
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.eclipse.jdt.internal.debug.ui.variables;

import java.util.Optional;

import org.eclipse.debug.ui.IWatchExpressionCellEditorFactory;

Check warning on line 18 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/JavaWatchExpressionCellEditorFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Import

ERROR: The import org.eclipse.debug.ui.IWatchExpressionCellEditorFactory cannot be resolved
import org.eclipse.jdt.internal.debug.ui.JDIDebugUIPlugin;
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.display.DisplayViewerConfiguration;
import org.eclipse.jdt.ui.text.IJavaPartitions;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
import org.eclipse.jface.text.source.SourceViewer;
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.swt.widgets.Composite;

public class JavaWatchExpressionCellEditorFactory implements IWatchExpressionCellEditorFactory {

Check warning on line 30 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/JavaWatchExpressionCellEditorFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Type

ERROR: IWatchExpressionCellEditorFactory cannot be resolved to a type

@Override
public Optional<CellEditor> createCellEditor(Composite parent) {

Check warning on line 33 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/JavaWatchExpressionCellEditorFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Member

ERROR: The method createCellEditor(Composite) of type JavaWatchExpressionCellEditorFactory must override or implement a supertype method
return Optional.of(new JDISourceViewerCellEditor(parent));
}

@Override
public void configureSourceViewer(SourceViewer viewer) {

Check warning on line 38 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/JavaWatchExpressionCellEditorFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Member

ERROR: The method configureSourceViewer(SourceViewer) of type JavaWatchExpressionCellEditorFactory must override or implement a supertype method
viewer.configure(new DisplayViewerConfiguration() {
@Override
public IContentAssistProcessor getContentAssistantProcessor() {
return new JavaDebugContentAssistProcessor(new CurrentFrameContext());
}
});
}

@Override
public void prepareDocument(IDocument document) {

Check warning on line 48 in org.eclipse.jdt.debug.ui/ui/org/eclipse/jdt/internal/debug/ui/variables/JavaWatchExpressionCellEditorFactory.java

View check run for this annotation

Jenkins - Eclipse JDT / Compiler

Member

ERROR: The method prepareDocument(IDocument) of type JavaWatchExpressionCellEditorFactory must override or implement a supertype method
JDIDebugUIPlugin.getDefault().getJavaTextTools()
.setupJavaDocumentPartitioner(document, IJavaPartitions.JAVA_PARTITIONING);
}
}
Loading