Exemple #1
0
        // The location in the source code to which the insertion point moves when you double-click an element in Designer or Class View.
        private TextPoint GetNavigationPoint(Nemerle.Compiler.Location bodyLocation)
        {
            TextPoint point = null;

            if (bodyLocation.Line < bodyLocation.EndLine)             // тело метода состоит более чем из одной строки
            {
                var tmpPoint  = new CodeDomTextPoint(GetTextDocument(), bodyLocation.Column, bodyLocation.Line);
                var editPoint = tmpPoint.CreateEditPoint();

                // предпоследн¤¤ строка тела метода
                var lines = editPoint.GetLines(bodyLocation.EndLine, bodyLocation.EndLine + 1);

                if (lines.Trim(' ', '\t').Length > 0)                 // если предпоследн¤¤ строка состоит не только из пробельных символов
                {
                    if (bodyLocation.Line == bodyLocation.EndLine - 1)
                    {
                        // тело метода состоит из двух строк
                        // установим курсор на последней позиции предпоследней строки
                        // void foo()
                        // {_
                        // }
                        point = new CodeDomTextPoint(GetTextDocument(), bodyLocation.Column, bodyLocation.EndLine - 1);
                    }
                    else
                    {
                        // тело метода состоит из более чем двух строк
                        // установим курсор на перед первым непробельныи символом предпоследней строки
                        // void foo()
                        // {
                        //     _source
                        // }
                        point = new CodeDomTextPoint(GetTextDocument(), lines.Length - lines.TrimStart(' ', '\t').Length, bodyLocation.EndLine - 1);
                    }
                }
                else
                {
                    // если предпоследн¤¤ строка - пуста¤ (состоит тлько из пробельных симвлов)
                    // установим курсор на последнюю позицию предпоследней строки
                    // void foo()
                    // {
                    //     _
                    // }
                    point = new CodeDomTextPoint(GetTextDocument(), lines.Length, bodyLocation.EndLine - 1);
                }
            }
            else
            {
                // тело метода стостоит только из одной строки
                // установим курсор на позицию за началом тела метода
                // void foo()
                // {_    }
                point = new CodeDomTextPoint(GetTextDocument(), bodyLocation.Column, bodyLocation.Line);
            }

            return(point);
        }
Exemple #2
0
        public bool LessThan(TextPoint Point)
        {
            CodeDomTextPoint tp = Point as CodeDomTextPoint;

            if (tp == null)
            {
                return(false);
            }

            return(tp.y > y || (tp.y == y && tp.x > x));
        }
Exemple #3
0
        public bool GreaterThan(TextPoint Point)
        {
            CodeDomTextPoint tp = Point as CodeDomTextPoint;

            if (tp == null)
            {
                return(false);
            }

            return(tp.y < y || (tp.y == y && tp.x < x));
        }
Exemple #4
0
        public bool EqualTo(TextPoint Point)
        {
            CodeDomTextPoint tp = Point as CodeDomTextPoint;

            if (tp == null)
            {
                return(false);
            }

            return(tp.x == x && tp.y == y);
        }
Exemple #5
0
        public override TextPoint GetStartPoint(vsCMPart part)
        {
            TextPoint point  = null;
            var       member = CodeObject.UserData["Member"] as Nemerle.Compiler.Parsetree.MemberBase;

            if (member != null)
            {
                if (part == vsCMPart.vsCMPartBody && member.BodyLocation != null)
                {
                    point = new CodeDomTextPoint(GetTextDocument(), member.BodyLocation.Column, member.BodyLocation.Line);
                }
                else if (part == vsCMPart.vsCMPartNavigate && member.BodyLocation != null)
                {
                    point = GetNavigationPoint(member.BodyLocation);
                }
                else if (member.Location != null)
                {
                    point = new CodeDomTextPoint(GetTextDocument(), member.Location.Column, member.Location.Line);
                }
            }

            return((point != null) ? point : new NullTextPoint());
        }