public Symbol Add(string name, SymbolCategory categories = SymbolCategory.None)
        {
            var result = new Symbol(name)
            {
                Categories = categories
            };

            Add(result);
            return(result);
        }
示例#2
0
        internal static IEnumerable <ISymbol> GetSourceSymbols(
            Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation,
            SymbolCategory category
            )
        {
            // NYI for local symbols
            var list = GetSourceSymbols(compilation, includeLocal: false);

            var kinds = new List <SymbolKind>();

            if ((category & SymbolCategory.DeclaredNamespace) != 0)
            {
                kinds.Add(SymbolKind.Namespace);
            }

            if ((category & SymbolCategory.DeclaredType) != 0)
            {
                kinds.Add(SymbolKind.NamedType);
                kinds.Add(SymbolKind.TypeParameter);
            }

            if ((category & SymbolCategory.NonTypeMember) != 0)
            {
                kinds.Add(SymbolKind.Field);
                kinds.Add(SymbolKind.Event);
                kinds.Add(SymbolKind.Property);
                kinds.Add(SymbolKind.Method);
            }

            if ((category & SymbolCategory.Parameter) != 0)
            {
                kinds.Add(SymbolKind.Parameter);
            }

            return(list.Where(
                       s =>
            {
                if (s.IsImplicitlyDeclared)
                {
                    return false;
                }

                foreach (var k in kinds)
                {
                    if (s.Kind == k)
                    {
                        return true;
                    }
                }

                return false;
            }
                       ));
        }
示例#3
0
        internal short ItemIndexCategory(string Name, SymbolCategory Category)
        {
            int num = -1;

            for (int i = 0; (i < base.Count()) & (num == -1); i++)
            {
                SymbolBuild build = (SymbolBuild) base[i];
                if ((build.Name.ToUpper() == Name.ToUpper()) & (build.Category() == Category))
                {
                    num = i;
                }
            }
            return((short)num);
        }
        public override IEnumerable<CilSymbolRef> GetSymbolsInCategory(SymbolCategory requestedCategories)
        {
            if ((requestedCategories & this.categories) == 0)
            {
                return Enumerable.Empty<CilSymbolRef>();
            }

            if (Text == null)
            {
                return new[] { CilSymbolRef.Create(TokenType) };
            }
            else
            {
                return new[] { CilSymbolRef.Create(Text) };
            }
        }
示例#5
0
        public override IEnumerable <CilSymbolRef> GetSymbolsInCategory(SymbolCategory category)
        {
            if ((category & SymbolCategory.ExplicitlyUsed) != SymbolCategory.ExplicitlyUsed)
            {
                return(Enumerable.Empty <CilSymbolRef>());
            }

            if (Text == null)
            {
                return(new[] { CilSymbolRef.Create(TokenType) });
            }
            else
            {
                return(new[] { CilSymbolRef.Create(Text) });
            }
        }
        public override IEnumerable<CilSymbolRef> GetSymbolsInCategory(SymbolCategory category)
        {
            if ((category & SymbolCategory.ExplicitlyUsed) != SymbolCategory.ExplicitlyUsed)
            {
                return Enumerable.Empty<CilSymbolRef>();
            }

            if (Text == null)
            {
                return new[] { CilSymbolRef.Create(TokenType) };
            }
            else
            {
                return new[] { CilSymbolRef.Create(Text) };
            }
        }
示例#7
0
        public override IEnumerable <CilSymbolRef> GetSymbolsInCategory(SymbolCategory requestedCategories)
        {
            if ((requestedCategories & this.categories) == 0)
            {
                return(Enumerable.Empty <CilSymbolRef>());
            }

            if (Text == null)
            {
                return(new[] { CilSymbolRef.Create(TokenType) });
            }
            else
            {
                return(new[] { CilSymbolRef.Create(Text) });
            }
        }
示例#8
0
        /// <summary>
        /// Determines whether should move on to the next state
        /// or create new token and then return.
        /// Also fills respective tables with newly created tokens.
        /// </summary>
        /// <param name="ch">Current symbol to process.</param>
        /// <param name="symbolCategory">Category of current symbol.</param>
        /// <param name="symbolClass">Class of current symbol.</param>
        /// <param name="isBufferedTokenCreated">Whether token was created from buffer or not.</param>
        private void ProcessSymbol(char ch, SymbolCategory symbolCategory, string symbolClass, out bool isBufferedTokenCreated)
        {
            isBufferedTokenCreated = false;

            // If current state has link for this symbol
            // then move to the next state and fill buffer with the character.
            if (symbolClass != null &&
                currentState.Links != null &&
                currentState.Links.ContainsKey(symbolClass))
            {
                buffer.Append(ch);
                currentState = GetState(currentState.Links[symbolClass]);

                return;
            }

            // if the buffer is empty and symbol is undefined
            // then an undefined token will be created.
            if (string.IsNullOrWhiteSpace(buffer.ToString()))
            {
                if (symbolCategory == SymbolCategory.Undefined)
                {
                    ParsedToken undefinedToken = new ParsedToken
                    {
                        Id               = -1,
                        TokenClassId     = -1,
                        Name             = ch.ToString(),
                        InRowPosition    = inRowPosition,
                        RowIndex         = rowIndex,
                        InStringPosition = inStringPosition,
                    };

                    tokens.Add(undefinedToken);
                }

                return;
            }


            CreateBuffered();

            isBufferedTokenCreated = true;
        }
 public virtual IEnumerable<CilSymbolRef> GetSymbolsInCategory(SymbolCategory category)
 {
     return Enumerable.Empty<CilSymbolRef>();
 }
示例#10
0
        internal static IEnumerable<ISymbol> GetSourceSymbols(Microsoft.CodeAnalysis.CSharp.CSharpCompilation compilation, SymbolCategory category)
        {
            // NYI for local symbols
            var list = GetSourceSymbols(compilation, includeLocal: false);

            List<SymbolKind> kinds = new List<SymbolKind>();
            if ((category & SymbolCategory.DeclaredNamespace) != 0)
            {
                kinds.Add(SymbolKind.Namespace);
            }

            if ((category & SymbolCategory.DeclaredType) != 0)
            {
                kinds.Add(SymbolKind.NamedType);
                kinds.Add(SymbolKind.TypeParameter);
            }

            if ((category & SymbolCategory.NonTypeMember) != 0)
            {
                kinds.Add(SymbolKind.Field);
                kinds.Add(SymbolKind.Event);
                kinds.Add(SymbolKind.Property);
                kinds.Add(SymbolKind.Method);
            }

            if ((category & SymbolCategory.Parameter) != 0)
            {
                kinds.Add(SymbolKind.Parameter);
            }

            return list.Where(s =>
            {
                if (s.IsImplicitlyDeclared)
                {
                    return false;
                }

                foreach (var k in kinds)
                {
                    if (s.Kind == k)
                    {
                        return true;
                    }
                }

                return false;
            });
        }
示例#11
0
 public static bool Has(this SymbolCategory self, SymbolCategory flag)
 {
     return((self & flag) == flag);
 }
示例#12
0
 public TokenCategoryAttribute(string text, SymbolCategory category)
 {
     this.Text       = text;
     this.categories = category;
 }
示例#13
0
 public TokenCategoryAttribute(Type type, SymbolCategory category)
 {
     this.TokenType  = type;
     this.categories = category;
 }
 public TokenCategoryAttribute(string text, SymbolCategory category)
 {
     this.Text = text;
     this.categories = category;
 }
 public TokenCategoryAttribute(Type type, SymbolCategory category)
 {
     this.TokenType = type;
     this.categories = category;
 }
示例#16
0
 public static bool Has(this SymbolCategory self, SymbolCategory flag)
 {
     return (self & flag) == flag;
 }
 public IEnumerable <CilSymbolRef> GetSymbolsInCategory(SymbolCategory category)
 {
     return(Enumerable.Empty <CilSymbolRef>());
 }