Ejemplo n.º 1
0
        public override TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null || doc.ParsedDocument == null)
            {
                return(null);
            }
            var unit = doc.ParsedDocument.GetAst <SyntaxTree> ();

            if (unit == null)
            {
                return(null);
            }

            var file = doc.ParsedDocument.ParsedFile as CSharpUnresolvedFile;

            if (file == null)
            {
                return(null);
            }

            ResolveResult result;
            AstNode       node;
            var           loc = editor.OffsetToLocation(offset);

            if (!doc.TryResolveAt(loc, out result, out node))
            {
                if (node is CSharpTokenNode)
                {
                    int startOffset2 = editor.LocationToOffset(node.StartLocation);
                    int endOffset2   = editor.LocationToOffset(node.EndLocation);

                    return(new TooltipItem(new ToolTipData(unit, result, node, null), startOffset2, endOffset2 - startOffset2));
                }
                return(null);
            }
            if (node == lastNode)
            {
                return(lastResult);
            }
            var resolver = new CSharpAstResolver(doc.Compilation, unit, file);

            resolver.ApplyNavigator(new NodeListResolveVisitorNavigator(node), CancellationToken.None);

            var hoverNode = node.GetNodeAt(loc) ?? node;

            int startOffset = editor.LocationToOffset(hoverNode.StartLocation);
            int endOffset   = editor.LocationToOffset(hoverNode.EndLocation);

            return(lastResult = new TooltipItem(new ToolTipData(unit, result, node, resolver), startOffset, endOffset - startOffset));
        }
Ejemplo n.º 2
0
        public override Gtk.Window ShowTooltipWindow(TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
        {
            var location   = editor.OffsetToLocation(item.ItemSegment.Offset);
            var point      = editor.LocationToPoint(location);
            int lineHeight = (int)editor.LineHeight;
            int y          = point.Y;

            // find the top of the line that the mouse is hovering over
            while (y + lineHeight < mouseY)
            {
                y += lineHeight;
            }

            var caret = new Gdk.Rectangle(mouseX, y, 1, lineHeight);

            tooltip = new DebugValueWindow(editor, offset, DebuggingService.CurrentFrame, (ObjectValue)item.Item, null);
            tooltip.ShowPopup(editor, caret, PopupPosition.TopLeft);

            return(tooltip);
        }
        public TooltipItem GetItem(Mono.TextEditor.TextEditor editor, int offset)
        {
            var doc = IdeApp.Workbench.ActiveDocument;

            if (doc == null || doc.ParsedDocument == null)
            {
                return(null);
            }
            var unit = doc.ParsedDocument.GetAst <CompilationUnit> ();

            if (unit == null)
            {
                return(null);
            }

            var file = doc.ParsedDocument.ParsedFile as CSharpParsedFile;

            if (file == null)
            {
                return(null);
            }

            ResolveResult result;
            AstNode       node;
            var           loc = editor.OffsetToLocation(offset);

            if (!doc.TryResolveAt(loc, out result, out node))
            {
                return(null);
            }
            var resolver = new CSharpAstResolver(doc.Compilation, unit, file);

            resolver.ApplyNavigator(new NodeListResolveVisitorNavigator(node), CancellationToken.None);

            int startOffset = offset;
            int endOffset   = offset;

            return(new TooltipItem(new ToolTipData(unit, result, node, resolver), startOffset, endOffset - startOffset));
        }
		public override Gtk.Window ShowTooltipWindow (TextEditor editor, int offset, Gdk.ModifierType modifierState, int mouseX, int mouseY, TooltipItem item)
		{
			var location = editor.OffsetToLocation (item.ItemSegment.Offset);
			var point = editor.LocationToPoint (location);
			int lineHeight = (int) editor.LineHeight;
			int y = (int) point.Y;

			// find the top of the line that the mouse is hovering over
			while (y + lineHeight < mouseY)
				y += lineHeight;

			var caret = new Gdk.Rectangle (mouseX - editor.Allocation.X, y - editor.Allocation.Y, 1, lineHeight);

			tooltip = new DebugValueWindow (editor, offset, DebuggingService.CurrentFrame, (ObjectValue) item.Item, null);
			tooltip.ShowPopup (editor, caret, PopupPosition.TopLeft);

			return tooltip;
		}
Ejemplo n.º 5
0
        public override TooltipItem GetItem(TextEditor editor, int offset)
        {
            if (offset >= editor.Document.TextLength)
            {
                return(null);
            }

            if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
            {
                return(null);
            }

            StackFrame frame = DebuggingService.CurrentFrame;

            if (frame == null)
            {
                return(null);
            }

            var    ed         = (ExtensibleTextEditor)editor;
            string expression = null;
            int    startOffset;

            if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset)
            {
                startOffset = ed.SelectionRange.Offset;
                expression  = ed.SelectedText;
            }
            else
            {
                var doc = IdeApp.Workbench.ActiveDocument;
                if (doc == null || doc.ParsedDocument == null)
                {
                    return(null);
                }

                ResolveResult result;
                AstNode       node;

                var loc = editor.OffsetToLocation(offset);
                if (!TryResolveAt(doc, loc, out result, out node))
                {
                    return(null);
                }

                expression = ResolveExpression(editor.GetTextEditorData(), result, node, out startOffset);
            }

            if (string.IsNullOrEmpty(expression))
            {
                return(null);
            }

            ObjectValue val;

            if (!cachedValues.TryGetValue(expression, out val))
            {
                val = frame.GetExpressionValue(expression, true);
                cachedValues [expression] = val;
            }

            if (val == null || val.IsUnknown || val.IsNotSupported)
            {
                return(null);
            }

            val.Name = expression;

            return(new TooltipItem(val, startOffset, expression.Length));
        }
		public override TooltipItem GetItem (TextEditor editor, int offset)
		{
			if (offset >= editor.Document.TextLength)
				return null;

			if (!DebuggingService.IsDebugging || DebuggingService.IsRunning)
				return null;

			StackFrame frame = DebuggingService.CurrentFrame;
			if (frame == null)
				return null;

			var ed = (ExtensibleTextEditor) editor;
			string expression = null;
			int startOffset;

			if (ed.IsSomethingSelected && offset >= ed.SelectionRange.Offset && offset <= ed.SelectionRange.EndOffset) {
				startOffset = ed.SelectionRange.Offset;
				expression = ed.SelectedText;
			} else {
				var doc = IdeApp.Workbench.ActiveDocument;
				if (doc == null || doc.ParsedDocument == null)
					return null;

				ResolveResult result;
				AstNode node;

				var loc = editor.OffsetToLocation (offset);
				if (!TryResolveAt (doc, loc, out result, out node))
					return null;

				expression = ResolveExpression (editor.GetTextEditorData (), result, node, out startOffset);
			}
			
			if (string.IsNullOrEmpty (expression))
				return null;
			
			ObjectValue val;
			if (!cachedValues.TryGetValue (expression, out val)) {
				val = frame.GetExpressionValue (expression, true);
				cachedValues [expression] = val;
			}
			
			if (val == null || val.IsUnknown || val.IsNotSupported)
				return null;
			
			val.Name = expression;
			
			return new TooltipItem (val, startOffset, expression.Length);
		}