aboutsummaryrefslogtreecommitdiffstats
path: root/Software
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-03-10 09:05:11 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-03-10 09:05:11 +0200
commitcbdd79778764ce38017790e1e1f9316e52ec8104 (patch)
tree35ef519f5c6b3621fa7362f69230ac0730413689 /Software
parent88a73106e8113a4a6ce224f9205e11219939798e (diff)
downloadTango-cbdd79778764ce38017790e1e1f9316e52ec8104.tar.gz
Tango-cbdd79778764ce38017790e1e1f9316e52ec8104.zip
Working on new scripting editor.
Diffstat (limited to 'Software')
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionListBoxItem.cs14
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindow.cs2
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindowBase.cs5
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityConverter.cs24
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityInversedConverter.cs24
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Editing/Caret.cs2
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Highlighting/Resources/CSharp-Mode.xshd1
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/class.pngbin0 -> 212 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/enum.pngbin0 -> 190 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/interface.pngbin0 -> 222 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/method.pngbin0 -> 276 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/namespace.pngbin0 -> 250 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/property.pngbin0 -> 316 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubclass.gifbin290 -> 0 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubevent.gifbin365 -> 0 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubmethod.gifbin599 -> 0 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubproperty.gifbin435 -> 0 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/struct.pngbin0 -> 136 bytes
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs323
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeConstructor.cs27
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMember.cs29
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs25
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethodParameter.cs16
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeProperty.cs21
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodDescription.cs20
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodPopup.cs82
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/ParameterDescription.cs26
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Rendering/TextView.cs22
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/ScriptEditor.cs717
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors.csproj40
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Themes/Generic.xaml248
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/DetectedType.cs13
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/ScriptParser.cs71
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Tango.Scripting.csproj1
34 files changed, 1575 insertions, 178 deletions
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionListBoxItem.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionListBoxItem.cs
index bb6acf69e..55d752bfd 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionListBoxItem.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionListBoxItem.cs
@@ -42,11 +42,15 @@ namespace Tango.Scripting.Editors.CodeCompletion
protected override void OnSelected(RoutedEventArgs e)
{
- base.OnSelected(e);
- toolTip.Content = DataContext;
- toolTip.ContentTemplate = ToolTipContentTemplate;
- toolTip.StaysOpen = true;
- toolTip.IsOpen = true;
+ try
+ {
+ base.OnSelected(e);
+ toolTip.Content = DataContext;
+ toolTip.ContentTemplate = ToolTipContentTemplate;
+ toolTip.StaysOpen = true;
+ toolTip.IsOpen = true;
+ }
+ catch { }
}
protected override void OnUnselected(RoutedEventArgs e)
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindow.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindow.cs
index 0e8cd781d..33759e351 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindow.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindow.cs
@@ -84,6 +84,8 @@ namespace Tango.Scripting.Editors.CodeCompletion
{
InsertionRequest?.Invoke(item);
}
+
+ completionList.SelectedItem = null;
}
void AttachEvents()
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindowBase.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindowBase.cs
index b5bab3f97..e33ede203 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindowBase.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/CodeCompletion/CompletionWindowBase.cs
@@ -79,6 +79,7 @@ namespace Tango.Scripting.Editors.CodeCompletion
public virtual void HideCompletion()
{
+ Debug.WriteLine("Hide Completion...");
DetachEvents();
Hide();
}
@@ -148,7 +149,7 @@ namespace Tango.Scripting.Editors.CodeCompletion
public override void Detach()
{
base.Detach();
- window.HideCompletion();
+ //window.HideCompletion();
}
const Key KeyDeadCharProcessed = (Key)0xac; // Key.DeadCharProcessed; // new in .NET 4
@@ -367,6 +368,8 @@ namespace Tango.Scripting.Editors.CodeCompletion
bounds = bounds.TransformFromDevice(textView);
this.Left = bounds.X;
this.Top = bounds.Y;
+
+ Debug.WriteLine($"Position: {Left}x{Top}");
}
/// <inheritdoc/>
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityConverter.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityConverter.cs
new file mode 100644
index 000000000..7412e4a67
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityConverter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Tango.Scripting.Editors.Converters
+{
+ public class BooleanToVisibilityConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Visible : Visibility.Collapsed;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityInversedConverter.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityInversedConverter.cs
new file mode 100644
index 000000000..c91aa45fd
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Converters/BooleanToVisibilityInversedConverter.cs
@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.Globalization;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Data;
+
+namespace Tango.Scripting.Editors.Converters
+{
+ public class BooleanToVisibilityInversedConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return (bool)value ? Visibility.Collapsed : Visibility.Visible;
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Editing/Caret.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Editing/Caret.cs
index 23542cd21..fb21448e5 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Editing/Caret.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Editing/Caret.cs
@@ -267,7 +267,7 @@ namespace Tango.Scripting.Editors.Editing
if (!visualColumnValid) {
TextDocument document = textArea.Document;
if (document != null) {
- Debug.WriteLine("Explicit validation of caret column");
+ //Debug.WriteLine("Explicit validation of caret column");
var documentLine = document.GetLineByNumber(position.Line);
RevalidateVisualColumn(textView.GetOrConstructVisualLine(documentLine));
}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Highlighting/Resources/CSharp-Mode.xshd b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Highlighting/Resources/CSharp-Mode.xshd
index a8ca62be2..1ba2cbc6f 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Highlighting/Resources/CSharp-Mode.xshd
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Highlighting/Resources/CSharp-Mode.xshd
@@ -220,6 +220,7 @@
<Word>uint</Word>
<Word>ushort</Word>
<Word>ulong</Word>
+ <Word>null</Word>
</Keywords>
<Keywords color="ReferenceTypes">
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/class.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/class.png
new file mode 100644
index 000000000..91b35a829
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/class.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/enum.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/enum.png
new file mode 100644
index 000000000..b79aa844f
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/enum.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/interface.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/interface.png
new file mode 100644
index 000000000..3b07597dd
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/interface.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/method.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/method.png
new file mode 100644
index 000000000..249689941
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/method.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/namespace.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/namespace.png
new file mode 100644
index 000000000..7f2b6b5ef
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/namespace.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/property.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/property.png
new file mode 100644
index 000000000..001a8c66a
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/property.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubclass.gif b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubclass.gif
deleted file mode 100644
index 28abc36a7..000000000
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubclass.gif
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubevent.gif b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubevent.gif
deleted file mode 100644
index 7c2466f0e..000000000
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubevent.gif
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubmethod.gif b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubmethod.gif
deleted file mode 100644
index 040280d15..000000000
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubmethod.gif
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubproperty.gif b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubproperty.gif
deleted file mode 100644
index 49d5042b9..000000000
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/pubproperty.gif
+++ /dev/null
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/struct.png b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/struct.png
new file mode 100644
index 000000000..02fbdbde7
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Images/struct.png
Binary files differ
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs
new file mode 100644
index 000000000..3cb61b991
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs
@@ -0,0 +1,323 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Text;
+using System.Threading.Tasks;
+using System.Xml;
+
+namespace Tango.Scripting.Editors.Intellisense
+{
+ public class KnownType
+ {
+ private static String dotNetXmlFolder = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X";
+ private static Dictionary<Assembly, XmlDocument> _assemblies_docs_cache;
+
+ private bool _initialized;
+
+ public Type Type { get; private set; }
+ public String Name { get; private set; }
+ public String TypeDefinition { get; private set; }
+ public String FriendlyName { get; private set; }
+
+ private String _summary;
+ public String Summary
+ {
+ get
+ {
+ InitTypeDocumentation();
+ return _summary;
+ }
+ private set { _summary = value; }
+ }
+
+
+ private List<KnownTypeConstructor> _constructors;
+ public List<KnownTypeConstructor> Constructors
+ {
+ get
+ {
+ InitTypeDocumentation();
+ return _constructors;
+ }
+ private set { _constructors = value; }
+ }
+
+ private List<KnownTypeMethod> _methods;
+ public List<KnownTypeMethod> Methods
+ {
+ get
+ {
+ InitTypeDocumentation();
+ return _methods;
+ }
+ private set { _methods = value; }
+ }
+
+ private List<KnownTypeProperty> _properties;
+ public List<KnownTypeProperty> Properties
+ {
+ get
+ {
+ InitTypeDocumentation();
+ return _properties;
+ }
+ private set { _properties = value; }
+ }
+
+ public List<KnownTypeMember> Members
+ {
+ get
+ {
+ List<KnownTypeMember> members = new List<KnownTypeMember>();
+
+ members.AddRange(Properties);
+ members.AddRange(Methods);
+
+ return members.OrderBy(x => x.Name).ToList();
+ }
+ }
+
+ static KnownType()
+ {
+ _assemblies_docs_cache = new Dictionary<Assembly, XmlDocument>();
+ }
+
+ public KnownType(Type type)
+ {
+ _constructors = new List<KnownTypeConstructor>();
+ _methods = new List<KnownTypeMethod>();
+ _properties = new List<KnownTypeProperty>();
+ Type = type;
+ Name = type.Name;
+ Init();
+ }
+
+ private void Init()
+ {
+ InitTypeDefinition();
+ InitFriendlyName();
+ }
+
+ private void InitFriendlyName()
+ {
+ if (Type.IsGenericType)
+ {
+ List<String> args = new List<string>();
+
+ foreach (var lGenericArgument in Type.GetGenericTypeDefinition().GetGenericArguments())
+ {
+ args.Add(lGenericArgument.Name);
+ }
+
+ String gArgs = String.Join(",", args);
+
+ FriendlyName = $"{new String(Type.Name.TakeWhile(x => x != '`').ToArray())}<{gArgs}>";
+ }
+ else
+ {
+ FriendlyName = Type.Name;
+ }
+ }
+
+ private void InitTypeDefinition()
+ {
+ if (Type.IsClass) TypeDefinition = "class";
+ else if (Type.IsEnum) TypeDefinition = "enum";
+ else if (Type.IsInterface) TypeDefinition = "interface";
+ else if (Type.IsValueType) TypeDefinition = "struct";
+ }
+
+ private void InitTypeDocumentation()
+ {
+ if (!_initialized)
+ {
+ XmlDocument xmlDoc = null;
+
+ if (_assemblies_docs_cache.ContainsKey(Type.Assembly))
+ {
+ xmlDoc = _assemblies_docs_cache[Type.Assembly];
+ }
+
+ if (xmlDoc == null)
+ {
+ String dllPath = Type.Assembly.Location;
+
+ string docuPath = dllPath.Substring(0, dllPath.LastIndexOf(".")) + ".XML";
+
+ if (File.Exists(docuPath))
+ {
+ xmlDoc = new XmlDocument();
+ xmlDoc.Load(docuPath);
+ }
+ else if (File.Exists(System.IO.Path.Combine(dotNetXmlFolder, System.IO.Path.GetFileName(docuPath))))
+ {
+ xmlDoc = new XmlDocument();
+ xmlDoc.Load(System.IO.Path.Combine(dotNetXmlFolder, System.IO.Path.GetFileName(docuPath)));
+ }
+
+ if (xmlDoc != null)
+ {
+ _assemblies_docs_cache.Add(Type.Assembly, xmlDoc);
+ }
+ }
+
+ if (xmlDoc != null)
+ {
+ //Load Type Summary
+ {
+ string path = "T:" + Type.FullName;
+ XmlNode xmlDocuOfType = xmlDoc.SelectSingleNode("//member[starts-with(@name, '" + path + "')]");
+
+ if (xmlDocuOfType != null)
+ {
+ XmlNode summaryNode = xmlDocuOfType.SelectSingleNode("summary");
+ Summary = summaryNode.InnerText;
+ }
+ }
+
+ //Load Constructors...
+ {
+ string path = "M:" + Type.FullName + ".#ctor";
+
+ var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
+ var constructors = Type.GetConstructors().Where(x => x.IsPublic).ToList();
+
+ for (int i = 0; i < constructors.Count; i++)
+ {
+ var constructor = constructors[i];
+ XmlNode cDoc = null;
+
+ if (i < docNodes.Count)
+ {
+ cDoc = docNodes[i];
+ }
+
+ KnownTypeConstructor c = new KnownTypeConstructor(this);
+ c.Summary = cDoc != null ? cDoc.SelectSingleNode("summary").InnerText : $"Initializes a new instance of {FriendlyName}.";
+
+ var parameters = constructor.GetParameters().ToList();
+ var parametersNodes = cDoc != null ? cDoc.SelectNodes("param").OfType<XmlNode>().ToList() : new List<XmlNode>();
+
+ for (int j = 0; j < parameters.Count; j++)
+ {
+ var parameter = parameters[j];
+ XmlNode pNode = null;
+
+ if (j < parametersNodes.Count)
+ {
+ pNode = parametersNodes[j];
+ }
+
+ KnownTypeMethodParameter p = new KnownTypeMethodParameter();
+ p.Type = parameter.ParameterType;
+ p.Name = parameter.Name;
+ p.Description = pNode != null ? pNode.InnerText : null;
+
+ if (j == parameters.Count - 1)
+ {
+ p.IsLast = true;
+ }
+
+ c.Parameters.Add(p);
+ }
+
+ _constructors.Add(c);
+ }
+ }
+
+ //Load Methods...
+ {
+ string path = "M:" + Type.FullName;
+
+ var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
+ var methods = Type.GetRuntimeMethods().Where(x => x.IsPublic && !x.IsSpecialName).ToList();
+
+ //TODO: Separate extension methods!
+ methods.AddRange(Type.GetExtensionMethods(Type.Assembly).ToList());
+
+ for (int i = 0; i < methods.Count; i++)
+ {
+ var method = methods[i];
+ XmlNode mDoc = null;
+
+ mDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(method.DeclaringType.Name + "." + method.Name));
+
+ KnownTypeMethod m = new KnownTypeMethod(this);
+ m.Summary = mDoc != null ? mDoc.SelectSingleNode("summary").InnerText : "No documentation";
+ m.Name = method.Name;
+ m.ReturnType = method.ReturnType;
+ m.ReturnTypeFriendlyName = method.ReturnType.Name;
+
+ if (method.ReturnType.IsGenericType)
+ {
+ List<String> args = new List<string>();
+
+ foreach (var lGenericArgument in m.ReturnType.GetGenericTypeDefinition().GetGenericArguments())
+ {
+ args.Add(lGenericArgument.Name);
+ }
+
+ String gArgs = String.Join(",", args);
+
+ m.ReturnTypeFriendlyName = $"{new String(Type.Name.TakeWhile(x => x != '`').ToArray())}<{gArgs}>";
+ }
+
+ var parameters = method.GetParameters().ToList();
+ var parametersNodes = mDoc != null ? mDoc.SelectNodes("param").OfType<XmlNode>().ToList() : new List<XmlNode>();
+
+ for (int j = 0; j < parameters.Count; j++)
+ {
+ var parameter = parameters[j];
+ XmlNode pNode = null;
+
+ if (j < parametersNodes.Count)
+ {
+ pNode = parametersNodes[j];
+ }
+
+ KnownTypeMethodParameter p = new KnownTypeMethodParameter();
+ p.Type = parameter.ParameterType;
+ p.Name = parameter.Name;
+ p.Description = pNode != null ? pNode.InnerText : null;
+
+ if (j == parameters.Count - 1)
+ {
+ p.IsLast = true;
+ }
+
+ m.Parameters.Add(p);
+ }
+
+ _methods.Add(m);
+ }
+ }
+
+ //Load Properties
+ {
+ string path = "P:" + Type.FullName;
+
+ var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
+ var properties = Type.GetProperties(BindingFlags.Public | BindingFlags.Instance).Where(x => x.PropertyType.IsPublic).ToList();
+
+ for (int i = 0; i < properties.Count; i++)
+ {
+ var property = properties[i];
+ var pDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(property.DeclaringType.Name + "." + property.Name));
+
+ KnownTypeProperty p = new KnownTypeProperty(this);
+ p.Summary = pDoc != null ? pDoc.SelectSingleNode("summary").InnerText : "No documentation";
+ p.Name = property.Name;
+ p.ReturnType = property.PropertyType;
+
+ _properties.Add(p);
+ }
+ }
+ }
+
+ _initialized = true;
+ }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeConstructor.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeConstructor.cs
new file mode 100644
index 000000000..273d61084
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeConstructor.cs
@@ -0,0 +1,27 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Intellisense
+{
+ public class KnownTypeConstructor
+ {
+ public KnownType Type { get; set; }
+
+ public String Summary { get; set; }
+
+ public List<KnownTypeMethodParameter> Parameters { get; set; }
+
+ public KnownTypeConstructor()
+ {
+ Parameters = new List<KnownTypeMethodParameter>();
+ }
+
+ public KnownTypeConstructor(KnownType knownType) : this()
+ {
+ Type = knownType;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMember.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMember.cs
new file mode 100644
index 000000000..d3d8cb428
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMember.cs
@@ -0,0 +1,29 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Intellisense
+{
+ public abstract class KnownTypeMember
+ {
+ public Type ReturnType { get; set; }
+
+ public KnownType Type { get; set; }
+
+ public String Summary { get; set; }
+
+ public String Name { get; set; }
+
+ public KnownTypeMember()
+ {
+
+ }
+
+ public KnownTypeMember(KnownType knownType) : this()
+ {
+ Type = knownType;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs
new file mode 100644
index 000000000..27b052978
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Intellisense
+{
+ public class KnownTypeMethod : KnownTypeMember
+ {
+ public String ReturnTypeFriendlyName { get; set; }
+
+ public List<KnownTypeMethodParameter> Parameters { get; set; }
+
+ public KnownTypeMethod()
+ {
+ Parameters = new List<KnownTypeMethodParameter>();
+ }
+
+ public KnownTypeMethod(KnownType knownType) : this()
+ {
+ Type = knownType;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethodParameter.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethodParameter.cs
new file mode 100644
index 000000000..c4f2a62c5
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethodParameter.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Intellisense
+{
+ public class KnownTypeMethodParameter
+ {
+ public Type Type { get; set; }
+ public String Name { get; set; }
+ public String Description { get; set; }
+ public bool IsLast { get; set; }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeProperty.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeProperty.cs
new file mode 100644
index 000000000..a77dd7dc2
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeProperty.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Intellisense
+{
+ public class KnownTypeProperty : KnownTypeMember
+ {
+ public KnownTypeProperty()
+ {
+
+ }
+
+ public KnownTypeProperty(KnownType knownType) : this()
+ {
+ Type = knownType;
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodDescription.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodDescription.cs
new file mode 100644
index 000000000..864072952
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodDescription.cs
@@ -0,0 +1,20 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Popups
+{
+ public class MethodDescription
+ {
+ public String Description { get; set; }
+ public String ReturnType { get; set; }
+ public List<ParameterDescription> Parameters { get; set; }
+
+ public MethodDescription()
+ {
+ Parameters = new List<ParameterDescription>();
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodPopup.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodPopup.cs
new file mode 100644
index 000000000..7c431f9b4
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/MethodPopup.cs
@@ -0,0 +1,82 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace Tango.Scripting.Editors.Popups
+{
+ public class MethodPopup : Control
+ {
+ public List<MethodDescription> Methods { get; set; }
+
+ public int CurrentMethodIndex
+ {
+ get { return (int)GetValue(CurrentMethodIndexProperty); }
+ set { SetValue(CurrentMethodIndexProperty, value); }
+ }
+ public static readonly DependencyProperty CurrentMethodIndexProperty =
+ DependencyProperty.Register("CurrentMethodIndex", typeof(int), typeof(MethodPopup), new PropertyMetadata(1));
+
+ public MethodDescription CurrentMethod
+ {
+ get { return (MethodDescription)GetValue(CurrentMethodProperty); }
+ set { SetValue(CurrentMethodProperty, value); }
+ }
+ public static readonly DependencyProperty CurrentMethodProperty =
+ DependencyProperty.Register("CurrentMethod", typeof(MethodDescription), typeof(MethodPopup), new PropertyMetadata(null));
+
+ public void IncrementMethod()
+ {
+ if (Methods.Count > 0)
+ {
+ if (CurrentMethodIndex < Methods.Count)
+ {
+ CurrentMethodIndex++;
+ CurrentMethod = Methods[CurrentMethodIndex - 1];
+ }
+ else
+ {
+ CurrentMethodIndex = 1;
+ CurrentMethod = Methods[0];
+ }
+ }
+ }
+
+ public void DecrementMethod()
+ {
+ if (Methods.Count > 0)
+ {
+ if (CurrentMethodIndex > 1)
+ {
+ CurrentMethodIndex--;
+ CurrentMethod = Methods[CurrentMethodIndex - 1];
+ }
+ else
+ {
+ CurrentMethodIndex = Methods.Count;
+ CurrentMethod = Methods[Methods.Count - 1];
+ }
+ }
+ }
+
+ public MethodPopup()
+ {
+ Methods = new List<MethodDescription>();
+ }
+
+ static MethodPopup()
+ {
+ DefaultStyleKeyProperty.OverrideMetadata(typeof(MethodPopup), new FrameworkPropertyMetadata(typeof(MethodPopup)));
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/ParameterDescription.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/ParameterDescription.cs
new file mode 100644
index 000000000..6650f76ec
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Popups/ParameterDescription.cs
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Tango.Scripting.Editors.Popups
+{
+ public class ParameterDescription
+ {
+ public ParameterDescription(MethodDescription method)
+ {
+ Method = method;
+ }
+
+ public MethodDescription Method { get; set; }
+ public String Type { get; set; }
+ public String Name { get; set; }
+ public String Description { get; set; }
+
+ public bool IsLast
+ {
+ get { return Method.Parameters.Last() == this; }
+ }
+ }
+}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Rendering/TextView.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Rendering/TextView.cs
index 6bbf13618..3dabb6b7a 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Rendering/TextView.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Rendering/TextView.cs
@@ -800,9 +800,14 @@ namespace Tango.Scripting.Editors.Rendering
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1065:DoNotRaiseExceptionsInUnexpectedLocations")]
public ReadOnlyCollection<VisualLine> VisualLines {
get {
- if (visibleVisualLines == null)
- throw new VisualLinesInvalidException();
- return visibleVisualLines;
+ if (visibleVisualLines == null)
+ {
+ return new ReadOnlyCollection<VisualLine>(new List<VisualLine>());
+ }
+ else
+ {
+ return visibleVisualLines;
+ }
}
}
@@ -848,11 +853,12 @@ namespace Tango.Scripting.Editors.Rendering
// Sometimes we still have invalid lines after UpdateLayout - work around the problem
// by calling MeasureOverride directly.
if (!VisualLinesValid) {
- Debug.WriteLine("UpdateLayout() failed in EnsureVisualLines");
- MeasureOverride(lastAvailableSize);
- }
- if (!VisualLinesValid)
- throw new VisualLinesInvalidException("Internal error: visual lines invalid after EnsureVisualLines call");
+ //Debug.WriteLine("UpdateLayout() failed in EnsureVisualLines");
+ //MeasureOverride(lastAvailableSize);
+ // UpdateLayout();
+ }
+ //if (!VisualLinesValid)
+ //throw new VisualLinesInvalidException("Internal error: visual lines invalid after EnsureVisualLines call");
}
#endregion
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/ScriptEditor.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/ScriptEditor.cs
index 316b95ed7..3370ca0ee 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/ScriptEditor.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/ScriptEditor.cs
@@ -1,4 +1,5 @@
using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
@@ -11,6 +12,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
+using System.Windows.Controls.Primitives;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
@@ -27,6 +29,9 @@ using Tango.Scripting.Editors.Editing;
using Tango.Scripting.Editors.Folding;
using Tango.Scripting.Editors.Highlighting;
using Tango.Scripting.Editors.Highlighting.Xshd;
+using Tango.Scripting.Editors.Intellisense;
+using Tango.Scripting.Editors.Popups;
+using Tango.Scripting.Editors.Rendering;
using Tango.Scripting.Parsing;
namespace Tango.Scripting.Editors
@@ -35,18 +40,16 @@ namespace Tango.Scripting.Editors
{
private char[] word_separators = { ' ', '\t', '\n', '.', '(', ',', '-', '*', '/', '+', '$', '=' };
private string[] _blocking_type_words = { "class", "void" };
- private String dotNetXmlFolder = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X";
private DispatcherTimer _update_timer;
+ private Popup _popup;
private FoldingManager foldingManager;
private BraceFoldingStrategy foldingStrategy;
private CompletionWindow completionWindow;
private ScriptParser _parser;
private List<String> _current_usings;
- private List<Type> _knownTypes;
+ private List<KnownType> _knownTypes;
private List<INamedTypeSymbol> _declaredTypes;
- private Dictionary<Type, String> _known_types_docs_cache;
- private Dictionary<Assembly, XmlDocument> _assemblies_docs_cache;
#region Mini Classes
@@ -56,6 +59,20 @@ namespace Tango.Scripting.Editors
public int Index { get; set; }
}
+ private class ConstructionSession
+ {
+ public KnownType Type { get; set; }
+ public int ParameterIndex { get; set; }
+ public List<String> TypeArguments { get; set; }
+ }
+
+ private class MethodSession
+ {
+ public KnownType Type { get; set; }
+ public int ParameterIndex { get; set; }
+ public List<String> TypeArguments { get; set; }
+ }
+
#endregion
#region Completion
@@ -64,7 +81,7 @@ namespace Tango.Scripting.Editors
/// Represents an auto complete item.
/// </summary>
/// <seealso cref="ICSharpCode.AvalonEdit.CodeCompletion.ICompletionData" />
- internal class CompletionData : DependencyObject, ICompletionData
+ internal class TypeCompletionData : DependencyObject, ICompletionData
{
private String _description;
@@ -74,12 +91,13 @@ namespace Tango.Scripting.Editors
public BitmapSource Source { get; set; }
/// <summary>
- /// Initializes a new instance of the <see cref="CompletionData"/> class.
+ /// Initializes a new instance of the <see cref="TypeCompletionData"/> class.
/// </summary>
/// <param name="name">The text.</param>
/// <param name="description">The description.</param>
- public CompletionData(String type, string name, String ns, String description)
+ public TypeCompletionData(String type, string name, String ns, String description)
{
+
Type = type;
this.Text = name;
Namespace = ns;
@@ -143,7 +161,7 @@ namespace Tango.Scripting.Editors
set { SetValue(IsSelectedProperty, value); }
}
public static readonly DependencyProperty IsSelectedProperty =
- DependencyProperty.Register("IsSelected", typeof(bool), typeof(CompletionData), new PropertyMetadata(false, IsSelectedChanged));
+ DependencyProperty.Register("IsSelected", typeof(bool), typeof(TypeCompletionData), new PropertyMetadata(false, IsSelectedChanged));
private static void IsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
@@ -164,6 +182,209 @@ namespace Tango.Scripting.Editors
}
}
+ internal class MethodCompletionData : DependencyObject, ICompletionData
+ {
+ private String _description;
+
+ /// <summary>
+ /// Gets or sets the icon source.
+ /// </summary>
+ public BitmapSource Source { get; set; }
+
+ public String ReturnType { get; set; }
+
+ public String Type { get; set; }
+
+ public String Class { get; set; }
+
+ public int Overloads { get; set; }
+
+ public List<KnownTypeMethodParameter> Parameters { get; set; }
+
+ public bool HasOverloads
+ {
+ get { return Overloads > 0; }
+ }
+
+ public MethodCompletionData(String cls, string name, String returnType, String description, List<KnownTypeMethodParameter> parameters, int overloads)
+ {
+ Type = "method";
+ Parameters = parameters;
+ Class = cls;
+ this.Text = name;
+ Overloads = overloads;
+ ReturnType = returnType;
+ _description = description;
+ }
+
+ /// <summary>
+ /// Gets the image.
+ /// </summary>
+ public System.Windows.Media.ImageSource Image
+ {
+ get { return Source; }
+ }
+
+ /// <summary>
+ /// Gets the text. This property is used to filter the list of visible elements.
+ /// </summary>
+ public string Text { get; private set; }
+
+ // Use this property if you want to show a fancy UIElement in the drop down list.
+ public object Content
+ {
+ get { return this.Text; }
+ }
+
+ /// <summary>
+ /// Gets the description.
+ /// </summary>
+ public object Description
+ {
+ get { return _description; }
+ }
+
+ /// <summary>
+ /// Gets the priority. This property is used in the selection logic. You can use it to prefer selecting those items
+ /// which the user is accessing most frequently.
+ /// </summary>
+ public double Priority { get { return 0; } }
+
+ /// <summary>
+ /// Perform the completion.
+ /// </summary>
+ /// <param name="textArea">The text area on which completion is performed.</param>
+ /// <param name="completionSegment">The text segment that was used by the completion window if
+ /// the user types (segment between CompletionWindow.StartOffset and CompletionWindow.EndOffset).</param>
+ /// <param name="insertionRequestEventArgs">The EventArgs used for the insertion request.
+ /// These can be TextCompositionEventArgs, KeyEventArgs, MouseEventArgs, depending on how
+ /// the insertion was triggered.</param>
+ public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
+ {
+ textArea.Document.Replace(completionSegment, this.Text);
+ }
+
+ public bool IsSelected
+ {
+ get { return (bool)GetValue(IsSelectedProperty); }
+ set { SetValue(IsSelectedProperty, value); }
+ }
+ public static readonly DependencyProperty IsSelectedProperty =
+ DependencyProperty.Register("IsSelected", typeof(bool), typeof(MethodCompletionData), new PropertyMetadata(false, IsSelectedChanged));
+
+ private static void IsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ Debug.WriteLine("Selected");
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String" /> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String" /> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return Text;
+ }
+ }
+
+ internal class PropertyCompletionData : DependencyObject, ICompletionData
+ {
+ private String _description;
+
+ /// <summary>
+ /// Gets or sets the icon source.
+ /// </summary>
+ public BitmapSource Source { get; set; }
+
+ public String ReturnType { get; set; }
+
+ public String Type { get; set; }
+
+ public String Class { get; set; }
+
+ public PropertyCompletionData(String cls, string name, String returnType, String description)
+ {
+ Type = "property";
+ Class = cls;
+ this.Text = name;
+ ReturnType = returnType;
+ _description = description;
+ }
+
+ /// <summary>
+ /// Gets the image.
+ /// </summary>
+ public System.Windows.Media.ImageSource Image
+ {
+ get { return Source; }
+ }
+
+ /// <summary>
+ /// Gets the text. This property is used to filter the list of visible elements.
+ /// </summary>
+ public string Text { get; private set; }
+
+ // Use this property if you want to show a fancy UIElement in the drop down list.
+ public object Content
+ {
+ get { return this.Text; }
+ }
+
+ /// <summary>
+ /// Gets the description.
+ /// </summary>
+ public object Description
+ {
+ get { return _description; }
+ }
+
+ /// <summary>
+ /// Gets the priority. This property is used in the selection logic. You can use it to prefer selecting those items
+ /// which the user is accessing most frequently.
+ /// </summary>
+ public double Priority { get { return 0; } }
+
+ /// <summary>
+ /// Perform the completion.
+ /// </summary>
+ /// <param name="textArea">The text area on which completion is performed.</param>
+ /// <param name="completionSegment">The text segment that was used by the completion window if
+ /// the user types (segment between CompletionWindow.StartOffset and CompletionWindow.EndOffset).</param>
+ /// <param name="insertionRequestEventArgs">The EventArgs used for the insertion request.
+ /// These can be TextCompositionEventArgs, KeyEventArgs, MouseEventArgs, depending on how
+ /// the insertion was triggered.</param>
+ public void Complete(TextArea textArea, ISegment completionSegment, EventArgs insertionRequestEventArgs)
+ {
+ textArea.Document.Replace(completionSegment, this.Text);
+ }
+
+ public bool IsSelected
+ {
+ get { return (bool)GetValue(IsSelectedProperty); }
+ set { SetValue(IsSelectedProperty, value); }
+ }
+ public static readonly DependencyProperty IsSelectedProperty =
+ DependencyProperty.Register("IsSelected", typeof(bool), typeof(PropertyCompletionData), new PropertyMetadata(false, IsSelectedChanged));
+
+ private static void IsSelectedChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
+ {
+ Debug.WriteLine("Selected");
+ }
+
+ /// <summary>
+ /// Returns a <see cref="System.String" /> that represents this instance.
+ /// </summary>
+ /// <returns>
+ /// A <see cref="System.String" /> that represents this instance.
+ /// </returns>
+ public override string ToString()
+ {
+ return Text;
+ }
+ }
+
#endregion
#region Properties
@@ -201,6 +422,15 @@ namespace Tango.Scripting.Editors
public static readonly DependencyProperty ReferenceAssembliesProperty =
DependencyProperty.Register("ReferenceAssemblies", typeof(ObservableCollection<ReferenceAssembly>), typeof(ScriptEditor), new PropertyMetadata(null));
+ public Object CurrentPopupContent
+ {
+ get { return (Object)GetValue(CurrentPopupContentProperty); }
+ set { SetValue(CurrentPopupContentProperty, value); }
+ }
+ public static readonly DependencyProperty CurrentPopupContentProperty =
+ DependencyProperty.Register("CurrentPopupContent", typeof(Object), typeof(ScriptEditor), new PropertyMetadata(null));
+
+
#endregion
#region Constructors
@@ -218,8 +448,6 @@ namespace Tango.Scripting.Editors
/// </summary>
public ScriptEditor()
{
- _known_types_docs_cache = new Dictionary<Type, string>();
- _assemblies_docs_cache = new Dictionary<Assembly, XmlDocument>();
_declaredTypes = new List<INamedTypeSymbol>();
_current_usings = new List<string>();
@@ -230,7 +458,7 @@ namespace Tango.Scripting.Editors
ReferenceAssemblies.Add(new ReferenceAssembly(typeof(String))); //mscorelib
ReferenceAssemblies.Add(new ReferenceAssembly(typeof(Enumerable))); //System.Core
- _knownTypes = new List<Type>();
+ _knownTypes = new List<KnownType>();
_parser = new ScriptParser();
TextArea.IndentationStrategy = new Indentation.CSharp.CSharpIndentationStrategy(Options);
@@ -410,6 +638,146 @@ namespace Tango.Scripting.Editors
return GetWordByEndIndex(index);
}
+ private ConstructionSession GetConstructionSession()
+ {
+ var expression = _parser.GetCurrentConstructionExpression(GetCurrentLineText());
+
+ if (expression != null)
+ {
+ ConstructionSession session = new ConstructionSession();
+
+ var line = GetCurrentLine();
+ int parameterIndex = 0;
+ for (int i = CaretOffset; i > line.Offset; i--)
+ {
+ String c = Document.GetText(i, 1);
+
+ if (c == "(")
+ {
+ var typeDeclaration = expression.Type as GenericNameSyntax;
+
+ KnownType type = null;
+
+ if (typeDeclaration != null)
+ {
+ var typeName = typeDeclaration.Identifier.ToString();
+ var argumentsCount = typeDeclaration.TypeArgumentList.Arguments.Count;
+ session.TypeArguments = typeDeclaration.TypeArgumentList.Arguments.Select(x => x.ToString()).ToList();
+
+ if (argumentsCount == 0)
+ {
+ type = _knownTypes.FirstOrDefault(x => x.Type.Name == expression.Type.ToString());
+ }
+ else
+ {
+ type = _knownTypes.FirstOrDefault(x => x.Type.Name == typeName + "`" + argumentsCount);
+ }
+ }
+ else
+ {
+ type = _knownTypes.FirstOrDefault(x => x.Name == expression.Type.ToString());
+ }
+
+ if (type != null)
+ {
+ session.Type = type;
+ session.ParameterIndex = parameterIndex;
+ return session;
+ }
+ else
+ {
+ return null;
+ }
+ }
+ else if (c == ",")
+ {
+ parameterIndex++;
+ }
+
+ }
+ }
+
+ return null;
+ }
+
+ //private MethodSession GetMethodSession()
+ //{
+ // var lineText = GetCurrentLineText();
+ // var expression = lineText.Split(' ').ToList().LastOrDefault();
+
+ // if (expression != null)
+ // {
+
+ // }
+
+
+ // var expression = _parser.GetExpression<InvocationExpressionSyntax>(GetCurrentLineText());
+
+ // if (expression != null)
+ // {
+ // MethodSession session = new MethodSession();
+
+ // var line = GetCurrentLine();
+ // int parameterIndex = 0;
+ // for (int i = CaretOffset; i > line.Offset; i--)
+ // {
+ // String c = Document.GetText(i, 1);
+
+ // if (c == "(")
+ // {
+ // //var typeDeclaration = expression.Type as GenericNameSyntax;
+
+ // //KnownType type = null;
+
+ // //if (typeDeclaration != null)
+ // //{
+ // // var typeName = typeDeclaration.Identifier.ToString();
+ // // var argumentsCount = typeDeclaration.TypeArgumentList.Arguments.Count;
+ // // session.TypeArguments = typeDeclaration.TypeArgumentList.Arguments.Select(x => x.ToString()).ToList();
+
+ // // if (argumentsCount == 0)
+ // // {
+ // // type = _knownTypes.FirstOrDefault(x => x.Type.Name == expression.Type.ToString());
+ // // }
+ // // else
+ // // {
+ // // type = _knownTypes.FirstOrDefault(x => x.Type.Name == typeName + "`" + argumentsCount);
+ // // }
+ // //}
+ // //else
+ // //{
+ // // type = _knownTypes.FirstOrDefault(x => x.Name == expression.Type.ToString());
+ // //}
+
+ // //if (type != null)
+ // //{
+ // // session.Type = type;
+ // // session.ParameterIndex = parameterIndex;
+ // // return session;
+ // //}
+ // //else
+ // //{
+ // // return null;
+ // //}
+ // }
+ // else if (c == ",")
+ // {
+ // parameterIndex++;
+ // }
+
+ // }
+ // }
+
+ // return null;
+ //}
+
+ public List<String> GetPreviousWords()
+ {
+ var currentLine = GetCurrentLine();
+ var currentText = Document.GetText(currentLine.Offset, CaretOffset - currentLine.Offset);
+ return currentText.Split(' ').ToList();
+ }
+
#endregion
#region Highlighting
@@ -431,7 +799,7 @@ namespace Tango.Scripting.Editors
{
lock (_knownTypes)
{
- _knownTypes.Add(type);
+ _knownTypes.Add(new KnownType(type));
}
}
});
@@ -453,22 +821,25 @@ namespace Tango.Scripting.Editors
List<String> referenceTypes = new List<string>();
List<String> interfaceTypes = new List<string>();
- foreach (var type in _knownTypes)
+ lock (_knownTypes)
{
- String name = type.Name;
-
- if (type.ContainsGenericParameters)
+ foreach (var type in _knownTypes.ToList().Where(x => x != null))
{
- name = new String(name.TakeWhile(x => x != '`').ToArray());
- }
+ String name = type.Name;
- if (type.IsClass || (type.IsValueType && !type.IsPrimitive))
- {
- referenceTypes.Add(String.Format("<Word>{0}</Word>", name));
- }
- else if (type.IsInterface || type.IsEnum)
- {
- interfaceTypes.Add(String.Format("<Word>{0}</Word>", name));
+ if (type.Type.ContainsGenericParameters)
+ {
+ name = new String(name.TakeWhile(x => x != '`').ToArray());
+ }
+
+ if (type.Type.IsInterface || type.Type.IsEnum)
+ {
+ interfaceTypes.Add(String.Format("<Word>{0}</Word>", name));
+ }
+ else if (type.Type.IsClass)
+ {
+ referenceTypes.Add(String.Format("<Word>{0}</Word>", name));
+ }
}
}
@@ -545,12 +916,40 @@ namespace Tango.Scripting.Editors
/// <param name="e">The <see cref="T:System.Windows.Input.KeyEventArgs" /> that contains the event data.</param>
protected override void OnPreviewKeyDown(KeyEventArgs e)
{
+ if (CurrentPopupContent is MethodPopup && (e.Key == Key.Down || e.Key == Key.Up))
+ {
+ e.Handled = true;
+
+ if (e.Key == Key.Down)
+ {
+ (CurrentPopupContent as MethodPopup).IncrementMethod();
+ }
+ else if (e.Key == Key.Up)
+ {
+ (CurrentPopupContent as MethodPopup).DecrementMethod();
+ }
+
+ return;
+ }
+
base.OnPreviewKeyDown(e);
+ HidePopup();
HandleKeyCombinations(e);
}
#endregion
+ #region Apply Template
+
+ public override void OnApplyTemplate()
+ {
+ base.OnApplyTemplate();
+
+ _popup = GetTemplateChild("PART_popup") as Popup;
+ }
+
+ #endregion
+
#region Key Combination Handling
/// <summary>
@@ -605,11 +1004,118 @@ namespace Tango.Scripting.Editors
{
List<Object> items = new List<object>();
- if (e.Text == ".")
+ HidePopup();
+
+ var lineText = GetCurrentLineText();
+ var previousWordsLast = GetPreviousWords().LastOrDefault();
+ String currentWord = previousWordsLast != null ? previousWordsLast.Replace("\t", "") : String.Empty;
+
+
+ if (e.Text == ";" || e.Text == " ")
{
- var word = GetCurrentWord();
+ HideCompletionWindow();
}
- else
+ else if (e.Text == ".")
+ {
+ var expression = GetPreviousWords().LastOrDefault();
+
+ if (expression != null)
+ {
+ var tree = expression.Split('.').Select(x => x.Replace("\n", "").Replace("\r", "").Replace(" ", "").Replace("\t", "").Replace("(", "").Replace(")", "")).ToList();
+ var variableName = tree.FirstOrDefault();
+
+ if (variableName != null)
+ {
+ tree.RemoveAt(0);
+ var variables = _parser.GetScriptVariables(Document.Text);
+ var variable = variables.FirstOrDefault(x => x.Name == variableName);
+
+ if (variable != null)
+ {
+ var knownType = _knownTypes.FirstOrDefault(x => x.FriendlyName == variable.Type);
+
+ if (knownType != null)
+ {
+ while (tree.Count > 1)
+ {
+ var memberName = tree.First();
+ tree.RemoveAt(0);
+ var member = knownType.Members.FirstOrDefault(x => x.Name == memberName);
+
+ if (member == null)
+ {
+ return;
+ }
+
+ knownType = _knownTypes.FirstOrDefault(x => x.Type == member.ReturnType);
+ }
+
+ if (knownType != null)
+ {
+ completionWindow.HideCompletion();
+ IList<ICompletionData> data = new List<ICompletionData>();
+
+ var typeMembers = knownType.Members.ToList();
+
+ foreach (var methodGroup in typeMembers.GroupBy(x => x.Name))
+ {
+ var member = methodGroup.First();
+
+ if (member.GetType() == typeof(KnownTypeMethod))
+ {
+ var method = member as KnownTypeMethod;
+ data.Add(new MethodCompletionData(knownType.FriendlyName, method.Name, method.ReturnTypeFriendlyName, method.Summary, method.Parameters, methodGroup.Count() - 1));
+ }
+ else
+ {
+ data.Add(new PropertyCompletionData(knownType.FriendlyName, member.Name, member.ReturnType.Name, member.Summary));
+ }
+ }
+
+ ShowCompletionWindow(data, GetCurrentWord());
+ }
+ }
+ }
+ }
+ }
+ }
+ else if (e.Text == "(" || e.Text == ",")
+ {
+ completionWindow.HideCompletion();
+
+ var session = GetConstructionSession();
+
+ if (session != null)
+ {
+ var content = CreateConstructionSessionPopupContent(session);
+ if (content.Methods.Count > 0)
+ {
+ ShowPopup(content);
+ }
+ }
+
+ //var methodSession = GetMethodSession();
+
+ //if (methodSession != null)
+ //{
+
+ //}
+ }
+ else if (lineText.StartsWith("using"))
+ {
+ IList<ICompletionData> data = new List<ICompletionData>();
+
+ foreach (var asm in ReferenceAssemblies)
+ {
+ foreach (var ns in asm.Assembly.GetTypes().Select(x => x.Namespace).Distinct().Where(x => x != null))
+ {
+ data.Add(new TypeCompletionData("namespace", ns, "", asm.Assembly.GetName().Name));
+ }
+ }
+
+ ShowCompletionWindow(data, GetCurrentWord());
+ }
+ else if (!currentWord.Contains("."))
{
var previous_word = GetPreviousWord();
var word = GetCurrentWord();
@@ -631,33 +1137,19 @@ namespace Tango.Scripting.Editors
{
if (char.IsUpper(word.First()))
{
- IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
- data.Clear();
+ IList<ICompletionData> data = new List<ICompletionData>();
foreach (var type in _declaredTypes.Where(x => x.Name.StartsWith(word)))
{
- data.Add(new CompletionData(type.TypeKind.ToString().ToLower(), type.Name, type.ContainingNamespace?.Name, "Declared inside the current script..."));
+ data.Add(new TypeCompletionData(type.TypeKind.ToString().ToLower(), type.Name, type.ContainingNamespace?.Name, "Declared inside the current script..."));
}
foreach (var type in _knownTypes.Where(x => x.Name.StartsWith(word)))
{
- String doc = GetKnownTypeDocumentation(type);
- data.Add(new CompletionData(GetTypeOfType(type), type.Name, type.Namespace, doc));
+ data.Add(new TypeCompletionData(type.TypeDefinition, type.FriendlyName, type.Type.Namespace, type.Summary));
}
- if (data.Count > 0)
- {
- completionWindow.ShowCompletion();
-
- if (completionWindow.CompletionList.ListBox != null)
- {
- completionWindow.CompletionList.SelectItemFiltering(word);
- }
- }
- else
- {
- completionWindow.HideCompletion();
- }
+ ShowCompletionWindow(data, word);
}
}
}
@@ -671,61 +1163,34 @@ namespace Tango.Scripting.Editors
Document.Replace(index, Math.Min(max - index, item.Text.Length), item.Text);
}
- private String GetKnownTypeDocumentation(Type type)
+ private void ShowCompletionWindow(IList<ICompletionData> suggestions, String filter)
{
- if (_known_types_docs_cache.ContainsKey(type))
- {
- return _known_types_docs_cache[type];
- }
+ IList<ICompletionData> data = completionWindow.CompletionList.CompletionData;
+ data.Clear();
- XmlDocument _docuDoc = null;
-
- if (_assemblies_docs_cache.ContainsKey(type.Assembly))
+ foreach (var item in suggestions)
{
- _docuDoc = _assemblies_docs_cache[type.Assembly];
+ data.Add(item);
}
- if (_docuDoc == null)
+ if (data.Count > 0)
{
- String dllPath = type.Assembly.Location;
-
- string docuPath = dllPath.Substring(0, dllPath.LastIndexOf(".")) + ".XML";
+ completionWindow.ShowCompletion();
- if (File.Exists(docuPath))
+ if (completionWindow.CompletionList.ListBox != null)
{
- _docuDoc = new XmlDocument();
- _docuDoc.Load(docuPath);
+ completionWindow.CompletionList.SelectItemFiltering(filter);
}
- else if (File.Exists(System.IO.Path.Combine(dotNetXmlFolder, System.IO.Path.GetFileName(docuPath))))
- {
- _docuDoc = new XmlDocument();
- _docuDoc.Load(System.IO.Path.Combine(dotNetXmlFolder, System.IO.Path.GetFileName(docuPath)));
- }
-
- _assemblies_docs_cache.Add(type.Assembly, _docuDoc);
}
-
- if (_docuDoc != null)
+ else
{
- string path = "T:" + type.FullName;
- XmlNode xmlDocuOfType = _docuDoc.SelectSingleNode("//member[starts-with(@name, '" + path + "')]");
-
- _known_types_docs_cache.Add(type, xmlDocuOfType.InnerText);
-
- return xmlDocuOfType.InnerText;
+ completionWindow.HideCompletion();
}
-
- return String.Empty;
}
- private String GetTypeOfType(Type type)
+ private void HideCompletionWindow()
{
- if (type.IsClass) return "class";
- if (type.IsEnum) return "enum";
- if (type.IsInterface) return "interface";
- if (type.IsValueType) return "struct";
-
- return "";
+ completionWindow.HideCompletion();
}
private List<String> GetScriptClassNames()
@@ -776,5 +1241,85 @@ namespace Tango.Scripting.Editors
}
#endregion
+
+ #region Popup
+
+ private void ShowPopup(Object content)
+ {
+ var position = TextArea.Caret.Position;
+ var textView = TextArea.TextView;
+
+ var visualLocation = textView.GetVisualPosition(position, VisualYPosition.LineBottom);
+ var visualLocationTop = textView.GetVisualPosition(position, VisualYPosition.LineTop);
+
+ Point location = textView.PointToScreen(visualLocation - textView.ScrollOffset);
+ Point locationTop = textView.PointToScreen(visualLocationTop - textView.ScrollOffset);
+
+ _popup.Placement = PlacementMode.Absolute;
+ _popup.PlacementRectangle = new Rect(location, new Size(200, 100));
+
+ CurrentPopupContent = content;
+
+ _popup.IsOpen = true;
+ }
+
+ private void HidePopup()
+ {
+ _popup.IsOpen = false;
+ CurrentPopupContent = null;
+ }
+
+ private MethodPopup CreateConstructionSessionPopupContent(ConstructionSession session)
+ {
+ MethodPopup popup = new MethodPopup();
+
+ foreach (var c in session.Type.Constructors)
+ {
+ MethodDescription method = new MethodDescription();
+ method.ReturnType = session.Type.Name;
+ method.Description = c.Summary;
+
+ if (session.Type.Type.IsGenericType && session.TypeArguments != null)
+ {
+ method.ReturnType = new String(session.Type.Name.TakeWhile(x => x != '`').ToArray()) + $"<{String.Join(",", session.TypeArguments)}>";
+ }
+
+ var parameters = c.Parameters;
+
+ foreach (var p in parameters)
+ {
+ ParameterDescription pDescription = new ParameterDescription(method);
+ pDescription.Name = p.Name;
+ pDescription.Type = p.Type.Name;
+ pDescription.Description = p.Description;
+ method.Parameters.Add(pDescription);
+ }
+
+ popup.Methods.Add(method);
+ }
+
+ if (session.ParameterIndex > 0)
+ {
+ popup.CurrentMethod = popup.Methods.FirstOrDefault(x => x.Parameters.Count == session.ParameterIndex + 1);
+
+ if (popup.CurrentMethod == null)
+ {
+ popup.CurrentMethod = popup.Methods.FirstOrDefault();
+ }
+ }
+ else
+ {
+ popup.CurrentMethod = popup.Methods.FirstOrDefault();
+ }
+
+ if (popup.CurrentMethod != null)
+ {
+ popup.CurrentMethodIndex = popup.Methods.IndexOf(popup.CurrentMethod) + 1;
+ }
+
+ return popup;
+ }
+
+ #endregion
}
}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors.csproj b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors.csproj
index 18ed1ff70..d7c455704 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors.csproj
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors.csproj
@@ -189,6 +189,9 @@
<Compile Include="CodeCompletion\IOverloadProvider.cs" />
<Compile Include="CodeCompletion\OverloadInsightWindow.cs" />
<Compile Include="CodeCompletion\OverloadViewer.cs" />
+ <Compile Include="Converters\BooleanToVisibilityConverter.cs" />
+ <Compile Include="Converters\BooleanToVisibilityInversedConverter.cs" />
+ <Compile Include="Intellisense\KnownType.cs" />
<Compile Include="Document\ChangeTrackingCheckpoint.cs" />
<Compile Include="Document\DocumentChangeOperation.cs">
<DependentUpon>UndoStack.cs</DependentUpon>
@@ -320,6 +323,14 @@
<Compile Include="Indentation\CSharp\DocumentAccessor.cs" />
<Compile Include="Indentation\DefaultIndentationStrategy.cs" />
<Compile Include="Indentation\IIndentationStrategy.cs" />
+ <Compile Include="Intellisense\KnownTypeConstructor.cs" />
+ <Compile Include="Intellisense\KnownTypeMember.cs" />
+ <Compile Include="Intellisense\KnownTypeMethodParameter.cs" />
+ <Compile Include="Intellisense\KnownTypeMethod.cs" />
+ <Compile Include="Intellisense\KnownTypeProperty.cs" />
+ <Compile Include="Popups\MethodDescription.cs" />
+ <Compile Include="Popups\MethodPopup.cs" />
+ <Compile Include="Popups\ParameterDescription.cs" />
<Compile Include="Rendering\BackgroundGeometryBuilder.cs">
<DependentUpon>IBackgroundRenderer.cs</DependentUpon>
</Compile>
@@ -561,18 +572,33 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
- <Resource Include="Images\pubclass.gif" />
- <Resource Include="Images\pubevent.gif" />
- <Resource Include="Images\pubmethod.gif" />
- <Resource Include="Images\pubproperty.gif" />
- </ItemGroup>
- <ItemGroup>
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.Analyzers.dll" />
<Analyzer Include="..\packages\Microsoft.CodeAnalysis.Analyzers.1.1.0\analyzers\dotnet\cs\Microsoft.CodeAnalysis.CSharp.Analyzers.dll" />
</ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\enum.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\class.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\interface.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\struct.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\namespace.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\method.png" />
+ </ItemGroup>
+ <ItemGroup>
+ <Resource Include="Images\property.png" />
+ </ItemGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UseGlobalSettings="True" />
+ <UserProperties BuildVersion_UseGlobalSettings="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_StartDate="2000/1/1" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Themes/Generic.xaml b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Themes/Generic.xaml
index d113ca2a2..8b60d42a7 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Themes/Generic.xaml
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Themes/Generic.xaml
@@ -1,9 +1,11 @@
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Tango.Scripting.Editors"
+ xmlns:popups="clr-namespace:Tango.Scripting.Editors.Popups"
xmlns:fa="http://schemas.fontawesome.io/icons/"
xmlns:editing="clr-namespace:Tango.Scripting.Editors.Editing"
xmlns:folding="clr-namespace:Tango.Scripting.Editors.Folding"
+ xmlns:converters="clr-namespace:Tango.Scripting.Editors.Converters"
xmlns:completion="clr-namespace:Tango.Scripting.Editors.CodeCompletion">
<ResourceDictionary.MergedDictionaries>
@@ -21,6 +23,8 @@
<Color x:Key="ScriptForeground">#E6E6E6</Color>
<Color x:Key="ScriptFoldingForeground">#A0A0A0</Color>
<Color x:Key="ScriptLineNumberForeground">#2B91AF</Color>
+ <Color x:Key="ScriptReferenceTypesColor">#4EC9B0</Color>
+ <Color x:Key="ScriptKeywordColor">#3F8FD6</Color>
<!--Brushes-->
<SolidColorBrush x:Key="ScriptBackgroundBrush" Color="{StaticResource ScriptBackground}"></SolidColorBrush>
@@ -29,6 +33,21 @@
<SolidColorBrush x:Key="ScriptLineNumberForegroundBrush" Color="{StaticResource ScriptLineNumberForeground}"></SolidColorBrush>
<SolidColorBrush x:Key="CompletionBackgroundBrush" Color="{StaticResource CompletionBackground}"></SolidColorBrush>
<SolidColorBrush x:Key="CompletionToolTipBackgroundBrush" Color="{StaticResource CompletionToolTipBackground}"></SolidColorBrush>
+ <SolidColorBrush x:Key="ScriptReferenceTypesBrush" Color="{StaticResource ScriptReferenceTypesColor}"></SolidColorBrush>
+ <SolidColorBrush x:Key="ScriptKeywordBrush" Color="{StaticResource ScriptKeywordColor}"></SolidColorBrush>
+
+ <!--Images-->
+ <BitmapImage x:Key="interface" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/interface.png" />
+ <BitmapImage x:Key="class" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/class.png" />
+ <BitmapImage x:Key="enum" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/enum.png" />
+ <BitmapImage x:Key="struct" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/struct.png" />
+ <BitmapImage x:Key="namespace" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/namespace.png" />
+ <BitmapImage x:Key="method" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/method.png" />
+ <BitmapImage x:Key="property" UriSource="pack://application:,,,/Tango.Scripting.Editors;component/Images/property.png" />
+
+ <!--Converters-->
+ <converters:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter" />
+ <converters:BooleanToVisibilityInversedConverter x:Key="BooleanToVisibilityInversedConverter" />
<Style TargetType="{x:Type completion:CompletionList}">
<Setter Property="Background" Value="{StaticResource CompletionBackgroundBrush}"></Setter>
@@ -61,12 +80,108 @@
<Setter.Value>
<DataTemplate>
<Border Background="{StaticResource CompletionToolTipBackgroundBrush}" CornerRadius="3" BorderThickness="0.5" BorderBrush="#434343" Padding="10 5" TextElement.Foreground="{StaticResource ScriptForegroundBrush}" TextElement.FontSize="12">
- <TextBlock TextWrapping="Wrap">
- <Run Text="{Binding Type,Mode=OneWay}" Foreground="#3F8FD6"></Run>
- <Run Text="{Binding Namespace,Mode=OneWay}"></Run>.<Run Text="{Binding Text,Mode=OneWay}" Foreground="#4EC9B0"></Run>
- <LineBreak/>
- <Run Text="{Binding Description,Mode=OneWay}"></Run>
- </TextBlock>
+ <ContentControl Content="{Binding}">
+ <ContentControl.Style>
+ <Style TargetType="ContentControl">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <TextBlock TextWrapping="Wrap">
+ <Run Text="{Binding Type,Mode=OneWay}" Foreground="#3F8FD6"></Run>
+ <Run Text="{Binding Namespace,Mode=OneWay}"></Run>.<Run Text="{Binding Text,Mode=OneWay}" Foreground="#4EC9B0"></Run>
+ <LineBreak/>
+ <Run Text="{Binding Description,Mode=OneWay}"></Run>
+ </TextBlock>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Type}" Value="namespace">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <TextBlock TextWrapping="Wrap">
+ <Run Text="{Binding Type,Mode=OneWay}" Foreground="#3F8FD6"></Run>
+ <Run Text="{Binding Text,Mode=OneWay}"></Run>
+ <LineBreak/>
+ <Run Text="{Binding Description,Mode=OneWay}"></Run>
+ </TextBlock>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+
+ <DataTrigger Binding="{Binding Type}" Value="method">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <StackPanel>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding ReturnType}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock Margin="5 0 0 0" Text="{Binding Class}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock>.</TextBlock>
+ <TextBlock Text="{Binding Text}"></TextBlock>
+ <TextBlock>(</TextBlock>
+ <ItemsControl ItemsSource="{Binding Parameters}">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <StackPanel Orientation="Horizontal"></StackPanel>
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding Type.Name}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock Margin="5 0 0 0" Text="{Binding Name}"></TextBlock>
+ <TextBlock Margin="0 0 5 0" Text="," Visibility="{Binding IsLast,Converter={StaticResource BooleanToVisibilityInversedConverter}}"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ <TextBlock>)</TextBlock>
+
+ <StackPanel Margin="5 0 0 0" Orientation="Horizontal" Visibility="{Binding HasOverloads,Converter={StaticResource BooleanToVisibilityConverter}}">
+ <TextBlock>(+</TextBlock>
+ <TextBlock Margin="2 0" Text="{Binding Overloads}"></TextBlock>
+ <TextBlock>overloads)</TextBlock>
+ </StackPanel>
+ </StackPanel>
+
+ <TextBlock Text="{Binding Description}"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+
+ <DataTrigger Binding="{Binding Type}" Value="property">
+ <Setter Property="ContentTemplate">
+ <Setter.Value>
+ <DataTemplate>
+ <StackPanel>
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding ReturnType}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock Margin="5 0 0 0" Text="{Binding Class}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock>.</TextBlock>
+ <TextBlock Text="{Binding Text}"></TextBlock>
+ <TextBlock Margin="5 0 0 0">
+ <Run>{</Run>
+ <Run Foreground="{StaticResource ScriptKeywordBrush}">get</Run><Run>;</Run>
+ <Run Foreground="{StaticResource ScriptKeywordBrush}">set</Run><Run>;</Run>
+ <Run>}</Run>
+ </TextBlock>
+ </StackPanel>
+
+ <TextBlock Text="{Binding Description}"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </Setter.Value>
+ </Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </ContentControl.Style>
+ </ContentControl>
</Border>
</DataTemplate>
</Setter.Value>
@@ -90,7 +205,35 @@
<ItemsControl.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
- <Image Source="{Binding Image}" Width="16" Height="16" Margin="0,0,4,0"/>
+ <Image Width="16" Height="16" Margin="0,0,4,0">
+ <Image.Style>
+ <Style TargetType="Image">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Type}" Value="interface">
+ <Setter Property="Source" Value="{StaticResource interface}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="class">
+ <Setter Property="Source" Value="{StaticResource class}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="enum">
+ <Setter Property="Source" Value="{StaticResource enum}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="struct">
+ <Setter Property="Source" Value="{StaticResource struct}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="namespace">
+ <Setter Property="Source" Value="{StaticResource namespace}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="method">
+ <Setter Property="Source" Value="{StaticResource method}"></Setter>
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="property">
+ <Setter Property="Source" Value="{StaticResource property}"></Setter>
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Image.Style>
+ </Image>
<ContentControl Content="{Binding Content}" />
</StackPanel>
</DataTemplate>
@@ -160,17 +303,86 @@
BorderBrush="{TemplateBinding BorderBrush}"
BorderThickness="{TemplateBinding BorderThickness}">
- <ScrollViewer
- Focusable="False"
- Name="PART_ScrollViewer"
- CanContentScroll="True"
- VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"
- HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
- Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TextArea}"
- VerticalContentAlignment="Top"
- HorizontalContentAlignment="Left"
- Background="{TemplateBinding Background}"
- Padding="{TemplateBinding Padding}"/>
+ <Grid>
+ <ScrollViewer
+ Focusable="False"
+ Name="PART_ScrollViewer"
+ CanContentScroll="True"
+ VerticalScrollBarVisibility="{TemplateBinding VerticalScrollBarVisibility}"
+ HorizontalScrollBarVisibility="{TemplateBinding HorizontalScrollBarVisibility}"
+ Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=TextArea}"
+ VerticalContentAlignment="Top"
+ HorizontalContentAlignment="Left"
+ Background="{TemplateBinding Background}"
+ Padding="{TemplateBinding Padding}"/>
+
+ <Popup x:Name="PART_popup" IsOpen="False" AllowsTransparency="True">
+ <Border Background="{StaticResource CompletionToolTipBackgroundBrush}" CornerRadius="3" BorderThickness="0.5" BorderBrush="#434343" Padding="10 5" TextElement.Foreground="{StaticResource ScriptForegroundBrush}" TextElement.FontSize="12">
+ <ContentControl Content="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=CurrentPopupContent}" />
+ </Border>
+ </Popup>
+ </Grid>
+ </Border>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
+ <Style TargetType="{x:Type popups:MethodPopup}">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type popups:MethodPopup}">
+ <Border Background="{TemplateBinding Background}"
+ BorderBrush="{TemplateBinding BorderBrush}"
+ BorderThickness="{TemplateBinding BorderThickness}">
+
+ <DockPanel>
+ <StackPanel Orientation="Horizontal" VerticalAlignment="Top">
+ <fa:ImageAwesome VerticalAlignment="Center" Icon="ChevronUp" Width="10" Height="10" Foreground="{StaticResource ScriptForegroundBrush}" />
+ <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=CurrentMethodIndex}"></TextBlock>
+ <TextBlock VerticalAlignment="Center" Margin="5 0 0 0">of</TextBlock>
+ <TextBlock VerticalAlignment="Center" Margin="5 0 0 0" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=Methods.Count}"></TextBlock>
+ <fa:ImageAwesome VerticalAlignment="Center" Margin="5 0 0 0" Icon="ChevronDown" Width="10" Height="10" Foreground="{StaticResource ScriptForegroundBrush}" />
+ </StackPanel>
+
+ <StackPanel Margin="10 0 0 0">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=CurrentMethod.ReturnType}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock>(</TextBlock>
+ <ItemsControl ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=CurrentMethod.Parameters}">
+ <ItemsControl.ItemsPanel>
+ <ItemsPanelTemplate>
+ <StackPanel Orientation="Horizontal"></StackPanel>
+ </ItemsPanelTemplate>
+ </ItemsControl.ItemsPanel>
+ <ItemsControl.ItemTemplate>
+ <DataTemplate DataType="{x:Type popups:ParameterDescription}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding Type}" Foreground="{StaticResource ScriptReferenceTypesBrush}"></TextBlock>
+ <TextBlock Margin="5 0 0 0" Text="{Binding Name}"></TextBlock>
+ <TextBlock Margin="0 0 5 0" Visibility="{Binding IsLast,Converter={StaticResource BooleanToVisibilityInversedConverter}}">,</TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ <TextBlock>)</TextBlock>
+ </StackPanel>
+
+ <TextBlock Margin="0 5 0 0" Text="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=CurrentMethod.Description}" TextWrapping="Wrap"></TextBlock>
+
+ <ItemsControl Margin="0 10 0 0" ItemsSource="{Binding RelativeSource={RelativeSource Mode=TemplatedParent},Path=CurrentMethod.Parameters}">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate DataType="{x:Type popups:ParameterDescription}">
+ <StackPanel Orientation="Horizontal">
+ <TextBlock Text="{Binding Name}"></TextBlock>
+ <TextBlock>:</TextBlock>
+ <TextBlock Opacity="0.7" Margin="5 0 0 0" Text="{Binding Description}"></TextBlock>
+ </StackPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ </StackPanel>
+ </DockPanel>
</Border>
</ControlTemplate>
</Setter.Value>
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/DetectedType.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/DetectedType.cs
deleted file mode 100644
index d388e6798..000000000
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/DetectedType.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
-
-namespace Tango.Scripting.Parsing
-{
- public class DetectedType
- {
- public Type Type { get; set; }
- }
-}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/ScriptParser.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/ScriptParser.cs
index 1fc771a93..7bbc029d6 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/ScriptParser.cs
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/ScriptParser.cs
@@ -30,29 +30,36 @@ namespace Tango.Scripting.Parsing
return model;
}
- public List<ScriptVariable> ParseScript(String code)
+ public List<ScriptVariable> GetScriptVariables(String code)
{
List<ScriptVariable> vars = new List<ScriptVariable>();
SyntaxTree tree = CSharpSyntaxTree.ParseText(code);
var root = (CompilationUnitSyntax)tree.GetRoot();
- List<VariableDeclaratorSyntax> variables = new List<VariableDeclaratorSyntax>();
+ List<VariableDeclarationSyntax> variables = new List<VariableDeclarationSyntax>();
FillVariables(variables, root.Members[0]);
variables = variables.Distinct().ToList();
foreach (var item in variables)
{
ScriptVariable v = new ScriptVariable();
- v.Name = item.Identifier.ToString();
+ v.Type = item.Type.ToString();
- if (item.Initializer.Value.GetType() == typeof(ObjectCreationExpressionSyntax))
- {
- v.Type = (item.Initializer.Value as ObjectCreationExpressionSyntax).Type.ToString();
- }
- else if (item.Initializer.Value.GetType() == typeof(InvocationExpressionSyntax))
+ var variable = item.Variables.FirstOrDefault();
+
+ if (variable != null)
{
- v.Type = (((item.Initializer.Value as InvocationExpressionSyntax).Expression as MemberAccessExpressionSyntax).Name as GenericNameSyntax).TypeArgumentList.Arguments[0].ToString();
+ //if (variable.Initializer.Value.GetType() == typeof(ObjectCreationExpressionSyntax))
+ //{
+ // v.Type = (variable.Initializer.Value as ObjectCreationExpressionSyntax).Type.ToString();
+ //}
+ //else if (variable.Initializer.Value.GetType() == typeof(InvocationExpressionSyntax))
+ //{
+ // v.Type = (((variable.Initializer.Value as InvocationExpressionSyntax).Expression as MemberAccessExpressionSyntax).Name as GenericNameSyntax).TypeArgumentList.Arguments[0].ToString();
+ //}
+
+ v.Name = variable.Identifier.ToString();
}
vars.Add(v);
@@ -61,24 +68,13 @@ namespace Tango.Scripting.Parsing
return vars;
}
- //public List<DetectedType> DetectTypes(String code, List<ReferenceAssembly> referenceAssemblies)
- //{
- // SyntaxTree tree = CSharpSyntaxTree.ParseText(code);
- // CompilationUnitSyntax root = tree.GetCompilationUnitRoot();
- // var compilation = CSharpCompilation.Create("CSharpScript").AddReferences(referenceAssemblies.Select(x => MetadataReference.CreateFromFile(x.Assembly.Location))).AddSyntaxTrees(tree);
-
- // SemanticModel model = compilation.GetSemanticModel(tree);
-
-
- //}
-
- private void FillVariables(List<VariableDeclaratorSyntax> variables, SyntaxNode node)
+ private void FillVariables(List<VariableDeclarationSyntax> variables, SyntaxNode node)
{
foreach (var item in node.DescendantNodes(x => true))
{
- if (item.GetType() == typeof(VariableDeclaratorSyntax))
+ if (item.GetType() == typeof(VariableDeclarationSyntax))
{
- variables.Add(item as VariableDeclaratorSyntax);
+ variables.Add(item as VariableDeclarationSyntax);
}
else
{
@@ -94,21 +90,6 @@ namespace Tango.Scripting.Parsing
return matches.OfType<Match>().Select(x => x.Value.Replace("using ", "").Replace(";", "")).ToList();
}
- //class ClassVirtualizationVisitor : CSharpSyntaxRewriter
- //{
- // public List<string> classes = new List<String>();
-
- // public override SyntaxNode VisitClassDeclaration(ClassDeclarationSyntax node)
- // {
- // node = (ClassDeclarationSyntax)base.VisitClassDeclaration(node);
-
- // string className = node.Identifier.ValueText;
- // classes.Add(className); // save your visited classes
-
- // return node;
- // }
- //}
-
public List<INamedTypeSymbol> GetDeclaredTypes(String code)
{
List<INamedTypeSymbol> types = new List<INamedTypeSymbol>();
@@ -129,5 +110,19 @@ namespace Tango.Scripting.Parsing
return types;
}
+
+ public ObjectCreationExpressionSyntax GetCurrentConstructionExpression(String code)
+ {
+ SyntaxTree tree = CSharpSyntaxTree.ParseText(code);
+ CompilationUnitSyntax root = tree.GetCompilationUnitRoot();
+ return root.DescendantNodes().OfType<ObjectCreationExpressionSyntax>().FirstOrDefault();
+ }
+
+ public T GetExpression<T>(String line) where T : ExpressionSyntax
+ {
+ SyntaxTree tree = CSharpSyntaxTree.ParseText(line);
+ CompilationUnitSyntax root = tree.GetCompilationUnitRoot();
+ return root.DescendantNodes().OfType<T>().FirstOrDefault();
+ }
}
}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Tango.Scripting.csproj b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Tango.Scripting.csproj
index 28425884a..71d1da005 100644
--- a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Tango.Scripting.csproj
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Tango.Scripting.csproj
@@ -121,7 +121,6 @@
<Compile Include="ExtensionMethods.cs" />
<Compile Include="GlobalObject.cs" />
<Compile Include="IScriptingEngine.cs" />
- <Compile Include="Parsing\DetectedType.cs" />
<Compile Include="ReferenceAssembly.cs" />
<Compile Include="Script.cs" />
<Compile Include="ScriptingEngine.cs" />