コード例 #1
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack<int> matches = new Stack<int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 86 || style == 7)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    int endWordIndex = m + word.Length;

                    char c = scintilla.CharAt(++endWordIndex);
                    List<string> words = new List<string>();
                   
                    //skip whitespace
                    while (Char.IsWhiteSpace(c)) c = scintilla.CharAt(++endWordIndex);

                    // get "As"
                    StringBuilder nextword = new StringBuilder();
                    do
                    {
                        nextword.Append(c);
                        c = scintilla.CharAt(++endWordIndex);
                    } while (!Char.IsWhiteSpace(c));

                    if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase))
                    {
                        //skip whitespace
                        while (Char.IsWhiteSpace(c)) c = scintilla.CharAt(++endWordIndex);

                        // get Type
                        nextword.Remove(0, nextword.Length);
                        do
                        {
                            nextword.Append(c);
                            c = scintilla.CharAt(++endWordIndex);
                        } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator)));

                        string type = nextword.ToString();
                        List<Type> types = AutoCompleteHelper.SearchForType(type);
                        if (types.Count > 0)
                        {
                            node = new AutoCompleteNodeInfo(types[0], varname);
                            isFound = true;
                        }
                    }
                }
            }

            return isFound;
        }
コード例 #2
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack<int> matches = new Stack<int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 61 || style == 11)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    //scintilla.
                    char c = scintilla.CharAt(--beginWordIndex);
                    while (Char.IsWhiteSpace(c) && (beginWordIndex > 0)) c = scintilla.CharAt(--beginWordIndex);
                    StringBuilder typeName = new StringBuilder();
                    while (this.IsValidIdentifierChar(c) || (c == MemberSeperator))
                    {
                        if (typeName.Length == 0)
                            typeName.Append(c);
                        else 
                            typeName.Insert(0, c);

                        c = scintilla.CharAt(--beginWordIndex);
                    }
                    
                    string type = typeName.ToString();
                    List<Type> types = AutoCompleteHelper.SearchForType(type);
                    if (types.Count > 0)
                    {
                        node = new AutoCompleteNodeInfo(types[0], varname);
                        isFound = true;
                    }
                } 
            }

            return isFound;
        }
コード例 #3
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex   = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd   = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack <int> matches = new Stack <int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);

            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 86 || style == 7)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos     = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd   = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    int endWordIndex   = m + word.Length;

                    char          c     = scintilla.CharAt(++endWordIndex);
                    List <string> words = new List <string>();

                    //skip whitespace
                    while (Char.IsWhiteSpace(c))
                    {
                        c = scintilla.CharAt(++endWordIndex);
                    }

                    // get "As"
                    StringBuilder nextword = new StringBuilder();
                    do
                    {
                        nextword.Append(c);
                        c = scintilla.CharAt(++endWordIndex);
                    } while (!Char.IsWhiteSpace(c));

                    if (nextword.ToString().Equals("as", StringComparison.CurrentCultureIgnoreCase))
                    {
                        //skip whitespace
                        while (Char.IsWhiteSpace(c))
                        {
                            c = scintilla.CharAt(++endWordIndex);
                        }

                        // get Type
                        nextword.Remove(0, nextword.Length);
                        do
                        {
                            nextword.Append(c);
                            c = scintilla.CharAt(++endWordIndex);
                        } while (!Char.IsWhiteSpace(c) && (this.IsValidIdentifierChar(c) || (c == MemberSeperator)));

                        string      type  = nextword.ToString();
                        List <Type> types = AutoCompleteHelper.SearchForType(type);
                        if (types.Count > 0)
                        {
                            node    = new AutoCompleteNodeInfo(types[0], varname);
                            isFound = true;
                        }
                    }
                }
            }

            return(isFound);
        }
コード例 #4
0
        public override bool ScanCodeForVariable(ZeusScintillaControl scintilla, String varname, out AutoCompleteNodeInfo node)
        {
            node = null;
            bool isFound = false;

            int currentIndex   = scintilla.CurrentPos;
            int selectionStart = scintilla.SelectionStart;
            int selectionEnd   = scintilla.SelectionEnd;
            int searchEndIndex = (currentIndex - varname.Length - 1);

            Stack <int> matches = new Stack <int>();

            scintilla.CurrentPos = searchEndIndex;
            scintilla.SearchAnchor();
            int matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);

            while ((matchPosition >= 0) && (matchPosition < searchEndIndex))
            {
                int style = scintilla.StyleAt(matchPosition);
                if (style == 61 || style == 11)
                {
                    matches.Push(matchPosition);
                }

                scintilla.CurrentPos = matchPosition;
                scintilla.SearchAnchor();

                matchPosition = scintilla.SearchPrevious((int)FindOption.WholeWord, varname);
            }

            scintilla.CurrentPos     = currentIndex;
            scintilla.SelectionStart = selectionStart;
            scintilla.SelectionEnd   = selectionEnd;
            scintilla.SearchAnchor();

            foreach (int m in matches)
            {
                string word = scintilla.GetWordFromPosition(m + 1);
                if (string.Equals(word, varname, StringComparison.CurrentCultureIgnoreCase))
                {
                    varname = word;

                    int beginWordIndex = m;
                    //scintilla.
                    char c = scintilla.CharAt(--beginWordIndex);
                    while (Char.IsWhiteSpace(c) && (beginWordIndex > 0))
                    {
                        c = scintilla.CharAt(--beginWordIndex);
                    }
                    StringBuilder typeName = new StringBuilder();
                    while (this.IsValidIdentifierChar(c) || (c == MemberSeperator))
                    {
                        if (typeName.Length == 0)
                        {
                            typeName.Append(c);
                        }
                        else
                        {
                            typeName.Insert(0, c);
                        }

                        c = scintilla.CharAt(--beginWordIndex);
                    }

                    string      type  = typeName.ToString();
                    List <Type> types = AutoCompleteHelper.SearchForType(type);
                    if (types.Count > 0)
                    {
                        node    = new AutoCompleteNodeInfo(types[0], varname);
                        isFound = true;
                    }
                }
            }

            return(isFound);
        }