mirror of
https://github.com/SpartanJ/eepp.git
synced 2026-06-04 20:46:29 +03:00
Clock: renamed getElapsed in favor of getElapsedTimeAndReset. Since it was not very clear what it was doing.
ecode: Some minor clean up.
This commit is contained in:
@@ -172,8 +172,8 @@ void AutoCompletePlugin::onUnregister( UICodeEditor* editor ) {
|
||||
editor->removeEventListener( listener );
|
||||
mEditors.erase( editor );
|
||||
mEditorDocs.erase( editor );
|
||||
for ( auto editor : mEditorDocs )
|
||||
if ( editor.second == doc )
|
||||
for ( auto ceditor : mEditorDocs )
|
||||
if ( ceditor.second == doc )
|
||||
return;
|
||||
mDocs.erase( doc );
|
||||
mDocCache.erase( doc );
|
||||
@@ -346,29 +346,32 @@ bool AutoCompletePlugin::onTextInput( UICodeEditor* editor, const TextInputEvent
|
||||
auto lang = editor->getDocumentRef()->getSyntaxDefinition().getLSPName();
|
||||
auto cap = mCapabilities.find( lang );
|
||||
if ( cap != mCapabilities.end() ) {
|
||||
bool requestedSignatureHelp = false;
|
||||
const auto& signatureTrigger = cap->second.signatureHelpProvider.triggerCharacters;
|
||||
if ( std::find( signatureTrigger.begin(), signatureTrigger.end(), event.getChar() ) !=
|
||||
signatureTrigger.end() ) {
|
||||
requestSignatureHelp( editor );
|
||||
requestedSignatureHelp = true;
|
||||
if ( cap->second.signatureHelpProvider.provider ) {
|
||||
bool requestedSignatureHelp = false;
|
||||
const auto& signatureTrigger = cap->second.signatureHelpProvider.triggerCharacters;
|
||||
if ( std::find( signatureTrigger.begin(), signatureTrigger.end(), event.getChar() ) !=
|
||||
signatureTrigger.end() ) {
|
||||
requestSignatureHelp( editor );
|
||||
requestedSignatureHelp = true;
|
||||
}
|
||||
if ( mSignatureHelpVisible && !requestedSignatureHelp ) {
|
||||
auto doc = editor->getDocumentRef();
|
||||
auto curPos = doc->getSelection().start();
|
||||
if ( curPos.line() != mSignatureHelpPosition.line() ||
|
||||
curPos < doc->startOfWord( doc->positionOffset( mSignatureHelpPosition, 1 ) ) )
|
||||
resetSignatureHelp();
|
||||
}
|
||||
}
|
||||
|
||||
if ( mSignatureHelpVisible && !requestedSignatureHelp ) {
|
||||
auto doc = editor->getDocumentRef();
|
||||
auto curPos = doc->getSelection().start();
|
||||
if ( curPos.line() != mSignatureHelpPosition.line() ||
|
||||
curPos < doc->startOfWord( doc->positionOffset( mSignatureHelpPosition, 1 ) ) )
|
||||
resetSignatureHelp();
|
||||
}
|
||||
|
||||
const auto& triggerCharacters = cap->second.completionProvider.triggerCharacters;
|
||||
if ( partialSymbol.size() >= 1 ||
|
||||
std::find( triggerCharacters.begin(), triggerCharacters.end(), event.getChar() ) !=
|
||||
triggerCharacters.end() ) {
|
||||
updateSuggestions( partialSymbol, editor );
|
||||
} else {
|
||||
resetSuggestions( editor );
|
||||
if ( cap->second.completionProvider.provider ) {
|
||||
const auto& triggerCharacters = cap->second.completionProvider.triggerCharacters;
|
||||
if ( partialSymbol.size() >= 1 ||
|
||||
std::find( triggerCharacters.begin(), triggerCharacters.end(), event.getChar() ) !=
|
||||
triggerCharacters.end() ) {
|
||||
updateSuggestions( partialSymbol, editor );
|
||||
} else {
|
||||
resetSuggestions( editor );
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@@ -906,7 +909,7 @@ void AutoCompletePlugin::resetSuggestions( UICodeEditor* editor ) {
|
||||
mSuggestionIndex = 0;
|
||||
mSuggestionsStartIndex = 0;
|
||||
{
|
||||
Lock l( mSuggestionsEditorMutex );
|
||||
Lock l2( mSuggestionsEditorMutex );
|
||||
mSuggestionsEditor = nullptr;
|
||||
}
|
||||
mSuggestions.clear();
|
||||
@@ -974,11 +977,11 @@ void AutoCompletePlugin::updateSuggestions( const std::string& symbol, UICodeEdi
|
||||
auto langSuggestions = mLangCache.find( lang );
|
||||
if ( langSuggestions == mLangCache.end() )
|
||||
return;
|
||||
auto& symbols = langSuggestions->second;
|
||||
const auto& symbols = langSuggestions->second;
|
||||
{
|
||||
#if AUTO_COMPLETE_THREADED
|
||||
mPool->run(
|
||||
[this, symbol, symbols, editor] { runUpdateSuggestions( symbol, symbols, editor ); } );
|
||||
[this, symbol, &symbols, editor] { runUpdateSuggestions( symbol, symbols, editor ); } );
|
||||
#else
|
||||
runUpdateSuggestions( symbol, symbols, editor );
|
||||
#endif
|
||||
|
||||
@@ -425,7 +425,7 @@ static LSPSymbolInformationList parseDocumentSymbols( const json& result ) {
|
||||
rret.push_back( LSPSymbolInformationTmp::fromTmp( r ) );
|
||||
|
||||
Log::debug( "LSPClientServer - parseDocumentSymbols took: %.2fms",
|
||||
clock.getElapsed().asMilliseconds() );
|
||||
clock.getElapsedTimeAndReset().asMilliseconds() );
|
||||
return rret;
|
||||
}
|
||||
|
||||
@@ -774,7 +774,7 @@ static LSPCompletionList parseDocumentCompletion( const json& result ) {
|
||||
}
|
||||
#ifndef EE_DEBUG
|
||||
} catch ( const json::exception& err ) {
|
||||
Log::warning( "Error parsing parseDocumentCompletion: %s", err.what() );
|
||||
Log::debug( "Error parsing parseDocumentCompletion: %s", err.what() );
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
@@ -834,7 +834,7 @@ static LSPSignatureHelp parseSignatureHelp( const json& sig ) {
|
||||
}
|
||||
#ifndef EE_DEBUG
|
||||
} catch ( const json::exception& err ) {
|
||||
Log::warning( "Error parsing parseSignatureHelp: %s", err.what() );
|
||||
Log::debug( "Error parsing parseSignatureHelp: %s", err.what() );
|
||||
}
|
||||
#endif
|
||||
return ret;
|
||||
@@ -1103,8 +1103,7 @@ void LSPClientServer::notifyServerInitialized() {
|
||||
}
|
||||
|
||||
bool LSPClientServer::needsAsync() {
|
||||
return Engine::isEngineRunning() &&
|
||||
Engine::instance()->getMainThreadId() == Thread::getCurrentThreadId();
|
||||
return Engine::isRunninMainThread();
|
||||
}
|
||||
|
||||
bool LSPClientServer::isRunning() {
|
||||
@@ -1191,9 +1190,8 @@ void LSPClientServer::sendAsync( const json& msg, const JsonReplyHandler& h,
|
||||
|
||||
LSPClientServer::LSPRequestHandle LSPClientServer::send( const json& msg, const JsonReplyHandler& h,
|
||||
const JsonReplyHandler& eh ) {
|
||||
#ifdef EE_DEBUG
|
||||
eeASSERT( !needsAsync() );
|
||||
#endif
|
||||
|
||||
if ( mProcess.isAlive() ) {
|
||||
return write( msg, h, eh );
|
||||
} else {
|
||||
@@ -1393,7 +1391,7 @@ void LSPClientServer::publishDiagnostics( const json& msg ) {
|
||||
}
|
||||
Log::debug( "LSPClientServer::publishDiagnostics: %s - returned %zu items",
|
||||
res.uri.toString().c_str(), res.diagnostics.size() );
|
||||
Log::info( "LSPClientServer::publishDiagnostics: %s", msg.dump().c_str() );
|
||||
Log::debug( "LSPClientServer::publishDiagnostics: %s", msg.dump().c_str() );
|
||||
}
|
||||
|
||||
void LSPClientServer::workDoneProgress( const LSPWorkDoneProgressParams& workDoneParams ) {
|
||||
@@ -1406,8 +1404,8 @@ void LSPClientServer::workDoneProgress( const LSPWorkDoneProgressParams& workDon
|
||||
|
||||
void LSPClientServer::processNotification( const json& msg ) {
|
||||
if ( !msg.contains( MEMBER_METHOD ) ) {
|
||||
Log::info( "LSPClientServer::processNotification - Unexpected notification, msg: %s",
|
||||
msg.dump().c_str() );
|
||||
Log::debug( "LSPClientServer::processNotification - Unexpected notification, msg: %s",
|
||||
msg.dump().c_str() );
|
||||
return;
|
||||
}
|
||||
auto method = msg[MEMBER_METHOD].get<std::string>();
|
||||
|
||||
@@ -197,11 +197,11 @@ class LSPClientServer {
|
||||
LSPRequestHandle documentFormatting( const URI& document, const json& options,
|
||||
const TextEditArrayHandler& h );
|
||||
|
||||
void documentRename( const URI& document, const TextPosition& pos,
|
||||
const std::string& newName, const JsonReplyHandler& h );
|
||||
void documentRename( const URI& document, const TextPosition& pos, const std::string& newName,
|
||||
const JsonReplyHandler& h );
|
||||
|
||||
void documentRename( const URI& document, const TextPosition& pos,
|
||||
const std::string& newName, const WorkspaceEditHandler& h );
|
||||
void documentRename( const URI& document, const TextPosition& pos, const std::string& newName,
|
||||
const WorkspaceEditHandler& h );
|
||||
|
||||
void memoryUsage( const JsonReplyHandler& h );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user