aboutsummaryrefslogtreecommitdiffstats
path: root/Software/Visual_Studio/TEMP
diff options
context:
space:
mode:
authorRoy Ben Shabat <Roy.mail.net@gmail.com>2019-03-16 01:27:14 +0200
committerRoy Ben Shabat <Roy.mail.net@gmail.com>2019-03-16 01:27:14 +0200
commitec4b039d1d72742943f67725dd3f2622d576c28b (patch)
tree5b46308e65475fe3aa2a4ab048e4fd9d6ba6b2b1 /Software/Visual_Studio/TEMP
parent08443c61c8c7930e97149392b6dab0a0fd3de3bc (diff)
downloadTango-ec4b039d1d72742943f67725dd3f2622d576c28b.tar.gz
Tango-ec4b039d1d72742943f67725dd3f2622d576c28b.zip
Refactored known type doc reading.
Added support for enum values.
Diffstat (limited to 'Software/Visual_Studio/TEMP')
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs192
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeConstructor.cs1
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeField.cs21
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMember.cs2
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs1
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeProperty.cs2
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs171
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/ScriptEditor.cs112
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Tango.Scripting.Editors.csproj4
-rw-r--r--Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting/Parsing/ScriptParser.cs8
10 files changed, 339 insertions, 175 deletions
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
index 7aec36a86..28f9ccb9a 100644
--- 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
@@ -7,66 +7,23 @@ using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
+using Tango.Core;
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;
+ private bool _documentationLoaded;
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 String Summary { get; set; }
+ public List<KnownTypeConstructor> Constructors { get; set; }
+ public List<KnownTypeMethod> Methods { get; set; }
+ public List<KnownTypeProperty> Properties { get; set; }
public List<KnownTypeMember> Members
{
get
@@ -79,18 +36,15 @@ namespace Tango.Scripting.Editors.Intellisense
return members.OrderBy(x => x.Name).ToList();
}
}
-
- static KnownType()
- {
- _assemblies_docs_cache = new Dictionary<Assembly, XmlDocument>();
- }
+ public List<KnownTypeField> Fields { get; set; }
public KnownType(Type type)
{
- _summary = "Loading documentation...";
- _constructors = new List<KnownTypeConstructor>();
- _methods = new List<KnownTypeMethod>();
- _properties = new List<KnownTypeProperty>();
+ Summary = "Loading documentation...";
+ Constructors = new List<KnownTypeConstructor>();
+ Methods = new List<KnownTypeMethod>();
+ Properties = new List<KnownTypeProperty>();
+ Fields = new List<KnownTypeField>();
Type = type;
Name = type.Name;
@@ -106,7 +60,7 @@ namespace Tango.Scripting.Editors.Intellisense
{
InitTypeDefinition();
InitFriendlyName();
- InitTypeDocumentation();
+ InitType();
}
private void InitFriendlyName()
@@ -122,93 +76,31 @@ namespace Tango.Scripting.Editors.Intellisense
else if (Type.IsValueType) TypeDefinition = "struct";
}
- private void InitTypeDocumentation()
+ private void InitType()
{
if (!_initialized)
{
_initialized = true;
- 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);
- }
- }
-
- xmlDoc = new XmlDocument();
-
- //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").InnerXml : $"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.GetFriendlyName();
p.Name = parameter.Name;
- p.Description = pNode != null ? pNode.InnerText : null;
if (j == parameters.Count - 1)
{
@@ -218,15 +110,12 @@ namespace Tango.Scripting.Editors.Intellisense
c.Parameters.Add(p);
}
- _constructors.Add(c);
+ 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!
@@ -241,12 +130,8 @@ namespace Tango.Scripting.Editors.Intellisense
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").InnerXml : "No documentation";
m.Name = method.Name;
m.ReturnType = method.ReturnType;
m.ReturnTypeFriendlyName = method.ReturnType.GetFriendlyName();
@@ -260,7 +145,6 @@ namespace Tango.Scripting.Editors.Intellisense
}
var parameters = method.GetParameters().ToList();
- var parametersNodes = mDoc != null ? mDoc.SelectNodes("param").OfType<XmlNode>().ToList() : new List<XmlNode>();
bool isLinq = method.DeclaringType == typeof(Enumerable);
@@ -268,17 +152,9 @@ namespace Tango.Scripting.Editors.Intellisense
{
var parameter = parameters[j];
- XmlNode pNode = null;
-
- if (j < parametersNodes.Count)
- {
- pNode = parametersNodes[j];
- }
-
KnownTypeMethodParameter p = new KnownTypeMethodParameter();
p.Type = parameter.ParameterType.GetFriendlyName();
p.Name = parameter.Name;
- p.Description = pNode != null ? pNode.InnerText : null;
if (j == parameters.Count - 1)
{
@@ -289,34 +165,58 @@ namespace Tango.Scripting.Editors.Intellisense
m.Parameters.Add(p);
}
- _methods.Add(m);
+ 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").InnerXml : "No documentation";
p.Name = property.Name;
p.ReturnType = property.PropertyType;
p.ReturnTypeFriendlyName = property.PropertyType.GetFriendlyName();
- _properties.Add(p);
+ Properties.Add(p);
+ }
+ }
+
+ //Load Enum Values
+ {
+ if (Type.IsEnum)
+ {
+ var values = Enum.GetNames(Type).ToList();
+
+ for (int i = 0; i < values.Count; i++)
+ {
+ var value = values[i];
+
+ KnownTypeField f = new KnownTypeField(this);
+ f.Name = value;
+ f.ReturnType = typeof(Int32);
+ f.ReturnTypeFriendlyName = typeof(Int32).Name;
+ Fields.Add(f);
+ }
}
}
_initialized = true;
}
}
+
+ public void LoadDocumentation()
+ {
+ if (!_documentationLoaded)
+ {
+ _documentationLoaded = true;
+
+ Utils.LoadKnownTypeDocs(this);
+ }
+ }
}
}
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
index 273d61084..83dc3f750 100644
--- 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
@@ -16,6 +16,7 @@ namespace Tango.Scripting.Editors.Intellisense
public KnownTypeConstructor()
{
+ Summary = "Loading documentation...";
Parameters = new List<KnownTypeMethodParameter>();
}
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeField.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeField.cs
new file mode 100644
index 000000000..cd1349744
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeField.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 KnownTypeField : KnownTypeMember
+ {
+ public KnownTypeField()
+ {
+ Summary = "Loading documentation...";
+ }
+
+ public KnownTypeField(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
index 1405a8c34..bae4edf41 100644
--- 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
@@ -20,7 +20,7 @@ namespace Tango.Scripting.Editors.Intellisense
public KnownTypeMember()
{
-
+ Summary = "Loading documentation...";
}
public KnownTypeMember(KnownType knownType) : this()
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
index 767d49b7e..f84e26fe5 100644
--- 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
@@ -29,6 +29,7 @@ namespace Tango.Scripting.Editors.Intellisense
public KnownTypeMethod()
{
+ Summary = "Loading documentation...";
Parameters = new List<KnownTypeMethodParameter>();
TypeArguments = new List<string>();
}
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
index a77dd7dc2..52717579a 100644
--- 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
@@ -10,7 +10,7 @@ namespace Tango.Scripting.Editors.Intellisense
{
public KnownTypeProperty()
{
-
+ Summary = "Loading documentation...";
}
public KnownTypeProperty(KnownType knownType) : this()
diff --git a/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs
new file mode 100644
index 000000000..e30d0e37e
--- /dev/null
+++ b/Software/Visual_Studio/TEMP/Tango.Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs
@@ -0,0 +1,171 @@
+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 static class Utils
+ {
+ private static String dotNetXmlFolder = @"C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.X";
+ private static Dictionary<Assembly, XmlDocument> _assemblies_docs_cache;
+
+ static Utils()
+ {
+ _assemblies_docs_cache = new Dictionary<Assembly, XmlDocument>();
+ }
+
+ public static void LoadKnownTypeDocs(KnownType knownType)
+ {
+ XmlDocument xmlDoc = null;
+
+ if (_assemblies_docs_cache.ContainsKey(knownType.Type.Assembly))
+ {
+ xmlDoc = _assemblies_docs_cache[knownType.Type.Assembly];
+ }
+
+ if (xmlDoc == null)
+ {
+ String dllPath = knownType.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(knownType.Type.Assembly, xmlDoc);
+ }
+ }
+
+ if (xmlDoc == null)
+ {
+ xmlDoc = new XmlDocument();
+ }
+
+ //Load Type Summary
+ {
+ string path = "T:" + knownType.Type.FullName;
+ XmlNode xmlDocuOfType = xmlDoc.SelectSingleNode("//member[starts-with(@name, '" + path + "')]");
+
+ if (xmlDocuOfType != null)
+ {
+ XmlNode summaryNode = xmlDocuOfType.SelectSingleNode("summary");
+ knownType.Summary = summaryNode.InnerText;
+ }
+ }
+
+ //Load Constructors...
+ {
+ string path = "M:" + knownType.Type.FullName + ".#ctor";
+
+ var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
+
+ for (int i = 0; i < knownType.Constructors.Count; i++)
+ {
+ var constructor = knownType.Constructors[i];
+ XmlNode cDoc = null;
+
+ if (i < docNodes.Count)
+ {
+ cDoc = docNodes[i];
+ }
+
+ constructor.Summary = cDoc != null ? cDoc.SelectSingleNode("summary").InnerXml : $"Initializes a new instance of {knownType.FriendlyName}.";
+
+ var parameters = constructor.Parameters.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];
+ }
+
+ parameter.Description = pNode != null ? pNode.InnerText : null;
+ }
+ }
+ }
+
+ //Load Methods...
+ {
+ string path = "M:" + knownType.Type.FullName;
+
+ var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
+
+ for (int i = 0; i < knownType.Methods.Count; i++)
+ {
+ var method = knownType.Methods[i];
+ XmlNode mDoc = null;
+
+ mDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(knownType.Type.Name + "." + method.Name));
+ method.Summary = mDoc != null ? mDoc.SelectSingleNode("summary").InnerXml : "No documentation";
+
+ var parameters = method.Parameters.ToList();
+ var parametersNodes = mDoc != null ? mDoc.SelectNodes("param").OfType<XmlNode>().ToList() : new List<XmlNode>();
+
+ bool isLinq = knownType.Type == typeof(Enumerable);
+
+ for (int j = 0; j < parameters.Count; j++)
+ {
+ var parameter = parameters[j];
+
+ XmlNode pNode = null;
+
+ if (j < parametersNodes.Count)
+ {
+ pNode = parametersNodes[j];
+ }
+
+ parameter.Description = pNode != null ? pNode.InnerText : null;
+ }
+ }
+ }
+
+ //Load Properties
+ {
+ string path = "P:" + knownType.Type.FullName;
+
+ var docNodes = xmlDoc.SelectNodes("//member[starts-with(@name, '" + path + "')]").OfType<XmlNode>().ToList();
+
+ for (int i = 0; i < knownType.Properties.Count; i++)
+ {
+ var property = knownType.Properties[i];
+ var pDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(knownType.Type.Name + "." + property.Name));
+
+ property.Summary = pDoc != null ? pDoc.SelectSingleNode("summary").InnerXml : "No documentation";
+ }
+ }
+
+ //Load Enum Values
+ {
+ if (knownType.Type.IsEnum)
+ {
+ for (int i = 0; i < knownType.Fields.Count; i++)
+ {
+ var field = knownType.Fields[i];
+ var pDoc = xmlDoc.SelectSingleNode("//member[starts-with(@name, '" + $"F:{knownType.Type.FullName}.{field.Name}" + "')]");
+ field.Summary = pDoc != null ? pDoc.SelectSingleNode("summary").InnerXml : "No documentation";
+ }
+ }
+ }
+ }
+ }
+}
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 f6296ac5c..71b836f36 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
@@ -248,6 +248,7 @@ namespace Tango.Scripting.Editors
public void IndentCode()
{
Text = Indentation.CSharp.CSharpIndentationHelper.IndentCSharpCode(Text);
+ //Text = _parser.IndentCSharpCode(Text);
}
/// <summary>
@@ -516,7 +517,7 @@ namespace Tango.Scripting.Editors
{
var currentLine = GetCurrentLine();
var currentText = Document.GetText(currentLine.Offset, CaretOffset - currentLine.Offset);
- return currentText.Split(' ').ToList();
+ return currentText.Split(' ',',').ToList();
}
#endregion
@@ -581,7 +582,7 @@ namespace Tango.Scripting.Editors
{
interfaceTypes.Add(String.Format("<Word>{0}</Word>", name));
}
- else if (type.Type.IsClass)
+ else if (type.Type.IsClass || (type.Type.IsValueType))
{
referenceTypes.Add(String.Format("<Word>{0}</Word>", name));
}
@@ -621,6 +622,11 @@ namespace Tango.Scripting.Editors
ms.Dispose();
}));
+
+ foreach (var knownType in _knownTypes)
+ {
+ knownType.LoadDocumentation();
+ }
}
_isLoadingTypes = false;
@@ -775,7 +781,32 @@ namespace Tango.Scripting.Editors
if (previousWords.Count > 0 && previousWords.First().Trim().StartsWith("//")) return;
- if (e.Text == " " && GetPreviousWord() == "new")
+ if (e.Text == " " && previousWords.Count > 2 && previousWords[previousWords.Count - 2] == "=")
+ {
+ var expression = previousWords.First();
+ var knownType = GetKnownTypeFromExpression(expression + ".");
+
+ if (knownType != null && knownType.Type.IsEnum)
+ {
+ completionWindow.HideCompletion();
+ IList<ICompletionData> data = new List<ICompletionData>();
+
+ foreach (var field in knownType.Fields)
+ {
+ data.Add(new FieldCompletionItem()
+ {
+ Class = knownType.FriendlyName,
+ Name = knownType.FriendlyName + "." + field.Name,
+ Type = field.ReturnTypeFriendlyName,
+ Description = field.Summary,
+ });
+ }
+
+ ShowCompletionWindow(data.OrderBy(x => x.Text).ToList(), GetCurrentWord());
+ }
+
+ }
+ else if (e.Text == " " && GetPreviousWord() == "new")
{
var s = _parser.GetExpressionFirst<FieldDeclarationSyntax>(GetCurrentLineText());
@@ -807,35 +838,52 @@ namespace Tango.Scripting.Editors
completionWindow.HideCompletion();
IList<ICompletionData> data = new List<ICompletionData>();
- var typeMembers = knownType.Members.ToList();
-
- foreach (var methodGroup in typeMembers.OfType<KnownTypeMethod>().GroupBy(x => x.NameWithTypeArguments))
+ if (!knownType.Type.IsEnum)
{
- var method = methodGroup.First();
+ var typeMembers = knownType.Members.ToList();
- data.Add(new MethodCompletionItem()
+ foreach (var methodGroup in typeMembers.OfType<KnownTypeMethod>().GroupBy(x => x.NameWithTypeArguments))
{
- Class = knownType.FriendlyName,
- Name = method.NameWithTypeArguments,
- ReturnType = method.ReturnTypeFriendlyName,
- Description = method.Summary,
- Parameters = method.Parameters,
- Overloads = methodGroup.Count() - 1,
- });
- }
+ var method = methodGroup.First();
- foreach (var methodGroup in typeMembers.Where(x => x.GetType() != typeof(KnownTypeMethod)).GroupBy(x => x.Name))
- {
- var member = methodGroup.First();
+ data.Add(new MethodCompletionItem()
+ {
+ Class = knownType.FriendlyName,
+ Name = method.NameWithTypeArguments,
+ ReturnType = method.ReturnTypeFriendlyName,
+ Description = method.Summary,
+ Parameters = method.Parameters,
+ Overloads = methodGroup.Count() - 1,
+ });
+ }
- data.Add(new PropertyCompletionItem()
+ foreach (var methodGroup in typeMembers.Where(x => x.GetType() != typeof(KnownTypeMethod)).GroupBy(x => x.Name))
{
- Class = knownType.FriendlyName,
- Name = member.Name,
- Type = member.ReturnTypeFriendlyName,
- Description = member.Summary,
- });
+ var member = methodGroup.First();
+
+ data.Add(new PropertyCompletionItem()
+ {
+ Class = knownType.FriendlyName,
+ Name = member.Name,
+ Type = member.ReturnTypeFriendlyName,
+ Description = member.Summary,
+ });
+
+ }
+ }
+ else
+ {
+ foreach (var field in knownType.Fields)
+ {
+ data.Add(new FieldCompletionItem()
+ {
+ Class = knownType.FriendlyName,
+ Name = field.Name,
+ Type = field.ReturnTypeFriendlyName,
+ Description = field.Summary,
+ });
+ }
}
ShowCompletionWindow(data.OrderBy(x => x.Text).ToList(), GetCurrentWord());
@@ -1062,7 +1110,7 @@ namespace Tango.Scripting.Editors
}
}
- foreach (var type in _knownTypes.Where(x => x.Name.StartsWith(word)))
+ foreach (var type in _knownTypes.ToList().Where(x => x.Name.StartsWith(word)))
{
if (type.Type.IsEnum)
{
@@ -1251,7 +1299,11 @@ namespace Tango.Scripting.Editors
private KnownType GetCurrentKnownType()
{
var expression = GetPreviousWords().LastOrDefault();
+ return GetKnownTypeFromExpression(expression);
+ }
+ private KnownType GetKnownTypeFromExpression(String expression)
+ {
if (expression != null)
{
var tree = expression.Split('.').Select(x => x.Remove(@"\n|\t|\r|\(.*\)|\[.*\]|\s")).ToList();
@@ -1259,6 +1311,14 @@ namespace Tango.Scripting.Editors
if (variableName != null)
{
+ //Search for enum type first
+ var enumType = _knownTypes.FirstOrDefault(x => x.Name == variableName && x.Type.IsEnum);
+
+ if (enumType != null)
+ {
+ return enumType;
+ }
+
tree.RemoveAt(0);
var variables = _parser.GetContextSymbols(Document.Text, CaretOffset);
var variable = variables.FirstOrDefault(x => x.Name == variableName);
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 8b213a870..de8308271 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
@@ -336,6 +336,7 @@
<Compile Include="Indentation\DefaultIndentationStrategy.cs" />
<Compile Include="Indentation\IIndentationStrategy.cs" />
<Compile Include="Intellisense\KnownTypeConstructor.cs" />
+ <Compile Include="Intellisense\KnownTypeField.cs" />
<Compile Include="Intellisense\KnownTypeMember.cs" />
<Compile Include="Intellisense\KnownTypeMethodParameter.cs" />
<Compile Include="Intellisense\KnownTypeMethod.cs" />
@@ -349,6 +350,7 @@
<Compile Include="Intellisense\PropertyCompletionItemPopup.cs" />
<Compile Include="Intellisense\StructCompletionItem.cs" />
<Compile Include="Intellisense\StructCompletionItemPopup.cs" />
+ <Compile Include="Intellisense\Utils.cs" />
<Compile Include="Popups\MethodDescription.cs" />
<Compile Include="Popups\MethodPopup.cs" />
<Compile Include="Popups\ParameterDescription.cs" />
@@ -622,7 +624,7 @@
</ItemGroup>
<ProjectExtensions>
<VisualStudio>
- <UserProperties BuildVersion_UseGlobalSettings="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_StartDate="2000/1/1" />
+ <UserProperties BuildVersion_StartDate="2000/1/1" BuildVersion_BuildVersioningStyle="None.None.Increment.TimeStamp" BuildVersion_UpdateAssemblyVersion="True" BuildVersion_AssemblyInfoFilename="Properties\AssemblyInfo.cs" BuildVersion_UseGlobalSettings="True" />
</VisualStudio>
</ProjectExtensions>
</Project> \ No newline at end of file
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 508801037..f022f7999 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
@@ -368,5 +368,13 @@ namespace Tango.Scripting.Parsing
return parameters;
}
+
+ public String IndentCSharpCode(String code)
+ {
+ var tree = CSharpSyntaxTree.ParseText(code);
+ var root = tree.GetRoot().NormalizeWhitespace();
+ var ret = root.ToFullString();
+ return ret;
+ }
}
}