MCPcopy Create free account
hub / github.com/SpartanJ/eepp / showDocumentSymbols

Method showDocumentSymbols

src/tools/ecode/plugins/lsp/lspclientplugin.cpp:2040–2115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2038}
2039
2040void LSPClientPlugin::showDocumentSymbols( UICodeEditor* editor ) {
2041 TextDocument& doc = editor->getDocument();
2042 URI uri = doc.getURI();
2043
2044 auto model = createDocSymbolsModel( uri );
2045 if ( !model )
2046 return;
2047
2048 getUISceneNode()->getRoot()->setFocus();
2049 UIWindow* win =
2050 UIWindow::NewOpt( UIMessageBox::WindowBaseContainerType::VERTICAL_LINEAR_LAYOUT );
2051 win->setMinWindowSize( 400, getUISceneNode()->getSize().getHeight() * 0.7f );
2052 win->setKeyBindingCommand( "closeWindow", [win, editor] {
2053 win->closeWindow();
2054 editor->setFocus();
2055 } );
2056 win->getKeyBindings().addKeybind( { KEY_ESCAPE }, "closeWindow" );
2057 win->setWindowFlags( UI_WIN_NO_DECORATION | UI_WIN_SHADOW | UI_WIN_MODAL | UI_WIN_EPHEMERAL );
2058 win->center();
2059 UITextInput* input = UITextInput::New();
2060 input->setParent( win->getContainer() );
2061 input->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::WrapContent );
2062 input->setHint( i18n( "search_symbols_ellipsis", "Search Symbols..." ) );
2063
2064 UITreeView* tv = UITreeView::New();
2065 tv->setHeadersVisible( false );
2066 tv->setAutoExpandOnSingleColumn( true );
2067 tv->setLayoutSizePolicy( SizePolicy::MatchParent, SizePolicy::Fixed );
2068 tv->setLayoutWeight( 1 );
2069 tv->setParent( win->getContainer() );
2070 tv->setModel( model );
2071 tv->expandAll();
2072 tv->setFocusOnSelection( false );
2073
2074 {
2075 Lock l( mDocCurrentSymbolsMutex );
2076 auto symbolsIt = mDocCurrentSymbols.find( uri );
2077 ModelIndex index;
2078 if ( symbolsIt != mDocCurrentSymbols.end() ) {
2079 auto docSymbols = symbolsIt->second;
2080 std::vector<std::string> path;
2081 path.reserve( docSymbols.size() );
2082 for ( const auto& sym : docSymbols )
2083 path.emplace_back( sym.name );
2084 tv->openRowWithPath( path );
2085 }
2086 }
2087
2088 win->show();
2089 input->setFocus();
2090
2091 input->on( Event::KeyDown, [tv, input]( const Event* event ) {
2092 tv->forceKeyDown( *event->asKeyEvent() );
2093 input->setFocus();
2094 } );
2095
2096 input->on( Event::OnTextChanged, [tv, input, uri, this]( const Event* ) {
2097 tv->setModel( createDocSymbolsModel( uri, input->getText().toUtf8() ) );

Callers

nothing calls this directly

Calls 15

getDocumentMethod · 0.80
getURIMethod · 0.80
setMinWindowSizeMethod · 0.80
closeWindowMethod · 0.80
addKeybindMethod · 0.80
setWindowFlagsMethod · 0.80
centerMethod · 0.80
setParentMethod · 0.80
setLayoutSizePolicyMethod · 0.80
setHintMethod · 0.80
setLayoutWeightMethod · 0.80

Tested by

no test coverage detected