-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-lsp.sh
More file actions
executable file
·250 lines (208 loc) · 6.37 KB
/
test-lsp.sh
File metadata and controls
executable file
·250 lines (208 loc) · 6.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
#!/bin/bash
# Gleeb LSP Test Script
# Tests all LSP features with a sample Fern project
set -e
echo "🧪 Gleeb LSP Testing Script"
echo "=========================="
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log_info() {
echo -e "${BLUE}[INFO]${NC} $1"
}
log_success() {
echo -e "${GREEN}[SUCCESS]${NC} $1"
}
log_warning() {
echo -e "${YELLOW}[WARNING]${NC} $1"
}
log_error() {
echo -e "${RED}[ERROR]${NC} $1"
}
# Check if we're in the gleeb directory
if [ ! -f "package.json" ] || [ ! -d "src" ]; then
log_error "This script must be run from the gleeb directory"
exit 1
fi
# Check Node.js
if ! command -v node &> /dev/null; then
log_error "Node.js is required but not installed"
exit 1
fi
# Check npm
if ! command -v npm &> /dev/null; then
log_error "npm is required but not installed"
exit 1
fi
# Install dependencies if needed
if [ ! -d "node_modules" ]; then
log_info "Installing dependencies..."
npm install
fi
# Build if needed
if [ ! -d "dist" ]; then
log_info "Building TypeScript source..."
npm run build
fi
# Test 1: Server starts without errors
log_info "Test 1: Starting LSP server..."
node dist/server.js --stdio < /dev/null > /dev/null 2>&1 &
SERVER_PID=$!
sleep 1
if kill -0 $SERVER_PID 2>/dev/null; then
log_success "✅ LSP server starts successfully"
kill $SERVER_PID 2>/dev/null || true
else
log_error "❌ LSP server failed to start"
exit 1
fi
# Test 2: Server responds to basic LSP messages
log_info "Test 2: Testing LSP communication..."
# Create a test LSP initialize request
cat > /tmp/lsp_test_request.json << 'EOF'
{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"processId":null,"rootPath":"/tmp","capabilities":{"textDocument":{"completion":{"completionItem":{"snippetSupport":true}},"hover":{"contentFormat":["markdown"]}}}}}
EOF
# Test server response
if timeout 5s node dist/server.js --stdio < /tmp/lsp_test_request.json > /dev/null 2>&1; then
log_success "✅ LSP server responds to initialize request"
else
log_warning "⚠️ LSP server communication test inconclusive"
fi
# Test 3: Check if completion provider is working
log_info "Test 3: Testing completion provider..."
# Create a test file with Fern code
cat > /tmp/test_fern.cpp << 'EOF'
#include <fern/fern.hpp>
using namespace Fern;
void test() {
Fern::
Colors::
auto text = Text(
EOF
# Test completion logic (simplified)
if node -e "
const fs = require('fs');
const path = require('path');
const { FernCompletionProvider } = require('./dist/completion');
const document = {
uri: 'file:///tmp/test_fern.cpp',
getText: () => fs.readFileSync('/tmp/test_fern.cpp', 'utf8')
};
const position = {
textDocument: { uri: 'file:///tmp/test_fern.cpp' },
position: { line: 4, character: 10 }
};
try {
const completions = FernCompletionProvider.getCompletions(document, position);
console.log('Completion test passed:', completions.length > 0);
} catch (e) {
console.log('Completion test failed:', e.message);
}
" 2>/dev/null | grep -q "passed: true"; then
log_success "✅ Completion provider is working"
else
log_warning "⚠️ Completion provider test inconclusive"
fi
# Test 4: Check diagnostic provider
log_info "Test 4: Testing diagnostic provider..."
# Create a test file without Fern include
cat > /tmp/test_fern_no_include.cpp << 'EOF'
using namespace Fern;
void test() {
auto text = Text(Point(0, 0), "test", 2, Colors::White);
}
EOF
if node -e "
const fs = require('fs');
const { FernDiagnostics } = require('./dist/diagnostics');
const document = {
uri: 'file:///tmp/test_fern_no_include.cpp',
getText: () => fs.readFileSync('/tmp/test_fern_no_include.cpp', 'utf8')
};
const settings = {
maxNumberOfProblems: 100,
enableDiagnostics: true,
enableCompletion: true
};
try {
const diagnostics = FernDiagnostics.validateDocument(document, settings);
console.log('Diagnostic test passed:', diagnostics.length > 0);
} catch (e) {
console.log('Diagnostic test failed:', e.message);
}
" 2>/dev/null | grep -q "passed: true"; then
log_success "✅ Diagnostic provider is working"
else
log_warning "⚠️ Diagnostic provider test inconclusive"
fi
# Test 5: Check hover provider
log_info "Test 5: Testing hover provider..."
if node -e "
const fs = require('fs');
const { FernHoverProvider } = require('./dist/hover');
const document = {
uri: 'file:///tmp/test_fern.cpp',
getText: () => fs.readFileSync('/tmp/test_fern.cpp', 'utf8')
};
const params = {
textDocument: { uri: 'file:///tmp/test_fern.cpp' },
position: { line: 6, character: 15 }
};
try {
const hover = FernHoverProvider.getHover(document, params);
console.log('Hover test passed:', hover !== null);
} catch (e) {
console.log('Hover test failed:', e.message);
}
" 2>/dev/null | grep -q "passed: true"; then
log_success "✅ Hover provider is working"
else
log_warning "⚠️ Hover provider test inconclusive"
fi
# Test 6: Performance test
log_info "Test 6: Performance test..."
start_time=$(date +%s%N)
for i in {1..10}; do
timeout 1s node dist/server.js --stdio < /dev/null > /dev/null 2>&1 &
SERVER_PID=$!
sleep 0.1
kill $SERVER_PID 2>/dev/null || true
done
end_time=$(date +%s%N)
duration=$(((end_time - start_time) / 1000000))
if [ $duration -lt 5000 ]; then
log_success "✅ Performance test passed (${duration}ms for 10 starts)"
else
log_warning "⚠️ Performance test slow (${duration}ms for 10 starts)"
fi
# Clean up
rm -f /tmp/lsp_test_request.json
rm -f /tmp/test_fern.cpp
rm -f /tmp/test_fern_no_include.cpp
echo ""
echo "=========================="
log_success "🎉 Gleeb LSP Testing Complete!"
echo "=========================="
echo ""
echo "How to use Gleeb LSP:"
echo "1. Start the server:"
echo " ./start-server.sh"
echo ""
echo "2. Configure your editor to use the LSP server:"
echo " - Server command: node $(pwd)/dist/server.js --stdio"
echo " - Language ID: cpp, c"
echo ""
echo "3. Test with a Fern file:"
echo " - Type 'Fern::' for function completions"
echo " - Type 'Colors::' for color completions"
echo " - Hover over widgets for documentation"
echo ""
echo "4. VS Code setup:"
echo " - Copy vscode-extension/ to a new folder"
echo " - Run: npm install && npm run compile"
echo " - Install as extension"
echo ""
echo "Ready to provide intelligent Fern development assistance! 🚀"