private void SetupIntelliSense() { // Start the parser service (only call this once at the start of your application) SemanticParserService.Start(); string temp = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Branding.ProductName + Path.DirectorySeparatorChar + "Temp"); if (!Directory.Exists(temp)) { Directory.CreateDirectory(temp); } string intellisenseCacheDir = Path.Combine(temp, @"IntellisenseCacheModelScripts"); TempAssembliesDir = Path.Combine(temp, @"TempAssemblies"); if (!Directory.Exists(intellisenseCacheDir)) { Directory.CreateDirectory(intellisenseCacheDir); } dotNetProjectResolver.CachePath = intellisenseCacheDir; //AddMainFunctionAssemblyToProjectResolver(); ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage cSharpLanguage = new ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage(); syntaxEditorOffscreen.Document.Language = cSharpLanguage; syntaxEditorOffscreen.Document.LanguageData = dotNetProjectResolver; syntaxEditorOffscreen.Document.Filename = System.Guid.NewGuid().ToString() + ".cs"; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(null, Controller.Instance.CurrentProject.TemplateLoader); gen.ClearAllDebugLines(); if (!backgroundWorkerAddReferences.IsBusy) { backgroundWorkerAddReferences.RunWorkerAsync(); } }
private void ProcessEditorKeyDown(object sender, KeyEventArgs e) { int openParen = 57; if ((e.Control && e.KeyCode == Keys.Space) || (e.Shift && e.KeyValue == openParen)) { SyntaxEditor editor = (SyntaxEditor)sender; int closePos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("%>", editor.Caret.Offset); int openPos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("<%", editor.Caret.Offset); if (openPos < 0 || closePos > openPos) { return; } ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); if (e.Control && e.KeyCode == Keys.Space) { syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, extraCode) + "}"; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length - 1; ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).IntelliPromptCompleteWord(syntaxEditorOffscreen, editor); } else if (e.Shift && e.KeyValue == openParen) { syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, extraCode) + "("; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length; // -1; //syntaxEditorOffscreen.Focus(); ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).ShowIntelliPromptParameterInfo(syntaxEditorOffscreen, editor); } } }
private void ProcessEditorTriggerActivated(object sender, ActiproSoftware.SyntaxEditor.TriggerEventArgs e) { SyntaxEditor editor = (SyntaxEditor)sender; int closePos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("%>", editor.Caret.Offset); int openPos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("<%", editor.Caret.Offset); if (openPos < 0 || closePos > openPos) { return; } ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, CurrentScriptType); syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.Text.Length - 1; ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).ShowIntelliPromptMemberList(syntaxEditorOffscreen, editor); return; }
private void ProcessEditorTriggerActivated(object sender, ActiproSoftware.SyntaxEditor.TriggerEventArgs e) { SyntaxEditor editor = (SyntaxEditor)sender; int closePos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("%>", editor.Caret.Offset); int openPos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("<%", editor.Caret.Offset); if (openPos < 0 || closePos > openPos) return; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, CurrentScriptType); syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.Text.Length - 1; ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).ShowIntelliPromptMemberList(syntaxEditorOffscreen, editor); return; }
internal void Populate() { if (BusyPopulating) return; try { if (ArchAngel.Interfaces.SharedData.CurrentProject == null) return; BusyPopulating = true; if (ArchAngel.Interfaces.SharedData.CurrentProject != null) { if (ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject == null) ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject = ArchAngel.Common.UserTemplateHelper.GetDefaultTemplate(); TemplateProject = ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject; ArchAngel.Interfaces.SharedData.CurrentProject.InitialiseScriptObjects(); } if (TemplateProject == null) { comboBoxTemplates.SelectedIndex = 0; comboBoxDelimiter.SelectedIndex = 0; } else { for (int i = 0; i < comboBoxTemplates.Items.Count; i++) { if (comboBoxTemplates.Items[i] is string) continue; ArchAngel.Interfaces.Template.TemplateProject p = (ArchAngel.Interfaces.Template.TemplateProject)comboBoxTemplates.Items[i]; if (p.Name == TemplateProject.Name && p.IsOfficial == TemplateProject.IsOfficial) { comboBoxTemplates.SelectedIndex = i; break; } } if (TemplateProject.Delimiter == Interfaces.Template.TemplateProject.DelimiterTypes.ASP) comboBoxDelimiter.SelectedIndex = 0; else comboBoxDelimiter.SelectedIndex = 1; } PopulateTree(); PopulateStaticFiles(); #region Intellisense setup // Start the parser service (only call this once at the start of your application) SemanticParserService.Start(); string temp = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Branding.ProductName + Path.DirectorySeparatorChar + "Temp"); if (!Directory.Exists(temp)) Directory.CreateDirectory(temp); string intellisenseCacheDir = Path.Combine(temp, @"IntellisenseCache"); TempAssembliesDir = Path.Combine(temp, @"TempAssemblies"); if (!Directory.Exists(intellisenseCacheDir)) Directory.CreateDirectory(intellisenseCacheDir); dotNetProjectResolver.CachePath = intellisenseCacheDir; //AddMainFunctionAssemblyToProjectResolver(); ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage cSharpLanguage = new ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage(); syntaxEditorOffscreen.Document.Language = cSharpLanguage; syntaxEditorOffscreen.Document.LanguageData = dotNetProjectResolver; syntaxEditorOffscreen.Document.Filename = System.Guid.NewGuid().ToString() + ".cs"; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(null, Controller.Instance.CurrentProject.TemplateLoader); gen.ClearAllDebugLines(); if (!backgroundWorkerAddReferences.IsBusy) backgroundWorkerAddReferences.RunWorkerAsync(); #endregion IsPopulated = true; #region Compile to find errors string exeDir = Path.GetDirectoryName(Application.ExecutablePath); List<string> referencedAssemblies = new List<string>(); //referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Scripting.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Interfaces.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Providers.EntityModel.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.NHibernateHelper.dll")); #if DEBUG string path = Slyce.Common.RelativePaths.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location, @"..\..\..\..\3rd_Party_Libs\Inflector.Net.dll"); referencedAssemblies.Add(path); #else referencedAssemblies.Add(Path.Combine(exeDir, "Inflector.Net.dll")); #endif List<System.CodeDom.Compiler.CompilerError> compileErrors; gen.CompileCombinedAssembly(ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject, referencedAssemblies, null, out compileErrors, false, null); if (compileErrors.Count > 0) Instance_OnCompileErrors(compileErrors); #endregion } finally { BusyPopulating = false; } }
private void ProcessEditorKeyDown(object sender, KeyEventArgs e) { int openParen = 57; if ((e.Control && e.KeyCode == Keys.Space) || (e.Shift && e.KeyValue == openParen)) { SyntaxEditor editor = (SyntaxEditor)sender; int closePos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("%>", editor.Caret.Offset); int openPos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf("<%", editor.Caret.Offset); if (openPos < 0 || closePos > openPos) return; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); if (e.Control && e.KeyCode == Keys.Space) { syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, extraCode) + "}"; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length - 1; ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).IntelliPromptCompleteWord(syntaxEditorOffscreen, editor); } else if (e.Shift && e.KeyValue == openParen) { syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, extraCode) + "("; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length;// -1; //syntaxEditorOffscreen.Focus(); ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).ShowIntelliPromptParameterInfo(syntaxEditorOffscreen, editor); } } }
private void syntaxEditorSkipStaticFile_TriggerActivated(object sender, TriggerEventArgs e) { SyntaxEditor editor = (SyntaxEditor)sender; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); syntaxEditorOffscreen.Document.Text = GetCSharpCode(ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterStart + editor.Document.GetText(LineTerminator.Newline) + ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterEnd, editor.Caret.Offset + 2, extraCode); syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.Text.Length - 1; ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).ShowIntelliPromptMemberList(syntaxEditorOffscreen, syntaxEditorSkipStaticFile); }
private void syntaxEditorSkipStaticFile_KeyDown(object sender, KeyEventArgs e) { if (e.Control && e.KeyCode == Keys.Space) { SyntaxEditor editor = (SyntaxEditor)sender; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); syntaxEditorOffscreen.Document.Text = GetCSharpCode(ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterStart + editor.Document.GetText(LineTerminator.Newline) + ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterEnd, editor.Caret.Offset + 2, extraCode) + "}"; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length - 1; string iteratorName; if (comboBoxIterator.Text == "one file" || comboBoxIterator.Text == "one folder") iteratorName = ArchAngel.Interfaces.Template.IteratorTypes.None.ToString().ToLower(); else iteratorName = comboBoxIterator.Text.Substring(comboBoxIterator.Text.IndexOf(" per ") + 5).ToLower(); ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).IntelliPromptCompleteWord(syntaxEditorOffscreen, syntaxEditorSkipStaticFile);//, syntaxEditor1); } }
private void QuickCompile( bool execute, int fileId, object param, out string genFilename, out string genBody, out bool genSkipFile) { genFilename = ""; genBody = ""; genSkipFile = false; System.Diagnostics.Stopwatch stopwatch = System.Diagnostics.Stopwatch.StartNew(); ArchAngel.Interfaces.Template.TemplateProject proj = new ArchAngel.Interfaces.Template.TemplateProject(); if (treeFiles.SelectedNode.Tag is ArchAngel.Interfaces.Template.File) { ArchAngel.Interfaces.Template.File file = (ArchAngel.Interfaces.Template.File)treeFiles.SelectedNode.Tag; file.Name = syntaxEditorFilename.Text; file.Script.Syntax = Slyce.Common.SyntaxEditorHelper.LanguageEnumFromName(comboBoxSyntax.Text); file.Script.Body = syntaxEditor1.Text; if (comboBoxIterator.Text.ToLowerInvariant().Trim() == "one file") file.Iterator = ArchAngel.Interfaces.Template.IteratorTypes.None; else { string iterator = comboBoxIterator.Text.ToLowerInvariant().Trim(); iterator = iterator.Substring(iterator.LastIndexOf(' ') + 1); file.Iterator = (ArchAngel.Interfaces.Template.IteratorTypes)Enum.Parse(typeof(ArchAngel.Interfaces.Template.IteratorTypes), iterator, true); } proj.OutputFolder.Files.Add(file); } else if (treeFiles.SelectedNode.Tag is ArchAngel.Interfaces.Template.Folder) { ArchAngel.Interfaces.Template.Folder folder = (ArchAngel.Interfaces.Template.Folder)treeFiles.SelectedNode.Tag; folder.Name = syntaxEditorFilename.Text; if (comboBoxIterator.Text.ToLowerInvariant().Trim() == "one folder") folder.Iterator = ArchAngel.Interfaces.Template.IteratorTypes.None; else { string iterator = comboBoxIterator.Text.ToLowerInvariant().Trim(); iterator = iterator.Substring(iterator.LastIndexOf(' ') + 1); folder.Iterator = (ArchAngel.Interfaces.Template.IteratorTypes)Enum.Parse(typeof(ArchAngel.Interfaces.Template.IteratorTypes), iterator, true); } proj.OutputFolder.Folders.Add(folder); } string exeDir = Path.GetDirectoryName(Application.ExecutablePath); List<string> referencedAssemblies = new List<string>(); //referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Scripting.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Interfaces.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Providers.EntityModel.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.NHibernateHelper.dll")); #if DEBUG referencedAssemblies.Add(Slyce.Common.RelativePaths.GetFullPath(System.Reflection.Assembly.GetExecutingAssembly().Location, @"..\..\..\..\3rd_Party_Libs\Inflector.Net.dll")); #else referencedAssemblies.Add(Path.Combine(exeDir, "Inflector.Net.dll")); #endif //referencedAssemblies.Add(BaseAssemblyPath); List<System.CodeDom.Compiler.CompilerError> compileErrors; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator( null, Controller.Instance.CurrentProject.TemplateLoader); //gen.CompileFunctionsAssembly(proj, referencedAssemblies, out compileErrors); string temp = Path.Combine(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Branding.ProductName + Path.DirectorySeparatorChar + "Temp"), "Compile"); if (!Directory.Exists(temp)) Directory.CreateDirectory(temp); temp = Path.Combine(temp, Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".dll"); gen.CompileCombinedAssembly(proj, referencedAssemblies, null, out compileErrors, execute, temp); if (treeFiles.SelectedNode.Tag is ArchAngel.Interfaces.Template.File) treeFiles.SelectedNode.ImageIndex = compileErrors.Count == 0 ? IMG_FILE_GREEN : IMG_FILE_ORANGE; else if (treeFiles.SelectedNode.Tag is ArchAngel.Interfaces.Template.Folder) treeFiles.SelectedNode.ImageIndex = compileErrors.Count == 0 ? IMG_CLOSED_FOLDER : IMG_FOLDER_ORANGE; if (execute) { if (compileErrors.Count == 0) { if (treeFiles.SelectedNode.Tag is ArchAngel.Interfaces.Template.File) { ArchAngel.Interfaces.Template.File file = (ArchAngel.Interfaces.Template.File)treeFiles.SelectedNode.Tag; gen.SetProjectInCode(ArchAngel.Interfaces.SharedData.CurrentProject.ScriptProject); genFilename = gen.GetFileName(fileId, param); try { genBody = Utility.StandardizeLineBreaks(gen.GetFileBody(file.Id, param, out genSkipFile), Utility.LineBreaks.Windows); } catch (Exception e) { int errLine; string stackTrace = ArchAngel.Common.Generator.GetCleanStackTrace(e.InnerException.StackTrace, file.Id, out errLine); stackTrace = stackTrace.Substring(stackTrace.IndexOf(":line ") + ":line ".Length); //throw new Exception("TODO: Work out how to handle filename: file vs. static file"); ArchAngel.Common.Generator.DebugPos debugPos = ArchAngel.Common.Generator.GetDebugPos(string.Format("File_{0}", file.Id), errLine - 1, 1, string.Format("Error: {0}\nFile: {1}", e.Message, file.Id)); debugPos.Line = errLine; // GFH HighlightRuntimeException(file.Id, debugPos, e.InnerException.Message); return; } } else if (treeFiles.SelectedNode.Tag is ArchAngel.Interfaces.Template.Folder) { ArchAngel.Interfaces.Template.Folder folder = (ArchAngel.Interfaces.Template.Folder)treeFiles.SelectedNode.Tag; try { genFilename = gen.GetFolderName(folder.ID, param); } catch (Exception e) { MessageBox.Show(this, e.InnerException.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } genBody = ""; } else throw new NotImplementedException("Template type not handled yet: " + treeFiles.SelectedNode.Tag.GetType().ToString()); if (superTabControl1.SelectedTab != superTabItemTest) superTabControl1.SelectedTab = superTabItemTest; } else { if (superTabControl1.SelectedTab != superTabItemScript) superTabControl1.SelectedTab = superTabItemScript; MessageBox.Show(this, "See bottom of screen for errors.", "Errors occurred", MessageBoxButtons.OK, MessageBoxIcon.Error); } } syntaxEditorFilename.Document.SpanIndicatorLayers.Clear(); syntaxEditor1.Document.SpanIndicatorLayers.Clear(); BusyPopulatingErrors = true; dataGridViewErrors.Rows.Clear(); highlighter1.SetHighlightColor(syntaxEditorFilename, DevComponents.DotNetBar.Validator.eHighlightColor.None); if (compileErrors.Count == 0) { labelHeader.BackgroundStyle.BackColor = Color.GreenYellow; labelHeader.BackgroundStyle.BackColor2 = Color.Green; labelHeader.Refresh(); } else { labelHeader.BackgroundStyle.BackColor = Color.FromArgb(249, 224, 123); labelHeader.BackgroundStyle.BackColor2 = Color.FromArgb(224, 113, 21); labelHeader.Refresh(); //Controller.Instance.RaiseCompileErrors(compileErrors); //progressHelper.ReportProgress(100, new GenerateFilesProgress(0, new Controller.CompileErrorsDelegate(compileErrors))); foreach (var err in compileErrors) { //throw new Exception("TODO: Work out how to handle filename: file vs. static file"); ArchAngel.Common.Generator.DebugPos debugPos = ArchAngel.Common.Generator.GetDebugPos(err.FileName, err.Line, err.Column, string.Format("Error: {0}\nFile: {1}", err.ErrorText, err.FileName)); string functionName = debugPos.FunctionName == "GetFileName" ? "Filename" : "Body"; int line = debugPos.Line - 1; int column = err.Column - 10 - 1; string filename = treeFiles.FindNodeByDataKey(err.FileName).Text; string description = err.ErrorText .Replace("Slyce.FunctionRunner.", ""); ActiproSoftware.SyntaxEditor.SyntaxEditor editor; if (functionName == "Filename") editor = syntaxEditorFilename; else if (functionName == "Body") editor = syntaxEditor1; else throw new NotImplementedException("Function type not handled yet: " + functionName); int startOffset = editor.Document.Lines[line].TextRange.StartOffset + column; //if (startOffset < 0 && functionName == "Body") //{ // editor = syntaxEditorFilename; // startOffset = editor.Document.Lines[line].TextRange.StartOffset + column; //} dataGridViewErrors.Rows.Add(err.FileName, "", description, filename, functionName, debugPos.Line, err.Column - 10); // Account for \r\n instead of \n //startOffset -= line; //int endOffset = syntaxEditor1.Document.findc startOffset + 3; ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder wbf = new ActiproSoftware.SyntaxEditor.DefaultWordBreakFinder(); if (startOffset < 0) return; int endOffset = wbf.FindCurrentWordEnd(editor.Document, startOffset); if (endOffset < startOffset) { //MessageBox.Show("endOffset < startOffset"); return; } ActiproSoftware.SyntaxEditor.WaveLineSpanIndicator errorIndicator = new ActiproSoftware.SyntaxEditor.WaveLineSpanIndicator(Color.Red); errorIndicator.Tag = err.ErrorText; this.AddSpanIndicator( editor, ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorKey, ActiproSoftware.SyntaxEditor.SpanIndicatorLayer.SyntaxErrorDisplayPriority, errorIndicator, new ActiproSoftware.SyntaxEditor.TextRange(startOffset, endOffset)); } bar1.SelectedDockContainerItem = dockContainerItemErrors; BusyPopulatingErrors = false; } stopwatch.Stop(); long duration = stopwatch.ElapsedMilliseconds; #if DEBUG timer1.Interval = 600; #else timer1.Interval = Math.Max((int)duration * 3, 600); #endif }
private void ProcessEditorKeyDown(object sender, KeyEventArgs e) { int openParen = 57; if ((e.Control && e.KeyCode == Keys.Space) || (e.Shift && e.KeyValue == openParen)) { SyntaxEditor editor = (SyntaxEditor)sender; int closePos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf(ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterEnd, editor.Caret.Offset); int openPos = editor.Document.GetText(LineTerminator.Newline).LastIndexOf(ArchAngel.Interfaces.SharedData.CurrentProject.TemplateProject.DelimiterStart, editor.Caret.Offset); if (openPos < 0 || closePos > openPos) return; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); string extraCode = Slyce.Common.Utility.StandardizeLineBreaks(gen.GetFunctionLookupClass(true), Slyce.Common.Utility.LineBreaks.Unix); string iteratorName; if (comboBoxIterator.Text == "one file" || comboBoxIterator.Text == "one folder") iteratorName = ArchAngel.Interfaces.Template.IteratorTypes.None.ToString().ToLower(); else iteratorName = comboBoxIterator.Text.Substring(comboBoxIterator.Text.IndexOf(" per ") + 5).ToLower(); if (e.Control && e.KeyCode == Keys.Space) { syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, extraCode) + "}"; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length - 1; ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).IntelliPromptCompleteWord(syntaxEditorOffscreen, editor); } else if (e.Shift && e.KeyValue == openParen) { syntaxEditorOffscreen.Document.Text = GetCSharpCode(editor.Document.GetText(LineTerminator.Newline), editor.Caret.Offset, extraCode) + "("; syntaxEditorOffscreen.Caret.Offset = syntaxEditorOffscreen.Document.GetText(ActiproSoftware.SyntaxEditor.LineTerminator.Newline).Length;// -1; //syntaxEditorOffscreen.Focus(); ((ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage)syntaxEditorOffscreen.SelectedView.GetCurrentLanguageForContext()).ShowIntelliPromptParameterInfo(syntaxEditorOffscreen, editor); } } }
private void CompileBaseAssemblyOnly() { string exeDir = Path.GetDirectoryName(Application.ExecutablePath); List<string> referencedAssemblies = new List<string>(); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Interfaces.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.Providers.EntityModel.dll")); referencedAssemblies.Add(Path.Combine(exeDir, "ArchAngel.NHibernateHelper.dll")); ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(); if (!Directory.Exists(TempAssembliesDir)) Directory.CreateDirectory(TempAssembliesDir); BaseAssemblyPath = Path.Combine(TempAssembliesDir, Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) + ".dll"); BaseAssembly = gen.CompileBaseAssembly(referencedAssemblies, null, BaseAssemblyPath); }
private void SetupIntelliSense() { // Start the parser service (only call this once at the start of your application) SemanticParserService.Start(); string temp = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), Branding.ProductName + Path.DirectorySeparatorChar + "Temp"); if (!Directory.Exists(temp)) Directory.CreateDirectory(temp); string intellisenseCacheDir = Path.Combine(temp, @"IntellisenseCacheModelScripts"); TempAssembliesDir = Path.Combine(temp, @"TempAssemblies"); if (!Directory.Exists(intellisenseCacheDir)) Directory.CreateDirectory(intellisenseCacheDir); dotNetProjectResolver.CachePath = intellisenseCacheDir; //AddMainFunctionAssemblyToProjectResolver(); ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage cSharpLanguage = new ActiproSoftware.SyntaxEditor.Addons.CSharp.CSharpSyntaxLanguage(); syntaxEditorOffscreen.Document.Language = cSharpLanguage; syntaxEditorOffscreen.Document.LanguageData = dotNetProjectResolver; syntaxEditorOffscreen.Document.Filename = System.Guid.NewGuid().ToString() + ".cs"; ArchAngel.Common.Generator gen = new ArchAngel.Common.Generator(null, Controller.Instance.CurrentProject.TemplateLoader); gen.ClearAllDebugLines(); if (!backgroundWorkerAddReferences.IsBusy) backgroundWorkerAddReferences.RunWorkerAsync(); }