public void GetExtensionMethodsCompletionData(TypeDefinitionBase targetType, SD_NameSpace namespaceDefinition, Dictionary <string, SymbolDefinition> data) { namespaceDefinition.GetExtensionMethodsCompletionData(targetType, data, AccessLevelMask.Public | AccessLevelMask.Internal); foreach (var ra in referencedAssemblies) { var nsDef = ra.FindSameNamespace(namespaceDefinition); if (nsDef != null) { nsDef.GetExtensionMethodsCompletionData(targetType, data, AccessLevelMask.Public | (ra.InternalsVisibleIn(this) ? AccessLevelMask.Internal : 0)); } } }
public SD_NameSpace FindSameNamespace(SD_NameSpace namespaceDefinition) { if (string.IsNullOrEmpty(namespaceDefinition.name)) { return(GlobalNamespace); } var parent = FindSameNamespace(namespaceDefinition.parentSymbol as SD_NameSpace); if (parent == null) { return(null); } return(parent.FindName(namespaceDefinition.name, 0, true) as SD_NameSpace); }
public void ResolveInReferencedAssemblies(SyntaxTreeNode_Leaf leaf, SD_NameSpace namespaceDefinition, int numTypeArgs) { var leafText = DecodeId(leaf.token.text); foreach (var ra in referencedAssemblies) { var nsDef = ra.FindSameNamespace(namespaceDefinition); if (nsDef != null) { leaf.ResolvedSymbol = nsDef.FindName(leafText, numTypeArgs, true); if (leaf.ResolvedSymbol != null) { return; } } } }
public void CollectExtensionMethods( SD_NameSpace namespaceDefinition, string id, SymbolReference[] typeArgs, TypeDefinitionBase extendedType, HashSet <MethodDefinition> extensionsMethods, Scope_Base context) { namespaceDefinition.CollectExtensionMethods(id, typeArgs, extendedType, extensionsMethods, context); foreach (var ra in referencedAssemblies) { var nsDef = ra.FindSameNamespace(namespaceDefinition); if (nsDef != null) { nsDef.CollectExtensionMethods(id, typeArgs, extendedType, extensionsMethods, context); } } }
public void GetTypesOnlyCompletionDataFromReferencedAssemblies(Dictionary <string, SymbolDefinition> data, SD_NameSpace namespaceDefinition) { if (dontReEnter) { return; } foreach (var ra in referencedAssemblies) { var nsDef = ra.FindSameNamespace(namespaceDefinition); if (nsDef != null) { dontReEnter = true; var accessLevelMask = ra.InternalsVisibleIn(this) ? AccessLevelMask.Public | AccessLevelMask.Internal : AccessLevelMask.Public; nsDef.GetTypesOnlyCompletionData(data, accessLevelMask, this); dontReEnter = false; } } }
private SD_NameSpace InitializeGlobalNamespace() { // var timer = new Stopwatch(); // timer.Start(); _globalNamespace = new SD_NameSpace { name = "", kind = SymbolKind.Namespace, parentSymbol = this }; if (assembly != null) { var types = assemblyId != UnityAssembly.None ? assembly.GetTypes() : assembly.GetExportedTypes(); foreach (var t in types) { if (t.IsNested) { continue; } SymbolDefinition current = _globalNamespace; if (!string.IsNullOrEmpty(t.Namespace)) { var ns = t.Namespace.Split('.'); for (var i = 0; i < ns.Length; ++i) { var nsName = ns[i]; var definition = current.FindName(nsName, 0, true); if (definition != null) { current = definition; } else { var nsd = new SD_NameSpace { kind = SymbolKind.Namespace, name = nsName, parentSymbol = current, accessLevel = AccessLevel.Public, modifiers = Modifiers.Public, }; current.AddMember(nsd); current = nsd; } } } current.ImportReflectedType(t); } } // timer.Stop(); // UnityEngine.Debug.Log(timer.ElapsedMilliseconds + " ms\n" + string.Join(", ", _globalNamespace.members.Keys.ToArray())); // Debug.Log(_globalNamespace.Dump()); if (builtInTypes == null) { builtInTypes = new Dictionary <string, TypeDefinitionBase> { { "int", builtInTypes_int = DefineBuiltInType(typeof(int)) }, { "uint", builtInTypes_uint = DefineBuiltInType(typeof(uint)) }, { "byte", builtInTypes_byte = DefineBuiltInType(typeof(byte)) }, { "sbyte", builtInTypes_sbyte = DefineBuiltInType(typeof(sbyte)) }, { "short", builtInTypes_short = DefineBuiltInType(typeof(short)) }, { "ushort", builtInTypes_ushort = DefineBuiltInType(typeof(ushort)) }, { "long", builtInTypes_long = DefineBuiltInType(typeof(long)) }, { "ulong", builtInTypes_ulong = DefineBuiltInType(typeof(ulong)) }, { "float", builtInTypes_float = DefineBuiltInType(typeof(float)) }, { "double", builtInTypes_double = DefineBuiltInType(typeof(float)) }, { "decimal", builtInTypes_decimal = DefineBuiltInType(typeof(decimal)) }, { "char", builtInTypes_char = DefineBuiltInType(typeof(char)) }, { "string", builtInTypes_string = DefineBuiltInType(typeof(string)) }, { "bool", builtInTypes_bool = DefineBuiltInType(typeof(bool)) }, { "object", builtInTypes_object = DefineBuiltInType(typeof(object)) }, { "void", builtInTypes_void = DefineBuiltInType(typeof(void)) }, }; builtInTypes_Array = DefineBuiltInType(typeof(System.Array)); builtInTypes_Nullable = DefineBuiltInType(typeof(System.Nullable <>)); builtInTypes_IEnumerable = DefineBuiltInType(typeof(System.Collections.IEnumerable)); builtInTypes_IEnumerable_1 = DefineBuiltInType(typeof(System.Collections.Generic.IEnumerable <>)); builtInTypes_Exception = DefineBuiltInType(typeof(System.Exception)); } return(_globalNamespace); }