GetDefinitionPosition() public method

public GetDefinitionPosition ( object definition ) : int
definition object
return int
Exemplo n.º 1
0
		/// <summary>
		/// Jumps to the definition referred to by the <see cref="ReferenceSegment"/>.
		/// </summary>
		internal void JumpToReference(ReferenceSegment referenceSegment)
		{
			object reference = referenceSegment.Reference;
			if (referenceSegment.IsLocal) {
				ClearLocalReferenceMarks();
				if (references != null) {
					foreach (var r in references) {
						if (reference.Equals(r.Reference)) {
							var mark = textMarkerService.Create(r.StartOffset, r.Length);
							mark.BackgroundColor = r.IsLocalTarget ? Colors.LightSeaGreen : Colors.GreenYellow;
							localReferenceMarks.Add(mark);
						}
					}
				}
				return;
			}
			if (definitionLookup != null) {
				int pos = definitionLookup.GetDefinitionPosition(reference);
				if (pos >= 0) {
					textEditor.TextArea.Focus();
					textEditor.Select(pos, 0);
					textEditor.ScrollTo(textEditor.TextArea.Caret.Line, textEditor.TextArea.Caret.Column);
					Dispatcher.Invoke(DispatcherPriority.Background, new Action(
						delegate {
							CaretHighlightAdorner.DisplayCaretHighlightAnimation(textEditor.TextArea);
						}));
					return;
				}
			}
			MainWindow.Instance.JumpToReference(reference);
		}
Exemplo n.º 2
0
        /// <summary>
        /// Jumps to the definition referred to by the <see cref="ReferenceSegment"/>.
        /// </summary>
        internal void JumpToReference(ReferenceSegment referenceSegment)
        {
            object reference = referenceSegment.Reference;

            if (definitionLookup != null)
            {
                int pos = definitionLookup.GetDefinitionPosition(reference);
                if (pos >= 0)
                {
                    textEditor.TextArea.Focus();
                    textEditor.Select(pos, 0);
                    textEditor.ScrollTo(textEditor.TextArea.Caret.Line, textEditor.TextArea.Caret.Column);
                    Dispatcher.Invoke(DispatcherPriority.Background, new Action(
                                          delegate {
                        CaretHighlightAdorner.DisplayCaretHighlightAnimation(textEditor.TextArea);
                    }));
                    return;
                }
            }
            MainWindow.Instance.JumpToReference(reference);
        }