-
Notifications
You must be signed in to change notification settings - Fork 0
Python language server
Sergey Skorik edited this page Sep 11, 2018
·
11 revisions
- Create workspace from the Python stack with console-python3-simple project.
- Enable Python language server in the Installers tab and start the workspace.
- Create "calc.py" file with content:
import main.py
var2 = main.add(100, 200)
- Create “towers.py” file with content:
def towers(i, start, finish, middle):
if i > 0:
towers(i-1, start, middle, finish)
print('move disk from ', start, ' to ', finish)
towers ( i-1, middle, finish, start )
towers ( 5, 'X', 'Z', 'Y' )
- Create "main.py" with content:
class MyClass:
var = 1
variable = "variable"
def function(self):
print("This is a message inside the class.")
def add(a, b):
return a + b
- Language server initialization
- From the project open "main.py" file.
- Check
Finished language servers initialization, file path '/console-python3-simple/main.py'
message in the dev-machine console.
- Autocomplete feature
- Open "main.py" file.
- In the last line type code fragment like
myobjectx = MyClass()
. - Press ENTER button, type "myobjectx." and than Ctrl+Space buttons. Make sure that function, var and variable fields are available from the class in the proposal menu.
- Delete added lines
- Find definition feature
- Open "calc.py" file.
- Set cursor to 3:15 position and invoke Assistant -> Find Definition. The "main.py" file should be opened and add function should be selected.
- Close the "main.py" file. Repeat previous step using F4 key instead of Assistant -> Find Definition invocation.
- Code validation feature, Comment line
- Open "calc.py" file.
- Move cursor in 1:1 position.
- Type any symbol there and check that error marker is appeared. Click on error marker - the proposal widget should be show
invalid syntax
message. - Restore content. Error marker should disappear.
- Add empty line in the end of file and press SPACE button. Make sure that warning marker with message:
W293 blank line contains whitespace
in line 4 is present. - Delete this line. The warning marker should disappear.
- Move cursor in line 3 position and comment this line by Ctrl+/ buttons.
- Check that text in line 3 was changed from
var2 = main.add(100, 200)
to#var2 = main.add(100, 200)
. - Uncomment this line by Ctrl+/ buttons.
- Hover feature
- Open "main.py" file.
- Move mouse pointer on position 6:12(print function).
- Wait hover popup is appeared with text
Prints the values to a stream, of to sys.stdout by default
.
- Format code feature
- Open "towers.py" file.
- Select all text on line 7.
- Start Format option from context menu;
- Check that the file content after formatting selected code was changed to:
def towers(i, start, finish, middle):
if i > 0:
towers(i-1, start, middle, finish)
print('move disk from ', start, ' to ', finish)
towers ( i-1, middle, finish, start )
towers(5, 'X', 'Z', 'Y')
- Start Format option from context menu again.
- Check that the file content after full file formatting was changed to:
def towers(i, start, finish, middle):
if i > 0:
towers(i-1, start, middle, finish)
print('move disk from ', start, ' to ', finish)
towers(i-1, middle, finish, start)
towers(5, 'X', 'Z', 'Y')
Rename
- Open "main.py" file.
- Select "var" variable.
- Start Rename feature by Shift+F6 or from Assistant menu.
- Type new variable name.
- Check that the variable name was changed.
Find References
- Open "calc.py" file.
- Select
var2
variable. - Start Find References feature by pressing Alt+F7 buttons or from Assistant menu.
- Check that Find References panel is opened with
/console-python3-simple/calc.py From:3:0 To:3:5
result in it.
Signature Help
- Open "calc.py" file.
- Type
main.add
on line 4. - Type '(' symbol and wait for hover popup with
add(a,b)
text. - Delete added line
Go To Symbol
- Open "main.py" file.
- Start Go To Symbol feature by Ctrl+F12 buttons or from Assistant menu.
- Wait for Go To Symbol form is opened with next lines:
MyClass symbols(5)
var
variable
function
add
- Click on any of them and check that it correctly selected in file.