예제 #1
0
 /// <summary>
 /// Close the completion dropdown, don't make any changes
 /// </summary>
 public virtual void DismissCompletionSession()
 {
     if (HasActiveCompletionSession)
     {
         CompletionSession.Dismiss();
     }
 }
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var session = new CompletionSession()
            {

            };

            var completionContext = GetCompletionContext(view);

            if (completionContext.IsDocumentProperty)
            {
                var properties = GetProperties(completionContext.CompletedPropertyPath);
                foreach (var property in properties)
                {
                    session.Items.Add(new CompletionItem()
                    {
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        Text = property,
                        AutoCompletePreText = property,
                        DescriptionProvider =
                            new HtmlContentProvider(string.Format("Document Property <em>{0}</em>", property))
                    }); 
                }
            }
            else if (!completionContext.IsObjectMember)
            {
                session.Items.Add(new CompletionItem()
                {
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                    Text = "LoadDocument",
                    AutoCompletePreText = "LoadDocument",
                    DescriptionProvider =
                        new HtmlContentProvider("(<em>documentId</em>)<br/>Loads the document with the given id")
                });

                foreach (var patchValue in patchValues)
                {
                    session.Items.Add(new CompletionItem()
                    {
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ConstantPublic),
                        Text = patchValue.Key,
                        AutoCompletePreText = patchValue.Key,
                        DescriptionProvider =
                            new HtmlContentProvider(
                                          string.Format("Script Parameter <em>{0}</em>. Current value: <em>{1}</em>",
                                                        patchValue.Key, patchValue.Value))
                    });
                }
            }

            if (session.Items.Count > 0)
            {
                session.Open(view);
                return true;
            }
            else
            {
                return false;
            }
        }
        protected override void AddItemsToSession(CompletionSession session)
        {
            foreach (var sqlReplicationTable in sqlReplicationSettingsSectionModel.SelectedReplication.Value.SqlReplicationTables)
            {
                session.Items.Add(new CompletionItem
                {
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                    Text = "replicateTo" + sqlReplicationTable.TableName,
                    AutoCompletePreText = "replicateTo" + sqlReplicationTable.TableName,
                    DescriptionProvider =
                        new HtmlContentProvider("Will update/insert the specified object to the table " + sqlReplicationTable.TableName +
                                                ", using the specified pkName<br/>replicateTo" + sqlReplicationTable.TableName +
                                                "(columnsObj)")
                });
            }
            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                Text = "replicateTo",
                AutoCompletePreText = "replicateTo",
                DescriptionProvider =
                    new HtmlContentProvider("Will update/insert the specified object (with the object properties matching the table columns) to the specified table, using the specified pkName<br/>replicateTo(table, columnsObj)")
            });

            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.FieldPublic),
                Text = "documentId",
                AutoCompletePreText = "documentId",
                DescriptionProvider =
                    new HtmlContentProvider("The document id for the current document")
            });
        }
예제 #4
0
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var session = new CompletionSession
            {
                CanCommitWithoutPopup   = canCommitWithoutPopup,
                CanFilterUnmatchedItems = true,
                MatchOptions            = CompletionMatchOptions.UseAcronyms,
            };

            var context = GetCompletionContext(view);

            if (context.Field != null)
            {
                if (!isInFieldsOnlyMode)
                {
                    PopulateTerm(context.Field, session, view, context.Prefix);
                }
            }
            else
            {
                PopulateFields(session);
            }

            if (session.Items.Count == 0)
            {
                return(false);
            }

            session.Selection = new CompletionSelection(session.Items.First(), CompletionSelectionState.Partial);
            session.Open(view);

            return(true);
        }
예제 #5
0
 /// <summary>
 /// Restricts the set of completions to those that match the applicability
 /// text of the completion set, and then determines the best match.
 /// R is case-sensitive so 't' is different from 'T' (the latter is
 /// a shortcut for 'TRUE').
 /// </summary>
 public virtual void FilterCompletionSession()
 {
     if (HasActiveCompletionSession)
     {
         CompletionSession.Filter();
     }
 }
		protected override void AddItemsToSession(CompletionSession session)
		{
			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ClassPublic),
				Text = "this.",
				AutoCompletePreText = "this."
			});

			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
				Text = "LoadDocument",
				AutoCompletePreText = "LoadDocument",
				DescriptionProvider =
					new HtmlContentProvider("(<em>documentId</em>)<br/>Loads the document with the given id")
			});

			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
				Text = "PutDocument",
				AutoCompletePreText = "PutDocument",
				DescriptionProvider =
					new HtmlContentProvider("(<em>documentId</em>, <em>doc</em>, <em>meta</em>)<br/>Puts a document with the given id, with doc and metadata objects")
			});
		}
		protected override void AddItemsToSession(CompletionSession session)
		{
			foreach (var sqlReplicationTable in sqlReplicationSettingsSectionModel.SelectedReplication.Value.SqlReplicationTables)
			{
				session.Items.Add(new CompletionItem
				{
					ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
					Text = "replicateTo" + sqlReplicationTable.TableName,
					AutoCompletePreText = "replicateTo" + sqlReplicationTable.TableName,
					DescriptionProvider =
						new HtmlContentProvider("Will update/insert the specified object to the table " + sqlReplicationTable.TableName +
												", using the specified pkName<br/>replicateTo" + sqlReplicationTable.TableName +
												"(columnsObj)")
				});
			}
			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
				Text = "replicateTo",
				AutoCompletePreText = "replicateTo",
				DescriptionProvider =
					 new HtmlContentProvider("Will update/insert the specified object (with the object properties matching the table columns) to the specified table, using the specified pkName<br/>replicateTo(table, columnsObj)")
			});

			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.FieldPublic),
				Text = "documentId",
				AutoCompletePreText = "documentId",
				DescriptionProvider =
					 new HtmlContentProvider("The document id for the current document")
			});
		}
예제 #8
0
        protected override void AddItemsToSession(CompletionSession session)
        {
            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ClassPublic),
                Text = "this.",
                AutoCompletePreText = "this."
            });

            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                Text = "LoadDocument",
                AutoCompletePreText = "LoadDocument",
                DescriptionProvider =
                    new HtmlContentProvider("(<em>documentId</em>)<br/>Loads the document with the given id")
            });

            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                Text = "PutDocument",
                AutoCompletePreText = "PutDocument",
                DescriptionProvider =
                    new HtmlContentProvider("(<em>documentId</em>, <em>doc</em>, <em>meta</em>)<br/>Puts a document with the given id, with doc and metadata objects")
            });
        }
		public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
		{
			var session = new CompletionSession
			              {
			              	CanCommitWithoutPopup = canCommitWithoutPopup,
			              	CanFilterUnmatchedItems = true,
			              	MatchOptions = CompletionMatchOptions.UseAcronyms,
			              };

		    var context = GetCompletionContext(view);

            if (context.Field != null)
            {
                if (!isInFieldsOnlyMode)
                {
                    PopulateTerm(context.Field, session, view, context.Prefix);
                }
            }
			else
			{
				PopulateFields(session);
			}

			if (session.Items.Count == 0) return false;

			session.Selection = new CompletionSelection(session.Items.First(), CompletionSelectionState.Partial);
			session.Open(view);

			return true;
		}
예제 #10
0
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var session = new CompletionSession()
            {
            };

            var completionContext = GetCompletionContext(view);

            if (completionContext.IsDocumentProperty)
            {
                var properties = GetProperties(completionContext.CompletedPropertyPath);
                foreach (var property in properties)
                {
                    session.Items.Add(new CompletionItem()
                    {
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        Text = property,
                        AutoCompletePreText = property,
                        DescriptionProvider =
                            new HtmlContentProvider(string.Format("Document Property <em>{0}</em>", property))
                    });
                }
            }
            else if (!completionContext.IsObjectMember)
            {
                session.Items.Add(new CompletionItem()
                {
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                    Text = "LoadDocument",
                    AutoCompletePreText = "LoadDocument",
                    DescriptionProvider =
                        new HtmlContentProvider("(<em>documentId</em>)<br/>Loads the document with the given id")
                });

                foreach (var patchValue in patchValues)
                {
                    session.Items.Add(new CompletionItem()
                    {
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ConstantPublic),
                        Text = patchValue.Key,
                        AutoCompletePreText = patchValue.Key,
                        DescriptionProvider =
                            new HtmlContentProvider(
                                string.Format("Script Parameter <em>{0}</em>. Current value: <em>{1}</em>",
                                              patchValue.Key, patchValue.Value))
                    });
                }
            }

            if (session.Items.Count > 0)
            {
                session.Open(view);
                return(true);
            }
            else
            {
                return(false);
            }
        }
예제 #11
0
 private void PopulateFields(CompletionSession session)
 {
     foreach (var field in fields)
     {
         session.Items.Add(new CompletionItem
         {
             Text = field,
             ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
             AutoCompletePreText = field + ": ",
         });
     }
 }
예제 #12
0
        private void PopulateTerm(string field, CompletionSession session, IEditorView view, string termPrefix)
        {
            if (termPrefix.StartsWith("\""))
            {
                termPrefix = termPrefix.Substring(1);
            }

            if (termPrefix.EndsWith("\""))
            {
                termPrefix = termPrefix.Substring(0, termPrefix.Length - 1);
            }

            if (fieldTermsDictionary.ContainsKey(field) == false)
            {
                return;
            }

            var           termsDictionary = fieldTermsDictionary[field];
            List <string> terms;

            if (termsDictionary.ContainsKey(termPrefix))
            {
                terms = termsDictionary[termPrefix];
            }
            else
            {
                terms = new List <string>();
                termsDictionary[termPrefix] = terms;

                QueryIndexAutoComplete.GetTermsForFieldAsync(indexName, field, terms, termPrefix)
                .ContinueOnSuccessInTheUIThread(() =>
                {
                    PopulateTerm(field, session, view, termPrefix);
                    var completionItem = session.Items.FirstOrDefault();
                    if (completionItem != null)
                    {
                        session.Selection = new CompletionSelection(completionItem, CompletionSelectionState.Partial);
                        session.Open(view);
                    }
                });
            }

            foreach (var term in terms)
            {
                var maybeQuotedTerm = term.IndexOfAny(new[] { ' ', '\t' }) == -1 ? term : "\"" + term + "\"";
                session.Items.Add(new CompletionItem
                {
                    Text = term,
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ConstantPublic),
                    AutoCompletePreText = maybeQuotedTerm,
                });
            }
        }
예제 #13
0
	    private void PopulateFields(CompletionSession session)
	    {
	        foreach (var field in fields)
	        {
		        session.Items.Add(new CompletionItem
		        {
			        Text = field,
			        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
			        AutoCompletePreText = field + ": ",
		        });
	        }
	    }
        private void ShowMethodSignatureAsToolTip(CompletionSession session, IMember currentMember, string currentLine, int currentIndex)
        {
            session.SignatureToolTip = "";

            try
            {
                if (currentMember == null)
                {
                    return;
                }

                var lineParser = new FortranStatementParser();
                var methodName = lineParser.FindMethodAtOffset(currentLine, currentIndex);

                if (String.IsNullOrEmpty(methodName))
                {
                    return;
                }

                var allMethodsInScope = FortranSyntaxTreeModel.GetElementsAvailableInScope(SyntaxTreeMaintainer.GetSyntaxTrees(), currentMember).
                                        OfType <IMethod>();

                var method = allMethodsInScope.FirstOrDefault(m => String.Equals(m.Name, methodName,
                                                                                 StringComparison.InvariantCultureIgnoreCase));

                if (method == null)
                {
                    if (fortranIntrinsics.ContainsKey(methodName))
                    {
                        var intrinsicDoc  = fortranIntrinsics[methodName];
                        var fistLineOfDoc = intrinsicDoc.Split('\n').FirstOrDefault() ?? ""; // take first line of documentation
                        session.SignatureToolTip = fistLineOfDoc;
                    }
                    return;
                }

                var declarationParser = new FortranDeclarationParser();
                var signatureParser   = new FortranSignatureParser();
                declarationParser.ParseDeclarationsAndUses(method);
                signatureParser.ParseMethodSignature(method);

                session.SignatureToolTip = method.Name +
                                           "(" +
                                           String.Join(", ", method.Parameters.Select(p => p.TypeString + " " + p.Name).ToArray()) +
                                           ")";
            }
            catch (Exception e)
            {
                Log.Error("Exception while generating signature tooltip", e);
            }
        }
예제 #15
0
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var currentInterestingToken = GetCurrentInterestingToken(view);

            var session = new CompletionSession
            {
                CanCommitWithoutPopup   = canCommitWithoutPopup,
                CanFilterUnmatchedItems = true,
                MatchOptions            = CompletionMatchOptions.UseAcronyms,
            };

            if (currentInterestingToken != null && currentInterestingToken.EndsWith(":"))
            {
                var field = currentInterestingToken.Substring(0, currentInterestingToken.Length - 1);
                if (termsDictionary.ContainsKey(field) == false)
                {
                    return(false);
                }
                var terms = termsDictionary[field];
                foreach (var term in terms)
                {
                    session.Items.Add(new CompletionItem
                    {
                        Text = term,
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        AutoCompletePreText = term + " ",
                    });
                }
            }
            else
            {
                foreach (var field in fields)
                {
                    session.Items.Add(new CompletionItem
                    {
                        Text = field,
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        AutoCompletePreText = field + ": ",
                    });
                }
            }

            if (session.Items.Count == 0)
            {
                return(false);
            }

            session.Open(view);
            return(true);
        }
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var session = new CompletionSession();

            var completionContext = GetCompletionContext(view);

            if (completionContext.IsDocumentProperty)
            {
                var properties = GetProperties();
                foreach (var property in properties)
                {
                    session.Items.Add(new CompletionItem
                    {
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        Text = property,
                        AutoCompletePreText = property,
                        DescriptionProvider =
                            new HtmlContentProvider(string.Format("Document Property <em>{0}</em>", property))
                    });
                }
            }
            else if (!completionContext.IsObjectMember)
            {
                session.Items.Add(new CompletionItem
                {
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                    Text = "sqlReplicate",
                    AutoCompletePreText = "sqlReplicate",
                    DescriptionProvider =
                        new HtmlContentProvider("Will update/insert the specified object (with the object properties matching the table columns) to the specified table, using the specified pkName<br/>sqlReplicate(table, pkName, columnsObj)")
                });

                session.Items.Add(new CompletionItem
                {
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.FieldPublic),
                    Text = "documentId",
                    AutoCompletePreText = "documentId",
                    DescriptionProvider =
                        new HtmlContentProvider("The document id for the current document")
                });
            }

            if (session.Items.Count > 0)
            {
                session.Open(view);
                return(true);
            }

            return(false);
        }
예제 #17
0
	    private void PopulateTerm(string field, CompletionSession session, IEditorView view, string termPrefix)
		{
			if(termPrefix.StartsWith("\""))
			{
				termPrefix = termPrefix.Substring(1);
			}
			if( termPrefix.EndsWith("\""))
			{
				termPrefix = termPrefix.Substring(0,termPrefix.Length - 1);
			}

			if (fieldTermsDictionary.ContainsKey(field) == false)
				return;

			var termsDictionary = fieldTermsDictionary[field];
			List<string> terms;
			if (termsDictionary.ContainsKey(termPrefix))
			{
				terms = termsDictionary[termPrefix];
			}
			else
			{
				terms = new List<string>();
				termsDictionary[termPrefix] = terms;

			    QueryIndexAutoComplete.GetTermsForFieldAsync(indexName, field, terms, termPrefix)
			        .ContinueOnSuccessInTheUIThread(
			            () =>
			                {
			                    PopulateTerm(field, session, view, termPrefix);
			                    var completionItem = session.Items.FirstOrDefault();
			                    if (completionItem != null)
			                    {
			                        session.Selection = new CompletionSelection(completionItem,CompletionSelectionState.Partial);
                                    session.Open(view);
			                    }
			                });
			}

			foreach (var term in terms)
			{
				var maybeQuotedTerm = term.IndexOfAny(new[] {' ', '\t'}) == -1 ? term : "\"" + term + "\"";
				session.Items.Add(new CompletionItem
				{
					Text = term,
					ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ConstantPublic),
					AutoCompletePreText = maybeQuotedTerm,
				});
			}
		}
		public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
		{
			var session = new CompletionSession();

			var completionContext = GetCompletionContext(view);

			if (completionContext.IsDocumentProperty)
			{
				var properties = GetProperties();
				foreach (var property in properties)
				{
					session.Items.Add(new CompletionItem
					{
						ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
						Text = property,
						AutoCompletePreText = property,
						DescriptionProvider =
							new HtmlContentProvider(string.Format("Document Property <em>{0}</em>", property))
					});
				}
			}
			else if (!completionContext.IsObjectMember)
			{
				session.Items.Add(new CompletionItem
				{
					ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
					Text = "sqlReplicate",
					AutoCompletePreText = "sqlReplicate",
					DescriptionProvider =
						 new HtmlContentProvider("Will update/insert the specified object (with the object properties matching the table columns) to the specified table, using the specified pkName<br/>sqlReplicate(table, pkName, columnsObj)")
				});

				session.Items.Add(new CompletionItem
				{
					ImageSourceProvider = new CommonImageSourceProvider(CommonImage.FieldPublic),
					Text = "documentId",
					AutoCompletePreText = "documentId",
					DescriptionProvider =
						 new HtmlContentProvider("The document id for the current document")
				});
			}

			if (session.Items.Count > 0)
			{
				session.Open(view);
				return true;
			}

			return false;
		}
        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <param name="includeStartDelimiter">Whether to include the start delimiter.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup, bool includeStartDelimiter)
        {
            //
            // IMPORTANT NOTE:
            // The items for this completion list are hard coded in this sample and
            // are simply meant to illustrate the rich features of the SyntaxEditor completion list.
            // When implementing a real language, you should vary the items based
            // on the current context of the caret.
            //

            // Create a session
            CompletionSession session = new CompletionSession();

            session.CanCommitWithoutPopup = canCommitWithoutPopup;
            session.MatchOptions          = CompletionMatchOptions.TargetsDisplayText;

            // HTML allows ! and - characters to be typed too... make sure they are inserted
            session.AllowedCharacters.Add('!');
            session.AllowedCharacters.Add('-');

            // Add some items
            var highlightingStyleRegistry = view.HighlightingStyleRegistry;

            session.Items.Add(new CompletionItem("!--", new CommonImageSourceProvider(CommonImageKind.XmlComment),
                                                 new HtmlContentProvider("<b>&lt;!-- --&gt;</b> Comment<br/><span style=\"color: " + HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">A comment.</span>"),
                                                 String.Format("{0}!-- ", (includeStartDelimiter ? "<" : String.Empty)), " -->"));
            session.Items.Add(new CompletionItem("a", new CommonImageSourceProvider(CommonImageKind.XmlTag),
                                                 new HtmlContentProvider("<b>a</b> Element<br/><span style=\"color: " + HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">A hyperlink to another URL.</span>"),
                                                 String.Format("{0}a href=\"", (includeStartDelimiter ? "<" : String.Empty)), "\""));
            session.Items.Add(new CompletionItem("br", new CommonImageSourceProvider(CommonImageKind.XmlTag),
                                                 new HtmlContentProvider("<b>br</b> Element<br/><span style=\"color: " + HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Creates a line break.</span>"),
                                                 String.Format("{0}br/>", (includeStartDelimiter ? "<" : String.Empty)), null));

            if (session.Items.Count > 0)
            {
                // Ensure the caret is visible
                view.Scroller.ScrollToCaret();

                // Ensure the items are sorted and open the session
                session.SortItems();
                session.Open(view);
                return(true);
            }

            return(false);
        }
		public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
		{
			var currentInterestingToken = GetCurrentInterestingToken(view);

			var session = new CompletionSession
			              {
			              	CanCommitWithoutPopup = canCommitWithoutPopup,
			              	CanFilterUnmatchedItems = true,
			              	MatchOptions = CompletionMatchOptions.UseAcronyms,
			              };

			if (currentInterestingToken != null && currentInterestingToken.EndsWith(":"))
			{
				var field = currentInterestingToken.Substring(0, currentInterestingToken.Length - 1);
				if (termsDictionary.ContainsKey(field) == false)
					return false;
				var terms = termsDictionary[field];
				foreach (var term in terms)
				{
					session.Items.Add(new CompletionItem
					                  {
					                  	Text = term,
					                  	ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
					                  	AutoCompletePreText = term + " ",
					                  });
				}
			}
			else
			{
				foreach (var field in fields)
				{
					session.Items.Add(new CompletionItem
					                  {
					                  	Text = field,
					                  	ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
					                  	AutoCompletePreText = field + ": ",
					                  });
				}
			}

			if (session.Items.Count == 0) return false;

			session.Open(view);
			return true;
		}
예제 #21
0
        /// <summary>
        /// Close the completion dropdown, commit the selected item to the text view.
        /// Used when typing a char, use the one without a typed char for CompleteWord command
        /// </summary>
        /// <returns>true if text was committed</returns>
        public virtual bool CommitCompletionSession(char typedCharacter)
        {
            bool committed = false;

            if (CanCommitCompletionSession(typedCharacter))
            {
                UpdateInsertionText();
                CompletionSession.Commit();

                committed = true;
            }
            else if (HasActiveCompletionSession)
            {
                DismissCompletionSession();
            }

            return(committed);
        }
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var session = new CompletionSession
            {
                CanCommitWithoutPopup   = canCommitWithoutPopup,
                CanFilterUnmatchedItems = true,
                MatchOptions            = CompletionMatchOptions.UseAcronyms,
            };

            var    currentToken = GetInterestingToken(view, 0);
            var    prevToken    = GetInterestingToken(view, 1);
            string termPrefix   = null;

            if (currentToken != null && currentToken.EndsWith(":"))
            {
                PopulateTerm(currentToken, session, view, string.Empty);
            }
            else if (prevToken != null && prevToken.EndsWith(":"))
            {
                termPrefix = currentToken;
                PopulateTerm(prevToken, session, view, termPrefix);
            }
            else
            {
                foreach (var field in fields)
                {
                    session.Items.Add(new CompletionItem
                    {
                        Text = field,
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        AutoCompletePreText = field + ": ",
                    });
                }
            }

            if (session.Items.Count == 0)
            {
                return(false);
            }

            session.Selection = new CompletionSelection(session.Items.First(), CompletionSelectionState.Partial);
            session.Open(view);
            return(true);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            //
            // IMPORTANT NOTE:
            // The items for this completion list are hard coded in this sample and
            // are simply meant to illustrate the rich features of the SyntaxEditor completion list.
            // When implementing a real language, you should vary the items based
            // on the current context of the caret.
            //

            // Create a session
            var session = new CompletionSession();

            session.AllowedCharacters.Add('.');
            session.CanCommitWithoutPopup = canCommitWithoutPopup;

            // Insert the custom completion item matcher as the second thing in the list so that starts-with continues to match first
            session.ItemMatchers.Insert(1, new CustomCompletionItemMatcher());

            // Add some items
            session.Items.Add(new CompletionItem("CUSTOMER.FIRST_NAME", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));
            session.Items.Add(new CompletionItem("CUSTOMER.LAST_NAME", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));
            session.Items.Add(new CompletionItem("EMPLOYEE.CELL_NUMBER", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));
            session.Items.Add(new CompletionItem("EMPLOYEE.FIRST_NAME", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));
            session.Items.Add(new CompletionItem("EMPLOYEE.LAST_NAME", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));
            session.Items.Add(new CompletionItem("EMPLOYEE.ID", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));
            session.Items.Add(new CompletionItem("LOCATION.ID", new CommonImageSourceProvider(CommonImageKind.PropertyPublic)));

            if (session.Items.Count > 0)
            {
                // Ensure the caret is visible
                view.Scroller.ScrollToCaret();

                // Ensure the items are sorted and open the session
                session.SortItems();
                session.Open(view);
                return(true);
            }

            return(false);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            //
            // IMPORTANT NOTE:
            // The items for this completion list are hardcoded in this sample and
            // are simply meant to illustrate the rich features of the SyntaxEditor completion list.
            // When implementing a real language, you should vary the items based
            // on the current context of the caret.
            //

            // Create a session
            var session = new CompletionSession();

            session.CanCommitWithoutPopup = canCommitWithoutPopup;
            session.MatchOptions          = CompletionMatchOptions.TargetsDisplayText;

            // Add some items
            session.Items.Add(new CompletionItem("actiprosoftware.com", new CommonImageSourceProvider(CommonImageKind.PropertyPublic),
                                                 new DirectContentProvider("Inserts a URL to Actipro's web site."), "http://www.actiprosoftware.com", null));
            session.Items.Add(new CompletionItem("microsoft.com", new CommonImageSourceProvider(CommonImageKind.PropertyPublic),
                                                 new DirectContentProvider("Inserts a URL to Microsoft's web site."), "http://www.microsoft.com", null));
            session.Items.Add(new CompletionItem("Open URL dialog...", new CommonImageSourceProvider(CommonImageKind.ClassPublic),
                                                 new DirectContentProvider("Opens a URL Builder dialog."), null, null, "MsgBox"));

            if (session.Items.Count > 0)
            {
                // Attach to session events
                session.Closed     += OnSessionClosed;
                session.Committing += OnSessionCommitting;

                // Ensure the caret is visible
                view.Scroller.ScrollToCaret();

                // Ensure the items are sorted and open the session
                session.SortItems();
                session.Open(view);
                return(true);
            }

            return(false);
        }
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            //
            // IMPORTANT NOTE:
            // The items for this completion list are hard coded in this sample and
            // are simply meant to illustrate the rich features of the SyntaxEditor completion list.
            // When implementing a real language, you should vary the items based
            // on the current context of the caret.
            //

            // Create a session
            CompletionSession session = new CompletionSession();

            session.CanCommitWithoutPopup = canCommitWithoutPopup;

            // Add some items
            var highlightingStyleRegistry = view.HighlightingStyleRegistry;

            session.Items.Add(new CompletionItem("bool", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(bool))));
            session.Items.Add(new CompletionItem("byte", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(byte))));
            session.Items.Add(new CompletionItem("char", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(char))));
            session.Items.Add(new CompletionItem("double", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(double))));
            session.Items.Add(new CompletionItem("float", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(float))));
            session.Items.Add(new CompletionItem("int", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(int))));
            session.Items.Add(new CompletionItem("long", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(long))));
            session.Items.Add(new CompletionItem("short", new CommonImageSourceProvider(CommonImageKind.StructurePublic), new CustomContentProvider(highlightingStyleRegistry, typeof(short))));
            session.Items.Add(new CompletionItem("string", new CommonImageSourceProvider(CommonImageKind.ClassPublic), new CustomContentProvider(highlightingStyleRegistry, typeof(string))));

            if (session.Items.Count > 0)
            {
                // Ensure the caret is visible
                view.Scroller.ScrollToCaret();

                // Ensure the items are sorted and open the session
                session.SortItems();
                session.Open(view);
                return(true);
            }

            return(false);
        }
	    protected override void AddItemsToSession(CompletionSession session)
	    {
			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ClassPublic),
				Text = "this.",
				AutoCompletePreText = "this."
			});

			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
				Text = "LoadDocument",
				AutoCompletePreText = "LoadDocument",
				DescriptionProvider =
					new HtmlContentProvider("(<em>documentId</em>)<br/>Loads the document with the given id")
			});

			session.Items.Add(new CompletionItem
			{
				ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
				Text = "PutDocument",
				AutoCompletePreText = "PutDocument",
				DescriptionProvider =
					new HtmlContentProvider("(<em>documentId</em>, <em>doc</em>, <em>meta</em>)<br/>Puts a document with the given id, with doc and metadata objects")
			});

			foreach (var patchValue in patchValues)
			{
				session.Items.Add(new CompletionItem
				{
					ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ConstantPublic),
					Text = patchValue.Key,
					AutoCompletePreText = patchValue.Key,
					DescriptionProvider =
						new HtmlContentProvider(string.Format("Script Parameter <em>{0}</em>. Current value: <em>{1}</em>",
															  patchValue.Key, patchValue.Value))
				});
			}
	    }
예제 #27
0
        protected override void AddItemsToSession(CompletionSession session)
        {
            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ClassPublic),
                Text = "this.",
                AutoCompletePreText = "this."
            });

            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                Text = "LoadDocument",
                AutoCompletePreText = "LoadDocument",
                DescriptionProvider =
                    new HtmlContentProvider("(<em>documentId</em>)<br/>Loads the document with the given id")
            });

            session.Items.Add(new CompletionItem
            {
                ImageSourceProvider = new CommonImageSourceProvider(CommonImage.MethodPublic),
                Text = "PutDocument",
                AutoCompletePreText = "PutDocument",
                DescriptionProvider =
                    new HtmlContentProvider("(<em>documentId</em>, <em>doc</em>, <em>meta</em>)<br/>Puts a document with the given id, with doc and metadata objects")
            });

            foreach (var patchValue in patchValues)
            {
                session.Items.Add(new CompletionItem
                {
                    ImageSourceProvider = new CommonImageSourceProvider(CommonImage.ConstantPublic),
                    Text = patchValue.Key,
                    AutoCompletePreText = patchValue.Key,
                    DescriptionProvider =
                        new HtmlContentProvider(string.Format("Script Parameter <em>{0}</em>. Current value: <em>{1}</em>",
                                                              patchValue.Key, patchValue.Value))
                });
            }
        }
예제 #28
0
		public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
		{
			var session = new CompletionSession
			              {
			              	CanCommitWithoutPopup = canCommitWithoutPopup,
			              	CanFilterUnmatchedItems = true,
			              	MatchOptions = CompletionMatchOptions.UseAcronyms,
			              };

			var currentToken = GetInterestingToken(view, 0);
			var prevToken = GetInterestingToken(view, 1);
			string termPrefix = null;
			if (currentToken != null && currentToken.EndsWith(":"))
			{
				PopulateTerm(currentToken, session, view, string.Empty);
			}
			else if (prevToken != null && prevToken.EndsWith(":"))
			{
				termPrefix = currentToken;
				PopulateTerm(prevToken, session, view, termPrefix);
			}
			else
			{
				foreach (var field in fields)
				{
					session.Items.Add(new CompletionItem
					                  	{
					                  		Text = field,
					                  		ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
					                  		AutoCompletePreText = field + ": ",
					                  	});
				}
			}

			if (session.Items.Count == 0) return false;

			session.Selection = new CompletionSelection(session.Items.First(), CompletionSelectionState.Partial);
			session.Open(view);
			return true;
		}
예제 #29
0
		public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
		{
			var session = new CompletionSession
			{
				CanCommitWithoutPopup = canCommitWithoutPopup,
				CanFilterUnmatchedItems = true,
				MatchOptions = CompletionMatchOptions.UseAcronyms,
			};

			var completionContext = GetCompletionContext(view);

			if (completionContext.IsDocumentProperty && ShowDocumentProperties)
			{
				var properties = GetProperties(completionContext.CompletedPropertyPath);
				foreach (var property in properties)
				{
					session.Items.Add(new CompletionItem
					{
						ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
						Text = property,
						AutoCompletePreText = property,
						DescriptionProvider =
							new HtmlContentProvider(string.Format("Document Property <em>{0}</em>", property))
					});
				}
			}
			else if (!completionContext.IsObjectMember)
			{
				AddItemsToSession(session);
			}

			if (session.Items.Count > 0)
			{
				session.Open(view);
				return true;
			}

			return false;
		}
        public bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            var session = new CompletionSession
            {
                CanCommitWithoutPopup   = canCommitWithoutPopup,
                CanFilterUnmatchedItems = true,
                MatchOptions            = CompletionMatchOptions.UseAcronyms,
            };

            var completionContext = GetCompletionContext(view);

            if (completionContext.IsDocumentProperty && ShowDocumentProperties)
            {
                var properties = GetProperties(completionContext.CompletedPropertyPath);
                foreach (var property in properties)
                {
                    session.Items.Add(new CompletionItem
                    {
                        ImageSourceProvider = new CommonImageSourceProvider(CommonImage.PropertyPublic),
                        Text = property,
                        AutoCompletePreText = property,
                        DescriptionProvider =
                            new HtmlContentProvider(string.Format("Document Property <em>{0}</em>", property))
                    });
                }
            }
            else if (!completionContext.IsObjectMember)
            {
                AddItemsToSession(session);
            }

            if (session.Items.Count > 0)
            {
                session.Open(view);
                return(true);
            }

            return(false);
        }
예제 #31
0
        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            //
            // IMPORTANT NOTE:
            // The items for this completion list are hard coded in this sample and
            // are simply meant to illustrate the rich features of the SyntaxEditor completion list.
            // When implementing a real language, you should vary the items based
            // on the current context of the caret.
            //

            // Create a session
            CompletionSession session = new CompletionSession();

            session.CanCommitWithoutPopup = canCommitWithoutPopup;

            // Set options
            session.CanHighlightMatchedText = this.CanHighlightMatchedText;
            session.MatchOptions            = CompletionMatchOptions.None;
            if (IsCaseSensitive == false)
            {
                session.MatchOptions |= CompletionMatchOptions.IsCaseInsensitive;
            }
            if (RequiresExact == true)
            {
                session.MatchOptions |= CompletionMatchOptions.RequiresExact;
            }
            if (UseAcronyms == true)
            {
                session.MatchOptions |= CompletionMatchOptions.UseAcronyms;
            }
            if (UseShorthand == true)
            {
                session.MatchOptions |= CompletionMatchOptions.UseShorthand;
            }

            // Add some items
            var highlightingStyleRegistry = view.HighlightingStyleRegistry;

            session.Items.Add(new CompletionItem("aField", new CommonImageSourceProvider(CommonImageKind.FieldPrivate),
                                                 new HtmlContentProvider("<img src=\"resource:FieldPrivate\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>Foo.aField</b>")));
            session.Items.Add(new CompletionItem("AMethod", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<img src=\"resource:MethodPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">void</span> <b>Foo.AMethod</b>()")));
            session.Items.Add(new CompletionItem("AnIntValue", new CommonImageSourceProvider(CommonImageKind.PropertyPublic),
                                                 new HtmlContentProvider("<img src=\"resource:PropertyPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>Foo.AnIntValue</b>")));
            session.Items.Add(new CompletionItem("AStringValue", new CommonImageSourceProvider(CommonImageKind.PropertyPublic),
                                                 new HtmlContentProvider("<img src=\"resource:PropertyPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">string</span> <b>Foo.AStringValue</b>")));
            session.Items.Add(new CompletionItem("Equals", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<img src=\"resource:MethodPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() +
                                                                         ";\">bool</span> <b>object.Equals</b>(<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">object</span> obj)<br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Determines whether the specified <b>System.Object</b> is equal to the current <b>System.Object</b>.</span>")));
            session.Items.Add(new CompletionItem("GetHashCode", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<img src=\"resource:MethodPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() +
                                                                         ";\">int</span> <b>object.GetHashCode</b>()<br/><span style=\"color: " + HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Gets a hash code for this <b>System.Object</b>.</span>")));
            session.Items.Add(new CompletionItem("GetType", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<img src=\"resource:MethodPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() +
                                                                         ";\">Type</span> <b>object.GetType</b>()<br/><span style=\"color: " + HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Gets the <b>System.Type</b> of the current instance.</span>")));
            session.Items.Add(new CompletionItem("ToString", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<img src=\"resource:MethodPublic\" align=\"absbottom\" /> <span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() +
                                                                         ";\">string</span> <b>object.ToString</b>()<br/><span style=\"color: " + HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Returns the string representation of the object.</span>")));

            if (session.Items.Count > 0)
            {
                // Ensure the caret is visible
                view.Scroller.ScrollToCaret();

                // Ensure the items are sorted and open the session
                session.SortItems();
                session.Open(view);
                return(true);
            }

            return(false);
        }
예제 #32
0
		protected abstract void AddItemsToSession(CompletionSession session);
예제 #33
0
        private void method_2(bool bool_1, string string_0)
        {
            CompletionSession completionSession = new CompletionSession();

            completionSession.CanCommitWithoutPopup   = true;
            completionSession.CanHighlightMatchedText = true;
            completionSession.MatchOptions            = CompletionMatchOptions.None;
            completionSession.MatchOptions           |= CompletionMatchOptions.IsCaseInsensitive;
            List <CompletionItem> list = new List <CompletionItem>();
            string text = string_0.ToLowerInvariant();

            if (text.Contains("type") || text == "t")
            {
                list.Add(this.method_3("BaseType", "IType", "The Base Type for this Type"));
                list.Add(this.method_3("Fields", "FieldCollection", "A Collection of this Type's Fields"));
                list.Add(this.method_3("Methods", "MethodCollection", "A Collection of this Type's Methods"));
                list.Add(this.method_3("Events", "EventCollection", "A Collection of this Type's Events"));
                list.Add(this.method_3("Interfaces", "TypeCollection", "A Collection of Interfaces that this Type implements"));
                list.Add(this.method_3("TypesUsing", "TypeCollection", "A Collection of Types that depend on this Type"));
                list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this Type depends on"));
                list.Add(this.method_3("DerivedTypes", "TypeCollection", "A Collection of Types that derive from this Type"));
                list.Add(this.method_3("Assembly", "IAssembly", "The IAssembly that contains this Type"));
                list.Add(this.method_3("FullName", "string", "The full name of this Type"));
                list.Add(this.method_3("GenericParameterCount", "int", "The number of generic parameters on this Type"));
                list.Add(this.method_3("IsAbstract", "bool", "Whether or not this Type is Abstract"));
                list.Add(this.method_3("IsClass", "bool", "Whether or not this Type is a Class"));
                list.Add(this.method_3("IsDelegate", "bool", "Whether or not this Type is a Delegate"));
                list.Add(this.method_3("IsEnum", "bool", "Whether or not this Type is an Enum"));
                list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Type is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
                list.Add(this.method_3("IsInterface", "bool", "Whether or not this Type is an Interface"));
                list.Add(this.method_3("IsInternal", "bool", "Whether or not this Type is marked Internal"));
                list.Add(this.method_3("IsNested", "bool", "Whether or not this Type is a Nested Type"));
                list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Type is marked Private"));
                list.Add(this.method_3("IsProtected", "bool", "Whether or not this Type is marked Protected (visible only to derived classes)"));
                list.Add(this.method_3("IsProtectedAndInternal", "bool", "Whether or not this Type is marked Protected and Internal (visible only to derived classes from the same assembly)"));
                list.Add(this.method_3("IsProtectedOrInternal", "bool", "Whether or not this Type is marked Protected or Internal (visible only to derived classes or classes in the same assembly)"));
                list.Add(this.method_3("IsPublic", "bool", "Whether or not this Type is marked Public"));
                list.Add(this.method_3("IsSealed", "bool", "Whether or not this Type is Sealed (doesn't allow for derived classes)"));
                list.Add(this.method_3("IsStatic", "bool", "Whether or not this Type is Static"));
                list.Add(this.method_3("IsValueType", "bool", "Whether or not this Type is a Value Type"));
                list.Add(this.method_3("Name", "string", "The name of this Type"));
                list.Add(this.method_3("Namespace", "INamespace", "The INamespace that contains this Type"));
                list.Add(this.method_3("TypeId", "int", "The Nitriq Unique Id for this Type. You must select this in a query in order for the Treemap and other visualizations to work properly"));
                list.Add(this.method_3("PhysicalLineCount", "int", "The sum of the line count for all Methods in this Type. Does NOT include any lines outside of its methods"));
                list.Add(this.method_3("LogicalLineCount", "int", "The number of breakpoints that could be set inside this type"));
                list.Add(this.method_3("CommentLineCount", "int", "The sum of the comment lines for all Methods in this Type. Does NOT include any lines/comments outside of its methods."));
                list.Add(this.method_3("Cyclomatic", "int", "The sum of the cyclomatic complexity for all Methods in this Type"));
                list.Add(this.method_3("ILCount", "int", "The sum of the IL instructions for all Methods in this Type"));
                list.Add(this.method_3("PercentComment", "double", "The CommentLineCount divided by the PhysicalLineCount. (Only counts lines inside a method)"));
                list.Add(this.method_3("InheritanceDepth", "int", "The Depth of this Type in its Inheritance Tree"));
            }
            else if (text.Contains("method") || text == "m")
            {
                list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Method is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
                list.Add(this.method_3("ParameterTypes", "TypeCollection", "A distinct set of the Types of this Method's Parameters"));
                list.Add(this.method_3("Type", "IType", "The Type that Declares this method"));
                list.Add(this.method_3("Name", "string", "The Name of this method"));
                list.Add(this.method_3("FullName", "string", "The Full Name of this method"));
                list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this method depends on"));
                list.Add(this.method_3("MethodId", "int", "The Nitriq Unique Id for this Method. You must select this in a query in order for the Treemap and other visualizations to work properly"));
                list.Add(this.method_3("ReturnType", "IType", "The Type that this Method returns"));
                list.Add(this.method_3("LogicalLineCount", "int", "The number of breakpoints that *could* be set in this Method."));
                list.Add(this.method_3("PhysicalLineCount", "int", "The number of line breaks in the source code for this Method."));
                list.Add(this.method_3("CommentLineCount", "int", "The number of lines with comments in the source code for this Method"));
                list.Add(this.method_3("ILCount", "int", "The number of IL Instructions in this Method"));
                list.Add(this.method_3("Cyclomatic", "int", "The Cyclomatic Complexity (CC) of this Method. CC is the number of individual paths through a method. In C# it is the count the following tokens if, &&, ||, for, foreach, case, default, continue, while, goto, catch, ??, and a ternary expression"));
                list.Add(this.method_3("ILCyclomatic", "int", "The cyclomatic complexity of the IL for a method is the count of the distinct offset targets in a branch/jump instruction"));
                list.Add(this.method_3("ParameterCount", "int", "The number of parameters on this Method"));
                list.Add(this.method_3("OverloadCount", "int", "The number of overloads for this Method (same method name on the same class but with a different set of parameters)"));
                list.Add(this.method_3("IsPublic", "bool", "Whether or not this Method is marked Public"));
                list.Add(this.method_3("IsInternal", "bool", "Whether or not this Method is marked Internal (only visible from the same assembly)"));
                list.Add(this.method_3("IsProtected", "bool", "Whether or not this Method is marked Protected"));
                list.Add(this.method_3("IsProtectedOrInternal", "bool", "Whether or not this Type is marked Protected or Internal (visible only to derived classes or classes in the same assembly)"));
                list.Add(this.method_3("IsProtectedAndInternal", "bool", "Whether or not this Type is marked Protected and Internal (visible only to derived classes from the same assembly)"));
                list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Method is marked Private"));
                list.Add(this.method_3("IsConstructor", "bool", "Whether or not this Method is a Constructor"));
                list.Add(this.method_3("IsPropertyGetter", "bool", "Whether or not this Method is a Property Getter"));
                list.Add(this.method_3("IsPropertySetter", "bool", "Whether or not this Method is a Property Setter"));
                list.Add(this.method_3("IsStatic", "bool", "Whether or not this Method is marked Static"));
                list.Add(this.method_3("IsVirtual", "bool", "Whether or not this Method is marked Virtual"));
                list.Add(this.method_3("UsesBoxing", "bool", "Whether or not this Method uses Boxing"));
                list.Add(this.method_3("UsesUnboxing", "bool", "Whether or not this Method uses Unboxing"));
                list.Add(this.method_3("IsGeneric", "bool", "Whether or not this Method is has generic parameters"));
                list.Add(this.method_3("IsOperator", "bool", "Whether or not this Method is an Operator"));
                list.Add(this.method_3("IsIndexGetter", "bool", "Whether or not this Method is an Index Getter (ie this[int index])"));
                list.Add(this.method_3("IsIndexSetter", "bool", "Whether or not this Method is an Index Setter (ie this[int index])"));
                list.Add(this.method_3("IsEventAdder", "bool", "Whether or not this Method is an Event Adder"));
                list.Add(this.method_3("IsEventRemover", "bool", "Whether or not this Method is an Index Remover"));
                list.Add(this.method_3("IsStaticConstructor", "bool", "Whether or not this Method is a Static Constructor"));
                list.Add(this.method_3("PercentComment", "double", "The percent of lines in this Method that are comments (100 * CommentLineCount / PhysicalLineCount)"));
                list.Add(this.method_3("Calls", "MethodCollection", "Methods that this Method Calls"));
                list.Add(this.method_3("CalledBy", "MethodCollection", "Methods that call this Method"));
                list.Add(this.method_3("FieldSets", "FieldCollection", "Fields that this Method Sets"));
                list.Add(this.method_3("FieldGets", "FieldCollection", "Fields that this Method Gets (reads from)"));
            }
            else if (text.Contains("event") || text == "e" || text == "ev")
            {
                list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Event is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
                list.Add(this.method_3("Type", "IType", "The Type that Declares this Event"));
                list.Add(this.method_3("Name", "string", "The Name of this Event"));
                list.Add(this.method_3("FullName", "string", "The Full Name of this Event"));
                list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this Event depends on"));
                list.Add(this.method_3("EventType", "IType", "The Type of this Event"));
                list.Add(this.method_3("EventId", "int", "The Nitriq Unique Id for this Event. You must select this in a query in order for the Treemap and other visualizations to work properly"));
                list.Add(this.method_3("IsPublic", "bool", "Whether or not this Event is marked Public"));
                list.Add(this.method_3("IsInternal", "bool", "Whether or not this Event is marked Internal"));
                list.Add(this.method_3("IsProtected", "bool", "Whether or not this Event is marked Protected"));
                list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Event is marked Private"));
                list.Add(this.method_3("IsStatic", "bool", "Whether or not this Event is marked Static"));
            }
            else if (text.Contains("field") || text == "f")
            {
                list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Field is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
                list.Add(this.method_3("Type", "IType", "The Type that Declares this Field"));
                list.Add(this.method_3("Name", "string", "The Name of this Field"));
                list.Add(this.method_3("FullName", "string", "The Full Name of this Field"));
                list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this Field depends on"));
                list.Add(this.method_3("FieldId", "int", "The Nitriq Unique Id for this Field. You must select this in a query in order for the Treemap and other visualizations to work properly"));
                list.Add(this.method_3("FieldType", "IType", "The Type of this Field"));
                list.Add(this.method_3("SetByMethods", "MethodCollection", "A Collection of Methods that assign values to this Field"));
                list.Add(this.method_3("GotByMethods", "MethodCollection", "A Collection of Methods that retrieve values from this Field"));
                list.Add(this.method_3("IsPublic", "bool", "Whether or not this Field is marked Public"));
                list.Add(this.method_3("IsInternal", "bool", "Whether or not this Field is marked Internal"));
                list.Add(this.method_3("IsProtected", "bool", "Whether or not this Field is marked Protected"));
                list.Add(this.method_3("IsProtectedOrInternal", "bool", "Whether or not this Field is marked Protected or Internal"));
                list.Add(this.method_3("IsProtectedAndInternal", "bool", "Whether or not this Field is marked Protected and Internal"));
                list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Field is marked Private"));
                list.Add(this.method_3("IsStatic", "bool", "Whether or not this Field is marked Static"));
                list.Add(this.method_3("IsConstant", "bool", "Whether or not this Field is marked const"));
            }
            else if (text.Contains("assembly") || text.Contains("assem") || text == "a")
            {
                list.Add(this.method_3("AssemblyId", "int", "The Nitriq Unique Id given to this Assembly. You must select this in a query in order for the Treemap and other visualizations to work properly."));
                list.Add(this.method_3("Version", "string", "The Version of this Assembly"));
                list.Add(this.method_3("Namespaces", "NamespaceCollection", "The INamespace array of Namespaces in this Assembly"));
                list.Add(this.method_3("Name", "string", "The name of this Assembly"));
                list.Add(this.method_3("IsCoreAssembly", "bool", "Returns whether or not this Assembly is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing - typically excludes Microsoft and 3rd Party Assemblies."));
            }
            else if (text.Contains("namespace") || text == "n" || text == "ns")
            {
                list.Add(this.method_3("FullName", "string", "The FullName of this Namespace"));
                list.Add(this.method_3("Types", "TypeCollection", "A Collection of Types that are contained in this Namespace"));
                list.Add(this.method_3("NamespaceId", "int", "The Nitriq Unique Id given to this Namespace. You must select this in a query in order for the Treemap and other visualizations to work properly."));
            }
            List <CompletionItem> arg_D81_0 = list;

            if (NitriqEditor.comparison_0 == null)
            {
                NitriqEditor.comparison_0 = new Comparison <CompletionItem>(NitriqEditor.smethod_2);
            }
            arg_D81_0.Sort(NitriqEditor.comparison_0);
            foreach (CompletionItem current in list)
            {
                completionSession.Items.Add(current);
            }
            completionSession.Open(this.nitriqSyntaxEditor_0.ActiveView);
        }
        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            //
            // IMPORTANT NOTE:
            // The items and filters for this completion list are hard coded in this sample and
            // are simply meant to illustrate the rich features of the SyntaxEditor completion list.
            // When implementing a real language, you should vary the items and filters based
            // on the current context of the caret.
            //

            // Create a session
            CompletionSession session = new CompletionSession();

            session.CanCommitWithoutPopup   = canCommitWithoutPopup;
            session.CanFilterUnmatchedItems = this.FilterUnmatchedItems;
            session.MatchOptions            = CompletionMatchOptions.UseAcronyms | CompletionMatchOptions.UseShorthand;

            // Add some items
            var highlightingStyleRegistry = view.HighlightingStyleRegistry;

            session.Items.Add(new CompletionItem("_intValue", new CommonImageSourceProvider(CommonImageKind.FieldPrivate),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>Foo._intValue</b><br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">An integer value.</span>")));
            session.Items.Add(new CompletionItem("Equals", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">bool</span> <b>object.Equals</b>(<span style=\"color: " +
                                                                         HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">object</span> obj)<br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Determines whether the specified <b>System.Object</b> is equal to the current <b>System.Object</b>.</span>")));
            session.Items.Add(new CompletionItem("GetHashCode", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>object.GetHashCode</b>()<br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Gets a hash code for this <b>System.Object</b>.</span>")));
            session.Items.Add(new CompletionItem("GetType", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Type</span> <b>object.GetType</b>()<br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Gets the <b>System.Type</b> of the current instance.</span>")));
            session.Items.Add(new CompletionItem("IntValue", new CommonImageSourceProvider(CommonImageKind.PropertyPublic),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">int</span> <b>Foo.IntValue</b><br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">An integer value.</span>")));
            session.Items.Add(new CompletionItem("IntValueChanged", new CommonImageSourceProvider(CommonImageKind.EventPublic),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">EventHandler</span> <b>Foo.IntValueChanged</b>")));
            session.Items.Add(new CompletionItem("OnIntValueChanged", new CommonImageSourceProvider(CommonImageKind.MethodProtected),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">void</span> <b>Foo.OnIntValueChanged</b>(<span style=\"color: " +
                                                                         HtmlContentProvider.GetTypeNameForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">EventArgs</span> e)")));
            session.Items.Add(new CompletionItem("ToString", new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                 new HtmlContentProvider("<span style=\"color: " + HtmlContentProvider.GetKeywordForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">string</span> <b>object.ToString</b>()<br/><span style=\"color: " +
                                                                         HtmlContentProvider.GetCommentForegroundColor(highlightingStyleRegistry).ToWebColor() + ";\">Returns the string representation of the object.</span>")));

            //
            // NOTE: In the filters below, the filtering conditions are just looking at the item text and image used.
            //   Normally you would store some contextual object in the Tag property and examine that instead.
            //

            if (this.MemberTypeFilterButtonsVisible == true)
            {
                // Add member type filters
                session.Filters.Add(new CompletionFilter("Events",
                                                         (mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Event"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
                                                         )
                {
                    DisplayMode = CompletionFilterDisplayMode.ToggleButton,
                    GroupName   = "MemberType",
                    ToolTip     = "Events",
                    Content     = new Image()
                    {
                        Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.EventPublic).GetImageSource()
                    }
                });
                session.Filters.Add(new CompletionFilter("Fields",
                                                         (mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Field"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
                                                         )
                {
                    DisplayMode = CompletionFilterDisplayMode.ToggleButton,
                    GroupName   = "MemberType",
                    ToolTip     = "Fields",
                    Content     = new Image()
                    {
                        Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.FieldPublic).GetImageSource()
                    }
                });
                session.Filters.Add(new CompletionFilter("Methods",
                                                         (mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Method"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
                                                         )
                {
                    DisplayMode = CompletionFilterDisplayMode.ToggleButton,
                    GroupName   = "MemberType",
                    ToolTip     = "Methods",
                    Content     = new Image()
                    {
                        Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.MethodPublic).GetImageSource()
                    }
                });
                session.Filters.Add(new CompletionFilter("Properties",
                                                         (mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().StartsWith("Property"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
                                                         )
                {
                    DisplayMode = CompletionFilterDisplayMode.ToggleButton,
                    GroupName   = "MemberType",
                    ToolTip     = "Properties",
                    Content     = new Image()
                    {
                        Width = 16, Height = 16, Source = new CommonImageSourceProvider(CommonImageKind.PropertyPublic).GetImageSource()
                    }
                });
            }

            if (this.InheritedFilterButtonVisible == true)
            {
                // Add inherited filter
                session.Filters.Add(new CompletionFilter("Inherited",
                                                         (CompletionFilterPredicate) delegate(ICompletionSession mysession, ICompletionItem item) { return(("Equals,GetHashCode,GetType,ToString".IndexOf(item.Text) != -1) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded); })
                {
                    DisplayMode = CompletionFilterDisplayMode.ToggleButton,
                    GroupName   = "Inherited",
                    ToolTip     = "Inherited members",
                    Content     = "Inherited"
                });
            }

            if (this.FilterTabsVisible == true)
            {
                // Add access filters
                session.Filters.Add(new CompletionFilter("All",
                                                         (mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().EndsWith("Public"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
                                                         )
                {
                    DisplayMode = CompletionFilterDisplayMode.AllTab,
                    Content     = "All members",
                });
                session.Filters.Add(new CompletionFilter("Public",
                                                         (mysession, item) => (((item.Text == null) || (((CommonImageSourceProvider)item.ImageSourceProvider).ImageKind.ToString().EndsWith("Public"))) ? CompletionFilterResult.Included : CompletionFilterResult.Excluded)
                                                         )
                {
                    DisplayMode = CompletionFilterDisplayMode.Tab,
                    Content     = "Public members"
                });
            }

            if (session.Items.Count > 0)
            {
                // Ensure the caret is visible
                view.Scroller.ScrollToCaret();

                // Ensure the items are sorted and open the session
                session.SortItems();
                session.Open(view);
                return(true);
            }

            return(false);
        }
예제 #35
0
 private void TheCompletionsListView_MouseDoubleClick(object sender, MouseButtonEventArgs e)
 {
     CompletionSession?.Commit();
 }
        /// <summary>
        /// This method parses the current line, and determines which suggestions to show for code completion (intellisense)
        /// </summary>
        /// <param name="session"></param>
        private void UpdateCodeComplete(CompletionSession session)
        {
            //parse current line
            //set results
            //set filter
            try
            {
                ParseQueueProcessor.ShowProgressDialog = false; //maybe not actually required anymore

                var currentLine = VisualStudio.GetCurrentLine();

                var currentIndex = VisualStudio.GetCursorPositionInLine();

                var lineParser = new FortranStatementParser();

                var beginOfStatement = 0;

                var statement     = lineParser.FindEffectiveStatementAtOffset(currentLine, currentIndex, out beginOfStatement);
                var fullStatement = currentLine.Substring(beginOfStatement, currentIndex - beginOfStatement);

                var currentMember = GetCurrent <IMember>();

                ShowMethodSignatureAsToolTip(session, currentMember, currentLine, currentIndex);

                IList <INameable> codeCompleteOptions;
                var filter = "";
                var addLanguageKeywords = false;
                var codeElementsInScope =
                    FortranSyntaxTreeModel.GetElementsAvailableInScope(SyntaxTreeMaintainer.GetSyntaxTrees(),
                                                                       currentMember);

                // are we in a 'call something' statement?
                var callMatch = callRegex.Match(statement);
                if (callMatch.Success)
                {
                    //only subroutines
                    codeCompleteOptions          = codeElementsInScope.OfType <Subroutine>().Cast <INameable>().ToList(); //subroutines only
                    session.InsertionIndexInLine = beginOfStatement + callMatch.Groups[1].Index;
                    filter = callMatch.Groups[1].Value;
                }
                else if (!statement.Contains('%')) //local scope
                {
                    if (statement.Length > 0 &&
                        FortranParseHelper.IsWhiteSpace(statement[statement.Length - 1]))
                    {
                        //reset: wrong statement:
                        beginOfStatement += statement.Length;
                        statement         = "";
                    }

                    codeCompleteOptions          = codeElementsInScope.Where(ce => !(ce is Subroutine)).ToList(); //subroutines only available after a 'call'
                    session.InsertionIndexInLine = beginOfStatement;
                    filter = statement;
                    addLanguageKeywords = true;
                }
                else // nested in type, eg: channel % sourceNode % id
                {
                    var elements = FortranParseHelper.SplitElementsInStatement(statement, fullStatement, ref beginOfStatement, out filter);

                    if (elements.Count < 1)
                    {
                        throw new NotSupportedException("help!");
                    }

                    var variableName = elements[0];

                    var matchingVariable = codeElementsInScope
                                           .OfType <Variable>()
                                           .FirstOrDefault(lv => String.Equals(lv.Name, variableName, StringComparison.InvariantCultureIgnoreCase));

                    var typeOfVariable = matchingVariable.TypeString;

                    var currentType = codeElementsInScope
                                      .OfType <Type>()
                                      .FirstOrDefault(tp => String.Equals(tp.Name, typeOfVariable, StringComparison.InvariantCultureIgnoreCase));

                    for (int i = 1; i < elements.Count; i++)
                    {
                        if (currentType == null)
                        {
                            break;
                        }

                        var propertyName = elements[i];
                        var property     = GetElementsOfType(currentType).FirstOrDefault(vf => String.Equals(vf.Name, propertyName, StringComparison.InvariantCultureIgnoreCase));

                        typeOfVariable = property.TypeString;

                        currentType = codeElementsInScope
                                      .OfType <Type>()
                                      .FirstOrDefault(tp => String.Equals(tp.Name, typeOfVariable, StringComparison.InvariantCultureIgnoreCase));
                    }

                    if (currentType == null)
                    {
                        codeCompleteOptions = new INameable[] { }
                    }
                    ;
                    else
                    {
                        codeCompleteOptions = GetElementsOfType(currentType).Cast <INameable>().ToList();
                    }

                    session.InsertionIndexInLine = beginOfStatement;
                }

                // gather all results
                var completionItems = codeCompleteOptions.Select(e => new CompletionItem(e.Name, FortranIconProvider.GetIconForMember(e))
                {
                    ToolTip = GetTooltipForMember(currentMember, e)
                }).ToList();
                if (addLanguageKeywords)
                {
                    foreach (var keyword in fortranKeywords)
                    {
                        completionItems.Add(new CompletionItem(keyword, null));
                    }

                    foreach (var intrinsic in fortranIntrinsics)
                    {
                        completionItems.Add(new CompletionItem(intrinsic.Key, IntrinsicIcon)
                        {
                            ToolTip = intrinsic.Value
                        });
                    }
                }

                {//YK, 2020, also add all the words already in this current file
                    //check file content.
                    var myFileContents = VisualStudio.GetCurrentCodeFileContent();

                    {
                        ////two methods to replace \t, \n, \r, tested and works
                        //myFileContents = Regex.Replace(myFileContents, @"\t", " ");
                        ////myFileContents = myFileContents.Replace("\t", " ");
                        //myFileContents = myFileContents.Replace("\r", " ");
                        //myFileContents = myFileContents.Replace("\n", " ");
                    }

                    {//example to remove separator...
                     //char[] separators = new char[] { ' ', ';', ',', '\r', '\t', '\n', '(', ')', '!', ':', '=', '+', '*', '/' };
                     //string s = "replace;multiple,characters\tin;a,c\rsharp,string";
                     //string[] temp = s.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                     //s = String.Join("\n", temp);
                    }

                    {//example to remove duplicated string
                     //String[] a = { "1", "1", "2", "1", "1", "3", "1", "1", };
                     //Console.WriteLine("原数组长度:    {0}", a.Length);
                     //Console.WriteLine("排除后数组长度:{0}", a.Distinct<string>().ToArray().Length);
                     //Console.ReadKey();
                    }

                    char[]   separators = new char[] { ' ', ';', ',', '\r', '\t', '\n', '(', ')', '!', ':', '=', '+', '-', '*', '/', '&', '.', '\'', '<', '>', '{', '}', '[', ']', '$', '%', '?' };
                    string   s          = myFileContents;
                    string[] myFileContentSplittedStr         = myFileContents.Split(separators, StringSplitOptions.RemoveEmptyEntries);
                    string[] myFileContentSplittedStrDistinct = myFileContentSplittedStr.Distinct <string>().ToArray();
                    foreach (var keyword in myFileContentSplittedStrDistinct)
                    {
                        //{//example to add non-duplicated string
                        //    //if (!listString.Contains(eachString))
                        //    //    listString.Add(eachString);
                        //}

                        completionItems.Add(new CompletionItem(keyword, null));
                    }
                }

                session.SetCompletionSet(completionItems, filter);
            }
            catch (Exception e)
            {
                Log.Error("Error while updating code complete", e);
            }
            finally
            {
                ParseQueueProcessor.ShowProgressDialog = true; //messes with intellisense popup
            }
        }
예제 #37
0
		private void method_2(bool bool_1, string string_0)
		{
			CompletionSession completionSession = new CompletionSession();
			completionSession.CanCommitWithoutPopup = true;
			completionSession.CanHighlightMatchedText = true;
			completionSession.MatchOptions = CompletionMatchOptions.None;
			completionSession.MatchOptions |= CompletionMatchOptions.IsCaseInsensitive;
			List<CompletionItem> list = new List<CompletionItem>();
			string text = string_0.ToLowerInvariant();
			if (text.Contains("type") || text == "t")
			{
				list.Add(this.method_3("BaseType", "IType", "The Base Type for this Type"));
				list.Add(this.method_3("Fields", "FieldCollection", "A Collection of this Type's Fields"));
				list.Add(this.method_3("Methods", "MethodCollection", "A Collection of this Type's Methods"));
				list.Add(this.method_3("Events", "EventCollection", "A Collection of this Type's Events"));
				list.Add(this.method_3("Interfaces", "TypeCollection", "A Collection of Interfaces that this Type implements"));
				list.Add(this.method_3("TypesUsing", "TypeCollection", "A Collection of Types that depend on this Type"));
				list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this Type depends on"));
				list.Add(this.method_3("DerivedTypes", "TypeCollection", "A Collection of Types that derive from this Type"));
				list.Add(this.method_3("Assembly", "IAssembly", "The IAssembly that contains this Type"));
				list.Add(this.method_3("FullName", "string", "The full name of this Type"));
				list.Add(this.method_3("GenericParameterCount", "int", "The number of generic parameters on this Type"));
				list.Add(this.method_3("IsAbstract", "bool", "Whether or not this Type is Abstract"));
				list.Add(this.method_3("IsClass", "bool", "Whether or not this Type is a Class"));
				list.Add(this.method_3("IsDelegate", "bool", "Whether or not this Type is a Delegate"));
				list.Add(this.method_3("IsEnum", "bool", "Whether or not this Type is an Enum"));
				list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Type is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
				list.Add(this.method_3("IsInterface", "bool", "Whether or not this Type is an Interface"));
				list.Add(this.method_3("IsInternal", "bool", "Whether or not this Type is marked Internal"));
				list.Add(this.method_3("IsNested", "bool", "Whether or not this Type is a Nested Type"));
				list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Type is marked Private"));
				list.Add(this.method_3("IsProtected", "bool", "Whether or not this Type is marked Protected (visible only to derived classes)"));
				list.Add(this.method_3("IsProtectedAndInternal", "bool", "Whether or not this Type is marked Protected and Internal (visible only to derived classes from the same assembly)"));
				list.Add(this.method_3("IsProtectedOrInternal", "bool", "Whether or not this Type is marked Protected or Internal (visible only to derived classes or classes in the same assembly)"));
				list.Add(this.method_3("IsPublic", "bool", "Whether or not this Type is marked Public"));
				list.Add(this.method_3("IsSealed", "bool", "Whether or not this Type is Sealed (doesn't allow for derived classes)"));
				list.Add(this.method_3("IsStatic", "bool", "Whether or not this Type is Static"));
				list.Add(this.method_3("IsValueType", "bool", "Whether or not this Type is a Value Type"));
				list.Add(this.method_3("Name", "string", "The name of this Type"));
				list.Add(this.method_3("Namespace", "INamespace", "The INamespace that contains this Type"));
				list.Add(this.method_3("TypeId", "int", "The Nitriq Unique Id for this Type. You must select this in a query in order for the Treemap and other visualizations to work properly"));
				list.Add(this.method_3("PhysicalLineCount", "int", "The sum of the line count for all Methods in this Type. Does NOT include any lines outside of its methods"));
				list.Add(this.method_3("LogicalLineCount", "int", "The number of breakpoints that could be set inside this type"));
				list.Add(this.method_3("CommentLineCount", "int", "The sum of the comment lines for all Methods in this Type. Does NOT include any lines/comments outside of its methods."));
				list.Add(this.method_3("Cyclomatic", "int", "The sum of the cyclomatic complexity for all Methods in this Type"));
				list.Add(this.method_3("ILCount", "int", "The sum of the IL instructions for all Methods in this Type"));
				list.Add(this.method_3("PercentComment", "double", "The CommentLineCount divided by the PhysicalLineCount. (Only counts lines inside a method)"));
				list.Add(this.method_3("InheritanceDepth", "int", "The Depth of this Type in its Inheritance Tree"));
			}
			else if (text.Contains("method") || text == "m")
			{
				list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Method is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
				list.Add(this.method_3("ParameterTypes", "TypeCollection", "A distinct set of the Types of this Method's Parameters"));
				list.Add(this.method_3("Type", "IType", "The Type that Declares this method"));
				list.Add(this.method_3("Name", "string", "The Name of this method"));
				list.Add(this.method_3("FullName", "string", "The Full Name of this method"));
				list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this method depends on"));
				list.Add(this.method_3("MethodId", "int", "The Nitriq Unique Id for this Method. You must select this in a query in order for the Treemap and other visualizations to work properly"));
				list.Add(this.method_3("ReturnType", "IType", "The Type that this Method returns"));
				list.Add(this.method_3("LogicalLineCount", "int", "The number of breakpoints that *could* be set in this Method."));
				list.Add(this.method_3("PhysicalLineCount", "int", "The number of line breaks in the source code for this Method."));
				list.Add(this.method_3("CommentLineCount", "int", "The number of lines with comments in the source code for this Method"));
				list.Add(this.method_3("ILCount", "int", "The number of IL Instructions in this Method"));
				list.Add(this.method_3("Cyclomatic", "int", "The Cyclomatic Complexity (CC) of this Method. CC is the number of individual paths through a method. In C# it is the count the following tokens if, &&, ||, for, foreach, case, default, continue, while, goto, catch, ??, and a ternary expression"));
				list.Add(this.method_3("ILCyclomatic", "int", "The cyclomatic complexity of the IL for a method is the count of the distinct offset targets in a branch/jump instruction"));
				list.Add(this.method_3("ParameterCount", "int", "The number of parameters on this Method"));
				list.Add(this.method_3("OverloadCount", "int", "The number of overloads for this Method (same method name on the same class but with a different set of parameters)"));
				list.Add(this.method_3("IsPublic", "bool", "Whether or not this Method is marked Public"));
				list.Add(this.method_3("IsInternal", "bool", "Whether or not this Method is marked Internal (only visible from the same assembly)"));
				list.Add(this.method_3("IsProtected", "bool", "Whether or not this Method is marked Protected"));
				list.Add(this.method_3("IsProtectedOrInternal", "bool", "Whether or not this Type is marked Protected or Internal (visible only to derived classes or classes in the same assembly)"));
				list.Add(this.method_3("IsProtectedAndInternal", "bool", "Whether or not this Type is marked Protected and Internal (visible only to derived classes from the same assembly)"));
				list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Method is marked Private"));
				list.Add(this.method_3("IsConstructor", "bool", "Whether or not this Method is a Constructor"));
				list.Add(this.method_3("IsPropertyGetter", "bool", "Whether or not this Method is a Property Getter"));
				list.Add(this.method_3("IsPropertySetter", "bool", "Whether or not this Method is a Property Setter"));
				list.Add(this.method_3("IsStatic", "bool", "Whether or not this Method is marked Static"));
				list.Add(this.method_3("IsVirtual", "bool", "Whether or not this Method is marked Virtual"));
				list.Add(this.method_3("UsesBoxing", "bool", "Whether or not this Method uses Boxing"));
				list.Add(this.method_3("UsesUnboxing", "bool", "Whether or not this Method uses Unboxing"));
				list.Add(this.method_3("IsGeneric", "bool", "Whether or not this Method is has generic parameters"));
				list.Add(this.method_3("IsOperator", "bool", "Whether or not this Method is an Operator"));
				list.Add(this.method_3("IsIndexGetter", "bool", "Whether or not this Method is an Index Getter (ie this[int index])"));
				list.Add(this.method_3("IsIndexSetter", "bool", "Whether or not this Method is an Index Setter (ie this[int index])"));
				list.Add(this.method_3("IsEventAdder", "bool", "Whether or not this Method is an Event Adder"));
				list.Add(this.method_3("IsEventRemover", "bool", "Whether or not this Method is an Index Remover"));
				list.Add(this.method_3("IsStaticConstructor", "bool", "Whether or not this Method is a Static Constructor"));
				list.Add(this.method_3("PercentComment", "double", "The percent of lines in this Method that are comments (100 * CommentLineCount / PhysicalLineCount)"));
				list.Add(this.method_3("Calls", "MethodCollection", "Methods that this Method Calls"));
				list.Add(this.method_3("CalledBy", "MethodCollection", "Methods that call this Method"));
				list.Add(this.method_3("FieldSets", "FieldCollection", "Fields that this Method Sets"));
				list.Add(this.method_3("FieldGets", "FieldCollection", "Fields that this Method Gets (reads from)"));
			}
			else if (text.Contains("event") || text == "e" || text == "ev")
			{
				list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Event is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
				list.Add(this.method_3("Type", "IType", "The Type that Declares this Event"));
				list.Add(this.method_3("Name", "string", "The Name of this Event"));
				list.Add(this.method_3("FullName", "string", "The Full Name of this Event"));
				list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this Event depends on"));
				list.Add(this.method_3("EventType", "IType", "The Type of this Event"));
				list.Add(this.method_3("EventId", "int", "The Nitriq Unique Id for this Event. You must select this in a query in order for the Treemap and other visualizations to work properly"));
				list.Add(this.method_3("IsPublic", "bool", "Whether or not this Event is marked Public"));
				list.Add(this.method_3("IsInternal", "bool", "Whether or not this Event is marked Internal"));
				list.Add(this.method_3("IsProtected", "bool", "Whether or not this Event is marked Protected"));
				list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Event is marked Private"));
				list.Add(this.method_3("IsStatic", "bool", "Whether or not this Event is marked Static"));
			}
			else if (text.Contains("field") || text == "f")
			{
				list.Add(this.method_3("IsInCoreAssembly", "bool", "Returns whether or not this Field is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing."));
				list.Add(this.method_3("Type", "IType", "The Type that Declares this Field"));
				list.Add(this.method_3("Name", "string", "The Name of this Field"));
				list.Add(this.method_3("FullName", "string", "The Full Name of this Field"));
				list.Add(this.method_3("TypesUsed", "TypeCollection", "A Collection of Types that this Field depends on"));
				list.Add(this.method_3("FieldId", "int", "The Nitriq Unique Id for this Field. You must select this in a query in order for the Treemap and other visualizations to work properly"));
				list.Add(this.method_3("FieldType", "IType", "The Type of this Field"));
				list.Add(this.method_3("SetByMethods", "MethodCollection", "A Collection of Methods that assign values to this Field"));
				list.Add(this.method_3("GotByMethods", "MethodCollection", "A Collection of Methods that retrieve values from this Field"));
				list.Add(this.method_3("IsPublic", "bool", "Whether or not this Field is marked Public"));
				list.Add(this.method_3("IsInternal", "bool", "Whether or not this Field is marked Internal"));
				list.Add(this.method_3("IsProtected", "bool", "Whether or not this Field is marked Protected"));
				list.Add(this.method_3("IsProtectedOrInternal", "bool", "Whether or not this Field is marked Protected or Internal"));
				list.Add(this.method_3("IsProtectedAndInternal", "bool", "Whether or not this Field is marked Protected and Internal"));
				list.Add(this.method_3("IsPrivate", "bool", "Whether or not this Field is marked Private"));
				list.Add(this.method_3("IsStatic", "bool", "Whether or not this Field is marked Static"));
				list.Add(this.method_3("IsConstant", "bool", "Whether or not this Field is marked const"));
			}
			else if (text.Contains("assembly") || text.Contains("assem") || text == "a")
			{
				list.Add(this.method_3("AssemblyId", "int", "The Nitriq Unique Id given to this Assembly. You must select this in a query in order for the Treemap and other visualizations to work properly."));
				list.Add(this.method_3("Version", "string", "The Version of this Assembly"));
				list.Add(this.method_3("Namespaces", "NamespaceCollection", "The INamespace array of Namespaces in this Assembly"));
				list.Add(this.method_3("Name", "string", "The name of this Assembly"));
				list.Add(this.method_3("IsCoreAssembly", "bool", "Returns whether or not this Assembly is a Core Assembly. Core Assemblies are the assemblies you are primarily concerned with analyzing - typically excludes Microsoft and 3rd Party Assemblies."));
			}
			else if (text.Contains("namespace") || text == "n" || text == "ns")
			{
				list.Add(this.method_3("FullName", "string", "The FullName of this Namespace"));
				list.Add(this.method_3("Types", "TypeCollection", "A Collection of Types that are contained in this Namespace"));
				list.Add(this.method_3("NamespaceId", "int", "The Nitriq Unique Id given to this Namespace. You must select this in a query in order for the Treemap and other visualizations to work properly."));
			}
			List<CompletionItem> arg_D81_0 = list;
			if (NitriqEditor.comparison_0 == null)
			{
				NitriqEditor.comparison_0 = new Comparison<CompletionItem>(NitriqEditor.smethod_2);
			}
			arg_D81_0.Sort(NitriqEditor.comparison_0);
			foreach (CompletionItem current in list)
			{
				completionSession.Items.Add(current);
			}
			completionSession.Open(this.nitriqSyntaxEditor_0.ActiveView);
		}
        /// <summary>
        /// This method parses the current line, and determines which suggestions to show for code completion (intellisense)
        /// </summary>
        /// <param name="session"></param>
        private void UpdateCodeComplete(CompletionSession session)
        {
            //parse current line
            //set results
            //set filter
            try
            {
                ParseQueueProcessor.ShowProgressDialog = false; //maybe not actually required anymore

                var currentLine = VisualStudio.GetCurrentLine();

                var currentIndex = VisualStudio.GetCursorPositionInLine();

                var lineParser = new FortranStatementParser();

                var beginOfStatement = 0;

                var statement     = lineParser.FindEffectiveStatementAtOffset(currentLine, currentIndex, out beginOfStatement);
                var fullStatement = currentLine.Substring(beginOfStatement, currentIndex - beginOfStatement);

                var currentMember = GetCurrent <IMember>();

                ShowMethodSignatureAsToolTip(session, currentMember, currentLine, currentIndex);

                IList <INameable> codeCompleteOptions;
                var filter = "";
                var addLanguageKeywords = false;
                var codeElementsInScope =
                    FortranSyntaxTreeModel.GetElementsAvailableInScope(SyntaxTreeMaintainer.GetSyntaxTrees(),
                                                                       currentMember);

                // are we in a 'call something' statement?
                var callMatch = callRegex.Match(statement);
                if (callMatch.Success)
                {
                    //only subroutines
                    codeCompleteOptions          = codeElementsInScope.OfType <Subroutine>().Cast <INameable>().ToList(); //subroutines only
                    session.InsertionIndexInLine = beginOfStatement + callMatch.Groups[1].Index;
                    filter = callMatch.Groups[1].Value;
                }
                else if (!statement.Contains('%')) //local scope
                {
                    if (statement.Length > 0 &&
                        FortranParseHelper.IsWhiteSpace(statement[statement.Length - 1]))
                    {
                        //reset: wrong statement:
                        beginOfStatement += statement.Length;
                        statement         = "";
                    }

                    codeCompleteOptions          = codeElementsInScope.Where(ce => !(ce is Subroutine)).ToList(); //subroutines only available after a 'call'
                    session.InsertionIndexInLine = beginOfStatement;
                    filter = statement;
                    addLanguageKeywords = true;
                }
                else // nested in type, eg: channel % sourceNode % id
                {
                    var elements = FortranParseHelper.SplitElementsInStatement(statement, fullStatement, ref beginOfStatement, out filter);

                    if (elements.Count < 1)
                    {
                        throw new NotSupportedException("help!");
                    }

                    var variableName = elements[0];

                    var matchingVariable = codeElementsInScope
                                           .OfType <Variable>()
                                           .FirstOrDefault(lv => String.Equals(lv.Name, variableName, StringComparison.InvariantCultureIgnoreCase));

                    var typeOfVariable = matchingVariable.TypeString;

                    var currentType = codeElementsInScope
                                      .OfType <Type>()
                                      .FirstOrDefault(tp => String.Equals(tp.Name, typeOfVariable, StringComparison.InvariantCultureIgnoreCase));

                    for (int i = 1; i < elements.Count; i++)
                    {
                        if (currentType == null)
                        {
                            break;
                        }

                        var propertyName = elements[i];
                        var property     = GetElementsOfType(currentType).FirstOrDefault(vf => String.Equals(vf.Name, propertyName, StringComparison.InvariantCultureIgnoreCase));

                        typeOfVariable = property.TypeString;

                        currentType = codeElementsInScope
                                      .OfType <Type>()
                                      .FirstOrDefault(tp => String.Equals(tp.Name, typeOfVariable, StringComparison.InvariantCultureIgnoreCase));
                    }

                    if (currentType == null)
                    {
                        codeCompleteOptions = new INameable[] { }
                    }
                    ;
                    else
                    {
                        codeCompleteOptions = GetElementsOfType(currentType).Cast <INameable>().ToList();
                    }

                    session.InsertionIndexInLine = beginOfStatement;
                }

                // gather all results
                var completionItems = codeCompleteOptions.Select(e => new CompletionItem(e.Name, FortranIconProvider.GetIconForMember(e))
                {
                    ToolTip = GetTooltipForMember(currentMember, e)
                }).ToList();
                if (addLanguageKeywords)
                {
                    foreach (var keyword in fortranKeywords)
                    {
                        completionItems.Add(new CompletionItem(keyword, null));
                    }

                    foreach (var intrinsic in fortranIntrinsics)
                    {
                        completionItems.Add(new CompletionItem(intrinsic.Key, IntrinsicIcon)
                        {
                            ToolTip = intrinsic.Value
                        });
                    }
                }
                session.SetCompletionSet(completionItems, filter);
            }
            catch (Exception e)
            {
                Log.Error("Error while updating code complete", e);
            }
            finally
            {
                ParseQueueProcessor.ShowProgressDialog = true; //messes with intellisense popup
            }
        }
 internal void OnCodeCompleteUpdating(CompletionSession session)
 {
     UpdateCodeComplete(session);
 }
 internal void OnCodeCompleteActivating(CompletionSession session)
 {
     session.Coordinate = VisualStudio.GetCaretPositionInScreenCoordinates();
     UpdateCodeComplete(session);
 }
예제 #41
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        // PUBLIC PROCEDURES
        /////////////////////////////////////////////////////////////////////////////////////////////////////

        /// <summary>
        /// Requests that an <see cref="ICompletionSession"/> be opened for the specified <see cref="IEditorView"/>.
        /// </summary>
        /// <param name="view">The <see cref="IEditorView"/> that will host the session.</param>
        /// <param name="canCommitWithoutPopup">Whether the session can immediately commit if a single match is made when the session is opened, commonly known as "complete word" functionality.</param>
        /// <returns>
        /// <c>true</c> if a session was opened; otherwise, <c>false</c>.
        /// </returns>
        public override bool RequestSession(IEditorView view, bool canCommitWithoutPopup)
        {
            // Get the context factory service
            SimpleContextFactory contextFactory = view.SyntaxEditor.Document.Language.GetService <SimpleContextFactory>();

            if (contextFactory != null)
            {
                // Get a context
                SimpleContext context = contextFactory.CreateContext(view.Selection.EndSnapshotOffset, false);

                // Create a session
                CompletionSession session = new CompletionSession();
                session.CanCommitWithoutPopup = canCommitWithoutPopup;

                switch (context.Type)
                {
                case SimpleContextType.Default:
                    // Add items for keywords
                    session.Items.Add(new CompletionItem("function", new CommonImageSourceProvider(CommonImageKind.Keyword),
                                                         new PlainTextContentProvider("Declares a function.")));
                    break;

                case SimpleContextType.FunctionDeclarationBlock:
                case SimpleContextType.FunctionReference: {
                    // Add items for keywords
                    session.Items.Add(new CompletionItem("var", new CommonImageSourceProvider(CommonImageKind.Keyword),
                                                         new PlainTextContentProvider("Declares a variable.")));
                    session.Items.Add(new CompletionItem("return", new CommonImageSourceProvider(CommonImageKind.Keyword),
                                                         new PlainTextContentProvider("Returns a value.")));

                    // Add items (one for each function name)
                    ILLParseData parseData = view.SyntaxEditor.Document.ParseData as ILLParseData;
                    if (parseData != null)
                    {
                        CompilationUnit compilationUnit = parseData.Ast as CompilationUnit;
                        if ((compilationUnit != null) && (compilationUnit.HasMembers))
                        {
                            // Loop through the AST nodes
                            foreach (FunctionDeclaration functionAstNode in compilationUnit.Members)
                            {
                                session.Items.Add(new CompletionItem(functionAstNode.Name, new CommonImageSourceProvider(CommonImageKind.MethodPublic),
                                                                     new FunctionContentProvider(view.HighlightingStyleRegistry, functionAstNode, false, view.DefaultBackgroundColor)));
                            }
                        }
                    }
                    break;
                }
                }

                if (session.Items.Count > 0)
                {
                    // Ensure the caret is visible
                    view.Scroller.ScrollToCaret();

                    // Ensure the items are sorted and open the session
                    session.SortItems();
                    session.Open(view);
                    return(true);
                }
            }
            return(false);
        }
 protected abstract void AddItemsToSession(CompletionSession session);