Add files using upload-large-folder tool
Browse files- projects/ui/serena-new/test/resources/repos/r/test_repo/DESCRIPTION +13 -0
- projects/ui/serena-new/test/resources/repos/r/test_repo/NAMESPACE +7 -0
- projects/ui/serena-new/test/resources/repos/r/test_repo/R/models.R +48 -0
- projects/ui/serena-new/test/resources/repos/r/test_repo/R/utils.R +44 -0
- projects/ui/serena-new/test/resources/repos/r/test_repo/examples/analysis.R +30 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/.solargraph.yml +4 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/examples/user_management.rb +116 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/lib.rb +9 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/main.rb +21 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/models.rb +86 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/nested.rb +51 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/services.rb +60 -0
- projects/ui/serena-new/test/resources/repos/ruby/test_repo/variables.rb +150 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo/Cargo.lock +7 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo/Cargo.toml +6 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo/src/lib.rs +9 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo/src/main.rs +8 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/Cargo.lock +7 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/Cargo.toml +6 -0
- projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/src/lib.rs +21 -0
projects/ui/serena-new/test/resources/repos/r/test_repo/DESCRIPTION
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
Package: testpackage
|
| 2 |
+
Type: Package
|
| 3 |
+
Title: Test Package for R Language Server
|
| 4 |
+
Version: 1.0.0
|
| 5 |
+
Author: Serena Test
|
| 6 |
+
Maintainer: Serena Test <test@example.com>
|
| 7 |
+
Description: A minimal test package for testing R language server functionality.
|
| 8 |
+
This package contains sample R functions for testing symbol extraction,
|
| 9 |
+
completion, and other language server features.
|
| 10 |
+
License: MIT + file LICENSE
|
| 11 |
+
Encoding: UTF-8
|
| 12 |
+
LazyData: true
|
| 13 |
+
RoxygenNote: 7.2.0
|
projects/ui/serena-new/test/resources/repos/r/test_repo/NAMESPACE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Generated by roxygen2: do not edit by hand
|
| 2 |
+
|
| 3 |
+
export(calculate_mean)
|
| 4 |
+
export(create_data_frame)
|
| 5 |
+
export(fit_linear_model)
|
| 6 |
+
export(plot_data)
|
| 7 |
+
export(process_data)
|
projects/ui/serena-new/test/resources/repos/r/test_repo/R/models.R
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#' Fit a linear model
|
| 2 |
+
#'
|
| 3 |
+
#' @param formula A formula for the model
|
| 4 |
+
#' @param data A data frame containing the variables
|
| 5 |
+
#' @return A fitted lm object
|
| 6 |
+
#' @export
|
| 7 |
+
fit_linear_model <- function(formula, data) {
|
| 8 |
+
if (missing(formula) || missing(data)) {
|
| 9 |
+
stop("Both formula and data are required")
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
model <- lm(formula, data = data)
|
| 13 |
+
|
| 14 |
+
# Add some custom attributes
|
| 15 |
+
attr(model, "created_by") <- "fit_linear_model"
|
| 16 |
+
attr(model, "creation_time") <- Sys.time()
|
| 17 |
+
|
| 18 |
+
return(model)
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
#' Plot data using ggplot2-style syntax
|
| 22 |
+
#'
|
| 23 |
+
#' @param data A data frame
|
| 24 |
+
#' @param x_var Column name for x-axis
|
| 25 |
+
#' @param y_var Column name for y-axis
|
| 26 |
+
#' @return A plot object
|
| 27 |
+
#' @export
|
| 28 |
+
plot_data <- function(data, x_var, y_var) {
|
| 29 |
+
if (!is.data.frame(data)) {
|
| 30 |
+
stop("data must be a data frame")
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
if (!(x_var %in% names(data))) {
|
| 34 |
+
stop(paste("Column", x_var, "not found in data"))
|
| 35 |
+
}
|
| 36 |
+
|
| 37 |
+
if (!(y_var %in% names(data))) {
|
| 38 |
+
stop(paste("Column", y_var, "not found in data"))
|
| 39 |
+
}
|
| 40 |
+
|
| 41 |
+
# Create a simple base R plot
|
| 42 |
+
plot(data[[x_var]], data[[y_var]],
|
| 43 |
+
xlab = x_var, ylab = y_var,
|
| 44 |
+
main = paste(y_var, "vs", x_var))
|
| 45 |
+
|
| 46 |
+
# Add a trend line
|
| 47 |
+
abline(lm(data[[y_var]] ~ data[[x_var]]), col = "red")
|
| 48 |
+
}
|
projects/ui/serena-new/test/resources/repos/r/test_repo/R/utils.R
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#' Calculate mean of numeric vector
|
| 2 |
+
#'
|
| 3 |
+
#' @param x A numeric vector
|
| 4 |
+
#' @return The mean of the vector
|
| 5 |
+
#' @export
|
| 6 |
+
calculate_mean <- function(x) {
|
| 7 |
+
if (!is.numeric(x)) {
|
| 8 |
+
stop("Input must be numeric")
|
| 9 |
+
}
|
| 10 |
+
mean(x, na.rm = TRUE)
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
#' Process data by removing missing values
|
| 14 |
+
#'
|
| 15 |
+
#' @param data A data frame
|
| 16 |
+
#' @return A cleaned data frame
|
| 17 |
+
#' @export
|
| 18 |
+
process_data <- function(data) {
|
| 19 |
+
if (!is.data.frame(data)) {
|
| 20 |
+
stop("Input must be a data frame")
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
# Remove rows with any missing values
|
| 24 |
+
clean_data <- na.omit(data)
|
| 25 |
+
|
| 26 |
+
# Add a processed flag
|
| 27 |
+
clean_data$processed <- TRUE
|
| 28 |
+
|
| 29 |
+
return(clean_data)
|
| 30 |
+
}
|
| 31 |
+
|
| 32 |
+
#' Create a sample data frame
|
| 33 |
+
#'
|
| 34 |
+
#' @param n Number of rows to create
|
| 35 |
+
#' @return A data frame with sample data
|
| 36 |
+
#' @export
|
| 37 |
+
create_data_frame <- function(n = 100) {
|
| 38 |
+
data.frame(
|
| 39 |
+
id = 1:n,
|
| 40 |
+
value = rnorm(n),
|
| 41 |
+
category = sample(c("A", "B", "C"), n, replace = TRUE),
|
| 42 |
+
stringsAsFactors = FALSE
|
| 43 |
+
)
|
| 44 |
+
}
|
projects/ui/serena-new/test/resources/repos/r/test_repo/examples/analysis.R
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Example R script demonstrating package usage
|
| 2 |
+
|
| 3 |
+
# Load required libraries
|
| 4 |
+
library(testpackage)
|
| 5 |
+
|
| 6 |
+
# Create sample data
|
| 7 |
+
sample_data <- create_data_frame(n = 50)
|
| 8 |
+
|
| 9 |
+
# Process the data
|
| 10 |
+
clean_data <- process_data(sample_data)
|
| 11 |
+
|
| 12 |
+
# Calculate some statistics
|
| 13 |
+
mean_value <- calculate_mean(clean_data$value)
|
| 14 |
+
cat("Mean value:", mean_value, "\n")
|
| 15 |
+
|
| 16 |
+
# Fit a simple model
|
| 17 |
+
model <- fit_linear_model(value ~ id, data = clean_data)
|
| 18 |
+
summary(model)
|
| 19 |
+
|
| 20 |
+
# Create a plot
|
| 21 |
+
plot_data(clean_data, "id", "value")
|
| 22 |
+
|
| 23 |
+
# Additional analysis function (not exported)
|
| 24 |
+
analyze_categories <- function(data) {
|
| 25 |
+
table(data$category)
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
# Run the analysis
|
| 29 |
+
category_summary <- analyze_categories(clean_data)
|
| 30 |
+
print(category_summary)
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/.solargraph.yml
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
include:
|
| 3 |
+
- "main.rb"
|
| 4 |
+
- "lib.rb"
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/examples/user_management.rb
ADDED
|
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
require '../services.rb'
|
| 2 |
+
require '../models.rb'
|
| 3 |
+
|
| 4 |
+
class UserStats
|
| 5 |
+
attr_reader :user_count, :active_users, :last_updated
|
| 6 |
+
|
| 7 |
+
def initialize
|
| 8 |
+
@user_count = 0
|
| 9 |
+
@active_users = 0
|
| 10 |
+
@last_updated = Time.now
|
| 11 |
+
end
|
| 12 |
+
|
| 13 |
+
def update_stats(total, active)
|
| 14 |
+
@user_count = total
|
| 15 |
+
@active_users = active
|
| 16 |
+
@last_updated = Time.now
|
| 17 |
+
end
|
| 18 |
+
|
| 19 |
+
def activity_ratio
|
| 20 |
+
return 0.0 if @user_count == 0
|
| 21 |
+
(@active_users.to_f / @user_count * 100).round(2)
|
| 22 |
+
end
|
| 23 |
+
|
| 24 |
+
def formatted_stats
|
| 25 |
+
"Users: #{@user_count}, Active: #{@active_users} (#{activity_ratio}%)"
|
| 26 |
+
end
|
| 27 |
+
end
|
| 28 |
+
|
| 29 |
+
class UserManager
|
| 30 |
+
def initialize
|
| 31 |
+
@service = Services::UserService.new
|
| 32 |
+
@stats = UserStats.new
|
| 33 |
+
end
|
| 34 |
+
|
| 35 |
+
def create_user_with_tracking(id, name, email = nil)
|
| 36 |
+
user = @service.create_user(id, name)
|
| 37 |
+
user.email = email if email
|
| 38 |
+
|
| 39 |
+
update_statistics
|
| 40 |
+
notify_user_created(user)
|
| 41 |
+
|
| 42 |
+
user
|
| 43 |
+
end
|
| 44 |
+
|
| 45 |
+
def get_user_details(id)
|
| 46 |
+
user = @service.get_user(id)
|
| 47 |
+
return nil unless user
|
| 48 |
+
|
| 49 |
+
{
|
| 50 |
+
user_info: user.full_info,
|
| 51 |
+
created_at: Time.now,
|
| 52 |
+
stats: @stats.formatted_stats
|
| 53 |
+
}
|
| 54 |
+
end
|
| 55 |
+
|
| 56 |
+
def bulk_create_users(user_data_list)
|
| 57 |
+
created_users = []
|
| 58 |
+
|
| 59 |
+
user_data_list.each do |data|
|
| 60 |
+
user = create_user_with_tracking(data[:id], data[:name], data[:email])
|
| 61 |
+
created_users << user
|
| 62 |
+
end
|
| 63 |
+
|
| 64 |
+
created_users
|
| 65 |
+
end
|
| 66 |
+
|
| 67 |
+
private
|
| 68 |
+
|
| 69 |
+
def update_statistics
|
| 70 |
+
total_users = @service.users.length
|
| 71 |
+
# For demo purposes, assume all users are active
|
| 72 |
+
@stats.update_stats(total_users, total_users)
|
| 73 |
+
end
|
| 74 |
+
|
| 75 |
+
def notify_user_created(user)
|
| 76 |
+
puts "User created: #{user.name} (ID: #{user.id})"
|
| 77 |
+
end
|
| 78 |
+
end
|
| 79 |
+
|
| 80 |
+
def process_user_data(raw_data)
|
| 81 |
+
processed = raw_data.map do |entry|
|
| 82 |
+
{
|
| 83 |
+
id: entry["id"] || entry[:id],
|
| 84 |
+
name: entry["name"] || entry[:name],
|
| 85 |
+
email: entry["email"] || entry[:email]
|
| 86 |
+
}
|
| 87 |
+
end
|
| 88 |
+
|
| 89 |
+
processed.reject { |entry| entry[:name].nil? || entry[:name].empty? }
|
| 90 |
+
end
|
| 91 |
+
|
| 92 |
+
def main
|
| 93 |
+
# Example usage
|
| 94 |
+
manager = UserManager.new
|
| 95 |
+
|
| 96 |
+
sample_data = [
|
| 97 |
+
{ id: 1, name: "Alice Johnson", email: "alice@example.com" },
|
| 98 |
+
{ id: 2, name: "Bob Smith", email: "bob@example.com" },
|
| 99 |
+
{ id: 3, name: "Charlie Brown" }
|
| 100 |
+
]
|
| 101 |
+
|
| 102 |
+
users = manager.bulk_create_users(sample_data)
|
| 103 |
+
|
| 104 |
+
users.each do |user|
|
| 105 |
+
details = manager.get_user_details(user.id)
|
| 106 |
+
puts details[:user_info]
|
| 107 |
+
end
|
| 108 |
+
|
| 109 |
+
puts "\nFinal statistics:"
|
| 110 |
+
stats = UserStats.new
|
| 111 |
+
stats.update_stats(users.length, users.length)
|
| 112 |
+
puts stats.formatted_stats
|
| 113 |
+
end
|
| 114 |
+
|
| 115 |
+
# Execute if this file is run directly
|
| 116 |
+
main if __FILE__ == $0
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/lib.rb
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class Calculator
|
| 2 |
+
def add(a, b)
|
| 3 |
+
a + b
|
| 4 |
+
end
|
| 5 |
+
|
| 6 |
+
def subtract(a, b)
|
| 7 |
+
a - b
|
| 8 |
+
end
|
| 9 |
+
end
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/main.rb
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
require './lib.rb'
|
| 2 |
+
|
| 3 |
+
class DemoClass
|
| 4 |
+
attr_accessor :value
|
| 5 |
+
|
| 6 |
+
def initialize(value)
|
| 7 |
+
@value = value
|
| 8 |
+
end
|
| 9 |
+
|
| 10 |
+
def print_value
|
| 11 |
+
puts @value
|
| 12 |
+
end
|
| 13 |
+
end
|
| 14 |
+
|
| 15 |
+
def helper_function(number = 42)
|
| 16 |
+
demo = DemoClass.new(number)
|
| 17 |
+
Calculator.new.add(demo.value, 10)
|
| 18 |
+
demo.print_value
|
| 19 |
+
end
|
| 20 |
+
|
| 21 |
+
helper_function
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/models.rb
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class User
|
| 2 |
+
attr_accessor :id, :name, :email
|
| 3 |
+
|
| 4 |
+
def initialize(id, name, email = nil)
|
| 5 |
+
@id = id
|
| 6 |
+
@name = name
|
| 7 |
+
@email = email
|
| 8 |
+
end
|
| 9 |
+
|
| 10 |
+
def full_info
|
| 11 |
+
info = "User: #{@name} (ID: #{@id})"
|
| 12 |
+
info += ", Email: #{@email}" if @email
|
| 13 |
+
info
|
| 14 |
+
end
|
| 15 |
+
|
| 16 |
+
def to_hash
|
| 17 |
+
{
|
| 18 |
+
id: @id,
|
| 19 |
+
name: @name,
|
| 20 |
+
email: @email
|
| 21 |
+
}
|
| 22 |
+
end
|
| 23 |
+
|
| 24 |
+
def self.from_hash(hash)
|
| 25 |
+
new(hash[:id], hash[:name], hash[:email])
|
| 26 |
+
end
|
| 27 |
+
|
| 28 |
+
class << self
|
| 29 |
+
def default_user
|
| 30 |
+
new(0, "Guest")
|
| 31 |
+
end
|
| 32 |
+
end
|
| 33 |
+
end
|
| 34 |
+
|
| 35 |
+
class Item
|
| 36 |
+
attr_reader :id, :name, :price
|
| 37 |
+
|
| 38 |
+
def initialize(id, name, price)
|
| 39 |
+
@id = id
|
| 40 |
+
@name = name
|
| 41 |
+
@price = price
|
| 42 |
+
end
|
| 43 |
+
|
| 44 |
+
def discounted_price(discount_percent)
|
| 45 |
+
@price * (1 - discount_percent / 100.0)
|
| 46 |
+
end
|
| 47 |
+
|
| 48 |
+
def description
|
| 49 |
+
"#{@name}: $#{@price}"
|
| 50 |
+
end
|
| 51 |
+
end
|
| 52 |
+
|
| 53 |
+
module ItemHelpers
|
| 54 |
+
def format_price(price)
|
| 55 |
+
"$#{sprintf('%.2f', price)}"
|
| 56 |
+
end
|
| 57 |
+
|
| 58 |
+
def calculate_tax(price, tax_rate = 0.08)
|
| 59 |
+
price * tax_rate
|
| 60 |
+
end
|
| 61 |
+
end
|
| 62 |
+
|
| 63 |
+
class Order
|
| 64 |
+
include ItemHelpers
|
| 65 |
+
|
| 66 |
+
def initialize
|
| 67 |
+
@items = []
|
| 68 |
+
@total = 0
|
| 69 |
+
end
|
| 70 |
+
|
| 71 |
+
def add_item(item, quantity = 1)
|
| 72 |
+
@items << { item: item, quantity: quantity }
|
| 73 |
+
calculate_total
|
| 74 |
+
end
|
| 75 |
+
|
| 76 |
+
def total_with_tax
|
| 77 |
+
tax = calculate_tax(@total)
|
| 78 |
+
@total + tax
|
| 79 |
+
end
|
| 80 |
+
|
| 81 |
+
private
|
| 82 |
+
|
| 83 |
+
def calculate_total
|
| 84 |
+
@total = @items.sum { |entry| entry[:item].price * entry[:quantity] }
|
| 85 |
+
end
|
| 86 |
+
end
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/nested.rb
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
class OuterClass
|
| 2 |
+
def initialize
|
| 3 |
+
@value = "outer"
|
| 4 |
+
end
|
| 5 |
+
|
| 6 |
+
def outer_method
|
| 7 |
+
inner_function = lambda do |x|
|
| 8 |
+
x * 2
|
| 9 |
+
end
|
| 10 |
+
|
| 11 |
+
result = inner_function.call(5)
|
| 12 |
+
puts "Result: #{result}"
|
| 13 |
+
end
|
| 14 |
+
|
| 15 |
+
class NestedClass
|
| 16 |
+
def initialize(name)
|
| 17 |
+
@name = name
|
| 18 |
+
end
|
| 19 |
+
|
| 20 |
+
def find_me
|
| 21 |
+
"Found in NestedClass: #{@name}"
|
| 22 |
+
end
|
| 23 |
+
|
| 24 |
+
def nested_method
|
| 25 |
+
puts "Nested method called"
|
| 26 |
+
end
|
| 27 |
+
|
| 28 |
+
class DeeplyNested
|
| 29 |
+
def deep_method
|
| 30 |
+
"Deep inside"
|
| 31 |
+
end
|
| 32 |
+
end
|
| 33 |
+
end
|
| 34 |
+
|
| 35 |
+
module NestedModule
|
| 36 |
+
def module_method
|
| 37 |
+
"Module method"
|
| 38 |
+
end
|
| 39 |
+
|
| 40 |
+
class ModuleClass
|
| 41 |
+
def module_class_method
|
| 42 |
+
"Module class method"
|
| 43 |
+
end
|
| 44 |
+
end
|
| 45 |
+
end
|
| 46 |
+
end
|
| 47 |
+
|
| 48 |
+
# Test usage of nested classes
|
| 49 |
+
outer = OuterClass.new
|
| 50 |
+
nested = OuterClass::NestedClass.new("test")
|
| 51 |
+
result = nested.find_me
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/services.rb
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
require './lib.rb'
|
| 2 |
+
require './models.rb'
|
| 3 |
+
|
| 4 |
+
module Services
|
| 5 |
+
class UserService
|
| 6 |
+
attr_reader :users
|
| 7 |
+
|
| 8 |
+
def initialize
|
| 9 |
+
@users = {}
|
| 10 |
+
end
|
| 11 |
+
|
| 12 |
+
def create_user(id, name)
|
| 13 |
+
user = User.new(id, name)
|
| 14 |
+
@users[id] = user
|
| 15 |
+
user
|
| 16 |
+
end
|
| 17 |
+
|
| 18 |
+
def get_user(id)
|
| 19 |
+
@users[id]
|
| 20 |
+
end
|
| 21 |
+
|
| 22 |
+
def delete_user(id)
|
| 23 |
+
@users.delete(id)
|
| 24 |
+
end
|
| 25 |
+
|
| 26 |
+
private
|
| 27 |
+
|
| 28 |
+
def validate_user_data(id, name)
|
| 29 |
+
return false if id.nil? || name.nil?
|
| 30 |
+
return false if name.empty?
|
| 31 |
+
true
|
| 32 |
+
end
|
| 33 |
+
end
|
| 34 |
+
|
| 35 |
+
class ItemService
|
| 36 |
+
def initialize
|
| 37 |
+
@items = []
|
| 38 |
+
end
|
| 39 |
+
|
| 40 |
+
def add_item(item)
|
| 41 |
+
@items << item
|
| 42 |
+
end
|
| 43 |
+
|
| 44 |
+
def find_item(id)
|
| 45 |
+
@items.find { |item| item.id == id }
|
| 46 |
+
end
|
| 47 |
+
end
|
| 48 |
+
end
|
| 49 |
+
|
| 50 |
+
# Module-level function
|
| 51 |
+
def create_service_container
|
| 52 |
+
{
|
| 53 |
+
user_service: Services::UserService.new,
|
| 54 |
+
item_service: Services::ItemService.new
|
| 55 |
+
}
|
| 56 |
+
end
|
| 57 |
+
|
| 58 |
+
# Variables for testing
|
| 59 |
+
user_service_instance = Services::UserService.new
|
| 60 |
+
item_service_instance = Services::ItemService.new
|
projects/ui/serena-new/test/resources/repos/ruby/test_repo/variables.rb
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
require './models.rb'
|
| 2 |
+
|
| 3 |
+
# Global variables for testing references
|
| 4 |
+
$global_counter = 0
|
| 5 |
+
$global_config = {
|
| 6 |
+
debug: true,
|
| 7 |
+
timeout: 30
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
class DataContainer
|
| 11 |
+
attr_accessor :status, :data, :metadata
|
| 12 |
+
|
| 13 |
+
def initialize
|
| 14 |
+
@status = "pending"
|
| 15 |
+
@data = {}
|
| 16 |
+
@metadata = {
|
| 17 |
+
created_at: Time.now,
|
| 18 |
+
version: "1.0"
|
| 19 |
+
}
|
| 20 |
+
end
|
| 21 |
+
|
| 22 |
+
def update_status(new_status)
|
| 23 |
+
old_status = @status
|
| 24 |
+
@status = new_status
|
| 25 |
+
log_status_change(old_status, new_status)
|
| 26 |
+
end
|
| 27 |
+
|
| 28 |
+
def process_data(input_data)
|
| 29 |
+
@data = input_data
|
| 30 |
+
@status = "processing"
|
| 31 |
+
|
| 32 |
+
# Process the data
|
| 33 |
+
result = @data.transform_values { |v| v.to_s.upcase }
|
| 34 |
+
@status = "completed"
|
| 35 |
+
|
| 36 |
+
result
|
| 37 |
+
end
|
| 38 |
+
|
| 39 |
+
def get_metadata_info
|
| 40 |
+
info = "Status: #{@status}, Version: #{@metadata[:version]}"
|
| 41 |
+
info += ", Created: #{@metadata[:created_at]}"
|
| 42 |
+
info
|
| 43 |
+
end
|
| 44 |
+
|
| 45 |
+
private
|
| 46 |
+
|
| 47 |
+
def log_status_change(old_status, new_status)
|
| 48 |
+
puts "Status changed from #{old_status} to #{new_status}"
|
| 49 |
+
end
|
| 50 |
+
end
|
| 51 |
+
|
| 52 |
+
class StatusTracker
|
| 53 |
+
def initialize
|
| 54 |
+
@tracked_items = []
|
| 55 |
+
end
|
| 56 |
+
|
| 57 |
+
def add_item(item)
|
| 58 |
+
@tracked_items << item
|
| 59 |
+
item.status = "tracked" if item.respond_to?(:status=)
|
| 60 |
+
end
|
| 61 |
+
|
| 62 |
+
def find_by_status(target_status)
|
| 63 |
+
@tracked_items.select { |item| item.status == target_status }
|
| 64 |
+
end
|
| 65 |
+
|
| 66 |
+
def update_all_status(new_status)
|
| 67 |
+
@tracked_items.each do |item|
|
| 68 |
+
item.status = new_status if item.respond_to?(:status=)
|
| 69 |
+
end
|
| 70 |
+
end
|
| 71 |
+
end
|
| 72 |
+
|
| 73 |
+
# Module level variables and functions
|
| 74 |
+
module ProcessingHelper
|
| 75 |
+
PROCESSING_MODES = ["sync", "async", "batch"].freeze
|
| 76 |
+
|
| 77 |
+
@@instance_count = 0
|
| 78 |
+
|
| 79 |
+
def self.create_processor(mode = "sync")
|
| 80 |
+
@@instance_count += 1
|
| 81 |
+
{
|
| 82 |
+
id: @@instance_count,
|
| 83 |
+
mode: mode,
|
| 84 |
+
created_at: Time.now
|
| 85 |
+
}
|
| 86 |
+
end
|
| 87 |
+
|
| 88 |
+
def self.get_instance_count
|
| 89 |
+
@@instance_count
|
| 90 |
+
end
|
| 91 |
+
end
|
| 92 |
+
|
| 93 |
+
# Test instances for reference testing
|
| 94 |
+
dataclass_instance = DataContainer.new
|
| 95 |
+
dataclass_instance.status = "initialized"
|
| 96 |
+
|
| 97 |
+
second_dataclass = DataContainer.new
|
| 98 |
+
second_dataclass.update_status("ready")
|
| 99 |
+
|
| 100 |
+
tracker = StatusTracker.new
|
| 101 |
+
tracker.add_item(dataclass_instance)
|
| 102 |
+
tracker.add_item(second_dataclass)
|
| 103 |
+
|
| 104 |
+
# Function that uses the variables
|
| 105 |
+
def demonstrate_variable_usage
|
| 106 |
+
puts "Global counter: #{$global_counter}"
|
| 107 |
+
|
| 108 |
+
container = DataContainer.new
|
| 109 |
+
container.status = "demo"
|
| 110 |
+
|
| 111 |
+
processor = ProcessingHelper.create_processor("async")
|
| 112 |
+
puts "Created processor #{processor[:id]} in #{processor[:mode]} mode"
|
| 113 |
+
|
| 114 |
+
container
|
| 115 |
+
end
|
| 116 |
+
|
| 117 |
+
# More complex variable interactions
|
| 118 |
+
class VariableInteractionTest
|
| 119 |
+
def initialize
|
| 120 |
+
@internal_status = "created"
|
| 121 |
+
@data_containers = []
|
| 122 |
+
end
|
| 123 |
+
|
| 124 |
+
def add_container(container)
|
| 125 |
+
@data_containers << container
|
| 126 |
+
container.status = "added_to_collection"
|
| 127 |
+
@internal_status = "modified"
|
| 128 |
+
end
|
| 129 |
+
|
| 130 |
+
def process_all_containers
|
| 131 |
+
@data_containers.each do |container|
|
| 132 |
+
container.status = "batch_processed"
|
| 133 |
+
end
|
| 134 |
+
@internal_status = "processing_complete"
|
| 135 |
+
end
|
| 136 |
+
|
| 137 |
+
def get_status_summary
|
| 138 |
+
statuses = @data_containers.map(&:status)
|
| 139 |
+
{
|
| 140 |
+
internal: @internal_status,
|
| 141 |
+
containers: statuses,
|
| 142 |
+
count: @data_containers.length
|
| 143 |
+
}
|
| 144 |
+
end
|
| 145 |
+
end
|
| 146 |
+
|
| 147 |
+
# Create instances for testing
|
| 148 |
+
interaction_test = VariableInteractionTest.new
|
| 149 |
+
interaction_test.add_container(dataclass_instance)
|
| 150 |
+
interaction_test.add_container(second_dataclass)
|
projects/ui/serena-new/test/resources/repos/rust/test_repo/Cargo.lock
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is automatically @generated by Cargo.
|
| 2 |
+
# It is not intended for manual editing.
|
| 3 |
+
version = 3
|
| 4 |
+
|
| 5 |
+
[[package]]
|
| 6 |
+
name = "rsandbox"
|
| 7 |
+
version = "0.1.0"
|
projects/ui/serena-new/test/resources/repos/rust/test_repo/Cargo.toml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "rsandbox"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2021"
|
| 5 |
+
|
| 6 |
+
[dependencies]
|
projects/ui/serena-new/test/resources/repos/rust/test_repo/src/lib.rs
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// This function returns the sum of 2 + 2
|
| 2 |
+
pub fn add() -> i32 {
|
| 3 |
+
let res = 2 + 2;
|
| 4 |
+
res
|
| 5 |
+
}
|
| 6 |
+
pub fn multiply() -> i32 {
|
| 7 |
+
2 * 3
|
| 8 |
+
}
|
| 9 |
+
|
projects/ui/serena-new/test/resources/repos/rust/test_repo/src/main.rs
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
use rsandbox::add;
|
| 2 |
+
|
| 3 |
+
fn main() {
|
| 4 |
+
println!("Hello, World!");
|
| 5 |
+
println!("Good morning!");
|
| 6 |
+
println!("add result: {}", add());
|
| 7 |
+
println!("inserted line");
|
| 8 |
+
}
|
projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/Cargo.lock
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# This file is automatically @generated by Cargo.
|
| 2 |
+
# It is not intended for manual editing.
|
| 3 |
+
version = 4
|
| 4 |
+
|
| 5 |
+
[[package]]
|
| 6 |
+
name = "rsandbox_2024"
|
| 7 |
+
version = "0.1.0"
|
projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/Cargo.toml
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[package]
|
| 2 |
+
name = "rsandbox_2024"
|
| 3 |
+
version = "0.1.0"
|
| 4 |
+
edition = "2024"
|
| 5 |
+
|
| 6 |
+
[dependencies]
|
projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/src/lib.rs
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
pub fn multiply(a: i32, b: i32) -> i32 {
|
| 2 |
+
a * b
|
| 3 |
+
}
|
| 4 |
+
|
| 5 |
+
pub struct Calculator {
|
| 6 |
+
pub result: i32,
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
impl Calculator {
|
| 10 |
+
pub fn new() -> Self {
|
| 11 |
+
Calculator { result: 0 }
|
| 12 |
+
}
|
| 13 |
+
|
| 14 |
+
pub fn add(&mut self, value: i32) {
|
| 15 |
+
self.result += value;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
pub fn get_result(&self) -> i32 {
|
| 19 |
+
self.result
|
| 20 |
+
}
|
| 21 |
+
}
|