Exemple #1
0
		void OnToolTipRequest(object sender, TextEditor.ToolTipRequestEventArgs e)
		{
			if (e.InDocument && !e.ToolTipShown) {
				IExpressionFinder expressionFinder;
				if (MainForm.IsVisualBasic) {
					expressionFinder = new VBExpressionFinder();
				} else {
					expressionFinder = new CSharpExpressionFinder(mainForm.parseInformation);
				}
				ExpressionResult expression = expressionFinder.FindFullExpression(
					editor.Text,
					editor.Document.PositionToOffset(e.LogicalPosition));
				if (expression.Region.IsEmpty) {
					expression.Region = new DomRegion(e.LogicalPosition.Line + 1, e.LogicalPosition.Column + 1);
				}
				
				TextEditor.TextArea textArea = editor.ActiveTextAreaControl.TextArea;
				NRefactoryResolver resolver = new NRefactoryResolver(mainForm.myProjectContent.Language);
				ResolveResult rr = resolver.Resolve(expression,
				                                    mainForm.parseInformation,
				                                    textArea.MotherTextEditorControl.Text);
				string toolTipText = GetText(rr);
				if (toolTipText != null) {
					e.ShowToolTip(toolTipText);
				}
			}
		}
		private void OnToolTipRequest(object sender, TextEditor.ToolTipRequestEventArgs e)
		{
			if (!e.InDocument || e.ToolTipShown)
				return;

			IExpressionFinder expressionFinder;
			if (IntellisenseForm.SupportedLanguage == SupportedLanguage.VisualBasic)
			{
				expressionFinder = new VBExpressionFinder();
			}
			else
			{
				expressionFinder = new CSharpExpressionFinder(_iForm.ParseInformation);
			}

			var expression = expressionFinder.FindFullExpression(
				_editor.Text,
				_editor.Document.PositionToOffset(e.LogicalPosition));
			if (expression.Region.IsEmpty)
			{
				expression.Region = new DomRegion(e.LogicalPosition.Line + 1, e.LogicalPosition.Column + 1);
			}

			var textArea = _editor.ActiveTextAreaControl.TextArea;
			var resolver = new NRefactoryResolver(_iForm.ProjectContent.Language);
			var rr = resolver.Resolve(expression,
				_iForm.ParseInformation,
				textArea.MotherTextEditorControl.Text);

			var toolTipText = GetText(rr);
			if (toolTipText != null)
			{
				e.ShowToolTip(toolTipText);
			}
		}
		public void Init()
		{
			HostCallback.GetCurrentProjectContent = delegate {
				return ParserService.CurrentProjectContent;
			};
			
			ef = new VBExpressionFinder();
		}
 /// <summary>
 /// Find the expression the cursor is at.
 /// Also determines the context (using statement, "new"-expression etc.) the
 /// cursor is at.
 /// </summary>
 private ExpressionResult FindExpression(TextArea textArea)
 {
     IExpressionFinder finder;
     if (MainForm.IsVisualBasic)
     {
         finder = new VBExpressionFinder();
     }
     else
     {
         finder = new CSharpExpressionFinder(mainForm.parseInformation);
     }
     ExpressionResult expression = finder.FindExpression(textArea.Document.TextContent, textArea.Caret.Offset);
     if (expression.Region.IsEmpty)
     {
         expression.Region = new DomRegion(textArea.Caret.Line + 1, textArea.Caret.Column + 1);
     }
     return expression;
 }
		public void SetupDataProvider(string fileName)
		{
			IExpressionFinder expressionFinder;
			if (IntellisenseForm.SupportedLanguage == SupportedLanguage.VisualBasic)
			{
				expressionFinder = new VBExpressionFinder();
			}
			else
			{
				expressionFinder = new CSharpExpressionFinder(_iForm.ParseInformation);
			}

			//TextLocation position = _textArea.Caret.Position;
			//ExpressionResult expression = expressionFinder.FindFullExpression(_textArea.MotherTextEditorControl.Text, _textArea.Document.PositionToOffset(position));
			//if (expression.Region.IsEmpty)
			//{
			//    expression.Region = new DomRegion(position.Line + 1, position.Column + 1);
			//}
			var expression = expressionFinder.FindFullExpression(
				_textArea.MotherTextEditorControl.Text,
				_textArea.MotherTextEditorControl.Document.PositionToOffset(_textArea.Caret.Position) - 1);
			if (expression.Region.IsEmpty)
			{
				expression.Region = new DomRegion(_textArea.Caret.Position.Line + 1, _textArea.Caret.Position.Column + 1);
			}


			var resolver = new NRefactoryResolver(_iForm.ProjectContent.Language);
			var rr = resolver.Resolve(expression, _iForm.ParseInformation, _textArea.MotherTextEditorControl.Text);

			var lines = new List<string>();
			if (rr is MethodGroupResolveResult)
			{
				var mrr = rr as MethodGroupResolveResult;
				var ambience = IntellisenseForm.SupportedLanguage == SupportedLanguage.VisualBasic
					? (IAmbience) new VBNetAmbience()
					: new CSharpAmbience();
				ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowAccessibility;

				lines.AddRange(mrr.Methods.SelectMany(methodgroup => methodgroup,
					(methodgroup, method) => ToolTipProvider.GetMemberText(ambience, method)));
			}

			_insighText = (lines.Count > 0) ? lines.ToArray() : null;
			ArgumentStartOffset = _textArea.Caret.Offset;
		}
        public void SetupDataProvider(string fileName)
        {
            IExpressionFinder expressionFinder;
            if (IntellisenseForm.SupportedLanguage == ESupportedLanguage.VisualBasic)
            {
                expressionFinder = new VBExpressionFinder();
            }
            else
            {
                expressionFinder = new CSharpExpressionFinder(iForm.ParseInformation);
            }

            //TextLocation position = m_textarea.Caret.Position;
            //ExpressionResult expression = expressionFinder.FindFullExpression(m_textarea.MotherTextEditorControl.Text, m_textarea.Document.PositionToOffset(position));
            //if (expression.Region.IsEmpty)
            //{
            //    expression.Region = new DomRegion(position.Line + 1, position.Column + 1);
            //}
            ExpressionResult expression = expressionFinder.FindFullExpression(
                    m_textarea.MotherTextEditorControl.Text,
                    m_textarea.MotherTextEditorControl.Document.PositionToOffset(m_textarea.Caret.Position)-1);
            if (expression.Region.IsEmpty)
            {
                expression.Region = new DomRegion(m_textarea.Caret.Position.Line + 1, m_textarea.Caret.Position.Column + 1);
            }



            NRefactoryResolver resolver = new NRefactoryResolver(iForm.ProjectContent.Language);
            ResolveResult rr = resolver.Resolve(expression, iForm.ParseInformation, m_textarea.MotherTextEditorControl.Text);

            List<string> lines = new List<string>();
            if (rr is MethodGroupResolveResult)
            {
                MethodGroupResolveResult mrr = rr as MethodGroupResolveResult;
                IAmbience ambience = IntellisenseForm.SupportedLanguage == ESupportedLanguage.VisualBasic ? (IAmbience)new VBNetAmbience() : new CSharpAmbience();
                ambience.ConversionFlags = ConversionFlags.StandardConversionFlags | ConversionFlags.ShowAccessibility;
                
                foreach (MethodGroup methodgroup in mrr.Methods)
                {
                    foreach (IMethod method in methodgroup)
                    {
                        lines.Add(ToolTipProvider.GetMemberText(ambience, method));
                    }
                }
            }

            m_insighttext = (lines.Count > 0) ? lines.ToArray() : null;
            m_argumentstartoffset = m_textarea.Caret.Offset;
        }