19 changed files with 263 additions and 804 deletions
@ -0,0 +1,120 @@
@@ -0,0 +1,120 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
using System.Windows.Media; |
||||
using System.Windows.Threading; |
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
namespace Debugger.AddIn.Pads.Controls |
||||
{ |
||||
public class AutoCompleteTextBox : UserControl |
||||
{ |
||||
TextEditor editor; |
||||
ITextEditor editorAdapter; |
||||
|
||||
public static readonly DependencyProperty TextProperty = |
||||
DependencyProperty.Register("Text", typeof(string), typeof(AutoCompleteTextBox), |
||||
new FrameworkPropertyMetadata(string.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, TextChanged)); |
||||
|
||||
public static readonly DependencyProperty IsEditableProperty = |
||||
DependencyProperty.Register("IsEditable", typeof(bool), typeof(AutoCompleteTextBox), |
||||
new FrameworkPropertyMetadata(true, IsEditableChanged)); |
||||
|
||||
public string Text { |
||||
get { return (string)GetValue(TextProperty); } |
||||
set { SetValue(TextProperty, value); } |
||||
} |
||||
|
||||
public bool IsEditable { |
||||
get { return (bool)GetValue(IsEditableProperty); } |
||||
set { SetValue(IsEditableProperty, value); } |
||||
} |
||||
|
||||
static void TextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
((AutoCompleteTextBox)d).editor.Text = (string)e.NewValue; |
||||
} |
||||
|
||||
static void IsEditableChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) |
||||
{ |
||||
((AutoCompleteTextBox)d).editor.IsReadOnly = !(bool)e.NewValue; |
||||
} |
||||
|
||||
public AutoCompleteTextBox() |
||||
{ |
||||
object tmp; |
||||
this.editorAdapter = EditorControlService.CreateEditor(out tmp); |
||||
this.editor = (TextEditor)tmp; |
||||
|
||||
this.editor.Background = Brushes.Transparent; |
||||
this.editor.ShowLineNumbers = false; |
||||
this.editor.HorizontalScrollBarVisibility = ScrollBarVisibility.Hidden; |
||||
this.editor.VerticalScrollBarVisibility = ScrollBarVisibility.Hidden; |
||||
this.editor.TextArea.GotKeyboardFocus += delegate { |
||||
this.Background = Brushes.White; |
||||
}; |
||||
this.editor.TextArea.LostKeyboardFocus += delegate { |
||||
this.Background = Brushes.Transparent; |
||||
this.Text = this.editor.Text; |
||||
this.editor.Select(0, 0); |
||||
}; |
||||
this.editor.TextArea.PreviewKeyDown += editor_TextArea_PreviewKeyDown; |
||||
this.editor.TextArea.TextEntered += editor_TextArea_TextEntered; |
||||
|
||||
this.Content = this.editor; |
||||
} |
||||
|
||||
void editor_TextArea_PreviewKeyDown(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Return || e.Key == Key.Escape) { |
||||
if (e.Key == Key.Return) |
||||
this.Text = this.editor.Text; |
||||
|
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
void editor_TextArea_TextEntered(object sender, TextCompositionEventArgs e) |
||||
{ |
||||
StackFrame frame = WindowsDebugger.CurrentStackFrame; |
||||
if (e.Text == "." && frame != null) |
||||
ShowDotCompletion(frame, this.editor.Text); |
||||
} |
||||
|
||||
private void ShowDotCompletion(StackFrame frame, string currentText) |
||||
{ |
||||
string language = ProjectService.CurrentProject == null ? "C#" : ProjectService.CurrentProject.Language; |
||||
NRefactoryResolver resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language)); |
||||
|
||||
var seg = frame.NextStatement; |
||||
|
||||
var expressionFinder = ParserService.GetExpressionFinder(seg.Filename); |
||||
var info = ParserService.GetParseInformation(seg.Filename); |
||||
|
||||
string text = ParserService.GetParseableFileContent(seg.Filename).Text; |
||||
|
||||
int currentOffset = this.editor.CaretOffset; |
||||
|
||||
var expr = expressionFinder.FindExpression(currentText, currentOffset); |
||||
|
||||
expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn); |
||||
|
||||
var rr = resolver.Resolve(expr, info, text); |
||||
|
||||
if (rr != null) { |
||||
editorAdapter.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context)); |
||||
} |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
<ResourceDictionary |
||||
x:Class="CommonResources" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:local="clr-namespace:Debugger.AddIn.Pads.Controls" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
xmlns:tv="http://icsharpcode.net/sharpdevelop/treeview" |
||||
> |
||||
<tv:SharpGridView x:Key="variableGridView"> |
||||
<GridView.Columns> |
||||
<GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.NameColumn}" Width="400"> |
||||
<GridViewColumn.CellTemplate> |
||||
<DataTemplate> |
||||
<StackPanel Orientation="Horizontal"> |
||||
<tv:SharpTreeNodeView/> |
||||
<local:AutoCompleteTextBox Margin="-6 0 0 0" Text="{Binding Node.Name}" IsEditable="{Binding Node.CanSetName}"/> |
||||
</StackPanel> |
||||
</DataTemplate> |
||||
</GridViewColumn.CellTemplate> |
||||
</GridViewColumn> |
||||
<GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.ValueColumn}" Width="200"> |
||||
<GridViewColumn.CellTemplate> |
||||
<DataTemplate> |
||||
<local:AutoCompleteTextBox Text="{Binding Node.Value}" IsEditable="{Binding Node.CanSetValue}"/> |
||||
</DataTemplate> |
||||
</GridViewColumn.CellTemplate> |
||||
</GridViewColumn> |
||||
<GridViewColumn Header="{core:Localize MainWindow.Windows.Debug.LocalVariables.TypeColumn}" Width="200"> |
||||
<GridViewColumn.CellTemplate> |
||||
<DataTemplate> |
||||
<local:AutoCompleteTextBox Text="{Binding Node.Type}" /> |
||||
</DataTemplate> |
||||
</GridViewColumn.CellTemplate> |
||||
</GridViewColumn> |
||||
</GridView.Columns> |
||||
</tv:SharpGridView> |
||||
</ResourceDictionary> |
@ -1,28 +0,0 @@
@@ -1,28 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Globalization; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Media; |
||||
|
||||
namespace Debugger.AddIn.Pads.Controls |
||||
{ |
||||
public class BoolToVisibilityConverter : IMultiValueConverter |
||||
{ |
||||
public object Convert(object[] values, Type targetType, |
||||
object parameter, CultureInfo culture) |
||||
{ |
||||
bool val = bool.Parse(parameter.ToString()); |
||||
return val == (bool.Parse(values[0].ToString()) && bool.Parse(values[1].ToString())) ? Visibility.Visible : Visibility.Collapsed; |
||||
} |
||||
|
||||
public object[] ConvertBack(object value, Type[] targetTypes, |
||||
object parameter, CultureInfo culture) |
||||
{ |
||||
throw new NotImplementedException(); |
||||
} |
||||
} |
||||
} |
@ -1,82 +0,0 @@
@@ -1,82 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<UserControl x:Class="Debugger.AddIn.Pads.Controls.WatchList" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
xmlns:local="clr-namespace:Debugger.AddIn.Pads.Controls" |
||||
xmlns:core="http://icsharpcode.net/sharpdevelop/core" |
||||
xmlns:tv="http://icsharpcode.net/sharpdevelop/treeview"> |
||||
<UserControl.Resources> |
||||
<local:BoolToVisibilityConverter x:Key="boolToVisibility" /> |
||||
<Style x:Key="BorderStyle" TargetType="Border"> |
||||
<Setter Property="BorderBrush" Value="LightGray" /> |
||||
<Setter Property="BorderThickness" Value="1,0,1,1"></Setter> |
||||
<Setter Property="VerticalAlignment" Value="Center" /> |
||||
<Setter Property="HorizontalAlignment" Value="Stretch" /> |
||||
</Style> |
||||
<Style TargetType="{x:Type TextBox}" x:Key="TextBoxValueStyle"> |
||||
<Setter Property="BorderThickness" Value="0"/> |
||||
<Setter Property="BorderBrush" Value="Transparent"/> |
||||
<Setter Property="Background" Value="White"/> |
||||
<Setter Property="VerticalAlignment" Value="Center" /> |
||||
<Setter Property="Visibility"> |
||||
<Setter.Value> |
||||
<MultiBinding Converter="{StaticResource boolToVisibility}" ConverterParameter="True"> |
||||
<Binding Path="Node.CanSetValue" /> |
||||
<Binding Path="IsSelected" /> |
||||
</MultiBinding> |
||||
</Setter.Value> |
||||
</Setter> |
||||
</Style> |
||||
<Style TargetType="{x:Type TextBlock}" x:Key="TextBlockValueStyle"> |
||||
<Setter Property="VerticalAlignment" Value="Center" /> |
||||
<Setter Property="Visibility"> |
||||
<Setter.Value> |
||||
<MultiBinding Converter="{StaticResource boolToVisibility}" ConverterParameter="False"> |
||||
<Binding Path="Node.CanSetValue" /> |
||||
<Binding Path="IsSelected" /> |
||||
</MultiBinding> |
||||
</Setter.Value> |
||||
</Setter> |
||||
</Style> |
||||
<!-- Value column --> |
||||
<DataTemplate x:Key="CellTemplate_Value"> |
||||
<StackPanel Orientation="Horizontal"> |
||||
<TextBlock VerticalAlignment="Center" MinWidth="200" Text="{Binding Node.Value}" Style="{StaticResource TextBlockValueStyle}" /> |
||||
<TextBox Text="{Binding Node.Value, Mode=OneWay}" Style="{StaticResource TextBoxValueStyle}" KeyUp="OnValueTextBoxKeyUp" /> |
||||
</StackPanel> |
||||
</DataTemplate> |
||||
<!-- Type column --> |
||||
<DataTemplate x:Key="CellTemplate_Type"> |
||||
<TextBlock VerticalAlignment="Center" MinWidth="200" Text="{Binding Node.Type}" /> |
||||
</DataTemplate> |
||||
</UserControl.Resources> |
||||
<DockPanel> |
||||
<tv:SharpTreeView x:Name="myList" ShowRoot="False" PreviewMouseDoubleClick="MyListPreviewMouseDoubleClick" AllowDrop="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}, Path=AllowDrop}"> |
||||
<tv:SharpTreeView.View> |
||||
<tv:SharpGridView> |
||||
<GridView.Columns> |
||||
<GridViewColumn Header="{core:Localize Global.Name}" Width="400"> |
||||
<GridViewColumn.CellTemplate> |
||||
<DataTemplate> |
||||
<tv:SharpTreeNodeView> |
||||
<tv:SharpTreeNodeView.CellEditor> |
||||
<local:WatchListAutoCompleteCell |
||||
CommandText="{Binding Node.Name, Mode=OneWay}" |
||||
CommandEntered="WatchListAutoCompleteCellCommandEntered"/> |
||||
</tv:SharpTreeNodeView.CellEditor> |
||||
</tv:SharpTreeNodeView> |
||||
</DataTemplate> |
||||
</GridViewColumn.CellTemplate> |
||||
</GridViewColumn> |
||||
<GridViewColumn Header="{core:Localize Dialog.HighlightingEditor.Properties.Value}" |
||||
CellTemplate="{StaticResource CellTemplate_Value}" |
||||
Width="200" /> |
||||
<GridViewColumn Header="{core:Localize ResourceEditor.ResourceEdit.TypeColumn}" |
||||
CellTemplate="{StaticResource CellTemplate_Type}" |
||||
Width="200" /> |
||||
</GridView.Columns> |
||||
</tv:SharpGridView> |
||||
</tv:SharpTreeView.View> |
||||
</tv:SharpTreeView> |
||||
</DockPanel> |
||||
</UserControl> |
@ -1,91 +0,0 @@
@@ -1,91 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.Collections.Generic; |
||||
using System.Collections.ObjectModel; |
||||
using System.Linq; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Data; |
||||
using System.Windows.Input; |
||||
using Debugger.AddIn.TreeModel; |
||||
using ICSharpCode.Core.Presentation; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.Pads; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
using ICSharpCode.TreeView; |
||||
|
||||
namespace Debugger.AddIn.Pads.Controls |
||||
{ |
||||
public enum WatchListType |
||||
{ |
||||
LocalVar, |
||||
Watch |
||||
} |
||||
|
||||
public partial class WatchList : UserControl |
||||
{ |
||||
public WatchList(WatchListType type) |
||||
{ |
||||
InitializeComponent(); |
||||
WatchType = type; |
||||
if (type == WatchListType.Watch) |
||||
myList.Root = new WatchRootNode(); |
||||
else |
||||
myList.Root = new SharpTreeNode(); |
||||
} |
||||
|
||||
public WatchListType WatchType { get; private set; } |
||||
|
||||
public SharpTreeNodeCollection WatchItems { |
||||
get { return myList.Root.Children; } |
||||
} |
||||
|
||||
public TreeNodeWrapper SelectedNode { |
||||
get { return myList.SelectedItem as TreeNodeWrapper; } |
||||
} |
||||
|
||||
void OnValueTextBoxKeyUp(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key != Key.Enter && e.Key != Key.Escape) { |
||||
e.Handled = true; |
||||
return; |
||||
} |
||||
|
||||
if (e.Key == Key.Enter) { |
||||
if(SelectedNode.Node is ValueNode) { |
||||
var node = (ValueNode)SelectedNode.Node; |
||||
node.Value = ((TextBox)sender).Text; |
||||
} |
||||
} |
||||
if (e.Key == Key.Enter || e.Key == Key.Escape) { |
||||
myList.UnselectAll(); |
||||
WindowsDebugger.RefreshPads(); |
||||
} |
||||
} |
||||
|
||||
void WatchListAutoCompleteCellCommandEntered(object sender, EventArgs e) |
||||
{ |
||||
if (SelectedNode == null) return; |
||||
if (WatchType != WatchListType.Watch) return; |
||||
|
||||
var cell = ((WatchListAutoCompleteCell)sender); |
||||
|
||||
SelectedNode.Node.Name = cell.CommandText; |
||||
myList.UnselectAll(); |
||||
if (WatchType == WatchListType.Watch && WatchPad.Instance != null) { |
||||
WindowsDebugger.RefreshPads(); |
||||
} |
||||
SelectedNode.IsEditing = false; |
||||
} |
||||
|
||||
void MyListPreviewMouseDoubleClick(object sender, MouseButtonEventArgs e) |
||||
{ |
||||
if (SelectedNode == null) return; |
||||
if (WatchType != WatchListType.Watch) |
||||
return; |
||||
SelectedNode.IsEditing = true; |
||||
} |
||||
} |
||||
} |
@ -1,169 +0,0 @@
@@ -1,169 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Windows; |
||||
using System.Windows.Controls; |
||||
using System.Windows.Input; |
||||
|
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
||||
using ICSharpCode.SharpDevelop.Editor; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
using ICSharpCode.SharpDevelop.Gui; |
||||
using ICSharpCode.SharpDevelop.Gui.Pads; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
namespace Debugger.AddIn.Pads.Controls |
||||
{ |
||||
public partial class WatchListAutoCompleteCell : UserControl |
||||
{ |
||||
private string language; |
||||
|
||||
protected ConsoleControl console; |
||||
|
||||
public static readonly DependencyProperty CommandTextProperty = |
||||
DependencyProperty.Register("CommandText", typeof(string), typeof(WatchListAutoCompleteCell), |
||||
new UIPropertyMetadata(null, new PropertyChangedCallback(OnCommandTextChanged))); |
||||
|
||||
private NRefactoryResolver resolver; |
||||
|
||||
public event EventHandler CommandEntered; |
||||
|
||||
public WatchListAutoCompleteCell() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
console = new ConsoleControl(); |
||||
console.TextAreaTextEntered += new TextCompositionEventHandler(consoleControl_TextAreaTextEntered); |
||||
console.TextAreaPreviewKeyDown += new KeyEventHandler(console_TextAreaPreviewKeyDown); |
||||
console.LostFocus += new RoutedEventHandler(console_LostFocus); |
||||
console.HideScrollBar(); |
||||
ConsolePanel.Content = console; |
||||
|
||||
// get language
|
||||
if (ProjectService.CurrentProject == null) |
||||
language = "C#"; |
||||
else |
||||
language = ProjectService.CurrentProject.Language; |
||||
resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language)); |
||||
|
||||
// FIXME set language
|
||||
if (language == "VB" || language == "VBNet") { |
||||
console.SetHighlighting("VBNET"); |
||||
} |
||||
else { |
||||
console.SetHighlighting("C#"); |
||||
} |
||||
|
||||
// get process
|
||||
WindowsDebugger debugger = (WindowsDebugger)DebuggerService.CurrentDebugger; |
||||
} |
||||
|
||||
/// <summary>
|
||||
/// Gets/sets the command text displayed at the command prompt.
|
||||
/// </summary>
|
||||
public string CommandText { |
||||
get { return console.CommandText.Trim(); } |
||||
set { console.CommandText = value; } |
||||
} |
||||
|
||||
private ITextEditor TextEditor { |
||||
get { |
||||
return console.TextEditor; |
||||
} |
||||
} |
||||
|
||||
private void console_TextAreaPreviewKeyDown(object sender, KeyEventArgs e) |
||||
{ |
||||
if (e.Key == Key.Return || e.Key == Key.Escape) { |
||||
|
||||
if (e.Key == Key.Escape) |
||||
CommandText = string.Empty; |
||||
else { |
||||
if(!CheckSyntax()) |
||||
return; |
||||
} |
||||
|
||||
if (CommandEntered != null) |
||||
CommandEntered(this, EventArgs.Empty); |
||||
|
||||
e.Handled = true; |
||||
} |
||||
} |
||||
|
||||
private void console_LostFocus(object sender, RoutedEventArgs e) |
||||
{ |
||||
if (string.IsNullOrEmpty(CommandText) || !this.CheckSyntax()) |
||||
return; |
||||
|
||||
if (CommandEntered != null) |
||||
CommandEntered(this, EventArgs.Empty); |
||||
} |
||||
|
||||
private bool CheckSyntax() |
||||
{ |
||||
string command = CommandText; |
||||
|
||||
// FIXME workaround the NRefactory issue that needs a ; at the end
|
||||
if (language == "C#" || language == "CSharp") { |
||||
if(!command.EndsWith(";")) |
||||
command += ";"; |
||||
// FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
|
||||
language = "CSharp"; |
||||
} |
||||
|
||||
SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language.ToString(), true); |
||||
using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(command))) { |
||||
parser.ParseExpression(); |
||||
if (parser.Errors.Count > 0) { |
||||
MessageService.ShowError(parser.Errors.ErrorOutput); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
private void consoleControl_TextAreaTextEntered(object sender, TextCompositionEventArgs e) |
||||
{ |
||||
StackFrame frame = WindowsDebugger.CurrentStackFrame; |
||||
if (e.Text == "." && frame != null) |
||||
ShowDotCompletion(frame, console.CommandText); |
||||
} |
||||
|
||||
private void ShowDotCompletion(StackFrame frame, string currentText) |
||||
{ |
||||
var seg = frame.NextStatement; |
||||
|
||||
var expressionFinder = ParserService.GetExpressionFinder(seg.Filename); |
||||
var info = ParserService.GetParseInformation(seg.Filename); |
||||
|
||||
string text = ParserService.GetParseableFileContent(seg.Filename).Text; |
||||
|
||||
int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1; |
||||
|
||||
var expr = expressionFinder.FindExpression(currentText, currentOffset); |
||||
|
||||
expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn); |
||||
|
||||
var rr = resolver.Resolve(expr, info, text); |
||||
|
||||
if (rr != null) { |
||||
TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context)); |
||||
} |
||||
} |
||||
|
||||
private static void OnCommandTextChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { |
||||
var cell = d as WatchListAutoCompleteCell; |
||||
cell.CommandText = e.NewValue.ToString(); |
||||
} |
||||
} |
||||
} |
@ -1,11 +0,0 @@
@@ -1,11 +0,0 @@
|
||||
<UserControl x:Class="Debugger.AddIn.Pads.Controls.WatchListAutoCompleteCell" |
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> |
||||
<Grid> |
||||
<Grid.ColumnDefinitions> |
||||
<ColumnDefinition Width="Auto" MinWidth="200"/> |
||||
</Grid.ColumnDefinitions> |
||||
<ContentPresenter |
||||
Name="ConsolePanel" /> |
||||
</Grid> |
||||
</UserControl> |
@ -1,35 +0,0 @@
@@ -1,35 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<src:BaseWatchBox |
||||
x:Class="Debugger.AddIn.Pads.WatchInputBox" xmlns:src="clr-namespace:ICSharpCode.SharpDevelop.Gui.Pads;assembly=ICSharpCode.SharpDevelop" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:core="http://icsharpcode.net/sharpdevelop/core" xmlns:widgets="http://icsharpcode.net/sharpdevelop/widgets" |
||||
Style="{x:Static core:GlobalStyles.DialogWindowStyle}" |
||||
WindowStartupLocation="CenterScreen" |
||||
WindowState="Normal" |
||||
WindowStyle="ToolWindow" |
||||
Width="300" |
||||
SizeToContent="Height" |
||||
ResizeMode="NoResize"> |
||||
<DockPanel Margin="4"> |
||||
<widgets:UniformGridWithSpacing |
||||
Columns="2" |
||||
DockPanel.Dock="Bottom" |
||||
Margin="0,8" |
||||
Grid.Row="1" |
||||
HorizontalAlignment="Center"> |
||||
<Button |
||||
Name="AcceptButton" |
||||
Style="{x:Static core:GlobalStyles.ButtonStyle}" |
||||
Content="{core:Localize Global.OKButtonText}" |
||||
Click="AcceptButton_Click" |
||||
IsDefault="True" /> |
||||
<Button |
||||
Name="CancelButton" |
||||
Style="{x:Static core:GlobalStyles.ButtonStyle}" |
||||
Content="{core:Localize Global.CancelButtonText}" |
||||
Click="CancelButton_Click" |
||||
IsCancel="True" /> |
||||
</widgets:UniformGridWithSpacing> |
||||
<ContentPresenter |
||||
MaxHeight="75" |
||||
Name="ConsolePanel" /> |
||||
</DockPanel> |
||||
</src:BaseWatchBox> |
@ -1,123 +0,0 @@
@@ -1,123 +0,0 @@
|
||||
// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt)
|
||||
// This code is distributed under the GNU LGPL (for details please see \doc\license.txt)
|
||||
|
||||
using System; |
||||
using System.IO; |
||||
using System.Windows; |
||||
using System.Windows.Input; |
||||
|
||||
using ICSharpCode.AvalonEdit; |
||||
using ICSharpCode.Core; |
||||
using ICSharpCode.NRefactory; |
||||
using ICSharpCode.SharpDevelop; |
||||
using ICSharpCode.SharpDevelop.Debugging; |
||||
using ICSharpCode.SharpDevelop.Dom; |
||||
using ICSharpCode.SharpDevelop.Dom.NRefactoryResolver; |
||||
using ICSharpCode.SharpDevelop.Editor.CodeCompletion; |
||||
using ICSharpCode.SharpDevelop.Gui.Pads; |
||||
using ICSharpCode.SharpDevelop.Project; |
||||
using ICSharpCode.SharpDevelop.Services; |
||||
|
||||
namespace Debugger.AddIn.Pads |
||||
{ |
||||
/// <summary>
|
||||
/// Interaction logic for WatchBox.xaml
|
||||
/// </summary>
|
||||
public partial class WatchInputBox : BaseWatchBox |
||||
{ |
||||
private NRefactoryResolver resolver; |
||||
private string language; |
||||
|
||||
public WatchInputBox(string text, string caption) : base() |
||||
{ |
||||
InitializeComponent(); |
||||
|
||||
// UI
|
||||
text = StringParser.Parse(text); |
||||
this.Title = StringParser.Parse(caption); |
||||
this.ConsolePanel.Content = console; |
||||
|
||||
if (ProjectService.CurrentProject == null) return; |
||||
|
||||
// get language
|
||||
language = ProjectService.CurrentProject.Language; |
||||
resolver = new NRefactoryResolver(LanguageProperties.GetLanguage(language)); |
||||
|
||||
// FIXME set language
|
||||
if (language == "VB" || language == "VBNet") { |
||||
console.SetHighlighting("VBNET"); |
||||
} else { |
||||
language = "C#"; |
||||
console.SetHighlighting("C#"); |
||||
} |
||||
} |
||||
|
||||
protected override void AbstractConsolePadTextEntered(object sender, TextCompositionEventArgs e) |
||||
{ |
||||
StackFrame frame = WindowsDebugger.CurrentStackFrame; |
||||
if (e.Text == "." && frame != null) |
||||
ShowDotCompletion(frame, console.CommandText); |
||||
} |
||||
|
||||
private void ShowDotCompletion(StackFrame frame, string currentText) |
||||
{ |
||||
var seg = frame.NextStatement; |
||||
|
||||
var expressionFinder = ParserService.GetExpressionFinder(seg.Filename); |
||||
var info = ParserService.GetParseInformation(seg.Filename); |
||||
|
||||
string text = ParserService.GetParseableFileContent(seg.Filename).Text; |
||||
|
||||
int currentOffset = TextEditor.Caret.Offset - console.CommandOffset - 1; |
||||
|
||||
var expr = expressionFinder.FindExpression(currentText, currentOffset); |
||||
|
||||
expr.Region = new DomRegion(seg.StartLine, seg.StartColumn, seg.EndLine, seg.EndColumn); |
||||
|
||||
var rr = resolver.Resolve(expr, info, text); |
||||
|
||||
if (rr != null) { |
||||
TextEditor.ShowCompletionWindow(new DotCodeCompletionItemProvider().GenerateCompletionListForResolveResult(rr, expr.Context)); |
||||
} |
||||
} |
||||
|
||||
private bool CheckSyntax() |
||||
{ |
||||
string command = console.CommandText.Trim(); |
||||
|
||||
// FIXME workaround the NRefactory issue that needs a ; at the end
|
||||
if (language == "C#") { |
||||
if(!command.EndsWith(";")) |
||||
command += ";"; |
||||
// FIXME only one string should be available; highlighting expects C#, supproted language, CSharp
|
||||
language = "CSharp"; |
||||
} |
||||
|
||||
SupportedLanguage supportedLanguage = (SupportedLanguage)Enum.Parse(typeof(SupportedLanguage), language, true); |
||||
using (var parser = ParserFactory.CreateParser(supportedLanguage, new StringReader(command))) { |
||||
parser.ParseExpression(); |
||||
if (parser.Errors.Count > 0) { |
||||
MessageService.ShowError(parser.Errors.ErrorOutput); |
||||
return false; |
||||
} |
||||
} |
||||
|
||||
return true; |
||||
} |
||||
|
||||
private void AcceptButton_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
if (!this.CheckSyntax()) |
||||
return; |
||||
|
||||
this.DialogResult = true; |
||||
this.Close(); |
||||
} |
||||
|
||||
private void CancelButton_Click(object sender, RoutedEventArgs e) |
||||
{ |
||||
DialogResult = false; |
||||
this.Close(); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue