JObject Analyze(string code, AnalyzeModes analyzeMode) { try { Lua state = CreateAnalyser(); state["code"] = code; var fn = "analyzeCode"; if (analyzeMode == AnalyzeModes.Module) { fn = "analyzeModule"; } else if (analyzeMode == AnalyzeModes.ModuleEx) { fn = "analyzeModuleEx"; } string tpl = @"local analyzer = require('lua.libs.luacheck.analyzer').new();" + @"return analyzer.{0}(code)"; var script = string.Format(tpl, fn); string r = state.DoString(script)[0] as string; return(JObject.Parse(r)); } catch { } return(null); }
private void selectSimpleButton_Click(object sender, EventArgs e) { this.openFileDialog.FileName = this.filePathTextEdit.Text.Trim(); if (this.openFileDialog.ShowDialog() != DialogResult.OK) { return; } try { this.filePathTextEdit.Text = this.openFileDialog.FileName; FileInfo fileInfo = new FileInfo(this.filePathTextEdit.Text); string fileExtension = fileInfo.Extension; if (fileExtension.Equals(".xml", StringComparison.InvariantCultureIgnoreCase)) { this._currentAnalyzeMode = AnalyzeModes.TranslationFile; } else if (fileExtension.Equals(".csproj", StringComparison.InvariantCultureIgnoreCase)) { this._currentAnalyzeMode = AnalyzeModes.UIProject; string fullName = fileInfo.Directory.Parent.FullName; ProjectManager.InitializeEnglishKeys(fullName); ProjectManager.InitializeAllowedKeys(fullName); } else if (fileExtension.Equals(".sln", StringComparison.InvariantCultureIgnoreCase)) { this._currentAnalyzeMode = AnalyzeModes.Solution; } } catch (Exception ex) { XtraMessageBox.Show(ex.Message, ex.Source, MessageBoxButtons.OK, MessageBoxIcon.Error); } }