Skip to content

Language server protocol semantic highlight works #70

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: language-server-protocol
Choose a base branch
from
Open
Binary file modified .nuget/NuGet.exe
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ namespace Nitra.ClientServer.Server.Lsp

_reader.UnknownRequestHandler += UnknownHandler;

_reader.RegisterHandler("$/fileActivatedNotification", FileActivated);
_reader.RegisterHandler("$/cancelRequest", CancelRequest);
_reader.RegisterHandler(Methods.Initialize, Initialize);
_reader.RegisterHandler(Methods.Shutdown, Shutdown);
Expand All @@ -83,6 +84,7 @@ namespace Nitra.ClientServer.Server.Lsp
_reader.RegisterHandler(Methods.TextDocumentDidSave, TextDocument_DidSave);
_reader.RegisterHandler(Methods.WorkspaceDidChangeConfiguration, Workspace_DidChangeConfiguration);
_reader.RegisterHandler(Methods.WorkspaceDidChangeWatchedFiles, Workspace_DidChangeWatchedFiles);

}

public Dispose() : void
Expand Down Expand Up @@ -110,13 +112,16 @@ namespace Nitra.ClientServer.Server.Lsp

match (message)
{
| FindSymbolReferences(_span, symbols, tag) => CompleteRequest(tag, symbols)
| Hint(text, _span, tag) => CompleteRequest(tag, text)
| CompleteWord(id, _span, completionList) => CompleteWord(message.FileId, completionList, id)
| FindSymbolReferences(_span, symbols, tag) => CompleteRequest(tag, symbols);
| Hint(text, _span, tag) => CompleteRequest(tag, text);
| CompleteWord(id, _span, completionList) => CompleteWord(message.FileId, completionList, id);
//| ProjectLoadingMessages (projectId, messages) => SendCompilerMessagesToClient(projectId, message.FileId, messages);
| ParsingMessages (projectId, messages) => lock (_locker) SendCompilerMessagesToClient(projectId, message.FileId, messages, pass=0);
| MappingMessages (projectId, messages) => lock (_locker) SendCompilerMessagesToClient(projectId, message.FileId, messages, pass=1);
| SemanticAnalysisMessages(projectId, messages) => lock (_locker) SendCompilerMessagesToClient(projectId, message.FileId, messages, pass=2);
| KeywordsHighlightingCreated as khc => WriteNotification(LspNotification("$/keywordHighlight"), new (uri = _solution.GetFileUri(khc.FileId), spanInfos = khc.spanInfos));
| SymbolsHighlightingCreated as shc => WriteNotification(LspNotification("$/symbolHighlight"), new (uri = _solution.GetFileUri(shc.FileId), spanInfos = shc.spanInfos));
| LanguageLoaded as ll => WriteNotification(LspNotification("$/languageLoaded"), new (SpanClassInfo = ll.spanClassInfos));
| _ => ()
}
}
Expand Down Expand Up @@ -180,6 +185,14 @@ namespace Nitra.ClientServer.Server.Lsp
WriteError(id, LspErrorCode.MethodNotFound, method)
}

private FileActivated(doc: TextDocumentItem): void
{
Log.Message($"LSP -> $$/fileActivatedNotification file=$(doc.Uri)", ConsoleColor.Cyan);
def fileId = _solution.GetFileId(doc.Uri);
foreach (project in _solution.GetProjects(fileId))
_router.AddMessage(ClientMessage.FileActivated(project.ProjectId, fileId, FileVersion(doc.Version)));
}

private CancelRequest(p : CancelParams) : void
{
Log.Message($"LSP -> $$/cancelRequest Id=$(p.Id)", ConsoleColor.Cyan);
Expand Down
2 changes: 1 addition & 1 deletion Nitra/DotNetLang/Collectors/BaseTypeReferenceSet.n
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ namespace DotNet
Debug.WriteLine("SupportsInheritanceTypeSymbol(IsBaseTypeSetEvaluated=true, IsMemberTableEvaluated=false)");
assert2(false);

| _ => assert2(false);
| _ => (); //assert2(false);
}

foreach (type in ancestorTypes)
Expand Down