1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
use std::fmt;
#[derive(Eq, PartialEq)]
pub enum ProjectType {
Javascript,
Rust,
Go,
C,
Cpp,
Python,
Java,
Kotlin,
Swift,
Php,
Ruby,
Shell,
Dart,
Haskell,
Scala,
Perl,
R,
Elixir,
CSharp,
FSharp,
Lua,
}
impl fmt::Display for ProjectType {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let name = match self {
ProjectType::Javascript => "Javascript",
ProjectType::Rust => "Rust",
ProjectType::Go => "Go",
ProjectType::C => "C",
ProjectType::Cpp => "C++",
ProjectType::Python => "Python",
ProjectType::Java => "Java",
ProjectType::Kotlin => "Kotlin",
ProjectType::Swift => "Swift",
ProjectType::Php => "PHP",
ProjectType::Ruby => "Ruby",
ProjectType::Shell => "Shell",
ProjectType::Dart => "Dart",
ProjectType::Haskell => "Haskell",
ProjectType::Scala => "Scala",
ProjectType::Perl => "Perl",
ProjectType::R => "R",
ProjectType::Elixir => "Elixir",
ProjectType::CSharp => "C#",
ProjectType::FSharp => "F#",
ProjectType::Lua => "Lua",
};
write!(f, "{}", name)
}
}
impl ProjectType {
pub fn from(file: &str) -> Vec<Self> {
let mut types = Vec::new();
match file {
// JavaScript/TypeScript specific files
"package.json" | "yarn.lock" | "pnpm-lock.yaml" | "vite.config.js"
| "webpack.config.js" => {
types.push(Self::Javascript);
}
// Rust specific files
"Cargo.toml" | "Cargo.lock" | "build.rs" => {
types.push(Self::Rust);
}
// Go specific files
"go.mod" | "go.sum" => {
types.push(Self::Go);
}
// C-specific files
"Makefile" | "config.h" => {
types.push(Self::C);
}
// C++ specific files
"CMakeLists.txt" | ".clang-format" | ".clang-tidy" => {
types.push(Self::Cpp);
types.push(Self::C);
}
// Python specific files
"requirements.txt" | "Pipfile" | "pyproject.toml" | "setup.py" | "tox.ini" => {
types.push(Self::Python);
}
// Java specific files
"pom.xml" | "build.gradle" | "settings.gradle" => {
types.push(Self::Java);
}
// Kotlin specific files
"build.gradle.kts" | "settings.gradle.kts" => {
types.push(Self::Kotlin);
}
// Swift specific files
"Package.swift" | "Info.plist" | ".xcodeproj" | ".xcworkspace" => {
types.push(Self::Swift);
}
// PHP specific files
"composer.json" | "composer.lock" => {
types.push(Self::Php);
}
// Ruby specific files
"Gemfile" | "Gemfile.lock" | "Rakefile" => {
types.push(Self::Ruby);
}
// Shell specific files
".sh" | ".bashrc" | ".zshrc" | ".profile" => {
types.push(Self::Shell);
}
// Dart specific files
"pubspec.yaml" | ".packages" => {
types.push(Self::Dart);
}
// Haskell specific files
"stack.yaml" | "cabal.project" | ".ghci" => {
types.push(Self::Haskell);
}
// Scala specific files
"build.sbt" => {
types.push(Self::Scala);
}
// Perl specific files
"Makefile.PL" => {
types.push(Self::Perl);
}
// R specific files
"DESCRIPTION" | "NAMESPACE" => {
types.push(Self::R);
}
// Elixir specific files
"mix.exs" => {
types.push(Self::Elixir);
}
// C# specific files
".csproj" | ".sln" | "app.config" => {
types.push(Self::CSharp);
}
// F# specific files
".fsproj" => {
types.push(Self::FSharp);
}
// Lua specific files
"init.lua" | ".luacheckrc" => {
types.push(Self::Lua);
}
_ => {}
}
types
}
pub fn get_files(&self) -> Vec<&str> {
match self {
Self::Javascript => vec![
".ts",
".js",
".jsx",
".tsx",
".json",
"package.json",
"yarn.lock",
"pnpm-lock.yaml",
"vite.config.js",
"webpack.config.js",
".eslintrc",
".prettierrc",
".babelrc",
".svelte",
".vue",
".nuxt",
".astro",
],
Self::Rust => vec![
".rs",
"Cargo.toml",
"build.rs",
".rustfmt.toml",
".clippy.toml",
],
Self::Go => vec![
".go",
"go.mod",
"go.sum",
".golangci.yaml",
"Makefile",
"Dockerfile",
],
Self::C => vec![".c", ".h", ".o", "Makefile", "config.h", "CMakeLists.txt"],
Self::Cpp => vec![
".cpp",
".hpp",
".hxx",
".cxx",
".cc",
".o",
"Makefile",
"CMakeLists.txt",
".clang-format",
".clang-tidy",
],
Self::Python => vec![
".py", // Python source files
"requirements.txt", // Dependency management
"Pipfile", // Pipenv dependency management
"pyproject.toml", // PEP 518 configuration
"setup.py", // Package configuration
".pylintrc", // Pylint configuration
"tox.ini", // Testing framework configuration
"Dockerfile", // Docker build configuration
],
Self::Java => vec![
".java", // Java source files
"pom.xml", // Maven project descriptor
"build.gradle", // Gradle project descriptor
"settings.gradle", // Gradle settings
".classpath", // Eclipse project configuration
".project", // Eclipse project configuration
],
Self::Kotlin => vec![
".kt", // Kotlin source files
".kts", // Kotlin scripts
"build.gradle.kts", // Gradle Kotlin DSL
"settings.gradle.kts", // Gradle settings Kotlin DSL
],
Self::Swift => vec![
".swift", // Swift source files
"Package.swift", // Swift package manager manifest
"Info.plist", // iOS/macOS app metadata
".xcodeproj", // Xcode project file
".xcworkspace", // Xcode workspace
],
Self::Php => vec![
".php", // PHP source files
"composer.json", // Composer dependency manager
"composer.lock", // Composer lock file
".env", // Environment configuration
],
Self::Ruby => vec![
".rb", // Ruby source files
"Gemfile", // Ruby dependency management
"Gemfile.lock", // Lock file for dependencies
"Rakefile", // Rake build scripts
],
Self::Shell => vec![
".sh", // Shell scripts
".bashrc", // Bash configuration
".zshrc", // Zsh configuration
".profile", // User profile configuration
],
Self::Dart => vec![
".dart", // Dart source files
"pubspec.yaml", // Dart package manager manifest
".packages", // Dart package resolution
],
Self::Haskell => vec![
".hs", // Haskell source files
"stack.yaml", // Stack configuration
"cabal.project", // Cabal configuration
".ghci", // GHC interactive environment
],
Self::Scala => vec![
".scala", // Scala source files
"build.sbt", // SBT build file
".sc", // Scala scripts
],
Self::Perl => vec![
".pl", // Perl source files
".pm", // Perl modules
"Makefile.PL", // Perl makefile
],
Self::R => vec![
".R", // R source files
"DESCRIPTION", // R package description
"NAMESPACE", // R package namespace
],
Self::Elixir => vec![
".ex", // Elixir source files
".exs", // Elixir scripts
"mix.exs", // Mix build configuration
],
Self::CSharp => vec![
".cs", // C# source files
".csproj", // C# project configuration
".sln", // Solution files
"app.config", // Application configuration
],
Self::FSharp => vec![
".fs", // F# source files
".fsproj", // F# project configuration
],
Self::Lua => vec![
".lua", // Lua source files
"init.lua", // Lua entry point
".luacheckrc", // Lua lint configuration
],
}
}
}