ADAPT-Chase commited on
Commit
743debb
·
verified ·
1 Parent(s): e6ed164

Add files using upload-large-folder tool

Browse files
Files changed (20) hide show
  1. projects/ui/serena-new/test/resources/repos/java/test_repo/src/main/java/test_repo/ModelUser.java +8 -0
  2. projects/ui/serena-new/test/resources/repos/java/test_repo/src/main/java/test_repo/Utils.java +7 -0
  3. projects/ui/serena-new/test/resources/repos/kotlin/test_repo/build.gradle.kts +11 -0
  4. projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/Main.kt +15 -0
  5. projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/Model.kt +3 -0
  6. projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/ModelUser.kt +9 -0
  7. projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/Utils.kt +7 -0
  8. projects/ui/serena-new/test/resources/repos/lua/test_repo/.gitignore +13 -0
  9. projects/ui/serena-new/test/resources/repos/lua/test_repo/main.lua +114 -0
  10. projects/ui/serena-new/test/resources/repos/lua/test_repo/src/calculator.lua +76 -0
  11. projects/ui/serena-new/test/resources/repos/lua/test_repo/src/utils.lua +120 -0
  12. projects/ui/serena-new/test/resources/repos/lua/test_repo/tests/test_calculator.lua +93 -0
  13. projects/ui/serena-new/test/resources/repos/nix/test_repo/.gitignore +11 -0
  14. projects/ui/serena-new/test/resources/repos/nix/test_repo/default.nix +183 -0
  15. projects/ui/serena-new/test/resources/repos/nix/test_repo/flake.nix +146 -0
  16. projects/ui/serena-new/test/resources/repos/nix/test_repo/lib/utils.nix +165 -0
  17. projects/ui/serena-new/test/resources/repos/nix/test_repo/modules/example.nix +145 -0
  18. projects/ui/serena-new/test/resources/repos/nix/test_repo/scripts/hello.sh +3 -0
  19. projects/ui/serena-new/test/resources/repos/php/test_repo/helper.php +7 -0
  20. projects/ui/serena-new/test/resources/repos/php/test_repo/index.php +20 -0
projects/ui/serena-new/test/resources/repos/java/test_repo/src/main/java/test_repo/ModelUser.java ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ package test_repo;
2
+
3
+ public class ModelUser {
4
+ public static void main(String[] args) {
5
+ Model model = new Model("Cascade");
6
+ System.out.println(model.getName());
7
+ }
8
+ }
projects/ui/serena-new/test/resources/repos/java/test_repo/src/main/java/test_repo/Utils.java ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ package test_repo;
2
+
3
+ public class Utils {
4
+ public static void printHello() {
5
+ System.out.println("Hello from Utils!");
6
+ }
7
+ }
projects/ui/serena-new/test/resources/repos/kotlin/test_repo/build.gradle.kts ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ plugins {
2
+ kotlin("jvm") version "1.9.21"
3
+ application
4
+ }
5
+
6
+ group = "test.serena"
7
+ version = "1.0-SNAPSHOT"
8
+
9
+ repositories {
10
+ mavenCentral()
11
+ }
projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/Main.kt ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ package test_repo
2
+
3
+ object Main {
4
+ @JvmStatic
5
+ fun main(args: Array<String>) {
6
+ Utils.printHello()
7
+ val model = Model("Cascade")
8
+ println(model.name)
9
+ acceptModel(model)
10
+ }
11
+
12
+ fun acceptModel(m: Model?) {
13
+ // Do nothing, just for LSP reference
14
+ }
15
+ }
projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/Model.kt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ package test_repo
2
+
3
+ data class Model(val name: String)
projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/ModelUser.kt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ package test_repo
2
+
3
+ object ModelUser {
4
+ @JvmStatic
5
+ fun main(args: Array<String>) {
6
+ val model = Model("Cascade")
7
+ println(model.name)
8
+ }
9
+ }
projects/ui/serena-new/test/resources/repos/kotlin/test_repo/src/main/kotlin/test_repo/Utils.kt ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ package test_repo
2
+
3
+ object Utils {
4
+ fun printHello() {
5
+ println("Hello from Utils!")
6
+ }
7
+ }
projects/ui/serena-new/test/resources/repos/lua/test_repo/.gitignore ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Lua specific
2
+ *.luac
3
+ .luarocks/
4
+ lua_modules/
5
+ luarocks/
6
+
7
+ # Build artifacts
8
+ build/
9
+ dist/
10
+
11
+ # IDE
12
+ .vscode/
13
+ .idea/
projects/ui/serena-new/test/resources/repos/lua/test_repo/main.lua ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env lua
2
+
3
+ -- main.lua: Entry point for the test application
4
+
5
+ local calculator = require("src.calculator")
6
+ local utils = require("src.utils")
7
+
8
+ local function print_banner()
9
+ print("=" .. string.rep("=", 40))
10
+ print(" Lua Test Repository")
11
+ print("=" .. string.rep("=", 40))
12
+ end
13
+
14
+ local function test_calculator()
15
+ print("\nTesting Calculator Module:")
16
+ print("5 + 3 =", calculator.add(5, 3))
17
+ print("10 - 4 =", calculator.subtract(10, 4))
18
+ print("6 * 7 =", calculator.multiply(6, 7))
19
+ print("15 / 3 =", calculator.divide(15, 3))
20
+ print("2^8 =", calculator.power(2, 8))
21
+ print("5! =", calculator.factorial(5))
22
+
23
+ local numbers = {5, 2, 8, 3, 9, 1, 7}
24
+ print("Mean of", table.concat(numbers, ", "), "=", calculator.mean(numbers))
25
+ print("Median of", table.concat(numbers, ", "), "=", calculator.median(numbers))
26
+ end
27
+
28
+ local function test_utils()
29
+ print("\nTesting Utils Module:")
30
+
31
+ -- String utilities
32
+ print("Trimmed ' hello ' =", "'" .. utils.trim(" hello ") .. "'")
33
+ local parts = utils.split("apple,banana,orange", ",")
34
+ print("Split 'apple,banana,orange' by ',' =", table.concat(parts, " | "))
35
+ print("'hello' starts with 'he' =", utils.starts_with("hello", "he"))
36
+ print("'world' ends with 'ld' =", utils.ends_with("world", "ld"))
37
+
38
+ -- Table utilities
39
+ local t1 = {a = 1, b = 2}
40
+ local t2 = {b = 3, c = 4}
41
+ local merged = utils.table_merge(t1, t2)
42
+ print("Merged tables: a=" .. (merged.a or "nil") ..
43
+ ", b=" .. (merged.b or "nil") ..
44
+ ", c=" .. (merged.c or "nil"))
45
+
46
+ -- Logger
47
+ local logger = utils.Logger:new("TestApp")
48
+ logger:info("Application started")
49
+ logger:debug("Debug information")
50
+ logger:warn("This is a warning")
51
+ end
52
+
53
+ local function interactive_calculator()
54
+ print("\nInteractive Calculator (type 'quit' to exit):")
55
+ while true do
56
+ io.write("Enter operation (e.g., '5 + 3'): ")
57
+ local input = io.read()
58
+
59
+ if input == "quit" then
60
+ break
61
+ end
62
+
63
+ -- Simple parser for basic operations
64
+ local a, op, b = input:match("(%d+)%s*([%+%-%*/])%s*(%d+)")
65
+ if a and op and b then
66
+ a = tonumber(a)
67
+ b = tonumber(b)
68
+ local result
69
+
70
+ if op == "+" then
71
+ result = calculator.add(a, b)
72
+ elseif op == "-" then
73
+ result = calculator.subtract(a, b)
74
+ elseif op == "*" then
75
+ result = calculator.multiply(a, b)
76
+ elseif op == "/" then
77
+ local success, res = pcall(calculator.divide, a, b)
78
+ if success then
79
+ result = res
80
+ else
81
+ print("Error: " .. res)
82
+ goto continue
83
+ end
84
+ end
85
+
86
+ print("Result: " .. result)
87
+ else
88
+ print("Invalid input. Please use format: number operator number")
89
+ end
90
+
91
+ ::continue::
92
+ end
93
+ end
94
+
95
+ -- Main execution
96
+ local function main(args)
97
+ print_banner()
98
+
99
+ if #args == 0 then
100
+ test_calculator()
101
+ test_utils()
102
+ elseif args[1] == "interactive" then
103
+ interactive_calculator()
104
+ elseif args[1] == "test" then
105
+ test_calculator()
106
+ test_utils()
107
+ print("\nAll tests completed!")
108
+ else
109
+ print("Usage: lua main.lua [interactive|test]")
110
+ end
111
+ end
112
+
113
+ -- Run main function
114
+ main(arg or {})
projects/ui/serena-new/test/resources/repos/lua/test_repo/src/calculator.lua ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- calculator.lua: A simple calculator module for testing LSP features
2
+
3
+ local calculator = {}
4
+
5
+ -- Basic arithmetic operations
6
+ function calculator.add(a, b)
7
+ return a + b
8
+ end
9
+
10
+ function calculator.subtract(a, b)
11
+ return a - b
12
+ end
13
+
14
+ function calculator.multiply(a, b)
15
+ return a * b
16
+ end
17
+
18
+ function calculator.divide(a, b)
19
+ if b == 0 then
20
+ error("Division by zero")
21
+ end
22
+ return a / b
23
+ end
24
+
25
+ -- Advanced operations
26
+ function calculator.power(base, exponent)
27
+ return base ^ exponent
28
+ end
29
+
30
+ function calculator.factorial(n)
31
+ if n < 0 then
32
+ error("Factorial is not defined for negative numbers")
33
+ elseif n == 0 or n == 1 then
34
+ return 1
35
+ else
36
+ local result = 1
37
+ for i = 2, n do
38
+ result = result * i
39
+ end
40
+ return result
41
+ end
42
+ end
43
+
44
+ -- Statistics functions
45
+ function calculator.mean(numbers)
46
+ if #numbers == 0 then
47
+ return nil
48
+ end
49
+
50
+ local sum = 0
51
+ for _, num in ipairs(numbers) do
52
+ sum = sum + num
53
+ end
54
+ return sum / #numbers
55
+ end
56
+
57
+ function calculator.median(numbers)
58
+ if #numbers == 0 then
59
+ return nil
60
+ end
61
+
62
+ local sorted = {}
63
+ for i, v in ipairs(numbers) do
64
+ sorted[i] = v
65
+ end
66
+ table.sort(sorted)
67
+
68
+ local mid = math.floor(#sorted / 2)
69
+ if #sorted % 2 == 0 then
70
+ return (sorted[mid] + sorted[mid + 1]) / 2
71
+ else
72
+ return sorted[mid + 1]
73
+ end
74
+ end
75
+
76
+ return calculator
projects/ui/serena-new/test/resources/repos/lua/test_repo/src/utils.lua ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- utils.lua: Utility functions for the test repository
2
+
3
+ local utils = {}
4
+
5
+ -- String utilities
6
+ function utils.trim(s)
7
+ return s:match("^%s*(.-)%s*$")
8
+ end
9
+
10
+ function utils.split(str, delimiter)
11
+ local result = {}
12
+ local pattern = string.format("([^%s]+)", delimiter)
13
+ for match in string.gmatch(str, pattern) do
14
+ table.insert(result, match)
15
+ end
16
+ return result
17
+ end
18
+
19
+ function utils.starts_with(str, prefix)
20
+ return str:sub(1, #prefix) == prefix
21
+ end
22
+
23
+ function utils.ends_with(str, suffix)
24
+ return str:sub(-#suffix) == suffix
25
+ end
26
+
27
+ -- Table utilities
28
+ function utils.deep_copy(orig)
29
+ local orig_type = type(orig)
30
+ local copy
31
+ if orig_type == 'table' then
32
+ copy = {}
33
+ for orig_key, orig_value in next, orig, nil do
34
+ copy[utils.deep_copy(orig_key)] = utils.deep_copy(orig_value)
35
+ end
36
+ setmetatable(copy, utils.deep_copy(getmetatable(orig)))
37
+ else
38
+ copy = orig
39
+ end
40
+ return copy
41
+ end
42
+
43
+ function utils.table_contains(tbl, value)
44
+ for _, v in ipairs(tbl) do
45
+ if v == value then
46
+ return true
47
+ end
48
+ end
49
+ return false
50
+ end
51
+
52
+ function utils.table_merge(t1, t2)
53
+ local result = {}
54
+ for k, v in pairs(t1) do
55
+ result[k] = v
56
+ end
57
+ for k, v in pairs(t2) do
58
+ result[k] = v
59
+ end
60
+ return result
61
+ end
62
+
63
+ -- File utilities
64
+ function utils.read_file(path)
65
+ local file = io.open(path, "r")
66
+ if not file then
67
+ return nil, "Could not open file: " .. path
68
+ end
69
+ local content = file:read("*all")
70
+ file:close()
71
+ return content
72
+ end
73
+
74
+ function utils.write_file(path, content)
75
+ local file = io.open(path, "w")
76
+ if not file then
77
+ return false, "Could not open file for writing: " .. path
78
+ end
79
+ file:write(content)
80
+ file:close()
81
+ return true
82
+ end
83
+
84
+ -- Class-like structure
85
+ utils.Logger = {}
86
+ utils.Logger.__index = utils.Logger
87
+
88
+ function utils.Logger:new(name)
89
+ local self = setmetatable({}, utils.Logger)
90
+ self.name = name or "default"
91
+ self.level = "info"
92
+ return self
93
+ end
94
+
95
+ function utils.Logger:set_level(level)
96
+ self.level = level
97
+ end
98
+
99
+ function utils.Logger:log(message, level)
100
+ level = level or self.level
101
+ print(string.format("[%s] %s: %s", self.name, level:upper(), message))
102
+ end
103
+
104
+ function utils.Logger:debug(message)
105
+ self:log(message, "debug")
106
+ end
107
+
108
+ function utils.Logger:info(message)
109
+ self:log(message, "info")
110
+ end
111
+
112
+ function utils.Logger:warn(message)
113
+ self:log(message, "warn")
114
+ end
115
+
116
+ function utils.Logger:error(message)
117
+ self:log(message, "error")
118
+ end
119
+
120
+ return utils
projects/ui/serena-new/test/resources/repos/lua/test_repo/tests/test_calculator.lua ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ -- test_calculator.lua: Unit tests for calculator module
2
+
3
+ local calculator = require("src.calculator")
4
+
5
+ local function assert_equals(actual, expected, message)
6
+ if actual ~= expected then
7
+ error(string.format("%s: expected %s, got %s",
8
+ message or "Assertion failed", tostring(expected), tostring(actual)))
9
+ end
10
+ end
11
+
12
+ local function assert_error(func, message)
13
+ local success = pcall(func)
14
+ if success then
15
+ error(string.format("%s: expected error but none was thrown",
16
+ message or "Assertion failed"))
17
+ end
18
+ end
19
+
20
+ local function test_basic_operations()
21
+ print("Testing basic operations...")
22
+ assert_equals(calculator.add(2, 3), 5, "Addition test")
23
+ assert_equals(calculator.add(-5, 5), 0, "Addition with negative")
24
+ assert_equals(calculator.add(0, 0), 0, "Addition with zeros")
25
+
26
+ assert_equals(calculator.subtract(10, 3), 7, "Subtraction test")
27
+ assert_equals(calculator.subtract(5, 10), -5, "Subtraction negative result")
28
+
29
+ assert_equals(calculator.multiply(4, 5), 20, "Multiplication test")
30
+ assert_equals(calculator.multiply(-3, 4), -12, "Multiplication with negative")
31
+ assert_equals(calculator.multiply(0, 100), 0, "Multiplication with zero")
32
+
33
+ assert_equals(calculator.divide(10, 2), 5, "Division test")
34
+ assert_equals(calculator.divide(7, 2), 3.5, "Division with decimal result")
35
+ assert_error(function() calculator.divide(5, 0) end, "Division by zero")
36
+
37
+ print("✓ Basic operations tests passed")
38
+ end
39
+
40
+ local function test_advanced_operations()
41
+ print("Testing advanced operations...")
42
+ assert_equals(calculator.power(2, 3), 8, "Power test")
43
+ assert_equals(calculator.power(5, 0), 1, "Power of zero")
44
+ assert_equals(calculator.power(10, -1), 0.1, "Negative exponent")
45
+
46
+ assert_equals(calculator.factorial(0), 1, "Factorial of 0")
47
+ assert_equals(calculator.factorial(1), 1, "Factorial of 1")
48
+ assert_equals(calculator.factorial(5), 120, "Factorial of 5")
49
+ assert_equals(calculator.factorial(10), 3628800, "Factorial of 10")
50
+ assert_error(function() calculator.factorial(-1) end, "Factorial of negative")
51
+
52
+ print("✓ Advanced operations tests passed")
53
+ end
54
+
55
+ local function test_statistics()
56
+ print("Testing statistics functions...")
57
+
58
+ -- Mean tests
59
+ assert_equals(calculator.mean({1, 2, 3, 4, 5}), 3, "Mean of sequential numbers")
60
+ assert_equals(calculator.mean({10}), 10, "Mean of single number")
61
+ assert_equals(calculator.mean({-5, 5}), 0, "Mean with negatives")
62
+ assert_equals(calculator.mean({}), nil, "Mean of empty array")
63
+
64
+ -- Median tests
65
+ assert_equals(calculator.median({1, 2, 3, 4, 5}), 3, "Median of odd count")
66
+ assert_equals(calculator.median({1, 2, 3, 4}), 2.5, "Median of even count")
67
+ assert_equals(calculator.median({5, 1, 3, 2, 4}), 3, "Median of unsorted")
68
+ assert_equals(calculator.median({7}), 7, "Median of single number")
69
+ assert_equals(calculator.median({}), nil, "Median of empty array")
70
+
71
+ print("✓ Statistics tests passed")
72
+ end
73
+
74
+ -- Run all tests
75
+ local function run_all_tests()
76
+ print("Running calculator tests...\n")
77
+ test_basic_operations()
78
+ test_advanced_operations()
79
+ test_statistics()
80
+ print("\n✅ All calculator tests passed!")
81
+ end
82
+
83
+ -- Execute tests if run directly
84
+ if arg and arg[0] and arg[0]:match("test_calculator%.lua$") then
85
+ run_all_tests()
86
+ end
87
+
88
+ return {
89
+ run_all_tests = run_all_tests,
90
+ test_basic_operations = test_basic_operations,
91
+ test_advanced_operations = test_advanced_operations,
92
+ test_statistics = test_statistics
93
+ }
projects/ui/serena-new/test/resources/repos/nix/test_repo/.gitignore ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Nix specific
2
+ result
3
+ result-*
4
+ .direnv/
5
+
6
+ # Build artifacts
7
+ *.drv
8
+
9
+ # IDE
10
+ .vscode/
11
+ .idea/
projects/ui/serena-new/test/resources/repos/nix/test_repo/default.nix ADDED
@@ -0,0 +1,183 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # default.nix - Traditional Nix expression for backwards compatibility
2
+ { pkgs ? import <nixpkgs> { } }:
3
+
4
+ let
5
+ # Import library functions
6
+ lib = pkgs.lib;
7
+ stdenv = pkgs.stdenv;
8
+
9
+ # Import our custom utilities
10
+ utils = import ./lib/utils.nix { inherit lib; };
11
+
12
+ # Custom function to create a greeting
13
+ makeGreeting = name: "Hello, ${name}!";
14
+
15
+ # List manipulation functions (using imported utils)
16
+ listUtils = {
17
+ double = list: map (x: x * 2) list;
18
+ sum = list: lib.foldl' (acc: x: acc + x) 0 list;
19
+ average = list:
20
+ if list == [ ]
21
+ then 0
22
+ else (listUtils.sum list) / (builtins.length list);
23
+ # Use function from imported utils
24
+ unique = utils.lists.unique;
25
+ };
26
+
27
+ # String utilities
28
+ stringUtils = rec {
29
+ capitalize = str:
30
+ let
31
+ first = lib.substring 0 1 str;
32
+ rest = lib.substring 1 (-1) str;
33
+ in
34
+ (lib.toUpper first) + rest;
35
+
36
+ repeat = n: str: lib.concatStrings (lib.genList (_: str) n);
37
+
38
+ padLeft = width: char: str:
39
+ let
40
+ len = lib.stringLength str;
41
+ padding = if len >= width then 0 else width - len;
42
+ in
43
+ (repeat padding char) + str;
44
+ };
45
+
46
+ # Package builder helper
47
+ buildSimplePackage = { name, version, script }:
48
+ stdenv.mkDerivation {
49
+ pname = name;
50
+ inherit version;
51
+
52
+ phases = [ "installPhase" ];
53
+
54
+ installPhase = ''
55
+ mkdir -p $out/bin
56
+ cat > $out/bin/${name} << EOF
57
+ #!/usr/bin/env bash
58
+ ${script}
59
+ EOF
60
+ chmod +x $out/bin/${name}
61
+ '';
62
+ };
63
+
64
+ in
65
+ rec {
66
+ # Export utilities
67
+ inherit listUtils stringUtils makeGreeting;
68
+
69
+ # Export imported utilities directly
70
+ inherit (utils) math strings;
71
+
72
+ # Example packages
73
+ hello = buildSimplePackage {
74
+ name = "hello";
75
+ version = "1.0";
76
+ script = ''
77
+ echo "${makeGreeting "World"}"
78
+ '';
79
+ };
80
+
81
+ calculator = buildSimplePackage {
82
+ name = "calculator";
83
+ version = "0.1";
84
+ script = ''
85
+ if [ $# -ne 3 ]; then
86
+ echo "Usage: calculator <num1> <op> <num2>"
87
+ exit 1
88
+ fi
89
+
90
+ case $2 in
91
+ +) echo $(($1 + $3)) ;;
92
+ -) echo $(($1 - $3)) ;;
93
+ x) echo $(($1 * $3)) ;;
94
+ /) echo $(($1 / $3)) ;;
95
+ *) echo "Unknown operator: $2" ;;
96
+ esac
97
+ '';
98
+ };
99
+
100
+ # Environment with multiple packages
101
+ devEnv = pkgs.buildEnv {
102
+ name = "dev-environment";
103
+ paths = with pkgs; [
104
+ git
105
+ vim
106
+ bash
107
+ hello
108
+ calculator
109
+ ];
110
+ };
111
+
112
+ # Shell derivation
113
+ shell = pkgs.mkShell {
114
+ buildInputs = with pkgs; [
115
+ bash
116
+ coreutils
117
+ findutils
118
+ gnugrep
119
+ gnused
120
+ ];
121
+
122
+ shellHook = ''
123
+ echo "Entering Nix shell environment"
124
+ echo "Available custom functions: makeGreeting, listUtils, stringUtils"
125
+ '';
126
+ };
127
+
128
+ # Configuration example
129
+ config = {
130
+ system = {
131
+ stateVersion = "23.11";
132
+ enable = true;
133
+ };
134
+
135
+ services = {
136
+ nginx = {
137
+ enable = false;
138
+ virtualHosts = {
139
+ "example.com" = {
140
+ root = "/var/www/example";
141
+ locations."/" = {
142
+ index = "index.html";
143
+ };
144
+ };
145
+ };
146
+ };
147
+ };
148
+
149
+ users = {
150
+ testUser = {
151
+ name = "test";
152
+ group = "users";
153
+ home = "/home/test";
154
+ shell = "${pkgs.bash}/bin/bash";
155
+ };
156
+ };
157
+ };
158
+
159
+ # Recursive attribute set example
160
+ tree = {
161
+ root = {
162
+ value = 1;
163
+ left = {
164
+ value = 2;
165
+ left = { value = 4; };
166
+ right = { value = 5; };
167
+ };
168
+ right = {
169
+ value = 3;
170
+ left = { value = 6; };
171
+ right = { value = 7; };
172
+ };
173
+ };
174
+
175
+ # Tree traversal function
176
+ traverse = node:
177
+ if node ? left && node ? right
178
+ then [ node.value ] ++ (tree.traverse node.left) ++ (tree.traverse node.right)
179
+ else if node ? value
180
+ then [ node.value ]
181
+ else [ ];
182
+ };
183
+ }
projects/ui/serena-new/test/resources/repos/nix/test_repo/flake.nix ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ description = "Test Nix flake for language server testing";
3
+
4
+ inputs = {
5
+ nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6
+ flake-utils.url = "github:numtide/flake-utils";
7
+ };
8
+
9
+ outputs = { self, nixpkgs, flake-utils }:
10
+ flake-utils.lib.eachDefaultSystem (system:
11
+ let
12
+ pkgs = nixpkgs.legacyPackages.${system};
13
+
14
+ # Import our default.nix for shared logic
15
+ defaultNix = import ./default.nix { inherit pkgs; };
16
+
17
+ # Custom derivation for testing
18
+ hello-custom = pkgs.stdenv.mkDerivation {
19
+ pname = "hello-custom";
20
+ version = "1.0.0";
21
+
22
+ src = ./.;
23
+
24
+ buildInputs = with pkgs; [
25
+ bash
26
+ coreutils
27
+ ];
28
+
29
+ installPhase = ''
30
+ mkdir -p $out/bin
31
+ cp ${./scripts/hello.sh} $out/bin/hello-custom
32
+ chmod +x $out/bin/hello-custom
33
+ '';
34
+
35
+ meta = with pkgs.lib; {
36
+ description = "A custom hello world script";
37
+ license = licenses.mit;
38
+ platforms = platforms.all;
39
+ };
40
+ };
41
+
42
+ # Development shell configuration
43
+ devShell = pkgs.mkShell {
44
+ buildInputs = with pkgs; [
45
+ # Development tools
46
+ git
47
+ gnumake
48
+ gcc
49
+
50
+ # Nix tools
51
+ nix-prefetch-git
52
+ nixpkgs-fmt
53
+ nil
54
+
55
+ # Languages
56
+ python3
57
+ nodejs
58
+ rustc
59
+ cargo
60
+ ];
61
+
62
+ shellHook = ''
63
+ echo "Welcome to the Nix development shell!"
64
+ echo "Available tools: git, make, gcc, python3, nodejs, rustc"
65
+ '';
66
+ };
67
+
68
+ in
69
+ {
70
+ # Packages
71
+ packages = {
72
+ default = hello-custom;
73
+ inherit hello-custom;
74
+
75
+ # Another package for testing
76
+ utils = pkgs.stdenv.mkDerivation {
77
+ pname = "test-utils";
78
+ version = "0.1.0";
79
+ src = ./.;
80
+
81
+ installPhase = ''
82
+ mkdir -p $out/share
83
+ echo "Utility functions" > $out/share/utils.txt
84
+ '';
85
+ };
86
+ };
87
+
88
+ # Apps
89
+ apps = {
90
+ default = {
91
+ type = "app";
92
+ program = "${hello-custom}/bin/hello-custom";
93
+ };
94
+
95
+ hello = {
96
+ type = "app";
97
+ program = "${hello-custom}/bin/hello-custom";
98
+ };
99
+ };
100
+
101
+ # Development shells
102
+ devShells = {
103
+ default = devShell;
104
+
105
+ # Minimal shell for testing
106
+ minimal = pkgs.mkShell {
107
+ buildInputs = with pkgs; [
108
+ bash
109
+ coreutils
110
+ ];
111
+ };
112
+ };
113
+
114
+ # Overlay
115
+ overlays.default = final: prev: {
116
+ inherit hello-custom;
117
+ };
118
+
119
+ # NixOS module
120
+ nixosModules.default = { config, lib, pkgs, ... }:
121
+ with lib;
122
+ {
123
+ options.services.hello-custom = {
124
+ enable = mkEnableOption "hello-custom service";
125
+
126
+ message = mkOption {
127
+ type = types.str;
128
+ default = "Hello from NixOS!";
129
+ description = "Message to display";
130
+ };
131
+ };
132
+
133
+ config = mkIf config.services.hello-custom.enable {
134
+ systemd.services.hello-custom = {
135
+ description = "Hello Custom Service";
136
+ wantedBy = [ "multi-user.target" ];
137
+ serviceConfig = {
138
+ ExecStart = "${hello-custom}/bin/hello-custom";
139
+ Type = "oneshot";
140
+ };
141
+ };
142
+ };
143
+ };
144
+ }
145
+ );
146
+ }
projects/ui/serena-new/test/resources/repos/nix/test_repo/lib/utils.nix ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Utility functions library
2
+ { lib }:
3
+
4
+ rec {
5
+ # Math utilities
6
+ math = {
7
+ # Calculate factorial
8
+ factorial = n:
9
+ if n == 0
10
+ then 1
11
+ else n * factorial (n - 1);
12
+
13
+ # Calculate fibonacci number
14
+ fibonacci = n:
15
+ if n <= 1
16
+ then n
17
+ else (fibonacci (n - 1)) + (fibonacci (n - 2));
18
+
19
+ # Check if number is prime
20
+ isPrime = n:
21
+ let
22
+ checkDivisible = i:
23
+ if i * i > n then true
24
+ else if lib.mod n i == 0 then false
25
+ else checkDivisible (i + 1);
26
+ in
27
+ if n <= 1 then false
28
+ else if n <= 3 then true
29
+ else checkDivisible 2;
30
+
31
+ # Greatest common divisor
32
+ gcd = a: b:
33
+ if b == 0
34
+ then a
35
+ else gcd b (lib.mod a b);
36
+ };
37
+
38
+ # String manipulation
39
+ strings = {
40
+ # Reverse a string
41
+ reverse = str:
42
+ let
43
+ len = lib.stringLength str;
44
+ chars = lib.genList (i: lib.substring (len - i - 1) 1 str) len;
45
+ in
46
+ lib.concatStrings chars;
47
+
48
+ # Check if string is palindrome
49
+ isPalindrome = str:
50
+ str == strings.reverse str;
51
+
52
+ # Convert to camelCase
53
+ toCamelCase = str:
54
+ let
55
+ words = lib.splitString "-" str;
56
+ capitalize = w:
57
+ if w == "" then ""
58
+ else (lib.toUpper (lib.substring 0 1 w)) + (lib.substring 1 (-1) w);
59
+ capitalizedWords = lib.tail (map capitalize words);
60
+ in
61
+ (lib.head words) + (lib.concatStrings capitalizedWords);
62
+
63
+ # Convert to snake_case
64
+ toSnakeCase = str:
65
+ lib.replaceStrings ["-"] ["_"] (lib.toLower str);
66
+ };
67
+
68
+ # List operations
69
+ lists = {
70
+ # Get unique elements
71
+ unique = list:
72
+ lib.foldl' (acc: x:
73
+ if lib.elem x acc
74
+ then acc
75
+ else acc ++ [x]
76
+ ) [] list;
77
+
78
+ # Zip two lists
79
+ zip = list1: list2:
80
+ let
81
+ len1 = lib.length list1;
82
+ len2 = lib.length list2;
83
+ minLen = if len1 < len2 then len1 else len2;
84
+ in
85
+ lib.genList (i: {
86
+ fst = lib.elemAt list1 i;
87
+ snd = lib.elemAt list2 i;
88
+ }) minLen;
89
+
90
+ # Flatten nested list
91
+ flatten = list:
92
+ lib.foldl' (acc: x:
93
+ if builtins.isList x
94
+ then acc ++ (flatten x)
95
+ else acc ++ [x]
96
+ ) [] list;
97
+
98
+ # Partition list by predicate
99
+ partition = pred: list:
100
+ lib.foldl' (acc: x:
101
+ if pred x
102
+ then { yes = acc.yes ++ [x]; no = acc.no; }
103
+ else { yes = acc.yes; no = acc.no ++ [x]; }
104
+ ) { yes = []; no = []; } list;
105
+ };
106
+
107
+ # Attribute set operations
108
+ attrs = {
109
+ # Deep merge two attribute sets
110
+ deepMerge = attr1: attr2:
111
+ lib.recursiveUpdate attr1 attr2;
112
+
113
+ # Filter attributes by predicate
114
+ filterAttrs = pred: attrs:
115
+ lib.filterAttrs pred attrs;
116
+
117
+ # Map over attribute values
118
+ mapValues = f: attrs:
119
+ lib.mapAttrs (name: value: f value) attrs;
120
+
121
+ # Get nested attribute safely
122
+ getAttrPath = path: default: attrs:
123
+ lib.attrByPath path default attrs;
124
+ };
125
+
126
+ # File system utilities
127
+ files = {
128
+ # Read JSON file
129
+ readJSON = path:
130
+ builtins.fromJSON (builtins.readFile path);
131
+
132
+ # Read TOML file
133
+ readTOML = path:
134
+ builtins.fromTOML (builtins.readFile path);
135
+
136
+ # Check if path exists
137
+ pathExists = path:
138
+ builtins.pathExists path;
139
+
140
+ # Get file type
141
+ getFileType = path:
142
+ let
143
+ type = builtins.readFileType path;
144
+ in
145
+ if type == "directory" then "dir"
146
+ else if type == "regular" then "file"
147
+ else if type == "symlink" then "link"
148
+ else "unknown";
149
+ };
150
+
151
+ # Validation utilities
152
+ validate = {
153
+ # Check if value is email
154
+ isEmail = str:
155
+ builtins.match "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$" str != null;
156
+
157
+ # Check if value is URL
158
+ isURL = str:
159
+ builtins.match "^https?://[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}" str != null;
160
+
161
+ # Check if value is valid version
162
+ isVersion = str:
163
+ builtins.match "^[0-9]+\\.[0-9]+\\.[0-9]+$" str != null;
164
+ };
165
+ }
projects/ui/serena-new/test/resources/repos/nix/test_repo/modules/example.nix ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Example NixOS module
2
+ { config, lib, pkgs, ... }:
3
+
4
+ with lib;
5
+
6
+ let
7
+ cfg = config.services.example;
8
+
9
+ # Helper function to generate config file
10
+ generateConfig = settings: ''
11
+ # Generated configuration
12
+ ${lib.concatStringsSep "\n" (lib.mapAttrsToList (k: v: "${k} = ${toString v}") settings)}
13
+ '';
14
+
15
+ in {
16
+ # Module options
17
+ options = {
18
+ services.example = {
19
+ enable = mkEnableOption "example service";
20
+
21
+ package = mkOption {
22
+ type = types.package;
23
+ default = pkgs.hello;
24
+ description = "Package to use for the service";
25
+ };
26
+
27
+ port = mkOption {
28
+ type = types.port;
29
+ default = 8080;
30
+ description = "Port to listen on";
31
+ };
32
+
33
+ host = mkOption {
34
+ type = types.str;
35
+ default = "localhost";
36
+ description = "Host to bind to";
37
+ };
38
+
39
+ workers = mkOption {
40
+ type = types.int;
41
+ default = 4;
42
+ description = "Number of worker processes";
43
+ };
44
+
45
+ settings = mkOption {
46
+ type = types.attrsOf types.anything;
47
+ default = {};
48
+ description = "Additional settings";
49
+ };
50
+
51
+ users = mkOption {
52
+ type = types.listOf types.str;
53
+ default = [];
54
+ description = "List of users with access";
55
+ };
56
+
57
+ database = {
58
+ enable = mkOption {
59
+ type = types.bool;
60
+ default = false;
61
+ description = "Enable database support";
62
+ };
63
+
64
+ type = mkOption {
65
+ type = types.enum [ "postgresql" "mysql" "sqlite" ];
66
+ default = "sqlite";
67
+ description = "Database type";
68
+ };
69
+
70
+ host = mkOption {
71
+ type = types.str;
72
+ default = "localhost";
73
+ description = "Database host";
74
+ };
75
+
76
+ name = mkOption {
77
+ type = types.str;
78
+ default = "example";
79
+ description = "Database name";
80
+ };
81
+ };
82
+ };
83
+ };
84
+
85
+ # Module configuration
86
+ config = mkIf cfg.enable {
87
+ # System packages
88
+ environment.systemPackages = [ cfg.package ];
89
+
90
+ # Systemd service
91
+ systemd.services.example = {
92
+ description = "Example Service";
93
+ after = [ "network.target" ] ++ (optional cfg.database.enable "postgresql.service");
94
+ wantedBy = [ "multi-user.target" ];
95
+
96
+ serviceConfig = {
97
+ Type = "simple";
98
+ User = "example";
99
+ Group = "example";
100
+ ExecStart = "${cfg.package}/bin/example --port ${toString cfg.port} --host ${cfg.host}";
101
+ Restart = "on-failure";
102
+ RestartSec = 5;
103
+
104
+ # Security hardening
105
+ PrivateTmp = true;
106
+ ProtectSystem = "strict";
107
+ ProtectHome = true;
108
+ NoNewPrivileges = true;
109
+ };
110
+
111
+ environment = {
112
+ EXAMPLE_WORKERS = toString cfg.workers;
113
+ EXAMPLE_CONFIG = generateConfig cfg.settings;
114
+ } // optionalAttrs cfg.database.enable {
115
+ DATABASE_TYPE = cfg.database.type;
116
+ DATABASE_HOST = cfg.database.host;
117
+ DATABASE_NAME = cfg.database.name;
118
+ };
119
+ };
120
+
121
+ # User and group
122
+ users.users.example = {
123
+ isSystemUser = true;
124
+ group = "example";
125
+ description = "Example service user";
126
+ };
127
+
128
+ users.groups.example = {};
129
+
130
+ # Firewall rules
131
+ networking.firewall = mkIf (cfg.host == "0.0.0.0") {
132
+ allowedTCPPorts = [ cfg.port ];
133
+ };
134
+
135
+ # Database setup
136
+ services.postgresql = mkIf (cfg.database.enable && cfg.database.type == "postgresql") {
137
+ enable = true;
138
+ ensureDatabases = [ cfg.database.name ];
139
+ ensureUsers = [{
140
+ name = "example";
141
+ ensureDBOwnership = true;
142
+ }];
143
+ };
144
+ };
145
+ }
projects/ui/serena-new/test/resources/repos/nix/test_repo/scripts/hello.sh ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ # Simple hello script for testing
3
+ echo "Hello from Nix!"
projects/ui/serena-new/test/resources/repos/php/test_repo/helper.php ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ function helperFunction(): void {
4
+ echo "Helper function was called.";
5
+ }
6
+
7
+ ?>
projects/ui/serena-new/test/resources/repos/php/test_repo/index.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once 'helper.php';
4
+
5
+ function greet(string $name): string {
6
+ return "Hello, " . $name . "!";
7
+ }
8
+
9
+ $userName = "PHP User";
10
+ $greeting = greet($userName);
11
+
12
+ echo $greeting;
13
+
14
+ helperFunction();
15
+
16
+ function useHelperFunction() {
17
+ helperFunction();
18
+ }
19
+
20
+ ?>