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


C# ICompletionSession.Dismiss方法代码示例

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


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

示例1: Exec

		public int Exec(ref Guid pguidCmdGroup, uint nCmdID, uint nCmdexecopt, IntPtr pvaIn, IntPtr pvaOut)
		{
			var handled = false;
			var hresult = VSConstants.S_OK;

			if (pguidCmdGroup == VSConstants.VSStd2K)
			{
				switch ((VSConstants.VSStd2KCmdID) nCmdID)
				{
					case VSConstants.VSStd2KCmdID.AUTOCOMPLETE:
					case VSConstants.VSStd2KCmdID.COMPLETEWORD:
						handled = true;
						if (IsSessionStarted) break;
						_currentSession = StartSession();
						break;
					case VSConstants.VSStd2KCmdID.RETURN:
						if (!IsSessionStarted) break;
						handled = true;
						_currentSession.Commit();
						break;
					case VSConstants.VSStd2KCmdID.TAB:
						if (!IsSessionStarted) break;
						handled = true;
						_currentSession.Commit();
						break;
					case VSConstants.VSStd2KCmdID.CANCEL:
						if (!IsSessionStarted) break;
						handled = true;
						_currentSession.Dismiss();
						break;
				}
			}

			if (!handled) hresult = Next.Exec(pguidCmdGroup, nCmdID, nCmdexecopt, pvaIn, pvaOut);

			if (ErrorHandler.Succeeded(hresult))
			{
				if (pguidCmdGroup == VSConstants.VSStd2K)
				{
					switch ((VSConstants.VSStd2KCmdID) nCmdID)
					{
						case VSConstants.VSStd2KCmdID.TYPECHAR:
							if (IsSessionStarted) _currentSession.Filter();
							break;
						case VSConstants.VSStd2KCmdID.BACKSPACE:
							if (IsSessionStarted)
							{
								_currentSession.Dismiss();
								_currentSession = StartSession();
							}
							break;
					}
				}
			}

			return hresult;
		}
开发者ID:rpete4130,项目名称:vsClojure,代码行数:57,代码来源:IntellisenseCommandFilter.cs

示例2: AugmentCompletionSession

		public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
		{
			// read XML up to the cursor
			var point = session.TextView.Caret.Position.BufferPosition;
			var info = XmlParser.Read(buffer.CurrentSnapshot.GetText(0, point.Position));
			if (info.Mode == CompletionMode.Class)
			{
				var prevPoint = point - 1;
				var prevCh = prevPoint.GetChar();
                if (prevCh != '<' && prevCh != '.')
				{
					session.Dismiss();
					return;
				}
			}
			var nodes = info.Nodes;
			var ns = nodes.SelectMany(r => r.Namespaces ?? Enumerable.Empty<CompletionNamespace>());
			var path = nodes.Where(r => r.Mode == CompletionMode.Class).Select(r => r.Name).ToList();
			var last = nodes.LastOrDefault();

			// get available completion items
			var items = Designer.Completion.Completion.GetCompletionItems(ns, info.Mode, path, last);

			// translate to VS completions
			var completionList = new List<mvli.Completion>();
            foreach (var cls in items.OrderBy(r => r.Name))
			{
                completionList.Add(new mvli.Completion(cls.Name, cls.Name, cls.Description, GetGlyph(cls.Type), null));
			}

			completionSets.Insert(0, new CompletionSet(
				"Eto",
				"Eto",
				FindTokenSpanAtPosition(session.GetTriggerPoint(buffer), session, info.Mode),
				completionList,
				null));
			return;
		}
开发者ID:mhusen,项目名称:Eto,代码行数:38,代码来源:XamlCompletionSource.cs

示例3: Commit

        //private ITrackingSpan FindTokenSpanAtPosition(ITrackingPoint trackingPoint, ICompletionSession newSession)
        //{
        //    SnapshotPoint currentPoint = (newSession.TextView.Caret.Position.BufferPosition);

        //    ITextStructureNavigator navigator = Provider.NavigatorService.GetTextStructureNavigator(TextBuffer);
        //    TextExtent extent = navigator.GetExtentOfWord(currentPoint);
        //    return currentPoint.Snapshot.CreateTrackingSpan(extent.Span, SpanTrackingMode.EdgeInclusive);
        //}

        public void Commit(ICompletionSession session, char typedChar)
        {
            if (session.SelectedCompletionSet != null && session.SelectedCompletionSet.SelectionStatus != null)
            {
                var completion = session.SelectedCompletionSet.SelectionStatus.Completion;
                var trackingSpan = completion.Properties.GetProperty<ITrackingSpan>(typeof(ITrackingSpan));

                var edit = TextBuffer.CreateEdit();
                edit.Replace(trackingSpan.GetSpan(edit.Snapshot), completion.InsertionText);
                edit.Apply();                
            }

            session.Dismiss();
        }
开发者ID:XewTurquish,项目名称:vsminecraft,代码行数:23,代码来源:JavaCompletion.cs

示例4: AugmentCompletionSession

        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            var tokens = classifier.Tokens;
            if (tokens != null)
            {
                // find current token
                var cursorPosition = session.TextView.Caret.Position.BufferPosition;
                var currentToken = tokens.FirstOrDefault(t => t.StartPosition <= cursorPosition && t.StartPosition + t.Length >= cursorPosition);
                if (currentToken != null)
                {
                    // prepare the context
                    var items = Enumerable.Empty<SimpleRwHtmlCompletion>();
                    var context = GetCompletionContext();
                    context.CurrentTokenIndex = classifier.Tokens.IndexOf(currentToken);
                    context.CurrentNode = parser.Root.FindNodeByPosition(session.TextView.Caret.Position.BufferPosition.Position - 1);
                    var combineWithHtmlCompletions = false;

                    TriggerPoint triggerPoint = TriggerPoint.None;
                    if (currentToken.Type == RwHtmlTokenType.DirectiveStart)
                    {
                        // directive name completion
                        triggerPoint = TriggerPoint.DirectiveName;
                        items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                    }
                    else if (currentToken.Type == RwHtmlTokenType.WhiteSpace)
                    {
                        if (context.CurrentNode is RwHtmlDirectiveNode && context.CurrentTokenIndex >= 2 && tokens[context.CurrentTokenIndex - 2].Type == RwHtmlTokenType.DirectiveStart)
                        {
                            // directive value
                            triggerPoint = TriggerPoint.DirectiveValue;
                            items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        }
                        else if (context.CurrentNode is RwHtmlElementNode || context.CurrentNode is RwHtmlAttributeNode)
                        {
                            // attribute name
                            triggerPoint = TriggerPoint.TagAttributeName;
                            items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                            combineWithHtmlCompletions = sourceProvider.CompletionProviders.OfType<MainTagAttributeNameCompletionProvider>().Single().CombineWithHtmlCompletions;
                        }
                    }
                    else if (currentToken.Type == RwHtmlTokenType.OpenTag)
                    {
                        // element name
                        triggerPoint = TriggerPoint.TagName;
                        items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        combineWithHtmlCompletions = true;
                    }
                    else if (currentToken.Type == RwHtmlTokenType.SingleQuote || currentToken.Type == RwHtmlTokenType.DoubleQuote || currentToken.Type == RwHtmlTokenType.Equals)
                    {
                        // attribute value
                        triggerPoint = TriggerPoint.TagAttributeValue;
                        items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        combineWithHtmlCompletions = true;
                    }
                    else if (currentToken.Type == RwHtmlTokenType.OpenBinding)
                    {
                        // binding name
                        triggerPoint = TriggerPoint.BindingName;
                        items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                    }
                    else if (currentToken.Type == RwHtmlTokenType.Colon)
                    {
                        if (context.CurrentNode is RwHtmlBindingNode)
                        {
                            // binding value
                            triggerPoint = TriggerPoint.BindingValue;
                            items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                        }
                        else
                        {
                            // element name
                            triggerPoint = TriggerPoint.TagName;
                            items = sourceProvider.CompletionProviders.Where(p => p.TriggerPoint == triggerPoint).SelectMany(p => p.GetItems(context));
                            combineWithHtmlCompletions = true;
                        }
                    }
                    var results = items.OrderBy(v => v.DisplayText).Distinct(CompletionEqualityComparer.Instance).ToList();

                    // show the session
                    if (!results.Any())
                    {
                        session.Dismiss();
                    }
                    else
                    {
                        // handle duplicate sessions (sometimes this method is called twice (e.g. when space key is pressed) so we need to make sure that we'll display only one session
                        lock (activeSessions)
                        {
                            if (activeSessions.Count > 0)
                            {
                                session.Dismiss();
                                return;
                            }
                            activeSessions.Add(session);

                            session.Dismissed += (s, a) =>
                            {
                                lock (activeSessions)
                                {
                                    activeSessions.Remove((ICompletionSession)s);
//.........这里部分代码省略.........
开发者ID:adamjez,项目名称:dotvvm,代码行数:101,代码来源:RwHtmlCompletionSource.cs


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