public void TriggersCompletion_WithAlreadyBegunIdentifier_ReturnsCompletionItems() { var caret = OpenMainFile(@"module main; class MyClass {int propertyA;} void foo(MyClass i) { i.prop§ } "); var workAndProgress = WorkAndProgressTester.Setup(Client); var completions = Client.SendRequest <CompletionList>(DocumentNames.Completion, new CompletionParams { Context = new CompletionContext { TriggerKind = CompletionTriggerKind.Invoked }, Position = caret, TextDocument = new TextDocumentIdentifier(new Uri(Lsp4DUtil.DefaultMainFile)), PartialResultToken = WorkAndProgressTester.PartialResultToken, WorkDoneToken = WorkAndProgressTester.WorkDoneToken }) .Result; workAndProgress.AssertProgressLogExpectations("DParserverTests.DCompletionHandlerTests.PropnameTrigger"); Assert.IsEmpty(completions); Assert.IsFalse(completions.IsIncomplete); }
public void RequestSelectionRange_ReturnsAstStackAsSelectionRangeStack() { var caret = OpenMainFile(@"module modA; static if(true) { class AClass { void foo(T = bo§ol)() { return bar(); } } } "); var tester = WorkAndProgressTester.Setup(Client); var result = Client.SendRequest <Container <SelectionRange> >(DocumentNames.SelectionRange, new SelectionRangeParam { TextDocument = new TextDocumentIdentifier(new Uri(Lsp4DUtil.DefaultMainFile)), Positions = new Container <Position>( new Position(4, 22), caret), PartialResultToken = WorkAndProgressTester.PartialResultToken, WorkDoneToken = WorkAndProgressTester.WorkDoneToken }).Result; tester.AssertProgressLogExpectations("DParserverTests.DSelectionRangeHandlerTests1"); Assert.IsEmpty(result); }
public void EnumReferences_IncludeDeclaration_ReturnsReferences() { OpenFile(ModuleAFile, @"module modA; class AClass {} class BClass {} void bar() { auto a = new AClass(); } "); var bFileCaret = OpenFile(ModuleBFile, @"module modB; import modA; AC§lass ainstance; void foo(T: AClass)() {} "); var workTester = WorkAndProgressTester.Setup(Client); Assert.IsEmpty(Client.SendRequest <LocationContainer>("textDocument/references", new ReferenceParams { Context = new ReferenceContext { IncludeDeclaration = true }, PartialResultToken = WorkAndProgressTester.PartialResultToken, Position = bFileCaret, TextDocument = new TextDocumentIdentifier(new Uri(ModuleBFile)), WorkDoneToken = WorkAndProgressTester.WorkDoneToken }).Result); workTester.AssertProgressLogExpectations("DParserverTests.DReferencesHandlerTests.ExpectedProgress1"); }
public void CallGotoDeclarationHandler_ReturnsLocations() { var caret = OpenMainFile(@"module main; class MyClass {} My§Class instance;"); var workAndProgress = WorkAndProgressTester.Setup(Client); Assert.IsEmpty(Client.SendRequest <List <LocationOrLocationLink> >(DocumentNames.Definition, new DefinitionParams { PartialResultToken = WorkAndProgressTester.PartialResultToken, Position = caret, TextDocument = new TextDocumentIdentifier(new Uri(Lsp4DUtil.DefaultMainFile)), WorkDoneToken = WorkAndProgressTester.WorkDoneToken }).Result); workAndProgress.AssertProgressLogExpectations("DParserverTests.DDefinitionHandlerTests1"); }
public void EnumReferences_DontIncludeDeclaration_ReturnsReferences() { OpenFile(ModuleAFile, @"module modA; class AClass {} class BClass {} void bar() { auto a = new AClass(); } "); var bFileCaret = OpenFile(ModuleBFile, @"module modB; import modA; AC§lass ainstance; void foo(T: AClass)() {} "); var partialResultToken = new ProgressToken("partialResult"); var workdoneToken = new ProgressToken("workDone"); var workTester = WorkAndProgressTester.Setup(Client); var result = Client.SendRequest <LocationContainer>(DocumentNames.References, new ReferenceParams { Context = new ReferenceContext { IncludeDeclaration = false }, PartialResultToken = partialResultToken, Position = bFileCaret, TextDocument = new TextDocumentIdentifier(new Uri(ModuleBFile)), WorkDoneToken = workdoneToken }).Result; workTester.AssertProgressLogExpectations("DParserverTests.DReferencesHandlerTests.ExpectedProgress2"); Assert.AreEqual("[]", JsonConvert.SerializeObject(result)); }
public void GetDocumentHighlights_ReturnsHighlights() { var caret = OpenMainFile(@"module modA; class AClass { AClass foo(T = AClass)(T t); } void bar() { auto a = new ACla§ss(); } "); var workTester = WorkAndProgressTester.Setup(Client); Assert.IsEmpty(Client.SendRequest <DocumentHighlightContainer>(DocumentNames.DocumentHighlight, new DocumentHighlightParams { Position = caret, PartialResultToken = WorkAndProgressTester.PartialResultToken, TextDocument = new TextDocumentIdentifier(new Uri(Lsp4DUtil.DefaultMainFile)), WorkDoneToken = WorkAndProgressTester.WorkDoneToken }).Result); workTester.AssertProgressLogExpectations("DParserverTests.DDocumentHighlightHandlerTests1"); }