Пример #1
0
        /// <summary>
        /// Matches the completion string with classes and
        /// global methods and properties loaded in the session
        /// </summary>
        /// <param name="stringToComplete"> current string being typed which is to be completed </param>
        /// <param name="guid"> code block node guid to identify current node being typed </param>
        /// <returns> list of classes, global methods and properties that match with string being completed </returns>
        internal IEnumerable <CompletionData> SearchCompletions(string stringToComplete, Guid guid)
        {
            List <CompletionData> completions = new List <CompletionData>();

            // Add matching DS keywords
            completions.AddRange(KeywordList.Where(x => x.ToLower().Contains(stringToComplete.ToLower())).
                                 Select(x => new CompletionData(x, CompletionData.CompletionType.Keyword)));

            // Add matching Classes
            var groups = StaticMirror.GetClasses(core).
                         Where(x => x.Alias.ToLower().Contains(stringToComplete.ToLower())).
                         GroupBy(x => x.Alias);

            // For those class names that have collisions, list their fully qualified names in completion window
            foreach (var group in groups)
            {
                if (group.Count() > 1)
                {
                    completions.AddRange(group.
                                         Where(x => !x.IsHiddenInLibrary).
                                         Select(x => CompletionData.ConvertMirrorToCompletionData(x, useFullyQualifiedName: true)));
                }
                else
                {
                    completions.AddRange(group.
                                         Where(x => !x.IsHiddenInLibrary).
                                         Select(x => CompletionData.ConvertMirrorToCompletionData(x)));
                }
            }

            // Add matching builtin methods
            completions.AddRange(StaticMirror.GetBuiltInMethods(core).
                                 GroupBy(x => x.Name).Select(y => y.First()).
                                 Where(x => x.MethodName.ToLower().Contains(stringToComplete.ToLower())).
                                 Select(x => CompletionData.ConvertMirrorToCompletionData(x)));

            return(completions);
        }
Пример #2
0
 /// <summary>
 /// Returns the list of names of classes loaded in the Core
 /// </summary>
 /// <returns> list of class names </returns>
 internal IEnumerable <string> GetClasses()
 {
     return(StaticMirror.GetClasses(core).Select(x => x.Alias));
 }