public string getText(StaDynTokenTypes type)
        {
            string textValue = null;

            this._StaDynTypes.TryGetValue(type, out textValue);
            return(textValue);
        }
        //void _buffer_Changed(object sender, TextContentChangedEventArgs e)
        //{
        //    if (e.After != _buffer.CurrentSnapshot)
        //        return;

        //    OnTagsChanged(new SnapshotSpan(_buffer.CurrentSnapshot, 0, _buffer.CurrentSnapshot.Length));
        //}

        //void OnTagsChanged(SnapshotSpan span)
        //{

        //    if (TagsChanged != null)
        //        TagsChanged(this, new SnapshotSpanEventArgs(span));
        //}

        public IEnumerable <ITagSpan <StaDynTokenTag> > GetTags(NormalizedSnapshotSpanCollection spans)
        {
            var currentFile = ProjectFileAST.Instance.getAstFile(FileUtilities.Instance.getCurrentOpenDocumentFilePath());

            //Get the compileMode
            string       dynOption   = StaDyn.StaDynProject.ProjectConfiguration.Instance.GetProperty(PropertyTag.DynVarOption.ToString());
            DynVarOption compileMode = (DynVarOption)Enum.Parse(typeof(DynVarOption), dynOption);

            foreach (SnapshotSpan curSpan in spans)
            {
                ITextSnapshotLine containingLine = curSpan.Start.GetContainingLine();
                int    curLoc                = containingLine.Start.Position;
                int    charsMatched          = 0;
                int    currentPositionInLine = 1;
                string tokenText             = null;
                lexer = new StaDynLexer(containingLine.GetText());

                while (curLoc < containingLine.End)
                {
                    IToken StaDynToken = null;
                    try
                    {
                        StaDynToken = lexer.nextToken();
                    }
                    catch (Exception e)
                    {
                    }
                    if (StaDynToken == null)
                    {
                        break;
                    }
                    tokenText = StaDynToken.getText();

                    if (!string.IsNullOrEmpty(tokenText))
                    {
                        charsMatched           = StaDynToken.getText().Length;
                        currentPositionInLine += StaDynToken.getText().Length;
                    }
                    else
                    {
                        charsMatched = 0;
                    }


                    //Sets the line number
                    StaDynToken.setLine(containingLine.LineNumber);
                    StaDynToken.setColumn(currentPositionInLine);

                    StaDynTokenTypes tokenType = lexer.getTokenType(StaDynToken.Type);


                    //Check if the current token its a type
                    //Needed for highlighting
                    if (tokenType == StaDynTokenTypes.Identifier && StaDynTypeTableFunctions.Instance.CheckTokenTypeOnCurrentDocument(StaDynToken))
                    {
                        tokenType = StaDynTokenTypes.TypeDefinition;
                    }

                    //If the compile mode is set to EverythingDynamic
                    //We hace to check wich AST identifires are varibales declared by user
                    //And then check if can ve dynamic
                    else if (tokenType == StaDynTokenTypes.Identifier && compileMode == DynVarOption.EverythingDynamic)
                    {
                        if (currentFile == null)
                        {
                            break;
                        }

                        StaDynLanguage.Visitors.StaDynVariablesInScopeTable infoVariablesInScope = StaDynLanguage.Intellisense.StaDynIntellisenseHelper.Instance.getVariablesInCurrentScope(StaDynToken.getLine(), StaDynToken.getColumn(), _buffer.CurrentSnapshot, 0, false);

                        for (int i = 0; i < infoVariablesInScope.Table.Count; i++)
                        {
                            if (infoVariablesInScope.Table[i].Count > 0)
                            {
                                foreach (KeyValuePair <string, AST.IdDeclaration> variable in infoVariablesInScope.Table[i])
                                {
                                    if (variable.Key == tokenText && variable.Value.Symbol != null)
                                    {
                                        //Only identifiers declared as var
                                        //HACK: Harcoded the "[Var
                                        if (variable.Value.Symbol.SymbolType.FullName.StartsWith("[Var"))
                                        {
                                            tokenType = StaDynTokenTypes.DynamicVar;
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    //Atmanaged compile mode
                    //Check if the current token its a dynamicVar
                    //Needed for highlighting
                    else if (tokenType == StaDynTokenTypes.Identifier && StaDynDynamicHelper.Instance.checkDynamicVar(StaDynToken.getText(), StaDynToken.getLine(), StaDynToken.getColumn(), currentFile) && compileMode == DynVarOption.Managed)
                    {
                        tokenType = StaDynTokenTypes.DynamicVar;
                    }

                    var tokenSpan = new SnapshotSpan(curSpan.Snapshot, new Span(curLoc, charsMatched));
                    if (tokenSpan.IntersectsWith(curSpan))
                    {
                        yield return(new TagSpan <StaDynTokenTag>(tokenSpan,
                                                                  new StaDynTokenTag(tokenType, StaDynToken)));
                    }

                    curLoc += charsMatched;
                }
            }
        }
 public StaDynTokenTag(StaDynTokenTypes type, IToken token)
 {
     this.type        = type;
     this.StaDynToken = token;
 }