This commit is contained in:
2026-01-11 23:15:41 +00:00
parent 530985d704
commit b9dc7be3ce
759 changed files with 830 additions and 2013 deletions

View File

@@ -0,0 +1,20 @@
#!/bin/bash
# Script to fix common Java compilation errors
cd /home/rewrich/Documents/GitHub/tustu/app/src/main/java
# Fix illegal escape sequences \BInterfaceNovember -> \\n
echo "Fixing illegal escape sequences..."
find . -name "*.java" -type f -exec sed -i 's/\\BInterfaceNovember/\\n/g' {} \;
# Fix "do" keyword usage (do -> doObj)
echo "Fixing 'do' keyword issues..."
find . -name "*.java" -type f -exec sed -i 's/\bdo paramdo\b/DoObj paramDoObj/g' {} \;
find . -name "*.java" -type f -exec sed -i 's/instanceof do\b/instanceof DoObj/g' {} \;
find . -name "*.java" -type f -exec sed -i 's/return do;/return numericTextField;/g' {} \;
# Fix Abstract keyword usage
echo "Fixing 'Abstract' keyword issues..."
find . -name "*.java" -type f -exec sed -i 's/\bAbstract paramh\b/AbstractParam paramh/g' {} \;
echo "Done! Files modified."

View File

@@ -0,0 +1,65 @@
#!/usr/bin/env python3
"""
Fix constructor declarations in Java files where methods have lowercase names
matching patterns like: a(X paramX) or b(Y paramY) but should be constructors.
"""
import os
import re
import sys
def fix_constructor(file_path):
"""Fix constructor declarations in a Java file."""
with open(file_path, 'r', encoding='utf-8', errors='ignore') as f:
content = f.read()
# Extract class name from file
filename = os.path.basename(file_path)
expected_class_name = filename.replace('.java', '')
# Find the class declaration
class_match = re.search(r'class\s+(\w+)', content)
if not class_match:
return False
actual_class_name = class_match.group(1)
# Pattern: lowercase method name followed by constructor-like parameters
# Examples: c(b paramb) {}, d(b paramb) {}, etc.
pattern = r'(\n\s+)([a-z][A-Z]?)\(([^)]+)\)\s*\{\}'
def replace_constructor(match):
indent = match.group(1)
method_name = match.group(2)
params = match.group(3)
# Replace with actual class name
return f"{indent}{actual_class_name}({params}) {{}}"
new_content = re.sub(pattern, replace_constructor, content)
if new_content != content:
with open(file_path, 'w', encoding='utf-8') as f:
f.write(new_content)
return True
return False
def main():
base_path = "/home/rewrich/Documents/GitHub/tustu/app/src/main/java"
fixed_count = 0
for root, dirs, files in os.walk(base_path):
for file in files:
if file.endswith('.java'):
file_path = os.path.join(root, file)
try:
if fix_constructor(file_path):
fixed_count += 1
print(f"Fixed: {file_path}")
except Exception as e:
print(f"Error processing {file_path}: {e}", file=sys.stderr)
print(f"\nTotal files fixed: {fixed_count}")
if __name__ == "__main__":
main()