ADAPT-Chase commited on
Commit
09397c1
·
verified ·
1 Parent(s): 4b5c48e

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. projects/ui/serena-new/src/solidlsp/language_servers/elixir_tools/README.md +90 -0
  2. projects/ui/serena-new/src/solidlsp/language_servers/elixir_tools/__init__.py +1 -0
  3. projects/ui/serena-new/src/solidlsp/language_servers/elixir_tools/elixir_tools.py +353 -0
  4. projects/ui/serena-new/src/solidlsp/language_servers/omnisharp/initialize_params.json +631 -0
  5. projects/ui/serena-new/src/solidlsp/language_servers/omnisharp/runtime_dependencies.json +441 -0
  6. projects/ui/serena-new/src/solidlsp/language_servers/omnisharp/workspace_did_change_configuration.json +111 -0
  7. projects/ui/serena-new/src/solidlsp/util/subprocess_util.py +13 -0
  8. projects/ui/serena-new/src/solidlsp/util/zip.py +128 -0
  9. projects/ui/serena-new/test/resources/repos/bash/test_repo/config.sh +91 -0
  10. projects/ui/serena-new/test/resources/repos/bash/test_repo/main.sh +70 -0
  11. projects/ui/serena-new/test/resources/repos/bash/test_repo/utils.sh +83 -0
  12. projects/ui/serena-new/test/resources/repos/clojure/test_repo/deps.edn +5 -0
  13. projects/ui/serena-new/test/serena/__init__.py +1 -0
  14. projects/ui/serena-new/test/serena/test_edit_marker.py +13 -0
  15. projects/ui/serena-new/test/serena/test_mcp.py +300 -0
  16. projects/ui/serena-new/test/serena/test_serena_agent.py +286 -0
  17. projects/ui/serena-new/test/serena/test_symbol.py +162 -0
  18. projects/ui/serena-new/test/serena/test_symbol_editing.py +485 -0
  19. projects/ui/serena-new/test/serena/test_text_utils.py +484 -0
  20. projects/ui/serena-new/test/serena/test_tool_parameter_types.py +39 -0
projects/ui/serena-new/src/solidlsp/language_servers/elixir_tools/README.md ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Elixir Language Server Integration
2
+
3
+ This directory contains the integration for Elixir language support using [Next LS](https://github.com/elixir-tools/next-ls) from the elixir-tools project.
4
+
5
+ > **⚠️ Windows Not Supported**: Next LS does not provide Windows binaries, so Elixir language server integration is only available on Linux and macOS.
6
+
7
+ ## Known Issues
8
+
9
+ ### Next LS v0.23.3 Timeout Enumeration Bug
10
+ There is a known intermittent bug in Next LS v0.23.3 where `textDocument/definition` requests can fail with:
11
+ ```
12
+ Protocol.UndefinedError: protocol Enumerable not implemented for :timeout of type Atom
13
+ ```
14
+
15
+ This bug is tracked in [Next LS Issue #543](https://github.com/elixir-tools/next-ls/issues/543) and primarily occurs in CI environments. The affected test (`test_request_defining_symbol_none`) is marked as expected to fail until this upstream bug is resolved.
16
+
17
+ ## Prerequisites
18
+
19
+ Before using the Elixir language server integration, you need to have:
20
+
21
+ 1. **Elixir** installed and available in your PATH
22
+ - Install from: https://elixir-lang.org/install.html
23
+ - Verify with: `elixir --version`
24
+
25
+ 2. **Next LS** installed and available in your PATH
26
+ - Install from: https://github.com/elixir-tools/next-ls#installation
27
+ - Verify with: `nextls --version`
28
+
29
+ ## Features
30
+
31
+ The Elixir integration provides:
32
+
33
+ - **Language Server Protocol (LSP) support** via Next LS
34
+ - **File extension recognition** for `.ex` and `.exs` files
35
+ - **Project structure awareness** with proper handling of Elixir-specific directories:
36
+ - `_build/` - Compiled artifacts (ignored)
37
+ - `deps/` - Dependencies (ignored)
38
+ - `.elixir_ls/` - ElixirLS artifacts (ignored)
39
+ - `cover/` - Coverage reports (ignored)
40
+ - `lib/` - Source code (not ignored)
41
+ - `test/` - Test files (not ignored)
42
+
43
+ ## Configuration
44
+
45
+ The integration uses the default Next LS configuration with:
46
+
47
+ - **MIX_ENV**: `dev`
48
+ - **MIX_TARGET**: `host`
49
+ - **Experimental completions**: Disabled by default
50
+ - **Credo extension**: Enabled by default
51
+
52
+ ## Usage
53
+
54
+ The Elixir language server is automatically selected when working with Elixir projects. It will be used for:
55
+
56
+ - Code completion
57
+ - Go to definition
58
+ - Find references
59
+ - Document symbols
60
+ - Hover information
61
+ - Code formatting
62
+ - Diagnostics (via Credo integration)
63
+
64
+ ### Important: Project Compilation
65
+
66
+ Next LS requires your Elixir project to be **compiled** for optimal performance, especially for:
67
+ - Cross-file reference resolution
68
+ - Complete symbol information
69
+ - Accurate go-to-definition
70
+
71
+ **For production use**: Ensure your project is compiled with `mix compile` before using the language server.
72
+
73
+ **For testing**: The test suite automatically compiles the test repositories before running tests to ensure optimal Next LS performance.
74
+
75
+ ## Testing
76
+
77
+ Run the Elixir-specific tests with:
78
+
79
+ ```bash
80
+ pytest test/solidlsp/elixir/ -m elixir
81
+ ```
82
+
83
+ ## Implementation Details
84
+
85
+ - **Main class**: `ElixirTools` in `elixir_tools.py`
86
+ - **Initialization parameters**: Defined in `initialize_params.json`
87
+ - **Language identifier**: `"elixir"`
88
+ - **Command**: `nextls --stdio`
89
+
90
+ The implementation follows the same patterns as other language servers in this project, inheriting from `SolidLanguageServer` and providing Elixir-specific configuration and behavior.
projects/ui/serena-new/src/solidlsp/language_servers/elixir_tools/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+
projects/ui/serena-new/src/solidlsp/language_servers/elixir_tools/elixir_tools.py ADDED
@@ -0,0 +1,353 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import pathlib
4
+ import stat
5
+ import subprocess
6
+ import threading
7
+ import time
8
+
9
+ from overrides import override
10
+
11
+ from solidlsp.ls import SolidLanguageServer
12
+ from solidlsp.ls_config import LanguageServerConfig
13
+ from solidlsp.ls_logger import LanguageServerLogger
14
+ from solidlsp.ls_utils import FileUtils, PlatformId, PlatformUtils
15
+ from solidlsp.lsp_protocol_handler.lsp_types import InitializeParams
16
+ from solidlsp.lsp_protocol_handler.server import ProcessLaunchInfo
17
+ from solidlsp.settings import SolidLSPSettings
18
+
19
+ from ..common import RuntimeDependency
20
+
21
+
22
+ class ElixirTools(SolidLanguageServer):
23
+ """
24
+ Provides Elixir specific instantiation of the LanguageServer class using Next LS from elixir-tools.
25
+ """
26
+
27
+ @override
28
+ def is_ignored_dirname(self, dirname: str) -> bool:
29
+ # For Elixir projects, we should ignore:
30
+ # - _build: compiled artifacts
31
+ # - deps: dependencies
32
+ # - node_modules: if the project has JavaScript components
33
+ # - .elixir_ls: ElixirLS artifacts (in case both are present)
34
+ # - cover: coverage reports
35
+ return super().is_ignored_dirname(dirname) or dirname in ["_build", "deps", "node_modules", ".elixir_ls", "cover"]
36
+
37
+ def _is_next_ls_internal_file(self, abs_path: str) -> bool:
38
+ """Check if an absolute path is a Next LS internal file that should be ignored."""
39
+ return any(
40
+ pattern in abs_path
41
+ for pattern in [
42
+ ".burrito", # Next LS runtime directory
43
+ "next_ls_erts-", # Next LS Erlang runtime
44
+ "_next_ls_private_", # Next LS private files
45
+ "/priv/monkey/", # Next LS monkey patching directory
46
+ ]
47
+ )
48
+
49
+ @override
50
+ def _send_references_request(self, relative_file_path: str, line: int, column: int):
51
+ """Override to filter out Next LS internal files from references."""
52
+ from solidlsp.ls_utils import PathUtils
53
+
54
+ # Get the raw response from the parent implementation
55
+ raw_response = super()._send_references_request(relative_file_path, line, column)
56
+
57
+ if raw_response is None:
58
+ return None
59
+
60
+ # Filter out Next LS internal files
61
+ filtered_response = []
62
+ for item in raw_response:
63
+ if isinstance(item, dict) and "uri" in item:
64
+ abs_path = PathUtils.uri_to_path(item["uri"])
65
+ if self._is_next_ls_internal_file(abs_path):
66
+ self.logger.log(f"Filtering out Next LS internal file: {abs_path}", logging.DEBUG)
67
+ continue
68
+ filtered_response.append(item)
69
+
70
+ return filtered_response
71
+
72
+ @classmethod
73
+ def _get_elixir_version(cls):
74
+ """Get the installed Elixir version or None if not found."""
75
+ try:
76
+ result = subprocess.run(["elixir", "--version"], capture_output=True, text=True, check=False)
77
+ if result.returncode == 0:
78
+ return result.stdout.strip()
79
+ except FileNotFoundError:
80
+ return None
81
+ return None
82
+
83
+ @classmethod
84
+ def _setup_runtime_dependencies(
85
+ cls, logger: LanguageServerLogger, config: LanguageServerConfig, solidlsp_settings: SolidLSPSettings
86
+ ) -> str:
87
+ """
88
+ Setup runtime dependencies for Next LS.
89
+ Downloads the Next LS binary for the current platform and returns the path to the executable.
90
+ """
91
+ # Check if Elixir is available first
92
+ elixir_version = cls._get_elixir_version()
93
+ if not elixir_version:
94
+ raise RuntimeError(
95
+ "Elixir is not installed. Please install Elixir from https://elixir-lang.org/install.html and make sure it is added to your PATH."
96
+ )
97
+
98
+ logger.log(f"Found Elixir: {elixir_version}", logging.INFO)
99
+
100
+ platform_id = PlatformUtils.get_platform_id()
101
+
102
+ # Check for Windows and provide a helpful error message
103
+ if platform_id.value.startswith("win"):
104
+ raise RuntimeError(
105
+ "Windows is not supported by Next LS. The Next LS project does not provide Windows binaries. "
106
+ "Consider using Windows Subsystem for Linux (WSL) or a virtual machine with Linux/macOS."
107
+ )
108
+
109
+ valid_platforms = [
110
+ PlatformId.LINUX_x64,
111
+ PlatformId.LINUX_arm64,
112
+ PlatformId.OSX_x64,
113
+ PlatformId.OSX_arm64,
114
+ ]
115
+ assert platform_id in valid_platforms, f"Platform {platform_id} is not supported for Next LS at the moment"
116
+
117
+ next_ls_dir = os.path.join(cls.ls_resources_dir(solidlsp_settings), "next-ls")
118
+
119
+ NEXTLS_VERSION = "v0.23.4"
120
+
121
+ # Define runtime dependencies inline
122
+ runtime_deps = {
123
+ PlatformId.LINUX_x64: RuntimeDependency(
124
+ id="next_ls_linux_amd64",
125
+ platform_id="linux-x64",
126
+ url=f"https://github.com/elixir-tools/next-ls/releases/download/{NEXTLS_VERSION}/next_ls_linux_amd64",
127
+ archive_type="binary",
128
+ binary_name="next_ls_linux_amd64",
129
+ extract_path="next_ls",
130
+ ),
131
+ PlatformId.LINUX_arm64: RuntimeDependency(
132
+ id="next_ls_linux_arm64",
133
+ platform_id="linux-arm64",
134
+ url=f"https://github.com/elixir-tools/next-ls/releases/download/{NEXTLS_VERSION}/next_ls_linux_arm64",
135
+ archive_type="binary",
136
+ binary_name="next_ls_linux_arm64",
137
+ extract_path="next_ls",
138
+ ),
139
+ PlatformId.OSX_x64: RuntimeDependency(
140
+ id="next_ls_darwin_amd64",
141
+ platform_id="osx-x64",
142
+ url=f"https://github.com/elixir-tools/next-ls/releases/download/{NEXTLS_VERSION}/next_ls_darwin_amd64",
143
+ archive_type="binary",
144
+ binary_name="next_ls_darwin_amd64",
145
+ extract_path="next_ls",
146
+ ),
147
+ PlatformId.OSX_arm64: RuntimeDependency(
148
+ id="next_ls_darwin_arm64",
149
+ platform_id="osx-arm64",
150
+ url=f"https://github.com/elixir-tools/next-ls/releases/download/{NEXTLS_VERSION}/next_ls_darwin_arm64",
151
+ archive_type="binary",
152
+ binary_name="next_ls_darwin_arm64",
153
+ extract_path="next_ls",
154
+ ),
155
+ }
156
+
157
+ dependency = runtime_deps[platform_id]
158
+ executable_path = os.path.join(next_ls_dir, "nextls")
159
+ binary_path = os.path.join(next_ls_dir, dependency.binary_name)
160
+
161
+ if not os.path.exists(executable_path):
162
+ logger.log(f"Downloading Next LS binary from {dependency.url}", logging.INFO)
163
+ FileUtils.download_file(logger, dependency.url, binary_path)
164
+
165
+ # Make the binary executable on Unix-like systems
166
+ os.chmod(binary_path, stat.S_IRWXU | stat.S_IRGRP | stat.S_IXGRP | stat.S_IROTH | stat.S_IXOTH)
167
+
168
+ # Create a symlink with the expected name
169
+ if binary_path != executable_path:
170
+ if os.path.exists(executable_path):
171
+ os.remove(executable_path)
172
+ os.symlink(os.path.basename(binary_path), executable_path)
173
+
174
+ assert os.path.exists(executable_path), f"Next LS executable not found at {executable_path}"
175
+
176
+ logger.log(f"Next LS binary ready at: {executable_path}", logging.INFO)
177
+ return executable_path
178
+
179
+ def __init__(
180
+ self, config: LanguageServerConfig, logger: LanguageServerLogger, repository_root_path: str, solidlsp_settings: SolidLSPSettings
181
+ ):
182
+ nextls_executable_path = self._setup_runtime_dependencies(logger, config, solidlsp_settings)
183
+
184
+ super().__init__(
185
+ config,
186
+ logger,
187
+ repository_root_path,
188
+ ProcessLaunchInfo(cmd=f'"{nextls_executable_path}" --stdio', cwd=repository_root_path),
189
+ "elixir",
190
+ solidlsp_settings,
191
+ )
192
+ self.server_ready = threading.Event()
193
+ self.request_id = 0
194
+
195
+ # Set generous timeout for Next LS which can be slow to initialize and respond
196
+ self.set_request_timeout(180.0) # 60 seconds for all environments
197
+
198
+ @staticmethod
199
+ def _get_initialize_params(repository_absolute_path: str) -> InitializeParams:
200
+ """
201
+ Returns the initialize params for the Next LS Language Server.
202
+ """
203
+ root_uri = pathlib.Path(repository_absolute_path).as_uri()
204
+ initialize_params = {
205
+ "processId": os.getpid(),
206
+ "locale": "en",
207
+ "rootPath": repository_absolute_path,
208
+ "rootUri": root_uri,
209
+ "initializationOptions": {
210
+ "mix_env": "dev",
211
+ "mix_target": "host",
212
+ "experimental": {"completions": {"enable": False}},
213
+ "extensions": {"credo": {"enable": True, "cli_options": []}},
214
+ },
215
+ "capabilities": {
216
+ "textDocument": {
217
+ "synchronization": {"didSave": True, "dynamicRegistration": True},
218
+ "completion": {
219
+ "dynamicRegistration": True,
220
+ "completionItem": {"snippetSupport": True, "documentationFormat": ["markdown", "plaintext"]},
221
+ },
222
+ "definition": {"dynamicRegistration": True},
223
+ "references": {"dynamicRegistration": True},
224
+ "documentSymbol": {
225
+ "dynamicRegistration": True,
226
+ "hierarchicalDocumentSymbolSupport": True,
227
+ "symbolKind": {"valueSet": list(range(1, 27))},
228
+ },
229
+ "hover": {"dynamicRegistration": True, "contentFormat": ["markdown", "plaintext"]},
230
+ "formatting": {"dynamicRegistration": True},
231
+ "codeAction": {
232
+ "dynamicRegistration": True,
233
+ "codeActionLiteralSupport": {
234
+ "codeActionKind": {
235
+ "valueSet": [
236
+ "quickfix",
237
+ "refactor",
238
+ "refactor.extract",
239
+ "refactor.inline",
240
+ "refactor.rewrite",
241
+ "source",
242
+ "source.organizeImports",
243
+ ]
244
+ }
245
+ },
246
+ },
247
+ },
248
+ "workspace": {
249
+ "workspaceFolders": True,
250
+ "didChangeConfiguration": {"dynamicRegistration": True},
251
+ "executeCommand": {"dynamicRegistration": True},
252
+ },
253
+ },
254
+ "workspaceFolders": [{"uri": root_uri, "name": os.path.basename(repository_absolute_path)}],
255
+ }
256
+
257
+ return initialize_params
258
+
259
+ def _start_server(self):
260
+ """Start Next LS server process"""
261
+
262
+ def register_capability_handler(params):
263
+ return
264
+
265
+ def window_log_message(msg):
266
+ """Handle window/logMessage notifications from Next LS"""
267
+ message_text = msg.get("message", "")
268
+ self.logger.log(f"LSP: window/logMessage: {message_text}", logging.INFO)
269
+
270
+ # Check for the specific Next LS readiness signal
271
+ # Based on Next LS source: "Runtime for folder #{name} is ready..."
272
+ if "Runtime for folder" in message_text and "is ready..." in message_text:
273
+ self.logger.log("Next LS runtime is ready based on official log message", logging.INFO)
274
+ self.server_ready.set()
275
+
276
+ def do_nothing(params):
277
+ return
278
+
279
+ def check_server_ready(params):
280
+ """
281
+ Handle $/progress notifications from Next LS.
282
+ Keep as fallback for error detection, but primary readiness detection
283
+ is now done via window/logMessage handler.
284
+ """
285
+ value = params.get("value", {})
286
+
287
+ # Check for initialization completion progress (fallback signal)
288
+ if value.get("kind") == "end":
289
+ message = value.get("message", "")
290
+ if "has initialized!" in message:
291
+ self.logger.log("Next LS initialization progress completed", logging.INFO)
292
+ # Note: We don't set server_ready here - we wait for the log message
293
+
294
+ def work_done_progress(params):
295
+ """
296
+ Handle $/workDoneProgress notifications from Next LS.
297
+ Keep for completeness but primary readiness detection is via window/logMessage.
298
+ """
299
+ value = params.get("value", {})
300
+ if value.get("kind") == "end":
301
+ self.logger.log("Next LS work done progress completed", logging.INFO)
302
+ # Note: We don't set server_ready here - we wait for the log message
303
+
304
+ self.server.on_request("client/registerCapability", register_capability_handler)
305
+ self.server.on_notification("window/logMessage", window_log_message)
306
+ self.server.on_notification("$/progress", check_server_ready)
307
+ self.server.on_notification("window/workDoneProgress/create", do_nothing)
308
+ self.server.on_notification("$/workDoneProgress", work_done_progress)
309
+ self.server.on_notification("textDocument/publishDiagnostics", do_nothing)
310
+
311
+ self.logger.log("Starting Next LS server process", logging.INFO)
312
+ self.server.start()
313
+ initialize_params = self._get_initialize_params(self.repository_root_path)
314
+
315
+ self.logger.log(
316
+ "Sending initialize request from LSP client to LSP server and awaiting response",
317
+ logging.INFO,
318
+ )
319
+ init_response = self.server.send.initialize(initialize_params)
320
+
321
+ # Verify server capabilities - be more lenient with Next LS
322
+ self.logger.log(f"Next LS capabilities: {list(init_response['capabilities'].keys())}", logging.INFO)
323
+
324
+ # Next LS may not provide all capabilities immediately, so we check for basic ones
325
+ assert "textDocumentSync" in init_response["capabilities"], f"Missing textDocumentSync in {init_response['capabilities']}"
326
+
327
+ # Some capabilities might be optional or provided later
328
+ if "completionProvider" not in init_response["capabilities"]:
329
+ self.logger.log("Warning: completionProvider not available in initial capabilities", logging.WARNING)
330
+ if "definitionProvider" not in init_response["capabilities"]:
331
+ self.logger.log("Warning: definitionProvider not available in initial capabilities", logging.WARNING)
332
+
333
+ self.server.notify.initialized({})
334
+ self.completions_available.set()
335
+
336
+ # Wait for Next LS to send the specific "Runtime for folder X is ready..." log message
337
+ # This is the authoritative signal that Next LS is truly ready for requests
338
+ ready_timeout = 180.0
339
+ self.logger.log(f"Waiting up to {ready_timeout} seconds for Next LS runtime readiness...", logging.INFO)
340
+
341
+ if self.server_ready.wait(timeout=ready_timeout):
342
+ self.logger.log("Next LS is ready and available for requests", logging.INFO)
343
+
344
+ # Add a small settling period to ensure background indexing is complete
345
+ # Next LS often continues compilation/indexing in background after ready signal
346
+ settling_time = 120.0
347
+ self.logger.log(f"Allowing {settling_time} seconds for Next LS background indexing to complete...", logging.INFO)
348
+ time.sleep(settling_time)
349
+ self.logger.log("Next LS settling period complete", logging.INFO)
350
+ else:
351
+ error_msg = f"Next LS failed to initialize within {ready_timeout} seconds. This may indicate a problem with the Elixir installation, project compilation, or Next LS itself."
352
+ self.logger.log(error_msg, logging.ERROR)
353
+ raise RuntimeError(error_msg)
projects/ui/serena-new/src/solidlsp/language_servers/omnisharp/initialize_params.json ADDED
@@ -0,0 +1,631 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_description": "The parameters sent by the client when initializing the language server with the \"initialize\" request. More details at https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#initialize",
3
+ "processId": "os.getpid()",
4
+ "clientInfo": {
5
+ "name": "Visual Studio Code - Insiders",
6
+ "version": "1.82.0-insider"
7
+ },
8
+ "locale": "en",
9
+ "rootPath": "$rootPath",
10
+ "rootUri": "$rootUri",
11
+ "capabilities": {
12
+ "workspace": {
13
+ "applyEdit": true,
14
+ "workspaceEdit": {
15
+ "documentChanges": true,
16
+ "resourceOperations": [
17
+ "create",
18
+ "rename",
19
+ "delete"
20
+ ],
21
+ "failureHandling": "textOnlyTransactional",
22
+ "normalizesLineEndings": true,
23
+ "changeAnnotationSupport": {
24
+ "groupsOnLabel": true
25
+ }
26
+ },
27
+ "configuration": false,
28
+ "didChangeWatchedFiles": {
29
+ "dynamicRegistration": true,
30
+ "relativePatternSupport": true
31
+ },
32
+ "symbol": {
33
+ "dynamicRegistration": true,
34
+ "symbolKind": {
35
+ "valueSet": [
36
+ 1,
37
+ 2,
38
+ 3,
39
+ 4,
40
+ 5,
41
+ 6,
42
+ 7,
43
+ 8,
44
+ 9,
45
+ 10,
46
+ 11,
47
+ 12,
48
+ 13,
49
+ 14,
50
+ 15,
51
+ 16,
52
+ 17,
53
+ 18,
54
+ 19,
55
+ 20,
56
+ 21,
57
+ 22,
58
+ 23,
59
+ 24,
60
+ 25,
61
+ 26
62
+ ]
63
+ },
64
+ "tagSupport": {
65
+ "valueSet": [
66
+ 1
67
+ ]
68
+ },
69
+ "resolveSupport": {
70
+ "properties": [
71
+ "location.range"
72
+ ]
73
+ }
74
+ },
75
+ "codeLens": {
76
+ "refreshSupport": true
77
+ },
78
+ "executeCommand": {
79
+ "dynamicRegistration": true
80
+ },
81
+ "didChangeConfiguration": {
82
+ "dynamicRegistration": true
83
+ },
84
+ "workspaceFolders": true,
85
+ "semanticTokens": {
86
+ "refreshSupport": true
87
+ },
88
+ "fileOperations": {
89
+ "dynamicRegistration": true,
90
+ "didCreate": true,
91
+ "didRename": true,
92
+ "didDelete": true,
93
+ "willCreate": true,
94
+ "willRename": true,
95
+ "willDelete": true
96
+ },
97
+ "inlineValue": {
98
+ "refreshSupport": true
99
+ },
100
+ "inlayHint": {
101
+ "refreshSupport": true
102
+ },
103
+ "diagnostics": {
104
+ "refreshSupport": true
105
+ }
106
+ },
107
+ "textDocument": {
108
+ "publishDiagnostics": {
109
+ "relatedInformation": true,
110
+ "versionSupport": false,
111
+ "tagSupport": {
112
+ "valueSet": [
113
+ 1,
114
+ 2
115
+ ]
116
+ },
117
+ "codeDescriptionSupport": true,
118
+ "dataSupport": true
119
+ },
120
+ "synchronization": {
121
+ "dynamicRegistration": true,
122
+ "willSave": true,
123
+ "willSaveWaitUntil": true,
124
+ "didSave": true
125
+ },
126
+ "completion": {
127
+ "dynamicRegistration": true,
128
+ "contextSupport": true,
129
+ "completionItem": {
130
+ "snippetSupport": true,
131
+ "commitCharactersSupport": true,
132
+ "documentationFormat": [
133
+ "markdown",
134
+ "plaintext"
135
+ ],
136
+ "deprecatedSupport": true,
137
+ "preselectSupport": true,
138
+ "tagSupport": {
139
+ "valueSet": [
140
+ 1
141
+ ]
142
+ },
143
+ "insertReplaceSupport": true,
144
+ "resolveSupport": {
145
+ "properties": [
146
+ "documentation",
147
+ "detail",
148
+ "additionalTextEdits"
149
+ ]
150
+ },
151
+ "insertTextModeSupport": {
152
+ "valueSet": [
153
+ 1,
154
+ 2
155
+ ]
156
+ },
157
+ "labelDetailsSupport": true
158
+ },
159
+ "insertTextMode": 2,
160
+ "completionItemKind": {
161
+ "valueSet": [
162
+ 1,
163
+ 2,
164
+ 3,
165
+ 4,
166
+ 5,
167
+ 6,
168
+ 7,
169
+ 8,
170
+ 9,
171
+ 10,
172
+ 11,
173
+ 12,
174
+ 13,
175
+ 14,
176
+ 16,
177
+ 17,
178
+ 18,
179
+ 19,
180
+ 20,
181
+ 21,
182
+ 22,
183
+ 23,
184
+ 24,
185
+ 25
186
+ ]
187
+ },
188
+ "completionList": {
189
+ "itemDefaults": [
190
+ "commitCharacters",
191
+ "editRange",
192
+ "insertTextFormat",
193
+ "insertTextMode"
194
+ ]
195
+ }
196
+ },
197
+ "hover": {
198
+ "dynamicRegistration": true,
199
+ "contentFormat": [
200
+ "markdown",
201
+ "plaintext"
202
+ ]
203
+ },
204
+ "signatureHelp": {
205
+ "dynamicRegistration": true,
206
+ "signatureInformation": {
207
+ "documentationFormat": [
208
+ "markdown",
209
+ "plaintext"
210
+ ],
211
+ "parameterInformation": {
212
+ "labelOffsetSupport": true
213
+ },
214
+ "activeParameterSupport": true
215
+ },
216
+ "contextSupport": true
217
+ },
218
+ "definition": {
219
+ "dynamicRegistration": true,
220
+ "linkSupport": true
221
+ },
222
+ "references": {
223
+ "dynamicRegistration": true
224
+ },
225
+ "documentHighlight": {
226
+ "dynamicRegistration": true
227
+ },
228
+ "documentSymbol": {
229
+ "dynamicRegistration": true,
230
+ "symbolKind": {
231
+ "valueSet": [
232
+ 1,
233
+ 2,
234
+ 3,
235
+ 4,
236
+ 5,
237
+ 6,
238
+ 7,
239
+ 8,
240
+ 9,
241
+ 10,
242
+ 11,
243
+ 12,
244
+ 13,
245
+ 14,
246
+ 15,
247
+ 16,
248
+ 17,
249
+ 18,
250
+ 19,
251
+ 20,
252
+ 21,
253
+ 22,
254
+ 23,
255
+ 24,
256
+ 25,
257
+ 26
258
+ ]
259
+ },
260
+ "hierarchicalDocumentSymbolSupport": true,
261
+ "tagSupport": {
262
+ "valueSet": [
263
+ 1
264
+ ]
265
+ },
266
+ "labelSupport": true
267
+ },
268
+ "codeAction": {
269
+ "dynamicRegistration": true,
270
+ "isPreferredSupport": true,
271
+ "disabledSupport": true,
272
+ "dataSupport": true,
273
+ "resolveSupport": {
274
+ "properties": [
275
+ "edit"
276
+ ]
277
+ },
278
+ "codeActionLiteralSupport": {
279
+ "codeActionKind": {
280
+ "valueSet": [
281
+ "",
282
+ "quickfix",
283
+ "refactor",
284
+ "refactor.extract",
285
+ "refactor.inline",
286
+ "refactor.rewrite",
287
+ "source",
288
+ "source.organizeImports"
289
+ ]
290
+ }
291
+ },
292
+ "honorsChangeAnnotations": false
293
+ },
294
+ "codeLens": {
295
+ "dynamicRegistration": true
296
+ },
297
+ "formatting": {
298
+ "dynamicRegistration": true
299
+ },
300
+ "rangeFormatting": {
301
+ "dynamicRegistration": true
302
+ },
303
+ "onTypeFormatting": {
304
+ "dynamicRegistration": true
305
+ },
306
+ "rename": {
307
+ "dynamicRegistration": true,
308
+ "prepareSupport": true,
309
+ "prepareSupportDefaultBehavior": 1,
310
+ "honorsChangeAnnotations": true
311
+ },
312
+ "documentLink": {
313
+ "dynamicRegistration": true,
314
+ "tooltipSupport": true
315
+ },
316
+ "typeDefinition": {
317
+ "dynamicRegistration": true,
318
+ "linkSupport": true
319
+ },
320
+ "implementation": {
321
+ "dynamicRegistration": true,
322
+ "linkSupport": true
323
+ },
324
+ "colorProvider": {
325
+ "dynamicRegistration": true
326
+ },
327
+ "foldingRange": {
328
+ "dynamicRegistration": true,
329
+ "rangeLimit": 5000,
330
+ "lineFoldingOnly": true,
331
+ "foldingRangeKind": {
332
+ "valueSet": [
333
+ "comment",
334
+ "imports",
335
+ "region"
336
+ ]
337
+ },
338
+ "foldingRange": {
339
+ "collapsedText": false
340
+ }
341
+ },
342
+ "declaration": {
343
+ "dynamicRegistration": true,
344
+ "linkSupport": true
345
+ },
346
+ "selectionRange": {
347
+ "dynamicRegistration": true
348
+ },
349
+ "callHierarchy": {
350
+ "dynamicRegistration": true
351
+ },
352
+ "semanticTokens": {
353
+ "dynamicRegistration": true,
354
+ "tokenTypes": [
355
+ "namespace",
356
+ "type",
357
+ "class",
358
+ "enum",
359
+ "interface",
360
+ "struct",
361
+ "typeParameter",
362
+ "parameter",
363
+ "variable",
364
+ "property",
365
+ "enumMember",
366
+ "event",
367
+ "function",
368
+ "method",
369
+ "macro",
370
+ "keyword",
371
+ "modifier",
372
+ "comment",
373
+ "string",
374
+ "number",
375
+ "regexp",
376
+ "operator",
377
+ "decorator"
378
+ ],
379
+ "tokenModifiers": [
380
+ "declaration",
381
+ "definition",
382
+ "readonly",
383
+ "static",
384
+ "deprecated",
385
+ "abstract",
386
+ "async",
387
+ "modification",
388
+ "documentation",
389
+ "defaultLibrary"
390
+ ],
391
+ "formats": [
392
+ "relative"
393
+ ],
394
+ "requests": {
395
+ "range": true,
396
+ "full": {
397
+ "delta": true
398
+ }
399
+ },
400
+ "multilineTokenSupport": false,
401
+ "overlappingTokenSupport": false,
402
+ "serverCancelSupport": true,
403
+ "augmentsSyntaxTokens": false
404
+ },
405
+ "linkedEditingRange": {
406
+ "dynamicRegistration": true
407
+ },
408
+ "typeHierarchy": {
409
+ "dynamicRegistration": true
410
+ },
411
+ "inlineValue": {
412
+ "dynamicRegistration": true
413
+ },
414
+ "inlayHint": {
415
+ "dynamicRegistration": true,
416
+ "resolveSupport": {
417
+ "properties": [
418
+ "tooltip",
419
+ "textEdits",
420
+ "label.tooltip",
421
+ "label.location",
422
+ "label.command"
423
+ ]
424
+ }
425
+ },
426
+ "diagnostic": {
427
+ "dynamicRegistration": true,
428
+ "relatedDocumentSupport": false
429
+ }
430
+ },
431
+ "window": {
432
+ "showMessage": {
433
+ "messageActionItem": {
434
+ "additionalPropertiesSupport": true
435
+ }
436
+ },
437
+ "showDocument": {
438
+ "support": true
439
+ },
440
+ "workDoneProgress": true
441
+ },
442
+ "general": {
443
+ "staleRequestSupport": {
444
+ "cancel": true,
445
+ "retryOnContentModified": [
446
+ "textDocument/semanticTokens/full",
447
+ "textDocument/semanticTokens/range",
448
+ "textDocument/semanticTokens/full/delta"
449
+ ]
450
+ },
451
+ "regularExpressions": {
452
+ "engine": "ECMAScript",
453
+ "version": "ES2020"
454
+ },
455
+ "markdown": {
456
+ "parser": "marked",
457
+ "version": "1.1.0",
458
+ "allowedTags": [
459
+ "ul",
460
+ "li",
461
+ "p",
462
+ "code",
463
+ "blockquote",
464
+ "ol",
465
+ "h1",
466
+ "h2",
467
+ "h3",
468
+ "h4",
469
+ "h5",
470
+ "h6",
471
+ "hr",
472
+ "em",
473
+ "pre",
474
+ "table",
475
+ "thead",
476
+ "tbody",
477
+ "tr",
478
+ "th",
479
+ "td",
480
+ "div",
481
+ "del",
482
+ "a",
483
+ "strong",
484
+ "br",
485
+ "img",
486
+ "span"
487
+ ]
488
+ },
489
+ "positionEncodings": [
490
+ "utf-16"
491
+ ]
492
+ },
493
+ "notebookDocument": {
494
+ "synchronization": {
495
+ "dynamicRegistration": true,
496
+ "executionSummarySupport": true
497
+ }
498
+ },
499
+ "experimental": {
500
+ "snippetTextEdit": true,
501
+ "codeActionGroup": true,
502
+ "hoverActions": true,
503
+ "serverStatusNotification": true,
504
+ "colorDiagnosticOutput": true,
505
+ "openServerLogs": true,
506
+ "commands": {
507
+ "commands": [
508
+ "editor.action.triggerParameterHints"
509
+ ]
510
+ }
511
+ }
512
+ },
513
+ "initializationOptions": {
514
+ "RoslynExtensionsOptions": {
515
+ "EnableDecompilationSupport": false,
516
+ "EnableAnalyzersSupport": true,
517
+ "EnableImportCompletion": true,
518
+ "EnableAsyncCompletion": false,
519
+ "DocumentAnalysisTimeoutMs": 30000,
520
+ "DiagnosticWorkersThreadCount": 18,
521
+ "AnalyzeOpenDocumentsOnly": true,
522
+ "InlayHintsOptions": {
523
+ "EnableForParameters": false,
524
+ "ForLiteralParameters": false,
525
+ "ForIndexerParameters": false,
526
+ "ForObjectCreationParameters": false,
527
+ "ForOtherParameters": false,
528
+ "SuppressForParametersThatDifferOnlyBySuffix": false,
529
+ "SuppressForParametersThatMatchMethodIntent": false,
530
+ "SuppressForParametersThatMatchArgumentName": false,
531
+ "EnableForTypes": false,
532
+ "ForImplicitVariableTypes": false,
533
+ "ForLambdaParameterTypes": false,
534
+ "ForImplicitObjectCreation": false
535
+ },
536
+ "LocationPaths": null
537
+ },
538
+ "FormattingOptions": {
539
+ "OrganizeImports": false,
540
+ "EnableEditorConfigSupport": true,
541
+ "NewLine": "\n",
542
+ "UseTabs": false,
543
+ "TabSize": 4,
544
+ "IndentationSize": 4,
545
+ "SpacingAfterMethodDeclarationName": false,
546
+ "SeparateImportDirectiveGroups": false,
547
+ "SpaceWithinMethodDeclarationParenthesis": false,
548
+ "SpaceBetweenEmptyMethodDeclarationParentheses": false,
549
+ "SpaceAfterMethodCallName": false,
550
+ "SpaceWithinMethodCallParentheses": false,
551
+ "SpaceBetweenEmptyMethodCallParentheses": false,
552
+ "SpaceAfterControlFlowStatementKeyword": true,
553
+ "SpaceWithinExpressionParentheses": false,
554
+ "SpaceWithinCastParentheses": false,
555
+ "SpaceWithinOtherParentheses": false,
556
+ "SpaceAfterCast": false,
557
+ "SpaceBeforeOpenSquareBracket": false,
558
+ "SpaceBetweenEmptySquareBrackets": false,
559
+ "SpaceWithinSquareBrackets": false,
560
+ "SpaceAfterColonInBaseTypeDeclaration": true,
561
+ "SpaceAfterComma": true,
562
+ "SpaceAfterDot": false,
563
+ "SpaceAfterSemicolonsInForStatement": true,
564
+ "SpaceBeforeColonInBaseTypeDeclaration": true,
565
+ "SpaceBeforeComma": false,
566
+ "SpaceBeforeDot": false,
567
+ "SpaceBeforeSemicolonsInForStatement": false,
568
+ "SpacingAroundBinaryOperator": "single",
569
+ "IndentBraces": false,
570
+ "IndentBlock": true,
571
+ "IndentSwitchSection": true,
572
+ "IndentSwitchCaseSection": true,
573
+ "IndentSwitchCaseSectionWhenBlock": true,
574
+ "LabelPositioning": "oneLess",
575
+ "WrappingPreserveSingleLine": true,
576
+ "WrappingKeepStatementsOnSingleLine": true,
577
+ "NewLinesForBracesInTypes": true,
578
+ "NewLinesForBracesInMethods": true,
579
+ "NewLinesForBracesInProperties": true,
580
+ "NewLinesForBracesInAccessors": true,
581
+ "NewLinesForBracesInAnonymousMethods": true,
582
+ "NewLinesForBracesInControlBlocks": true,
583
+ "NewLinesForBracesInAnonymousTypes": true,
584
+ "NewLinesForBracesInObjectCollectionArrayInitializers": true,
585
+ "NewLinesForBracesInLambdaExpressionBody": true,
586
+ "NewLineForElse": true,
587
+ "NewLineForCatch": true,
588
+ "NewLineForFinally": true,
589
+ "NewLineForMembersInObjectInit": true,
590
+ "NewLineForMembersInAnonymousTypes": true,
591
+ "NewLineForClausesInQuery": true
592
+ },
593
+ "FileOptions": {
594
+ "SystemExcludeSearchPatterns": [
595
+ "**/node_modules/**/*",
596
+ "**/bin/**/*",
597
+ "**/obj/**/*",
598
+ "**/.git/**/*",
599
+ "**/.git",
600
+ "**/.svn",
601
+ "**/.hg",
602
+ "**/CVS",
603
+ "**/.DS_Store",
604
+ "**/Thumbs.db"
605
+ ],
606
+ "ExcludeSearchPatterns": []
607
+ },
608
+ "RenameOptions": {
609
+ "RenameOverloads": false,
610
+ "RenameInStrings": false,
611
+ "RenameInComments": false
612
+ },
613
+ "ImplementTypeOptions": {
614
+ "InsertionBehavior": 0,
615
+ "PropertyGenerationBehavior": 0
616
+ },
617
+ "DotNetCliOptions": {
618
+ "LocationPaths": null
619
+ },
620
+ "Plugins": {
621
+ "LocationPaths": null
622
+ }
623
+ },
624
+ "trace": "verbose",
625
+ "workspaceFolders": [
626
+ {
627
+ "uri": "$uri",
628
+ "name": "$name"
629
+ }
630
+ ]
631
+ }
projects/ui/serena-new/src/solidlsp/language_servers/omnisharp/runtime_dependencies.json ADDED
@@ -0,0 +1,441 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "_description": "Used to download the runtime dependencies for running OmniSharp. Obtained from https://github.com/dotnet/vscode-csharp/blob/main/package.json",
3
+ "runtimeDependencies": [
4
+ {
5
+ "id": "OmniSharp",
6
+ "description": "OmniSharp for Windows (.NET 4 / x86)",
7
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-win-x86-1.39.10.zip",
8
+ "installPath": ".omnisharp/1.39.10",
9
+ "platforms": [
10
+ "win32"
11
+ ],
12
+ "architectures": [
13
+ "x86"
14
+ ],
15
+ "installTestPath": "./.omnisharp/1.39.10/OmniSharp.exe",
16
+ "platformId": "win-x86",
17
+ "isFramework": true,
18
+ "integrity": "C81CE2099AD494EF63F9D88FAA70D55A68CF175810F944526FF94AAC7A5109F9",
19
+ "dotnet_version": "4",
20
+ "binaryName": "OmniSharp.exe"
21
+ },
22
+ {
23
+ "id": "OmniSharp",
24
+ "description": "OmniSharp for Windows (.NET 6 / x86)",
25
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-win-x86-net6.0-1.39.10.zip",
26
+ "installPath": ".omnisharp/1.39.10-net6.0",
27
+ "platforms": [
28
+ "win32"
29
+ ],
30
+ "architectures": [
31
+ "x86"
32
+ ],
33
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
34
+ "platformId": "win-x86",
35
+ "isFramework": false,
36
+ "integrity": "B7E62415CFC3DAC2154AC636C5BF0FB4B2C9BBF11B5A1FBF72381DDDED59791E",
37
+ "dotnet_version": "6",
38
+ "binaryName": "OmniSharp.exe"
39
+ },
40
+ {
41
+ "id": "OmniSharp",
42
+ "description": "OmniSharp for Windows (.NET 4 / x64)",
43
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-win-x64-1.39.10.zip",
44
+ "installPath": ".omnisharp/1.39.10",
45
+ "platforms": [
46
+ "win32"
47
+ ],
48
+ "architectures": [
49
+ "x86_64"
50
+ ],
51
+ "installTestPath": "./.omnisharp/1.39.10/OmniSharp.exe",
52
+ "platformId": "win-x64",
53
+ "isFramework": true,
54
+ "integrity": "BE0ED10AACEA17E14B78BD0D887DE5935D4ECA3712192A701F3F2100CA3C8B6E",
55
+ "dotnet_version": "4",
56
+ "binaryName": "OmniSharp.exe"
57
+ },
58
+ {
59
+ "id": "OmniSharp",
60
+ "description": "OmniSharp for Windows (.NET 6 / x64)",
61
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-win-x64-net6.0-1.39.10.zip",
62
+ "installPath": ".omnisharp/1.39.10-net6.0",
63
+ "platforms": [
64
+ "win32"
65
+ ],
66
+ "architectures": [
67
+ "x86_64"
68
+ ],
69
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
70
+ "platformId": "win-x64",
71
+ "isFramework": false,
72
+ "integrity": "A73327395E7EF92C1D8E307055463DA412662C03F077ECC743462FD2760BB537",
73
+ "dotnet_version": "6",
74
+ "binaryName": "OmniSharp.exe"
75
+ },
76
+ {
77
+ "id": "OmniSharp",
78
+ "description": "OmniSharp for Windows (.NET 4 / arm64)",
79
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-win-arm64-1.39.10.zip",
80
+ "installPath": ".omnisharp/1.39.10",
81
+ "platforms": [
82
+ "win32"
83
+ ],
84
+ "architectures": [
85
+ "arm64"
86
+ ],
87
+ "installTestPath": "./.omnisharp/1.39.10/OmniSharp.exe",
88
+ "platformId": "win-arm64",
89
+ "isFramework": true,
90
+ "integrity": "32FA0067B0639F87760CD1A769B16E6A53588C137C4D31661836CA4FB28D3DD6",
91
+ "dotnet_version": "4",
92
+ "binaryName": "OmniSharp.exe"
93
+ },
94
+ {
95
+ "id": "OmniSharp",
96
+ "description": "OmniSharp for Windows (.NET 6 / arm64)",
97
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-win-arm64-net6.0-1.39.10.zip",
98
+ "installPath": ".omnisharp/1.39.10-net6.0",
99
+ "platforms": [
100
+ "win32"
101
+ ],
102
+ "architectures": [
103
+ "arm64"
104
+ ],
105
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
106
+ "platformId": "win-arm64",
107
+ "isFramework": false,
108
+ "integrity": "433F9B360CAA7B4DDD85C604D5C5542C1A718BCF2E71B2BCFC7526E6D41F4E8F",
109
+ "dotnet_version": "6",
110
+ "binaryName": "OmniSharp.exe"
111
+ },
112
+ {
113
+ "id": "OmniSharp",
114
+ "description": "OmniSharp for OSX (Mono / x64)",
115
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-osx-1.39.10.zip",
116
+ "installPath": ".omnisharp/1.39.10",
117
+ "platforms": [
118
+ "darwin"
119
+ ],
120
+ "architectures": [
121
+ "x86_64",
122
+ "arm64"
123
+ ],
124
+ "binaries": [
125
+ "./mono.osx",
126
+ "./run"
127
+ ],
128
+ "installTestPath": "./.omnisharp/1.39.10/run",
129
+ "platformId": "osx",
130
+ "isFramework": true,
131
+ "integrity": "2CC42F0EC7C30CFA8858501D12ECB6FB685A1FCFB8ECB35698A4B12406551968",
132
+ "dotnet_version": "mono"
133
+ },
134
+ {
135
+ "id": "OmniSharp",
136
+ "description": "OmniSharp for OSX (.NET 6 / x64)",
137
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-osx-x64-net6.0-1.39.10.zip",
138
+ "installPath": ".omnisharp/1.39.10-net6.0",
139
+ "platforms": [
140
+ "darwin"
141
+ ],
142
+ "architectures": [
143
+ "x86_64"
144
+ ],
145
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
146
+ "platformId": "osx-x64",
147
+ "isFramework": false,
148
+ "integrity": "C9D6E9F2C839A66A7283AE6A9EC545EE049B48EB230D33E91A6322CB67FF9D97",
149
+ "dotnet_version": "6"
150
+ },
151
+ {
152
+ "id": "OmniSharp",
153
+ "description": "OmniSharp for OSX (.NET 6 / arm64)",
154
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-osx-arm64-net6.0-1.39.10.zip",
155
+ "installPath": ".omnisharp/1.39.10-net6.0",
156
+ "platforms": [
157
+ "darwin"
158
+ ],
159
+ "architectures": [
160
+ "arm64"
161
+ ],
162
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
163
+ "platformId": "osx-arm64",
164
+ "isFramework": false,
165
+ "integrity": "851350F52F83E3BAD5A92D113E4B9882FCD1DEB16AA84FF94B6F2CEE3C70051E",
166
+ "dotnet_version": "6"
167
+ },
168
+ {
169
+ "id": "OmniSharp",
170
+ "description": "OmniSharp for Linux (Mono / x86)",
171
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-x86-1.39.10.zip",
172
+ "installPath": ".omnisharp/1.39.10",
173
+ "platforms": [
174
+ "linux"
175
+ ],
176
+ "architectures": [
177
+ "x86",
178
+ "i686"
179
+ ],
180
+ "binaries": [
181
+ "./mono.linux-x86",
182
+ "./run"
183
+ ],
184
+ "installTestPath": "./.omnisharp/1.39.10/run",
185
+ "platformId": "linux-x86",
186
+ "isFramework": true,
187
+ "integrity": "474B1CDBAE64CFEC655FB6B0659BCE481023C48274441C72991E67B6E13E56A1",
188
+ "dotnet_version": "mono"
189
+ },
190
+ {
191
+ "id": "OmniSharp",
192
+ "description": "OmniSharp for Linux (Mono / x64)",
193
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-x64-1.39.10.zip",
194
+ "installPath": ".omnisharp/1.39.10",
195
+ "platforms": [
196
+ "linux"
197
+ ],
198
+ "architectures": [
199
+ "x86_64"
200
+ ],
201
+ "binaries": [
202
+ "./mono.linux-x86_64",
203
+ "./run"
204
+ ],
205
+ "installTestPath": "./.omnisharp/1.39.10/run",
206
+ "platformId": "linux-x64",
207
+ "isFramework": true,
208
+ "integrity": "FB4CAA47343265100349375D79DBCCE1868950CED675CB07FCBE8462EDBCDD37",
209
+ "dotnet_version": "mono"
210
+ },
211
+ {
212
+ "id": "OmniSharp",
213
+ "description": "OmniSharp for Linux (.NET 6 / x64)",
214
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-x64-net6.0-1.39.10.zip",
215
+ "installPath": ".omnisharp/1.39.10-net6.0",
216
+ "platforms": [
217
+ "linux"
218
+ ],
219
+ "architectures": [
220
+ "x86_64"
221
+ ],
222
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
223
+ "platformId": "linux-x64",
224
+ "isFramework": false,
225
+ "integrity": "0926D3BEA060BF4373356B2FC0A68C10D0DE1B1150100B551BA5932814CE51E2",
226
+ "dotnet_version": "6",
227
+ "binaryName": "OmniSharp"
228
+ },
229
+ {
230
+ "id": "OmniSharp",
231
+ "description": "OmniSharp for Linux (Mono / arm64)",
232
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-arm64-1.39.10.zip",
233
+ "installPath": ".omnisharp/1.39.10",
234
+ "platforms": [
235
+ "linux"
236
+ ],
237
+ "architectures": [
238
+ "arm64"
239
+ ],
240
+ "binaries": [
241
+ "./mono.linux-arm64",
242
+ "./run"
243
+ ],
244
+ "installTestPath": "./.omnisharp/1.39.10/run",
245
+ "platformId": "linux-arm64",
246
+ "isFramework": true,
247
+ "integrity": "478F3594DFD0167E9A56E36F0364A86C73F8132A3E7EA916CA1419EFE141D2CC",
248
+ "dotnet_version": "mono"
249
+ },
250
+ {
251
+ "id": "OmniSharp",
252
+ "description": "OmniSharp for Linux (.NET 6 / arm64)",
253
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-arm64-net6.0-1.39.10.zip",
254
+ "installPath": ".omnisharp/1.39.10-net6.0",
255
+ "platforms": [
256
+ "linux"
257
+ ],
258
+ "architectures": [
259
+ "arm64"
260
+ ],
261
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
262
+ "platformId": "linux-arm64",
263
+ "isFramework": false,
264
+ "integrity": "6FB6A572043A74220A92F6C19C7BB0C3743321C7563A815FD2702EF4FA7D688E",
265
+ "dotnet_version": "6"
266
+ },
267
+ {
268
+ "id": "OmniSharp",
269
+ "description": "OmniSharp for Linux musl (.NET 6 / x64)",
270
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-musl-x64-net6.0-1.39.10.zip",
271
+ "installPath": ".omnisharp/1.39.10-net6.0",
272
+ "platforms": [
273
+ "linux-musl"
274
+ ],
275
+ "architectures": [
276
+ "x86_64"
277
+ ],
278
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
279
+ "platformId": "linux-musl-x64",
280
+ "isFramework": false,
281
+ "integrity": "6BFDA3AD11DBB0C6514B86ECC3E1597CC41C6E309B7575F7C599E07D9E2AE610",
282
+ "dotnet_version": "6"
283
+ },
284
+ {
285
+ "id": "OmniSharp",
286
+ "description": "OmniSharp for Linux musl (.NET 6 / arm64)",
287
+ "url": "https://roslynomnisharp.blob.core.windows.net/releases/1.39.10/omnisharp-linux-musl-arm64-net6.0-1.39.10.zip",
288
+ "installPath": ".omnisharp/1.39.10-net6.0",
289
+ "platforms": [
290
+ "linux-musl"
291
+ ],
292
+ "architectures": [
293
+ "arm64"
294
+ ],
295
+ "installTestPath": "./.omnisharp/1.39.10-net6.0/OmniSharp.dll",
296
+ "platformId": "linux-musl-arm64",
297
+ "isFramework": false,
298
+ "integrity": "DA63619EA024EB9BBF6DB5A85C6150CAB5C0BD554544A3596ED1B17F926D6875",
299
+ "dotnet_version": "6"
300
+ },
301
+ {
302
+ "id": "RazorOmnisharp",
303
+ "description": "Razor Language Server for OmniSharp (Windows / x64)",
304
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/8d42e62ea4051381c219b3e31bc4eced/razorlanguageserver-win-x64-7.0.0-preview.23363.1.zip",
305
+ "installPath": ".razoromnisharp",
306
+ "platforms": [
307
+ "win32"
308
+ ],
309
+ "architectures": [
310
+ "x86_64"
311
+ ],
312
+ "platformId": "win-x64",
313
+ "dll_path": "OmniSharpPlugin/Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll"
314
+ },
315
+ {
316
+ "id": "RazorOmnisharp",
317
+ "description": "Razor Language Server for OmniSharp (Windows / x86)",
318
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/e440c4f3a4a96334fe177513935fa010/razorlanguageserver-win-x86-7.0.0-preview.23363.1.zip",
319
+ "installPath": ".razoromnisharp",
320
+ "platforms": [
321
+ "win32"
322
+ ],
323
+ "architectures": [
324
+ "x86"
325
+ ],
326
+ "platformId": "win-x86",
327
+ "dll_path": "OmniSharpPlugin/Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll"
328
+ },
329
+ {
330
+ "id": "RazorOmnisharp",
331
+ "description": "Razor Language Server for OmniSharp (Windows / ARM64)",
332
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/4ef26e45cf32fe8d51c0e7dd21f1fef6/razorlanguageserver-win-arm64-7.0.0-preview.23363.1.zip",
333
+ "installPath": ".razoromnisharp",
334
+ "platforms": [
335
+ "win32"
336
+ ],
337
+ "architectures": [
338
+ "arm64"
339
+ ],
340
+ "platformId": "win-arm64",
341
+ "dll_path": "OmniSharpPlugin/Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll"
342
+ },
343
+ {
344
+ "id": "RazorOmnisharp",
345
+ "description": "Razor Language Server for OmniSharp (Linux / x64)",
346
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/6d4e23a3c7cf0465743950a39515a716/razorlanguageserver-linux-x64-7.0.0-preview.23363.1.zip",
347
+ "installPath": ".razoromnisharp",
348
+ "platforms": [
349
+ "linux"
350
+ ],
351
+ "architectures": [
352
+ "x86_64"
353
+ ],
354
+ "binaries": [
355
+ "./rzls"
356
+ ],
357
+ "platformId": "linux-x64",
358
+ "dll_path": "OmniSharpPlugin/Microsoft.AspNetCore.Razor.OmniSharpPlugin.dll"
359
+ },
360
+ {
361
+ "id": "RazorOmnisharp",
362
+ "description": "Razor Language Server for OmniSharp (Linux ARM64)",
363
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/85deebd44647ebf65724cc291d722283/razorlanguageserver-linux-arm64-7.0.0-preview.23363.1.zip",
364
+ "installPath": ".razoromnisharp",
365
+ "platforms": [
366
+ "linux"
367
+ ],
368
+ "architectures": [
369
+ "arm64"
370
+ ],
371
+ "binaries": [
372
+ "./rzls"
373
+ ],
374
+ "platformId": "linux-arm64"
375
+ },
376
+ {
377
+ "id": "RazorOmnisharp",
378
+ "description": "Razor Language Server for OmniSharp (Linux musl / x64)",
379
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/4f0caa94ae182785655efb15eafcef23/razorlanguageserver-linux-musl-x64-7.0.0-preview.23363.1.zip",
380
+ "installPath": ".razoromnisharp",
381
+ "platforms": [
382
+ "linux-musl"
383
+ ],
384
+ "architectures": [
385
+ "x86_64"
386
+ ],
387
+ "binaries": [
388
+ "./rzls"
389
+ ],
390
+ "platformId": "linux-musl-x64"
391
+ },
392
+ {
393
+ "id": "RazorOmnisharp",
394
+ "description": "Razor Language Server for OmniSharp (Linux musl ARM64)",
395
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/0a24828206a6f3b4bc743d058ef88ce7/razorlanguageserver-linux-musl-arm64-7.0.0-preview.23363.1.zip",
396
+ "installPath": ".razoromnisharp",
397
+ "platforms": [
398
+ "linux-musl"
399
+ ],
400
+ "architectures": [
401
+ "arm64"
402
+ ],
403
+ "binaries": [
404
+ "./rzls"
405
+ ],
406
+ "platformId": "linux-musl-arm64"
407
+ },
408
+ {
409
+ "id": "RazorOmnisharp",
410
+ "description": "Razor Language Server for OmniSharp (macOS / x64)",
411
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/2afcafaf41082989efcc10405abb9314/razorlanguageserver-osx-x64-7.0.0-preview.23363.1.zip",
412
+ "installPath": ".razoromnisharp",
413
+ "platforms": [
414
+ "darwin"
415
+ ],
416
+ "architectures": [
417
+ "x86_64"
418
+ ],
419
+ "binaries": [
420
+ "./rzls"
421
+ ],
422
+ "platformId": "osx-x64"
423
+ },
424
+ {
425
+ "id": "RazorOmnisharp",
426
+ "description": "Razor Language Server for OmniSharp (macOS ARM64)",
427
+ "url": "https://download.visualstudio.microsoft.com/download/pr/aee63398-023f-48db-bba2-30162c68f0c4/8bf2ed2f00d481a5987e3eb5165afddd/razorlanguageserver-osx-arm64-7.0.0-preview.23363.1.zip",
428
+ "installPath": ".razoromnisharp",
429
+ "platforms": [
430
+ "darwin"
431
+ ],
432
+ "architectures": [
433
+ "arm64"
434
+ ],
435
+ "binaries": [
436
+ "./rzls"
437
+ ],
438
+ "platformId": "osx-arm64"
439
+ }
440
+ ]
441
+ }
projects/ui/serena-new/src/solidlsp/language_servers/omnisharp/workspace_did_change_configuration.json ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "RoslynExtensionsOptions": {
3
+ "EnableDecompilationSupport": false,
4
+ "EnableAnalyzersSupport": true,
5
+ "EnableImportCompletion": true,
6
+ "EnableAsyncCompletion": false,
7
+ "DocumentAnalysisTimeoutMs": 30000,
8
+ "DiagnosticWorkersThreadCount": 18,
9
+ "AnalyzeOpenDocumentsOnly": true,
10
+ "InlayHintsOptions": {
11
+ "EnableForParameters": false,
12
+ "ForLiteralParameters": false,
13
+ "ForIndexerParameters": false,
14
+ "ForObjectCreationParameters": false,
15
+ "ForOtherParameters": false,
16
+ "SuppressForParametersThatDifferOnlyBySuffix": false,
17
+ "SuppressForParametersThatMatchMethodIntent": false,
18
+ "SuppressForParametersThatMatchArgumentName": false,
19
+ "EnableForTypes": false,
20
+ "ForImplicitVariableTypes": false,
21
+ "ForLambdaParameterTypes": false,
22
+ "ForImplicitObjectCreation": false
23
+ },
24
+ "LocationPaths": null
25
+ },
26
+ "FormattingOptions": {
27
+ "OrganizeImports": false,
28
+ "EnableEditorConfigSupport": true,
29
+ "NewLine": "\n",
30
+ "UseTabs": false,
31
+ "TabSize": 4,
32
+ "IndentationSize": 4,
33
+ "SpacingAfterMethodDeclarationName": false,
34
+ "SeparateImportDirectiveGroups": false,
35
+ "SpaceWithinMethodDeclarationParenthesis": false,
36
+ "SpaceBetweenEmptyMethodDeclarationParentheses": false,
37
+ "SpaceAfterMethodCallName": false,
38
+ "SpaceWithinMethodCallParentheses": false,
39
+ "SpaceBetweenEmptyMethodCallParentheses": false,
40
+ "SpaceAfterControlFlowStatementKeyword": true,
41
+ "SpaceWithinExpressionParentheses": false,
42
+ "SpaceWithinCastParentheses": false,
43
+ "SpaceWithinOtherParentheses": false,
44
+ "SpaceAfterCast": false,
45
+ "SpaceBeforeOpenSquareBracket": false,
46
+ "SpaceBetweenEmptySquareBrackets": false,
47
+ "SpaceWithinSquareBrackets": false,
48
+ "SpaceAfterColonInBaseTypeDeclaration": true,
49
+ "SpaceAfterComma": true,
50
+ "SpaceAfterDot": false,
51
+ "SpaceAfterSemicolonsInForStatement": true,
52
+ "SpaceBeforeColonInBaseTypeDeclaration": true,
53
+ "SpaceBeforeComma": false,
54
+ "SpaceBeforeDot": false,
55
+ "SpaceBeforeSemicolonsInForStatement": false,
56
+ "SpacingAroundBinaryOperator": "single",
57
+ "IndentBraces": false,
58
+ "IndentBlock": true,
59
+ "IndentSwitchSection": true,
60
+ "IndentSwitchCaseSection": true,
61
+ "IndentSwitchCaseSectionWhenBlock": true,
62
+ "LabelPositioning": "oneLess",
63
+ "WrappingPreserveSingleLine": true,
64
+ "WrappingKeepStatementsOnSingleLine": true,
65
+ "NewLinesForBracesInTypes": true,
66
+ "NewLinesForBracesInMethods": true,
67
+ "NewLinesForBracesInProperties": true,
68
+ "NewLinesForBracesInAccessors": true,
69
+ "NewLinesForBracesInAnonymousMethods": true,
70
+ "NewLinesForBracesInControlBlocks": true,
71
+ "NewLinesForBracesInAnonymousTypes": true,
72
+ "NewLinesForBracesInObjectCollectionArrayInitializers": true,
73
+ "NewLinesForBracesInLambdaExpressionBody": true,
74
+ "NewLineForElse": true,
75
+ "NewLineForCatch": true,
76
+ "NewLineForFinally": true,
77
+ "NewLineForMembersInObjectInit": true,
78
+ "NewLineForMembersInAnonymousTypes": true,
79
+ "NewLineForClausesInQuery": true
80
+ },
81
+ "FileOptions": {
82
+ "SystemExcludeSearchPatterns": [
83
+ "**/node_modules/**/*",
84
+ "**/bin/**/*",
85
+ "**/obj/**/*",
86
+ "**/.git/**/*",
87
+ "**/.git",
88
+ "**/.svn",
89
+ "**/.hg",
90
+ "**/CVS",
91
+ "**/.DS_Store",
92
+ "**/Thumbs.db"
93
+ ],
94
+ "ExcludeSearchPatterns": []
95
+ },
96
+ "RenameOptions": {
97
+ "RenameOverloads": false,
98
+ "RenameInStrings": false,
99
+ "RenameInComments": false
100
+ },
101
+ "ImplementTypeOptions": {
102
+ "InsertionBehavior": 0,
103
+ "PropertyGenerationBehavior": 0
104
+ },
105
+ "DotNetCliOptions": {
106
+ "LocationPaths": null
107
+ },
108
+ "Plugins": {
109
+ "LocationPaths": null
110
+ }
111
+ }
projects/ui/serena-new/src/solidlsp/util/subprocess_util.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import platform
2
+ import subprocess
3
+
4
+
5
+ def subprocess_kwargs():
6
+ """
7
+ Returns a dictionary of keyword arguments for subprocess calls, adding platform-specific
8
+ flags that we want to use consistently.
9
+ """
10
+ kwargs = {}
11
+ if platform.system() == "Windows":
12
+ kwargs["creationflags"] = subprocess.CREATE_NO_WINDOW # type: ignore
13
+ return kwargs
projects/ui/serena-new/src/solidlsp/util/zip.py ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import fnmatch
2
+ import logging
3
+ import os
4
+ import sys
5
+ import zipfile
6
+ from pathlib import Path
7
+ from typing import Optional
8
+
9
+ log = logging.getLogger(__name__)
10
+
11
+
12
+ class SafeZipExtractor:
13
+ """
14
+ A utility class for extracting ZIP archives safely.
15
+
16
+ Features:
17
+ - Handles long file paths on Windows
18
+ - Skips files that fail to extract, continuing with the rest
19
+ - Creates necessary directories automatically
20
+ - Optional include/exclude pattern filters
21
+ """
22
+
23
+ def __init__(
24
+ self,
25
+ archive_path: Path,
26
+ extract_dir: Path,
27
+ verbose: bool = True,
28
+ include_patterns: Optional[list[str]] = None,
29
+ exclude_patterns: Optional[list[str]] = None,
30
+ ) -> None:
31
+ """
32
+ Initialize the SafeZipExtractor.
33
+
34
+ :param archive_path: Path to the ZIP archive file
35
+ :param extract_dir: Directory where files will be extracted
36
+ :param verbose: Whether to log status messages
37
+ :param include_patterns: List of glob patterns for files to extract (None = all files)
38
+ :param exclude_patterns: List of glob patterns for files to skip
39
+ """
40
+ self.archive_path = Path(archive_path)
41
+ self.extract_dir = Path(extract_dir)
42
+ self.verbose = verbose
43
+ self.include_patterns = include_patterns or []
44
+ self.exclude_patterns = exclude_patterns or []
45
+
46
+ def extract_all(self) -> None:
47
+ """
48
+ Extract all files from the archive, skipping any that fail.
49
+ """
50
+ if not self.archive_path.exists():
51
+ raise FileNotFoundError(f"Archive not found: {self.archive_path}")
52
+
53
+ if self.verbose:
54
+ log.info(f"Extracting from: {self.archive_path} to {self.extract_dir}")
55
+
56
+ with zipfile.ZipFile(self.archive_path, "r") as zip_ref:
57
+ for member in zip_ref.infolist():
58
+ if self._should_extract(member.filename):
59
+ self._extract_member(zip_ref, member)
60
+ elif self.verbose:
61
+ log.info(f"Skipped: {member.filename}")
62
+
63
+ def _should_extract(self, filename: str) -> bool:
64
+ """
65
+ Determine whether a file should be extracted based on include/exclude patterns.
66
+
67
+ :param filename: The file name from the archive
68
+ :return: True if the file should be extracted
69
+ """
70
+ # If include_patterns is set, only extract if it matches at least one pattern
71
+ if self.include_patterns:
72
+ if not any(fnmatch.fnmatch(filename, pattern) for pattern in self.include_patterns):
73
+ return False
74
+
75
+ # If exclude_patterns is set, skip if it matches any pattern
76
+ if self.exclude_patterns:
77
+ if any(fnmatch.fnmatch(filename, pattern) for pattern in self.exclude_patterns):
78
+ return False
79
+
80
+ return True
81
+
82
+ def _extract_member(self, zip_ref: zipfile.ZipFile, member: zipfile.ZipInfo) -> None:
83
+ """
84
+ Extract a single member from the archive with error handling.
85
+
86
+ :param zip_ref: Open ZipFile object
87
+ :param member: ZipInfo object representing the file
88
+ """
89
+ try:
90
+ target_path = self.extract_dir / member.filename
91
+
92
+ # Ensure directory structure exists
93
+ target_path.parent.mkdir(parents=True, exist_ok=True)
94
+
95
+ # Handle long paths on Windows
96
+ final_path = self._normalize_path(target_path)
97
+
98
+ # Extract file
99
+ with zip_ref.open(member) as source, open(final_path, "wb") as target:
100
+ target.write(source.read())
101
+
102
+ if self.verbose:
103
+ log.info(f"Extracted: {member.filename}")
104
+
105
+ except Exception as e:
106
+ log.error(f"Failed to extract {member.filename}: {e}")
107
+
108
+ @staticmethod
109
+ def _normalize_path(path: Path) -> Path:
110
+ """
111
+ Adjust path to handle long paths on Windows.
112
+
113
+ :param path: Original path
114
+ :return: Normalized path
115
+ """
116
+ if sys.platform.startswith("win"):
117
+ return Path(rf"\\?\{os.path.abspath(path)}")
118
+ return path
119
+
120
+
121
+ # Example usage:
122
+ # extractor = SafeZipExtractor(
123
+ # archive_path=Path("file.nupkg"),
124
+ # extract_dir=Path("extract_dir"),
125
+ # include_patterns=["*.dll", "*.xml"],
126
+ # exclude_patterns=["*.pdb"]
127
+ # )
128
+ # extractor.extract_all()
projects/ui/serena-new/test/resources/repos/bash/test_repo/config.sh ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Configuration script for project setup
4
+
5
+ # Environment variables
6
+ export PROJECT_NAME="bash-test-project"
7
+ export PROJECT_VERSION="1.0.0"
8
+ export LOG_LEVEL="INFO"
9
+ export CONFIG_DIR="./config"
10
+
11
+ # Default settings
12
+ DEFAULT_TIMEOUT=30
13
+ DEFAULT_RETRIES=3
14
+ DEFAULT_PORT=8080
15
+
16
+ # Configuration arrays
17
+ declare -A ENVIRONMENTS=(
18
+ ["dev"]="development"
19
+ ["prod"]="production"
20
+ ["test"]="testing"
21
+ )
22
+
23
+ declare -A DATABASE_CONFIGS=(
24
+ ["host"]="localhost"
25
+ ["port"]="5432"
26
+ ["name"]="myapp_db"
27
+ ["user"]="dbuser"
28
+ )
29
+
30
+ # Function to load configuration
31
+ load_config() {
32
+ local env="${1:-dev}"
33
+ local config_file="${CONFIG_DIR}/${env}.conf"
34
+
35
+ if [[ -f "$config_file" ]]; then
36
+ echo "Loading configuration from $config_file"
37
+ source "$config_file"
38
+ else
39
+ echo "Warning: Configuration file $config_file not found, using defaults"
40
+ fi
41
+ }
42
+
43
+ # Function to validate configuration
44
+ validate_config() {
45
+ local errors=0
46
+
47
+ if [[ -z "$PROJECT_NAME" ]]; then
48
+ echo "Error: PROJECT_NAME is not set" >&2
49
+ ((errors++))
50
+ fi
51
+
52
+ if [[ -z "$PROJECT_VERSION" ]]; then
53
+ echo "Error: PROJECT_VERSION is not set" >&2
54
+ ((errors++))
55
+ fi
56
+
57
+ if [[ $DEFAULT_PORT -lt 1024 || $DEFAULT_PORT -gt 65535 ]]; then
58
+ echo "Error: Invalid port number $DEFAULT_PORT" >&2
59
+ ((errors++))
60
+ fi
61
+
62
+ return $errors
63
+ }
64
+
65
+ # Function to print configuration
66
+ print_config() {
67
+ echo "=== Current Configuration ==="
68
+ echo "Project Name: $PROJECT_NAME"
69
+ echo "Version: $PROJECT_VERSION"
70
+ echo "Log Level: $LOG_LEVEL"
71
+ echo "Default Port: $DEFAULT_PORT"
72
+ echo "Default Timeout: $DEFAULT_TIMEOUT"
73
+ echo "Default Retries: $DEFAULT_RETRIES"
74
+
75
+ echo "\n=== Environments ==="
76
+ for env in "${!ENVIRONMENTS[@]}"; do
77
+ echo " $env: ${ENVIRONMENTS[$env]}"
78
+ done
79
+
80
+ echo "\n=== Database Configuration ==="
81
+ for key in "${!DATABASE_CONFIGS[@]}"; do
82
+ echo " $key: ${DATABASE_CONFIGS[$key]}"
83
+ done
84
+ }
85
+
86
+ # Initialize configuration if this script is run directly
87
+ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
88
+ load_config "$1"
89
+ validate_config
90
+ print_config
91
+ fi
projects/ui/serena-new/test/resources/repos/bash/test_repo/main.sh ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Main script demonstrating various bash features
4
+
5
+ # Global variables
6
+ readonly SCRIPT_NAME="Main Script"
7
+ COUNTER=0
8
+ declare -a ITEMS=("item1" "item2" "item3")
9
+
10
+ # Function definitions
11
+ function greet_user() {
12
+ local username="$1"
13
+ local greeting_type="${2:-default}"
14
+
15
+ case "$greeting_type" in
16
+ "formal")
17
+ echo "Good day, ${username}!"
18
+ ;;
19
+ "casual")
20
+ echo "Hey ${username}!"
21
+ ;;
22
+ *)
23
+ echo "Hello, ${username}!"
24
+ ;;
25
+ esac
26
+ }
27
+
28
+ function process_items() {
29
+ local -n items_ref=$1
30
+ local operation="$2"
31
+
32
+ for item in "${items_ref[@]}"; do
33
+ case "$operation" in
34
+ "count")
35
+ ((COUNTER++))
36
+ echo "Processing item $COUNTER: $item"
37
+ ;;
38
+ "uppercase")
39
+ echo "${item^^}"
40
+ ;;
41
+ *)
42
+ echo "Unknown operation: $operation"
43
+ return 1
44
+ ;;
45
+ esac
46
+ done
47
+ }
48
+
49
+ # Main execution
50
+ main() {
51
+ echo "Starting $SCRIPT_NAME"
52
+
53
+ if [[ $# -eq 0 ]]; then
54
+ echo "Usage: $0 <username> [greeting_type]"
55
+ exit 1
56
+ fi
57
+
58
+ local user="$1"
59
+ local greeting="${2:-default}"
60
+
61
+ greet_user "$user" "$greeting"
62
+
63
+ echo "Processing items..."
64
+ process_items ITEMS "count"
65
+
66
+ echo "Script completed successfully"
67
+ }
68
+
69
+ # Run main function with all arguments
70
+ main "$@"
projects/ui/serena-new/test/resources/repos/bash/test_repo/utils.sh ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
3
+ # Utility functions for bash scripting
4
+
5
+ # String manipulation functions
6
+ function to_uppercase() {
7
+ echo "${1^^}"
8
+ }
9
+
10
+ function to_lowercase() {
11
+ echo "${1,,}"
12
+ }
13
+
14
+ function trim_whitespace() {
15
+ local var="$1"
16
+ var="${var#"${var%%[![:space:]]*}"}"
17
+ var="${var%"${var##*[![:space:]]}"}"
18
+ echo "$var"
19
+ }
20
+
21
+ # File operations
22
+ function backup_file() {
23
+ local file="$1"
24
+ local backup_dir="${2:-./backups}"
25
+
26
+ if [[ ! -f "$file" ]]; then
27
+ echo "Error: File '$file' does not exist" >&2
28
+ return 1
29
+ fi
30
+
31
+ mkdir -p "$backup_dir"
32
+ cp "$file" "${backup_dir}/$(basename "$file").$(date +%Y%m%d_%H%M%S).bak"
33
+ echo "Backup created for $file"
34
+ }
35
+
36
+ # Array operations
37
+ function contains_element() {
38
+ local element="$1"
39
+ shift
40
+ local array=("$@")
41
+
42
+ for item in "${array[@]}"; do
43
+ if [[ "$item" == "$element" ]]; then
44
+ return 0
45
+ fi
46
+ done
47
+ return 1
48
+ }
49
+
50
+ # Logging functions
51
+ function log_message() {
52
+ local level="$1"
53
+ local message="$2"
54
+ local timestamp=$(date '+%Y-%m-%d %H:%M:%S')
55
+
56
+ case "$level" in
57
+ "ERROR")
58
+ echo "[$timestamp] ERROR: $message" >&2
59
+ ;;
60
+ "WARN")
61
+ echo "[$timestamp] WARN: $message" >&2
62
+ ;;
63
+ "INFO")
64
+ echo "[$timestamp] INFO: $message"
65
+ ;;
66
+ "DEBUG")
67
+ [[ "${DEBUG:-false}" == "true" ]] && echo "[$timestamp] DEBUG: $message"
68
+ ;;
69
+ *)
70
+ echo "[$timestamp] $message"
71
+ ;;
72
+ esac
73
+ }
74
+
75
+ # Validation functions
76
+ function is_valid_email() {
77
+ local email="$1"
78
+ [[ "$email" =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]]
79
+ }
80
+
81
+ function is_number() {
82
+ [[ $1 =~ ^[0-9]+$ ]]
83
+ }
projects/ui/serena-new/test/resources/repos/clojure/test_repo/deps.edn ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ {:paths ["src"]
2
+ :deps {org.clojure/clojure {:mvn/version "1.11.1"}}
3
+ :aliases
4
+ {:test {:extra-paths ["test"]
5
+ :extra-deps {org.clojure/test.check {:mvn/version "1.1.1"}}}}}
projects/ui/serena-new/test/serena/__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+
projects/ui/serena-new/test/serena/test_edit_marker.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from serena.tools import CreateTextFileTool, ReadFileTool, Tool
2
+
3
+
4
+ class TestEditMarker:
5
+ def test_tool_can_edit_method(self):
6
+ """Test that Tool.can_edit() method works correctly"""
7
+ # Non-editing tool should return False
8
+ assert issubclass(ReadFileTool, Tool)
9
+ assert not ReadFileTool.can_edit()
10
+
11
+ # Editing tool should return True
12
+ assert issubclass(CreateTextFileTool, Tool)
13
+ assert CreateTextFileTool.can_edit()
projects/ui/serena-new/test/serena/test_mcp.py ADDED
@@ -0,0 +1,300 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Tests for the mcp.py module in serena."""
2
+
3
+ import pytest
4
+ from mcp.server.fastmcp.tools.base import Tool as MCPTool
5
+
6
+ from serena.agent import Tool, ToolRegistry
7
+ from serena.config.context_mode import SerenaAgentContext
8
+ from serena.mcp import SerenaMCPFactory
9
+
10
+ make_tool = SerenaMCPFactory.make_mcp_tool
11
+
12
+
13
+ # Create a mock agent for tool initialization
14
+ class MockAgent:
15
+ def __init__(self):
16
+ self.project_config = None
17
+ self.serena_config = None
18
+
19
+ @staticmethod
20
+ def get_context() -> SerenaAgentContext:
21
+ return SerenaAgentContext.load_default()
22
+
23
+
24
+ class BaseMockTool(Tool):
25
+ """A mock Tool class for testing."""
26
+
27
+ def __init__(self):
28
+ super().__init__(MockAgent()) # type: ignore
29
+
30
+
31
+ class BasicTool(BaseMockTool):
32
+ """A mock Tool class for testing."""
33
+
34
+ def apply(self, name: str, age: int = 0) -> str:
35
+ """This is a test function.
36
+
37
+ :param name: The person's name
38
+ :param age: The person's age
39
+ :return: A greeting message
40
+ """
41
+ return f"Hello {name}, you are {age} years old!"
42
+
43
+ def apply_ex(
44
+ self,
45
+ log_call: bool = True,
46
+ catch_exceptions: bool = True,
47
+ **kwargs,
48
+ ) -> str:
49
+ """Mock implementation of apply_ex."""
50
+ return self.apply(**kwargs)
51
+
52
+
53
+ def test_make_tool_basic() -> None:
54
+ """Test that make_tool correctly creates an MCP tool from a Tool object."""
55
+ mock_tool = BasicTool()
56
+
57
+ mcp_tool = make_tool(mock_tool)
58
+
59
+ # Test that the MCP tool has the correct properties
60
+ assert isinstance(mcp_tool, MCPTool)
61
+ assert mcp_tool.name == "basic"
62
+ assert "This is a test function. Returns A greeting message." in mcp_tool.description
63
+
64
+ # Test that the parameters were correctly processed
65
+ parameters = mcp_tool.parameters
66
+ assert "properties" in parameters
67
+ assert "name" in parameters["properties"]
68
+ assert "age" in parameters["properties"]
69
+ assert parameters["properties"]["name"]["description"] == "The person's name."
70
+ assert parameters["properties"]["age"]["description"] == "The person's age."
71
+
72
+
73
+ def test_make_tool_execution() -> None:
74
+ """Test that the execution function created by make_tool works correctly."""
75
+ mock_tool = BasicTool()
76
+ mcp_tool = make_tool(mock_tool)
77
+
78
+ # Execute the MCP tool function
79
+ result = mcp_tool.fn(name="Alice", age=30)
80
+
81
+ assert result == "Hello Alice, you are 30 years old!"
82
+
83
+
84
+ def test_make_tool_no_params() -> None:
85
+ """Test make_tool with a function that has no parameters."""
86
+
87
+ class NoParamsTool(BaseMockTool):
88
+ def apply(self) -> str:
89
+ """This is a test function with no parameters.
90
+
91
+ :return: A simple result
92
+ """
93
+ return "Simple result"
94
+
95
+ def apply_ex(self, *args, **kwargs) -> str:
96
+ return self.apply()
97
+
98
+ tool = NoParamsTool()
99
+ mcp_tool = make_tool(tool)
100
+
101
+ assert mcp_tool.name == "no_params"
102
+ assert "This is a test function with no parameters. Returns A simple result." in mcp_tool.description
103
+ assert mcp_tool.parameters["properties"] == {}
104
+
105
+
106
+ def test_make_tool_no_return_description() -> None:
107
+ """Test make_tool with a function that has no return description."""
108
+
109
+ class NoReturnTool(BaseMockTool):
110
+ def apply(self, param: str) -> str:
111
+ """This is a test function.
112
+
113
+ :param param: The parameter
114
+ """
115
+ return f"Processed: {param}"
116
+
117
+ def apply_ex(self, *args, **kwargs) -> str:
118
+ return self.apply(**kwargs)
119
+
120
+ tool = NoReturnTool()
121
+ mcp_tool = make_tool(tool)
122
+
123
+ assert mcp_tool.name == "no_return"
124
+ assert mcp_tool.description == "This is a test function."
125
+ assert mcp_tool.parameters["properties"]["param"]["description"] == "The parameter."
126
+
127
+
128
+ def test_make_tool_parameter_not_in_docstring() -> None:
129
+ """Test make_tool when a parameter in properties is not in the docstring."""
130
+
131
+ class MissingParamTool(BaseMockTool):
132
+ def apply(self, name: str, missing_param: str = "") -> str:
133
+ """This is a test function.
134
+
135
+ :param name: The person's name
136
+ """
137
+ return f"Hello {name}! Missing param: {missing_param}"
138
+
139
+ def apply_ex(self, *args, **kwargs) -> str:
140
+ return self.apply(**kwargs)
141
+
142
+ tool = MissingParamTool()
143
+ mcp_tool = make_tool(tool)
144
+
145
+ assert "name" in mcp_tool.parameters["properties"]
146
+ assert "missing_param" in mcp_tool.parameters["properties"]
147
+ assert mcp_tool.parameters["properties"]["name"]["description"] == "The person's name."
148
+ assert "description" not in mcp_tool.parameters["properties"]["missing_param"]
149
+
150
+
151
+ def test_make_tool_multiline_docstring() -> None:
152
+ """Test make_tool with a complex multi-line docstring."""
153
+
154
+ class ComplexDocTool(BaseMockTool):
155
+ def apply(self, project_file_path: str, host: str, port: int) -> str:
156
+ """Create an MCP server.
157
+
158
+ This function creates and configures a Model Context Protocol server
159
+ with the specified settings.
160
+
161
+ :param project_file_path: The path to the project file, or None
162
+ :param host: The host to bind to
163
+ :param port: The port to bind to
164
+ :return: A configured FastMCP server instance
165
+ """
166
+ return f"Server config: {project_file_path}, {host}:{port}"
167
+
168
+ def apply_ex(self, *args, **kwargs) -> str:
169
+ return self.apply(**kwargs)
170
+
171
+ tool = ComplexDocTool()
172
+ mcp_tool = make_tool(tool)
173
+
174
+ assert "Create an MCP server" in mcp_tool.description
175
+ assert "Returns A configured FastMCP server instance" in mcp_tool.description
176
+ assert mcp_tool.parameters["properties"]["project_file_path"]["description"] == "The path to the project file, or None."
177
+ assert mcp_tool.parameters["properties"]["host"]["description"] == "The host to bind to."
178
+ assert mcp_tool.parameters["properties"]["port"]["description"] == "The port to bind to."
179
+
180
+
181
+ def test_make_tool_capitalization_and_periods() -> None:
182
+ """Test that make_tool properly handles capitalization and periods in descriptions."""
183
+
184
+ class FormatTool(BaseMockTool):
185
+ def apply(self, param1: str, param2: str, param3: str) -> str:
186
+ """Test function.
187
+
188
+ :param param1: lowercase description
189
+ :param param2: description with period.
190
+ :param param3: description with Capitalized word.
191
+ """
192
+ return f"Formatted: {param1}, {param2}, {param3}"
193
+
194
+ def apply_ex(self, *args, **kwargs) -> str:
195
+ return self.apply(**kwargs)
196
+
197
+ tool = FormatTool()
198
+ mcp_tool = make_tool(tool)
199
+
200
+ assert mcp_tool.parameters["properties"]["param1"]["description"] == "Lowercase description."
201
+ assert mcp_tool.parameters["properties"]["param2"]["description"] == "Description with period."
202
+ assert mcp_tool.parameters["properties"]["param3"]["description"] == "Description with Capitalized word."
203
+
204
+
205
+ def test_make_tool_missing_apply() -> None:
206
+ """Test make_tool with a tool that doesn't have an apply method."""
207
+
208
+ class BadTool(BaseMockTool):
209
+ pass
210
+
211
+ tool = BadTool()
212
+
213
+ with pytest.raises(AttributeError):
214
+ make_tool(tool)
215
+
216
+
217
+ @pytest.mark.parametrize(
218
+ "docstring, expected_description",
219
+ [
220
+ (
221
+ """This is a test function.
222
+
223
+ :param param: The parameter
224
+ :return: A result
225
+ """,
226
+ "This is a test function. Returns A result.",
227
+ ),
228
+ (
229
+ """
230
+ :param param: The parameter
231
+ :return: A result
232
+ """,
233
+ "Returns A result.",
234
+ ),
235
+ (
236
+ """
237
+ :param param: The parameter
238
+ """,
239
+ "",
240
+ ),
241
+ ("Description without params.", "Description without params."),
242
+ ],
243
+ )
244
+ def test_make_tool_descriptions(docstring, expected_description) -> None:
245
+ """Test make_tool with various docstring formats."""
246
+
247
+ class TestTool(BaseMockTool):
248
+ def apply(self, param: str) -> str:
249
+ return f"Result: {param}"
250
+
251
+ def apply_ex(self, *args, **kwargs) -> str:
252
+ return self.apply(**kwargs)
253
+
254
+ # Dynamically set the docstring
255
+ TestTool.apply.__doc__ = docstring
256
+
257
+ tool = TestTool()
258
+ mcp_tool = make_tool(tool)
259
+
260
+ assert mcp_tool.name == "test"
261
+ assert mcp_tool.description == expected_description
262
+
263
+
264
+ def is_test_mock_class(tool_class: type) -> bool:
265
+ """Check if a class is a test mock class."""
266
+ # Check if the class is defined in a test module
267
+ module_name = tool_class.__module__
268
+ return (
269
+ module_name.startswith(("test.", "tests."))
270
+ or "test_" in module_name
271
+ or tool_class.__name__
272
+ in [
273
+ "BaseMockTool",
274
+ "BasicTool",
275
+ "BadTool",
276
+ "NoParamsTool",
277
+ "NoReturnTool",
278
+ "MissingParamTool",
279
+ "ComplexDocTool",
280
+ "FormatTool",
281
+ "NoDescriptionTool",
282
+ ]
283
+ )
284
+
285
+
286
+ @pytest.mark.parametrize("tool_class", ToolRegistry().get_all_tool_classes())
287
+ def test_make_tool_all_tools(tool_class) -> None:
288
+ """Test that make_tool works for all tools in the codebase."""
289
+ # Create an instance of the tool
290
+ tool_instance = tool_class(MockAgent())
291
+
292
+ # Try to create an MCP tool from it
293
+ mcp_tool = make_tool(tool_instance)
294
+
295
+ # Basic validation
296
+ assert isinstance(mcp_tool, MCPTool)
297
+ assert mcp_tool.name == tool_class.get_name_from_cls()
298
+
299
+ # The description should be a string (either from docstring or default)
300
+ assert isinstance(mcp_tool.description, str)
projects/ui/serena-new/test/serena/test_serena_agent.py ADDED
@@ -0,0 +1,286 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json
2
+ import logging
3
+ import os
4
+ import time
5
+
6
+ import pytest
7
+
8
+ import test.solidlsp.clojure as clj
9
+ from serena.agent import SerenaAgent
10
+ from serena.config.serena_config import ProjectConfig, RegisteredProject, SerenaConfig
11
+ from serena.project import Project
12
+ from serena.tools import FindReferencingSymbolsTool, FindSymbolTool
13
+ from solidlsp.ls_config import Language
14
+ from test.conftest import get_repo_path
15
+
16
+
17
+ @pytest.fixture
18
+ def serena_config():
19
+ """Create an in-memory configuration for tests with test repositories pre-registered."""
20
+ # Create test projects for all supported languages
21
+ test_projects = []
22
+ for language in [
23
+ Language.PYTHON,
24
+ Language.GO,
25
+ Language.JAVA,
26
+ Language.KOTLIN,
27
+ Language.RUST,
28
+ Language.TYPESCRIPT,
29
+ Language.PHP,
30
+ Language.CSHARP,
31
+ Language.CLOJURE,
32
+ ]:
33
+ repo_path = get_repo_path(language)
34
+ if repo_path.exists():
35
+ project_name = f"test_repo_{language}"
36
+ project = Project(
37
+ project_root=str(repo_path),
38
+ project_config=ProjectConfig(
39
+ project_name=project_name,
40
+ language=language,
41
+ ignored_paths=[],
42
+ excluded_tools=set(),
43
+ read_only=False,
44
+ ignore_all_files_in_gitignore=True,
45
+ initial_prompt="",
46
+ encoding="utf-8",
47
+ ),
48
+ )
49
+ test_projects.append(RegisteredProject.from_project_instance(project))
50
+
51
+ config = SerenaConfig(gui_log_window_enabled=False, web_dashboard=False, log_level=logging.ERROR)
52
+ config.projects = test_projects
53
+ return config
54
+
55
+
56
+ @pytest.fixture
57
+ def serena_agent(request: pytest.FixtureRequest, serena_config):
58
+ language = Language(request.param)
59
+ project_name = f"test_repo_{language}"
60
+
61
+ return SerenaAgent(project=project_name, serena_config=serena_config)
62
+
63
+
64
+ class TestSerenaAgent:
65
+ @pytest.mark.parametrize(
66
+ "serena_agent,symbol_name,expected_kind,expected_file",
67
+ [
68
+ pytest.param(Language.PYTHON, "User", "Class", "models.py", marks=pytest.mark.python),
69
+ pytest.param(Language.GO, "Helper", "Function", "main.go", marks=pytest.mark.go),
70
+ pytest.param(Language.JAVA, "Model", "Class", "Model.java", marks=pytest.mark.java),
71
+ pytest.param(Language.KOTLIN, "Model", "Struct", "Model.kt", marks=pytest.mark.kotlin),
72
+ pytest.param(Language.RUST, "add", "Function", "lib.rs", marks=pytest.mark.rust),
73
+ pytest.param(Language.TYPESCRIPT, "DemoClass", "Class", "index.ts", marks=pytest.mark.typescript),
74
+ pytest.param(Language.PHP, "helperFunction", "Function", "helper.php", marks=pytest.mark.php),
75
+ pytest.param(
76
+ Language.CLOJURE,
77
+ "greet",
78
+ "Function",
79
+ clj.CORE_PATH,
80
+ marks=[pytest.mark.clojure, pytest.mark.skipif(clj.CLI_FAIL, reason=f"Clojure CLI not available: {clj.CLI_FAIL}")],
81
+ ),
82
+ pytest.param(Language.CSHARP, "Calculator", "Class", "Program.cs", marks=pytest.mark.csharp),
83
+ ],
84
+ indirect=["serena_agent"],
85
+ )
86
+ def test_find_symbol(self, serena_agent, symbol_name: str, expected_kind: str, expected_file: str):
87
+ agent = serena_agent
88
+ find_symbol_tool = agent.get_tool(FindSymbolTool)
89
+ result = find_symbol_tool.apply_ex(name_path=symbol_name)
90
+
91
+ symbols = json.loads(result)
92
+ assert any(
93
+ symbol_name in s["name_path"] and expected_kind.lower() in s["kind"].lower() and expected_file in s["relative_path"]
94
+ for s in symbols
95
+ ), f"Expected to find {symbol_name} ({expected_kind}) in {expected_file}"
96
+
97
+ @pytest.mark.parametrize(
98
+ "serena_agent,symbol_name,def_file,ref_file",
99
+ [
100
+ pytest.param(
101
+ Language.PYTHON,
102
+ "User",
103
+ os.path.join("test_repo", "models.py"),
104
+ os.path.join("test_repo", "services.py"),
105
+ marks=pytest.mark.python,
106
+ ),
107
+ pytest.param(Language.GO, "Helper", "main.go", "main.go", marks=pytest.mark.go),
108
+ pytest.param(
109
+ Language.JAVA,
110
+ "Model",
111
+ os.path.join("src", "main", "java", "test_repo", "Model.java"),
112
+ os.path.join("src", "main", "java", "test_repo", "Main.java"),
113
+ marks=pytest.mark.java,
114
+ ),
115
+ pytest.param(
116
+ Language.KOTLIN,
117
+ "Model",
118
+ os.path.join("src", "main", "kotlin", "test_repo", "Model.kt"),
119
+ os.path.join("src", "main", "kotlin", "test_repo", "Main.kt"),
120
+ marks=pytest.mark.kotlin,
121
+ ),
122
+ pytest.param(Language.RUST, "add", os.path.join("src", "lib.rs"), os.path.join("src", "main.rs"), marks=pytest.mark.rust),
123
+ pytest.param(Language.TYPESCRIPT, "helperFunction", "index.ts", "use_helper.ts", marks=pytest.mark.typescript),
124
+ pytest.param(Language.PHP, "helperFunction", "helper.php", "index.php", marks=pytest.mark.php),
125
+ pytest.param(
126
+ Language.CLOJURE,
127
+ "multiply",
128
+ clj.CORE_PATH,
129
+ clj.UTILS_PATH,
130
+ marks=[pytest.mark.clojure, pytest.mark.skipif(clj.CLI_FAIL, reason=f"Clojure CLI not available: {clj.CLI_FAIL}")],
131
+ ),
132
+ pytest.param(Language.CSHARP, "Calculator", "Program.cs", "Program.cs", marks=pytest.mark.csharp),
133
+ ],
134
+ indirect=["serena_agent"],
135
+ )
136
+ def test_find_symbol_references(self, serena_agent, symbol_name: str, def_file: str, ref_file: str) -> None:
137
+ agent = serena_agent
138
+
139
+ # Find the symbol location first
140
+ find_symbol_tool = agent.get_tool(FindSymbolTool)
141
+ result = find_symbol_tool.apply_ex(name_path=symbol_name, relative_path=def_file)
142
+
143
+ time.sleep(1)
144
+ symbols = json.loads(result)
145
+ # Find the definition
146
+ def_symbol = symbols[0]
147
+
148
+ # Now find references
149
+ find_refs_tool = agent.get_tool(FindReferencingSymbolsTool)
150
+ result = find_refs_tool.apply_ex(name_path=def_symbol["name_path"], relative_path=def_symbol["relative_path"])
151
+
152
+ refs = json.loads(result)
153
+ assert any(
154
+ ref["relative_path"] == ref_file for ref in refs
155
+ ), f"Expected to find reference to {symbol_name} in {ref_file}. refs={refs}"
156
+
157
+ @pytest.mark.parametrize(
158
+ "serena_agent,name_path,substring_matching,expected_symbol_name,expected_kind,expected_file",
159
+ [
160
+ pytest.param(
161
+ Language.PYTHON,
162
+ "OuterClass/NestedClass",
163
+ False,
164
+ "NestedClass",
165
+ "Class",
166
+ os.path.join("test_repo", "nested.py"),
167
+ id="exact_qualname_class",
168
+ marks=pytest.mark.python,
169
+ ),
170
+ pytest.param(
171
+ Language.PYTHON,
172
+ "OuterClass/NestedClass/find_me",
173
+ False,
174
+ "find_me",
175
+ "Method",
176
+ os.path.join("test_repo", "nested.py"),
177
+ id="exact_qualname_method",
178
+ marks=pytest.mark.python,
179
+ ),
180
+ pytest.param(
181
+ Language.PYTHON,
182
+ "OuterClass/NestedCl", # Substring for NestedClass
183
+ True,
184
+ "NestedClass",
185
+ "Class",
186
+ os.path.join("test_repo", "nested.py"),
187
+ id="substring_qualname_class",
188
+ marks=pytest.mark.python,
189
+ ),
190
+ pytest.param(
191
+ Language.PYTHON,
192
+ "OuterClass/NestedClass/find_m", # Substring for find_me
193
+ True,
194
+ "find_me",
195
+ "Method",
196
+ os.path.join("test_repo", "nested.py"),
197
+ id="substring_qualname_method",
198
+ marks=pytest.mark.python,
199
+ ),
200
+ pytest.param(
201
+ Language.PYTHON,
202
+ "/OuterClass", # Absolute path
203
+ False,
204
+ "OuterClass",
205
+ "Class",
206
+ os.path.join("test_repo", "nested.py"),
207
+ id="absolute_qualname_class",
208
+ marks=pytest.mark.python,
209
+ ),
210
+ pytest.param(
211
+ Language.PYTHON,
212
+ "/OuterClass/NestedClass/find_m", # Absolute path with substring
213
+ True,
214
+ "find_me",
215
+ "Method",
216
+ os.path.join("test_repo", "nested.py"),
217
+ id="absolute_substring_qualname_method",
218
+ marks=pytest.mark.python,
219
+ ),
220
+ ],
221
+ indirect=["serena_agent"],
222
+ )
223
+ def test_find_symbol_name_path(
224
+ self,
225
+ serena_agent,
226
+ name_path: str,
227
+ substring_matching: bool,
228
+ expected_symbol_name: str,
229
+ expected_kind: str,
230
+ expected_file: str,
231
+ ):
232
+ agent = serena_agent
233
+
234
+ find_symbol_tool = agent.get_tool(FindSymbolTool)
235
+ result = find_symbol_tool.apply_ex(
236
+ name_path=name_path,
237
+ depth=0,
238
+ relative_path=None,
239
+ include_body=False,
240
+ include_kinds=None,
241
+ exclude_kinds=None,
242
+ substring_matching=substring_matching,
243
+ )
244
+
245
+ symbols = json.loads(result)
246
+ assert any(
247
+ expected_symbol_name == s["name_path"].split("/")[-1]
248
+ and expected_kind.lower() in s["kind"].lower()
249
+ and expected_file in s["relative_path"]
250
+ for s in symbols
251
+ ), f"Expected to find {name_path} ({expected_kind}) in {expected_file} for {agent._active_project.language.name}. Symbols: {symbols}"
252
+
253
+ @pytest.mark.parametrize(
254
+ "serena_agent,name_path",
255
+ [
256
+ pytest.param(
257
+ Language.PYTHON,
258
+ "/NestedClass", # Absolute path, NestedClass is not top-level
259
+ id="absolute_path_non_top_level_no_match",
260
+ marks=pytest.mark.python,
261
+ ),
262
+ pytest.param(
263
+ Language.PYTHON,
264
+ "/NoSuchParent/NestedClass", # Absolute path with non-existent parent
265
+ id="absolute_path_non_existent_parent_no_match",
266
+ marks=pytest.mark.python,
267
+ ),
268
+ ],
269
+ indirect=["serena_agent"],
270
+ )
271
+ def test_find_symbol_name_path_no_match(
272
+ self,
273
+ serena_agent,
274
+ name_path: str,
275
+ ):
276
+ agent = serena_agent
277
+
278
+ find_symbol_tool = agent.get_tool(FindSymbolTool)
279
+ result = find_symbol_tool.apply_ex(
280
+ name_path=name_path,
281
+ depth=0,
282
+ substring_matching=True,
283
+ )
284
+
285
+ symbols = json.loads(result)
286
+ assert not symbols, f"Expected to find no symbols for {name_path}. Symbols found: {symbols}"
projects/ui/serena-new/test/serena/test_symbol.py ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pytest
2
+
3
+ from src.serena.symbol import LanguageServerSymbol
4
+
5
+
6
+ class TestSymbolNameMatching:
7
+ def _create_assertion_error_message(
8
+ self,
9
+ name_path_pattern: str,
10
+ symbol_name_path_parts: list[str],
11
+ is_substring_match: bool,
12
+ expected_result: bool,
13
+ actual_result: bool,
14
+ ) -> str:
15
+ """Helper to create a detailed error message for assertions."""
16
+ qnp_repr = "/".join(symbol_name_path_parts)
17
+
18
+ return (
19
+ f"Pattern '{name_path_pattern}' (substring: {is_substring_match}) vs "
20
+ f"Qualname parts {symbol_name_path_parts} (as '{qnp_repr}'). "
21
+ f"Expected: {expected_result}, Got: {actual_result}"
22
+ )
23
+
24
+ @pytest.mark.parametrize(
25
+ "name_path_pattern, symbol_name_path_parts, is_substring_match, expected",
26
+ [
27
+ # Exact matches, anywhere in the name (is_substring_match=False)
28
+ pytest.param("foo", ["foo"], False, True, id="'foo' matches 'foo' exactly (simple)"),
29
+ pytest.param("foo/", ["foo"], False, True, id="'foo/' matches 'foo' exactly (simple)"),
30
+ pytest.param("foo", ["bar", "foo"], False, True, id="'foo' matches ['bar', 'foo'] exactly (simple, last element)"),
31
+ pytest.param("foo", ["foobar"], False, False, id="'foo' does not match 'foobar' exactly (simple)"),
32
+ pytest.param(
33
+ "foo", ["bar", "foobar"], False, False, id="'foo' does not match ['bar', 'foobar'] exactly (simple, last element)"
34
+ ),
35
+ pytest.param(
36
+ "foo", ["path", "to", "foo"], False, True, id="'foo' matches ['path', 'to', 'foo'] exactly (simple, last element)"
37
+ ),
38
+ # Exact matches, absolute patterns (is_substring_match=False)
39
+ pytest.param("/foo", ["foo"], False, True, id="'/foo' matches ['foo'] exactly (absolute simple)"),
40
+ pytest.param("/foo", ["foo", "bar"], False, False, id="'/foo' does not match ['foo', 'bar'] (absolute simple, len mismatch)"),
41
+ pytest.param("/foo", ["bar"], False, False, id="'/foo' does not match ['bar'] (absolute simple, name mismatch)"),
42
+ pytest.param(
43
+ "/foo", ["bar", "foo"], False, False, id="'/foo' does not match ['bar', 'foo'] (absolute simple, position mismatch)"
44
+ ),
45
+ # Substring matches, anywhere in the name (is_substring_match=True)
46
+ pytest.param("foo", ["foobar"], True, True, id="'foo' matches 'foobar' as substring (simple)"),
47
+ pytest.param("foo", ["bar", "foobar"], True, True, id="'foo' matches ['bar', 'foobar'] as substring (simple, last element)"),
48
+ pytest.param(
49
+ "foo", ["barfoo"], True, True, id="'foo' matches 'barfoo' as substring (simple)"
50
+ ), # This was potentially ambiguous before
51
+ pytest.param("foo", ["baz"], True, False, id="'foo' does not match 'baz' as substring (simple)"),
52
+ pytest.param("foo", ["bar", "baz"], True, False, id="'foo' does not match ['bar', 'baz'] as substring (simple, last element)"),
53
+ pytest.param("foo", ["my_foobar_func"], True, True, id="'foo' matches 'my_foobar_func' as substring (simple)"),
54
+ pytest.param(
55
+ "foo",
56
+ ["ClassA", "my_foobar_method"],
57
+ True,
58
+ True,
59
+ id="'foo' matches ['ClassA', 'my_foobar_method'] as substring (simple, last element)",
60
+ ),
61
+ pytest.param("foo", ["my_bar_func"], True, False, id="'foo' does not match 'my_bar_func' as substring (simple)"),
62
+ # Substring matches, absolute patterns (is_substring_match=True)
63
+ pytest.param("/foo", ["foobar"], True, True, id="'/foo' matches ['foobar'] as substring (absolute simple)"),
64
+ pytest.param("/foo/", ["foobar"], True, True, id="'/foo/' matches ['foobar'] as substring (absolute simple, last element)"),
65
+ pytest.param("/foo", ["barfoobaz"], True, True, id="'/foo' matches ['barfoobaz'] as substring (absolute simple)"),
66
+ pytest.param(
67
+ "/foo", ["foo", "bar"], True, False, id="'/foo' does not match ['foo', 'bar'] as substring (absolute simple, len mismatch)"
68
+ ),
69
+ pytest.param("/foo", ["bar"], True, False, id="'/foo' does not match ['bar'] (absolute simple, no substr)"),
70
+ pytest.param(
71
+ "/foo", ["bar", "foo"], True, False, id="'/foo' does not match ['bar', 'foo'] (absolute simple, position mismatch)"
72
+ ),
73
+ pytest.param(
74
+ "/foo/", ["bar", "foo"], True, False, id="'/foo/' does not match ['bar', 'foo'] (absolute simple, position mismatch)"
75
+ ),
76
+ ],
77
+ )
78
+ def test_match_simple_name(self, name_path_pattern, symbol_name_path_parts, is_substring_match, expected):
79
+ """Tests matching for simple names (no '/' in pattern)."""
80
+ result = LanguageServerSymbol.match_name_path(name_path_pattern, symbol_name_path_parts, is_substring_match)
81
+ error_msg = self._create_assertion_error_message(name_path_pattern, symbol_name_path_parts, is_substring_match, expected, result)
82
+ assert result == expected, error_msg
83
+
84
+ @pytest.mark.parametrize(
85
+ "name_path_pattern, symbol_name_path_parts, is_substring_match, expected",
86
+ [
87
+ # --- Relative patterns (suffix matching) ---
88
+ # Exact matches, relative patterns (is_substring_match=False)
89
+ pytest.param("bar/foo", ["bar", "foo"], False, True, id="R: 'bar/foo' matches ['bar', 'foo'] exactly"),
90
+ pytest.param("bar/foo", ["mod", "bar", "foo"], False, True, id="R: 'bar/foo' matches ['mod', 'bar', 'foo'] exactly (suffix)"),
91
+ pytest.param(
92
+ "bar/foo", ["bar", "foo", "baz"], False, False, id="R: 'bar/foo' does not match ['bar', 'foo', 'baz'] (pattern shorter)"
93
+ ),
94
+ pytest.param("bar/foo", ["bar"], False, False, id="R: 'bar/foo' does not match ['bar'] (pattern longer)"),
95
+ pytest.param("bar/foo", ["baz", "foo"], False, False, id="R: 'bar/foo' does not match ['baz', 'foo'] (first part mismatch)"),
96
+ pytest.param("bar/foo", ["bar", "baz"], False, False, id="R: 'bar/foo' does not match ['bar', 'baz'] (last part mismatch)"),
97
+ pytest.param("bar/foo", ["foo"], False, False, id="R: 'bar/foo' does not match ['foo'] (pattern longer)"),
98
+ pytest.param(
99
+ "bar/foo", ["other", "foo"], False, False, id="R: 'bar/foo' does not match ['other', 'foo'] (first part mismatch)"
100
+ ),
101
+ pytest.param(
102
+ "bar/foo", ["bar", "otherfoo"], False, False, id="R: 'bar/foo' does not match ['bar', 'otherfoo'] (last part mismatch)"
103
+ ),
104
+ # Substring matches, relative patterns (is_substring_match=True)
105
+ pytest.param("bar/foo", ["bar", "foobar"], True, True, id="R: 'bar/foo' matches ['bar', 'foobar'] as substring"),
106
+ pytest.param(
107
+ "bar/foo", ["mod", "bar", "foobar"], True, True, id="R: 'bar/foo' matches ['mod', 'bar', 'foobar'] as substring (suffix)"
108
+ ),
109
+ pytest.param("bar/foo", ["bar", "bazfoo"], True, True, id="R: 'bar/foo' matches ['bar', 'bazfoo'] as substring"),
110
+ pytest.param("bar/fo", ["bar", "foo"], True, True, id="R: 'bar/fo' matches ['bar', 'foo'] as substring"), # codespell:ignore
111
+ pytest.param("bar/foo", ["bar", "baz"], True, False, id="R: 'bar/foo' does not match ['bar', 'baz'] (last no substr)"),
112
+ pytest.param(
113
+ "bar/foo", ["baz", "foobar"], True, False, id="R: 'bar/foo' does not match ['baz', 'foobar'] (first part mismatch)"
114
+ ),
115
+ pytest.param(
116
+ "bar/foo", ["bar", "my_foobar_method"], True, True, id="R: 'bar/foo' matches ['bar', 'my_foobar_method'] as substring"
117
+ ),
118
+ pytest.param(
119
+ "bar/foo",
120
+ ["mod", "bar", "my_foobar_method"],
121
+ True,
122
+ True,
123
+ id="R: 'bar/foo' matches ['mod', 'bar', 'my_foobar_method'] as substring (suffix)",
124
+ ),
125
+ pytest.param(
126
+ "bar/foo",
127
+ ["bar", "another_method"],
128
+ True,
129
+ False,
130
+ id="R: 'bar/foo' does not match ['bar', 'another_method'] (last no substr)",
131
+ ),
132
+ pytest.param(
133
+ "bar/foo",
134
+ ["other", "my_foobar_method"],
135
+ True,
136
+ False,
137
+ id="R: 'bar/foo' does not match ['other', 'my_foobar_method'] (first part mismatch)",
138
+ ),
139
+ pytest.param("bar/f", ["bar", "foo"], True, True, id="R: 'bar/f' matches ['bar', 'foo'] as substring"),
140
+ # Exact matches, absolute patterns (is_substring_match=False)
141
+ pytest.param("/bar/foo", ["bar", "foo"], False, True, id="A: '/bar/foo' matches ['bar', 'foo'] exactly"),
142
+ pytest.param(
143
+ "/bar/foo", ["bar", "foo", "baz"], False, False, id="A: '/bar/foo' does not match ['bar', 'foo', 'baz'] (pattern shorter)"
144
+ ),
145
+ pytest.param("/bar/foo", ["bar"], False, False, id="A: '/bar/foo' does not match ['bar'] (pattern longer)"),
146
+ pytest.param("/bar/foo", ["baz", "foo"], False, False, id="A: '/bar/foo' does not match ['baz', 'foo'] (first part mismatch)"),
147
+ pytest.param("/bar/foo", ["bar", "baz"], False, False, id="A: '/bar/foo' does not match ['bar', 'baz'] (last part mismatch)"),
148
+ # Substring matches (is_substring_match=True)
149
+ pytest.param("/bar/foo", ["bar", "foobar"], True, True, id="A: '/bar/foo' matches ['bar', 'foobar'] as substring"),
150
+ pytest.param("/bar/foo", ["bar", "bazfoo"], True, True, id="A: '/bar/foo' matches ['bar', 'bazfoo'] as substring"),
151
+ pytest.param("/bar/fo", ["bar", "foo"], True, True, id="A: '/bar/fo' matches ['bar', 'foo'] as substring"), # codespell:ignore
152
+ pytest.param("/bar/foo", ["bar", "baz"], True, False, id="A: '/bar/foo' does not match ['bar', 'baz'] (last no substr)"),
153
+ pytest.param(
154
+ "/bar/foo", ["baz", "foobar"], True, False, id="A: '/bar/foo' does not match ['baz', 'foobar'] (first part mismatch)"
155
+ ),
156
+ ],
157
+ )
158
+ def test_match_name_path_pattern_path_len_2(self, name_path_pattern, symbol_name_path_parts, is_substring_match, expected):
159
+ """Tests matching for qualified names (e.g. 'module/class/func')."""
160
+ result = LanguageServerSymbol.match_name_path(name_path_pattern, symbol_name_path_parts, is_substring_match)
161
+ error_msg = self._create_assertion_error_message(name_path_pattern, symbol_name_path_parts, is_substring_match, expected, result)
162
+ assert result == expected, error_msg
projects/ui/serena-new/test/serena/test_symbol_editing.py ADDED
@@ -0,0 +1,485 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+ import os
3
+ import shutil
4
+ import sys
5
+ import tempfile
6
+ import time
7
+ from abc import abstractmethod
8
+ from collections.abc import Iterator
9
+ from contextlib import contextmanager
10
+ from dataclasses import dataclass, field
11
+ from difflib import SequenceMatcher
12
+ from pathlib import Path
13
+ from typing import Literal, NamedTuple
14
+
15
+ import pytest
16
+
17
+ from serena.code_editor import CodeEditor, LanguageServerCodeEditor
18
+ from solidlsp.ls_config import Language
19
+ from src.serena.symbol import LanguageServerSymbolRetriever
20
+ from test.conftest import create_ls, get_repo_path
21
+
22
+ pytestmark = pytest.mark.snapshot
23
+
24
+ log = logging.getLogger(__name__)
25
+
26
+
27
+ class LineChange(NamedTuple):
28
+ """Represents a change to a specific line or range of lines."""
29
+
30
+ operation: Literal["insert", "delete", "replace"]
31
+ original_start: int
32
+ original_end: int
33
+ modified_start: int
34
+ modified_end: int
35
+ original_lines: list[str]
36
+ modified_lines: list[str]
37
+
38
+
39
+ @dataclass
40
+ class CodeDiff:
41
+ """
42
+ Represents the difference between original and modified code.
43
+ Provides object-oriented access to diff information including line numbers.
44
+ """
45
+
46
+ relative_path: str
47
+ original_content: str
48
+ modified_content: str
49
+ _line_changes: list[LineChange] = field(init=False)
50
+
51
+ def __post_init__(self) -> None:
52
+ """Compute the diff using difflib's SequenceMatcher."""
53
+ original_lines = self.original_content.splitlines(keepends=True)
54
+ modified_lines = self.modified_content.splitlines(keepends=True)
55
+
56
+ matcher = SequenceMatcher(None, original_lines, modified_lines)
57
+ self._line_changes = []
58
+
59
+ for tag, orig_start, orig_end, mod_start, mod_end in matcher.get_opcodes():
60
+ if tag == "equal":
61
+ continue
62
+ if tag == "insert":
63
+ self._line_changes.append(
64
+ LineChange(
65
+ operation="insert",
66
+ original_start=orig_start,
67
+ original_end=orig_start,
68
+ modified_start=mod_start,
69
+ modified_end=mod_end,
70
+ original_lines=[],
71
+ modified_lines=modified_lines[mod_start:mod_end],
72
+ )
73
+ )
74
+ elif tag == "delete":
75
+ self._line_changes.append(
76
+ LineChange(
77
+ operation="delete",
78
+ original_start=orig_start,
79
+ original_end=orig_end,
80
+ modified_start=mod_start,
81
+ modified_end=mod_start,
82
+ original_lines=original_lines[orig_start:orig_end],
83
+ modified_lines=[],
84
+ )
85
+ )
86
+ elif tag == "replace":
87
+ self._line_changes.append(
88
+ LineChange(
89
+ operation="replace",
90
+ original_start=orig_start,
91
+ original_end=orig_end,
92
+ modified_start=mod_start,
93
+ modified_end=mod_end,
94
+ original_lines=original_lines[orig_start:orig_end],
95
+ modified_lines=modified_lines[mod_start:mod_end],
96
+ )
97
+ )
98
+
99
+ @property
100
+ def line_changes(self) -> list[LineChange]:
101
+ """Get all line changes in the diff."""
102
+ return self._line_changes
103
+
104
+ @property
105
+ def has_changes(self) -> bool:
106
+ """Check if there are any changes."""
107
+ return len(self._line_changes) > 0
108
+
109
+ @property
110
+ def added_lines(self) -> list[tuple[int, str]]:
111
+ """Get all added lines with their line numbers (0-based) in the modified file."""
112
+ result = []
113
+ for change in self._line_changes:
114
+ if change.operation in ("insert", "replace"):
115
+ for i, line in enumerate(change.modified_lines):
116
+ result.append((change.modified_start + i, line))
117
+ return result
118
+
119
+ @property
120
+ def deleted_lines(self) -> list[tuple[int, str]]:
121
+ """Get all deleted lines with their line numbers (0-based) in the original file."""
122
+ result = []
123
+ for change in self._line_changes:
124
+ if change.operation in ("delete", "replace"):
125
+ for i, line in enumerate(change.original_lines):
126
+ result.append((change.original_start + i, line))
127
+ return result
128
+
129
+ @property
130
+ def modified_line_numbers(self) -> list[int]:
131
+ """Get all line numbers (0-based) that were modified in the modified file."""
132
+ line_nums: set[int] = set()
133
+ for change in self._line_changes:
134
+ if change.operation in ("insert", "replace"):
135
+ line_nums.update(range(change.modified_start, change.modified_end))
136
+ return sorted(line_nums)
137
+
138
+ @property
139
+ def affected_original_line_numbers(self) -> list[int]:
140
+ """Get all line numbers (0-based) that were affected in the original file."""
141
+ line_nums: set[int] = set()
142
+ for change in self._line_changes:
143
+ if change.operation in ("delete", "replace"):
144
+ line_nums.update(range(change.original_start, change.original_end))
145
+ return sorted(line_nums)
146
+
147
+ def get_unified_diff(self, context_lines: int = 3) -> str:
148
+ """Get the unified diff as a string."""
149
+ import difflib
150
+
151
+ original_lines = self.original_content.splitlines(keepends=True)
152
+ modified_lines = self.modified_content.splitlines(keepends=True)
153
+
154
+ diff = difflib.unified_diff(
155
+ original_lines, modified_lines, fromfile=f"a/{self.relative_path}", tofile=f"b/{self.relative_path}", n=context_lines
156
+ )
157
+ return "".join(diff)
158
+
159
+ def get_context_diff(self, context_lines: int = 3) -> str:
160
+ """Get the context diff as a string."""
161
+ import difflib
162
+
163
+ original_lines = self.original_content.splitlines(keepends=True)
164
+ modified_lines = self.modified_content.splitlines(keepends=True)
165
+
166
+ diff = difflib.context_diff(
167
+ original_lines, modified_lines, fromfile=f"a/{self.relative_path}", tofile=f"b/{self.relative_path}", n=context_lines
168
+ )
169
+ return "".join(diff)
170
+
171
+
172
+ class EditingTest:
173
+ def __init__(self, language: Language, rel_path: str):
174
+ """
175
+ :param language: the language
176
+ :param rel_path: the relative path of the edited file
177
+ """
178
+ self.rel_path = rel_path
179
+ self.language = language
180
+ self.original_repo_path = get_repo_path(language)
181
+ self.repo_path: Path | None = None
182
+
183
+ @contextmanager
184
+ def _setup(self) -> Iterator[LanguageServerSymbolRetriever]:
185
+ """Context manager for setup/teardown with a temporary directory, providing the symbol manager."""
186
+ temp_dir = Path(tempfile.mkdtemp())
187
+ self.repo_path = temp_dir / self.original_repo_path.name
188
+ language_server = None # Initialize language_server
189
+ try:
190
+ print(f"Copying repo from {self.original_repo_path} to {self.repo_path}")
191
+ shutil.copytree(self.original_repo_path, self.repo_path)
192
+ # prevent deadlock on Windows due to file locks caused by antivirus or some other external software
193
+ # wait for a long time here
194
+ if os.name == "nt":
195
+ time.sleep(0.1)
196
+ log.info(f"Creating language server for {self.language} {self.rel_path}")
197
+ language_server = create_ls(self.language, str(self.repo_path))
198
+ log.info(f"Starting language server for {self.language} {self.rel_path}")
199
+ language_server.start()
200
+ log.info(f"Language server started for {self.language} {self.rel_path}")
201
+ yield LanguageServerSymbolRetriever(lang_server=language_server)
202
+ finally:
203
+ if language_server is not None and language_server.is_running():
204
+ log.info(f"Stopping language server for {self.language} {self.rel_path}")
205
+ language_server.stop()
206
+ # attempt at trigger of garbage collection
207
+ language_server = None
208
+ log.info(f"Language server stopped for {self.language} {self.rel_path}")
209
+
210
+ # prevent deadlock on Windows due to lingering file locks
211
+ if os.name == "nt":
212
+ time.sleep(0.1)
213
+ log.info(f"Removing temp directory {temp_dir}")
214
+ shutil.rmtree(temp_dir, ignore_errors=True)
215
+ log.info(f"Temp directory {temp_dir} removed")
216
+
217
+ def _read_file(self, rel_path: str) -> str:
218
+ """Read the content of a file in the test repository."""
219
+ assert self.repo_path is not None
220
+ file_path = self.repo_path / rel_path
221
+ with open(file_path, encoding="utf-8") as f:
222
+ return f.read()
223
+
224
+ def run_test(self, content_after_ground_truth: str) -> None:
225
+ with self._setup() as symbol_retriever:
226
+ content_before = self._read_file(self.rel_path)
227
+ code_editor = LanguageServerCodeEditor(symbol_retriever)
228
+ self._apply_edit(code_editor)
229
+ content_after = self._read_file(self.rel_path)
230
+ code_diff = CodeDiff(self.rel_path, original_content=content_before, modified_content=content_after)
231
+ self._test_diff(code_diff, content_after_ground_truth)
232
+
233
+ @abstractmethod
234
+ def _apply_edit(self, code_editor: CodeEditor) -> None:
235
+ pass
236
+
237
+ def _test_diff(self, code_diff: CodeDiff, snapshot: str) -> None:
238
+ assert code_diff.modified_content == snapshot
239
+
240
+
241
+ # Python test file path
242
+ PYTHON_TEST_REL_FILE_PATH = os.path.join("test_repo", "variables.py")
243
+
244
+ # TypeScript test file path
245
+ TYPESCRIPT_TEST_FILE = "index.ts"
246
+
247
+
248
+ class DeleteSymbolTest(EditingTest):
249
+ def __init__(self, language: Language, rel_path: str, deleted_symbol: str):
250
+ super().__init__(language, rel_path)
251
+ self.deleted_symbol = deleted_symbol
252
+ self.rel_path = rel_path
253
+
254
+ def _apply_edit(self, code_editor: CodeEditor) -> None:
255
+ code_editor.delete_symbol(self.deleted_symbol, self.rel_path)
256
+
257
+
258
+ @pytest.mark.parametrize(
259
+ "test_case",
260
+ [
261
+ pytest.param(
262
+ DeleteSymbolTest(
263
+ Language.PYTHON,
264
+ PYTHON_TEST_REL_FILE_PATH,
265
+ "VariableContainer",
266
+ ),
267
+ marks=pytest.mark.python,
268
+ ),
269
+ pytest.param(
270
+ DeleteSymbolTest(
271
+ Language.TYPESCRIPT,
272
+ TYPESCRIPT_TEST_FILE,
273
+ "DemoClass",
274
+ ),
275
+ marks=pytest.mark.typescript,
276
+ ),
277
+ ],
278
+ )
279
+ def test_delete_symbol(test_case, snapshot):
280
+ test_case.run_test(content_after_ground_truth=snapshot)
281
+
282
+
283
+ NEW_PYTHON_FUNCTION = """def new_inserted_function():
284
+ print("This is a new function inserted before another.")"""
285
+
286
+ NEW_PYTHON_CLASS_WITH_LEADING_NEWLINES = """
287
+
288
+ class NewInsertedClass:
289
+ pass
290
+ """
291
+
292
+ NEW_PYTHON_CLASS_WITH_TRAILING_NEWLINES = """class NewInsertedClass:
293
+ pass
294
+
295
+
296
+ """
297
+
298
+ NEW_TYPESCRIPT_FUNCTION = """function newInsertedFunction(): void {
299
+ console.log("This is a new function inserted before another.");
300
+ }"""
301
+
302
+
303
+ NEW_PYTHON_VARIABLE = 'new_module_var = "Inserted after typed_module_var"'
304
+
305
+ NEW_TYPESCRIPT_FUNCTION_AFTER = """function newFunctionAfterClass(): void {
306
+ console.log("This function is after DemoClass.");
307
+ }"""
308
+
309
+
310
+ class InsertInRelToSymbolTest(EditingTest):
311
+ def __init__(
312
+ self, language: Language, rel_path: str, symbol_name: str, new_content: str, mode: Literal["before", "after"] | None = None
313
+ ):
314
+ super().__init__(language, rel_path)
315
+ self.symbol_name = symbol_name
316
+ self.new_content = new_content
317
+ self.mode: Literal["before", "after"] | None = mode
318
+
319
+ def set_mode(self, mode: Literal["before", "after"]):
320
+ self.mode = mode
321
+
322
+ def _apply_edit(self, code_editor: CodeEditor) -> None:
323
+ assert self.mode is not None
324
+ if self.mode == "before":
325
+ code_editor.insert_before_symbol(self.symbol_name, self.rel_path, self.new_content)
326
+ elif self.mode == "after":
327
+ code_editor.insert_after_symbol(self.symbol_name, self.rel_path, self.new_content)
328
+
329
+
330
+ @pytest.mark.parametrize("mode", ["before", "after"])
331
+ @pytest.mark.parametrize(
332
+ "test_case",
333
+ [
334
+ pytest.param(
335
+ InsertInRelToSymbolTest(
336
+ Language.PYTHON,
337
+ PYTHON_TEST_REL_FILE_PATH,
338
+ "typed_module_var",
339
+ NEW_PYTHON_VARIABLE,
340
+ ),
341
+ marks=pytest.mark.python,
342
+ ),
343
+ pytest.param(
344
+ InsertInRelToSymbolTest(
345
+ Language.PYTHON,
346
+ PYTHON_TEST_REL_FILE_PATH,
347
+ "use_module_variables",
348
+ NEW_PYTHON_FUNCTION,
349
+ ),
350
+ marks=pytest.mark.python,
351
+ ),
352
+ pytest.param(
353
+ InsertInRelToSymbolTest(
354
+ Language.TYPESCRIPT,
355
+ TYPESCRIPT_TEST_FILE,
356
+ "DemoClass",
357
+ NEW_TYPESCRIPT_FUNCTION_AFTER,
358
+ ),
359
+ marks=pytest.mark.typescript,
360
+ ),
361
+ pytest.param(
362
+ InsertInRelToSymbolTest(
363
+ Language.TYPESCRIPT,
364
+ TYPESCRIPT_TEST_FILE,
365
+ "helperFunction",
366
+ NEW_TYPESCRIPT_FUNCTION,
367
+ ),
368
+ marks=pytest.mark.typescript,
369
+ ),
370
+ ],
371
+ )
372
+ def test_insert_in_rel_to_symbol(test_case: InsertInRelToSymbolTest, mode: Literal["before", "after"], snapshot):
373
+ test_case.set_mode(mode)
374
+ test_case.run_test(content_after_ground_truth=snapshot)
375
+
376
+
377
+ @pytest.mark.python
378
+ def test_insert_python_class_before(snapshot):
379
+ InsertInRelToSymbolTest(
380
+ Language.PYTHON,
381
+ PYTHON_TEST_REL_FILE_PATH,
382
+ "VariableDataclass",
383
+ NEW_PYTHON_CLASS_WITH_TRAILING_NEWLINES,
384
+ mode="before",
385
+ ).run_test(snapshot)
386
+
387
+
388
+ @pytest.mark.python
389
+ def test_insert_python_class_after(snapshot):
390
+ InsertInRelToSymbolTest(
391
+ Language.PYTHON,
392
+ PYTHON_TEST_REL_FILE_PATH,
393
+ "VariableDataclass",
394
+ NEW_PYTHON_CLASS_WITH_LEADING_NEWLINES,
395
+ mode="after",
396
+ ).run_test(snapshot)
397
+
398
+
399
+ PYTHON_REPLACED_BODY = """def modify_instance_var(self):
400
+ # This body has been replaced
401
+ self.instance_var = "Replaced!"
402
+ self.reassignable_instance_var = 999
403
+ """
404
+
405
+ TYPESCRIPT_REPLACED_BODY = """function printValue() {
406
+ // This body has been replaced
407
+ console.warn("New value: " + this.value);
408
+ }
409
+ """
410
+
411
+
412
+ class ReplaceBodyTest(EditingTest):
413
+ def __init__(self, language: Language, rel_path: str, symbol_name: str, new_body: str):
414
+ super().__init__(language, rel_path)
415
+ self.symbol_name = symbol_name
416
+ self.new_body = new_body
417
+
418
+ def _apply_edit(self, code_editor: CodeEditor) -> None:
419
+ code_editor.replace_body(self.symbol_name, self.rel_path, self.new_body)
420
+
421
+
422
+ @pytest.mark.parametrize(
423
+ "test_case",
424
+ [
425
+ pytest.param(
426
+ ReplaceBodyTest(
427
+ Language.PYTHON,
428
+ PYTHON_TEST_REL_FILE_PATH,
429
+ "VariableContainer/modify_instance_var",
430
+ PYTHON_REPLACED_BODY,
431
+ ),
432
+ marks=pytest.mark.python,
433
+ ),
434
+ pytest.param(
435
+ ReplaceBodyTest(
436
+ Language.TYPESCRIPT,
437
+ TYPESCRIPT_TEST_FILE,
438
+ "DemoClass/printValue",
439
+ TYPESCRIPT_REPLACED_BODY,
440
+ ),
441
+ marks=pytest.mark.typescript,
442
+ ),
443
+ ],
444
+ )
445
+ def test_replace_body(test_case: ReplaceBodyTest, snapshot):
446
+ test_case.run_test(content_after_ground_truth=snapshot)
447
+
448
+
449
+ NIX_ATTR_REPLACEMENT = """c = 3;"""
450
+
451
+
452
+ class NixAttrReplacementTest(EditingTest):
453
+ """Test for replacing individual attributes in Nix that should NOT result in double semicolons."""
454
+
455
+ def __init__(self, language: Language, rel_path: str, symbol_name: str, new_body: str):
456
+ super().__init__(language, rel_path)
457
+ self.symbol_name = symbol_name
458
+ self.new_body = new_body
459
+
460
+ def _apply_edit(self, code_editor: CodeEditor) -> None:
461
+ code_editor.replace_body(self.symbol_name, self.rel_path, self.new_body)
462
+
463
+
464
+ @pytest.mark.nix
465
+ @pytest.mark.skipif(sys.platform == "win32", reason="nixd language server doesn't run on Windows")
466
+ def test_nix_symbol_replacement_no_double_semicolon(snapshot):
467
+ """
468
+ Test that replacing a Nix attribute does not result in double semicolons.
469
+
470
+ This test exercises the bug where:
471
+ - Original: users.users.example = { isSystemUser = true; group = "example"; description = "Example service user"; };
472
+ - Replacement: c = 3;
473
+ - Bug result would be: c = 3;; (double semicolon)
474
+ - Correct result should be: c = 3; (single semicolon)
475
+
476
+ The replacement body includes a semicolon, but the language server's range extension
477
+ logic should prevent double semicolons.
478
+ """
479
+ test_case = NixAttrReplacementTest(
480
+ Language.NIX,
481
+ "default.nix",
482
+ "testUser", # Simple attrset with multiple key-value pairs
483
+ NIX_ATTR_REPLACEMENT,
484
+ )
485
+ test_case.run_test(content_after_ground_truth=snapshot)
projects/ui/serena-new/test/serena/test_text_utils.py ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import re
2
+
3
+ import pytest
4
+
5
+ from serena.text_utils import LineType, search_files, search_text
6
+
7
+
8
+ class TestSearchText:
9
+ def test_search_text_with_string_pattern(self):
10
+ """Test searching with a simple string pattern."""
11
+ content = """
12
+ def hello_world():
13
+ print("Hello, World!")
14
+ return 42
15
+ """
16
+
17
+ # Search for a simple string pattern
18
+ matches = search_text("print", content=content)
19
+
20
+ assert len(matches) == 1
21
+ assert matches[0].num_matched_lines == 1
22
+ assert matches[0].start_line == 3
23
+ assert matches[0].end_line == 3
24
+ assert matches[0].lines[0].line_content.strip() == 'print("Hello, World!")'
25
+
26
+ def test_search_text_with_regex_pattern(self):
27
+ """Test searching with a regex pattern."""
28
+ content = """
29
+ class DataProcessor:
30
+ def __init__(self, data):
31
+ self.data = data
32
+
33
+ def process(self):
34
+ return [x * 2 for x in self.data if x > 0]
35
+
36
+ def filter(self, predicate):
37
+ return [x for x in self.data if predicate(x)]
38
+ """
39
+
40
+ # Search for a regex pattern matching method definitions
41
+ pattern = r"def\s+\w+\s*\([^)]*\):"
42
+ matches = search_text(pattern, content=content)
43
+
44
+ assert len(matches) == 3
45
+ assert matches[0].lines[0].match_type == LineType.MATCH
46
+ assert "def __init__" in matches[0].lines[0].line_content
47
+ assert "def process" in matches[1].lines[0].line_content
48
+ assert "def filter" in matches[2].lines[0].line_content
49
+
50
+ def test_search_text_with_compiled_regex(self):
51
+ """Test searching with a pre-compiled regex pattern."""
52
+ content = """
53
+ import os
54
+ import sys
55
+ from pathlib import Path
56
+
57
+ # Configuration variables
58
+ DEBUG = True
59
+ MAX_RETRIES = 3
60
+
61
+ def configure_logging():
62
+ log_level = "DEBUG" if DEBUG else "INFO"
63
+ print(f"Setting log level to {log_level}")
64
+ """
65
+
66
+ # Search for variable assignments with a compiled regex
67
+ pattern = re.compile(r"^\s*[A-Z_]+ = .+$")
68
+ matches = search_text(pattern, content=content)
69
+
70
+ assert len(matches) == 2
71
+ assert "DEBUG = True" in matches[0].lines[0].line_content
72
+ assert "MAX_RETRIES = 3" in matches[1].lines[0].line_content
73
+
74
+ def test_search_text_with_context_lines(self):
75
+ """Test searching with context lines before and after the match."""
76
+ content = """
77
+ def complex_function(a, b, c):
78
+ # This is a complex function that does something.
79
+ if a > b:
80
+ return a * c
81
+ elif b > a:
82
+ return b * c
83
+ else:
84
+ return (a + b) * c
85
+ """
86
+
87
+ # Search with context lines
88
+ matches = search_text("return", content=content, context_lines_before=1, context_lines_after=1)
89
+
90
+ assert len(matches) == 3
91
+
92
+ # Check the first match with context
93
+ first_match = matches[0]
94
+ assert len(first_match.lines) == 3
95
+ assert first_match.lines[0].match_type == LineType.BEFORE_MATCH
96
+ assert first_match.lines[1].match_type == LineType.MATCH
97
+ assert first_match.lines[2].match_type == LineType.AFTER_MATCH
98
+
99
+ # Verify the content of lines
100
+ assert "if a > b:" in first_match.lines[0].line_content
101
+ assert "return a * c" in first_match.lines[1].line_content
102
+ assert "elif b > a:" in first_match.lines[2].line_content
103
+
104
+ def test_search_text_with_multiline_match(self):
105
+ """Test searching with multiline pattern matching."""
106
+ content = """
107
+ def factorial(n):
108
+ if n <= 1:
109
+ return 1
110
+ else:
111
+ return n * factorial(n-1)
112
+
113
+ result = factorial(5) # Should be 120
114
+ """
115
+
116
+ # Search for a pattern that spans multiple lines (if-else block)
117
+ pattern = r"if.*?else.*?return"
118
+ matches = search_text(pattern, content=content, allow_multiline_match=True)
119
+
120
+ assert len(matches) == 1
121
+ multiline_match = matches[0]
122
+ assert multiline_match.num_matched_lines >= 3
123
+ assert "if n <= 1:" in multiline_match.lines[0].line_content
124
+
125
+ # All matched lines should have match_type == LineType.MATCH
126
+ match_lines = [line for line in multiline_match.lines if line.match_type == LineType.MATCH]
127
+ assert len(match_lines) >= 3
128
+
129
+ def test_search_text_with_glob_pattern(self):
130
+ """Test searching with glob-like patterns."""
131
+ content = """
132
+ class UserService:
133
+ def get_user(self, user_id):
134
+ return {"id": user_id, "name": "Test User"}
135
+
136
+ def create_user(self, user_data):
137
+ print(f"Creating user: {user_data}")
138
+ return {"id": 123, **user_data}
139
+
140
+ def update_user(self, user_id, user_data):
141
+ print(f"Updating user {user_id} with {user_data}")
142
+ return True
143
+ """
144
+
145
+ # Search with a glob pattern for all user methods
146
+ matches = search_text("*_user*", content=content, is_glob=True)
147
+
148
+ assert len(matches) == 3
149
+ assert "get_user" in matches[0].lines[0].line_content
150
+ assert "create_user" in matches[1].lines[0].line_content
151
+ assert "update_user" in matches[2].lines[0].line_content
152
+
153
+ def test_search_text_with_complex_glob_pattern(self):
154
+ """Test searching with more complex glob patterns."""
155
+ content = """
156
+ def process_data(data):
157
+ return [transform(item) for item in data]
158
+
159
+ def transform(item):
160
+ if isinstance(item, dict):
161
+ return {k: v.upper() if isinstance(v, str) else v for k, v in item.items()}
162
+ elif isinstance(item, list):
163
+ return [x * 2 for x in item if isinstance(x, (int, float))]
164
+ elif isinstance(item, str):
165
+ return item.upper()
166
+ else:
167
+ return item
168
+ """
169
+
170
+ # Search with a simplified glob pattern to find all isinstance occurrences
171
+ matches = search_text("*isinstance*", content=content, is_glob=True)
172
+
173
+ # Should match lines with isinstance(item, dict) and isinstance(item, list)
174
+ assert len(matches) >= 2
175
+ instance_matches = [
176
+ line.line_content
177
+ for match in matches
178
+ for line in match.lines
179
+ if line.match_type == LineType.MATCH and "isinstance(item," in line.line_content
180
+ ]
181
+ assert len(instance_matches) >= 2
182
+ assert any("isinstance(item, dict)" in line for line in instance_matches)
183
+ assert any("isinstance(item, list)" in line for line in instance_matches)
184
+
185
+ def test_search_text_glob_with_special_chars(self):
186
+ """Glob patterns containing regex special characters should match literally."""
187
+ content = """
188
+ def func_square():
189
+ print("value[42]")
190
+
191
+ def func_curly():
192
+ print("value{bar}")
193
+ """
194
+
195
+ matches_square = search_text(r"*\[42\]*", content=content, is_glob=True)
196
+ assert len(matches_square) == 1
197
+ assert "[42]" in matches_square[0].lines[0].line_content
198
+
199
+ matches_curly = search_text("*{bar}*", content=content, is_glob=True)
200
+ assert len(matches_curly) == 1
201
+ assert "{bar}" in matches_curly[0].lines[0].line_content
202
+
203
+ def test_search_text_no_matches(self):
204
+ """Test searching with a pattern that doesn't match anything."""
205
+ content = """
206
+ def calculate_average(numbers):
207
+ if not numbers:
208
+ return 0
209
+ return sum(numbers) / len(numbers)
210
+ """
211
+
212
+ # Search for a pattern that doesn't exist in the content
213
+ matches = search_text("missing_function", content=content)
214
+
215
+ assert len(matches) == 0
216
+
217
+
218
+ # Mock file reader that always returns matching content
219
+ def mock_reader_always_match(file_path: str) -> str:
220
+ """Mock file reader that returns content guaranteed to match the simple pattern."""
221
+ return "This line contains a match."
222
+
223
+
224
+ class TestSearchFiles:
225
+ @pytest.mark.parametrize(
226
+ "file_paths, pattern, paths_include_glob, paths_exclude_glob, expected_matched_files, description",
227
+ [
228
+ # Basic cases
229
+ (["a.py", "b.txt"], "match", None, None, ["a.py", "b.txt"], "No filters"),
230
+ (["a.py", "b.txt"], "match", "*.py", None, ["a.py"], "Include only .py files"),
231
+ (["a.py", "b.txt"], "match", None, "*.txt", ["a.py"], "Exclude .txt files"),
232
+ (["a.py", "b.txt", "c.py"], "match", "*.py", "c.*", ["a.py"], "Include .py, exclude c.*"),
233
+ # Directory matching - Using pathspec patterns
234
+ (["main.c", "test/main.c"], "match", "test/*", None, ["test/main.c"], "Include files in test/ subdir"),
235
+ (["data/a.csv", "data/b.log"], "match", "data/*", "*.log", ["data/a.csv"], "Include data/*, exclude *.log"),
236
+ (["src/a.py", "tests/b.py"], "match", "src/**", "tests/**", ["src/a.py"], "Include src/**, exclude tests/**"),
237
+ (["src/mod/a.py", "tests/b.py"], "match", "**/*.py", "tests/**", ["src/mod/a.py"], "Include **/*.py, exclude tests/**"),
238
+ (["file.py", "dir/file.py"], "match", "dir/*.py", None, ["dir/file.py"], "Include files directly in dir"),
239
+ (["file.py", "dir/sub/file.py"], "match", "dir/**/*.py", None, ["dir/sub/file.py"], "Include files recursively in dir"),
240
+ # Overlap and edge cases
241
+ (["file.py", "dir/file.py"], "match", "*.py", "dir/*", ["file.py"], "Include *.py, exclude files directly in dir"),
242
+ (["root.py", "adir/a.py", "bdir/b.py"], "match", "a*/*.py", None, ["adir/a.py"], "Include files in dirs starting with 'a'"),
243
+ (["a.txt", "b.log"], "match", "*.py", None, [], "No files match include pattern"),
244
+ (["a.py", "b.py"], "match", None, "*.py", [], "All files match exclude pattern"),
245
+ (["a.py", "b.py"], "match", "a.*", "*.py", [], "Include a.* but exclude *.py -> empty"),
246
+ (["a.py", "b.py"], "match", "*.py", "b.*", ["a.py"], "Include *.py but exclude b.* -> a.py"),
247
+ ],
248
+ ids=lambda x: x if isinstance(x, str) else "", # Use description as test ID
249
+ )
250
+ def test_search_files_include_exclude(
251
+ self, file_paths, pattern, paths_include_glob, paths_exclude_glob, expected_matched_files, description
252
+ ):
253
+ """
254
+ Test the include/exclude glob filtering logic in search_files using PathSpec patterns.
255
+ """
256
+ results = search_files(
257
+ relative_file_paths=file_paths,
258
+ pattern=pattern,
259
+ file_reader=mock_reader_always_match,
260
+ paths_include_glob=paths_include_glob,
261
+ paths_exclude_glob=paths_exclude_glob,
262
+ context_lines_before=0, # No context needed for this test focus
263
+ context_lines_after=0,
264
+ )
265
+
266
+ # Extract the source file paths from the results
267
+ actual_matched_files = sorted([result.source_file_path for result in results if result.source_file_path])
268
+
269
+ # Assert that the matched files are exactly the ones expected
270
+ assert actual_matched_files == sorted(expected_matched_files)
271
+
272
+ # Basic check on results structure if files were expected
273
+ if expected_matched_files:
274
+ assert len(results) == len(expected_matched_files)
275
+ for result in results:
276
+ assert len(result.matched_lines) == 1 # Mock reader returns one matching line
277
+ assert result.matched_lines[0].line_content == "This line contains a match."
278
+ assert result.matched_lines[0].match_type == LineType.MATCH
279
+
280
+ @pytest.mark.parametrize(
281
+ "file_paths, pattern, paths_include_glob, paths_exclude_glob, expected_matched_files, description",
282
+ [
283
+ # Glob patterns that were problematic with gitignore syntax
284
+ (
285
+ ["src/serena/agent.py", "src/serena/process_isolated_agent.py", "test/agent.py"],
286
+ "match",
287
+ "src/**agent.py",
288
+ None,
289
+ ["src/serena/agent.py", "src/serena/process_isolated_agent.py"],
290
+ "Glob: src/**agent.py should match files ending with agent.py under src/",
291
+ ),
292
+ (
293
+ ["src/serena/agent.py", "src/serena/process_isolated_agent.py", "other/agent.py"],
294
+ "match",
295
+ "**agent.py",
296
+ None,
297
+ ["src/serena/agent.py", "src/serena/process_isolated_agent.py", "other/agent.py"],
298
+ "Glob: **agent.py should match files ending with agent.py anywhere",
299
+ ),
300
+ (
301
+ ["dir/subdir/file.py", "dir/other/file.py", "elsewhere/file.py"],
302
+ "match",
303
+ "dir/**file.py",
304
+ None,
305
+ ["dir/subdir/file.py", "dir/other/file.py"],
306
+ "Glob: dir/**file.py should match files ending with file.py under dir/",
307
+ ),
308
+ (
309
+ ["src/a/b/c/test.py", "src/x/test.py", "other/test.py"],
310
+ "match",
311
+ "src/**/test.py",
312
+ None,
313
+ ["src/a/b/c/test.py", "src/x/test.py"],
314
+ "Glob: src/**/test.py should match test.py files under src/ at any depth",
315
+ ),
316
+ # Edge cases for ** patterns
317
+ (
318
+ ["agent.py", "src/agent.py", "src/serena/agent.py"],
319
+ "match",
320
+ "**agent.py",
321
+ None,
322
+ ["agent.py", "src/agent.py", "src/serena/agent.py"],
323
+ "Glob: **agent.py should match at root and any depth",
324
+ ),
325
+ (["file.txt", "src/file.txt"], "match", "src/**", None, ["src/file.txt"], "Glob: src/** should match everything under src/"),
326
+ ],
327
+ ids=lambda x: x if isinstance(x, str) else "", # Use description as test ID
328
+ )
329
+ def test_search_files_glob_patterns(
330
+ self, file_paths, pattern, paths_include_glob, paths_exclude_glob, expected_matched_files, description
331
+ ):
332
+ """
333
+ Test glob patterns that were problematic with the previous gitignore-based implementation.
334
+ """
335
+ results = search_files(
336
+ relative_file_paths=file_paths,
337
+ pattern=pattern,
338
+ file_reader=mock_reader_always_match,
339
+ paths_include_glob=paths_include_glob,
340
+ paths_exclude_glob=paths_exclude_glob,
341
+ context_lines_before=0,
342
+ context_lines_after=0,
343
+ )
344
+
345
+ # Extract the source file paths from the results
346
+ actual_matched_files = sorted([result.source_file_path for result in results if result.source_file_path])
347
+
348
+ # Assert that the matched files are exactly the ones expected
349
+ assert actual_matched_files == sorted(
350
+ expected_matched_files
351
+ ), f"Pattern '{paths_include_glob}' failed: expected {sorted(expected_matched_files)}, got {actual_matched_files}"
352
+
353
+ # Basic check on results structure if files were expected
354
+ if expected_matched_files:
355
+ assert len(results) == len(expected_matched_files)
356
+ for result in results:
357
+ assert len(result.matched_lines) == 1 # Mock reader returns one matching line
358
+ assert result.matched_lines[0].line_content == "This line contains a match."
359
+ assert result.matched_lines[0].match_type == LineType.MATCH
360
+
361
+ def test_search_files_no_pattern_match_in_content(self):
362
+ """Test that no results are returned if the pattern doesn't match the file content, even if files pass filters."""
363
+ file_paths = ["a.py", "b.txt"]
364
+ pattern = "non_existent_pattern_in_mock_content" # This won't match mock_reader_always_match content
365
+ results = search_files(
366
+ relative_file_paths=file_paths,
367
+ pattern=pattern,
368
+ file_reader=mock_reader_always_match, # Content is "This line contains a match."
369
+ paths_include_glob=None, # Both files would pass filters
370
+ paths_exclude_glob=None,
371
+ )
372
+ assert len(results) == 0, "Should not find matches if pattern doesn't match content"
373
+
374
+ def test_search_files_regex_pattern_with_filters(self):
375
+ """Test using a regex pattern works correctly along with include/exclude filters."""
376
+
377
+ def specific_mock_reader(file_path: str) -> str:
378
+ # Provide different content for different files to test regex matching
379
+ if file_path == "a.py": # noqa: SIM116
380
+ return "File A: value=123\nFile A: value=456"
381
+ elif file_path == "b.py":
382
+ return "File B: value=789"
383
+ elif file_path == "c.txt":
384
+ return "File C: value=000"
385
+ return "No values here."
386
+
387
+ file_paths = ["a.py", "b.py", "c.txt"]
388
+ pattern = r"value=(\d+)"
389
+
390
+ results = search_files(
391
+ relative_file_paths=file_paths,
392
+ pattern=pattern,
393
+ file_reader=specific_mock_reader,
394
+ paths_include_glob="*.py", # Only include .py files
395
+ paths_exclude_glob="b.*", # Exclude files starting with b
396
+ )
397
+
398
+ # Expected: a.py included, b.py excluded by glob, c.txt excluded by glob
399
+ # a.py has two matches for the regex pattern
400
+ assert len(results) == 2, "Expected 2 matches only from a.py"
401
+ actual_matched_files = sorted([result.source_file_path for result in results if result.source_file_path])
402
+ assert actual_matched_files == ["a.py", "a.py"], "Both matches should be from a.py"
403
+ # Check the content of the matched lines
404
+ assert results[0].matched_lines[0].line_content == "File A: value=123"
405
+ assert results[1].matched_lines[0].line_content == "File A: value=456"
406
+
407
+ def test_search_files_context_lines_with_filters(self):
408
+ """Test context lines are included correctly when filters are active."""
409
+
410
+ def context_mock_reader(file_path: str) -> str:
411
+ if file_path == "include_me.txt":
412
+ return "Line before 1\nLine before 2\nMATCH HERE\nLine after 1\nLine after 2"
413
+ elif file_path == "exclude_me.log":
414
+ return "Noise\nMATCH HERE\nNoise"
415
+ return "No match"
416
+
417
+ file_paths = ["include_me.txt", "exclude_me.log"]
418
+ pattern = "MATCH HERE"
419
+
420
+ results = search_files(
421
+ relative_file_paths=file_paths,
422
+ pattern=pattern,
423
+ file_reader=context_mock_reader,
424
+ paths_include_glob="*.txt", # Only include .txt files
425
+ paths_exclude_glob=None,
426
+ context_lines_before=1,
427
+ context_lines_after=1,
428
+ )
429
+
430
+ # Expected: Only include_me.txt should be processed and matched
431
+ assert len(results) == 1, "Expected only one result from the included file"
432
+ result = results[0]
433
+ assert result.source_file_path == "include_me.txt"
434
+ assert len(result.lines) == 3, "Expected 3 lines (1 before, 1 match, 1 after)"
435
+ assert result.lines[0].line_content == "Line before 2", "Incorrect 'before' context line"
436
+ assert result.lines[0].match_type == LineType.BEFORE_MATCH
437
+ assert result.lines[1].line_content == "MATCH HERE", "Incorrect 'match' line"
438
+ assert result.lines[1].match_type == LineType.MATCH
439
+ assert result.lines[2].line_content == "Line after 1", "Incorrect 'after' context line"
440
+ assert result.lines[2].match_type == LineType.AFTER_MATCH
441
+
442
+
443
+ class TestGlobMatch:
444
+ """Test the glob_match function directly."""
445
+
446
+ @pytest.mark.parametrize(
447
+ "pattern, path, expected",
448
+ [
449
+ # Basic wildcard patterns
450
+ ("*.py", "file.py", True),
451
+ ("*.py", "file.txt", False),
452
+ ("*agent.py", "agent.py", True),
453
+ ("*agent.py", "process_isolated_agent.py", True),
454
+ ("*agent.py", "agent_test.py", False),
455
+ # Double asterisk patterns
456
+ ("**agent.py", "agent.py", True),
457
+ ("**agent.py", "src/agent.py", True),
458
+ ("**agent.py", "src/serena/agent.py", True),
459
+ ("**agent.py", "src/serena/process_isolated_agent.py", True),
460
+ ("**agent.py", "agent_test.py", False),
461
+ # Prefix with double asterisk
462
+ ("src/**agent.py", "src/agent.py", True),
463
+ ("src/**agent.py", "src/serena/agent.py", True),
464
+ ("src/**agent.py", "src/serena/process_isolated_agent.py", True),
465
+ ("src/**agent.py", "other/agent.py", False),
466
+ ("src/**agent.py", "src/agent_test.py", False),
467
+ # Directory patterns
468
+ ("src/**", "src/file.py", True),
469
+ ("src/**", "src/dir/file.py", True),
470
+ ("src/**", "other/file.py", False),
471
+ # Exact matches with double asterisk
472
+ ("src/**/test.py", "src/test.py", True),
473
+ ("src/**/test.py", "src/a/b/test.py", True),
474
+ ("src/**/test.py", "src/test_file.py", False),
475
+ # Simple patterns without asterisks
476
+ ("src/file.py", "src/file.py", True),
477
+ ("src/file.py", "src/other.py", False),
478
+ ],
479
+ )
480
+ def test_glob_match(self, pattern, path, expected):
481
+ """Test glob_match function with various patterns."""
482
+ from src.serena.text_utils import glob_match
483
+
484
+ assert glob_match(pattern, path) == expected
projects/ui/serena-new/test/serena/test_tool_parameter_types.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import logging
2
+
3
+ import pytest
4
+
5
+ from serena.config.serena_config import SerenaConfig
6
+ from serena.mcp import SerenaMCPFactorySingleProcess
7
+ from serena.tools.tools_base import ToolRegistry
8
+
9
+
10
+ @pytest.mark.parametrize("context", ("chatgpt", "codex", "oaicompat-agent"))
11
+ def test_all_tool_parameters_have_type(context):
12
+ """
13
+ For every tool exposed by Serena, ensure that the generated
14
+ Open‑AI schema contains a ``type`` entry for each parameter.
15
+ """
16
+ cfg = SerenaConfig(gui_log_window_enabled=False, web_dashboard=False, log_level=logging.ERROR)
17
+ registry = ToolRegistry()
18
+ cfg.included_optional_tools = tuple(registry.get_tool_names_optional())
19
+ factory = SerenaMCPFactorySingleProcess(context=context)
20
+ # Initialize the agent so that the tools are available
21
+ factory._instantiate_agent(cfg, [])
22
+ tools = list(factory._iter_tools())
23
+
24
+ for tool in tools:
25
+ mcp_tool = factory.make_mcp_tool(tool, openai_tool_compatible=True)
26
+ params = mcp_tool.parameters
27
+
28
+ # Collect any parameter that lacks a type
29
+ issues = []
30
+ print(f"Checking tool {tool}")
31
+
32
+ if "properties" not in params:
33
+ issues.append(f"Tool {tool.get_name()!r} missing properties section")
34
+ else:
35
+ for pname, prop in params["properties"].items():
36
+ if "type" not in prop:
37
+ issues.append(f"Tool {tool.get_name()!r} parameter {pname!r} missing 'type'")
38
+ if issues:
39
+ raise AssertionError("\n".join(issues))