Add files using upload-large-folder tool
Browse files- projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/src/main.rs +19 -0
- projects/ui/serena-new/test/resources/repos/swift/test_repo/Package.swift +16 -0
- projects/ui/serena-new/test/resources/repos/swift/test_repo/src/main.swift +62 -0
- projects/ui/serena-new/test/resources/repos/swift/test_repo/src/utils.swift +20 -0
- projects/ui/serena-new/test/resources/repos/terraform/test_repo/data.tf +28 -0
- projects/ui/serena-new/test/resources/repos/terraform/test_repo/main.tf +126 -0
- projects/ui/serena-new/test/resources/repos/terraform/test_repo/outputs.tf +46 -0
- projects/ui/serena-new/test/resources/repos/terraform/test_repo/variables.tf +61 -0
- projects/ui/serena-new/test/resources/repos/typescript/test_repo/.serena/project.yml +7 -0
- projects/ui/serena-new/test/resources/repos/typescript/test_repo/index.ts +16 -0
- projects/ui/serena-new/test/resources/repos/typescript/test_repo/tsconfig.json +11 -0
- projects/ui/serena-new/test/resources/repos/typescript/test_repo/use_helper.ts +8 -0
- projects/ui/serena-new/test/resources/repos/zig/test_repo/.gitignore +5 -0
- projects/ui/serena-new/test/resources/repos/zig/test_repo/build.zig +31 -0
- projects/ui/serena-new/test/resources/repos/zig/test_repo/src/calculator.zig +66 -0
- projects/ui/serena-new/test/resources/repos/zig/test_repo/src/main.zig +32 -0
- projects/ui/serena-new/test/resources/repos/zig/test_repo/src/math_utils.zig +65 -0
- projects/ui/serena-new/test/resources/repos/zig/test_repo/zls.json +12 -0
- projects/ui/serena-new/test/serena/__snapshots__/test_symbol_editing.ambr +1108 -0
- projects/ui/serena-new/test/serena/config/__init__.py +1 -0
projects/ui/serena-new/test/resources/repos/rust/test_repo_2024/src/main.rs
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
fn main() {
|
| 2 |
+
println!("Hello, Rust 2024 edition!");
|
| 3 |
+
let result = add(2, 3);
|
| 4 |
+
println!("2 + 3 = {}", result);
|
| 5 |
+
}
|
| 6 |
+
|
| 7 |
+
pub fn add(a: i32, b: i32) -> i32 {
|
| 8 |
+
a + b
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
#[cfg(test)]
|
| 12 |
+
mod tests {
|
| 13 |
+
use super::*;
|
| 14 |
+
|
| 15 |
+
#[test]
|
| 16 |
+
fn test_add() {
|
| 17 |
+
assert_eq!(add(2, 3), 5);
|
| 18 |
+
}
|
| 19 |
+
}
|
projects/ui/serena-new/test/resources/repos/swift/test_repo/Package.swift
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
// swift-tools-version: 5.9
|
| 2 |
+
import PackageDescription
|
| 3 |
+
|
| 4 |
+
let package = Package(
|
| 5 |
+
name: "test_repo",
|
| 6 |
+
products: [
|
| 7 |
+
.library(
|
| 8 |
+
name: "test_repo",
|
| 9 |
+
targets: ["test_repo"]),
|
| 10 |
+
],
|
| 11 |
+
targets: [
|
| 12 |
+
.target(
|
| 13 |
+
name: "test_repo",
|
| 14 |
+
dependencies: []),
|
| 15 |
+
]
|
| 16 |
+
)
|
projects/ui/serena-new/test/resources/repos/swift/test_repo/src/main.swift
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Foundation
|
| 2 |
+
|
| 3 |
+
// Main entry point
|
| 4 |
+
func main() {
|
| 5 |
+
let calculator = Calculator()
|
| 6 |
+
let result = calculator.add(5, 3)
|
| 7 |
+
print("Result: \(result)")
|
| 8 |
+
|
| 9 |
+
let user = User(name: "Alice", age: 30)
|
| 10 |
+
user.greet()
|
| 11 |
+
|
| 12 |
+
let area = Utils.calculateArea(radius: 5.0)
|
| 13 |
+
print("Circle area: \(area)")
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
class Calculator {
|
| 17 |
+
func add(_ a: Int, _ b: Int) -> Int {
|
| 18 |
+
return a + b
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
func multiply(_ a: Int, _ b: Int) -> Int {
|
| 22 |
+
return a * b
|
| 23 |
+
}
|
| 24 |
+
}
|
| 25 |
+
|
| 26 |
+
struct User {
|
| 27 |
+
let name: String
|
| 28 |
+
let age: Int
|
| 29 |
+
|
| 30 |
+
func greet() {
|
| 31 |
+
print("Hello, my name is \(name) and I am \(age) years old.")
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
func isAdult() -> Bool {
|
| 35 |
+
return age >= 18
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
enum Status {
|
| 40 |
+
case active
|
| 41 |
+
case inactive
|
| 42 |
+
case pending
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
protocol Drawable {
|
| 46 |
+
func draw()
|
| 47 |
+
}
|
| 48 |
+
|
| 49 |
+
class Circle: Drawable {
|
| 50 |
+
let radius: Double
|
| 51 |
+
|
| 52 |
+
init(radius: Double) {
|
| 53 |
+
self.radius = radius
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
func draw() {
|
| 57 |
+
print("Drawing a circle with radius \(radius)")
|
| 58 |
+
}
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
// Call main
|
| 62 |
+
main()
|
projects/ui/serena-new/test/resources/repos/swift/test_repo/src/utils.swift
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import Foundation
|
| 2 |
+
|
| 3 |
+
public struct Utils {
|
| 4 |
+
public static func formatDate(_ date: Date) -> String {
|
| 5 |
+
let formatter = DateFormatter()
|
| 6 |
+
formatter.dateStyle = .medium
|
| 7 |
+
return formatter.string(from: date)
|
| 8 |
+
}
|
| 9 |
+
|
| 10 |
+
public static func calculateArea(radius: Double) -> Double {
|
| 11 |
+
return Double.pi * radius * radius
|
| 12 |
+
}
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
public extension String {
|
| 16 |
+
func isValidEmail() -> Bool {
|
| 17 |
+
let emailRegex = "[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,}"
|
| 18 |
+
return NSPredicate(format: "SELF MATCHES %@", emailRegex).evaluate(with: self)
|
| 19 |
+
}
|
| 20 |
+
}
|
projects/ui/serena-new/test/resources/repos/terraform/test_repo/data.tf
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Data sources for the Terraform configuration
|
| 2 |
+
|
| 3 |
+
# Get the latest Ubuntu AMI
|
| 4 |
+
data "aws_ami" "ubuntu" {
|
| 5 |
+
most_recent = true
|
| 6 |
+
owners = ["099720109477"] # Canonical
|
| 7 |
+
|
| 8 |
+
filter {
|
| 9 |
+
name = "name"
|
| 10 |
+
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
filter {
|
| 14 |
+
name = "virtualization-type"
|
| 15 |
+
values = ["hvm"]
|
| 16 |
+
}
|
| 17 |
+
}
|
| 18 |
+
|
| 19 |
+
# Get available availability zones
|
| 20 |
+
data "aws_availability_zones" "available" {
|
| 21 |
+
state = "available"
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
# Get current AWS caller identity
|
| 25 |
+
data "aws_caller_identity" "current" {}
|
| 26 |
+
|
| 27 |
+
# Get current AWS region
|
| 28 |
+
data "aws_region" "current" {}
|
projects/ui/serena-new/test/resources/repos/terraform/test_repo/main.tf
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Main Terraform configuration
|
| 2 |
+
terraform {
|
| 3 |
+
required_version = ">= 1.0"
|
| 4 |
+
required_providers {
|
| 5 |
+
aws = {
|
| 6 |
+
source = "hashicorp/aws"
|
| 7 |
+
version = "~> 5.0"
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
}
|
| 11 |
+
|
| 12 |
+
provider "aws" {
|
| 13 |
+
region = var.aws_region
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
# EC2 Instance
|
| 17 |
+
resource "aws_instance" "web_server" {
|
| 18 |
+
ami = data.aws_ami.ubuntu.id
|
| 19 |
+
instance_type = var.instance_type
|
| 20 |
+
|
| 21 |
+
vpc_security_group_ids = [aws_security_group.web_sg.id]
|
| 22 |
+
subnet_id = aws_subnet.public.id
|
| 23 |
+
|
| 24 |
+
user_data = <<-EOF
|
| 25 |
+
#!/bin/bash
|
| 26 |
+
apt-get update
|
| 27 |
+
apt-get install -y nginx
|
| 28 |
+
systemctl start nginx
|
| 29 |
+
systemctl enable nginx
|
| 30 |
+
EOF
|
| 31 |
+
|
| 32 |
+
tags = {
|
| 33 |
+
Name = "${var.project_name}-web-server"
|
| 34 |
+
Environment = var.environment
|
| 35 |
+
Project = var.project_name
|
| 36 |
+
}
|
| 37 |
+
}
|
| 38 |
+
|
| 39 |
+
# S3 Bucket
|
| 40 |
+
resource "aws_s3_bucket" "app_bucket" {
|
| 41 |
+
bucket = "${var.project_name}-${var.environment}-bucket"
|
| 42 |
+
|
| 43 |
+
tags = {
|
| 44 |
+
Name = "${var.project_name}-bucket"
|
| 45 |
+
Environment = var.environment
|
| 46 |
+
Project = var.project_name
|
| 47 |
+
}
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
resource "aws_s3_bucket_versioning" "app_bucket_versioning" {
|
| 51 |
+
bucket = aws_s3_bucket.app_bucket.id
|
| 52 |
+
versioning_configuration {
|
| 53 |
+
status = "Enabled"
|
| 54 |
+
}
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
# VPC
|
| 58 |
+
resource "aws_vpc" "main" {
|
| 59 |
+
cidr_block = "10.0.0.0/16"
|
| 60 |
+
enable_dns_hostnames = true
|
| 61 |
+
enable_dns_support = true
|
| 62 |
+
|
| 63 |
+
tags = {
|
| 64 |
+
Name = "${var.project_name}-vpc"
|
| 65 |
+
Environment = var.environment
|
| 66 |
+
Project = var.project_name
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
|
| 70 |
+
# Internet Gateway
|
| 71 |
+
resource "aws_internet_gateway" "main" {
|
| 72 |
+
vpc_id = aws_vpc.main.id
|
| 73 |
+
|
| 74 |
+
tags = {
|
| 75 |
+
Name = "${var.project_name}-igw"
|
| 76 |
+
Environment = var.environment
|
| 77 |
+
Project = var.project_name
|
| 78 |
+
}
|
| 79 |
+
}
|
| 80 |
+
|
| 81 |
+
# Public Subnet
|
| 82 |
+
resource "aws_subnet" "public" {
|
| 83 |
+
vpc_id = aws_vpc.main.id
|
| 84 |
+
cidr_block = "10.0.1.0/24"
|
| 85 |
+
availability_zone = data.aws_availability_zones.available.names[0]
|
| 86 |
+
map_public_ip_on_launch = true
|
| 87 |
+
|
| 88 |
+
tags = {
|
| 89 |
+
Name = "${var.project_name}-public-subnet"
|
| 90 |
+
Environment = var.environment
|
| 91 |
+
Project = var.project_name
|
| 92 |
+
}
|
| 93 |
+
}
|
| 94 |
+
|
| 95 |
+
# Security Group
|
| 96 |
+
resource "aws_security_group" "web_sg" {
|
| 97 |
+
name_prefix = "${var.project_name}-web-"
|
| 98 |
+
vpc_id = aws_vpc.main.id
|
| 99 |
+
|
| 100 |
+
ingress {
|
| 101 |
+
from_port = 80
|
| 102 |
+
to_port = 80
|
| 103 |
+
protocol = "tcp"
|
| 104 |
+
cidr_blocks = ["0.0.0.0/0"]
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
ingress {
|
| 108 |
+
from_port = 443
|
| 109 |
+
to_port = 443
|
| 110 |
+
protocol = "tcp"
|
| 111 |
+
cidr_blocks = ["0.0.0.0/0"]
|
| 112 |
+
}
|
| 113 |
+
|
| 114 |
+
egress {
|
| 115 |
+
from_port = 0
|
| 116 |
+
to_port = 0
|
| 117 |
+
protocol = "-1"
|
| 118 |
+
cidr_blocks = ["0.0.0.0/0"]
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
tags = {
|
| 122 |
+
Name = "${var.project_name}-web-sg"
|
| 123 |
+
Environment = var.environment
|
| 124 |
+
Project = var.project_name
|
| 125 |
+
}
|
| 126 |
+
}
|
projects/ui/serena-new/test/resources/repos/terraform/test_repo/outputs.tf
ADDED
|
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Output values for the Terraform configuration
|
| 2 |
+
|
| 3 |
+
output "instance_id" {
|
| 4 |
+
description = "ID of the EC2 instance"
|
| 5 |
+
value = aws_instance.web_server.id
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
output "instance_public_ip" {
|
| 9 |
+
description = "Public IP address of the EC2 instance"
|
| 10 |
+
value = aws_instance.web_server.public_ip
|
| 11 |
+
}
|
| 12 |
+
|
| 13 |
+
output "instance_public_dns" {
|
| 14 |
+
description = "Public DNS name of the EC2 instance"
|
| 15 |
+
value = aws_instance.web_server.public_dns
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
output "s3_bucket_name" {
|
| 19 |
+
description = "Name of the S3 bucket"
|
| 20 |
+
value = aws_s3_bucket.app_bucket.bucket
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
output "s3_bucket_arn" {
|
| 24 |
+
description = "ARN of the S3 bucket"
|
| 25 |
+
value = aws_s3_bucket.app_bucket.arn
|
| 26 |
+
}
|
| 27 |
+
|
| 28 |
+
output "vpc_id" {
|
| 29 |
+
description = "ID of the VPC"
|
| 30 |
+
value = aws_vpc.main.id
|
| 31 |
+
}
|
| 32 |
+
|
| 33 |
+
output "subnet_id" {
|
| 34 |
+
description = "ID of the public subnet"
|
| 35 |
+
value = aws_subnet.public.id
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
output "security_group_id" {
|
| 39 |
+
description = "ID of the security group"
|
| 40 |
+
value = aws_security_group.web_sg.id
|
| 41 |
+
}
|
| 42 |
+
|
| 43 |
+
output "application_url" {
|
| 44 |
+
description = "URL to access the application"
|
| 45 |
+
value = "http://${aws_instance.web_server.public_dns}"
|
| 46 |
+
}
|
projects/ui/serena-new/test/resources/repos/terraform/test_repo/variables.tf
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Input variables for the Terraform configuration
|
| 2 |
+
|
| 3 |
+
variable "aws_region" {
|
| 4 |
+
description = "AWS region for resources"
|
| 5 |
+
type = string
|
| 6 |
+
default = "us-west-2"
|
| 7 |
+
}
|
| 8 |
+
|
| 9 |
+
variable "instance_type" {
|
| 10 |
+
description = "EC2 instance type"
|
| 11 |
+
type = string
|
| 12 |
+
default = "t3.micro"
|
| 13 |
+
|
| 14 |
+
validation {
|
| 15 |
+
condition = contains([
|
| 16 |
+
"t3.micro", "t3.small", "t3.medium",
|
| 17 |
+
"t2.micro", "t2.small", "t2.medium"
|
| 18 |
+
], var.instance_type)
|
| 19 |
+
error_message = "Instance type must be a valid t2 or t3 instance type."
|
| 20 |
+
}
|
| 21 |
+
}
|
| 22 |
+
|
| 23 |
+
variable "environment" {
|
| 24 |
+
description = "Environment name (dev, staging, prod)"
|
| 25 |
+
type = string
|
| 26 |
+
default = "dev"
|
| 27 |
+
|
| 28 |
+
validation {
|
| 29 |
+
condition = contains(["dev", "staging", "prod"], var.environment)
|
| 30 |
+
error_message = "Environment must be dev, staging, or prod."
|
| 31 |
+
}
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
variable "project_name" {
|
| 35 |
+
description = "Name of the project"
|
| 36 |
+
type = string
|
| 37 |
+
default = "terraform-test"
|
| 38 |
+
|
| 39 |
+
validation {
|
| 40 |
+
condition = can(regex("^[a-z0-9-]+$", var.project_name))
|
| 41 |
+
error_message = "Project name must contain only lowercase letters, numbers, and hyphens."
|
| 42 |
+
}
|
| 43 |
+
}
|
| 44 |
+
|
| 45 |
+
variable "enable_monitoring" {
|
| 46 |
+
description = "Enable CloudWatch monitoring"
|
| 47 |
+
type = bool
|
| 48 |
+
default = false
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
variable "allowed_cidr_blocks" {
|
| 52 |
+
description = "List of CIDR blocks allowed to access the application"
|
| 53 |
+
type = list(string)
|
| 54 |
+
default = ["0.0.0.0/0"]
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
variable "tags" {
|
| 58 |
+
description = "Additional tags to apply to resources"
|
| 59 |
+
type = map(string)
|
| 60 |
+
default = {}
|
| 61 |
+
}
|
projects/ui/serena-new/test/resources/repos/typescript/test_repo/.serena/project.yml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
excluded_tools: []
|
| 2 |
+
ignore_all_files_in_gitignore: true
|
| 3 |
+
ignored_paths: []
|
| 4 |
+
initial_prompt: ''
|
| 5 |
+
language: typescript
|
| 6 |
+
project_name: test_repo
|
| 7 |
+
read_only: false
|
projects/ui/serena-new/test/resources/repos/typescript/test_repo/index.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
export class DemoClass {
|
| 2 |
+
value: number;
|
| 3 |
+
constructor(value: number) {
|
| 4 |
+
this.value = value;
|
| 5 |
+
}
|
| 6 |
+
printValue() {
|
| 7 |
+
console.log(this.value);
|
| 8 |
+
}
|
| 9 |
+
}
|
| 10 |
+
|
| 11 |
+
export function helperFunction() {
|
| 12 |
+
const demo = new DemoClass(42);
|
| 13 |
+
demo.printValue();
|
| 14 |
+
}
|
| 15 |
+
|
| 16 |
+
helperFunction();
|
projects/ui/serena-new/test/resources/repos/typescript/test_repo/tsconfig.json
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"compilerOptions": {
|
| 3 |
+
"target": "ES2017",
|
| 4 |
+
"module": "commonjs",
|
| 5 |
+
"strict": true,
|
| 6 |
+
"esModuleInterop": true,
|
| 7 |
+
"forceConsistentCasingInFileNames": true,
|
| 8 |
+
"skipLibCheck": true
|
| 9 |
+
},
|
| 10 |
+
"include": ["**/*.ts"]
|
| 11 |
+
}
|
projects/ui/serena-new/test/resources/repos/typescript/test_repo/use_helper.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import {helperFunction} from "./index";
|
| 2 |
+
|
| 3 |
+
|
| 4 |
+
export function useHelper() {
|
| 5 |
+
helperFunction();
|
| 6 |
+
}
|
| 7 |
+
|
| 8 |
+
useHelper();
|
projects/ui/serena-new/test/resources/repos/zig/test_repo/.gitignore
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
zig-cache/
|
| 2 |
+
zig-out/
|
| 3 |
+
.zig-cache/
|
| 4 |
+
build/
|
| 5 |
+
dist/
|
projects/ui/serena-new/test/resources/repos/zig/test_repo/build.zig
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const std = @import("std");
|
| 2 |
+
|
| 3 |
+
pub fn build(b: *std.Build) void {
|
| 4 |
+
const target = b.standardTargetOptions(.{});
|
| 5 |
+
const optimize = b.standardOptimizeOption(.{});
|
| 6 |
+
|
| 7 |
+
const exe = b.addExecutable(.{
|
| 8 |
+
.name = "test_repo",
|
| 9 |
+
.root_source_file = b.path("src/main.zig"),
|
| 10 |
+
.target = target,
|
| 11 |
+
.optimize = optimize,
|
| 12 |
+
});
|
| 13 |
+
|
| 14 |
+
b.installArtifact(exe);
|
| 15 |
+
|
| 16 |
+
const run_cmd = b.addRunArtifact(exe);
|
| 17 |
+
run_cmd.step.dependOn(b.getInstallStep());
|
| 18 |
+
|
| 19 |
+
const run_step = b.step("run", "Run the app");
|
| 20 |
+
run_step.dependOn(&run_cmd.step);
|
| 21 |
+
|
| 22 |
+
const lib_tests = b.addTest(.{
|
| 23 |
+
.root_source_file = b.path("src/calculator.zig"),
|
| 24 |
+
.target = target,
|
| 25 |
+
.optimize = optimize,
|
| 26 |
+
});
|
| 27 |
+
|
| 28 |
+
const run_lib_tests = b.addRunArtifact(lib_tests);
|
| 29 |
+
const test_step = b.step("test", "Run unit tests");
|
| 30 |
+
test_step.dependOn(&run_lib_tests.step);
|
| 31 |
+
}
|
projects/ui/serena-new/test/resources/repos/zig/test_repo/src/calculator.zig
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const std = @import("std");
|
| 2 |
+
|
| 3 |
+
pub const CalculatorError = error{
|
| 4 |
+
DivisionByZero,
|
| 5 |
+
Overflow,
|
| 6 |
+
};
|
| 7 |
+
|
| 8 |
+
pub const Calculator = struct {
|
| 9 |
+
const Self = @This();
|
| 10 |
+
|
| 11 |
+
pub fn init() Self {
|
| 12 |
+
return .{};
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
pub fn add(self: Self, a: i32, b: i32) i32 {
|
| 16 |
+
_ = self;
|
| 17 |
+
return a + b;
|
| 18 |
+
}
|
| 19 |
+
|
| 20 |
+
pub fn subtract(self: Self, a: i32, b: i32) i32 {
|
| 21 |
+
_ = self;
|
| 22 |
+
return a - b;
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
pub fn multiply(self: Self, a: i32, b: i32) i32 {
|
| 26 |
+
_ = self;
|
| 27 |
+
return a * b;
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
pub fn divide(self: Self, a: i32, b: i32) !f64 {
|
| 31 |
+
_ = self;
|
| 32 |
+
if (b == 0) {
|
| 33 |
+
return CalculatorError.DivisionByZero;
|
| 34 |
+
}
|
| 35 |
+
return @as(f64, @floatFromInt(a)) / @as(f64, @floatFromInt(b));
|
| 36 |
+
}
|
| 37 |
+
|
| 38 |
+
pub fn power(self: Self, base: i32, exponent: u32) i64 {
|
| 39 |
+
_ = self;
|
| 40 |
+
return std.math.pow(i64, base, exponent);
|
| 41 |
+
}
|
| 42 |
+
};
|
| 43 |
+
|
| 44 |
+
test "Calculator add" {
|
| 45 |
+
const calc = Calculator.init();
|
| 46 |
+
try std.testing.expectEqual(@as(i32, 7), calc.add(3, 4));
|
| 47 |
+
try std.testing.expectEqual(@as(i32, 0), calc.add(-5, 5));
|
| 48 |
+
}
|
| 49 |
+
|
| 50 |
+
test "Calculator subtract" {
|
| 51 |
+
const calc = Calculator.init();
|
| 52 |
+
try std.testing.expectEqual(@as(i32, -1), calc.subtract(3, 4));
|
| 53 |
+
try std.testing.expectEqual(@as(i32, 10), calc.subtract(15, 5));
|
| 54 |
+
}
|
| 55 |
+
|
| 56 |
+
test "Calculator multiply" {
|
| 57 |
+
const calc = Calculator.init();
|
| 58 |
+
try std.testing.expectEqual(@as(i32, 12), calc.multiply(3, 4));
|
| 59 |
+
try std.testing.expectEqual(@as(i32, -25), calc.multiply(-5, 5));
|
| 60 |
+
}
|
| 61 |
+
|
| 62 |
+
test "Calculator divide" {
|
| 63 |
+
const calc = Calculator.init();
|
| 64 |
+
try std.testing.expectEqual(@as(f64, 2.0), try calc.divide(10, 5));
|
| 65 |
+
try std.testing.expectError(CalculatorError.DivisionByZero, calc.divide(10, 0));
|
| 66 |
+
}
|
projects/ui/serena-new/test/resources/repos/zig/test_repo/src/main.zig
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const std = @import("std");
|
| 2 |
+
const calculator = @import("calculator.zig");
|
| 3 |
+
const math_utils = @import("math_utils.zig");
|
| 4 |
+
|
| 5 |
+
pub fn main() !void {
|
| 6 |
+
const stdout = std.io.getStdOut().writer();
|
| 7 |
+
|
| 8 |
+
const calc = calculator.Calculator.init();
|
| 9 |
+
|
| 10 |
+
const sum = calc.add(10, 5);
|
| 11 |
+
const diff = calc.subtract(10, 5);
|
| 12 |
+
const prod = calc.multiply(10, 5);
|
| 13 |
+
const quot = calc.divide(10, 5) catch |err| {
|
| 14 |
+
try stdout.print("Division error: {}\n", .{err});
|
| 15 |
+
return;
|
| 16 |
+
};
|
| 17 |
+
|
| 18 |
+
try stdout.print("10 + 5 = {}\n", .{sum});
|
| 19 |
+
try stdout.print("10 - 5 = {}\n", .{diff});
|
| 20 |
+
try stdout.print("10 * 5 = {}\n", .{prod});
|
| 21 |
+
try stdout.print("10 / 5 = {}\n", .{quot});
|
| 22 |
+
|
| 23 |
+
const factorial_result = math_utils.factorial(5);
|
| 24 |
+
try stdout.print("5! = {}\n", .{factorial_result});
|
| 25 |
+
|
| 26 |
+
const is_prime = math_utils.isPrime(17);
|
| 27 |
+
try stdout.print("Is 17 prime? {}\n", .{is_prime});
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
pub fn greeting(name: []const u8) []const u8 {
|
| 31 |
+
return std.fmt.allocPrint(std.heap.page_allocator, "Hello, {s}!", .{name}) catch "Hello!";
|
| 32 |
+
}
|
projects/ui/serena-new/test/resources/repos/zig/test_repo/src/math_utils.zig
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
const std = @import("std");
|
| 2 |
+
|
| 3 |
+
pub fn factorial(n: u32) u64 {
|
| 4 |
+
if (n == 0 or n == 1) {
|
| 5 |
+
return 1;
|
| 6 |
+
}
|
| 7 |
+
var result: u64 = 1;
|
| 8 |
+
var i: u32 = 2;
|
| 9 |
+
while (i <= n) : (i += 1) {
|
| 10 |
+
result *= i;
|
| 11 |
+
}
|
| 12 |
+
return result;
|
| 13 |
+
}
|
| 14 |
+
|
| 15 |
+
pub fn isPrime(n: u32) bool {
|
| 16 |
+
if (n <= 1) return false;
|
| 17 |
+
if (n <= 3) return true;
|
| 18 |
+
if (n % 2 == 0 or n % 3 == 0) return false;
|
| 19 |
+
|
| 20 |
+
var i: u32 = 5;
|
| 21 |
+
while (i * i <= n) : (i += 6) {
|
| 22 |
+
if (n % i == 0 or n % (i + 2) == 0) {
|
| 23 |
+
return false;
|
| 24 |
+
}
|
| 25 |
+
}
|
| 26 |
+
return true;
|
| 27 |
+
}
|
| 28 |
+
|
| 29 |
+
pub fn gcd(a: u32, b: u32) u32 {
|
| 30 |
+
var x = a;
|
| 31 |
+
var y = b;
|
| 32 |
+
while (y != 0) {
|
| 33 |
+
const temp = y;
|
| 34 |
+
y = x % y;
|
| 35 |
+
x = temp;
|
| 36 |
+
}
|
| 37 |
+
return x;
|
| 38 |
+
}
|
| 39 |
+
|
| 40 |
+
pub fn lcm(a: u32, b: u32) u32 {
|
| 41 |
+
return (a * b) / gcd(a, b);
|
| 42 |
+
}
|
| 43 |
+
|
| 44 |
+
test "factorial" {
|
| 45 |
+
try std.testing.expectEqual(@as(u64, 1), factorial(0));
|
| 46 |
+
try std.testing.expectEqual(@as(u64, 1), factorial(1));
|
| 47 |
+
try std.testing.expectEqual(@as(u64, 120), factorial(5));
|
| 48 |
+
try std.testing.expectEqual(@as(u64, 3628800), factorial(10));
|
| 49 |
+
}
|
| 50 |
+
|
| 51 |
+
test "isPrime" {
|
| 52 |
+
try std.testing.expect(!isPrime(0));
|
| 53 |
+
try std.testing.expect(!isPrime(1));
|
| 54 |
+
try std.testing.expect(isPrime(2));
|
| 55 |
+
try std.testing.expect(isPrime(3));
|
| 56 |
+
try std.testing.expect(!isPrime(4));
|
| 57 |
+
try std.testing.expect(isPrime(17));
|
| 58 |
+
try std.testing.expect(!isPrime(100));
|
| 59 |
+
}
|
| 60 |
+
|
| 61 |
+
test "gcd and lcm" {
|
| 62 |
+
try std.testing.expectEqual(@as(u32, 6), gcd(12, 18));
|
| 63 |
+
try std.testing.expectEqual(@as(u32, 1), gcd(17, 19));
|
| 64 |
+
try std.testing.expectEqual(@as(u32, 36), lcm(12, 18));
|
| 65 |
+
}
|
projects/ui/serena-new/test/resources/repos/zig/test_repo/zls.json
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"enable_build_on_save": true,
|
| 3 |
+
"build_on_save_args": ["build"],
|
| 4 |
+
"enable_autofix": false,
|
| 5 |
+
"semantic_tokens": "full",
|
| 6 |
+
"enable_inlay_hints": true,
|
| 7 |
+
"inlay_hints_show_builtin": true,
|
| 8 |
+
"inlay_hints_exclude_single_argument": true,
|
| 9 |
+
"inlay_hints_show_parameter_name": true,
|
| 10 |
+
"skip_std_references": false,
|
| 11 |
+
"max_detail_length": 1048576
|
| 12 |
+
}
|
projects/ui/serena-new/test/serena/__snapshots__/test_symbol_editing.ambr
ADDED
|
@@ -0,0 +1,1108 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# serializer version: 1
|
| 2 |
+
# name: test_delete_symbol[test_case0]
|
| 3 |
+
'''
|
| 4 |
+
"""
|
| 5 |
+
Test module for variable declarations and usage.
|
| 6 |
+
|
| 7 |
+
This module tests various types of variable declarations and usages including:
|
| 8 |
+
- Module-level variables
|
| 9 |
+
- Class-level variables
|
| 10 |
+
- Instance variables
|
| 11 |
+
- Variable reassignments
|
| 12 |
+
"""
|
| 13 |
+
|
| 14 |
+
from dataclasses import dataclass, field
|
| 15 |
+
|
| 16 |
+
# Module-level variables
|
| 17 |
+
module_var = "Initial module value"
|
| 18 |
+
|
| 19 |
+
reassignable_module_var = 10
|
| 20 |
+
reassignable_module_var = 20 # Reassigned
|
| 21 |
+
|
| 22 |
+
# Module-level variable with type annotation
|
| 23 |
+
typed_module_var: int = 42
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
# Regular class with class and instance variables
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
|
| 30 |
+
# Dataclass with variables
|
| 31 |
+
@dataclass
|
| 32 |
+
class VariableDataclass:
|
| 33 |
+
"""Dataclass that contains various fields."""
|
| 34 |
+
|
| 35 |
+
# Field variables with type annotations
|
| 36 |
+
id: int
|
| 37 |
+
name: str
|
| 38 |
+
items: list[str] = field(default_factory=list)
|
| 39 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 40 |
+
optional_value: float | None = None
|
| 41 |
+
|
| 42 |
+
# This will be reassigned in various places
|
| 43 |
+
status: str = "pending"
|
| 44 |
+
|
| 45 |
+
|
| 46 |
+
# Function that uses the module variables
|
| 47 |
+
def use_module_variables():
|
| 48 |
+
"""Function that uses module-level variables."""
|
| 49 |
+
result = module_var + " used in function"
|
| 50 |
+
other_result = reassignable_module_var * 2
|
| 51 |
+
return result, other_result
|
| 52 |
+
|
| 53 |
+
|
| 54 |
+
# Create instances and use variables
|
| 55 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 56 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 57 |
+
|
| 58 |
+
# Use variables at module level
|
| 59 |
+
module_result = module_var + " used at module level"
|
| 60 |
+
other_module_result = reassignable_module_var + 30
|
| 61 |
+
|
| 62 |
+
# Create a second dataclass instance with different status
|
| 63 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 64 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 65 |
+
|
| 66 |
+
'''
|
| 67 |
+
# ---
|
| 68 |
+
# name: test_delete_symbol[test_case1]
|
| 69 |
+
'''
|
| 70 |
+
|
| 71 |
+
|
| 72 |
+
export function helperFunction() {
|
| 73 |
+
const demo = new DemoClass(42);
|
| 74 |
+
demo.printValue();
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
helperFunction();
|
| 78 |
+
|
| 79 |
+
'''
|
| 80 |
+
# ---
|
| 81 |
+
# name: test_insert_in_rel_to_symbol[test_case0-after]
|
| 82 |
+
'''
|
| 83 |
+
"""
|
| 84 |
+
Test module for variable declarations and usage.
|
| 85 |
+
|
| 86 |
+
This module tests various types of variable declarations and usages including:
|
| 87 |
+
- Module-level variables
|
| 88 |
+
- Class-level variables
|
| 89 |
+
- Instance variables
|
| 90 |
+
- Variable reassignments
|
| 91 |
+
"""
|
| 92 |
+
|
| 93 |
+
from dataclasses import dataclass, field
|
| 94 |
+
|
| 95 |
+
# Module-level variables
|
| 96 |
+
module_var = "Initial module value"
|
| 97 |
+
|
| 98 |
+
reassignable_module_var = 10
|
| 99 |
+
reassignable_module_var = 20 # Reassigned
|
| 100 |
+
|
| 101 |
+
# Module-level variable with type annotation
|
| 102 |
+
typed_module_var: int = 42
|
| 103 |
+
new_module_var = "Inserted after typed_module_var"
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
# Regular class with class and instance variables
|
| 107 |
+
class VariableContainer:
|
| 108 |
+
"""Class that contains various variables."""
|
| 109 |
+
|
| 110 |
+
# Class-level variables
|
| 111 |
+
class_var = "Initial class value"
|
| 112 |
+
|
| 113 |
+
reassignable_class_var = True
|
| 114 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 115 |
+
|
| 116 |
+
# Class-level variable with type annotation
|
| 117 |
+
typed_class_var: str = "typed value"
|
| 118 |
+
|
| 119 |
+
def __init__(self):
|
| 120 |
+
# Instance variables
|
| 121 |
+
self.instance_var = "Initial instance value"
|
| 122 |
+
self.reassignable_instance_var = 100
|
| 123 |
+
|
| 124 |
+
# Instance variable with type annotation
|
| 125 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 126 |
+
|
| 127 |
+
def modify_instance_var(self):
|
| 128 |
+
# Reassign instance variable
|
| 129 |
+
self.instance_var = "Modified instance value"
|
| 130 |
+
self.reassignable_instance_var = 200 # Reassigned
|
| 131 |
+
|
| 132 |
+
def use_module_var(self):
|
| 133 |
+
# Use module-level variables
|
| 134 |
+
result = module_var + " used in method"
|
| 135 |
+
other_result = reassignable_module_var + 5
|
| 136 |
+
return result, other_result
|
| 137 |
+
|
| 138 |
+
def use_class_var(self):
|
| 139 |
+
# Use class-level variables
|
| 140 |
+
result = VariableContainer.class_var + " used in method"
|
| 141 |
+
other_result = VariableContainer.reassignable_class_var
|
| 142 |
+
return result, other_result
|
| 143 |
+
|
| 144 |
+
|
| 145 |
+
# Dataclass with variables
|
| 146 |
+
@dataclass
|
| 147 |
+
class VariableDataclass:
|
| 148 |
+
"""Dataclass that contains various fields."""
|
| 149 |
+
|
| 150 |
+
# Field variables with type annotations
|
| 151 |
+
id: int
|
| 152 |
+
name: str
|
| 153 |
+
items: list[str] = field(default_factory=list)
|
| 154 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 155 |
+
optional_value: float | None = None
|
| 156 |
+
|
| 157 |
+
# This will be reassigned in various places
|
| 158 |
+
status: str = "pending"
|
| 159 |
+
|
| 160 |
+
|
| 161 |
+
# Function that uses the module variables
|
| 162 |
+
def use_module_variables():
|
| 163 |
+
"""Function that uses module-level variables."""
|
| 164 |
+
result = module_var + " used in function"
|
| 165 |
+
other_result = reassignable_module_var * 2
|
| 166 |
+
return result, other_result
|
| 167 |
+
|
| 168 |
+
|
| 169 |
+
# Create instances and use variables
|
| 170 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 171 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 172 |
+
|
| 173 |
+
# Use variables at module level
|
| 174 |
+
module_result = module_var + " used at module level"
|
| 175 |
+
other_module_result = reassignable_module_var + 30
|
| 176 |
+
|
| 177 |
+
# Create a second dataclass instance with different status
|
| 178 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 179 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 180 |
+
|
| 181 |
+
'''
|
| 182 |
+
# ---
|
| 183 |
+
# name: test_insert_in_rel_to_symbol[test_case0-before]
|
| 184 |
+
'''
|
| 185 |
+
"""
|
| 186 |
+
Test module for variable declarations and usage.
|
| 187 |
+
|
| 188 |
+
This module tests various types of variable declarations and usages including:
|
| 189 |
+
- Module-level variables
|
| 190 |
+
- Class-level variables
|
| 191 |
+
- Instance variables
|
| 192 |
+
- Variable reassignments
|
| 193 |
+
"""
|
| 194 |
+
|
| 195 |
+
from dataclasses import dataclass, field
|
| 196 |
+
|
| 197 |
+
# Module-level variables
|
| 198 |
+
module_var = "Initial module value"
|
| 199 |
+
|
| 200 |
+
reassignable_module_var = 10
|
| 201 |
+
reassignable_module_var = 20 # Reassigned
|
| 202 |
+
|
| 203 |
+
# Module-level variable with type annotation
|
| 204 |
+
new_module_var = "Inserted after typed_module_var"
|
| 205 |
+
typed_module_var: int = 42
|
| 206 |
+
|
| 207 |
+
|
| 208 |
+
# Regular class with class and instance variables
|
| 209 |
+
class VariableContainer:
|
| 210 |
+
"""Class that contains various variables."""
|
| 211 |
+
|
| 212 |
+
# Class-level variables
|
| 213 |
+
class_var = "Initial class value"
|
| 214 |
+
|
| 215 |
+
reassignable_class_var = True
|
| 216 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 217 |
+
|
| 218 |
+
# Class-level variable with type annotation
|
| 219 |
+
typed_class_var: str = "typed value"
|
| 220 |
+
|
| 221 |
+
def __init__(self):
|
| 222 |
+
# Instance variables
|
| 223 |
+
self.instance_var = "Initial instance value"
|
| 224 |
+
self.reassignable_instance_var = 100
|
| 225 |
+
|
| 226 |
+
# Instance variable with type annotation
|
| 227 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 228 |
+
|
| 229 |
+
def modify_instance_var(self):
|
| 230 |
+
# Reassign instance variable
|
| 231 |
+
self.instance_var = "Modified instance value"
|
| 232 |
+
self.reassignable_instance_var = 200 # Reassigned
|
| 233 |
+
|
| 234 |
+
def use_module_var(self):
|
| 235 |
+
# Use module-level variables
|
| 236 |
+
result = module_var + " used in method"
|
| 237 |
+
other_result = reassignable_module_var + 5
|
| 238 |
+
return result, other_result
|
| 239 |
+
|
| 240 |
+
def use_class_var(self):
|
| 241 |
+
# Use class-level variables
|
| 242 |
+
result = VariableContainer.class_var + " used in method"
|
| 243 |
+
other_result = VariableContainer.reassignable_class_var
|
| 244 |
+
return result, other_result
|
| 245 |
+
|
| 246 |
+
|
| 247 |
+
# Dataclass with variables
|
| 248 |
+
@dataclass
|
| 249 |
+
class VariableDataclass:
|
| 250 |
+
"""Dataclass that contains various fields."""
|
| 251 |
+
|
| 252 |
+
# Field variables with type annotations
|
| 253 |
+
id: int
|
| 254 |
+
name: str
|
| 255 |
+
items: list[str] = field(default_factory=list)
|
| 256 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 257 |
+
optional_value: float | None = None
|
| 258 |
+
|
| 259 |
+
# This will be reassigned in various places
|
| 260 |
+
status: str = "pending"
|
| 261 |
+
|
| 262 |
+
|
| 263 |
+
# Function that uses the module variables
|
| 264 |
+
def use_module_variables():
|
| 265 |
+
"""Function that uses module-level variables."""
|
| 266 |
+
result = module_var + " used in function"
|
| 267 |
+
other_result = reassignable_module_var * 2
|
| 268 |
+
return result, other_result
|
| 269 |
+
|
| 270 |
+
|
| 271 |
+
# Create instances and use variables
|
| 272 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 273 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 274 |
+
|
| 275 |
+
# Use variables at module level
|
| 276 |
+
module_result = module_var + " used at module level"
|
| 277 |
+
other_module_result = reassignable_module_var + 30
|
| 278 |
+
|
| 279 |
+
# Create a second dataclass instance with different status
|
| 280 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 281 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 282 |
+
|
| 283 |
+
'''
|
| 284 |
+
# ---
|
| 285 |
+
# name: test_insert_in_rel_to_symbol[test_case1-after]
|
| 286 |
+
'''
|
| 287 |
+
"""
|
| 288 |
+
Test module for variable declarations and usage.
|
| 289 |
+
|
| 290 |
+
This module tests various types of variable declarations and usages including:
|
| 291 |
+
- Module-level variables
|
| 292 |
+
- Class-level variables
|
| 293 |
+
- Instance variables
|
| 294 |
+
- Variable reassignments
|
| 295 |
+
"""
|
| 296 |
+
|
| 297 |
+
from dataclasses import dataclass, field
|
| 298 |
+
|
| 299 |
+
# Module-level variables
|
| 300 |
+
module_var = "Initial module value"
|
| 301 |
+
|
| 302 |
+
reassignable_module_var = 10
|
| 303 |
+
reassignable_module_var = 20 # Reassigned
|
| 304 |
+
|
| 305 |
+
# Module-level variable with type annotation
|
| 306 |
+
typed_module_var: int = 42
|
| 307 |
+
|
| 308 |
+
|
| 309 |
+
# Regular class with class and instance variables
|
| 310 |
+
class VariableContainer:
|
| 311 |
+
"""Class that contains various variables."""
|
| 312 |
+
|
| 313 |
+
# Class-level variables
|
| 314 |
+
class_var = "Initial class value"
|
| 315 |
+
|
| 316 |
+
reassignable_class_var = True
|
| 317 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 318 |
+
|
| 319 |
+
# Class-level variable with type annotation
|
| 320 |
+
typed_class_var: str = "typed value"
|
| 321 |
+
|
| 322 |
+
def __init__(self):
|
| 323 |
+
# Instance variables
|
| 324 |
+
self.instance_var = "Initial instance value"
|
| 325 |
+
self.reassignable_instance_var = 100
|
| 326 |
+
|
| 327 |
+
# Instance variable with type annotation
|
| 328 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 329 |
+
|
| 330 |
+
def modify_instance_var(self):
|
| 331 |
+
# Reassign instance variable
|
| 332 |
+
self.instance_var = "Modified instance value"
|
| 333 |
+
self.reassignable_instance_var = 200 # Reassigned
|
| 334 |
+
|
| 335 |
+
def use_module_var(self):
|
| 336 |
+
# Use module-level variables
|
| 337 |
+
result = module_var + " used in method"
|
| 338 |
+
other_result = reassignable_module_var + 5
|
| 339 |
+
return result, other_result
|
| 340 |
+
|
| 341 |
+
def use_class_var(self):
|
| 342 |
+
# Use class-level variables
|
| 343 |
+
result = VariableContainer.class_var + " used in method"
|
| 344 |
+
other_result = VariableContainer.reassignable_class_var
|
| 345 |
+
return result, other_result
|
| 346 |
+
|
| 347 |
+
|
| 348 |
+
# Dataclass with variables
|
| 349 |
+
@dataclass
|
| 350 |
+
class VariableDataclass:
|
| 351 |
+
"""Dataclass that contains various fields."""
|
| 352 |
+
|
| 353 |
+
# Field variables with type annotations
|
| 354 |
+
id: int
|
| 355 |
+
name: str
|
| 356 |
+
items: list[str] = field(default_factory=list)
|
| 357 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 358 |
+
optional_value: float | None = None
|
| 359 |
+
|
| 360 |
+
# This will be reassigned in various places
|
| 361 |
+
status: str = "pending"
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
# Function that uses the module variables
|
| 365 |
+
def use_module_variables():
|
| 366 |
+
"""Function that uses module-level variables."""
|
| 367 |
+
result = module_var + " used in function"
|
| 368 |
+
other_result = reassignable_module_var * 2
|
| 369 |
+
return result, other_result
|
| 370 |
+
|
| 371 |
+
def new_inserted_function():
|
| 372 |
+
print("This is a new function inserted before another.")
|
| 373 |
+
|
| 374 |
+
|
| 375 |
+
# Create instances and use variables
|
| 376 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 377 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 378 |
+
|
| 379 |
+
# Use variables at module level
|
| 380 |
+
module_result = module_var + " used at module level"
|
| 381 |
+
other_module_result = reassignable_module_var + 30
|
| 382 |
+
|
| 383 |
+
# Create a second dataclass instance with different status
|
| 384 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 385 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 386 |
+
|
| 387 |
+
'''
|
| 388 |
+
# ---
|
| 389 |
+
# name: test_insert_in_rel_to_symbol[test_case1-before]
|
| 390 |
+
'''
|
| 391 |
+
"""
|
| 392 |
+
Test module for variable declarations and usage.
|
| 393 |
+
|
| 394 |
+
This module tests various types of variable declarations and usages including:
|
| 395 |
+
- Module-level variables
|
| 396 |
+
- Class-level variables
|
| 397 |
+
- Instance variables
|
| 398 |
+
- Variable reassignments
|
| 399 |
+
"""
|
| 400 |
+
|
| 401 |
+
from dataclasses import dataclass, field
|
| 402 |
+
|
| 403 |
+
# Module-level variables
|
| 404 |
+
module_var = "Initial module value"
|
| 405 |
+
|
| 406 |
+
reassignable_module_var = 10
|
| 407 |
+
reassignable_module_var = 20 # Reassigned
|
| 408 |
+
|
| 409 |
+
# Module-level variable with type annotation
|
| 410 |
+
typed_module_var: int = 42
|
| 411 |
+
|
| 412 |
+
|
| 413 |
+
# Regular class with class and instance variables
|
| 414 |
+
class VariableContainer:
|
| 415 |
+
"""Class that contains various variables."""
|
| 416 |
+
|
| 417 |
+
# Class-level variables
|
| 418 |
+
class_var = "Initial class value"
|
| 419 |
+
|
| 420 |
+
reassignable_class_var = True
|
| 421 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 422 |
+
|
| 423 |
+
# Class-level variable with type annotation
|
| 424 |
+
typed_class_var: str = "typed value"
|
| 425 |
+
|
| 426 |
+
def __init__(self):
|
| 427 |
+
# Instance variables
|
| 428 |
+
self.instance_var = "Initial instance value"
|
| 429 |
+
self.reassignable_instance_var = 100
|
| 430 |
+
|
| 431 |
+
# Instance variable with type annotation
|
| 432 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 433 |
+
|
| 434 |
+
def modify_instance_var(self):
|
| 435 |
+
# Reassign instance variable
|
| 436 |
+
self.instance_var = "Modified instance value"
|
| 437 |
+
self.reassignable_instance_var = 200 # Reassigned
|
| 438 |
+
|
| 439 |
+
def use_module_var(self):
|
| 440 |
+
# Use module-level variables
|
| 441 |
+
result = module_var + " used in method"
|
| 442 |
+
other_result = reassignable_module_var + 5
|
| 443 |
+
return result, other_result
|
| 444 |
+
|
| 445 |
+
def use_class_var(self):
|
| 446 |
+
# Use class-level variables
|
| 447 |
+
result = VariableContainer.class_var + " used in method"
|
| 448 |
+
other_result = VariableContainer.reassignable_class_var
|
| 449 |
+
return result, other_result
|
| 450 |
+
|
| 451 |
+
|
| 452 |
+
# Dataclass with variables
|
| 453 |
+
@dataclass
|
| 454 |
+
class VariableDataclass:
|
| 455 |
+
"""Dataclass that contains various fields."""
|
| 456 |
+
|
| 457 |
+
# Field variables with type annotations
|
| 458 |
+
id: int
|
| 459 |
+
name: str
|
| 460 |
+
items: list[str] = field(default_factory=list)
|
| 461 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 462 |
+
optional_value: float | None = None
|
| 463 |
+
|
| 464 |
+
# This will be reassigned in various places
|
| 465 |
+
status: str = "pending"
|
| 466 |
+
|
| 467 |
+
|
| 468 |
+
# Function that uses the module variables
|
| 469 |
+
def new_inserted_function():
|
| 470 |
+
print("This is a new function inserted before another.")
|
| 471 |
+
|
| 472 |
+
def use_module_variables():
|
| 473 |
+
"""Function that uses module-level variables."""
|
| 474 |
+
result = module_var + " used in function"
|
| 475 |
+
other_result = reassignable_module_var * 2
|
| 476 |
+
return result, other_result
|
| 477 |
+
|
| 478 |
+
|
| 479 |
+
# Create instances and use variables
|
| 480 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 481 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 482 |
+
|
| 483 |
+
# Use variables at module level
|
| 484 |
+
module_result = module_var + " used at module level"
|
| 485 |
+
other_module_result = reassignable_module_var + 30
|
| 486 |
+
|
| 487 |
+
# Create a second dataclass instance with different status
|
| 488 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 489 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 490 |
+
|
| 491 |
+
'''
|
| 492 |
+
# ---
|
| 493 |
+
# name: test_insert_in_rel_to_symbol[test_case2-after]
|
| 494 |
+
'''
|
| 495 |
+
export class DemoClass {
|
| 496 |
+
value: number;
|
| 497 |
+
constructor(value: number) {
|
| 498 |
+
this.value = value;
|
| 499 |
+
}
|
| 500 |
+
printValue() {
|
| 501 |
+
console.log(this.value);
|
| 502 |
+
}
|
| 503 |
+
}
|
| 504 |
+
|
| 505 |
+
function newFunctionAfterClass(): void {
|
| 506 |
+
console.log("This function is after DemoClass.");
|
| 507 |
+
}
|
| 508 |
+
|
| 509 |
+
export function helperFunction() {
|
| 510 |
+
const demo = new DemoClass(42);
|
| 511 |
+
demo.printValue();
|
| 512 |
+
}
|
| 513 |
+
|
| 514 |
+
helperFunction();
|
| 515 |
+
|
| 516 |
+
'''
|
| 517 |
+
# ---
|
| 518 |
+
# name: test_insert_in_rel_to_symbol[test_case2-before]
|
| 519 |
+
'''
|
| 520 |
+
function newFunctionAfterClass(): void {
|
| 521 |
+
console.log("This function is after DemoClass.");
|
| 522 |
+
}
|
| 523 |
+
|
| 524 |
+
export class DemoClass {
|
| 525 |
+
value: number;
|
| 526 |
+
constructor(value: number) {
|
| 527 |
+
this.value = value;
|
| 528 |
+
}
|
| 529 |
+
printValue() {
|
| 530 |
+
console.log(this.value);
|
| 531 |
+
}
|
| 532 |
+
}
|
| 533 |
+
|
| 534 |
+
export function helperFunction() {
|
| 535 |
+
const demo = new DemoClass(42);
|
| 536 |
+
demo.printValue();
|
| 537 |
+
}
|
| 538 |
+
|
| 539 |
+
helperFunction();
|
| 540 |
+
|
| 541 |
+
'''
|
| 542 |
+
# ---
|
| 543 |
+
# name: test_insert_in_rel_to_symbol[test_case3-after]
|
| 544 |
+
'''
|
| 545 |
+
export class DemoClass {
|
| 546 |
+
value: number;
|
| 547 |
+
constructor(value: number) {
|
| 548 |
+
this.value = value;
|
| 549 |
+
}
|
| 550 |
+
printValue() {
|
| 551 |
+
console.log(this.value);
|
| 552 |
+
}
|
| 553 |
+
}
|
| 554 |
+
|
| 555 |
+
export function helperFunction() {
|
| 556 |
+
const demo = new DemoClass(42);
|
| 557 |
+
demo.printValue();
|
| 558 |
+
}
|
| 559 |
+
|
| 560 |
+
function newInsertedFunction(): void {
|
| 561 |
+
console.log("This is a new function inserted before another.");
|
| 562 |
+
}
|
| 563 |
+
|
| 564 |
+
helperFunction();
|
| 565 |
+
|
| 566 |
+
'''
|
| 567 |
+
# ---
|
| 568 |
+
# name: test_insert_in_rel_to_symbol[test_case3-before]
|
| 569 |
+
'''
|
| 570 |
+
export class DemoClass {
|
| 571 |
+
value: number;
|
| 572 |
+
constructor(value: number) {
|
| 573 |
+
this.value = value;
|
| 574 |
+
}
|
| 575 |
+
printValue() {
|
| 576 |
+
console.log(this.value);
|
| 577 |
+
}
|
| 578 |
+
}
|
| 579 |
+
|
| 580 |
+
function newInsertedFunction(): void {
|
| 581 |
+
console.log("This is a new function inserted before another.");
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
export function helperFunction() {
|
| 585 |
+
const demo = new DemoClass(42);
|
| 586 |
+
demo.printValue();
|
| 587 |
+
}
|
| 588 |
+
|
| 589 |
+
helperFunction();
|
| 590 |
+
|
| 591 |
+
'''
|
| 592 |
+
# ---
|
| 593 |
+
# name: test_insert_python_class_after
|
| 594 |
+
'''
|
| 595 |
+
"""
|
| 596 |
+
Test module for variable declarations and usage.
|
| 597 |
+
|
| 598 |
+
This module tests various types of variable declarations and usages including:
|
| 599 |
+
- Module-level variables
|
| 600 |
+
- Class-level variables
|
| 601 |
+
- Instance variables
|
| 602 |
+
- Variable reassignments
|
| 603 |
+
"""
|
| 604 |
+
|
| 605 |
+
from dataclasses import dataclass, field
|
| 606 |
+
|
| 607 |
+
# Module-level variables
|
| 608 |
+
module_var = "Initial module value"
|
| 609 |
+
|
| 610 |
+
reassignable_module_var = 10
|
| 611 |
+
reassignable_module_var = 20 # Reassigned
|
| 612 |
+
|
| 613 |
+
# Module-level variable with type annotation
|
| 614 |
+
typed_module_var: int = 42
|
| 615 |
+
|
| 616 |
+
|
| 617 |
+
# Regular class with class and instance variables
|
| 618 |
+
class VariableContainer:
|
| 619 |
+
"""Class that contains various variables."""
|
| 620 |
+
|
| 621 |
+
# Class-level variables
|
| 622 |
+
class_var = "Initial class value"
|
| 623 |
+
|
| 624 |
+
reassignable_class_var = True
|
| 625 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 626 |
+
|
| 627 |
+
# Class-level variable with type annotation
|
| 628 |
+
typed_class_var: str = "typed value"
|
| 629 |
+
|
| 630 |
+
def __init__(self):
|
| 631 |
+
# Instance variables
|
| 632 |
+
self.instance_var = "Initial instance value"
|
| 633 |
+
self.reassignable_instance_var = 100
|
| 634 |
+
|
| 635 |
+
# Instance variable with type annotation
|
| 636 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 637 |
+
|
| 638 |
+
def modify_instance_var(self):
|
| 639 |
+
# Reassign instance variable
|
| 640 |
+
self.instance_var = "Modified instance value"
|
| 641 |
+
self.reassignable_instance_var = 200 # Reassigned
|
| 642 |
+
|
| 643 |
+
def use_module_var(self):
|
| 644 |
+
# Use module-level variables
|
| 645 |
+
result = module_var + " used in method"
|
| 646 |
+
other_result = reassignable_module_var + 5
|
| 647 |
+
return result, other_result
|
| 648 |
+
|
| 649 |
+
def use_class_var(self):
|
| 650 |
+
# Use class-level variables
|
| 651 |
+
result = VariableContainer.class_var + " used in method"
|
| 652 |
+
other_result = VariableContainer.reassignable_class_var
|
| 653 |
+
return result, other_result
|
| 654 |
+
|
| 655 |
+
|
| 656 |
+
# Dataclass with variables
|
| 657 |
+
@dataclass
|
| 658 |
+
class VariableDataclass:
|
| 659 |
+
"""Dataclass that contains various fields."""
|
| 660 |
+
|
| 661 |
+
# Field variables with type annotations
|
| 662 |
+
id: int
|
| 663 |
+
name: str
|
| 664 |
+
items: list[str] = field(default_factory=list)
|
| 665 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 666 |
+
optional_value: float | None = None
|
| 667 |
+
|
| 668 |
+
# This will be reassigned in various places
|
| 669 |
+
status: str = "pending"
|
| 670 |
+
|
| 671 |
+
|
| 672 |
+
class NewInsertedClass:
|
| 673 |
+
pass
|
| 674 |
+
|
| 675 |
+
|
| 676 |
+
# Function that uses the module variables
|
| 677 |
+
def use_module_variables():
|
| 678 |
+
"""Function that uses module-level variables."""
|
| 679 |
+
result = module_var + " used in function"
|
| 680 |
+
other_result = reassignable_module_var * 2
|
| 681 |
+
return result, other_result
|
| 682 |
+
|
| 683 |
+
|
| 684 |
+
# Create instances and use variables
|
| 685 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 686 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 687 |
+
|
| 688 |
+
# Use variables at module level
|
| 689 |
+
module_result = module_var + " used at module level"
|
| 690 |
+
other_module_result = reassignable_module_var + 30
|
| 691 |
+
|
| 692 |
+
# Create a second dataclass instance with different status
|
| 693 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 694 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 695 |
+
|
| 696 |
+
'''
|
| 697 |
+
# ---
|
| 698 |
+
# name: test_insert_python_class_before
|
| 699 |
+
'''
|
| 700 |
+
"""
|
| 701 |
+
Test module for variable declarations and usage.
|
| 702 |
+
|
| 703 |
+
This module tests various types of variable declarations and usages including:
|
| 704 |
+
- Module-level variables
|
| 705 |
+
- Class-level variables
|
| 706 |
+
- Instance variables
|
| 707 |
+
- Variable reassignments
|
| 708 |
+
"""
|
| 709 |
+
|
| 710 |
+
from dataclasses import dataclass, field
|
| 711 |
+
|
| 712 |
+
# Module-level variables
|
| 713 |
+
module_var = "Initial module value"
|
| 714 |
+
|
| 715 |
+
reassignable_module_var = 10
|
| 716 |
+
reassignable_module_var = 20 # Reassigned
|
| 717 |
+
|
| 718 |
+
# Module-level variable with type annotation
|
| 719 |
+
typed_module_var: int = 42
|
| 720 |
+
|
| 721 |
+
|
| 722 |
+
# Regular class with class and instance variables
|
| 723 |
+
class VariableContainer:
|
| 724 |
+
"""Class that contains various variables."""
|
| 725 |
+
|
| 726 |
+
# Class-level variables
|
| 727 |
+
class_var = "Initial class value"
|
| 728 |
+
|
| 729 |
+
reassignable_class_var = True
|
| 730 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 731 |
+
|
| 732 |
+
# Class-level variable with type annotation
|
| 733 |
+
typed_class_var: str = "typed value"
|
| 734 |
+
|
| 735 |
+
def __init__(self):
|
| 736 |
+
# Instance variables
|
| 737 |
+
self.instance_var = "Initial instance value"
|
| 738 |
+
self.reassignable_instance_var = 100
|
| 739 |
+
|
| 740 |
+
# Instance variable with type annotation
|
| 741 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 742 |
+
|
| 743 |
+
def modify_instance_var(self):
|
| 744 |
+
# Reassign instance variable
|
| 745 |
+
self.instance_var = "Modified instance value"
|
| 746 |
+
self.reassignable_instance_var = 200 # Reassigned
|
| 747 |
+
|
| 748 |
+
def use_module_var(self):
|
| 749 |
+
# Use module-level variables
|
| 750 |
+
result = module_var + " used in method"
|
| 751 |
+
other_result = reassignable_module_var + 5
|
| 752 |
+
return result, other_result
|
| 753 |
+
|
| 754 |
+
def use_class_var(self):
|
| 755 |
+
# Use class-level variables
|
| 756 |
+
result = VariableContainer.class_var + " used in method"
|
| 757 |
+
other_result = VariableContainer.reassignable_class_var
|
| 758 |
+
return result, other_result
|
| 759 |
+
|
| 760 |
+
|
| 761 |
+
# Dataclass with variables
|
| 762 |
+
class NewInsertedClass:
|
| 763 |
+
pass
|
| 764 |
+
|
| 765 |
+
|
| 766 |
+
@dataclass
|
| 767 |
+
class VariableDataclass:
|
| 768 |
+
"""Dataclass that contains various fields."""
|
| 769 |
+
|
| 770 |
+
# Field variables with type annotations
|
| 771 |
+
id: int
|
| 772 |
+
name: str
|
| 773 |
+
items: list[str] = field(default_factory=list)
|
| 774 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 775 |
+
optional_value: float | None = None
|
| 776 |
+
|
| 777 |
+
# This will be reassigned in various places
|
| 778 |
+
status: str = "pending"
|
| 779 |
+
|
| 780 |
+
|
| 781 |
+
# Function that uses the module variables
|
| 782 |
+
def use_module_variables():
|
| 783 |
+
"""Function that uses module-level variables."""
|
| 784 |
+
result = module_var + " used in function"
|
| 785 |
+
other_result = reassignable_module_var * 2
|
| 786 |
+
return result, other_result
|
| 787 |
+
|
| 788 |
+
|
| 789 |
+
# Create instances and use variables
|
| 790 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 791 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 792 |
+
|
| 793 |
+
# Use variables at module level
|
| 794 |
+
module_result = module_var + " used at module level"
|
| 795 |
+
other_module_result = reassignable_module_var + 30
|
| 796 |
+
|
| 797 |
+
# Create a second dataclass instance with different status
|
| 798 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 799 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 800 |
+
|
| 801 |
+
'''
|
| 802 |
+
# ---
|
| 803 |
+
# name: test_nix_symbol_replacement_no_double_semicolon
|
| 804 |
+
'''
|
| 805 |
+
# default.nix - Traditional Nix expression for backwards compatibility
|
| 806 |
+
{ pkgs ? import <nixpkgs> { } }:
|
| 807 |
+
|
| 808 |
+
let
|
| 809 |
+
# Import library functions
|
| 810 |
+
lib = pkgs.lib;
|
| 811 |
+
stdenv = pkgs.stdenv;
|
| 812 |
+
|
| 813 |
+
# Import our custom utilities
|
| 814 |
+
utils = import ./lib/utils.nix { inherit lib; };
|
| 815 |
+
|
| 816 |
+
# Custom function to create a greeting
|
| 817 |
+
makeGreeting = name: "Hello, ${name}!";
|
| 818 |
+
|
| 819 |
+
# List manipulation functions (using imported utils)
|
| 820 |
+
listUtils = {
|
| 821 |
+
double = list: map (x: x * 2) list;
|
| 822 |
+
sum = list: lib.foldl' (acc: x: acc + x) 0 list;
|
| 823 |
+
average = list:
|
| 824 |
+
if list == [ ]
|
| 825 |
+
then 0
|
| 826 |
+
else (listUtils.sum list) / (builtins.length list);
|
| 827 |
+
# Use function from imported utils
|
| 828 |
+
unique = utils.lists.unique;
|
| 829 |
+
};
|
| 830 |
+
|
| 831 |
+
# String utilities
|
| 832 |
+
stringUtils = rec {
|
| 833 |
+
capitalize = str:
|
| 834 |
+
let
|
| 835 |
+
first = lib.substring 0 1 str;
|
| 836 |
+
rest = lib.substring 1 (-1) str;
|
| 837 |
+
in
|
| 838 |
+
(lib.toUpper first) + rest;
|
| 839 |
+
|
| 840 |
+
repeat = n: str: lib.concatStrings (lib.genList (_: str) n);
|
| 841 |
+
|
| 842 |
+
padLeft = width: char: str:
|
| 843 |
+
let
|
| 844 |
+
len = lib.stringLength str;
|
| 845 |
+
padding = if len >= width then 0 else width - len;
|
| 846 |
+
in
|
| 847 |
+
(repeat padding char) + str;
|
| 848 |
+
};
|
| 849 |
+
|
| 850 |
+
# Package builder helper
|
| 851 |
+
buildSimplePackage = { name, version, script }:
|
| 852 |
+
stdenv.mkDerivation {
|
| 853 |
+
pname = name;
|
| 854 |
+
inherit version;
|
| 855 |
+
|
| 856 |
+
phases = [ "installPhase" ];
|
| 857 |
+
|
| 858 |
+
installPhase = ''
|
| 859 |
+
mkdir -p $out/bin
|
| 860 |
+
cat > $out/bin/${name} << EOF
|
| 861 |
+
#!/usr/bin/env bash
|
| 862 |
+
${script}
|
| 863 |
+
EOF
|
| 864 |
+
chmod +x $out/bin/${name}
|
| 865 |
+
'';
|
| 866 |
+
};
|
| 867 |
+
|
| 868 |
+
in
|
| 869 |
+
rec {
|
| 870 |
+
# Export utilities
|
| 871 |
+
inherit listUtils stringUtils makeGreeting;
|
| 872 |
+
|
| 873 |
+
# Export imported utilities directly
|
| 874 |
+
inherit (utils) math strings;
|
| 875 |
+
|
| 876 |
+
# Example packages
|
| 877 |
+
hello = buildSimplePackage {
|
| 878 |
+
name = "hello";
|
| 879 |
+
version = "1.0";
|
| 880 |
+
script = ''
|
| 881 |
+
echo "${makeGreeting "World"}"
|
| 882 |
+
'';
|
| 883 |
+
};
|
| 884 |
+
|
| 885 |
+
calculator = buildSimplePackage {
|
| 886 |
+
name = "calculator";
|
| 887 |
+
version = "0.1";
|
| 888 |
+
script = ''
|
| 889 |
+
if [ $# -ne 3 ]; then
|
| 890 |
+
echo "Usage: calculator <num1> <op> <num2>"
|
| 891 |
+
exit 1
|
| 892 |
+
fi
|
| 893 |
+
|
| 894 |
+
case $2 in
|
| 895 |
+
+) echo $(($1 + $3)) ;;
|
| 896 |
+
-) echo $(($1 - $3)) ;;
|
| 897 |
+
x) echo $(($1 * $3)) ;;
|
| 898 |
+
/) echo $(($1 / $3)) ;;
|
| 899 |
+
*) echo "Unknown operator: $2" ;;
|
| 900 |
+
esac
|
| 901 |
+
'';
|
| 902 |
+
};
|
| 903 |
+
|
| 904 |
+
# Environment with multiple packages
|
| 905 |
+
devEnv = pkgs.buildEnv {
|
| 906 |
+
name = "dev-environment";
|
| 907 |
+
paths = with pkgs; [
|
| 908 |
+
git
|
| 909 |
+
vim
|
| 910 |
+
bash
|
| 911 |
+
hello
|
| 912 |
+
calculator
|
| 913 |
+
];
|
| 914 |
+
};
|
| 915 |
+
|
| 916 |
+
# Shell derivation
|
| 917 |
+
shell = pkgs.mkShell {
|
| 918 |
+
buildInputs = with pkgs; [
|
| 919 |
+
bash
|
| 920 |
+
coreutils
|
| 921 |
+
findutils
|
| 922 |
+
gnugrep
|
| 923 |
+
gnused
|
| 924 |
+
];
|
| 925 |
+
|
| 926 |
+
shellHook = ''
|
| 927 |
+
echo "Entering Nix shell environment"
|
| 928 |
+
echo "Available custom functions: makeGreeting, listUtils, stringUtils"
|
| 929 |
+
'';
|
| 930 |
+
};
|
| 931 |
+
|
| 932 |
+
# Configuration example
|
| 933 |
+
config = {
|
| 934 |
+
system = {
|
| 935 |
+
stateVersion = "23.11";
|
| 936 |
+
enable = true;
|
| 937 |
+
};
|
| 938 |
+
|
| 939 |
+
services = {
|
| 940 |
+
nginx = {
|
| 941 |
+
enable = false;
|
| 942 |
+
virtualHosts = {
|
| 943 |
+
"example.com" = {
|
| 944 |
+
root = "/var/www/example";
|
| 945 |
+
locations."/" = {
|
| 946 |
+
index = "index.html";
|
| 947 |
+
};
|
| 948 |
+
};
|
| 949 |
+
};
|
| 950 |
+
};
|
| 951 |
+
};
|
| 952 |
+
|
| 953 |
+
users = {
|
| 954 |
+
c = 3;
|
| 955 |
+
};
|
| 956 |
+
};
|
| 957 |
+
|
| 958 |
+
# Recursive attribute set example
|
| 959 |
+
tree = {
|
| 960 |
+
root = {
|
| 961 |
+
value = 1;
|
| 962 |
+
left = {
|
| 963 |
+
value = 2;
|
| 964 |
+
left = { value = 4; };
|
| 965 |
+
right = { value = 5; };
|
| 966 |
+
};
|
| 967 |
+
right = {
|
| 968 |
+
value = 3;
|
| 969 |
+
left = { value = 6; };
|
| 970 |
+
right = { value = 7; };
|
| 971 |
+
};
|
| 972 |
+
};
|
| 973 |
+
|
| 974 |
+
# Tree traversal function
|
| 975 |
+
traverse = node:
|
| 976 |
+
if node ? left && node ? right
|
| 977 |
+
then [ node.value ] ++ (tree.traverse node.left) ++ (tree.traverse node.right)
|
| 978 |
+
else if node ? value
|
| 979 |
+
then [ node.value ]
|
| 980 |
+
else [ ];
|
| 981 |
+
};
|
| 982 |
+
}
|
| 983 |
+
|
| 984 |
+
'''
|
| 985 |
+
# ---
|
| 986 |
+
# name: test_replace_body[test_case0]
|
| 987 |
+
'''
|
| 988 |
+
"""
|
| 989 |
+
Test module for variable declarations and usage.
|
| 990 |
+
|
| 991 |
+
This module tests various types of variable declarations and usages including:
|
| 992 |
+
- Module-level variables
|
| 993 |
+
- Class-level variables
|
| 994 |
+
- Instance variables
|
| 995 |
+
- Variable reassignments
|
| 996 |
+
"""
|
| 997 |
+
|
| 998 |
+
from dataclasses import dataclass, field
|
| 999 |
+
|
| 1000 |
+
# Module-level variables
|
| 1001 |
+
module_var = "Initial module value"
|
| 1002 |
+
|
| 1003 |
+
reassignable_module_var = 10
|
| 1004 |
+
reassignable_module_var = 20 # Reassigned
|
| 1005 |
+
|
| 1006 |
+
# Module-level variable with type annotation
|
| 1007 |
+
typed_module_var: int = 42
|
| 1008 |
+
|
| 1009 |
+
|
| 1010 |
+
# Regular class with class and instance variables
|
| 1011 |
+
class VariableContainer:
|
| 1012 |
+
"""Class that contains various variables."""
|
| 1013 |
+
|
| 1014 |
+
# Class-level variables
|
| 1015 |
+
class_var = "Initial class value"
|
| 1016 |
+
|
| 1017 |
+
reassignable_class_var = True
|
| 1018 |
+
reassignable_class_var = False # Reassigned #noqa: PIE794
|
| 1019 |
+
|
| 1020 |
+
# Class-level variable with type annotation
|
| 1021 |
+
typed_class_var: str = "typed value"
|
| 1022 |
+
|
| 1023 |
+
def __init__(self):
|
| 1024 |
+
# Instance variables
|
| 1025 |
+
self.instance_var = "Initial instance value"
|
| 1026 |
+
self.reassignable_instance_var = 100
|
| 1027 |
+
|
| 1028 |
+
# Instance variable with type annotation
|
| 1029 |
+
self.typed_instance_var: list[str] = ["item1", "item2"]
|
| 1030 |
+
|
| 1031 |
+
def modify_instance_var(self):
|
| 1032 |
+
# This body has been replaced
|
| 1033 |
+
self.instance_var = "Replaced!"
|
| 1034 |
+
self.reassignable_instance_var = 999 # Reassigned
|
| 1035 |
+
|
| 1036 |
+
def use_module_var(self):
|
| 1037 |
+
# Use module-level variables
|
| 1038 |
+
result = module_var + " used in method"
|
| 1039 |
+
other_result = reassignable_module_var + 5
|
| 1040 |
+
return result, other_result
|
| 1041 |
+
|
| 1042 |
+
def use_class_var(self):
|
| 1043 |
+
# Use class-level variables
|
| 1044 |
+
result = VariableContainer.class_var + " used in method"
|
| 1045 |
+
other_result = VariableContainer.reassignable_class_var
|
| 1046 |
+
return result, other_result
|
| 1047 |
+
|
| 1048 |
+
|
| 1049 |
+
# Dataclass with variables
|
| 1050 |
+
@dataclass
|
| 1051 |
+
class VariableDataclass:
|
| 1052 |
+
"""Dataclass that contains various fields."""
|
| 1053 |
+
|
| 1054 |
+
# Field variables with type annotations
|
| 1055 |
+
id: int
|
| 1056 |
+
name: str
|
| 1057 |
+
items: list[str] = field(default_factory=list)
|
| 1058 |
+
metadata: dict[str, str] = field(default_factory=dict)
|
| 1059 |
+
optional_value: float | None = None
|
| 1060 |
+
|
| 1061 |
+
# This will be reassigned in various places
|
| 1062 |
+
status: str = "pending"
|
| 1063 |
+
|
| 1064 |
+
|
| 1065 |
+
# Function that uses the module variables
|
| 1066 |
+
def use_module_variables():
|
| 1067 |
+
"""Function that uses module-level variables."""
|
| 1068 |
+
result = module_var + " used in function"
|
| 1069 |
+
other_result = reassignable_module_var * 2
|
| 1070 |
+
return result, other_result
|
| 1071 |
+
|
| 1072 |
+
|
| 1073 |
+
# Create instances and use variables
|
| 1074 |
+
dataclass_instance = VariableDataclass(id=1, name="Test")
|
| 1075 |
+
dataclass_instance.status = "active" # Reassign dataclass field
|
| 1076 |
+
|
| 1077 |
+
# Use variables at module level
|
| 1078 |
+
module_result = module_var + " used at module level"
|
| 1079 |
+
other_module_result = reassignable_module_var + 30
|
| 1080 |
+
|
| 1081 |
+
# Create a second dataclass instance with different status
|
| 1082 |
+
second_dataclass = VariableDataclass(id=2, name="Another Test")
|
| 1083 |
+
second_dataclass.status = "completed" # Another reassignment of status
|
| 1084 |
+
|
| 1085 |
+
'''
|
| 1086 |
+
# ---
|
| 1087 |
+
# name: test_replace_body[test_case1]
|
| 1088 |
+
'''
|
| 1089 |
+
export class DemoClass {
|
| 1090 |
+
value: number;
|
| 1091 |
+
constructor(value: number) {
|
| 1092 |
+
this.value = value;
|
| 1093 |
+
}
|
| 1094 |
+
function printValue() {
|
| 1095 |
+
// This body has been replaced
|
| 1096 |
+
console.warn("New value: " + this.value);
|
| 1097 |
+
}
|
| 1098 |
+
}
|
| 1099 |
+
|
| 1100 |
+
export function helperFunction() {
|
| 1101 |
+
const demo = new DemoClass(42);
|
| 1102 |
+
demo.printValue();
|
| 1103 |
+
}
|
| 1104 |
+
|
| 1105 |
+
helperFunction();
|
| 1106 |
+
|
| 1107 |
+
'''
|
| 1108 |
+
# ---
|
projects/ui/serena-new/test/serena/config/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
|
|
|
|
| 1 |
+
# Empty init file for test package
|