track these test files
- SHA
7b512c5ac8d5a199a0ae73d4b39ee156079d4466- Parents
-
d666496 - Tree
1d55475
7b512c5
7b512c5ac8d5a199a0ae73d4b39ee156079d4466d666496
1d55475| Status | File | + | - |
|---|---|---|---|
| A |
01_hover.py
|
49 | 0 |
| A |
02_completion.py
|
57 | 0 |
01_hover.pyadded@@ -0,0 +1,49 @@ | ||
| 1 | +# LSP Test 1: Hover Information (F1) | |
| 2 | +# =================================== | |
| 3 | +# | |
| 4 | +# Instructions: | |
| 5 | +# 1. Place cursor on any symbol below | |
| 6 | +# 2. Press F1 to see hover information | |
| 7 | +# 3. Press Escape to dismiss the hover popup | |
| 8 | +# | |
| 9 | +# Try hovering over: | |
| 10 | +# - Function names (greet, calculate_area) | |
| 11 | +# - Variable names (message, radius) | |
| 12 | +# - Built-in functions (print, len, range) | |
| 13 | +# - Type names (str, int, float, list) | |
| 14 | + | |
| 15 | +def greet(name: str) -> str: | |
| 16 | + """Return a greeting message for the given name.""" | |
| 17 | + message = f"Hello, {name}!" | |
| 18 | + return message | |
| 19 | + | |
| 20 | + | |
| 21 | +def calculate_area(radius: float) -> float: | |
| 22 | + """Calculate the area of a circle given its radius.""" | |
| 23 | + import math | |
| 24 | + return math.pi * radius ** 2 | |
| 25 | + | |
| 26 | + | |
| 27 | +class Person: | |
| 28 | + """A simple Person class for testing hover.""" | |
| 29 | + | |
| 30 | + def __init__(self, name: str, age: int): | |
| 31 | + self.name = name | |
| 32 | + self.age = age | |
| 33 | + | |
| 34 | + def introduce(self) -> str: | |
| 35 | + """Return an introduction string.""" | |
| 36 | + return f"I'm {self.name}, {self.age} years old." | |
| 37 | + | |
| 38 | + | |
| 39 | +# Test area - place cursor on these and press F1: | |
| 40 | +RESULT = greet("World") | |
| 41 | +area = calculate_area(5.0) | |
| 42 | +person = Person("Alice", 30) | |
| 43 | +intro = person.introduce() | |
| 44 | + | |
| 45 | +numbers = [1, 2, 3, 4, 5] | |
| 46 | +length = len(numbers) | |
| 47 | + | |
| 48 | +for i in range(10): | |
| 49 | + print(i) | |
02_completion.pyadded@@ -0,0 +1,57 @@ | ||
| 1 | +# LSP Test 2: Code Completion (Ctrl+Space) | |
| 2 | +# ========================================= | |
| 3 | +# | |
| 4 | +# Instructions: | |
| 5 | +# 1. Place cursor after a dot or partial word | |
| 6 | +# 2. Press Ctrl+Space to trigger completion | |
| 7 | +# 3. Use Up/Down arrows to navigate suggestions | |
| 8 | +# 4. Press Enter or Tab to accept a completion | |
| 9 | +# 5. Press Escape to dismiss without completing | |
| 10 | +# | |
| 11 | +# Try completing at the marked positions below: | |
| 12 | + | |
| 13 | +import os | |
| 14 | +import json | |
| 15 | +from pathlib import Path | |
| 16 | + | |
| 17 | +# Test 1: Module completions | |
| 18 | +# Place cursor after "os." and press Ctrl+Space | |
| 19 | +path = os. # <- complete here (try: getcwd, path, environ) | |
| 20 | + | |
| 21 | +# Test 2: String method completions | |
| 22 | +# Place cursor after "text." and press Ctrl+Space | |
| 23 | +text = "hello world" | |
| 24 | +upper = text. # <- complete here (try: upper, lower, split, strip) | |
| 25 | + | |
| 26 | +# Test 3: List method completions | |
| 27 | +numbers = [3, 1, 4, 1, 5] | |
| 28 | +numbers. # <- complete here (try: append, sort, reverse, pop) | |
| 29 | + | |
| 30 | +# Test 4: Dict method completions | |
| 31 | +data = {"name": "test", "value": 42} | |
| 32 | +keys = data. # <- complete here (try: keys, values, items, get) | |
| 33 | + | |
| 34 | +# Test 5: Path object completions | |
| 35 | +p = Path("/tmp") | |
| 36 | +p. # <- complete here (try: exists, is_file, read_text, mkdir) | |
| 37 | + | |
| 38 | +# Test 6: Partial word completion | |
| 39 | +# Type "pri" and press Ctrl+Space to complete to "print" | |
| 40 | +# pri # <- uncomment and complete | |
| 41 | + | |
| 42 | +# Test 7: Import completion | |
| 43 | +# from pathlib import P # <- complete after P (Path, PurePath, etc.) | |
| 44 | + | |
| 45 | + | |
| 46 | +class MyClass: | |
| 47 | + def __init__(self): | |
| 48 | + self.value = 100 | |
| 49 | + self.name = "test" | |
| 50 | + | |
| 51 | + def process(self): | |
| 52 | + # Test 8: Self completions | |
| 53 | + return self. # <- complete here (try: value, name) | |
| 54 | + | |
| 55 | + | |
| 56 | +obj = MyClass() | |
| 57 | +obj. # <- complete here (try: value, name, process) | |