예제 #1
0
        void FixIndentation(MonoDevelop.Projects.Dom.DomLocation location, int relOffset)
        {
            LineSegment lineSegment  = data.Document.GetLine(location.Line);
            string      lineIndent   = lineSegment.GetIndentation(data.Document);
            string      indentString = this.curIndent.IndentString;

            if (indentString != lineIndent && location.Column + relOffset == lineIndent.Length)
            {
                AddChange(lineSegment.Offset, lineIndent.Length, indentString);
            }
        }
예제 #2
0
        void FixStatementIndentation(MonoDevelop.Projects.Dom.DomLocation location)
        {
            int offset = data.Document.LocationToOffset(location.Line, location.Column);

            if (offset == 0)
            {
                Console.WriteLine("possible wrong offset");
                Console.WriteLine(Environment.StackTrace);
                return;
            }
            int    whitespaceStart = SearchWhitespaceStart(offset);
            string indentString    = nextStatementIndent == null ? data.EolMarker + this.curIndent.IndentString : nextStatementIndent;

            nextStatementIndent = null;
            AddChange(whitespaceStart, offset - whitespaceStart, indentString);
        }
예제 #3
0
파일: DomType.cs 프로젝트: poke/monodevelop
 public DomType(ICompilationUnit compilationUnit,
                ClassType classType,
                Modifiers modifiers,
                string name,
                DomLocation location,
                string namesp,
                DomRegion region)
 {
     this.compilationUnit = compilationUnit;
     this.classType       = classType;
     this.Modifiers       = modifiers;
     this.Name            = name;
     this.Namespace       = namesp;
     this.BodyRegion      = region;
     this.Location        = location;
 }
예제 #4
0
        public static IEnumerable <FoldingRegion> ToFolds(this IList <Comment> comments)
        {
            for (int i = 0; i < comments.Count; i++)
            {
                Comment comment = comments[i];

                if (comment.CommentType == CommentType.MultiLine)
                {
                    int startOffset = 0;
                    while (startOffset < comment.Text.Length)
                    {
                        char ch = comment.Text[startOffset];
                        if (!char.IsWhiteSpace(ch) && ch != '*')
                        {
                            break;
                        }
                        startOffset++;
                    }
                    int endOffset = startOffset;
                    while (endOffset < comment.Text.Length)
                    {
                        char ch = comment.Text[endOffset];
                        if (ch == '\r' || ch == '\n' || ch == '*')
                        {
                            break;
                        }
                        endOffset++;
                    }

                    string txt;
                    if (endOffset > startOffset)
                    {
                        txt = "/* " + SubstrEllipsize(comment.Text, startOffset, endOffset - startOffset) + " */";
                    }
                    else
                    {
                        txt = "/* */";
                    }
                    yield return(new FoldingRegion(txt, comment.Region, FoldType.Comment));

                    continue;
                }

                if (!comment.CommentStartsLine)
                {
                    continue;
                }
                int           j           = i;
                int           curLine     = comment.Region.Start.Line - 1;
                DomLocation   end         = comment.Region.End;
                StringBuilder commentText = new StringBuilder();
                for (; j < comments.Count; j++)
                {
                    Comment curComment = comments[j];
                    if (curComment == null || !curComment.CommentStartsLine ||
                        curComment.CommentType != comment.CommentType ||
                        curLine + 1 != curComment.Region.Start.Line)
                    {
                        break;
                    }
                    commentText.Append(curComment.Text);
                    end     = curComment.Region.End;
                    curLine = curComment.Region.Start.Line;
                }

                if (j - i > 1)
                {
                    string txt;
                    if (comment.IsDocumentation)
                    {
                        txt = "/// ...";
                        string cmtText = commentText.ToString();
                        int    idx     = cmtText.IndexOf("<summary>");
                        if (idx >= 0)
                        {
                            int maxOffset = cmtText.IndexOf("</summary>");
                            while (maxOffset > 0 && cmtText[maxOffset - 1] == ' ')
                            {
                                maxOffset--;
                            }
                            if (maxOffset < 0)
                            {
                                maxOffset = cmtText.Length;
                            }
                            int startOffset = idx + "<summary>".Length;
                            while (startOffset < maxOffset)
                            {
                                char ch = cmtText[startOffset];
                                if (!char.IsWhiteSpace(ch) && ch != '/')
                                {
                                    break;
                                }
                                startOffset++;
                            }
                            int endOffset = startOffset;
                            while (endOffset < maxOffset)
                            {
                                char ch = cmtText[endOffset];
                                if (ch == '\r' || ch == '\n')
                                {
                                    break;
                                }
                                endOffset++;
                            }
                            if (endOffset > startOffset)
                            {
                                txt = "/// " + SubstrEllipsize(cmtText, startOffset, endOffset - startOffset);
                            }
                        }
                    }
                    else
                    {
                        txt = "// " + SubstrEllipsize(comment.Text, 0, comment.Text.Length);
                    }

                    yield return(new FoldingRegion(txt,
                                                   new DomRegion(comment.Region.Start.Line,
                                                                 comment.Region.Start.Column, end.Line, end.Column),
                                                   FoldType.Comment));

                    i = j - 1;
                }
            }
        }
예제 #5
0
 public DomRegion(DomLocation start, DomLocation end) : this(start.Line, start.Column, end.Line, end.Column)
 {
 }
예제 #6
0
 public DomRegion(int startLine, int startColumn, int endLine, int endColumn) : this()
 {
     this.Start = new DomLocation(startLine, startColumn);
     this.End   = new DomLocation(endLine, endColumn);
 }
예제 #7
0
 public bool Contains(DomLocation location)
 {
     return(Start <= location && location <= End);
 }
예제 #8
0
 public ConditionBlock(string flag, DomLocation start)
 {
     this.Flag   = flag;
     this.Start  = start;
     this.Region = DomRegion.Empty;
 }
예제 #9
0
 public bool IsNamespaceUsedAt(string name, DomLocation location)
 {
     return(usings.Where(u => ((!u.IsFromNamespace && u.Region.Start < location) || u.Region.Contains(location)) && u.Namespaces.Contains(name)).Any());
 }
예제 #10
0
파일: DomType.cs 프로젝트: poke/monodevelop
 public DomType(ICompilationUnit compilationUnit, ClassType classType, string name, DomLocation location, string namesp, DomRegion region, List <IMember> members)
 {
     this.compilationUnit = compilationUnit;
     this.classType       = classType;
     this.Name            = name;
     this.Namespace       = namesp;
     this.BodyRegion      = region;
     this.Location        = location;
     foreach (IMember member in members)
     {
         AddChild(member);
         ((AbstractMember)member).DeclaringType = this;
     }
 }
예제 #11
0
 public void SetMainPart(string fileName, DomLocation location)
 {
     SetMainPart(fileName, location.Line, location.Column);
 }
예제 #12
0
 public DomRegion(DomLocation start, DomLocation end) : this()
 {
     this.start = start;
     this.end   = end;
 }
예제 #13
0
 public DomProperty(string name, Modifiers getterModifier, Modifiers setterModifier, DomLocation location, DomRegion bodyRegion, IReturnType returnType)
 {
     base.Name           = name;
     this.GetterModifier = getterModifier;
     this.SetterModifier = setterModifier;
     this.Location       = location;
     this.BodyRegion     = bodyRegion;
     base.ReturnType     = returnType;
 }
예제 #14
0
 public DomProperty(string name, Modifiers modifier, DomLocation location, DomRegion bodyRegion, IReturnType returnType)
     : this(name, modifier, modifier, location, bodyRegion, returnType)
 {
 }
예제 #15
0
 void FixIndentation(MonoDevelop.Projects.Dom.DomLocation location)
 {
     FixIndentation(location, 0);
 }
예제 #16
0
 public IType GetTypeAt(DomLocation location)
 {
     return(GetTypeAt(location.Line, location.Column));
 }
예제 #17
0
 public IMember GetMemberAt(DomLocation location)
 {
     return(GetMemberAt(location.Line, location.Column));
 }
예제 #18
0
파일: DomType.cs 프로젝트: poke/monodevelop
        public static DomType CreateDelegate(ICompilationUnit compilationUnit, string name, DomLocation location, IReturnType type, IEnumerable <IParameter> parameters)
        {
            DomType result = new DomType();

            result.compilationUnit = compilationUnit;
            result.Name            = name;
            result.classType       = MonoDevelop.Projects.Dom.ClassType.Delegate;
            DomMethod delegateMethod = new DomMethod("Invoke", Modifiers.None, MethodModifier.None, location, DomRegion.Empty, type);

            delegateMethod.Add(parameters);
            result.Add(delegateMethod);
            return(result);
        }
예제 #19
0
 public ShortenTypeNameVistior(ICompilationUnit unit, DomLocation location)
 {
     this.unit     = unit;
     this.location = location;
     callingType   = this.unit.GetTypeAt(location);
 }
예제 #20
0
 public Error(ErrorType errorType, DomLocation location, string message)
     : this(errorType, new DomRegion(location, DomLocation.Empty), message)
 {
 }
예제 #21
0
 public DomMethod(string name, Modifiers modifiers, MethodModifier MethodModifier, DomLocation location, DomRegion bodyRegion, IReturnType returnType)
 {
     this.Name           = name;
     this.Modifiers      = modifiers;
     this.Location       = location;
     this.BodyRegion     = bodyRegion;
     this.ReturnType     = returnType;
     this.MethodModifier = MethodModifier;
 }
 public PreProcessorDefine(string define, DomLocation location)
 {
     this.Define   = define;
     this.Location = location;
 }