当前位置: 首页>>代码示例>>C#>>正文


C# ITextEditor.ShowInsightWindow方法代码示例

本文整理汇总了C#中ITextEditor.ShowInsightWindow方法的典型用法代码示例。如果您正苦于以下问题:C# ITextEditor.ShowInsightWindow方法的具体用法?C# ITextEditor.ShowInsightWindow怎么用?C# ITextEditor.ShowInsightWindow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ITextEditor的用法示例。


在下文中一共展示了ITextEditor.ShowInsightWindow方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryComplete

        public Tuple<bool, CodeCompletionKeyPressResult> TryComplete(ITextEditor editor, char ch, IInsightWindowHandler insightWindowHandler)
        {
            int cursor_offset = editor.Caret.Offset;
            if(char.IsLetterOrDigit(ch) && CodeCompletionOptions.InsightEnabled){
                var insight_window = editor.ShowInsightWindow(new []{ProvideInsight(editor)});
                if(insight_window != null && insightWindowHandler != null){
                    insightWindowHandler.InitializeOpenedInsightWindow(editor, insight_window);
                    insightWindowHandler.HighlightParameter(insight_window, 0);
                }
                return Tuple.Create(true, CodeCompletionKeyPressResult.Completed);
            }

            return Tuple.Create(false, CodeCompletionKeyPressResult.None);
        }
开发者ID:hazama-yuinyan,项目名称:sharpdevelop-bvebinding,代码行数:14,代码来源:BVE5CommonFileCompleter.cs

示例2: TryComplete

        public Tuple<bool, CodeCompletionKeyPressResult> TryComplete(ITextEditor editor, char ch, IInsightWindowHandler insightWindowHandler)
        {
            int cursor_offset = editor.Caret.Offset;
            if(ch == '['){
                var line = editor.Document.GetLineForOffset(cursor_offset);
                current_context_type = line.Text.Trim();
                var provider = new UserDefinedNameCompletionItemProvider(current_context_type);
                var list = provider.Provide(editor);
                if(list != null){
                    editor.ShowCompletionWindow(list);
                    return Tuple.Create(true, CodeCompletionKeyPressResult.Completed);
                }else{
                    return Tuple.Create(false, CodeCompletionKeyPressResult.None);
                }
            }else if(ch == ',' && CodeCompletionOptions.InsightRefreshOnComma && CodeCompletionOptions.InsightEnabled){
                IInsightWindow insight_window;
                if(insightWindowHandler.InsightRefreshOnComma(editor, ch, out insight_window))
                    return Tuple.Create(true, CodeCompletionKeyPressResult.Completed);
            }else if(ch == '.'){
                var line = editor.Document.GetLineForOffset(cursor_offset);
                var type_name = (current_context_type != null) ? current_context_type : line.Text.Trim();
                var semantic_infos = BVE5ResourceManager.RouteFileSemanticInfos;
                var result = CodeCompletionKeyPressResult.None;
                if(semantic_infos.ContainsKey(type_name)){
                    var type_semantic_info = semantic_infos[type_name];

                    var names = type_semantic_info
                        .Where(member => member.Key != "indexer")
                        .Select(m => m.Key)
                        .Distinct()
                        .ToList();
                    var descriptions = type_semantic_info
                        .Where(member => member.Key != "indexer")
                        .Select(m => BVE5ResourceManager.GetDocumentationString(m.Value[0].Doc))
                        .ToList();

                    var list = CompletionDataHelper.GenerateCompletionList(names, descriptions);
                    editor.ShowCompletionWindow(list);
                    result = CodeCompletionKeyPressResult.Completed;
                }

                if(current_context_type != null) current_context_type = null;

                return Tuple.Create(result != CodeCompletionKeyPressResult.None, result);
            }else if(ch == '(' && CodeCompletionOptions.InsightEnabled){
                var insight_window = editor.ShowInsightWindow(ProvideInsight(editor));
                if(insight_window != null && insightWindowHandler != null){
                    insightWindowHandler.InitializeOpenedInsightWindow(editor, insight_window);
                    insightWindowHandler.HighlightParameter(insight_window, 0);
                }
                return Tuple.Create(true, CodeCompletionKeyPressResult.Completed);
            }

            if(char.IsLetter(ch) && CodeCompletionOptions.CompleteWhenTyping){
                var builtin_type_names = BVE5ResourceManager.GetAllTypeNames();
                var list = CompletionDataHelper.GenerateCompletionList(builtin_type_names);
                list = AddTemplateCompletionItems(editor, list, ch);
                editor.ShowCompletionWindow(list);
                return Tuple.Create(true, CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion);
            }

            return Tuple.Create(false, CodeCompletionKeyPressResult.None);
        }
开发者ID:hazama-yuinyan,项目名称:sharpdevelop-bvebinding,代码行数:63,代码来源:BVE5RouteFileCompleter.cs

示例3: ShowMethodInsight

        void ShowMethodInsight(ITextEditor editor)
        {
            TypeScriptContext context = GetContext(editor);
            UpdateContext(context, editor);

            var provider = new TypeScriptFunctionInsightProvider(context);
            IInsightItem[] items = provider.ProvideInsight(editor);
            IInsightWindow insightWindow = editor.ShowInsightWindow(items);
            if (insightWindow != null) {
                insightHandler.InitializeOpenedInsightWindow(editor, insightWindow);
                insightHandler.HighlightParameter(insightWindow, 0);
            }
        }
开发者ID:belov-gr,项目名称:typescript-addin,代码行数:13,代码来源:TypeScriptCodeCompletionBinding.cs

示例4: HandleKeyPress

		public virtual CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
		{
			switch (ch) {
				case '(':
					if (enableMethodInsight && CodeCompletionOptions.InsightEnabled) {
						IInsightWindow insightWindow = editor.ShowInsightWindow(new MethodInsightProvider().ProvideInsight(editor));
						if (insightWindow != null && insightHandler != null) {
							insightHandler.InitializeOpenedInsightWindow(editor, insightWindow);
							insightHandler.HighlightParameter(insightWindow, -1); // disable highlighting
						}
						return CodeCompletionKeyPressResult.Completed;
					}
					break;
				case '[':
					if (enableIndexerInsight && CodeCompletionOptions.InsightEnabled) {
						IInsightWindow insightWindow = editor.ShowInsightWindow(new IndexerInsightProvider().ProvideInsight(editor));
						if (insightWindow != null && insightHandler != null)
							insightHandler.InitializeOpenedInsightWindow(editor, insightWindow);
						return CodeCompletionKeyPressResult.Completed;
					}
					break;
				case '<':
					if (enableXmlCommentCompletion) {
						new CommentCompletionItemProvider().ShowCompletion(editor);
						return CodeCompletionKeyPressResult.Completed;
					}
					break;
				case '.':
					if (enableDotCompletion) {
						new DotCodeCompletionItemProvider().ShowCompletion(editor);
						return CodeCompletionKeyPressResult.Completed;
					}
					break;
				case ' ':
					if (CodeCompletionOptions.KeywordCompletionEnabled) {
						string word = editor.GetWordBeforeCaret();
						if (!string.IsNullOrEmpty(word)) {
							if (HandleKeyword(editor, word))
								return CodeCompletionKeyPressResult.Completed;
						}
					}
					break;
			}
			return CodeCompletionKeyPressResult.None;
		}
开发者ID:hpsa,项目名称:SharpDevelop,代码行数:45,代码来源:CodeCompletionBinding.cs

示例5: ShowInsight

		IInsightWindow ShowInsight(ITextEditor editor, IList<IInsightItem> insightItems, ICollection<ResolveResult> parameters, char charTyped)
		{
			int paramCount = parameters.Count;
			if (insightItems == null || insightItems.Count == 0)
				return null;
			bool overloadIsSure;
			int defaultIndex;
			if (insightItems.Count == 1) {
				overloadIsSure = true;
				defaultIndex = 0;
			} else {
				var methods = insightItems.Select(item => GetMethodFromInsightItem(item)).ToList();
				IReturnType[] argumentTypes = new IReturnType[paramCount + 1];
				int i = 0;
				foreach (ResolveResult rr in parameters) {
					if (rr != null) {
						argumentTypes[i] = rr.ResolvedType;
					}
					i++;
				}
				IMethodOrProperty result = Dom.CSharp.OverloadResolution.FindOverload(methods.Where(m => m != null), argumentTypes, true, false, out overloadIsSure);
				defaultIndex = methods.IndexOf(result);
			}

			IInsightWindow insightWindow = editor.ShowInsightWindow(insightItems);
			if (insightWindow != null) {
				InitializeOpenedInsightWindow(editor, insightWindow);
				insightWindow.SelectedItem = insightItems[defaultIndex];
			}
			if (overloadIsSure) {
				IMethodOrProperty method = GetMethodFromInsightItem(insightItems[defaultIndex]);
				if (method != null && paramCount < method.Parameters.Count) {
					IParameter param = method.Parameters[paramCount];
					ProvideContextCompletion(editor, param.ReturnType, charTyped);
				}
			}
			return insightWindow;
		}
开发者ID:Altaxo,项目名称:Altaxo,代码行数:38,代码来源:NRefactoryInsightWindowHandler.cs

示例6: CtrlSpace

		public bool CtrlSpace(ITextEditor editor)
		{
			XamlCompletionContext context = CompletionDataHelper.ResolveCompletionContext(editor, ' ');
			context.Forced = trackForced;
			
			if (context.Description == XamlContextDescription.InComment || context.Description == XamlContextDescription.InCData)
				return false;
			
			if (context.ActiveElement != null) {
				if (!XmlParser.IsInsideAttributeValue(editor.Document.Text, editor.Caret.Offset) && context.Description != XamlContextDescription.InAttributeValue) {
					XamlCompletionItemList list = CompletionDataHelper.CreateListForContext(context);
					string starter = editor.GetWordBeforeCaretExtended().TrimStart('/');
					if (context.Description != XamlContextDescription.None && !string.IsNullOrEmpty(starter)) {
						if (starter.Contains("."))
							list.PreselectionLength = starter.Length - starter.IndexOf('.') - 1;
						else
							list.PreselectionLength = starter.Length;
					}
					editor.ShowCompletionWindow(list);
					return true;
				} else {
					// DO NOT USE CompletionDataHelper.CreateListForContext here!!! results in endless recursion!!!!
					if (context.Attribute != null) {
						if (!DoMarkupExtensionCompletion(context)) {
							var completionList = new XamlCompletionItemList(context);
							completionList.PreselectionLength = editor.GetWordBeforeCaretExtended().Length;
							
							if ((context.ActiveElement.Name == "Setter" || context.ActiveElement.Name == "EventSetter") &&
							    (context.Attribute.Name == "Property" || context.Attribute.Name == "Value"))
								DoSetterAndEventSetterCompletion(context, completionList);
							else if ((context.ActiveElement.Name.EndsWith("Trigger") || context.ActiveElement.Name == "Condition") && context.Attribute.Name == "Value")
								DoTriggerCompletion(context, completionList);
							else {
								if (context.Attribute.Name == "xml:space") {
									completionList.Items.AddRange(new[] { new SpecialCompletionItem("preserve"),
									                              	new SpecialCompletionItem("default") });
								}
								
								var mrr = XamlResolver.Resolve(context.Attribute.Name, context) as MemberResolveResult;
								if (mrr != null && mrr.ResolvedType != null) {
									completionList.Items.AddRange(CompletionDataHelper.MemberCompletion(context, mrr.ResolvedType, string.Empty));
									editor.ShowInsightWindow(CompletionDataHelper.MemberInsight(mrr));
									if (mrr.ResolvedType.FullyQualifiedName == "System.Windows.PropertyPath") {
										string start = editor.GetWordBeforeCaretExtended();
										int index = start.LastIndexOfAny(PropertyPathTokenizer.ControlChars);
										if (index + 1 < start.Length)
											start = start.Substring(index + 1);
										else
											start = "";
										completionList.PreselectionLength = start.Length;
									} else if (mrr.ResolvedType.FullyQualifiedName == "System.Windows.Media.FontFamily") {
										string text = context.ValueStartOffset > -1 ? context.RawAttributeValue.Substring(0, Math.Min(context.ValueStartOffset + 1, context.RawAttributeValue.Length)) : "";
										int lastComma = text.LastIndexOf(',');
										completionList.PreselectionLength = lastComma == -1 ? context.ValueStartOffset + 1 : context.ValueStartOffset - lastComma;
									}
								}
							}
							
							completionList.SortItems();
							
							if (context.Attribute.Prefix.Equals("xmlns", StringComparison.OrdinalIgnoreCase) ||
							    context.Attribute.Name.Equals("xmlns", StringComparison.OrdinalIgnoreCase))
								completionList.Items.AddRange(CompletionDataHelper.CreateListForXmlnsCompletion(context.ProjectContent));
							
							ICompletionListWindow window = editor.ShowCompletionWindow(completionList);
							
							if ((context.Attribute.Prefix.Equals("xmlns", StringComparison.OrdinalIgnoreCase) ||
							     context.Attribute.Name.Equals("xmlns", StringComparison.OrdinalIgnoreCase)) && window != null)
								window.Width = 400;
							
							return completionList.Items.Any();
						}
						return true;
					}
				}
			}
			return false;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:78,代码来源:XamlCodeCompletionBinding.cs

示例7: InsightRefreshOnComma

        public bool InsightRefreshOnComma(ITextEditor editor, char ch, out IInsightWindow insightWindow)
        {
            int cursor_offset = editor.Caret.Offset;
            var line = editor.Document.GetLineForOffset(cursor_offset);
            if(line.Text.IndexOf('#') == -1){
                var insight_item = completer.ProvideInsight(editor);

                // find highlighted parameter
                // the number of recognized parameters is the index of the current parameter!
                var args = ResolveCallArguments(editor);
                highlighted_parameter = args.Count;
                insightWindow = editor.ShowInsightWindow(new []{insight_item});
                if(insightWindow != null){
                    InitializeOpenedInsightWindow(editor, insightWindow);
                    insightWindow.SelectedItem = insight_item;
                }
                return insightWindow != null;
            }

            insightWindow = null;
            return false;
        }
开发者ID:hazama-yuinyan,项目名称:sharpdevelop-bvebinding,代码行数:22,代码来源:BVE5CommonFileInsightWindowHandler.cs

示例8: HandleKeyPress

		public CodeCompletionKeyPressResult HandleKeyPress(ITextEditor editor, char ch)
		{
			if (IsInComment(editor) || IsInString(editor))
				return CodeCompletionKeyPressResult.None;
			
			if (editor.SelectionLength > 0) {
				// allow code completion when overwriting an identifier
				int endOffset = editor.SelectionStart + editor.SelectionLength;
				// but block code completion when overwriting only part of an identifier
				if (endOffset < editor.Document.TextLength && char.IsLetterOrDigit(editor.Document.GetCharAt(endOffset)))
					return CodeCompletionKeyPressResult.None;
				
				editor.Document.Remove(editor.SelectionStart, editor.SelectionLength);
			}
			
			VBNetExpressionFinder ef = new VBNetExpressionFinder(ParserService.GetParseInformation(editor.FileName));
			
			ExpressionResult result;
			
			switch (ch) {
				case '(':
					if (CodeCompletionOptions.InsightEnabled) {
						IInsightWindow insightWindow = editor.ShowInsightWindow(new MethodInsightProvider().ProvideInsight(editor));
						if (insightWindow != null) {
							insightHandler.InitializeOpenedInsightWindow(editor, insightWindow);
							insightHandler.HighlightParameter(insightWindow, 0);
							insightWindow.CaretPositionChanged += delegate { Run(insightWindow, editor); };
						}
						return CodeCompletionKeyPressResult.Completed;
					}
					break;
				case ',':
					if (CodeCompletionOptions.InsightRefreshOnComma && CodeCompletionOptions.InsightEnabled) {
						IInsightWindow insightWindow;
						editor.Document.Insert(editor.Caret.Offset, ",");
						if (insightHandler.InsightRefreshOnComma(editor, ch, out insightWindow)) {
							if (insightWindow != null) {
								insightHandler.HighlightParameter(insightWindow, GetArgumentIndex(editor) + 1);
								insightWindow.CaretPositionChanged += delegate { Run(insightWindow, editor); };;
							}
						}
						return CodeCompletionKeyPressResult.EatKey;
					}
					break;
				case '\n':
					TryDeclarationTypeInference(editor, editor.Document.GetLineForOffset(editor.Caret.Offset));
					break;
				case '.':
					string w = editor.GetWordBeforeCaret(); int index = w.IndexOf('.');
					
					if (index > -1 && w.Length - index == 2)
						index = editor.Caret.Offset - 2;
					else
						index = editor.Caret.Offset;
					
					result = ef.FindExpression(editor.Document.Text, index);
					LoggingService.Debug("CC: After dot, result=" + result + ", context=" + result.Context);
					ShowCompletion(result, editor, ch);
					return CodeCompletionKeyPressResult.Completed;
				case '@':
					if (editor.Caret.Offset > 0 && editor.Document.GetCharAt(editor.Caret.Offset - 1) == '.')
						return CodeCompletionKeyPressResult.None;
					goto default;
				case ' ':
					editor.Document.Insert(editor.Caret.Offset, " ");
					result = ef.FindExpression(editor.Document.Text, editor.Caret.Offset);
					
					string word = editor.GetWordBeforeCaret().Trim();
					if (word.Equals("overrides", StringComparison.OrdinalIgnoreCase) || word.Equals("return", StringComparison.OrdinalIgnoreCase) || !LiteralMayFollow((BitArray)result.Tag) && !OperatorMayFollow((BitArray)result.Tag) && ExpressionContext.IdentifierExpected != result.Context) {
						LoggingService.Debug("CC: After space, result=" + result + ", context=" + result.Context);
						ShowCompletion(result, editor, ch);
					}
					return CodeCompletionKeyPressResult.EatKey;
				default:
					if (CodeCompletionOptions.CompleteWhenTyping) {
						int cursor = editor.Caret.Offset;
						char prevChar = cursor > 1 ? editor.Document.GetCharAt(cursor - 1) : ' ';
						char ppChar = cursor > 2 ? editor.Document.GetCharAt(cursor - 2) : ' ';
						
						result = ef.FindExpression(editor.Document.Text, cursor);
						
						if ((result.Context != ExpressionContext.IdentifierExpected && char.IsLetter(ch)) &&
						    (!char.IsLetterOrDigit(prevChar) && prevChar != '.')) {
							if (prevChar == '@' && ppChar == '.')
								return CodeCompletionKeyPressResult.None;
							if (IsTypeCharacter(ch, prevChar))
								return CodeCompletionKeyPressResult.None;
							LoggingService.Debug("CC: Beginning to type a word, result=" + result + ", context=" + result.Context);
							ShowCompletion(result, editor, ch);
							return CodeCompletionKeyPressResult.CompletedIncludeKeyInCompletion;
						}
					}
					break;
			}
			
			return CodeCompletionKeyPressResult.None;
		}
开发者ID:Bombadil77,项目名称:SharpDevelop,代码行数:97,代码来源:VBNetCompletionBinding.cs

示例9: ShowInsight

        IInsightWindow ShowInsight(ITextEditor editor, IList<IInsightItem> insightItems, ICollection<ResolveResult> arguments)
        {
            if(insightItems == null || !insightItems.Any())
                return null;

            int default_index;
            if(insightItems.Count == 1){
                default_index = 0;
            }else{
                //var or = new OverloadResolution(BVE5LanguageBinding.Compilation, arguments.ToArray());
                //or
                return null;
            }

            var insight_window = editor.ShowInsightWindow(insightItems);
            if(insight_window != null){
                InitializeOpenedInsightWindow(editor, insight_window);
                insight_window.SelectedItem = insightItems[default_index];
            }

            return insight_window;
        }
开发者ID:hazama-yuinyan,项目名称:sharpdevelop-bvebinding,代码行数:22,代码来源:BVE5RouteFileInsightWindowHandler.cs


注:本文中的ITextEditor.ShowInsightWindow方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。