Beispiel #1
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);
    }
Beispiel #2
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);
    }
    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);

            var nameNode = symbol.NameNode();
            if (nameNode != null)
            {
                nameNode.SetDeclaredSymbol(parameter);
            }
        }
        return(parameter);
    }