Skip to content

Commit 9079c56

Browse files
authored
Merge pull request uniconproject#444 from Jafaral/win-ulsp
ulsp: fix socket option on Windows and handle a few exceptions
2 parents c48589b + 27ee86d commit 9079c56

File tree

5 files changed

+20
-11
lines changed

5 files changed

+20
-11
lines changed

uni/ulsp/Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export IPATH=$(UNI)/unidoc
1515
all: $(prog)
1616

1717
$(prog): $(OBJ)
18-
$(UC) $(DASHG) -o $(prog) $(OBJ)
18+
$(UC) -o $(prog) $(OBJ)
1919
$(CP) $(prog)$(EXE) ../../bin
2020

2121
launch-lsp.u:launch-lsp.icn workspace.u database.u server.u completion.u signature.u hover.u definition.u

uni/ulsp/hover.icn

+1
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ class HoverHandler(
5454
num_params, param, num_attributes, _attribute, line, character
5555

5656
line := context.line
57+
\line | fail
5758
character := context.charNum
5859

5960
# Begin initial string scanning

uni/ulsp/launch-lsp.icn

+7-5
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,13 @@ procedure main(args)
4040
#write("args: ", ximage(args))
4141
port := validate_args(args) | stop("Error: invalid args/port number.")
4242

43-
if &features == "MacOS" then
44-
#port := "localhost:" || port
45-
port := "127.0.0.1:" || port
46-
else
47-
port := ":" || port
43+
# Allow passing full host:port as an arg
44+
if integer(port) then {
45+
if &features == ("MacOS" | "MS Windows NT") then
46+
port := "127.0.0.1:" || port
47+
else
48+
port := ":" || port
49+
}
4850

4951
Server(port).run()
5052
end

uni/ulsp/server.icn

+3-3
Original file line numberDiff line numberDiff line change
@@ -278,11 +278,11 @@ class Server(
278278

279279
initially
280280

281-
every 1 to 5 do {
282-
if sock := open(port, "n") then
281+
every 1 to 10 do {
282+
if sock := open(port, "n", 1000) then
283283
break
284284
else {
285-
write("open(",port,") ERROR: ", &errortext)
285+
write("open(",port,") ERROR: ", \&errortext | "Unknown")
286286
delay(1000)
287287
}
288288
}

uni/ulsp/workspace.icn

+8-2
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ class Workspace(
8181
end
8282

8383
method getFile()
84-
return m_uni_file
84+
if \m_uni_file then
85+
return m_uni_file
8586
end
8687

8788
method updateUniDoc(uri, contents)
@@ -104,7 +105,8 @@ class Workspace(
104105
method setLinks()
105106
local links_w_ext, link_w_ext, temp, _link, pack
106107
links := []
107-
links_w_ext := getFile().getLinkNames()
108+
getFile() | fail
109+
links_w_ext := getFile().getLinkNames() | fail
108110
every link_w_ext := !links_w_ext do {
109111
temp := reverse(link_w_ext)
110112
temp ? {
@@ -130,6 +132,7 @@ class Workspace(
130132
method setImports()
131133
local _import
132134
imports := []
135+
getFile() | fail
133136
every _import := !getFile().getImportNames() do {
134137
if member(lsp_database.package_db, _import) then
135138
put(imports, _import)
@@ -146,6 +149,7 @@ class Workspace(
146149

147150
method setPackage()
148151
local file_loc
152+
getFile() | fail
149153
if \getFile().getPackageName() then {
150154
_package := getFile().getPackageName()
151155
if not member(lsp_database.package_db, _package) then {
@@ -170,6 +174,7 @@ class Workspace(
170174
method setInternalProcedures()
171175
local _procedure, _param, paramName, paramType, paramDef
172176
internal_procedures := table()
177+
getFile() | fail
173178
every _procedure := getFile().getProcedures().get() do {
174179
_procedure.setSrcFile(uri)
175180
internal_procedures[_procedure.getName()] := table()
@@ -268,6 +273,7 @@ class Workspace(
268273
method setInternalClasses()
269274
local _class, _method, _param, paramName, paramType, paramDef, constructor_param
270275
internal_classes := table()
276+
getFile() | fail
271277
every _class := getFile().getClasses().get() do {
272278
_class.setSrcFile(uri)
273279
internal_classes[_class.getName()] := table()

0 commit comments

Comments
 (0)