public override void OnSave() { var generator = ALittleScriptTranslation.CreateTranslation(); try { generator.Generate(this, true); } catch (System.Exception e) { MessageBox.Show(e.Message); } }
//编译部分////////////////////////////////////////////////////////////////////////////////////////////////// public override bool CompileDocument() { var project_info = GetProjectInfo(); if (project_info == null) { MessageBox.Show("请将当前文件加入到工程后再进行编译"); return(true); } var generator = ALittleScriptTranslation.CreateTranslation(); try { var error = generator.Generate(this, true); if (error != null) { var message = error.GetError(); if (error.GetElement() != null) { message += ", file:" + error.GetElement().GetFullPath(); message += ", line:" + (error.GetElement().GetStartLine() + 1); } MessageBox.Show(message); return(true); } } catch (System.Exception e) { MessageBox.Show(e.Message); return(true); } MessageBox.Show("生成完毕"); return(true); }
public override bool CompileProject() { var project_info = GetProjectInfo(); if (project_info == null) { MessageBox.Show("请将当前文件加入到工程后再进行编译"); return(true); } var target_path = ALittleScriptUtility.CalcRootFullPath(project_info.GetProjectPath(), "lua"); if (GeneralOptions.Instance.TargetLanguage == TargetLanguages.JavaScript) { target_path = ALittleScriptUtility.CalcRootFullPath(project_info.GetProjectPath(), "js"); } try { ALittleScriptUtility.DeleteDirectory(new DirectoryInfo(target_path)); } catch (Exception e) { MessageBox.Show(e.Message); return(true); } var all_file = project_info.GetAllFile(); try { foreach (var pair in all_file) { var generator = ALittleScriptTranslation.CreateTranslation(); var error = generator.Generate(pair.Value.GetFile(), true); if (error == null) { continue; } string full_path = pair.Value.GetFullPath(); if (error.GetElement() != null) { full_path = error.GetElement().GetFullPath(); } var result = MessageBox.Show(full_path + "\n" + error.GetError() + "\n是否打开错误文件?", "生成失败", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { int start = 0; int length = 0; if (error.GetElement() != null) { start = error.GetElement().GetStart(); length = error.GetElement().GetLength(); if (length <= 0) { length = 1; } } try { Application.Current.Dispatcher.Invoke(() => { ALanguageUtility.OpenFile(null, ALittleScriptVsTextViewCreationListener.s_adapters_factory, full_path, start, length); }); } catch (System.Exception) { } } return(true); } } catch (System.Exception e) { MessageBox.Show(e.Message); return(true); } MessageBox.Show("生成完毕"); return(true); }