Skip to content
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

error: '_stricmp' was not declared in this scope #35

Closed
wakaztahir opened this issue Jan 12, 2024 · 28 comments
Closed

error: '_stricmp' was not declared in this scope #35

wakaztahir opened this issue Jan 12, 2024 · 28 comments

Comments

@wakaztahir
Copy link
Contributor

wakaztahir commented Jan 12, 2024

This error occurs when I'm building the code using Cmake on Windows

LspCpp/include/LibLsp/lsp/Markup/string_ref.h:1015:32: error: '_stricmp' was not declared in this scope
 1015 |                         return _stricmp(this->c_str(), str.c_str());
          |                                ^~~~~~~~

The code is

                int compare_nocase(const string& str) const
                {
#ifdef _WIN32
                        return _stricmp(this->c_str(), str.c_str());
#else
                    return strcasecmp(this->c_str(), str.c_str());
#endif
                }
@kuafuwang
Copy link
Owner

can you help to fix all of this, and push a request. I didn't have windows PC now . I only have macbook.

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Jan 12, 2024

I am a beginner in C++, though I am trying, If I succeed, I'll send a PR

@kuafuwang
Copy link
Owner

I didn't build lsp with clion. I alway build with vs.

@kuafuwang
Copy link
Owner

Open cmd or powershell and generate visual studio project with CMake.

@kuafuwang
Copy link
Owner

then build with visual studio

@kuafuwang
Copy link
Owner

lsp need boost , it's easy to get boost lib with visual studio on windows.

@wakaztahir
Copy link
Contributor Author

The above errors may have occurred due to my faulty setup with boost and CLion or me not using the visual studio toolchain.

I have now run the server, It works, Server started, also printed the address and port to console, connected to a visual studio code host. I have added this code to start a websocket server

The only problem is that when the program starts, with initialize request std::cout is not printed to console, Not a single request prints to console, Its also kind of different from document didChange, didOpen

server.point.registerHandler(
                [&](const td_initialize::request &req) {
                    std::cout << "[Request] td_initialize\n";
                    td_initialize::response rsp;
                    CodeLensOptions code_lens_options;
                    code_lens_options.resolveProvider = true;
                    rsp.result.capabilities.codeLensProvider = code_lens_options;
                    return rsp;
                });

        server.point.registerHandler(
                [&](const td_semanticTokens_full::request &request) {
                    std::cout << "[Request] td_semanticTokens_full\n";
                    td_semanticTokens_full::response rsp;
                    return rsp;
                });

        server.point.registerHandler(
                [&](const td_semanticTokens_full_delta::request &request) {
                    std::cout << "[Request] td_semanticTokens_full_delta\n";
                    td_semanticTokens_full_delta::response rsp;
                    return rsp;
                });

        server.point.registerHandler(
                [&](const td_completion::request &request) {
                    std::cout << "[Request] td_completion\n";
                    td_completion::response rsp;
                    return rsp;
                });

        server.point.registerHandler(
                [&](const td_signatureHelp::request &request) {
                    std::cout << "[Request] td_signatureHelp\n";
                    td_signatureHelp::response rsp;
                    return rsp;
                });

        server.point.registerHandler(
                [&](const td_symbol::request &request) {
                    std::cout << "[Request] td_symbol\n";
                    td_symbol::response rsp;
                    return rsp;
                });

        server.point.registerHandler(
                [&](const td_typeHierarchy::request &request) {
                    std::cout << "[Request] td_typeHierarchy\n";
                    td_typeHierarchy::response rsp;
                    return rsp;
                });


        // std::thread([&]() {
        server.run();
        // }).detach();

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Jan 21, 2024

I'd prefer that there is an example that clearly states the usage of the whole thing by writing a very bare bones implementation

  • Provide syntax highlighting for a single statement like var x = 5;
  • Provide a single code completion e.g complete_me where it would appear when user writes complete
  • Provide a single signature help
  • And others, you get the point....

Could you please do this, This would make it easier for me to extend this project.

@kuafuwang
Copy link
Owner

I'd prefer that there is an example that clearly states the usage of the whole thing by writing a very bare bones implementation

  • Provide syntax highlighting for a single statement like var x = 5;
  • Provide a single code completion e.g complete_me where it would appear when user writes complete
  • Provide a single signature help
  • And others, you get the point....

Could you please do this, This would make it easier for me to extend this project.

This is an example

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Feb 2, 2024

Hi @kuafuwang

I get this message in the console and the program shuts down

Unknown notification message :

{"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

@kuafuwang
Copy link
Owner

Hi @kuafuwang

I get this message in the console and the program shuts down

Unknown notification message :

{"jsonrpc":"2.0","method":"$/setTrace","params":{"value":"off"}}

you can register notificaition handler to handler it.

@wakaztahir
Copy link
Contributor Author

Somehow I'm not receiving a semanticTokens/full request from the client Visual Studio Code

Can you check it out, What am I doing wrong ?

https://github.com/Qinetik/chemical-vscode
https://github.com/Qinetik/chemical

As you can see I've written the code to provide semantic tokens for a single statement, just to test, However I'm not receiving the semantic tokens request even though, I have sent true for full : semantic tokens in capabilities.

I've copied the some code from LPG server repository. I just want to get setup so I can write my own programming language. However its making me go crazy !

@kuafuwang
Copy link
Owner

Somehow I'm not receiving a semanticTokens/full request from the client Visual Studio Code

Can you check it out, What am I doing wrong ?

https://github.com/Qinetik/chemical-vscode https://github.com/Qinetik/chemical

As you can see I've written the code to provide semantic tokens for a single statement, just to test, However I'm not receiving the semantic tokens request even though, I have sent true for full : semantic tokens in capabilities.

I've copied the some code from LPG server repository. I just want to get setup so I can write my own programming language. However its making me go crazy !

I have try . But i didn't know why. It should send TextDocumentDidOpen notify first. but it didn't . You need to find out why the TextDocumentDidOpen notify didn't send by vscode. And i am buzy these day . It's chinese year now, i need to deal some thing.

@kuafuwang
Copy link
Owner

image you need to set the DocumentSelector like this with your language.

@wakaztahir
Copy link
Contributor Author

semanticTokens range request ... ?

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Feb 16, 2024

Also when the user is editing the document, server sends a semanticTokens request with textDocument containing its uri

However when I read the uri & source code from the file, it's not upto the current edits of the editor, So my tokens provide syntax highlighting for the previous source code which doesn't fit the current source code (in the editor, not saved) !!

How can I fix this...?

Do I need to implement some other request ?

@kuafuwang
Copy link
Owner

you could drop the outdate request, only return recent request. using document version to fix it.

@wakaztahir
Copy link
Contributor Author

I don't understand what you mean...

When I access the file, the source code is old. Unless user saved the file using ctrl + s and then the new source code is sent

@kuafuwang
Copy link
Owner

image
image

set the lsTextDocumentSyncKind opton to Incremental , and track the document change.

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Feb 19, 2024

I have registered the request like this

        _sp.registerHandler([&](Notify_TextDocumentDidChange::notify &notify) {

            _log.log(lsp::Log::Level::INFO, "TextDocumentDidChange Received 1");

            if (need_initialize_error) {
                return;
            }

            _log.log(lsp::Log::Level::INFO, "TextDocumentDidChange Received");
            const auto &params = notify.params;
            AbsolutePath path = params.textDocument.uri.GetAbsolutePath();
            if (ShouldIgnoreFileForIndexing(path))
                return;
//			work_space_mgr.OnChange(params);

        });

and I'm getting the following in my console

Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":7,"method":"textDocument/didChange","params":{"textDocument":{"version":4,"uri":"file:///d%3A/Prog
ramming/Chemical/chemical-vscode/sample/language.ch"},"contentChanges":[{"range":[{"line":0,"character":6},{"line":0,"ch
aracter":6}],"rangeOffset":6,"rangeLength":0,"text":" : int"}]}}

I don't understand what do you mean by "track the change", To track the change I'm adding this request handler, But its not getting triggered.

In the above code snippet you shared OnChange function, that's present in the library, what do I do with it

Checkout
https://github.com/Qinetik/chemical
https://github.com/Qinetik/chemical-vscode

@kuafuwang
Copy link
Owner

image

It seem work well to me.
track the change , it means using the code in the library to keep track the document change . and using the document content in workingfiles.

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Feb 22, 2024

on my computer, I am not getting TextDocumentDidChange Received 1, instead I'm getting This Error, This must be because of update to Lsp Spec, probably

Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":51,"method":"textDocument/didChange","params":{"textDocument":{"version":36,"uri":"file:///d%3A/Pr
ogramming/Chemical/chemical-vscode/sample/language.ch"},"contentChanges":[{"range":[{"line":0,"character":3},{"line":0,"
character":3}],"rangeOffset":3,"rangeLength":0,"text":"r"}]}}

@wakaztahir
Copy link
Contributor Author

The console output for (opening a file, changing something and then closing it), None of the requests handlers get triggered

Socket TcpServer 127.0.0.1 5007 start.
New client 127.0.0.1 connect.
td_initialize
Notify_InitializedNotification
Notify_InitializedNotification ClientPrefs Set
providing syntax highlighting
Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":2,"method":"textDocument/didChange","params":{"textDocument":{"version":2,"uri":"file:///d%3A/Prog
ramming/Chemical/chemical-vscode/sample/language.ch"},"contentChanges":[{"range":[{"line":0,"character":9},{"line":0,"ch
aracter":12}],"rangeOffset":9,"rangeLength":3,"text":""}]}}
Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":3,"method":"textDocument/didChange","params":{"textDocument":{"version":2,"uri":"file:///d%3A/Prog
ramming/Chemical/chemical-vscode/sample/language.ch"},"contentChanges":[]}}
providing syntax highlighting
Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":5,"method":"textDocument/didChange","params":{"textDocument":{"version":3,"uri":"file:///d%3A/Prog
ramming/Chemical/chemical-vscode/sample/language.ch"},"contentChanges":[{"range":[{"line":0,"character":0},{"line":0,"ch
aracter":14}],"rangeOffset":0,"rangeLength":14,"text":"#var x : int = 5;"}]}}
Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":6,"method":"textDocument/didChange","params":{"textDocument":{"version":3,"uri":"file:///d%3A/Prog
ramming/Chemical/chemical-vscode/sample/language.ch"},"contentChanges":[]}}
Unknown support request message when consumer message:
{"jsonrpc":"2.0","id":7,"method":"textDocument/didClose","params":{"textDocument":{"uri":"file:///d%3A/Programming/Chemi
cal/chemical-vscode/sample/language.ch"}}}

@wakaztahir
Copy link
Contributor Author

wakaztahir commented Feb 22, 2024

I just registered didOpen to be sent from vscode extension and it is also printing the same errror !
I thought maybe it's a json decoding issue, so I hardcoded the params in extension code to be empty and still the error occurred

I don't understand why it works on your machine and doesn't work on mine

1 - you are using a different version of vscode which sends a different request than mine (I'm using the latest 1.86.2)

2 - the lsp has some platform specific code that is causing a problem ! (I'm using windows)

You can checkout the repositories, I've updated the code

@kuafuwang
Copy link
Owner

I just registered didOpen to be sent from vscode extension and it is also printing the same errror ! I thought maybe it's a json decoding issue, so I hardcoded the params in extension code to be empty and still the error occurred

I don't understand why it works on your machine and doesn't work on mine

1 - you are using a different version of vscode which sends a different request than mine (I'm using the latest 1.86.2)

2 - the lsp has some platform specific code that is causing a problem ! (I'm using windows)

You can checkout the repositories, I've updated the code

image

it's Notification , no request!

@wakaztahir
Copy link
Contributor Author

Also Now I'm getting

Assertion failed: IsObject(), file D:\Programming\Chemical\chemical\LspCpp\third_party\rapidjson\include\rapidjson/docum
ent.h, line 1359

When I open the vscode, I make the change to the sample, which sends two on change requests to the server, first on change request contains zero changes , you can see in debug console, the second on change request contains a single change, which causes this assertion error

Try removing the "int" in sample.ch file when vscode instance opens, pull the latest code...

I believe this error is not being caused by my code

@kuafuwang
Copy link
Owner

the uir is wrong format that in LSP spec.

You need to debug it youself. You shouldn't send request or notify by yourself. you just need to
reister it on vscode before languageClient start.
languageClient.registerProposedFeatures();

@wakaztahir
Copy link
Contributor Author

microsoft/vscode#204906 (comment)

I think I'll be able to continue along with this since vscode is working & sending requests !

I'll produce a small language server that supports at least these features and keep it open source as MIT

1 - semantic highlighting
2 - basic code completion for identifiers and stuff
3 - basic go to definition

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants