mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-05-30 18:16:31 +03:00
Minor improvements in symbol search.
This commit is contained in:
@@ -336,7 +336,8 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
|
||||
|
||||
if ( String::startsWith( mLocateInput->getText(), "sb " ) ) {
|
||||
auto pbm = mApp->getProjectBuildManager();
|
||||
if ( nullptr == pbm ) return;
|
||||
if ( nullptr == pbm )
|
||||
return;
|
||||
auto cfg = pbm->getConfig();
|
||||
std::string buildName = vName.toString();
|
||||
if ( pbm->hasBuild( buildName ) ) {
|
||||
@@ -347,7 +348,8 @@ void UniversalLocator::initLocateBar( UILocateBar* locateBar, UITextInput* locat
|
||||
return;
|
||||
} else if ( String::startsWith( mLocateInput->getText(), "sbt " ) ) {
|
||||
auto pbm = mApp->getProjectBuildManager();
|
||||
if ( nullptr == pbm ) return;
|
||||
if ( nullptr == pbm )
|
||||
return;
|
||||
auto cfg = pbm->getConfig();
|
||||
auto build = pbm->getBuild( cfg.buildName );
|
||||
if ( build != nullptr ) {
|
||||
@@ -440,7 +442,9 @@ void UniversalLocator::showBar() {
|
||||
mLocateTable->setVisible( true );
|
||||
const String& text = mLocateInput->getText();
|
||||
|
||||
if ( !text.empty() && ( text[0] == '>' || text[0] == ':' || text[0] == '.' ) ) {
|
||||
if ( !text.empty() && ( text[0] == '>' || text[0] == ':' || text[0] == '.' ||
|
||||
( text[0] == 'o' && text.size() > 1 && text[1] == ' ' ) ||
|
||||
( text[0] == 'l' && text.size() > 1 && text[1] == ' ' ) ) ) {
|
||||
Int64 selectFrom = 1;
|
||||
if ( text.size() >= 2 && text[1] == ' ' )
|
||||
selectFrom = 2;
|
||||
@@ -462,6 +466,8 @@ void UniversalLocator::showLocateBar() {
|
||||
if ( !mLocateInput->getText().empty() &&
|
||||
( mLocateInput->getText()[0] == '>' || mLocateInput->getText()[0] == ':' ||
|
||||
mLocateInput->getText()[0] == '.' ||
|
||||
String::startsWith( mLocateInput->getText(), "l " ) ||
|
||||
String::startsWith( mLocateInput->getText(), "o " ) ||
|
||||
String::startsWith( mLocateInput->getText(), "sb " ) ||
|
||||
String::startsWith( mLocateInput->getText(), "sbt " ) ) )
|
||||
mLocateInput->setText( "" );
|
||||
@@ -707,22 +713,60 @@ std::shared_ptr<LSPSymbolInfoModel> UniversalLocator::emptyModel( const String&
|
||||
return LSPSymbolInfoModel::create( mUISceneNode, query, { info } );
|
||||
}
|
||||
|
||||
bool UniversalLocator::findCapability( PluginCapability capability ) {
|
||||
json capa;
|
||||
capa["capability"] = capability;
|
||||
capa["uri"] = getCurDocURI();
|
||||
PluginRequestHandle resp = mApp->getPluginManager()->sendRequest(
|
||||
PluginMessageType::QueryPluginCapability, PluginMessageFormat::JSON, &capa );
|
||||
if ( resp.isResponse() && resp.getResponse().data.is_boolean() )
|
||||
return resp.getResponse().data.get<bool>();
|
||||
return false;
|
||||
}
|
||||
|
||||
String UniversalLocator::getDefQueryText( PluginCapability capability ) {
|
||||
bool hasCapability = findCapability( capability );
|
||||
if ( !hasCapability )
|
||||
return mUISceneNode->i18n( "no_running_lsp_server", "No running LSP server" );
|
||||
return mUISceneNode->i18n( "insert_search_query", "Insert search query" );
|
||||
}
|
||||
|
||||
nlohmann::json UniversalLocator::pluginID( const PluginIDType& id ) {
|
||||
json r;
|
||||
r["uri"] = getCurDocURI();
|
||||
if ( id.isInteger() )
|
||||
r["id"] = id.asInt();
|
||||
else
|
||||
r["id"] = id.asString();
|
||||
return r;
|
||||
}
|
||||
|
||||
void UniversalLocator::requestWorkspaceSymbol() {
|
||||
if ( mLocateInput->getText().empty() )
|
||||
return;
|
||||
auto txt( mLocateInput->getText().substr( 1 ).trim() );
|
||||
if ( mWorkspaceSymbolQuery != txt.toUtf8() || mWorkspaceSymbolQuery.empty() ) {
|
||||
mWorkspaceSymbolQuery = txt.toUtf8();
|
||||
|
||||
if ( !mWorkspaceSymbolModel ) {
|
||||
auto defTxt = mUISceneNode->i18n( "no_running_lsp_server", "No running LSP server" );
|
||||
auto defTxt = getDefQueryText( PluginCapability::WorkspaceSymbol );
|
||||
mWorkspaceSymbolModel = emptyModel( defTxt, mWorkspaceSymbolQuery );
|
||||
}
|
||||
mLocateTable->setModel( mWorkspaceSymbolModel );
|
||||
|
||||
json j;
|
||||
j["query"] = mWorkspaceSymbolQuery;
|
||||
mApp->getPluginManager()->sendRequest( PluginMessageType::WorkspaceSymbol,
|
||||
PluginMessageFormat::JSON, &j );
|
||||
if ( mQueryWorkspaceLastId.isValid() ) {
|
||||
json r( pluginID( mQueryWorkspaceLastId ) );
|
||||
mApp->getPluginManager()->sendBroadcast( PluginMessageType::CancelRequest,
|
||||
PluginMessageFormat::JSON, &r );
|
||||
}
|
||||
|
||||
mApp->getThreadPool()->run( [this] {
|
||||
json j;
|
||||
j["query"] = mWorkspaceSymbolQuery;
|
||||
auto hdl = mApp->getPluginManager()->sendRequest( PluginMessageType::WorkspaceSymbol,
|
||||
PluginMessageFormat::JSON, &j );
|
||||
mQueryWorkspaceLastId = hdl.id();
|
||||
} );
|
||||
} else if ( mWorkspaceSymbolModel && mWorkspaceSymbolModel.get() != mLocateTable->getModel() ) {
|
||||
mLocateTable->setModel( mWorkspaceSymbolModel );
|
||||
}
|
||||
@@ -758,16 +802,18 @@ void UniversalLocator::requestDocumentSymbol() {
|
||||
|
||||
if ( mSplitter->curEditorIsNotNull() ) {
|
||||
if ( needsUpdate ) {
|
||||
mTextDocumentSymbolModel = emptyModel(
|
||||
mUISceneNode->i18n( "no_running_lsp_server", "No running LSP server" ) );
|
||||
mTextDocumentSymbolModel =
|
||||
emptyModel( getDefQueryText( PluginCapability::TextDocumentSymbol ) );
|
||||
mLocateTable->setModel( mTextDocumentSymbolModel );
|
||||
|
||||
json j;
|
||||
j["uri"] = mCurDocURI = getCurDocURI();
|
||||
mApp->getPluginManager()->sendRequest( PluginMessageType::TextDocumentFlattenSymbol,
|
||||
PluginMessageFormat::JSON, &j );
|
||||
auto hdl = mApp->getPluginManager()->sendRequest(
|
||||
PluginMessageType::TextDocumentFlattenSymbol, PluginMessageFormat::JSON, &j );
|
||||
} else {
|
||||
if ( !mTextDocumentSymbolModel ) {
|
||||
mTextDocumentSymbolModel = emptyModel(
|
||||
mUISceneNode->i18n( "no_running_lsp_server", "No running LSP server" ) );
|
||||
mTextDocumentSymbolModel =
|
||||
emptyModel( getDefQueryText( PluginCapability::TextDocumentSymbol ) );
|
||||
}
|
||||
mLocateTable->setModel( mTextDocumentSymbolModel );
|
||||
}
|
||||
@@ -822,6 +868,7 @@ std::string UniversalLocator::getCurDocURI() {
|
||||
PluginRequestHandle UniversalLocator::processResponse( const PluginMessage& msg ) {
|
||||
if ( msg.isResponse() && msg.type == PluginMessageType::WorkspaceSymbol &&
|
||||
msg.format == PluginMessageFormat::SymbolInformation ) {
|
||||
mQueryWorkspaceLastId = PluginIDType();
|
||||
updateWorkspaceSymbol( msg.asSymbolInformation() );
|
||||
} else if ( msg.isResponse() && msg.type == PluginMessageType::TextDocumentFlattenSymbol &&
|
||||
msg.format == PluginMessageFormat::SymbolInformation ) {
|
||||
|
||||
Reference in New Issue
Block a user