示例#1
0
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="location">Location.</param>
        /// <param name="name">Name.</param>
        /// <param name="span">Span.</param>
        /// <param name="modifier">Modifier.</param>
        /// <param name="tableType">TableType.</param>
        /// <param name="variableScopes">VariableScopes.</param>
        /// <param name="fields">Fields.</param>
        /// <param name="constructors">Constructors</param>
        /// <param name="properties">Properties</param>
        /// <param name="methods">Methods</param>
        /// <param name="extends">Extends.</param>
        /// <param name="interfaces">Interfaces</param>
        /// <param name="innerClasses">InnerClasses</param>
        public SymbolTable(
            TextPosition location,
            string name,
            TextSpan span,
            string[] attributes,
            SymbolModifier modifier,
            SymbolTableType tableType,
            VariableScope[] variableScopes,
            Field[] fields,
            Constructor[] constructors,
            Property[] properties,
            Method[] methods,
            string extends,
            string[] interfaces,
            SymbolTable[] innerClasses)
            : base(location, name, span, modifier, name)
        {
            Attributes     = attributes ?? new string[0];
            TableType      = tableType;
            VariableScopes = variableScopes ?? new VariableScope[0];
            Fields         = fields ?? new Field[0];
            Constructors   = constructors ?? new Constructor[0];
            Properties     = properties ?? new Property[0];
            Methods        = methods ?? new Method[0];
            Extends        = extends;
            Interfaces     = interfaces ?? new string[0];
            InnerClasses   = innerClasses ?? new SymbolTable[0];

            CalculateTableType();
        }
        private bool ContainsPublics(IMemberDatabase source, int index)
        {
            SymbolType     type     = source.GetMemberType(index);
            SymbolModifier modifier = source.GetMemberModifiers(index);

            // If this is a public type or extension method, we contain them
            if ((type.IsType() || type.IsExtensionMethod()) && modifier.HasFlag(SymbolModifier.Public))
            {
                return(true);
            }

            // If any descendants contain public types, we contain them
            int childIndex = source.DeclaredMembers.GetFirstChild(index);

            while (childIndex > 0)
            {
                if (ContainsPublics(source, childIndex))
                {
                    return(true);
                }
                childIndex = source.DeclaredMembers.GetNextSibling(childIndex);
            }

            // Otherwise, we don't
            return(false);
        }
示例#3
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="name">Name.</param>
 /// <param name="span">Span.</param>
 /// <param name="modifier">Modifier.</param>
 /// <param name="type">Type.</param>
 public Property(
     TextPosition location,
     string name,
     TextSpan span,
     SymbolModifier modifier,
     string type)
     : base(location, name, span, modifier, type)
 {
 }
示例#4
0
 public MutableSymbol(Symbol source)
 {
     this.Name = source.Name.ToString();
     this.Type = source.Type;
     this.Modifiers = source.Modifiers;
     this.Parameters = source.Parameters.ToString();
     this.FilePath = source.FilePath.ToString();
     this.Line = source.Line;
     this.CharInLine = source.CharInLine;
 }
示例#5
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="name">Name.</param>
 /// <param name="span">Span.</param>
 /// <param name="modifier">Modifier.</param>
 /// <param name="type">Type.</param>
 public Field(
     TextPosition location,
     string name,
     TextSpan span,
     SymbolModifier modifier,
     string type,
     bool isLocal)
     : base(location, name, span, modifier, type)
 {
     IsLocal = isLocal;
 }
示例#6
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="name">Name.</param>
 /// <param name="span">Span.</param>
 /// <param name="modifier">Modifier.</param>
 /// <param name="type">Type.</param>
 /// <param name="parameters">Parameters.</param>
 public Method(
     TextPosition location,
     string name,
     TextSpan span,
     SymbolModifier modifier,
     string type,
     Parameter[] parameters)
     : base(location, name, span, modifier, type)
 {
     Parameters = parameters ?? new Parameter[0];
     BuildSignature();
 }
示例#7
0
        /// <summary>
        /// Read in this object from the xml stream.
        /// </summary>
        /// <param name="reader">The xml stream to read from.</param>
        public override void ReadXml(XmlReader reader)
        {
            base.ReadXml(reader);

            string modifier = reader["modifier"];

            if (modifier == null)
            {
                Modifier = SymbolModifier.None;
            }
            else
            {
                Modifier = (SymbolModifier)int.Parse(modifier);
            }
        }
示例#8
0
        private void AddModifiers(ISymbol MutableSymbol, MutableSymbol result)
        {
            SymbolModifier modifiers = SymbolModifier.None;

            // Convert individual properties
            if (MutableSymbol.IsStatic)
            {
                modifiers |= SymbolModifier.Static;
            }

            // Not needed for scenarios.
            //if (MutableSymbol.IsAbstract) modifiers |= SymbolModifier.Abstract;
            //if (MutableSymbol.IsExtern) modifiers |= SymbolModifier.Extern;
            //if (MutableSymbol.IsOverride) modifiers |= SymbolModifier.Override;
            //if (MutableSymbol.IsSealed) modifiers |= SymbolModifier.Sealed;
            //if (MutableSymbol.IsVirtual) modifiers |= SymbolModifier.Virtual;

            // Convert accessibility
            switch (MutableSymbol.DeclaredAccessibility)
            {
            case Accessibility.Public:
                modifiers |= SymbolModifier.Public;
                break;

            case Accessibility.Protected:
                modifiers |= SymbolModifier.Protected;
                break;

            case Accessibility.Private:
                modifiers |= SymbolModifier.Private;
                break;

            case Accessibility.Internal:
                modifiers |= SymbolModifier.Internal;
                break;

            case Accessibility.ProtectedAndInternal:
            case Accessibility.ProtectedOrInternal:
                modifiers |= SymbolModifier.Protected | SymbolModifier.Internal;
                break;

            default:
                throw new ArgumentException("Accessibility unhandled: " + MutableSymbol.DeclaredAccessibility.ToString());
            }

            result.Modifiers = modifiers;
        }
示例#9
0
        private void AddModifiers(TypeAttributes attributes, MutableSymbol symbolToAdd)
        {
            SymbolModifier modifiers = symbolToAdd.Modifiers;

            // Same as Roslyn PENamedTypeSymbol.DeclaredAccessibility
            switch (attributes & TypeAttributes.VisibilityMask)
            {
            case TypeAttributes.NestedAssembly:
                modifiers = SymbolModifier.Internal;
                break;

            case TypeAttributes.NestedFamORAssem:
            case TypeAttributes.NestedFamANDAssem:
                modifiers = SymbolModifier.Protected | SymbolModifier.Internal;
                break;

            case TypeAttributes.NestedPrivate:
                modifiers = SymbolModifier.Private;
                break;

            case TypeAttributes.Public:
            case TypeAttributes.NestedPublic:
                modifiers = SymbolModifier.Public;
                break;

            case TypeAttributes.NestedFamily:
                modifiers = SymbolModifier.Protected;
                break;

            case TypeAttributes.NotPublic:
                modifiers = SymbolModifier.Internal;
                break;
            }


            // Same as Roslyn PENamedTypeSymbol.IsStatic
            if (attributes.HasFlag(TypeAttributes.Sealed) && attributes.HasFlag(TypeAttributes.Abstract))
            {
                modifiers |= SymbolModifier.Static;
            }

            symbolToAdd.Modifiers = modifiers;
        }
示例#10
0
        private void AddModifiers(FieldAttributes attributes, MutableSymbol symbolToAdd)
        {
            SymbolModifier modifiers = symbolToAdd.Modifiers;

            // Same as Roslyn PEFieldSymbol.DeclaredAccessibility
            switch (attributes & FieldAttributes.FieldAccessMask)
            {
            case FieldAttributes.Assembly:
                modifiers = SymbolModifier.Internal;
                break;

            case FieldAttributes.FamORAssem:
            case FieldAttributes.FamANDAssem:
                modifiers = SymbolModifier.Protected | SymbolModifier.Internal;
                break;

            case FieldAttributes.Private:
            case FieldAttributes.PrivateScope:
                modifiers = SymbolModifier.Private;
                break;

            case FieldAttributes.Public:
                modifiers = SymbolModifier.Public;
                break;

            case FieldAttributes.Family:
                modifiers = SymbolModifier.Protected;
                break;
            }

            if (attributes.HasFlag(FieldAttributes.Static))
            {
                modifiers |= SymbolModifier.Static;
            }

            symbolToAdd.Modifiers = modifiers;
        }
示例#11
0
 /// <summary>
 /// Get Fields that have the given modifiers.
 /// </summary>
 /// <param name="modifiers">The modifiers to filter by.</param>
 /// <returns>Fields that have the given modifier.</returns>
 public Field[] GetFieldsWithModifiers(SymbolModifier modifiers)
 {
     return(Fields.Where(m => m.Modifier.HasFlag(modifiers)).ToArray());
 }
示例#12
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="name">Name.</param>
 /// <param name="span">Span.</param>
 /// <param name="modifier">Modifier.</param>
 public ModifiedSymbol(TextPosition location, string name, TextSpan span, SymbolModifier modifier)
     : base(location, name, span)
 {
     Modifier = modifier;
 }
示例#13
0
        /// <summary>
        /// Process the the given token.
        /// </summary>
        /// <param name="token">The token to process.</param>
        /// <param name="span">The text span of the given token.</param>
        /// <param name="nodes">The nodes that reduce to the given token.</param>
        /// <returns>The resulting node from the reduce operation.</returns>
        public ApexSyntaxNode Process(Tokens token, ApexTextSpan span, ApexSyntaxNode[] nodes)
        {
            ApexSyntaxNode node = new ApexSyntaxNode(token, span, nodes);

            switch (node.Token)
            {
                // type reference
                case Tokens.grammar_type:
                    ApexSyntaxNode[] identifierNodes = node.GetNodesWithToken(Tokens.grammar_identifier);
                    if (identifierNodes.Length > 0)
                    {
                        List<TextSpan> parts = new List<TextSpan>();
                        foreach (ApexSyntaxNode part in identifierNodes)
                            if (part.Nodes[0].Token != Tokens.grammar_non_reserved_identifier)
                                parts.Add(new TextSpan(part.TextSpan));

                        if (parts.Count > 0)
                            _typeReferences.Add(new ReferenceTypeSymbol(
                                new TextPosition(node.TextSpan),
                                node.GetLeavesDisplayText(),
                                new TextSpan(node.TextSpan),
                                parts.ToArray()));
                    }

                    break;

                // local variable
                case Tokens.grammar_local_variable_declaration:
                    string variableType = node.GetChildNodeWithToken(Tokens.grammar_type).GetLeavesDisplayText();
                    ApexSyntaxNode[] variableDeclarators = node.GetNodesWithToken(Tokens.grammar_local_variable_declarator);

                    foreach (ApexSyntaxNode declarator in variableDeclarators)
                    {
                        _variables.Push(new Field(
                            new TextPosition(declarator.Nodes[0].TextSpan),
                            declarator.Nodes[0].GetLeavesDisplayText(),
                            null,
                            SymbolModifier.Private,
                            variableType,
                            true));
                    }

                    break;

                // variable scope
                case Tokens.grammar_block:
                case Tokens.grammar_embedded_statement:
                    _variableScopes.Push(new VariableScope(
                        new TextSpan(node.TextSpan),
                        GetSymbols<Field>(node, _variables)));

                    break;

                // for statement
                case Tokens.grammar_for_statement:
                    ApexSyntaxNode initNode = node.GetChildNodeWithToken(Tokens.grammar_for_initializer);
                    if (initNode != null)
                    {
                        ApexSyntaxNode varInitNode = node.GetChildNodeWithToken(Tokens.grammar_local_variable_declaration);
                        if (varInitNode != null)
                        {
                            List<Field> varFields = new List<Field>();
                            ApexSyntaxNode[] varNodes = varInitNode.GetNodesWithToken(Tokens.grammar_local_variable_declaration);
                            foreach (ApexSyntaxNode varNode in varNodes)
                            {
                                ApexSyntaxNode varTypeNode = varNode.GetChildNodeWithToken(Tokens.grammar_type);
                                string varTypeName = varTypeNode.GetLeavesDisplayText();

                                ApexSyntaxNode varNamesNode = varNode.GetChildNodeWithToken(Tokens.grammar_local_variable_declarators);
                                foreach (ApexSyntaxNode varNameNode in varNamesNode.GetNodesWithToken(Tokens.grammar_local_variable_declarator))
                                {
                                    varFields.Add(new Field(
                                        new TextPosition(varNameNode.TextSpan),
                                        varNameNode.GetLeavesDisplayText(),
                                        null,
                                        SymbolModifier.Private,
                                        varTypeName,
                                        true));
                                }
                            }

                            if (varFields.Count > 0)
                            {
                                _variableScopes.Push(new VariableScope(
                                    new TextSpan(node.TextSpan),
                                    varFields.ToArray()));
                            }
                        }
                    }

                    break;

                // foreach statement
                case Tokens.grammar_foreach_statement:
                    _variableScopes.Push(new VariableScope(
                        new TextSpan(node.TextSpan),
                        new Field[] { new Field(
                            new TextPosition(node.Nodes[3].TextSpan),
                            node.Nodes[3].GetLeavesDisplayText(),
                            null,
                            SymbolModifier.Private,
                            node.Nodes[2].GetLeavesDisplayText(),
                            true) }));
                    break;

                // catch clause
                case Tokens.grammar_specific_catch_clause:
                    ApexSyntaxNode classTypeNode = node.GetChildNodeWithToken(Tokens.grammar_class_type);
                    ApexSyntaxNode identifierNode = node.GetChildNodeWithToken(Tokens.grammar_identifier);
                    if (classTypeNode != null && identifierNode != null)
                    {
                        _variableScopes.Push(new VariableScope(
                            new TextSpan(node.TextSpan),
                            new Field[] { new Field(
                                new TextPosition(identifierNode.TextSpan),
                                identifierNode.GetLeavesDisplayText(),
                                null,
                                SymbolModifier.Private,
                                classTypeNode.GetLeavesDisplayText(),
                                true)}));


                        _typeReferences.Add(new ReferenceTypeSymbol(
                            new TextPosition(classTypeNode.TextSpan),
                            classTypeNode.GetLeavesDisplayText(),
                            null,
                            new TextSpan[] { new TextSpan(classTypeNode.TextSpan) }));
                    }
                    break;

                // field
                case Tokens.grammar_field_declaration:
                    SymbolModifier fieldVisibility = GetModifiers(node.GetNodesWithToken(Tokens.grammar_modifier));
                    string fieldType = node.GetChildNodeWithToken(Tokens.grammar_type).GetLeavesDisplayText();
                    ApexSyntaxNode[] fieldDeclarators = node.GetNodesWithToken(Tokens.grammar_variable_declarator);

                    foreach (ApexSyntaxNode declarator in fieldDeclarators)
                    {
                        _fields.Push(new Field(
                            new TextPosition(declarator.Nodes[0].TextSpan),
                            declarator.Nodes[0].GetLeavesDisplayText(),
                            null,
                            fieldVisibility,
                            fieldType,
                            false));
                    }

                    break;

                // enum member
                case Tokens.grammar_enum_member_declaration:
                    _enumFields.Push(new Field(
                        new TextPosition(node.TextSpan),
                        node.GetLeavesDisplayText(),
                        null,
                        SymbolModifier.Final | SymbolModifier.Public | SymbolModifier.Static,
                        "System.Object",
                        false));

                    break;

                // property
                case Tokens.grammar_property_declaration:
                    SymbolModifier propertyVisibility = GetModifiers(node.GetNodesWithToken(Tokens.grammar_modifier));
                    string propertyType = node.GetChildNodeWithToken(Tokens.grammar_type).GetLeavesDisplayText();
                    ApexSyntaxNode propertyName = node.GetChildNodeWithToken(Tokens.grammar_identifier);

                    _properties.Push(new Property(
                        new TextPosition(propertyName.TextSpan),
                        propertyName.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        propertyVisibility,
                        propertyType));

                    break;

                // constructor
                case Tokens.grammar_constructor_declaration:
                    SymbolModifier constructorVisibility = GetModifiers(node.GetNodesWithToken(Tokens.grammar_modifier));
                    ApexSyntaxNode constructorName = node.GetNodeWithToken(Tokens.grammar_constructor_declarator).Nodes[0];
                    Parameter[] constructorParameters = GetParameters(node.GetNodesWithToken(Tokens.grammar_fixed_parameter));

                    _constructors.Push(new Constructor(
                        new TextPosition(constructorName.TextSpan),
                        constructorName.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        constructorVisibility,
                        constructorParameters));

                    break;

                // method
                case Tokens.grammar_method_declaration:
                    ApexSyntaxNode methodHeader = node.GetNodeWithToken(Tokens.grammar_method_header);
                    SymbolModifier methodVisibility = GetModifiers(methodHeader.GetNodesWithToken(Tokens.grammar_modifier));
                    ApexSyntaxNode methodName = methodHeader.GetChildNodeWithToken(Tokens.grammar_identifier);
                    Parameter[] methodParameters = GetParameters(methodHeader.GetNodesWithToken(Tokens.grammar_fixed_parameter));
                    string methodReturnType = (methodHeader.GetChildNodeWithToken(Tokens.KEYWORD_VOID) != null) ?
                        "void" :
                        methodHeader.GetChildNodeWithToken(Tokens.grammar_type).GetLeavesDisplayText();

                    _methods.Push(new Method(
                        new TextPosition(methodName.TextSpan),
                        methodName.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        methodVisibility,
                        methodReturnType,
                        methodParameters));

                    break;

                // interface method
                case Tokens.grammar_interface_method_declaration:
                    ApexSyntaxNode interfaceMethodName = node.GetChildNodeWithToken(Tokens.grammar_identifier);
                    Parameter[] interfaceMethodParameters = GetParameters(node.GetNodesWithToken(Tokens.grammar_fixed_parameter));
                    string interfaceMethodReturnType = (node.GetChildNodeWithToken(Tokens.KEYWORD_VOID) != null) ?
                        "void" :
                        node.GetChildNodeWithToken(Tokens.grammar_type).GetLeavesDisplayText();

                    _methods.Push(new Method(
                        new TextPosition(interfaceMethodName.TextSpan),
                        interfaceMethodName.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        SymbolModifier.Public,
                        interfaceMethodReturnType,
                        interfaceMethodParameters));

                    break;

                // class
                case Tokens.grammar_class_declaration:
                    ApexSyntaxNode classModifiers = node.GetChildNodeWithToken(Tokens.grammar_modifiers);
                    SymbolModifier classVisibility = SymbolModifier.Private;
                    if (classModifiers != null)
                        classVisibility = GetModifiers(classModifiers.GetNodesWithToken(Tokens.grammar_modifier));

                    ApexSyntaxNode className = node.GetChildNodeWithToken(Tokens.grammar_identifier);
                    _typeReferences.Add(new ReferenceTypeSymbol(
                        new TextPosition(className.TextSpan), 
                        className.GetLeavesDisplayText(), 
                        null,
                        new TextSpan[] { new TextSpan(className.TextSpan) }));

                    ApexSyntaxNode classBase = node.GetChildNodeWithToken(Tokens.grammar_class_base);
                    List<string> classInterfaces = new List<string>();
                    string classExtends = null;
                    if (classBase != null)
                    {
                        foreach (ApexSyntaxNode classInterface in classBase.GetNodesWithToken(Tokens.grammar_interface_type))
                        {
                            string name = classInterface.GetLeavesDisplayText();
                            classInterfaces.Add(name);
                            _typeReferences.Add(new ReferenceTypeSymbol(
                                new TextPosition(classInterface.TextSpan), 
                                name, 
                                null, 
                                new TextSpan[] { new TextSpan(classInterface.TextSpan) }));
                        }

                        ApexSyntaxNode extends = classBase.GetChildNodeWithToken(Tokens.grammar_class_type);
                        if (extends != null)
                        {
                            classExtends = extends.GetLeavesDisplayText();
                            _typeReferences.Add(new ReferenceTypeSymbol(
                                new TextPosition(extends.TextSpan),
                                classExtends,
                                null,
                                new TextSpan[] { new TextSpan(extends.TextSpan) }));
                        }
                    }

                    List<string> attributeList = new List<string>();
                    ApexSyntaxNode attributes = node.GetChildNodeWithToken(Tokens.grammar_attributes);
                    if (attributes != null)
                    {
                        foreach (ApexSyntaxNode attributeSection in attributes.GetNodesWithToken(Tokens.grammar_attribute_section))
                        {
                            attributeList.Add(attributeSection.GetChildNodeWithToken(Tokens.grammar_identifier).GetLeavesDisplayText());
                        }
                    }

                    List<VariableScope> classScopes = new List<VariableScope>();
                    

                    _classes.Push(new SymbolTable(
                        new TextPosition(className.TextSpan),
                        className.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        attributeList.ToArray(),
                        classVisibility,
                        SymbolTableType.Class,
                        GetSymbols<VariableScope>(node, _variableScopes),
                        GetSymbols<Field>(node, _fields),
                        GetSymbols<Constructor>(node, _constructors),
                        GetSymbols<Property>(node, _properties),
                        GetSymbols<Method>(node, _methods),
                        classExtends,
                        classInterfaces.ToArray(),
                        GetSymbols<SymbolTable>(node, _classes)));

                    break;

                // interface
                case Tokens.grammar_interface_declaration:
                    ApexSyntaxNode interfaceModifiers = node.GetChildNodeWithToken(Tokens.grammar_modifiers);
                    SymbolModifier interfaceVisibility = SymbolModifier.Private;
                    if (interfaceModifiers != null)
                        interfaceVisibility = GetModifiers(interfaceModifiers.GetNodesWithToken(Tokens.grammar_modifier));

                    ApexSyntaxNode interfaceName = node.GetChildNodeWithToken(Tokens.grammar_identifier);
                    _typeReferences.Add(new ReferenceTypeSymbol(new TextPosition(interfaceName.TextSpan), interfaceName.GetLeavesDisplayText(), null, null));

                    ApexSyntaxNode interfaceBase = node.GetChildNodeWithToken(Tokens.grammar_interface_base);
                    List<string> interfaceBases = new List<string>();
                    string interfaceExtends = null;
                    if (interfaceBase != null)
                    {
                        foreach (ApexSyntaxNode interfaceInterface in interfaceBase.GetNodesWithToken(Tokens.grammar_interface_type))
                        {
                            string name = interfaceInterface.GetLeavesDisplayText();
                            interfaceBases.Add(interfaceInterface.GetLeavesDisplayText());
                            _typeReferences.Add(new ReferenceTypeSymbol(
                                new TextPosition(interfaceInterface.TextSpan), 
                                name, 
                                null, 
                                new TextSpan[] { new TextSpan(interfaceInterface.TextSpan) }));
                        }

                        ApexSyntaxNode extends = interfaceBase.GetChildNodeWithToken(Tokens.grammar_class_type);
                        if (extends != null)
                        {
                            interfaceExtends = extends.GetLeavesDisplayText();
                            _typeReferences.Add(new ReferenceTypeSymbol(
                                new TextPosition(extends.TextSpan),
                                interfaceExtends,
                                null,
                                new TextSpan[] { new TextSpan(extends.TextSpan) }));
                        }
                    }

                    _classes.Push(new SymbolTable(
                        new TextPosition(interfaceName.TextSpan),
                        interfaceName.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        null,
                        interfaceVisibility,
                        SymbolTableType.Interface,
                        null,
                        null,
                        null,
                        null,
                        GetSymbols<Method>(node, _methods),
                        interfaceExtends,
                        interfaceBases.ToArray(),
                        GetSymbols<SymbolTable>(node, _classes)));

                    break;

                // enum
                case Tokens.grammar_enum_declaration:
                    ApexSyntaxNode enumModifiers = node.GetChildNodeWithToken(Tokens.grammar_modifiers);
                    SymbolModifier enumVisibility = SymbolModifier.Private;
                    if (enumModifiers != null)
                        enumVisibility = GetModifiers(enumModifiers.GetNodesWithToken(Tokens.grammar_modifier));

                    ApexSyntaxNode enumName = node.GetChildNodeWithToken(Tokens.grammar_identifier);
                    _typeReferences.Add(new ReferenceTypeSymbol(
                        new TextPosition(enumName.TextSpan),
                        enumName.GetLeavesDisplayText(), 
                        null,
                        new TextSpan[] { new TextSpan(enumName.TextSpan) }));

                    List<string> enumAttributeList = new List<string>();
                    ApexSyntaxNode enumAttributes = node.GetChildNodeWithToken(Tokens.grammar_attributes);
                    if (enumAttributes != null)
                    {
                        foreach (ApexSyntaxNode attributeSection in enumAttributes.GetNodesWithToken(Tokens.grammar_attribute_section))
                        {
                            enumAttributeList.Add(attributeSection.GetChildNodeWithToken(Tokens.grammar_identifier).GetLeavesDisplayText());
                        }
                    }

                    _classes.Push(new SymbolTable(
                        new TextPosition(enumName.TextSpan),
                        enumName.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        enumAttributeList.ToArray(),
                        enumVisibility,
                        SymbolTableType.Enum,
                        null,
                        GetSymbols<Field>(node, _enumFields),
                        null,
                        null,
                        null,
                        null,
                        null,
                        null));

                    break;

                // trigger
                case Tokens.grammar_trigger_declaration:
                    ApexSyntaxNode headerNode = node.GetChildNodeWithToken(Tokens.grammar_trigger_header);
                    ApexSyntaxNode triggerNameNode = headerNode.Nodes[1];

                    _classes.Push(new SymbolTable(
                        new TextPosition(triggerNameNode.TextSpan),
                        triggerNameNode.GetLeavesDisplayText(),
                        new TextSpan(node.TextSpan),
                        null,
                        SymbolModifier.Private,
                        SymbolTableType.Trigger,
                        GetSymbols<VariableScope>(node, _variableScopes),
                        null,
                        null,
                        null,
                        null,
                        null,
                        null,
                        null));
                    
                    break;

                default:
                    break;
            }

            return node;
        }
示例#14
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="name">Name.</param>
 /// <param name="span">Span.</param>
 /// <param name="modifier">Modifier.</param>
 /// <param name="parameters">Parameters.</param>
 public Constructor(TextPosition location, string name, TextSpan span, SymbolModifier modifier, Parameter[] parameters)
     : base(location, name, span, modifier, null, parameters)
 {
 }
示例#15
0
 public static bool Matches(this SymbolModifier query, SymbolModifier candidate)
 {
     // Modifiers match if every flag on query is set on candidate
     return(((int)candidate & (int)query) == (int)query);
 }
示例#16
0
 /// <summary>
 /// Get Constructors that have the given modifiers.
 /// </summary>
 /// <param name="modifiers">The modifiers to filter by.</param>
 /// <returns>Constructors that have the given modifier.</returns>
 public Constructor[] GetConstructorsWithModifiers(SymbolModifier modifiers)
 {
     return(Constructors.Where(m => m.Modifier.HasFlag(modifiers)).ToArray());
 }
示例#17
0
 /// <summary>
 /// Get Properties that have the given modifiers.
 /// </summary>
 /// <param name="modifiers">The modifiers to filter by.</param>
 /// <returns>Properties that have the given modifier.</returns>
 public Property[] GetPropertiesWithModifiers(SymbolModifier modifiers)
 {
     return(Properties.Where(m => m.Modifier.HasFlag(modifiers)).ToArray());
 }
示例#18
0
 public void ReadBinary(BinaryReader r)
 {
     ParametersIdentifier = r.ReadInt32();
     Type      = (SymbolType)r.ReadByte();
     Modifiers = (SymbolModifier)r.ReadByte();
 }
示例#19
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="location">Location.</param>
 /// <param name="name">Name.</param>
 /// <param name="span">Span.</param>
 /// <param name="modifier">Modifier.</param>
 /// <param name="type">Type.</param>
 public TypedSymbol(TextPosition location, string name, TextSpan span, SymbolModifier modifier, string type)
     : base(location, name, span, modifier)
 {
     Type = type ?? String.Empty;
 }
示例#20
0
 /// <summary>
 /// Get Methods that have the given modifiers.
 /// </summary>
 /// <param name="modifiers">The modifiers to filter by.</param>
 /// <returns>Methods that have the given modifier.</returns>
 public Method[] GetMethodsWithModifiers(SymbolModifier modifiers)
 {
     return(Methods.Where(m => m.Modifier.HasFlag(modifiers)).ToArray());
 }