/// <summary> /// Initializes a new instance of the <c>ParentSyntaxLanguage</c> class. /// </summary> /// <param name="projectAssembly">The project assembly to use.</param> public ParentSyntaxLanguage(IProjectAssembly projectAssembly) : base("Parent to C# example") { // Create a classification type provider and register its classification types ParentClassificationTypeProvider classificationTypeProvider = new ParentClassificationTypeProvider(); classificationTypeProvider.RegisterAll(); // Create a C# child language var childLanguage = new CSharpSyntaxLanguage(); childLanguage.RegisterProjectAssembly(projectAssembly); this.RegisterProjectAssembly(projectAssembly); // Register core parent language services this.RegisterLexer(new ParentLexer(childLanguage)); this.RegisterService(new ParentTokenTaggerProvider(classificationTypeProvider)); this.RegisterParser(new ParentParser(childLanguage)); // Register proxy IntelliPrompt services this.RegisterService(new TranslatedCSharpCompletionProvider()); this.RegisterService(new TranslatedCSharpParameterInfoProvider()); this.RegisterService(new TranslatedCSharpQuickInfoProvider()); // Register a tagger provider for showing parse errors this.RegisterService(new CodeDocumentTaggerProvider <ParseErrorTagger>(typeof(ParseErrorTagger))); // Register a squiggle tag quick info provider this.RegisterService(new SquiggleTagQuickInfoProvider()); }
///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes an instance of the <c>MainControl</c> class. /// </summary> public MainControl() { InitializeComponent(); // // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // // Initialize the project assembly (enables support for automated IntelliPrompt features) projectAssembly = new VBProjectAssembly("SampleBrowser"); projectAssembly.AssemblyReferences.ItemAdded += OnAssemblyReferencesChanged; projectAssembly.AssemblyReferences.ItemRemoved += OnAssemblyReferencesChanged; var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on VB language and register the project assembly on it var language = new VBSyntaxLanguage(); language.RegisterProjectAssembly(projectAssembly); codeEditor.Document.Language = language; }
///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes an instance of the <c>MainControl</c> class. /// </summary> public MainControl() { InitializeComponent(); // Set the header and footer on the fragment editor's document fragmentEditor.Document.SetHeaderAndFooterText(headerEditor.Document.CurrentSnapshot.Text, footerEditor.Document.CurrentSnapshot.Text); // // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // // Initialize the project assembly (enables support for automated IntelliPrompt features) projectAssembly = new CSharpProjectAssembly("SampleBrowser"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on C# language and register the project assembly on it var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(projectAssembly); fragmentEditor.Document.Language = language; // Create a parser-less C# language for the header/footer editors var parserlessLanguage = new CSharpSyntaxLanguage(); parserlessLanguage.UnregisterParser(); headerEditor.Document.Language = parserlessLanguage; footerEditor.Document.Language = parserlessLanguage; }
///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes an instance of the <c>MainControl</c> class. /// </summary> public MainControl() { InitializeComponent(); // Register display item classification types (so breakpoint indicator styles are registered) new DisplayItemClassificationTypeProvider().RegisterAll(); // Set the header/footer text to make the editor work as a method body editor.Document.SetHeaderAndFooterText("using System; using System.Diagnostics; using System.IO; private class Program { private void Execute() {\r\n", "\r\n}}"); // // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // // Initialize the project assembly (enables support for automated IntelliPrompt features) projectAssembly = new CSharpProjectAssembly("SampleBrowser"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on C# language and register the project assembly on it var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(projectAssembly); // Register an indicator quick info provider language.RegisterService(new IndicatorQuickInfoProvider()); // Register an event sink that allows for handling of clicks in the indicator margin language.RegisterService(new DebuggingPointerInputEventSink()); // Assign the language editor.Document.Language = language; this.Dispatcher.BeginInvoke(DispatcherPriority.ApplicationIdle, (DispatcherOperationCallback) delegate(object arg) { // Since we are initializing some default breakpoints, make sure the document parse completes in the worker thread first AmbientParseRequestDispatcherProvider.Dispatcher.WaitForParse(ParseRequest.GetParseHashKey(editor.Document)); // Add some indicators (this is dispatched since this sample relies on the document's AST being available and parsing occurs asynchronously) DebuggingHelper.ToggleBreakpoint(new TextSnapshotOffset(editor.ActiveView.CurrentSnapshot, editor.ActiveView.CurrentSnapshot.Lines[19].StartOffset), true); DebuggingHelper.ToggleBreakpoint(new TextSnapshotOffset(editor.ActiveView.CurrentSnapshot, editor.ActiveView.CurrentSnapshot.Lines[23].StartOffset), false); DebuggingHelper.ToggleBreakpoint(new TextSnapshotOffset(editor.ActiveView.CurrentSnapshot, editor.ActiveView.CurrentSnapshot.Lines[28].StartOffset), true); return(null); }, null); }
public Syntax(Object ob) { cf = (Classfile)ob; InitializeComponent(); projectAssembly = new CSharpProjectAssembly("SampleBrowser"); //projectAssembly.AssemblyReferences.ItemAdded += OnAssemblyReferencesChanged; //projectAssembly.AssemblyReferences.ItemRemoved += OnAssemblyReferencesChanged; var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on C# language and register the project assembly on it var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(projectAssembly); codeEditor.Document.Language = language; }
/// <summary> /// Initializes a new instance of the <c>VBExpressionEditorSyntaxLanguage</c> class. /// </summary> public VBExpressionEditorSyntaxLanguage() { // // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // // Initialize the project assembly (enables support for automated IntelliPrompt features) projectAssembly = new VBProjectAssembly("ExpressionEditor"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += OnProjectAssemblyReferenceLoaderWork; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on VB language and register the project assembly on it this.RegisterProjectAssembly(projectAssembly); }
///////////////////////////////////////////////////////////////////////////////////////////////////// // OBJECT ///////////////////////////////////////////////////////////////////////////////////////////////////// /// <summary> /// Initializes an instance of the <c>MainControl</c> class. /// </summary> public MainControl() { InitializeComponent(); // // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // // Initialize the project assembly (enables support for automated IntelliPrompt features) projectAssembly = new CSharpProjectAssembly("SampleBrowser"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the merged language and pass in the project assembly codeEditor.Document.Language = new ParentSyntaxLanguage(projectAssembly); }
private void UpdateEditorLanguage(CodeTypes codeType, bool reloadAssemblies) { UpdateAssemblyReferences(); var changeToCsharp = codeType != CodeTypes.PixateCssFile; var currentEditorLanguageIsCsharp = CodeEditor.Document.Language is CSharpSyntaxLanguage; if (currentEditorLanguageIsCsharp == changeToCsharp) { if (reloadAssemblies) { LoadEditorReferences(); } return; } ISyntaxLanguage language; if (codeType == CodeTypes.PixateCssFile) { var serializer = new SyntaxLanguageDefinitionSerializer(); using (var cssLanguageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("ProtoPad_Client.Css.langdef")) { language = serializer.LoadFromStream(cssLanguageStream); } } else { // Initialize the project assembly (enables support for automated IntelliPrompt features) _projectAssembly = new CSharpProjectAssembly("ProtoPad Client"); LoadEditorReferences(); // Load the .NET Languages Add-on C# language and register the project assembly on it language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(_projectAssembly); } CodeEditor.Document.Language = language; CodeEditor.Document.Language.RegisterService(new IndicatorQuickInfoProvider()); }
public Intellisense() { ServerAssembly = new CSharpProjectAssembly("Project"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); ServerLanguage = new CSharpSyntaxLanguage(); ServerLanguage.RegisterProjectAssembly(ServerAssembly); ClientAssembly = new CSharpProjectAssembly("Client"); var clientAssemblyLoader = new BackgroundWorker(); clientAssemblyLoader.DoWork += ClientAssemblyReferenceLoader; clientAssemblyLoader.RunWorkerAsync(); ClientLanguage = new CSharpSyntaxLanguage(); ClientLanguage.RegisterProjectAssembly(ClientAssembly); ServerLanguage.RegisterService(new CodeDocumentTaggerProvider <CodeEditor.Tagger>(typeof(CodeEditor.Tagger))); ClientLanguage.RegisterService(new CodeDocumentTaggerProvider <CodeEditor.Tagger>(typeof(CodeEditor.Tagger))); }
/// <summary> /// Initializes a new instance of the <see cref="CodePanel"/>. /// </summary> public CodePanel() { InitializeComponent(); _projectAssembly = new CSharpProjectAssembly("StudioStrategy"); _projectAssembly.AssemblyReferences.AddMsCorLib(); var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(_projectAssembly); CodeEditor.Document.Language = language; _errorsSource = new ObservableCollection<CompileResultItem>(); ErrorsGrid.ItemsSource = _errorsSource; var references = new SynchronizedList<CodeReference>(); references.Added += r => _references.SafeAdd(r, r1 => { IProjectAssemblyReference asmRef = null; try { asmRef = _projectAssembly.AssemblyReferences.AddFrom(r1.Location); } catch (Exception ex) { ex.LogError(); } return asmRef; }); references.Removed += r => { var item = _projectAssembly .AssemblyReferences .FirstOrDefault(p => { var assm = p.Assembly as IBinaryAssembly; if (assm == null) return false; return assm.Location == r.Location; }); if (item != null) _projectAssembly.AssemblyReferences.Remove(item); }; references.Cleared += () => { _projectAssembly.AssemblyReferences.Clear(); _projectAssembly.AssemblyReferences.AddMsCorLib(); }; References = references; }
/// <summary> /// Initializes a new instance of the <see cref="CodePanel"/>. /// </summary> public CodePanel() { InitializeComponent(); _projectAssembly = new CSharpProjectAssembly("StudioStrategy"); _projectAssembly.AssemblyReferences.AddMsCorLib(); var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(_projectAssembly); CodeEditor.Document.Language = language; _errorsSource = new ObservableCollection <CompileResultItem>(); ErrorsGrid.ItemsSource = _errorsSource; var references = new SynchronizedList <CodeReference>(); references.Added += r => _references.SafeAdd(r, r1 => { IProjectAssemblyReference asmRef = null; try { asmRef = _projectAssembly.AssemblyReferences.AddFrom(r1.Location); } catch (Exception ex) { ex.LogError(); } return(asmRef); }); references.Removed += r => { var item = _projectAssembly .AssemblyReferences .FirstOrDefault(p => { var assm = p.Assembly as IBinaryAssembly; if (assm == null) { return(false); } return(assm.Location == r.Location); }); if (item != null) { _projectAssembly.AssemblyReferences.Remove(item); } }; references.Cleared += () => { _projectAssembly.AssemblyReferences.Clear(); _projectAssembly.AssemblyReferences.AddMsCorLib(); }; References = references; }
public MainWindow() { InitializeComponent(); _currentDevice = new DeviceItem { DeviceAddress = "http://192.168.1.104:8080/", DeviceName = "Yarvik", DeviceType = DeviceTypes.Android }; // NOTE: Make sure that you've read through the add-on language's 'Getting Started' topic // since it tells you how to set up an ambient parse request dispatcher and an ambient // code repository within your application OnStartup code, and add related cleanup in your // application OnExit code. These steps are essential to having the add-on perform well. // Initialize the project assembly (enables support for automated IntelliPrompt features) _projectAssembly = new CSharpProjectAssembly("SampleBrowser"); var assemblyLoader = new BackgroundWorker(); assemblyLoader.DoWork += DotNetProjectAssemblyReferenceLoader; assemblyLoader.RunWorkerAsync(); // Load the .NET Languages Add-on C# language and register the project assembly on it var language = new CSharpSyntaxLanguage(); language.RegisterProjectAssembly(_projectAssembly); CodeEditor.Document.Language = language; CodeEditor.Document.Language.RegisterService(new IndicatorQuickInfoProvider()); CodeEditor.PreviewKeyDown += (sender, args) => { if (args.Key != Key.Enter || (Keyboard.Modifiers & ModifierKeys.Control) != ModifierKeys.Control) return; SendCodeButton_Click(null,null); args.Handled = true; }; _udpDiscoveryClient = new UdpDiscoveryClient( // ready => Dispatcher.Invoke((Action) (() => SendCodeButton.IsEnabled = ready)), ready => { }, (name, address) => Dispatcher.Invoke(() => { if (address.Contains("?")) address = address.Replace("?", AndroidPort); var deviceItem = new DeviceItem { DeviceAddress = address, DeviceName = name, DeviceType = name.StartsWith("ProtoPad Service on ANDROID Device ") ? DeviceTypes.Android : DeviceTypes.iOS }; if (!DevicesComboBox.Items.Cast<object>().Any(i => (i as DeviceItem).DeviceAddress == deviceItem.DeviceAddress)) { DevicesComboBox.Items.Add(deviceItem); } DevicesComboBox.IsEnabled = true; //ResultTextBox.Text += String.Format("Found '{0}' on {1}", name, address); })); ResultTextBox.Navigated += (sender, args) => { var htmlDocument = ResultTextBox.Document as HTMLDocument; _htmlHolder = htmlDocument.getElementById("wrapallthethings") as HTMLDivElementClass; _htmlWindow = htmlDocument.parentWindow; _udpDiscoveryClient.SendServerPing(); var ticksPassed = 0; var dispatcherTimer = new System.Windows.Threading.DispatcherTimer(); dispatcherTimer.Tick += (s, a) => { if (ticksPassed > 2) { dispatcherTimer.Stop(); if (DevicesComboBox.Items.Count == 1) { DevicesComboBox.SelectedIndex = 0; } } _udpDiscoveryClient.SendServerPing(); ticksPassed++; }; dispatcherTimer.Interval = TimeSpan.FromMilliseconds(200); dispatcherTimer.Start(); }; ResultTextBox.NavigateToString(Properties.Resources.ResultHtmlWrap); }