-
Notifications
You must be signed in to change notification settings - Fork 62
feat: python language features inside proc python code block #991
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
Conversation
|
@scnwwu In main branch, formatting the above test code, the code disappearing problem occurs again just like before. Would you mind to have a check again? :) |
@jingjiajie, I have raised the issue #992 to track the changes. Thanks. |
|
@jingjiajie, I failed to build your PR code on my PC. |
Fixed |
|
There's a UX problem with this PR. The context menu item "Go to Definition", "Go to Declaration" etc. now always display. For most SAS code except PROC PYTHON, they have no functionality. It may be confusing for some user who rarely use Python. |
|
Got unexpected Got unexpected |
|
It does NOT work in browser build. |
@scnwwu It's controlled by the InitializeResult returned by onInitialize() at server side. I'm not sure if there's a way to dynamically control this. Could have a future investigation. Please let me know if you have more ideas about this design.
I found Microsoft maintained two language servers for Python, one is for desktop(Pyright https://github.com/microsoft/pyright), another is for browser(https://github.com/microsoft/vscode-python). In this PR we integrated the Pyright, so the browser version will become another work after this. |
Would you take a look at https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#client_registerCapability |
Good. It seems to work! |
@scnwwu I found they are caused by Lexer.startFrom(). The CodeZoneManager reads token by calling the Lexer.startFrom() in the middle of embedded code. Without having read "proc python" in previous lines, the Lexer can't regard the token as a part of embedded code, instead it regards it as a regular proc stmt, then gives wrong result. For example, the correct token should be 'print("x = " + x)' because it's in a proc python block, but if use Lexer.startFrom() from the start position of this line, the token returned is "print", that's wrong. Is it possible to remove all the occurance of Lexer.startFrom() function, instead use SyntaxProvider.getSyntax()? It returns correct tokens. However it seems to be a big complexity, I'll need your confirmation. |
@jingjiajie, please reset context in |
|
All reported issues so far have been fixed. |
|
@jingjiajie, the build is hang. Would you please address it? |
|
Put mouse indicator in the python code, try to 'Run Region' from the context menu, it will run proc python code block and others together. |
|
Python language features are disabled if the 'proc python' code block locates in a customized code block. |
Signed-off-by: Wei Wu <[email protected]> Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
sassoftware#1227) Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: b8735e2 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: ec49b40 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 583aa51 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 24dba01 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 01280f8 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: d4efe20 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 594c2fc I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 4c303bc Signed-off-by: Jonas <[email protected]> DCO Remediation Commit for Jonas Jing <[email protected]> I, Jonas Jing <[email protected]>, hereby add my Signed-off-by to this commit: 5cb31c1 Signed-off-by: Jonas Jing <[email protected]> DCO Remediation Commit for Jonas(Jiajie) Jing <[email protected]> I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 13a0fb7 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: b577b96 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 9bdc08d I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 4c62d85 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 805cb51 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 3d86770 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: bb0d46d I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 9b4f357 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: cf5615f I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 2f94357 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 89cc1dd I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: ecc5423 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: 492b8d8 I, Jonas(Jiajie) Jing <[email protected]>, hereby add my Signed-off-by to this commit: d15e767 Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: b8735e2 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: ec49b40 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 583aa51 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 24dba01 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 01280f8 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: d4efe20 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 594c2fc I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 4c303bc Signed-off-by: Jonas <[email protected]> Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
I, Jonas Jing <[email protected]>, hereby add my Signed-off-by to this commit: 5cb31c1 Signed-off-by: Jonas Jing <[email protected]> Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: b8735e2 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: ec49b40 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 583aa51 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 24dba01 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 01280f8 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: d4efe20 I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 594c2fc I, Jonas <[email protected]>, hereby add my Signed-off-by to this commit: 4c303bc Signed-off-by: Jonas <[email protected]> Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
cff6345 to
0ff2ae6
Compare
Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
@Zhirong2022 Fixed. |
Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
Signed-off-by: Jonas(Jiajie) Jing <[email protected]>
@Zhirong2022 Fixed. |
|
All raised issues have fixed. |




New libs are installed, please run npm install
Summary
"Pytight" language server is integrated, which is the Microsoft's official python language server.
Thanks to the Pyright, the following features are supported:

Code completion
Hover hint
Outline for python code
and functions shown in the picture:
Due to reasons, the following features are not yet included:
Python code formatting: It's not included in the Pyright language server. It has to be a feature we separately implement in the future.
Folding range for Python code: Because we set to use the Language Server side Folding range parsing rather than using the configuration file, it only recognizes the Folding ranges we returned from language server. However, the Python folding range is naturally implemented with configuration file, so it's ignored. We have to treat it as a separate feature and manually implement it with our language server in the future.
a simple test code: