diff options
| author | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
|---|---|---|
| committer | Mirta <mirta@twine-s.com> | 2020-12-30 16:39:52 +0200 |
| commit | 00a491d93733d4625ad329b2ba8237f445364b3f (patch) | |
| tree | 4b24c6fa78d7648f4bb7cefafa464bb0b063fec4 /Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense | |
| parent | 124ad4150f80c6846fdee41dbbda9848c105f6e5 (diff) | |
| download | Tango-00a491d9.tar.gz Tango-00a491d9.zip | |
merge
Diffstat (limited to 'Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense')
8 files changed, 9 insertions, 170 deletions
diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/CompletionItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/CompletionItem.cs index 191f99b6c..c8beebd28 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/CompletionItem.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/CompletionItem.cs @@ -31,7 +31,7 @@ namespace Tango.Scripting.Editors.Intellisense int index = editor.GetCurrentWordStartIndex(); int max = editor.GetCurrentLine().EndOffset; - editor.Document.Replace(index, word.Length, GetCode()); + editor.Document.Replace(index, word.Length,Text); } public abstract BitmapSource Image { get; } @@ -41,11 +41,6 @@ namespace Tango.Scripting.Editors.Intellisense return new BitmapImage(new Uri($"pack://application:,,,/Tango.Scripting.Editors;component/Images/{name}", UriKind.Absolute)); } - protected virtual String GetCode() - { - return Text; - } - public override string ToString() { return Text; diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/EventCompletionItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/EventCompletionItem.cs deleted file mode 100644 index 5c510c39f..000000000 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/EventCompletionItem.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media.Imaging; - -namespace Tango.Scripting.Editors.Intellisense -{ - public class EventCompletionItem : CompletionItem - { - private static BitmapSource image = GetImage("event.png"); - - public override string Text => Name; - public override CompletionItemPopupControl PopupControl => new FieldCompletionItemPopup(); - public override BitmapSource Image => image; - - public String Name { get; set; } - public String Class { get; set; } - public String Type { get; set; } - } -} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/HideIntellisenseAttribute.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/HideIntellisenseAttribute.cs deleted file mode 100644 index 548bd909e..000000000 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/HideIntellisenseAttribute.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Scripting.Editors.Intellisense -{ - public class HideIntellisenseAttribute : Attribute - { - } -} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs index 8010dc689..28f9ccb9a 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownType.cs @@ -1,14 +1,11 @@ -using Newtonsoft.Json; -using System; +using System; using System.Collections; using System.Collections.Generic; -using System.Drawing; using System.IO; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; -using System.Windows.Forms; using System.Xml; using Tango.Core; @@ -17,18 +14,16 @@ namespace Tango.Scripting.Editors.Intellisense public class KnownType { private bool _initialized; + private bool _documentationLoaded; - public String Alias { get; set; } - public bool DocumentationLoaded { get; set; } public Type Type { get; private set; } - public String Name { get; set; } + public String Name { get; private set; } public String TypeDefinition { get; private set; } public String FriendlyName { get; private set; } 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<KnownTypeEvent> Events { get; set; } public List<KnownTypeMember> Members { get @@ -37,20 +32,12 @@ namespace Tango.Scripting.Editors.Intellisense members.AddRange(Properties); members.AddRange(Methods); - members.AddRange(Events); return members.OrderBy(x => x.Name).ToList(); } } public List<KnownTypeField> Fields { get; set; } - public static List<Assembly> ExtensionMethodsAssemblies { get; set; } - - static KnownType() - { - ExtensionMethodsAssemblies = new List<Assembly>(); - } - public KnownType(Type type) { Summary = "Loading documentation..."; @@ -58,7 +45,6 @@ namespace Tango.Scripting.Editors.Intellisense Methods = new List<KnownTypeMethod>(); Properties = new List<KnownTypeProperty>(); Fields = new List<KnownTypeField>(); - Events = new List<KnownTypeEvent>(); Type = type; Name = type.Name; @@ -132,31 +118,9 @@ namespace Tango.Scripting.Editors.Intellisense { var methods = Type.GetRuntimeMethods().Where(x => x.IsPublic && !x.IsSpecialName).ToList(); - if (Type.IsInterface) - { - foreach (var inter in Type.GetInterfaces()) - { - methods.AddRange(inter.GetRuntimeMethods().Where(x => x.IsPublic && !x.IsSpecialName).ToList()); - } - methods = methods.Distinct().ToList(); - - if (!methods.Exists(x => x.Name == "ToString")) - { - methods.Add(typeof(Object).GetMethod("ToString")); - } - } - //TODO: Separate extension methods! methods.AddRange(Type.GetExtensionMethods(Type.Assembly).ToList()); - if (Type.Namespace.StartsWith("Tango")) - { - foreach (var asm in ExtensionMethodsAssemblies.Where(x => x != Type.Assembly)) - { - methods.AddRange(Type.GetExtensionMethods(asm).ToList()); - } - } - if (typeof(IEnumerable).IsAssignableFrom(Type)) { var linqMethods = typeof(System.Linq.Enumerable).GetMethods(BindingFlags.Static | BindingFlags.Public).ToList(); @@ -167,13 +131,10 @@ namespace Tango.Scripting.Editors.Intellisense { var method = methods[i]; - if (method.GetCustomAttribute<HideIntellisenseAttribute>() != null) continue; - KnownTypeMethod m = new KnownTypeMethod(this); m.Name = method.Name; m.ReturnType = method.ReturnType; m.ReturnTypeFriendlyName = method.ReturnType.GetFriendlyName(); - m.IsStatic = method.IsStatic && !method.IsDefined(typeof(System.Runtime.CompilerServices.ExtensionAttribute), false); if (method.IsGenericMethod) { @@ -187,11 +148,6 @@ namespace Tango.Scripting.Editors.Intellisense bool isLinq = method.DeclaringType == typeof(Enumerable); - if (isLinq) - { - m.IsStatic = false; - } - for (int j = 0; j < parameters.Count; j++) { var parameter = parameters[j]; @@ -215,14 +171,12 @@ namespace Tango.Scripting.Editors.Intellisense //Load Properties { - var properties = Type.GetProperties(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Instance | BindingFlags.Static).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]; - if (property.GetCustomAttribute<HideIntellisenseAttribute>() != null) continue; - KnownTypeProperty p = new KnownTypeProperty(this); p.Name = property.Name; p.ReturnType = property.PropertyType; @@ -232,23 +186,6 @@ namespace Tango.Scripting.Editors.Intellisense } } - //Load Events - { - var events = Type.GetRuntimeEvents().ToList(); - - for (int i = 0; i < events.Count; i++) - { - var ev = events[i]; - - if (ev.GetCustomAttribute<HideIntellisenseAttribute>() != null) continue; - - KnownTypeEvent p = new KnownTypeEvent(this); - p.Name = ev.Name; - - Events.Add(p); - } - } - //Load Enum Values { if (Type.IsEnum) @@ -274,9 +211,9 @@ namespace Tango.Scripting.Editors.Intellisense public void LoadDocumentation() { - if (!DocumentationLoaded) + if (!_documentationLoaded) { - DocumentationLoaded = true; + _documentationLoaded = true; Utils.LoadKnownTypeDocs(this); } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeEvent.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeEvent.cs deleted file mode 100644 index 7403d2cbd..000000000 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeEvent.cs +++ /dev/null @@ -1,21 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace Tango.Scripting.Editors.Intellisense -{ - public class KnownTypeEvent : KnownTypeMember - { - public KnownTypeEvent() - { - Summary = "Loading documentation..."; - } - - public KnownTypeEvent(KnownType knownType) : this() - { - Type = knownType; - } - } -} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs index 4cedad377..f84e26fe5 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/KnownTypeMethod.cs @@ -8,8 +8,6 @@ namespace Tango.Scripting.Editors.Intellisense { public class KnownTypeMethod : KnownTypeMember { - public bool IsStatic { get; set; } - public List<KnownTypeMethodParameter> Parameters { get; set; } public List<String> TypeArguments { get; set; } diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/SnippetCompletionItem.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/SnippetCompletionItem.cs deleted file mode 100644 index 97807ed19..000000000 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/SnippetCompletionItem.cs +++ /dev/null @@ -1,26 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using System.Windows.Media.Imaging; - -namespace Tango.Scripting.Editors.Intellisense -{ - public class SnippetCompletionItem : CompletionItem - { - private static BitmapSource image = GetImage("snippet.png"); - - public override string Text => Name; - public override CompletionItemPopupControl PopupControl => new FieldCompletionItemPopup(); - public override BitmapSource Image => image; - - public String Name { get; set; } - public String Code { get; set; } - - protected override string GetCode() - { - return Code; - } - } -} diff --git a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs index 2ead15d0d..f8cc7072d 100644 --- a/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs +++ b/Software/Visual_Studio/Scripting/Tango.Scripting.Editors/Intellisense/Utils.cs @@ -150,12 +150,7 @@ namespace Tango.Scripting.Editors.Intellisense var property = knownType.Properties[i]; var pDoc = docNodes.FirstOrDefault(x => x.Attributes["name"].InnerText.Contains(knownType.Type.Name + "." + property.Name)); - - if (pDoc != null) - { - var summaryNode = pDoc.SelectSingleNode("summary"); - property.Summary = summaryNode != null ? summaryNode.InnerXml : "No documentation"; - } + property.Summary = pDoc != null ? pDoc.SelectSingleNode("summary").InnerXml : "No documentation"; } } @@ -167,12 +162,7 @@ namespace Tango.Scripting.Editors.Intellisense { var field = knownType.Fields[i]; var pDoc = xmlDoc.SelectSingleNode("//member[starts-with(@name, '" + $"F:{knownType.Type.FullName}.{field.Name}" + "')]"); - - if (pDoc != null) - { - var summaryNode = pDoc.SelectSingleNode("summary"); - field.Summary = summaryNode != null ? summaryNode.InnerXml : "No documentation"; - } + field.Summary = pDoc != null ? pDoc.SelectSingleNode("summary").InnerXml : "No documentation"; } } } |
