public override void RemoveDeclaration(SymbolDeclaration symbol)
    {
        if (typeDeclarations != null)
        {
            typeDeclarations.Remove(symbol);
        }

        if (symbol.kind == SymbolKind.ImportedNamespace)
        {
            var node = symbol.parseTreeNode;
            declaration.importedNamespaces.RemoveAll(x => x.Node.Parent == node);
            return;
        }
        else if (symbol.kind == SymbolKind.TypeAlias)
        {
            var index = declaration.typeAliases.FindIndex(x => x.declaration == symbol);
            if (index >= 0)
            {
                declaration.typeAliases.RemoveAt(index);
            }
            return;
        }

        if (definition != null)
        {
            definition.RemoveDeclaration(symbol);
        }
    }
Пример #2
0
    public SymbolDefinition AddParameter(SymbolDeclaration symbol)
    {
        var symbolName = symbol.Name;
        var parameter  = (SD_Instance_Parameter)Create(symbol);

        parameter.type         = new SymbolReference(symbol.parseTreeNode.FindChildByName("type"));
        parameter.parentSymbol = this;
        var lastNode = symbol.parseTreeNode.NodeAt(-1);

        if (lastNode != null && lastNode.RuleName == "defaultArgument")
        {
            var defaultValueNode = lastNode.NodeAt(1);
            if (defaultValueNode != null)
            {
                parameter.defaultValue = defaultValueNode.Print();
            }
        }
        if (!string.IsNullOrEmpty(symbolName))
        {
            if (parameters == null)
            {
                parameters = new List <SD_Instance_Parameter>();
            }
            parameters.Add(parameter);
        }
        return(parameter);
    }
Пример #3
0
 public override void GetCompletionData(Dictionary <string, SymbolDefinition> data, bool fromInstance, SD_Assembly assembly)
 {
     if (localSymbols != null)
     {
         foreach (var ls in localSymbols)
         {
             SymbolDeclaration   declaration     = ls.declarations.FirstOrDefault();
             SyntaxTreeNode_Rule declarationNode = declaration != null ? declaration.parseTreeNode : null;
             if (declarationNode == null)
             {
                 continue;
             }
             var firstLeaf = declarationNode.GetFirstLeaf();
             if (firstLeaf != null &&
                 (firstLeaf.Line > completionAtLine ||
                  firstLeaf.Line == completionAtLine && firstLeaf.TokenIndex >= completionAtTokenIndex))
             {
                 continue;
             }
             if (!data.ContainsKey(ls.name))
             {
                 data.Add(ls.name, ls);
             }
         }
     }
     base.GetCompletionData(data, fromInstance, assembly);
 }
Пример #4
0
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        if (definition == null)
        {
            return(null);
        }

        symbol.scope = this;

        switch (symbol.kind)
        {
        case SymbolKind.ConstantField:
        case SymbolKind.LocalConstant:
            if (!(definition is TypeDefinitionBase))
            {
                return(base.AddDeclaration(symbol));
            }
            break;

        case SymbolKind.Variable:
        case SymbolKind.ForEachVariable:
        case SymbolKind.FromClauseVariable:
            return(base.AddDeclaration(symbol));
        }

        return(definition.AddDeclaration(symbol));
    }
	public static void FindOtherTypeDeclarationParts(SymbolDeclaration declaration)
	{
		if (scriptsWithPartialClass == null)
		{
			scriptsWithPartialClass = new Dictionary<AssemblyDefinition, List<string>>();
			scriptsWithPartialStruct = new Dictionary<AssemblyDefinition, List<string>>();
			scriptsWithPartialInterface = new Dictionary<AssemblyDefinition, List<string>>();
		}
		
		var typeDefinition = declaration.definition as TypeDefinition;
		if (typeDefinition == null)
			return;
		var assembly = typeDefinition.Assembly;
		
		var cachedAssemblyScripts =
			declaration.kind == SymbolKind.Class ? scriptsWithPartialClass :
			declaration.kind == SymbolKind.Struct ? scriptsWithPartialStruct :
			scriptsWithPartialInterface;
		List<string> scriptsWithPartials;
		if (!cachedAssemblyScripts.TryGetValue(assembly, out scriptsWithPartials))
		{
			FGFindInFiles.Reset();
			FGFindInFiles.FindAllAssemblyScripts(assembly);
			
			cachedAssemblyScripts[assembly] = scriptsWithPartials = new List<string>(FGFindInFiles.assets.Count);
			
			var partialTypePhrase = new string[] {
				"partial",
				declaration.kind == SymbolKind.Class ? "class" : declaration.kind == SymbolKind.Struct ? "struct" : "interface"
			};
			for (var i = FGFindInFiles.assets.Count; i --> 0; )
			{
				var assetPath = AssetDatabase.GUIDToAssetPath(FGFindInFiles.assets[i]);
				if (FGFindInFiles.ContainsWordsSequence(assetPath, partialTypePhrase))
					scriptsWithPartials.Add(FGFindInFiles.assets[i]);
			}
		}
		
		var words = new string[] {
			"partial",
			declaration.kind == SymbolKind.Class ? "class" : declaration.kind == SymbolKind.Struct ? "struct" : "interface",
			declaration.Name
		};
		for (var i = scriptsWithPartials.Count; i --> 0; )
		{
			var assetPath = AssetDatabase.GUIDToAssetPath(scriptsWithPartials[i]);
			if (FGFindInFiles.ContainsWordsSequence(assetPath, words))
			{
				asyncParseBuffers.Enqueue(scriptsWithPartials[i]);
				scriptsWithPartials.RemoveAt(i);
			}
		}
		
		EditorApplication.update -= OnUpdate;
		EditorApplication.update += OnUpdate;
	}
Пример #6
0
 public override void RemoveDeclaration(SymbolDeclaration symbol)
 {
     if (symbol.kind == SymbolKind.Parameter && parameters != null)
     {
         parameters.Remove((SD_Instance_Parameter)symbol.definition);
     }
     else
     {
         base.RemoveDeclaration(symbol);
     }
 }
Пример #7
0
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        if (symbol.kind != SymbolKind.TypeParameter)
        {
            return(base.AddDeclaration(symbol));
        }

        var symbolName = symbol.ReflectionName;// symbol.Name;

        if (typeParameters == null)
        {
            typeParameters = new List <SD_Type_Parameter>();
        }
        var definition = typeParameters.Find(x => x.name == symbolName);

        if (definition == null)
        {
            definition = (SD_Type_Parameter)Create(symbol);
            definition.parentSymbol = this;
            typeParameters.Add(definition);
        }

        symbol.definition = definition;

        var nameNode = symbol.NameNode();

        if (nameNode != null)
        {
            var leaf = nameNode as SyntaxTreeNode_Leaf;
            if (leaf != null)
            {
                leaf.SetDeclaredSymbol(definition);
            }
            else
            {
                // TODO: Remove this block?
                var lastLeaf = ((SyntaxTreeNode_Rule)nameNode).GetLastLeaf();
                if (lastLeaf != null)
                {
                    if (lastLeaf.Parent.RuleName == "typeParameterList")
                    {
                        lastLeaf = lastLeaf.Parent.Parent.LeafAt(0);
                    }
                    lastLeaf.SetDeclaredSymbol(definition);
                }
            }
        }

        //// this.ReflectionName has changed
        //parentSymbol.members.Remove(this);
        //parentSymbol.members[ReflectionName] = this;

        return(definition);
    }
Пример #8
0
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        if (symbol.kind == SymbolKind.Parameter)
        {
            SymbolDefinition definition = AddParameter(symbol);
            symbol.definition = definition;
            return(definition);
        }

        return(base.AddDeclaration(symbol));
    }
 public override void RemoveDeclaration(SymbolDeclaration symbol)
 {
     if ((symbol.kind == SymbolKind.Method) && declaration == symbol)
     {
         declaration = null;
         parentScope.RemoveDeclaration(symbol);
     }
     else if (declaration != null && declaration.definition != null)
     {
         declaration.definition.RemoveDeclaration(symbol);
     }
 }
 public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
 {
     if (symbol.scope == null)
     {
         symbol.scope = this;
     }
     if (declaration == null)
     {
         Debug.LogWarning("Missing declaration in SymbolDeclarationScope! Can't add " + symbol + "\nfor node: " + parseTreeNode);
         return(null);
     }
     return(declaration.definition.AddDeclaration(symbol));
 }
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        if (symbol.kind == SymbolKind.Parameter)
        {
            SymbolDefinition definition = AddParameter(symbol);
            //	if (!members.TryGetValue(symbolName, out definition) || definition is ReflectedMember || definition is ReflectedType)
            //		definition = AddMember(symbol);

            symbol.definition = definition;
            return(definition);
        }

        return(base.AddDeclaration(symbol));
    }
Пример #12
0
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        symbol.scope = this;
        if (localSymbols == null)
        {
            localSymbols = new List <SymbolDefinition>();
        }

        var definition = SymbolDefinition.Create(symbol);

        localSymbols.Add(definition);

        return(definition);
    }
Пример #13
0
    public override void RemoveDeclaration(SymbolDeclaration symbol)
    {
        if (symbol.kind == SymbolKind.TypeParameter && typeParameters != null)
        {
            if (typeParameters.Remove(symbol.definition as SD_Type_Parameter))
            {
                //// this.ReflectionName has changed
                //parentSymbol.members.Remove(this);
                //parentSymbol.members[ReflectionName] = this;
            }
        }

        base.RemoveDeclaration(symbol);
    }
Пример #14
0
    public override void RemoveDeclaration(SymbolDeclaration symbol)
    {
        if (IsExtensionMethod && symbol.kind == SymbolKind.Parameter && symbol.definition.modifiers == Modifiers.This &&
            (symbol.parseTreeNode == null || symbol.parseTreeNode.Parent == null || symbol.parseTreeNode.Parent.m_iChildIndex == 0))
        {
            isExtensionMethod = false;

            var parentType = (parentSymbol.kind == SymbolKind.MethodGroup ? parentSymbol.parentSymbol : parentSymbol) as TypeDefinitionBase;

            var namespaceDefinition = parentType.parentSymbol;
            if (namespaceDefinition is SD_NameSpace)
            {
                --parentType.numExtensionMethods;
            }
        }
        base.RemoveDeclaration(symbol);
    }
Пример #15
0
    public SymbolDefinition AddParameter(SymbolDeclaration symbol)
    {
        var symbolName = symbol.Name;
        var parameter  = (SD_Instance_Parameter)Create(symbol);

        parameter.type         = new SymbolReference(symbol.parseTreeNode.FindChildByName("type"));
        parameter.parentSymbol = this;
        if (!string.IsNullOrEmpty(symbolName))
        {
            if (parameters == null)
            {
                parameters = new List <SD_Instance_Parameter>();
            }
            parameters.Add(parameter);
        }
        return(parameter);
    }
Пример #16
0
    public override void RemoveDeclaration(SymbolDeclaration symbol)
    {
        switch (symbol.kind)
        {
        case SymbolKind.LocalConstant:
        case SymbolKind.Variable:
        case SymbolKind.ForEachVariable:
        case SymbolKind.FromClauseVariable:
            base.RemoveDeclaration(symbol);
            return;
        }

        if (definition != null)
        {
            definition.RemoveDeclaration(symbol);
        }
        base.RemoveDeclaration(symbol);
    }
Пример #17
0
    public SymbolDefinition AddTypeParameter(SymbolDeclaration symbol)
    {
        var symbolName = symbol.Name;

        if (typeParameters == null)
        {
            typeParameters = new List <SD_Type_Parameter>();
        }
        var definition = typeParameters.Find(x => x.name == symbolName);

        if (definition == null)
        {
            definition = (SD_Type_Parameter)Create(symbol);
            definition.parentSymbol = this;
            typeParameters.Add(definition);
        }

        symbol.definition = definition;

        var nameNode = symbol.NameNode();

        if (nameNode != null)
        {
            var leaf = nameNode as SyntaxTreeNode_Leaf;
            if (leaf != null)
            {
                leaf.SetDeclaredSymbol(definition);
            }
            else
            {
                var lastLeaf = ((SyntaxTreeNode_Rule)nameNode).GetLastLeaf();
                if (lastLeaf != null)
                {
                    if (lastLeaf.Parent.RuleName == "typeParameterList")
                    {
                        lastLeaf = lastLeaf.Parent.Parent.LeafAt(0);
                    }
                    lastLeaf.SetDeclaredSymbol(definition);
                }
            }
        }

        return(definition);
    }
Пример #18
0
 public override void RemoveDeclaration(SymbolDeclaration symbol)
 {
     if (localSymbols != null)
     {
         localSymbols.RemoveAll((SymbolDefinition x) =>
         {
             if (x.declarations == null)
             {
                 return(false);
             }
             if (!x.declarations.Remove(symbol))
             {
                 return(false);
             }
             return(x.declarations.Count == 0);
         });
     }
     symbol.definition = null;
 }
Пример #19
0
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        var result = base.AddDeclaration(symbol);

        if (IsStatic && result.kind == SymbolKind.Parameter && result.modifiers == Modifiers.This &&
            symbol.parseTreeNode != null && symbol.parseTreeNode.Parent != null && symbol.parseTreeNode.Parent.m_iChildIndex == 0)
        {
            var parentType = (parentSymbol.kind == SymbolKind.MethodGroup ? parentSymbol.parentSymbol : parentSymbol) as TypeDefinitionBase;
            if (parentType.kind == SymbolKind.Class && parentType.IsStatic && parentType.NumTypeParameters == 0)
            {
                var namespaceDefinition = parentType.parentSymbol;
                if (namespaceDefinition is SD_NameSpace)
                {
                    isExtensionMethod = true;
                    ++parentType.numExtensionMethods;
                }
            }
        }

        return(result);
    }
    public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
    {
        if (definition == null)
        {
            return(null);
        }

        symbol.scope = this;

        if (symbol.kind == SymbolKind.Class ||
            symbol.kind == SymbolKind.Struct ||
            symbol.kind == SymbolKind.Interface ||
            symbol.kind == SymbolKind.Enum ||
            symbol.kind == SymbolKind.Delegate)
        {
            if (typeDeclarations == null)
            {
                typeDeclarations = new List <SymbolDeclaration>();
            }
            typeDeclarations.Add(symbol);
        }

        if (symbol.kind == SymbolKind.ImportedNamespace)
        {
            declaration.importedNamespaces.Add(new SymbolReference(symbol.parseTreeNode.ChildAt(0)));
            return(null);
        }
        else if (symbol.kind == SymbolKind.TypeAlias)
        {
            declaration.typeAliases.Add(new TypeAlias
            {
                name        = symbol.parseTreeNode.ChildAt(0).Print(),
                type        = new SymbolReference(symbol.parseTreeNode.ChildAt(2)),
                declaration = symbol
            });
            return(null);
        }

        return(definition.AddDeclaration(symbol));
    }
 public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
 {
     Debug.LogException(new InvalidOperationException());
     return(null);
 }
 public override void RemoveDeclaration(SymbolDeclaration symbol)
 {
     Debug.LogException(new InvalidOperationException());
 }
Пример #23
0
    public override TypeDefinitionBase BaseType()
    {
        if (resolvingBaseType)
        {
            return(null);
        }
        resolvingBaseType = true;

        if (baseType != null && (baseType.Definition == null || !baseType.Definition.IsValid()) ||
            interfaces != null && interfaces.Exists(x => x.Definition == null || !x.Definition.IsValid()))
        {
            baseType   = null;
            interfaces = null;
        }

        if (baseType == null && interfaces == null)
        {
            interfaces = new List <SymbolReference>();

            SyntaxTreeNode_Rule baseNode          = null;
            SyntaxTreeNode_Rule interfaceListNode = null;
            SymbolDeclaration   decl = null;
            if (declarations != null)
            {
                foreach (var d in declarations)
                {
                    if (d != null)
                    {
                        baseNode = (SyntaxTreeNode_Rule)d.parseTreeNode.FindChildByName(
                            d.kind == SymbolKind.Class ? "classBase" :
                            d.kind == SymbolKind.Struct ? "structInterfaces" :
                            "interfaceBase");
                        interfaceListNode = baseNode != null?baseNode.NodeAt(1) : null;

                        if (baseNode != null)
                        {
                            decl = d;
                            break;
                        }
                    }
                }
            }

            if (decl != null)
            {
                switch (decl.kind)
                {
                case SymbolKind.Class:
                    if (interfaceListNode != null)
                    {
                        baseType = new SymbolReference(interfaceListNode.ChildAt(0));
                        if (baseType.Definition.kind == SymbolKind.Interface)
                        {
                            interfaces.Add(baseType);
                            baseType = this != builtInTypes_object?ReflectedTypeReference.ForType(typeof(object)) : null;
                        }

                        for (var i = 2; i < interfaceListNode.NumValidNodes; i += 2)
                        {
                            interfaces.Add(new SymbolReference(interfaceListNode.ChildAt(i)));
                        }
                    }
                    else
                    {
                        baseType = this != builtInTypes_object?ReflectedTypeReference.ForType(typeof(object)) : null;
                    }
                    break;

                case SymbolKind.Struct:
                case SymbolKind.Interface:
                    baseType = decl.kind == SymbolKind.Struct ?
                               ReflectedTypeReference.ForType(typeof(ValueType)) :
                               ReflectedTypeReference.ForType(typeof(object));
                    if (interfaceListNode != null)
                    {
                        for (var i = 0; i < interfaceListNode.NumValidNodes; i += 2)
                        {
                            interfaces.Add(new SymbolReference(interfaceListNode.ChildAt(i)));
                        }
                    }
                    break;

                case SymbolKind.Enum:
                    baseType = ReflectedTypeReference.ForType(typeof(Enum));
                    break;

                case SymbolKind.Delegate:
                    baseType = ReflectedTypeReference.ForType(typeof(MulticastDelegate));
                    break;
                }
            }
            //Debug.Log("BaseType() of " + this + " is " + (baseType != null ? baseType.definition.ToString() : "null"));
        }

        var result = baseType != null ? baseType.Definition as TypeDefinitionBase : base.BaseType();

        if (result == this)
        {
            baseType = new SymbolReference(circularBaseType);
            result   = circularBaseType;
        }
        resolvingBaseType = false;
        return(result);
    }
Пример #24
0
 public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
 {
     return(base.AddDeclaration(symbol));
 }
Пример #25
0
 public override void RemoveDeclaration(SymbolDeclaration symbol)
 {
 }
Пример #26
0
 public abstract SymbolDefinition AddDeclaration(SymbolDeclaration symbol);
Пример #27
0
    private SymbolReference TypeOfImplicitParameter(SymbolDeclaration declaration)
    {
        int index = 0;
        var node  = declaration.parseTreeNode;

        if (node.Parent.RuleName == "implicitAnonymousFunctionParameterList")
        {
            index = node.m_iChildIndex / 2;
            node  = node.Parent;
        }
        node = node.Parent; // anonymousFunctionSignature
        node = node.Parent; // lambdaExpression
        node = node.Parent; // nonAssignmentExpression
        node = node.Parent; // elementInitializer or expression
        if (node.RuleName == "elementInitializer")
        {
            node = node.Parent // elementInitializerList
                   .Parent     // collectionInitializer
                   .Parent     // objectOrCollectionInitializer
                   .Parent     // objectCreationExpression
                   .Parent;    // primaryExpression
            if (node.RuleName != "primaryExpression")
            {
                return(null);
            }

            node = node.NodeAt(1);
            if (node == null || node.RuleName != "nonArrayType")
            {
                return(null);
            }

            var collectionType = ResolveNode(node.ChildAt(0)).TypeOf() as TypeDefinitionBase;
            if (collectionType != null && collectionType.kind != SymbolKind.Error)
            {
                var enumerableType = collectionType.ConvertTo(builtInTypes_IEnumerable_1) as SD_Type_Constructed;

                var targetTypeReference = enumerableType == null || enumerableType.typeArguments == null ? null : enumerableType.typeArguments.FirstOrDefault();
                var targetType          = targetTypeReference == null ? null : targetTypeReference.Definition;
                if (targetType != null && targetType.kind == SymbolKind.Delegate)
                {
                    var delegateParameters = targetType.GetParameters();
                    if (delegateParameters != null && index < delegateParameters.Count)
                    {
                        var type = delegateParameters[index].TypeOf();
                        type = type.SubstituteTypeParameters(targetType);
                        return(new SymbolReference(type));
                    }
                }
            }
        }
        if (node.RuleName == "expression" && (node.Parent.RuleName == "localVariableInitializer" || node.Parent.RuleName == "variableInitializer"))
        {
            node = node.Parent.Parent;
            if (node.RuleName == "variableInitializerList")
            {
                node = node.Parent.Parent.Parent.NodeAt(1);
                if (node == null || node.RuleName != "nonArrayType")
                {
                    return(null);
                }
            }
            else if (node.RuleName != "localVariableDeclarator" && node.RuleName != "variableDeclarator")
            {
                return(null);
            }

            var targetSymbol = node.ChildAt(0).ResolvedSymbol ?? ResolveNode(node.ChildAt(0));
            if (targetSymbol != null && targetSymbol.kind != SymbolKind.Error)
            {
                var targetType = targetSymbol.kind == SymbolKind.Delegate ? targetSymbol : targetSymbol.TypeOf();
                if (targetType != null && targetType.kind == SymbolKind.Delegate)
                {
                    var delegateParameters = targetType.GetParameters();
                    if (delegateParameters != null && index < delegateParameters.Count)
                    {
                        var type = delegateParameters[index].TypeOf();
                        type = type.SubstituteTypeParameters(targetType);
                        return(new SymbolReference(type));
                    }
                }
            }
        }
        else if (node.RuleName == "expression" && node.Parent.RuleName == "argumentValue")
        {
            node = node.Parent; // argumentValue
            if (node.m_iChildIndex == 0)
            {
                node = node.Parent; // argument
                var argumentIndex = node.m_iChildIndex / 2;

                node = node.Parent; // argumentList
                node = node.Parent; // arguments
                node = node.Parent; // constructorInitializer or attribute or primaryExpressionPart or objectCreationExpression
                if (node.RuleName == "primaryExpressionPart")
                {
                    SyntaxTreeNode_Leaf methodId = null;
                    node = node.Parent.NodeAt(node.m_iChildIndex - 1); // primaryExpressionStart or primaryExpressionPart
                    if (node.RuleName == "primaryExpressionStart")
                    {
                        methodId = node.LeafAt(0);
                    }
                    else // node.RuleName == "primaryExpressionPart"
                    {
                        node = node.NodeAt(0);
                        if (node.RuleName == "accessIdentifier")
                        {
                            methodId = node.LeafAt(1);
                        }
                    }
                    if (methodId != null && methodId.token.tokenKind == LexerToken.Kind.Identifier)
                    {
                        if (methodId.ResolvedSymbol == null || methodId.ResolvedSymbol.kind == SymbolKind.MethodGroup)
                        {
                            SymbolResolver.ResolveNode(node);
                        }

                        var method            = methodId.ResolvedSymbol as MethodDefinition;
                        var constructedSymbol = methodId.ResolvedSymbol as SD_ConstructedReference;
                        if (method != null)
                        {
                            if (method.IsExtensionMethod)
                            {
                                var nodeLeft = methodId.Parent;
                                if (nodeLeft != null && nodeLeft.RuleName == "accessIdentifier")
                                {
                                    nodeLeft = nodeLeft.FindPreviousNode() as SyntaxTreeNode_Rule;
                                    if (nodeLeft != null)
                                    {
                                        if (nodeLeft.RuleName == "primaryExpressionPart" || nodeLeft.RuleName == "primaryExpressionStart")
                                        {
                                            var symbolLeft = SymbolResolver.GetResolvedSymbol(nodeLeft);
                                            if (symbolLeft != null && symbolLeft.kind != SymbolKind.Error && !(symbolLeft is TypeDefinitionBase))
                                            {
                                                ++argumentIndex;
                                            }
                                        }
                                        else
                                        {
                                            ++argumentIndex;
                                        }
                                    }
                                }
                            }

                            if (argumentIndex < method.parameters.Count)
                            {
                                var parameter     = method.parameters[argumentIndex];
                                var parameterType = parameter.TypeOf();
                                if (parameterType.kind == SymbolKind.Delegate)
                                {
                                    parameterType = parameterType.SubstituteTypeParameters(method);
                                    var delegateParameters = parameterType.GetParameters();
                                    if (delegateParameters != null && index < delegateParameters.Count)
                                    {
                                        var type = delegateParameters[index].TypeOf();
                                        type = type.SubstituteTypeParameters(parameterType);
                                        //type = type.SubstituteTypeParameters(method);
                                        return(new SymbolReference(type));
                                    }
                                }
                            }
                        }
                        else if (constructedSymbol != null && constructedSymbol.kind == SymbolKind.Method)
                        {
                            var genericMethod = constructedSymbol.referencedSymbol;
                            var parameters    = genericMethod.GetParameters();
                            if (parameters != null && argumentIndex < parameters.Count)
                            {
                                var parameter     = parameters[argumentIndex];
                                var parameterType = parameter.TypeOf();
                                if (parameterType.kind == SymbolKind.Delegate)
                                {
                                    parameterType = parameterType.SubstituteTypeParameters(constructedSymbol);
                                    var delegateParameters = parameterType.GetParameters();
                                    if (delegateParameters != null && index < delegateParameters.Count)
                                    {
                                        var type = delegateParameters[index].TypeOf();
                                        type = type.SubstituteTypeParameters(parameterType);
                                        //type = type.SubstituteTypeParameters(constructedSymbol);
                                        return(new SymbolReference(type));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        return(null);
    }
Пример #28
0
 public abstract void RemoveDeclaration(SymbolDeclaration symbol);
Пример #29
0
 public override void RemoveDeclaration(SymbolDeclaration symbol)
 {
     base.RemoveDeclaration(symbol);
 }
Пример #30
0
 public override SymbolDefinition AddDeclaration(SymbolDeclaration symbol)
 {
     return(null);
 }
	public static void FindOtherTypeDeclarationParts(SymbolDeclaration declaration)
	{
		if (scriptsWithPartialClass == null)
		{
			scriptsWithPartialClass = new Dictionary<AssemblyDefinition.UnityAssembly, List<string>>();
			scriptsWithPartialStruct = new Dictionary<AssemblyDefinition.UnityAssembly, List<string>>();
			scriptsWithPartialInterface = new Dictionary<AssemblyDefinition.UnityAssembly, List<string>>();
		}
		
		var typeDefinition = declaration.definition as TypeDefinition;
		if (typeDefinition == null)
			return;
		var assemblyId = typeDefinition.Assembly.assemblyId;
		
		var cachedAssemblyScripts =
			declaration.kind == SymbolKind.Class ? scriptsWithPartialClass :
			declaration.kind == SymbolKind.Struct ? scriptsWithPartialStruct :
			scriptsWithPartialInterface;
		List<string> scriptsWithPartials;
		if (!cachedAssemblyScripts.TryGetValue(assemblyId, out scriptsWithPartials))
		{
			FGFindInFiles.Reset();
			FGFindInFiles.FindAllAssemblyScripts(assemblyId);
			
			cachedAssemblyScripts[assemblyId] = scriptsWithPartials = new List<string>(FGFindInFiles.assets.Count);
			
			var partialTypePhrase = new string[] {
				"partial",
				declaration.kind == SymbolKind.Class ? "class" : declaration.kind == SymbolKind.Struct ? "struct" : "interface"
			};
			for (var i = FGFindInFiles.assets.Count; i --> 0; )
			{
				var assetPath = AssetDatabase.GUIDToAssetPath(FGFindInFiles.assets[i]);
				if (FGFindInFiles.ContainsWordsSequence(assetPath, partialTypePhrase))
					scriptsWithPartials.Add(FGFindInFiles.assets[i]);
			}
		}
		
		var words = new string[] {
			"partial",
			declaration.kind == SymbolKind.Class ? "class" : declaration.kind == SymbolKind.Struct ? "struct" : "interface",
			declaration.Name
		};
		for (var i = scriptsWithPartials.Count; i --> 0; )
		{
			var assetPath = AssetDatabase.GUIDToAssetPath(scriptsWithPartials[i]);
			if (FGFindInFiles.ContainsWordsSequence(assetPath, words))
			{
				asyncParseBuffers.Enqueue(scriptsWithPartials[i]);
				scriptsWithPartials.RemoveAt(i);
			}
		}
		
		EditorApplication.update -= OnUpdate;
		EditorApplication.update += OnUpdate;
	}