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 GenerateFoldings_HandleImportBlocks() { OpenMainFile(@"module main;//0 import a;//1 import b;import b2; import c=d; import e; import f; static if(true) { import g; import g.h.i; import k; void main(string[] args) { writeln(`asdf`); } } "); var request = new FoldingRangeRequestParam { TextDocument = new TextDocumentItem { Uri = new Uri(Lsp4DUtil.DefaultMainFile) } }; var foldings = Client.SendRequest <Container <FoldingRange> >(DocumentNames.FoldingRange, request).Result.ToList(); foldings.Sort((r1, r2) => r1.StartLine.CompareTo(r2.StartLine)); WorkAndProgressTester.AssertResultEquality(foldings, "DParserverTests.DFoldingRangeHandlerTests.ImportRanges-result.json"); }
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_NoProgressResult_ReturnsReferencesAsSingleResult() { OpenFile(ModuleAFile, @"module modA; class AClass {} class BClass {} void bar() { auto a = new AClass(); } "); var bFileCaret = OpenFile(ModuleBFile, @"module modB; import modA; ACl§ass ainstance; void foo(T: AClass)() {} "); var result = Client.SendRequest <LocationContainer>(DocumentNames.References, new ReferenceParams { Context = new ReferenceContext { IncludeDeclaration = true }, Position = bFileCaret, TextDocument = new TextDocumentIdentifier(new Uri(ModuleBFile)) }).Result; WorkAndProgressTester.AssertResultEquality(result, "DParserverTests.DReferencesHandlerTests.ExpectedProgress3-result.json"); }
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 GenerateFoldings_HandleRanges() { OpenMainFile(@"module main; // region asdf void main() {} //endregion "); var foldingRanges = Client.TextDocument.FoldingRanges(Lsp4DUtil.DefaultMainFile).Result .ToList(); foldingRanges.Sort((r1, r2) => r1.StartLine.CompareTo(r2.StartLine)); WorkAndProgressTester.AssertResultEquality(foldingRanges, "DParserverTests.DFoldingRangeHandlerTests.RegionComments-result.json"); }
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 GenerateFoldings_HandleSubsequentSingleLineComments() { OpenMainFile(@"module main; /// a /// b /// c // d // e // f "); var foldingRanges = Client.TextDocument.FoldingRanges(Lsp4DUtil.DefaultMainFile).Result .ToList(); foldingRanges.Sort((r1, r2) => r1.StartLine.CompareTo(r2.StartLine)); WorkAndProgressTester.AssertResultEquality(foldingRanges, "DParserverTests.DFoldingRangeHandlerTests.SubsequentSingleLineComments-result.json"); }
public void GenerateFoldings_HandleMetaBlocks() { OpenMainFile(@"module main;//0 import stdio;//1 static if(true) { //4 void main(string[] args) { writeln(`asdf`);//6 } } //9 "); var foldingRanges = Client.TextDocument.FoldingRanges(Lsp4DUtil.DefaultMainFile).Result .ToList(); foldingRanges.Sort((r1, r2) => r1.StartLine.CompareTo(r2.StartLine)); WorkAndProgressTester.AssertResultEquality(foldingRanges, "DParserverTests.DFoldingRangeHandlerTests.MetaBlocks-result.json"); }
public void GetDocumentHighlights_OnNewExpression_ReturnsClassNamesHighlights() { var caret = OpenMainFile(@"module modA; class AClass { this() {} this(int asdf) {} } void bar() { auto a = new ACla§ss(); } "); var results = Client.SendRequest <DocumentHighlightContainer>(DocumentNames.DocumentHighlight, new DocumentHighlightParams { Position = caret, TextDocument = new TextDocumentIdentifier(new Uri(Lsp4DUtil.DefaultMainFile)) }).Result; WorkAndProgressTester.AssertResultEquality(results, "DParserverTests.DDocumentHighlightHandlerTests2-result.json"); }
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"); }