MCPcopy Create free account
hub / github.com/VSCodeConfigHelper/v4 / list

Function list

src-tauri/src/tasks/mod.rs:187–287  ·  view source on GitHub ↗
(mut args: TaskInitArgs)

Source from the content-addressed store, hash-verified

185}
186
187pub fn list(mut args: TaskInitArgs) -> Vec<(&'static str, Box<dyn Fn() -> Result<()> + Send>)> {
188 let is_c = args.options.language == "C";
189 let file_ext = if is_c { "c" } else { "cpp" };
190 let vscode = adjust_vscode(Path::new(&args.vscode));
191 let workspace = {
192 let path = Path::new(&args.workspace);
193 if path.is_absolute() {
194 path.to_path_buf()
195 } else {
196 std::env::current_dir().unwrap().join(path)
197 }
198 };
199 let test_file = {
200 let mut path = workspace.join(format!("helloworld.{}", file_ext));
201 if match args.options.test {
202 Some(test) => test,
203 None => !path.exists(),
204 } {
205 let mut i = 1;
206 while path.exists() {
207 path = workspace.join(format!("helloworld({}).{}", i, file_ext));
208 i += 1;
209 }
210 Some(path.to_string())
211 } else {
212 None
213 }
214 };
215 let setup = *args.compiler.setup;
216 let standard = args.options.standard.as_ref().cloned().unwrap_or_else(|| {
217 let std_p = match setup.ty {
218 CompilerType::GCC => stdchoose::gcc,
219 CompilerType::LLVM => stdchoose::clang,
220 CompilerType::MSVC => (|_| ("c++20", "c17")) as fn(&str) -> (&'static str, &'static str),
221 }(&args.compiler.version);
222 (if is_c { std_p.1 } else { std_p.0 }).into()
223 });
224 {
225 let std_arg_prefix = if setup.is_msvc() { "/std:" } else { "-std=" };
226 if !args
227 .options
228 .args
229 .iter()
230 .any(|a| a.starts_with(std_arg_prefix))
231 {
232 let std_arg = format!("{}{}", std_arg_prefix, standard);
233 info!("在编译选项中添加 {}。", std_arg);
234 args.options.args.push(std_arg);
235 }
236 }
237 statistics::set(args.options.collect_data);
238
239 let args = Arc::from(TaskArgs {
240 vscode,
241 setup,
242 compiler_path: (setup.path_to_exe)(&args.compiler.path, is_c),
243 workspace,
244 run_hotkey: args.options.run_hotkey,

Callers 2

task_initFunction · 0.85
cliFunction · 0.85

Calls 3

to_stringMethod · 0.80
is_msvcMethod · 0.80
setFunction · 0.70

Tested by

no test coverage detected