예제 #1
0
        public IEnumerable<ICompletionData> GetCompletions(string editorText)
        {
            int cursorOffset = editorText.IndexOf("$", StringComparison.Ordinal);
            if(cursorOffset == -1)
                throw new ArgumentException("Editor text should contain a $");

            TextLocation cursorPosition = TestHelpers.GetLineAndColumnFromIndex(editorText, cursorOffset);
            string partialWord = GetPartialWord(editorText);
            editorText = editorText.Replace("$", "");

            var project = new FakeProject();
            project.AddFile(editorText);
            _solution.Projects.Add(project);
            var provider = new AutoCompleteHandler(new BufferParser(_solution), new Logger());
            var request = new AutoCompleteRequest
                {
                    FileName = "myfile",
                    WordToComplete = partialWord,
                    Buffer = editorText,
                    Line = cursorPosition.Line,
                    Column = cursorPosition.Column,
                };

            return provider.CreateProvider(request);
        }
        public IEnumerable<CompletionData> GetCompletions(string editorText, bool includeImportableTypes)
        {
            int cursorOffset = editorText.IndexOf("$", StringComparison.Ordinal);
            if(cursorOffset == -1)
                throw new ArgumentException("Editor text should contain a $");

            TextLocation cursorPosition = TestHelpers.GetLineAndColumnFromIndex(editorText, cursorOffset);
            string partialWord = GetPartialWord(editorText);
            editorText = editorText.Replace("$", "");

            var project = new FakeProject();
            project.AddFile(editorText);
            _solution.Projects.Add(project);
            var provider = new AutoCompleteHandler(_solution, new BufferParser(_solution), new Logger(Verbosity.Quiet));
            var request = new AutoCompleteRequest
                {
                    FileName = "myfile",
                    WordToComplete = partialWord,
                    Buffer = editorText,
                    Line = cursorPosition.Line,
                    Column = cursorPosition.Column,
                    WantDocumentationForEveryCompletionResult = false,
                    WantImportableTypes = includeImportableTypes,
                    WantMethodHeader = true,
                    WantReturnType = true,
                    WantSnippet = true
                };

            return provider.CreateProvider(request);
        }
예제 #3
0
 public AutoCompleteModule(AutoCompleteHandler autoCompleteHandler)
 {
     Post["/autocomplete"] = x =>
         {
             var req = this.Bind<AutoCompleteRequest>();
             var completions = autoCompleteHandler.CreateProvider(req);
             return Response.AsJson(completions.Select(c => new AutoCompleteResponse(c)));
         };
 }
예제 #4
0
 public AutoCompleteModule(AutoCompleteHandler autoCompleteHandler)
 {
     Post["/autocomplete"] = x =>
     {
         var req         = this.Bind <AutoCompleteRequest>();
         var completions = autoCompleteHandler.CreateProvider(req);
         return(Response.AsJson(completions.Select(c => new AutoCompleteResponse(c))));
     };
 }