Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
d901d599
Commit
d901d599
authored
Jan 11, 2020
by
geequlim
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow enable/disable threading for LSP server
Restart LSP server when configurations change without restart the editor
parent
02cd1442
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
42 additions
and
13 deletions
+42
-13
gdscript_language_server.cpp
...les/gdscript/language_server/gdscript_language_server.cpp
+38
-12
gdscript_language_server.h
modules/gdscript/language_server/gdscript_language_server.h
+4
-1
No files found.
modules/gdscript/language_server/gdscript_language_server.cpp
View file @
d901d599
...
...
@@ -36,10 +36,15 @@
GDScriptLanguageServer
::
GDScriptLanguageServer
()
{
thread
=
NULL
;
thread_exit
=
false
;
_EDITOR_DEF
(
"network/language_server/remote_port"
,
6008
);
thread_running
=
false
;
started
=
false
;
use_thread
=
false
;
port
=
6008
;
_EDITOR_DEF
(
"network/language_server/remote_port"
,
port
);
_EDITOR_DEF
(
"network/language_server/enable_smart_resolve"
,
true
);
_EDITOR_DEF
(
"network/language_server/show_native_symbols_in_editor"
,
false
);
_EDITOR_DEF
(
"network/language_server/use_thread"
,
use_thread
);
}
void
GDScriptLanguageServer
::
_notification
(
int
p_what
)
{
...
...
@@ -51,12 +56,25 @@ void GDScriptLanguageServer::_notification(int p_what) {
case
NOTIFICATION_EXIT_TREE
:
stop
();
break
;
case
NOTIFICATION_INTERNAL_PROCESS
:
{
if
(
started
&&
!
use_thread
)
{
protocol
.
poll
();
}
}
break
;
case
EditorSettings
:
:
NOTIFICATION_EDITOR_SETTINGS_CHANGED
:
{
int
port
=
(
int
)
_EDITOR_GET
(
"network/language_server/remote_port"
);
bool
use_thread
=
(
bool
)
_EDITOR_GET
(
"network/language_server/use_thread"
);
if
(
port
!=
this
->
port
||
use_thread
!=
this
->
use_thread
)
{
this
->
stop
();
this
->
start
();
}
}
break
;
}
}
void
GDScriptLanguageServer
::
thread_main
(
void
*
p_userdata
)
{
GDScriptLanguageServer
*
self
=
static_cast
<
GDScriptLanguageServer
*>
(
p_userdata
);
while
(
!
self
->
thread_exit
)
{
while
(
self
->
thread_running
)
{
// Poll 20 times per second
self
->
protocol
.
poll
();
OS
::
get_singleton
()
->
delay_usec
(
50000
);
...
...
@@ -64,22 +82,30 @@ void GDScriptLanguageServer::thread_main(void *p_userdata) {
}
void
GDScriptLanguageServer
::
start
()
{
int
port
=
(
int
)
_EDITOR_GET
(
"network/language_server/remote_port"
);
port
=
(
int
)
_EDITOR_GET
(
"network/language_server/remote_port"
);
use_thread
=
(
bool
)
_EDITOR_GET
(
"network/language_server/use_thread"
);
if
(
protocol
.
start
(
port
)
==
OK
)
{
EditorNode
::
get_log
()
->
add_message
(
"--- GDScript language server started ---"
,
EditorLog
::
MSG_TYPE_EDITOR
);
ERR_FAIL_COND
(
thread
!=
NULL
||
thread_exit
);
thread_exit
=
false
;
thread
=
Thread
::
create
(
GDScriptLanguageServer
::
thread_main
,
this
);
if
(
use_thread
)
{
ERR_FAIL_COND
(
thread
!=
NULL
);
thread_running
=
true
;
thread
=
Thread
::
create
(
GDScriptLanguageServer
::
thread_main
,
this
);
}
set_process_internal
(
!
use_thread
);
started
=
true
;
}
}
void
GDScriptLanguageServer
::
stop
()
{
ERR_FAIL_COND
(
NULL
==
thread
||
thread_exit
);
thread_exit
=
true
;
Thread
::
wait_to_finish
(
thread
);
memdelete
(
thread
);
thread
=
NULL
;
if
(
use_thread
)
{
ERR_FAIL_COND
(
NULL
==
thread
);
thread_running
=
false
;
Thread
::
wait_to_finish
(
thread
);
memdelete
(
thread
);
thread
=
NULL
;
}
protocol
.
stop
();
started
=
false
;
EditorNode
::
get_log
()
->
add_message
(
"--- GDScript language server stopped ---"
,
EditorLog
::
MSG_TYPE_EDITOR
);
}
...
...
modules/gdscript/language_server/gdscript_language_server.h
View file @
d901d599
...
...
@@ -41,7 +41,10 @@ class GDScriptLanguageServer : public EditorPlugin {
GDScriptLanguageProtocol
protocol
;
Thread
*
thread
;
bool
thread_exit
;
bool
thread_running
;
bool
started
;
bool
use_thread
;
int
port
;
static
void
thread_main
(
void
*
p_userdata
);
private
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment