using System.Collections.Generic;
public static void Main(string[] args)
Console.WriteLine("Hello World!");
var list = ExtractLookbackTokensForInference(100, new List<int> { 2 }, new List<string> { "." }, "str", 0);
Console.WriteLine(string.Join<string>(",", list));
Console.WriteLine(list.Count);
private static List<string> ExtractLookbackTokensForInference(int lookback, List<int> selected_tokens, List<string> selected_tokens_images, string type, int last_invocation_index)
var start = last_invocation_index - lookback + 1;
range = last_invocation_index + 1;
var token_images = selected_tokens_images.GetRange(start, range);
if (token_images[token_images.Count - 1] != "." && token_images[token_images.Count - 1] != ")")
token_images[token_images.Count - 1] = ".";
if(token_images.Count == 1)
else if (token_images[token_images.Count - 1] == "." && token_images[token_images.Count - 2] == ")")
token_images[token_images.Count - 1] = "\n";
token_images = token_images.GetRange(2, range);
if (token_images.Count > 1 && (IsNumeric(token_images[token_images.Count - 2]) || IsSymbol(token_images[token_images.Count - 2])))
token_images.Add(Consts.PrevSymbolOrNum);
public static bool IsNumeric(string value)
return value.All(char.IsNumber);
public static bool IsSymbol(string value)
return value.All(char.IsSymbol) || value.All(char.IsPunctuation);
internal static class Consts
public const string NullSequence = "N";
public const string SequenceDelimiter = "~";
public const string UnicodeStar = "\u2605 ";
public const string PrevSymbolOrNum = "$SYMBOL_OR_NUM$";
public const int MaxRecommendation = 5;
public const int PrecedingSequenceLength = 2;
public const string CompletionItemCommand = "vsintellicode.completionItemSelected";
public const bool IncludeUnresolvedType = true;
public const string UnresolvedType = "unktype";