Ejemplo n.º 1
0
        protected virtual bool DoesCompletionMatchApplicabilityTextDirect(Completion completion, string filterText, CompletionMatchType matchType, bool caseSensitive)
        {
            string displayText = string.Empty;
            if (matchType == CompletionMatchType.MatchDisplayText)
            {
                displayText = completion.DisplayText;
            }
            else if (matchType == CompletionMatchType.MatchInsertionText)
            {
                displayText = completion.InsertionText;
            }

            if (PrefixMatch)
            {
                return displayText.StartsWith(filterText, !caseSensitive, CultureInfo.CurrentCulture);
            }

            StringComparison comparison = caseSensitive
                                              ? StringComparison.CurrentCulture
                                              : StringComparison.CurrentCultureIgnoreCase;

            if (string.IsNullOrWhiteSpace(filterText))
                return false;

            var words = filterText.Split(new[] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries);
            if (words.Length < 1)
                return false; // empty

            return words.All(word => WordPrefixContains(displayText, word, comparison)); // all words should match
        }
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (!session.Properties.ContainsProperty(BufferProperties.SessionOriginIntellisense) || !session.TextView.TextBuffer.Properties.ContainsProperty(typeof(IList<CompletionResult>)))
            {
                return;
            }

            var textBuffer = session.TextView.TextBuffer;

            var trackingSpan = (ITrackingSpan)textBuffer.Properties.GetProperty(BufferProperties.LastWordReplacementSpan);
            var list = (IList<CompletionResult>)textBuffer.Properties.GetProperty(typeof(IList<CompletionResult>));
            var currentSnapshot = textBuffer.CurrentSnapshot;
            var filterSpan = currentSnapshot.CreateTrackingSpan(trackingSpan.GetEndPoint(currentSnapshot).Position, 0, SpanTrackingMode.EdgeInclusive);
            var lineStartToApplicableTo = (ITrackingSpan)textBuffer.Properties.GetProperty(BufferProperties.LineUpToReplacementSpan);

            Log.DebugFormat("TrackingSpan: {0}", trackingSpan.GetText(currentSnapshot));
            Log.DebugFormat("FilterSpan: {0}", filterSpan.GetText(currentSnapshot));

            var compList = new List<Completion>();
            foreach (var match in list)
            {
                var glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupUnknown, StandardGlyphItem.GlyphItemPublic);
                switch (match.ResultType)
                {
                    case CompletionResultType.ParameterName:
                        glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                        break;
                    case CompletionResultType.Command:
                        glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
                        break;
                    case CompletionResultType.Type:
                        glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupClass, StandardGlyphItem.GlyphItemPublic);
                        break;
                    case CompletionResultType.Property:
                        glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic);
                        break;
                    case CompletionResultType.Method:
                        glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic);
                        break;
                    case CompletionResultType.Variable:
                        glyph = _glyphs.GetGlyph(StandardGlyphGroup.GlyphGroupField, StandardGlyphItem.GlyphItemPublic);
                        break;
                    case  CompletionResultType.ProviderContainer:
                    case  CompletionResultType.ProviderItem:
                        glyph = _glyphs.GetGlyph(match.ResultType == CompletionResultType.ProviderContainer ? StandardGlyphGroup.GlyphOpenFolder : StandardGlyphGroup.GlyphLibrary, StandardGlyphItem.GlyphItemPublic);
                        break;
                }

                var completion = new Completion();
                completion.Description = match.ToolTip;
                completion.DisplayText = match.ListItemText;
                completion.InsertionText = match.CompletionText;
                completion.IconSource = glyph;
                completion.IconAutomationText = completion.Description;

                compList.Add(completion);
            }

            completionSets.Add(new PowerShellCompletionSet(string.Empty, string.Empty, trackingSpan, compList, null, filterSpan, lineStartToApplicableTo));
        }
		public FrameworkElement Create(CompletionSet completionSet, Completion completion, CompletionClassifierKind kind, bool colorize) {
			if (completionSet == null)
				throw new ArgumentNullException(nameof(completionSet));
			if (completion == null)
				throw new ArgumentNullException(nameof(completion));
			Debug.Assert(completionSet.Completions.Contains(completion));

			CompletionClassifierContext context;
			string defaultContentType;
			switch (kind) {
			case CompletionClassifierKind.DisplayText:
				var inputText = completionSet.ApplicableTo.GetText(completionSet.ApplicableTo.TextBuffer.CurrentSnapshot);
				context = new CompletionDisplayTextClassifierContext(completionSet, completion, completion.DisplayText, inputText, colorize);
				defaultContentType = ContentTypes.CompletionDisplayText;
				break;

			case CompletionClassifierKind.Suffix:
				var suffix = (completion as Completion4)?.Suffix ?? string.Empty;
				context = new CompletionSuffixClassifierContext(completionSet, completion, suffix, colorize);
				defaultContentType = ContentTypes.CompletionSuffix;
				break;

			default:
				throw new ArgumentOutOfRangeException(nameof(kind));
			}

			var contentType = (completionSet as ICompletionSetContentTypeProvider)?.GetContentType(contentTypeRegistryService, kind);
			if (contentType == null)
				contentType = contentTypeRegistryService.GetContentType(defaultContentType);
			var classifier = GetTextClassifier(contentType);
			return TextBlockFactory.Create(context.Text, classificationFormatMap.DefaultTextProperties,
				classifier.GetTags(context).Select(a => new TextRunPropertiesAndSpan(a.Span, classificationFormatMap.GetTextProperties(a.ClassificationType))), TextBlockFactory.Flags.DisableSetTextBlockFontFamily | TextBlockFactory.Flags.DisableFontSize);
		}
Ejemplo n.º 4
0
        public static void GetMethods(string text, ref List<Completion> completions)
        {
            text = remove_comments(text);
            text = remove_linebreaks(text);
            string function;
            int index = 0;
            int debug_Length = text.Length;
            bool already_found = false;

            while (index < text.Length)
            {
                already_found = false;
                if ((function = pull_top_level_function(text, ref index)) != null)
                {

                    //change 3/28/ lol object comparason without a compartor WHOOPS
                    foreach (Completion e in completions)
                    {
                        if (e.DisplayText == function)
                        {
                            already_found = true;
                            break;
                        }
                    }
                    if (!already_found)
                    {
                        Completion c = new Completion(function);
                        c.Description = "User defined Function";
                        //c.IconSource = Microsoft.VisualStudio.Language.Intellisense.IGlyphService.GetGlyph(StandardGlyphGroup.GlyphGroupMethod, StandardGlyphItem.GlyphItemPublic)
                        completions.Add(c);
                        already_found = false;
                    }
                }
            }
        }
Ejemplo n.º 5
0
 internal void Select(Completion completion)
 {
     this.listViewCompletions.SelectedItem = completion;
     if (completion != null)
     {
         this.listViewCompletions.ScrollIntoView(completion);
     }
 }
		/// <summary>
		/// Constructor
		/// </summary>
		/// <param name="completionSet">Completion set</param>
		/// <param name="completion">Completion to classify</param>
		/// <param name="text">Text to classify</param>
		/// <param name="colorize">true if it should be colorized</param>
		protected CompletionClassifierContext(CompletionSet completionSet, Completion completion, string text, bool colorize)
			: base(text, string.Empty, colorize) {
			if (completionSet == null)
				throw new ArgumentNullException(nameof(completionSet));
			if (completion == null)
				throw new ArgumentNullException(nameof(completion));
			CompletionSet = completionSet;
			Completion = completion;
		}
Ejemplo n.º 7
0
		public CompletionVM(Completion completion, IImageMonikerService imageMonikerService) {
			if (completion == null)
				throw new ArgumentNullException(nameof(completion));
			if (imageMonikerService == null)
				throw new ArgumentNullException(nameof(imageMonikerService));
			Completion = completion;
			Completion.Properties.AddProperty(typeof(CompletionVM), this);
			ImageUIObject = CreateImageUIObject(completion, imageMonikerService);
			this.imageMonikerService = imageMonikerService;
		}
Ejemplo n.º 8
0
		public bool IsMatch(Completion completion) {
			var completionText = completion.TryGetFilterText();
			if (completionText == null)
				return false;

			if (completionText.IndexOf(searchText, stringComparison) >= 0)
				return true;
			if (acronymMatchIndexes != null && TryUpdateAcronymIndexes(completionText))
				return true;

			return false;
		}
Ejemplo n.º 9
0
        protected override bool DoesCompletionMatchApplicabilityText(Completion completion, string filterText, CompletionMatchType matchType, bool caseSensitive)
        {
            if (base.DoesCompletionMatchApplicabilityText(completion, filterText, matchType, caseSensitive))
                return true;

            object parentObject;
            completion.Properties.TryGetProperty("parentObject", out parentObject);
            IStepSuggestionGroup<Completion> parentObjectAsGroup = parentObject as IStepSuggestionGroup<Completion>;
            return 
                parentObjectAsGroup != null && 
                parentObjectAsGroup.Suggestions
                    .Any(stepSuggestion => stepSuggestion.NativeSuggestionItem != null && DoesCompletionMatchApplicabilityText(stepSuggestion.NativeSuggestionItem, filterText, matchType, caseSensitive));
        }
        protected override bool DoesCompletionMatchApplicabilityText(Completion completion)
        {
            if (base.DoesCompletionMatchApplicabilityText(completion))
                return true;

            object parentObject = null;
            completion.Properties.TryGetProperty<object>("parentObject", out parentObject);
            IStepSuggestionGroup<Completion> parentObjectAsGroup = parentObject as IStepSuggestionGroup<Completion>;
            return 
                parentObjectAsGroup != null && 
                parentObjectAsGroup.Suggestions
                    .Any(stepSuggestion => stepSuggestion.NativeSuggestionItem != null && DoesCompletionMatchApplicabilityText(stepSuggestion.NativeSuggestionItem));
        }
Ejemplo n.º 11
0
 protected virtual bool DoesCompletionMatchApplicabilityText(Completion completion)
 {
     string displayText = string.Empty;
     if (this._filterMatchType == CompletionMatchType.MatchDisplayText)
     {
         displayText = completion.DisplayText;
     }
     else if (this._filterMatchType == CompletionMatchType.MatchInsertionText)
     {
         displayText = completion.InsertionText;
     }
     return displayText.StartsWith(this._filterBufferText, !this._filterCaseSensitive, CultureInfo.CurrentCulture);
 }
Ejemplo n.º 12
0
		static object CreateImageUIObject(Completion completion, IImageMonikerService imageMonikerService) {
			var c3 = completion as Completion3;
			if (c3 == null) {
				var iconSource = completion.IconSource;
				if (iconSource == null)
					return null;
				return new Image {
					Width = 16,
					Height = 16,
					Source = iconSource,
				};
			}

			var imageReference = imageMonikerService.ToImageReference(c3.IconMoniker);
			if (imageReference.IsDefault)
				return null;
			return new DsImage { ImageReference = imageReference };
		}
Ejemplo n.º 13
0
        public static void Main(string[] args)
        {
            string host = "esqa.moneris.com";
            string store_id = "store5";
            string api_token = "yesguy";
            string order_id = "Need_Unique_Order_ID_7cccxxc7_isssssos";
            string amount = "1.00";
            string txn_number = "12429-222-0";
            string crypt = "7";

            Completion completion = new Completion(order_id, amount, txn_number, crypt);

            //completion.SetDynamicDescriptor("123456");

            HttpsPostRequest mpgReq = new HttpsPostRequest(host, store_id, api_token, completion);

            try
            {
                Receipt receipt = mpgReq.GetReceipt();

                Console.WriteLine("CardType = " + receipt.GetCardType());
                Console.WriteLine("TransAmount = " + receipt.GetTransAmount());
                Console.WriteLine("TxnNumber = " + receipt.GetTxnNumber());
                Console.WriteLine("ReceiptId = " + receipt.GetReceiptId());
                Console.WriteLine("TransType = " + receipt.GetTransType());
                Console.WriteLine("ReferenceNum = " + receipt.GetReferenceNum());
                Console.WriteLine("ResponseCode = " + receipt.GetResponseCode());
                Console.WriteLine("ISO = " + receipt.GetISO());
                Console.WriteLine("BankTotals = " + receipt.GetBankTotals());
                Console.WriteLine("Message = " + receipt.GetMessage());
                Console.WriteLine("AuthCode = " + receipt.GetAuthCode());
                Console.WriteLine("Complete = " + receipt.GetComplete());
                Console.WriteLine("TransDate = " + receipt.GetTransDate());
                Console.WriteLine("TransTime = " + receipt.GetTransTime());
                Console.WriteLine("Ticket = " + receipt.GetTicket());
                Console.WriteLine("TimedOut = " + receipt.GetTimedOut());
                Console.WriteLine("IsVisaDebit = " + receipt.GetIsVisaDebit());

            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 14
0
 private static Completion CreateCompletion(ITextSnapshot snapshot, IGrouping<string, Protocol.Response.AutocompleteResponse.Completion> i)
 {
     var ret = new Completion(i.Key, i.First().completionText, GetDescription(i), GetImageSource(i.First()), null);
     ret.Properties.AddProperty(typeof(ITrackingSpan), GetReplacementSpanFromCompletions(snapshot, i.First()));
     return ret;
 }
Ejemplo n.º 15
0
        //
        // Triggers the completion engine, if insertBestMatch is true, then this will
        // insert the best match found, this behaves like the shell "tab" which will
        // complete as much as possible given the options.
        //
        void Complete()
        {
            Completion completion = AutoCompleteEvent(text.ToString(), cursor);

            string [] completions = completion.Result;
            if (completions == null)
            {
                HideCompletions();
                return;
            }

            int ncompletions = completions.Length;

            if (ncompletions == 0)
            {
                HideCompletions();
                return;
            }

            if (completions.Length == 1)
            {
                InsertTextAtCursor(completions [0]);
                HideCompletions();
            }
            else
            {
                int last = -1;

                for (int p = 0; p < completions [0].Length; p++)
                {
                    char c = completions [0][p];


                    for (int i = 1; i < ncompletions; i++)
                    {
                        if (completions [i].Length < p)
                        {
                            goto mismatch;
                        }

                        if (completions [i][p] != c)
                        {
                            goto mismatch;
                        }
                    }
                    last = p;
                }
mismatch:
                var prefix = completion.Prefix;
                if (last != -1)
                {
                    InsertTextAtCursor(completions [0].Substring(0, last + 1));

                    // Adjust the completions to skip the common prefix
                    prefix += completions [0].Substring(0, last + 1);
                    for (int i = 0; i < completions.Length; i++)
                    {
                        completions [i] = completions [i].Substring(last + 1);
                    }
                }
                ShowCompletions(prefix, completions);
                Render();
                ForceCursor(cursor);
            }
        }
 public ServerStreamingMethodCall(Func <ValueTask <IOutcomingInvocation <TRequest, TResponse> > > invocationFactory)
 {
     _invocationFactory = invocationFactory;
     Completion.LogCompletion(Log);
     _responseStream.PropagateCompletionFrom(Completion);
 }
Ejemplo n.º 17
0
        public override async ValueTask <Completion> WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
        {
            IEnumerable <FluidValue> elements = Array.Empty <FluidValue>();

            if (Member != null)
            {
                var member = await Member.EvaluateAsync(context);

                elements = member.Enumerate();
            }
            else if (Range != null)
            {
                int start = Convert.ToInt32((await Range.From.EvaluateAsync(context)).ToNumberValue());
                int end   = Convert.ToInt32((await Range.To.EvaluateAsync(context)).ToNumberValue());

                // Cache range
                if (_rangeElements == null || _rangeStart != start || _rangeEnd != end)
                {
                    _rangeElements = new List <FluidValue>();

                    for (var i = start; i <= end; i++)
                    {
                        _rangeElements.Add(NumberValue.Create(i));
                    }

                    elements    = _rangeElements;
                    _rangeStart = start;
                    _rangeEnd   = end;
                }
                else
                {
                    elements = _rangeElements;
                }
            }

            if (!elements.Any())
            {
                return(Completion.Normal);
            }

            // Apply options

            if (Offset != null)
            {
                var offset = (int)(await Offset.EvaluateAsync(context)).ToNumberValue();
                elements = elements.Skip(offset);
            }

            if (Limit != null)
            {
                var limit = (int)(await Limit.EvaluateAsync(context)).ToNumberValue();
                elements = elements.Take(limit);
            }

            if (Reversed)
            {
                elements = elements.Reverse();
            }

            var list = elements.ToList();

            if (!list.Any())
            {
                return(Completion.Normal);
            }

            try
            {
                var forloop = new ForLoopValue();

                var length = forloop.Length = list.Count;

                context.SetValue("forloop", forloop);

                for (var i = 0; i < length; i++)
                {
                    context.IncrementSteps();

                    var item = list[i];

                    context.SetValue(Identifier, item);

                    // Set helper variables
                    forloop.Index   = i + 1;
                    forloop.Index0  = i;
                    forloop.RIndex  = length - i - 1;
                    forloop.RIndex0 = length - i;
                    forloop.First   = i == 0;
                    forloop.Last    = i == length - 1;

                    Completion completion = Completion.Normal;

                    for (var index = 0; index < Statements.Count; index++)
                    {
                        var statement = Statements[index];
                        completion = await statement.WriteToAsync(writer, encoder, context);

                        // Restore the forloop property after every statement in case it replaced it,
                        // for instance if it contains a nested for loop
                        context.SetValue("forloop", forloop);

                        if (completion != Completion.Normal)
                        {
                            // Stop processing the block statements
                            break;
                        }
                    }

                    if (completion == Completion.Continue)
                    {
                        // Go to next iteration
                        continue;
                    }

                    if (completion == Completion.Break)
                    {
                        // Leave the loop
                        break;
                    }
                }
            }
            finally
            {
                context.LocalScope.Delete("forloop");
            }

            return(Completion.Normal);
        }
Ejemplo n.º 18
0
        private bool DoesCompletionMatchApplicabilityText(Completion completion)
        {
            if (IsUpper(filterBufferText))
            {
                return GetUpperString(completion.DisplayText).StartsWith(this.filterBufferText);
            }

            return completion.DisplayText.ToLowerInvariant().Contains(this.filterBufferText.ToLowerInvariant());
        }
Ejemplo n.º 19
0
 protected ProcessBase()
 {
     Completion.ContinueWithSynchronously((Action <Task>)DisposeRegistrations).IgnoreAwait();
 }
        ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        #region Constructors

        internal CompletionTooltipCustomization(Completion completion)
        {
            this.Text      = string.Format(CultureInfo.CurrentCulture, "{0}: {1}", completion.DisplayText, completion.Description);
            this.FontSize  = 24;
            this.FontStyle = FontStyles.Italic;
        }
Ejemplo n.º 21
0
 private void AskSequential(IPerfReceiver receiver, Completion<TimeSpan> completion, Stopwatch sw, int messageCount)
 {
     if(messageCount == 0) {
         sw.Stop();
         completion.Complete(sw.Elapsed);
     }
     receiver.Ask("foo").ContinueWith(t => AskSequential(receiver, completion, sw, messageCount - 1));
 }
Ejemplo n.º 22
0
		public void Select(Completion completion) {
			var newMatchPriority = GetMatchPriority(completion);
			if (newMatchPriority < matchPriority) {
				bestCompletion = completion;
				matchPriority = newMatchPriority;
			}
		}
Ejemplo n.º 23
0
        private void ShowCompletion(string enteredText, bool controlSpace)
        {
            if (!controlSpace)
            {
                Debug.WriteLine("Code Completion: TextEntered: " + enteredText);
            }
            else
            {
                Debug.WriteLine("Code Completion: Ctrl+Space");
            }

            //only process csharp files and if there is a code completion engine available
            if (String.IsNullOrEmpty(Document.FileName))
            {
                Debug.WriteLine("No document file name, cannot run code completion");
                return;
            }


            if (Completion == null)
            {
                Debug.WriteLine("Code completion is null, cannot run code completion");
                return;
            }

            var fileExtension = Path.GetExtension(Document.FileName);

            fileExtension = fileExtension != null?fileExtension.ToLower() : null;

            //check file extension to be a c# file (.cs, .csx, etc.)
            if (fileExtension == null || (!fileExtension.StartsWith(".cs")))
            {
                Debug.WriteLine("Wrong file extension, cannot run code completion");
                return;
            }

            if (completionWindow == null)
            {
                CodeCompletionResult results = null;
                try
                {
                    var offset = 0;
                    var doc    = GetCompletionDocument(out offset);
                    results = Completion.GetCompletions(doc, offset, controlSpace);
                }
                catch (Exception exception)
                {
                    Debug.WriteLine("Error in getting completion: " + exception);
                }
                if (results == null)
                {
                    return;
                }

                if (insightWindow == null && results.OverloadProvider != null)
                {
                    insightWindow          = new OverloadInsightWindow(TextArea);
                    insightWindow.Provider = results.OverloadProvider;
                    insightWindow.Show();
                    insightWindow.Closed += (o, args) => insightWindow = null;
                    return;
                }

                if (completionWindow == null && results != null && results.CompletionData.Any())
                {
                    // Open code completion after the user has pressed dot:
                    completionWindow = new CompletionWindow(TextArea);
                    completionWindow.CloseWhenCaretAtBeginning = controlSpace;
                    completionWindow.StartOffset -= results.TriggerWordLength;
                    //completionWindow.EndOffset -= results.TriggerWordLength;

                    IList <ICompletionData> data = completionWindow.CompletionList.CompletionData;
                    foreach (var completion in results.CompletionData.OrderBy(item => item.Text))
                    {
                        data.Add(completion);
                    }
                    if (results.TriggerWordLength > 0)
                    {
                        //completionWindow.CompletionList.IsFiltering = false;
                        completionWindow.CompletionList.SelectItem(results.TriggerWord);
                    }
                    completionWindow.Show();
                    completionWindow.Closed += (o, args) => completionWindow = null;
                }
            }//end if


            //update the insight window
            if (!string.IsNullOrEmpty(enteredText) && insightWindow != null)
            {
                //whenver text is entered update the provider
                var provider = insightWindow.Provider as CSharpOverloadProvider;
                if (provider != null)
                {
                    //since the text has not been added yet we need to tread it as if the char has already been inserted
                    var offset = 0;
                    var doc    = GetCompletionDocument(out offset);
                    provider.Update(doc, offset);
                    //if the windows is requested to be closed we do it here
                    if (provider.RequestClose)
                    {
                        insightWindow.Close();
                        insightWindow = null;
                    }
                }
            }
        }//end method
Ejemplo n.º 24
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="completionSet">Completion set</param>
 /// <param name="completion">Completion to classify</param>
 /// <param name="suffix">Text to classify</param>
 /// <param name="colorize">true if it should be colorized</param>
 public CompletionSuffixClassifierContext(CompletionSet completionSet, Completion completion, string suffix, bool colorize)
     : base(completionSet, completion, suffix, colorize)
 {
 }
Ejemplo n.º 25
0
 public Task CancelAsync()
 {
     _cancellation.Cancel();
     return(Completion.IgnoreExceptions());
 }
Ejemplo n.º 26
0
 public DuplexStreamingMethodCall(Func <ValueTask <IOutcomingInvocation <TRequest, TResponse> > > invocationFactory)
 {
     _invocationFactory = invocationFactory;
     Completion.LogCompletion(Log);
 }
Ejemplo n.º 27
0
		public BestMatchSelector(string searchText) {
			if (searchText == null)
				throw new ArgumentNullException(nameof(searchText));
			this.searchText = searchText;
			matchPriority = MatchPriority.Nothing;
			bestCompletion = null;
			acronymMatchIndexes = AcronymSearchHelpers.TryCreateMatchIndexes(searchText);
		}
Ejemplo n.º 28
0
 public void Complete()
 {
     Completion.Start();
 }
Ejemplo n.º 29
0
 public Task<TimeSpan> TellParallel(int messageCount)
 {
     _tellParallel = true;
     _tellCount = 0;
     _tellExpected = messageCount;
     _tellTimer = Stopwatch.StartNew();
     _tellCompletion = Context.GetCompletion<TimeSpan>();
     var receiver = Context.Create<IPerfReceiver>().Proxy;
     for(var i = 0; i < messageCount; i++) {
         receiver.Tell(Guid.NewGuid(), "foo");
     }
     return _tellCompletion;
 }
Ejemplo n.º 30
0
        private string Resolve()
        {
            string value = null;

            var sheet = this.DataResolver.GetExcelSheet <Completion>();

            Completion row = null;

            try
            {
                // try to get the row in the Completion table itself, because this is 'easiest'
                // The row may not exist at all (if the Key is for another table), or it could be the wrong row
                // (again, if it's meant for another table)
                row = sheet.GetRow(this.key);
            }
            catch { }    // don't care, row will be null

            if (row?.Group == this.group)
            {
                // if the row exists in this table and the group matches, this is actually the correct data
                value = row.Text;
            }
            else
            {
                try
                {
                    // we need to get the linked table and do the lookup there instead
                    // in this case, there will only be one entry for this group id
                    row = sheet.First(r => r.Group == this.group);
                    // many of the names contain valid id ranges after the table name, but we don't need those
                    var actualTableName = row.LookupTable.Split('[')[0];

                    var name = actualTableName switch
                    {
                        "Action" => this.DataResolver.GetExcelSheet <Lumina.Excel.GeneratedSheets.Action>().GetRow(this.key).Name,
                        "ActionComboRoute" => this.DataResolver.GetExcelSheet <ActionComboRoute>().GetRow(this.key).Name,
                        "BuddyAction" => this.DataResolver.GetExcelSheet <BuddyAction>().GetRow(this.key).Name,
                        "ClassJob" => this.DataResolver.GetExcelSheet <ClassJob>().GetRow(this.key).Name,
                        "Companion" => this.DataResolver.GetExcelSheet <Companion>().GetRow(this.key).Singular,
                        "CraftAction" => this.DataResolver.GetExcelSheet <CraftAction>().GetRow(this.key).Name,
                        "GeneralAction" => this.DataResolver.GetExcelSheet <GeneralAction>().GetRow(this.key).Name,
                        "GuardianDeity" => this.DataResolver.GetExcelSheet <GuardianDeity>().GetRow(this.key).Name,
                        "MainCommand" => this.DataResolver.GetExcelSheet <MainCommand>().GetRow(this.key).Name,
                        "Mount" => this.DataResolver.GetExcelSheet <Mount>().GetRow(this.key).Singular,
                        "Pet" => this.DataResolver.GetExcelSheet <Pet>().GetRow(this.key).Name,
                        "PetAction" => this.DataResolver.GetExcelSheet <PetAction>().GetRow(this.key).Name,
                        "PetMirage" => this.DataResolver.GetExcelSheet <PetMirage>().GetRow(this.key).Name,
                        "PlaceName" => this.DataResolver.GetExcelSheet <PlaceName>().GetRow(this.key).Name,
                        "Race" => this.DataResolver.GetExcelSheet <Race>().GetRow(this.key).Masculine,
                        "TextCommand" => this.DataResolver.GetExcelSheet <TextCommand>().GetRow(this.key).Command,
                        "Tribe" => this.DataResolver.GetExcelSheet <Tribe>().GetRow(this.key).Masculine,
                        "Weather" => this.DataResolver.GetExcelSheet <Weather>().GetRow(this.key).Name,
                        _ => throw new Exception(actualTableName)
                    };

                    value = name;
                }
                catch (Exception e)
                {
                    Log.Error(e, $"AutoTranslatePayload - failed to resolve: {this}");
                }
            }

            return(value);
        }
Ejemplo n.º 31
0
		FrameworkElement CreateFrameworkElement(Completion completion, CompletionClassifierKind kind) {
			if (completion == null)
				throw new ArgumentNullException(nameof(completion));
			if (session.IsDismissed)
				return null;
			var completionSet = session.SelectedCompletionSet;
			if (completionSet == null)
				return null;
			Debug.Assert(completionSet.Completions.Contains(completion));
			const bool colorize = true;
			return completionTextElementProvider.Create(completionSet, completion, kind, colorize);
		}
Ejemplo n.º 32
0
 public void Add(Completion item)
 {
     this.listBox.Items.Add(item);
 }
Ejemplo n.º 33
0
 private static bool IsVisible(Completion completion) {
     return ((DynamicallyVisibleCompletion)completion).Visible;
 }
Ejemplo n.º 34
0
        private List <Completion> memberCompletion(ITextSnapshot snapshot, int start, int line, int column)
        {
            List <Completion> memberCompletion = new List <Completion>();
            AstNode           foundNode        = null;

            //Replace '.' with ';' to avoid parse errors
            Span dotSpan = new Span(start, 1);

            snapshot = snapshot.TextBuffer.Delete(dotSpan);

            snapshot = snapshot.TextBuffer.Insert(dotSpan.Start, ";");

            //StaDynParser parser = new StaDynParser(snapshot.TextBuffer, FileUtilities.Instance.getCurrentOpenDocumentFilePath());

            //Parse source
            StaDynSourceFileAST parseResult;// = parser.parseSource();
            StaDynParser        parser = new StaDynParser();

            parser.parseAll();
            parseResult = ProjectFileAST.Instance.getAstFile(FileUtilities.Instance.getCurrentOpenDocumentFilePath());

            //Replace ';' with '.'
            snapshot = snapshot.TextBuffer.Delete(dotSpan);
            snapshot = snapshot.TextBuffer.Insert(dotSpan.Start, ".");

            //parseResult = DecorateAST.Instance.completeDecorateAndUpdate(parseResult);
            if (parseResult == null || parseResult.Ast == null)
            {
                return(memberCompletion);
            }

            char previousChar = snapshot.GetText(start - 1, 1)[0];

            column += 1;
            //Previous node is a MthodCall or Cast
            if (previousChar == ')')
            {
                //Start point is the ')', not the '.', so start-1
                //foundNode = this.getCurrentInvocation(parseResult, snapshot, start - 1, line, column);
                foundNode = StaDynIntellisenseHelper.Instance.getCurrentInvocation(parseResult, snapshot, start - 1, line, column);
                if (!(foundNode is InvocationExpression) && !(foundNode is NewExpression))
                {
                    foundNode = this.getCurrentCast(parseResult, snapshot, start - 1, line, column);
                }
            }
            //Previous node is ArrayAcces
            else if (previousChar == ']')
            {
                foundNode = this.getCurrentArray(parseResult, snapshot, start, line, column);
            }
            else
            {
                //Node search
                //foundNode = (AstNode)parseResult.Ast.Accept(new VisitorFindNode(), new Location(Path.GetFileName(parseResult.FileName), line, column));
                foundNode = (AstNode)parseResult.Ast.Accept(new VisitorFindNode(), new Location(parseResult.FileName, line, column));
            }


            if (foundNode == null)
            {
                return(null);
            }

            TypeExpression type = (TypeExpression)foundNode.AcceptOperation(new GetNodeTypeOperation(), null);

            if (type == null)
            {
                return(null);
            }

            //Get the type members
            //double dispathcer pattern
            AccessModifier[] members = (AccessModifier[])type.AcceptOperation(new GetMembersOperation(), null);

            string displayName, description;
            bool   duplicate = false;

            foreach (AccessModifier member in members)
            {
                duplicate   = false;
                displayName = member.MemberIdentifier;
                description = displayName;

                if (member.Type != null)
                {
                    //description = member.Type.FullName;
                    description = member.Type.AcceptOperation(new GetTypeSystemName(), null) as string;
                    if (String.IsNullOrEmpty(description))
                    {
                        description = displayName;
                    }
                }
                ImageSource image = CompletionGlyph.Instance.getImage(member.Type, this._glyphService);

                //Completion element = new Completion("." + displayName, "." + displayName, description, image, displayName);

                Completion element = new Completion(displayName, "." + displayName, description, image, displayName);

                //Avoid adding duplicate members
                foreach (Completion completion in memberCompletion)
                {
                    if (completion.DisplayText == element.DisplayText)
                    {
                        if (completion.Description != description)
                        {
                            completion.Description += @" \/ " + description;
                        }
                        duplicate = true;
                        break;
                    }
                }
                if (!duplicate)
                {
                    memberCompletion.Add(element);
                }
                //memberCompletion.Add(element);
            }

            //Sort the elements
            memberCompletion.Sort((x, y) => string.Compare(x.DisplayText, y.DisplayText));

            //Remove duplicates
            //List<Completion> unique = new List<Completion>(memberCompletion.Distinct<Completion>(new CompletionComparer()));

            return(memberCompletion);
        }
Ejemplo n.º 35
0
        void CmdTabOrComplete()
        {
            bool complete = false;

            if (AutoCompleteEvent != null)
            {
                if (TabAtStartCompletes)
                {
                    complete = true;
                }
                else
                {
                    for (int i = 0; i < cursor; i++)
                    {
                        if (!Char.IsWhiteSpace(text[i]))
                        {
                            complete = true;
                            break;
                        }
                    }
                }

                if (complete)
                {
                    Completion completion  = AutoCompleteEvent(text.ToString(), cursor);
                    string[]   completions = completion.Result;
                    if (completions == null)
                    {
                        return;
                    }

                    int ncompletions = completions.Length;
                    if (ncompletions == 0)
                    {
                        return;
                    }

                    if (completions.Length == 1)
                    {
                        InsertTextAtCursor(completions[0]);
                    }
                    else
                    {
                        int last = -1;

                        for (int p = 0; p < completions[0].Length; p++)
                        {
                            char c = completions[0][p];


                            for (int i = 1; i < ncompletions; i++)
                            {
                                if (completions[i].Length < p)
                                {
                                    goto mismatch;
                                }

                                if (completions[i][p] != c)
                                {
                                    goto mismatch;
                                }
                            }
                            last = p;
                        }
mismatch:
                        if (last != -1)
                        {
                            InsertTextAtCursor(completions[0].Substring(0, last + 1));
                        }
                        Console.WriteLine();
                        foreach (string s in completions)
                        {
                            Console.Write(completion.Prefix);
                            Console.Write(s);
                            Console.Write(' ');
                        }
                        Console.WriteLine();
                        Render();
                        ForceCursor(cursor);
                    }
                }
                else
                {
                    HandleChar('\t');
                }
            }
            else
            {
                HandleChar('t');
            }
        }
        bool CompleteCompletionSession(char ch)
        {
            if (_completionSession == null)
            {
                return(false);
            }
            bool         commit       = false;
            bool         moveBack     = false;
            Completion   completion   = null;
            XSCompletion xscompletion = null;
            ITextCaret   caret        = null;

            WriteOutputMessage("CompleteCompletionSession()");
            if (_completionSession.SelectedCompletionSet != null)
            {
                bool addDelim = false;

                if (_completionSession.SelectedCompletionSet.SelectionStatus.Completion != null)
                {
                    completion = _completionSession.SelectedCompletionSet.SelectionStatus.Completion;
                }
                xscompletion = completion as XSCompletion;
                Kind kind = Kind.Unknown;
                if (xscompletion != null)
                {
                    kind = xscompletion.Kind;
                }
                bool ctor = false;
                // some tokens need to be added to the insertion text.
                switch (kind)
                {
                case Kind.Keyword:
                    formatKeyword(completion);
                    break;

                case Kind.Class:
                case Kind.Structure:
                case Kind.Constructor:
                    ctor = true;
                    goto default;

                default:
                    switch (ch)
                    {
                    case '{' when ctor:
                    case '}' when ctor:
                        if (!completion.InsertionText.EndsWith("{"))
                        {
                            completion.InsertionText += "{";
                        }
                        break;

                    case '\t':        // Tab
                    case '\r':        // CR
                    case '\n':        // CR
                    case '.':         // DOT
                    case ':':         // COLON
                    case '\0':
                        break;

                    default:
                        var s = ch.ToString();
                        if (!completion.InsertionText.EndsWith(s))
                        {
                            completion.InsertionText += s;
                        }
                        break;
                    }
                    break;
                }
                if ((_completionSession.SelectedCompletionSet.Completions.Count > 0) && (_completionSession.SelectedCompletionSet.SelectionStatus.IsSelected))
                {
                    if (XSettings.EditorCompletionAutoPairs)
                    {
                        caret    = _completionSession.TextView.Caret;
                        addDelim = true;
                        WriteOutputMessage(" --> select " + completion.InsertionText);
                        if (kind == Kind.Constructor)
                        {
                            completion.InsertionText += "{";
                        }
                        else if (kind.HasParameters() && !completion.InsertionText.EndsWith("("))
                        {
                            completion.InsertionText += "(";
                        }
                    }
                    commit = true;
                }
                else
                {
                    if (completion != null)
                    {
                        // Push the completion char into the InsertionText if needed
                        if (!completion.InsertionText.EndsWith(ch.ToString()))
                        {
                            completion.InsertionText += ch;
                        }
                        if (XSettings.EditorCompletionAutoPairs)
                        {
                            caret    = _completionSession.TextView.Caret;
                            addDelim = true;
                        }
                    }
                    commit = true;
                }
                if (addDelim)
                {
                    if (completion.InsertionText.EndsWith("("))
                    {
                        moveBack = true;
                        completion.InsertionText += ")";
                    }
                    else if (completion.InsertionText.EndsWith("{"))
                    {
                        moveBack = true;
                        completion.InsertionText += "}";
                    }
                    else if (completion.InsertionText.EndsWith("["))
                    {
                        moveBack = true;
                        completion.InsertionText += "]";
                    }
                }
            }
            if (commit)
            {
                WriteOutputMessage(" --> Commit");
                var session = _completionSession;
                session.Properties.TryGetProperty(XsCompletionProperties.Type, out IXTypeSymbol type);
                string insertionText = completion.InsertionText;
                session.Properties.TryGetProperty(XsCompletionProperties.Char, out char triggerChar);
                if (ch == '.' || ch == ':')
                {
                    if (insertionText.IndexOfAny("({".ToCharArray()) == -1)
                    {
                        completion.InsertionText += ch;
                    }
                }
                _completionSession.Commit();
                if (moveBack && (caret != null))
                {
                    caret.MoveToPreviousCaretPosition();
                }
                // if a method or constructor was chosen, then trigger the signature help
                if (insertionText.Contains('(') || insertionText.Contains('{'))
                {
                    TriggerSignatureHelp(type, insertionText, triggerChar);
                }
                return(true);
            }

            WriteOutputMessage(" --> Dismiss");
            _completionSession.Dismiss();


            return(false);
        }
Ejemplo n.º 37
0
 void SelectItem(Completion completionItem)
 {
     TheCompletionsCollectionView.MoveCurrentTo(completionItem);
 }
 void formatKeyword(Completion completion)
 {
     completion.InsertionText = XSettings.FormatKeyword(completion.InsertionText);
 }
Ejemplo n.º 39
0
 public Task<Tuple<double, TimeSpan>> Start()
 {
     if(_completion != null) {
         throw new Exception("accumulator already started");
     }
     _t = Stopwatch.StartNew();
     _completion = Context.GetCompletion<Tuple<double, TimeSpan>>();
     return _completion;
 }
Ejemplo n.º 40
0
 private void CommentBuilder(Comment result)
 {
     _asyncCommentResult = result;
     Completion.Set();
 }
Ejemplo n.º 41
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="completionSet">Completion set</param>
 /// <param name="completion">Completion to classify</param>
 /// <param name="text">Text to classify</param>
 /// <param name="colorize">true if it should be colorized</param>
 protected CompletionClassifierContext(CompletionSet completionSet, Completion completion, string text, bool colorize)
     : base(text, string.Empty, colorize)
 {
     CompletionSet = completionSet ?? throw new ArgumentNullException(nameof(completionSet));
     Completion    = completion ?? throw new ArgumentNullException(nameof(completion));
 }
Ejemplo n.º 42
0
        public override async Task <Completion> WriteToAsync(TextWriter writer, TextEncoder encoder, TemplateContext context)
        {
            if (!context.AmbientValues.TryGetValue("Services", out var servicesValue))
            {
                throw new ArgumentException("Services missing while invoking 'helper'");
            }

            var services = servicesValue as IServiceProvider;

            if (!context.AmbientValues.TryGetValue("ViewContext", out var viewContext))
            {
                throw new ArgumentException("ViewContext missing while invoking 'helper'");
            }

            var arguments = (FilterArguments)(await _arguments.EvaluateAsync(context)).ToObjectValue();

            var helper = _helper ?? arguments.At(0).ToStringValue();
            var tagHelperSharedState = services.GetRequiredService <TagHelperSharedState>();

            if (tagHelperSharedState.TagHelperDescriptors == null)
            {
                lock (tagHelperSharedState)
                {
                    if (tagHelperSharedState.TagHelperDescriptors == null)
                    {
                        var razorEngine      = services.GetRequiredService <RazorEngine>();
                        var tagHelperFeature = razorEngine.Features.OfType <ITagHelperFeature>().FirstOrDefault();
                        tagHelperSharedState.TagHelperDescriptors = tagHelperFeature.GetDescriptors().ToList();
                    }
                }
            }

            if (_descriptor == null)
            {
                lock (this)
                {
                    var descriptors = tagHelperSharedState.TagHelperDescriptors
                                      .Where(d => d.TagMatchingRules.Any(rule => ((rule.TagName == "*") ||
                                                                                  rule.TagName == helper) && rule.Attributes.All(attr => arguments.Names.Any(name =>
                    {
                        if (String.Equals(name, attr.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            return(true);
                        }

                        name = name.Replace("_", "-");

                        if (attr.Name.StartsWith(AspPrefix) && String.Equals(name,
                                                                             attr.Name.Substring(AspPrefix.Length), StringComparison.OrdinalIgnoreCase))
                        {
                            return(true);
                        }

                        if (String.Equals(name, attr.Name, StringComparison.OrdinalIgnoreCase))
                        {
                            return(true);
                        }

                        return(false);
                    }))));

                    _descriptor = descriptors.FirstOrDefault();

                    if (_descriptor == null)
                    {
                        return(Completion.Normal);
                    }
                }
            }

            var tagHelperType = Type.GetType(_descriptor.Name + ", " + _descriptor.AssemblyName);

            var _tagHelperActivator = _tagHelperActivators.GetOrAdd(tagHelperType, key =>
            {
                var genericFactory = typeof(ReusableTagHelperFactory <>).MakeGenericType(key);
                var factoryMethod  = genericFactory.GetMethod("CreateTagHelper");

                return(Delegate.CreateDelegate(typeof(Func <ITagHelperFactory, ViewContext, ITagHelper>), factoryMethod) as Func <ITagHelperFactory, ViewContext, ITagHelper>);
            });

            var tagHelperFactory = services.GetRequiredService <ITagHelperFactory>();
            var tagHelper        = _tagHelperActivator(tagHelperFactory, (ViewContext)viewContext);

            var attributes = new TagHelperAttributeList();

            foreach (var name in arguments.Names)
            {
                var propertyName = LiquidViewFilters.LowerKebabToPascalCase(name);

                var found = false;
                foreach (var attribute in _descriptor.BoundAttributes)
                {
                    if (propertyName == attribute.GetPropertyName())
                    {
                        found = true;

                        var setter = _tagHelperSetters.GetOrAdd(attribute.DisplayName, key =>
                        {
                            var propertyInfo   = tagHelperType.GetProperty(propertyName);
                            var propertySetter = propertyInfo.GetSetMethod();

                            var invokeType     = typeof(Action <,>).MakeGenericType(tagHelperType, propertyInfo.PropertyType);
                            var setterDelegate = Delegate.CreateDelegate(invokeType, propertySetter);

                            Action <ITagHelper, FluidValue> result = (h, v) =>
                            {
                                object value = null;

                                if (attribute.IsEnum)
                                {
                                    value = Enum.Parse(propertyInfo.PropertyType, v.ToStringValue());
                                }
                                else if (attribute.IsStringProperty)
                                {
                                    value = v.ToStringValue();
                                }
                                else if (propertyInfo.PropertyType == typeof(Boolean))
                                {
                                    value = Convert.ToBoolean(v.ToStringValue());
                                }
                                else
                                {
                                    value = v.ToObjectValue();
                                }

                                setterDelegate.DynamicInvoke(new[] { h, value });
                            };

                            return(result);
                        });

                        try
                        {
                            setter(tagHelper, arguments[name]);
                        }
                        catch (ArgumentException e)
                        {
                            throw new ArgumentException("Incorrect value type assigned to a tag.", name, e);
                        }

                        break;
                    }
                }

                if (!found)
                {
                    attributes.Add(new TagHelperAttribute(name.Replace("_", "-"), arguments[name].ToObjectValue()));
                }
            }

            var content = new StringWriter();

            if (Statements?.Any() ?? false)
            {
                Completion completion = Completion.Break;
                for (var index = 0; index < Statements.Count; index++)
                {
                    completion = await Statements[index].WriteToAsync(content, encoder, context);

                    if (completion != Completion.Normal)
                    {
                        return(completion);
                    }
                }
            }

            var tagHelperContext = new TagHelperContext(attributes,
                                                        new Dictionary <object, object>(), Guid.NewGuid().ToString("N"));

            var tagHelperOutput = new TagHelperOutput(helper, attributes, (_, e)
                                                      => Task.FromResult(new DefaultTagHelperContent().AppendHtml(content.ToString())));

            tagHelperOutput.Content.AppendHtml(content.ToString());
            await tagHelper.ProcessAsync(tagHelperContext, tagHelperOutput);

            tagHelperOutput.WriteTo(writer, HtmlEncoder.Default);

            return(Completion.Normal);
        }
Ejemplo n.º 43
0
		public static CompletionVM TryGet(Completion completion) {
			if (completion == null)
				return null;
			CompletionVM vm;
			if (completion.Properties.TryGetProperty(typeof(CompletionVM), out vm))
				return vm;
			return null;
		}
Ejemplo n.º 44
0
 public static int CompareOrdinal(Completion completion1, Completion completion2)
 {
     return(Compare(completion1, completion2, StringComparison.Ordinal));
 }
Ejemplo n.º 45
0
		MatchPriority GetMatchPriority(Completion completion) {
			var filterText = completion.TryGetFilterText();
			Debug.Assert(filterText != null);
			if (filterText == null)
				return MatchPriority.Other;

			if (filterText.Equals(searchText, StringComparison.CurrentCulture))
				return MatchPriority.Full;

			bool matchedAcronym = acronymMatchIndexes != null && AcronymSearchHelpers.TryUpdateAcronymIndexes(acronymMatchIndexes, searchText, filterText);
			if (matchedAcronym && CountUpperCaseLetters(filterText) == acronymMatchIndexes.Length)
				return MatchPriority.FullAcronym;

			if (filterText.Equals(searchText, StringComparison.CurrentCultureIgnoreCase))
				return MatchPriority.FullIgnoringCase;

			int index = filterText.IndexOf(searchText, StringComparison.CurrentCulture);
			if (index == 0)
				return MatchPriority.Start;

			if (matchedAcronym && acronymMatchIndexes[0] == 0)
				return MatchPriority.StartAcronym;

			int indexIgnoringCase = filterText.IndexOf(searchText, StringComparison.CurrentCultureIgnoreCase);
			if (indexIgnoringCase == 0)
				return MatchPriority.StartIgnoringCase;

			if (index > 0)
				return MatchPriority.AnyLocation;
			if (matchedAcronym)
				return MatchPriority.AnyLocationAcronym;
			if (indexIgnoringCase > 0)
				return MatchPriority.AnyLocationIgnoringCase;

			return MatchPriority.Other;
		}
Ejemplo n.º 46
0
 public static int CompareIgnoreCase(Completion completion1, Completion completion2)
 {
     return(Compare(completion1, completion2, StringComparison.OrdinalIgnoreCase));
 }
Ejemplo n.º 47
0
 protected abstract void CommitCore(DothtmlCompletionContext context, Completion completion);
 private void TrackListBuilder(List <Track> result)
 {
     _asyncTracksResult = result;
     Completion.Set();
 }
Ejemplo n.º 49
0
 public Task SignalCounter(int count)
 {
     _counter = count;
     _completion = Context.GetCompletion();
     return _completion;
 }
Ejemplo n.º 50
0
 void Awake()
 {
     DontDestroyOnLoad(transform.gameObject);
     instance = this;
 }
Ejemplo n.º 51
0
 public Task<TimeSpan> TellSequential(int messageCount)
 {
     _tellParallel = false;
     _tellCount = 0;
     _tellExpected = messageCount;
     _tellTimer = Stopwatch.StartNew();
     _tellCompletion = Context.GetCompletion<TimeSpan>();
     _tellReceiver = Context.Create<IPerfReceiver>().Proxy;
     _tellReceiver.Tell(Guid.NewGuid(), "foo");
     return _tellCompletion;
 }
Ejemplo n.º 52
0
 private bool IsAdvanced(Completion comp)
 {
     return(_advancedItemPattern.IsMatch(_matchInsertionText ? comp.InsertionText : comp.DisplayText));
 }
Ejemplo n.º 53
0
		CompletionVM GetExistingCompletionVM(Completion completion) {
			if (completion == null)
				return null;
			var vm = CompletionVM.TryGet(completion);
			Debug.Assert(vm != null);
			return vm;
		}
Ejemplo n.º 54
0
 private static bool IsVisible(Completion completion)
 {
     return(((DynamicallyVisibleCompletion)completion).Visible);
 }
Ejemplo n.º 55
0
		CompletionVM GetOrCreateVM(Completion completion) => CompletionVM.TryGet(completion) ?? new CompletionVM(completion, imageMonikerService);
Ejemplo n.º 56
0
        private Completion ArrayAccumulate(ArrayObject array, int nextIndex)
        {
            foreach (var item in arrayLiteralItems)
            {
                Completion        valueComp;
                BooleanCompletion status;
                IValue            value;
                switch (item)
                {
                case AbstractAssignmentExpression assignmentExpression:
                    valueComp = assignmentExpression.Evaluate(Interpreter.Instance()).GetValue();
                    if (valueComp.IsAbrupt())
                    {
                        return(valueComp);
                    }
                    value  = valueComp.value !;
                    status = Utils.CreateDataProperty(array, nextIndex.ToString(System.Globalization.CultureInfo.InvariantCulture), value);
                    if (status.IsAbrupt() || !status.Other)
                    {
                        throw new InvalidOperationException("Spec 12.2.5.2, Assignment, step 5");
                    }
                    nextIndex++;
                    break;

                case Elision elision:
                    nextIndex += elision.width;
                    break;

                case SpreadElement spreadElement:
                    valueComp = spreadElement.assignmentExpression.Evaluate(Interpreter.Instance()).GetValue();
                    if (valueComp.IsAbrupt())
                    {
                        return(valueComp);
                    }
                    value = valueComp.value !;
                    if (!(value is Object @object))
                    {
                        throw new InvalidOperationException($"ArrayLiteral: tried to initialize an array using a spread on a non-object");
                    }
                    var iteratorComp = @object.GetIterator();
                    if (iteratorComp.IsAbrupt())
                    {
                        return(iteratorComp);
                    }
                    var iteratorRecord = iteratorComp.Other !;
                    while (true)
                    {
                        var next = iteratorRecord.IteratorStep();
                        if (next.IsAbrupt())
                        {
                            return(next);
                        }
                        if (next.value == BooleanValue.False)
                        {
                            break;
                        }
                        var nextValue = IteratorRecord.IteratorValue(next.value !);
                        if (nextValue.IsAbrupt())
                        {
                            return(nextValue);
                        }
                        status = Utils.CreateDataProperty(array, nextIndex.ToString(System.Globalization.CultureInfo.InvariantCulture), nextValue.value !);
                        if (status.IsAbrupt() || !status.Other)
                        {
                            throw new InvalidOperationException("Spec 12.2.5.2, Spread, step 4e");
                        }
                        nextIndex++;
                    }
                    break;
                }
            }
            return(Completion.NormalCompletion(new NumberValue(nextIndex)));
        }
Ejemplo n.º 57
0
 private bool IsAdvanced(Completion comp) {
     return _advancedItemPattern.IsMatch(_matchInsertionText ? comp.InsertionText : comp.DisplayText);
 }
Ejemplo n.º 58
0
 internal CompletionAwaiter(Task task, Completion parent)
 {
     _parent      = parent;
     _taskAwaiter = task.GetAwaiter();
 }
Ejemplo n.º 59
0
        /// <summary>
        /// Determines the best match in the completion set.
        /// </summary>
        public override void SelectBestMatch() {
            var text = ApplicableTo.GetText(ApplicableTo.TextBuffer.CurrentSnapshot);

            Completion bestMatch = _previousSelection;
            int bestValue = 0;
            bool isUnique = true;
            bool allowSelect = true;

            // Using the Completions property to only search through visible
            // completions.
            foreach (var comp in Completions) {
                int value = _comparer.GetSortKey(_matchInsertionText ? comp.InsertionText : comp.DisplayText, text);
                if (bestMatch == null || value > bestValue) {
                    bestMatch = comp;
                    bestValue = value;
                    isUnique = true;
                } else if (value == bestValue) {
                    isUnique = false;
                }
            }

            if (Moniker == "PythonOverrides") {
                allowSelect = false;
                isUnique = false;
            }

            if (((DynamicallyVisibleCompletion)bestMatch).Visible) {
                SelectionStatus = new CompletionSelectionStatus(
                    bestMatch,
                    isSelected: allowSelect && bestValue > 0,
                    isUnique: isUnique
                );
            } else {
                SelectionStatus = new CompletionSelectionStatus(
                    null,
                    isSelected: false,
                    isUnique: false
                );
            }

            _previousSelection = bestMatch;
        }
Ejemplo n.º 60
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public SubmissionStatus(Completion completion, bool late)
 {
     Completion = completion;
     Late       = late;
 }