Search in sources :

Example 1 with Match

use of org.springframework.tooling.ls.eclipse.gotosymbol.dialogs.GotoSymbolDialogModel.Match in project sts4 by spring-projects.

the class GotoSymbolDialog method getFirstElement.

private SymbolInformation getFirstElement(TreeViewer list) {
    TreeItem[] items = list.getTree().getItems();
    if (items != null && items.length > 0) {
        TreeItem item = items[0];
        Object data = item.getData();
        if (data instanceof Match) {
            data = ((Match<?>) data).value;
            if (data instanceof SymbolInformation) {
                return (SymbolInformation) data;
            }
        }
    }
    return null;
}
Also used : TreeItem(org.eclipse.swt.widgets.TreeItem) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) Match(org.springframework.tooling.ls.eclipse.gotosymbol.dialogs.GotoSymbolDialogModel.Match)

Example 2 with Match

use of org.springframework.tooling.ls.eclipse.gotosymbol.dialogs.GotoSymbolDialogModel.Match in project sts4 by spring-projects.

the class GotoSymbolDialog method getTarget.

/**
 * Determine the 'target' for the dialog's action.
 */
private SymbolInformation getTarget(TreeViewer list) {
    ISelection sel = list.getSelection();
    if (sel instanceof IStructuredSelection) {
        IStructuredSelection ss = (IStructuredSelection) sel;
        Object selected = ss.getFirstElement();
        if (selected instanceof Match) {
            selected = ((Match<?>) selected).value;
            if (selected instanceof SymbolInformation) {
                return (SymbolInformation) selected;
            }
        }
    }
    // This allows user to execute the action without explicitly selecting an element.
    return getFirstElement(list);
}
Also used : ISelection(org.eclipse.jface.viewers.ISelection) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) SymbolInformation(org.eclipse.lsp4j.SymbolInformation) Match(org.springframework.tooling.ls.eclipse.gotosymbol.dialogs.GotoSymbolDialogModel.Match)

Aggregations

SymbolInformation (org.eclipse.lsp4j.SymbolInformation)2 Match (org.springframework.tooling.ls.eclipse.gotosymbol.dialogs.GotoSymbolDialogModel.Match)2 ISelection (org.eclipse.jface.viewers.ISelection)1 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)1 TreeItem (org.eclipse.swt.widgets.TreeItem)1