Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions uni/ulsp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ UFLAGS=-s -u
prog=ulsp

SRC=launch-lsp.icn file_handler.icn database.icn server.icn completion.icn signature.icn hover.icn \
definition.icn jsonrpc.icn logger.icn lsif.icn symbols.icn folding.icn
definition.icn jsonrpc.icn logger.icn lsif.icn symbols.icn folding.icn formatting.icn
OBJ=launch-lsp.u file_handler.u database.u server.u completion.u signature.u hover.u definition.u \
jsonrpc.u logger.u lsif.u symbols.u folding.u
jsonrpc.u logger.u lsif.u symbols.u folding.u formatting.u

export IPATH=$(UNI)/unidoc

Expand All @@ -23,10 +23,10 @@ jsonrpc-test: jsonrpc-test.u jsonrpc.u
$(UC) -o jsonrpc-test jsonrpc-test.u jsonrpc.u

launch-lsp.u:launch-lsp.icn file_handler.u database.u server.u completion.u signature.u hover.u \
definition.u symbols.u folding.u
definition.u symbols.u folding.u formatting.u

server.u:server.icn database.u completion.u file_handler.u signature.u hover.u definition.u jsonrpc.u \
logger.u symbols.u folding.u
logger.u symbols.u folding.u formatting.u
hover.u:hover.icn signature.u
definition.u: definition.icn hover.u

Expand Down
14 changes: 8 additions & 6 deletions uni/ulsp/file_handler.icn
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,7 @@ class FileHandler(
while _line := temp_idoc.getUniFileLine(uri, lineNum) do {
# Check for procedures
every procedureName := key(internal_procedures) do {
if ReMatch("procedure\\s+" || procedureName || "\\s*\\(", _line) then {
if ReMatch("^\\s*procedure\\s+" || procedureName || "\\s*\\(", _line) then {
startPos := find(procedureName, _line)
endPos := startPos + *procedureName - 1
push(open_blocks, ["procedures", procedureName])
Expand All @@ -529,7 +529,7 @@ class FileHandler(

# Check for classes
every className := key(internal_classes) do {
if ReMatch("class\\s+" || className || "\\s*\\(", _line) then {
if ReMatch("^\\s*class\\s+" || className || ".*\\(", _line) then {
currentClass := className
startPos := find(className, _line)
endPos := startPos + *className - 1
Expand All @@ -549,7 +549,7 @@ class FileHandler(

# Check for methods
every methodName := key(internal_classes[className]["methods"]) do {
if ReMatch(".*method\\s+" || methodName || "\\s*\\(", _line) then {
if ReMatch("^\\s*method\\s+" || methodName || "\\s*\\(", _line) then {
startPos := find(methodName, _line)
endPos := startPos + *methodName - 1
push(open_blocks, ["methods", methodName])
Expand Down Expand Up @@ -912,9 +912,11 @@ class Context(uniAll, uri, line, lineNum, charNum, objectName, methodName, conte
contextCase := findContext()
totalFileLines := 0
f := open(uri) | fail
reads(f, stat(uri).size) ?
every upto('\n') do
totalFileLines +:= 1
if stat(uri).size > 0 then {
reads(f, stat(uri).size) ?
every upto('\n') do
totalFileLines +:= 1
}
f := close(f)
end

Expand Down
23 changes: 16 additions & 7 deletions uni/ulsp/folding.icn
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,24 @@ package ulsp
link regexp
link ximage

#<p>
# Processes all folding ranges in a document and constructs a result to return to the client.
#</p>
class FoldingRangeHandler(filehandler)

# Sets the class variables for the FoldingRangeHandler.
# Params: new_filehandler - The filehandler object created from the parameters of the
# request sent by the client.
#<p>
# Sets the class variables for the FoldingRangeHandler.
# <[param new_filehandler the filehandler object created using the request sent by the client]>
# <[param new_params passed through the message request]>
#</p>
method setVariables(new_filehandler)
filehandler := new_filehandler
end

#<p>
# Searches through the provided filehandler for all internal positions of symbols and
# constructs a result to send back to the client for all folding ranges.
#</p>
method run()
local results_list, tokenKind, tokenName, entry, startLine, endLine, result

Expand Down Expand Up @@ -42,10 +48,13 @@ class FoldingRangeHandler(filehandler)
return results_list |||:= findFoldingRanges()
end

# Parse through the filehandler's temp_idoc parser to find all regions that are
# large blocks of comments, large blocks of imports or links, and open sections
# between curly brackets.
# <i>This is intended for internal use only!</i>
#<p>
# Parse through the filehandler's temp_idoc parser to find all regions that are
# large blocks of comments, large blocks of imports or links, and open sections
# between curly brackets.
# <i>Used internally.</i>
# <[returns a list of all folding ranges.]>
#</p>
method findFoldingRanges()
local lineNum, _line, commentBlock, commentLine, results_list, open_blocks, startLine, character, ch,
single_quote, double_quote, importBlock, importLine
Expand Down
Loading