public PythonNavigateToItemDisplay(NavigateToItem item) { _item = item; var tag = (PythonNavigateToItemProvider.ItemTag)item.Tag; _node = tag.Node; _icon = GetIcon(tag.GlyphService, _node.GlyphType); var descrItems = new List<DescriptionItem>(); IVsHierarchy hier; uint itemId; uint itemsCount; _node.SourceItems(out hier, out itemId, out itemsCount); if (hier != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Project:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(hier.GetProject().FullName) }))); string fileName; hier.GetCanonicalName(itemId, out fileName); if (fileName != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("File:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(fileName) }))); var commonNode = _node as CommonLibraryNode; if (commonNode != null && commonNode.CanGoToSource) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Line:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun((commonNode.SourceSpan.iStartLine + 1).ToString()) }))); } } } _descrItems = descrItems.AsReadOnly(); }
public async Task TermSplittingTest3() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; await TestAsync(source, async w => { var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Substring, true, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem2 }; var items = await _aggregator.GetItemsAsync("K W"); VerifyNavigateToResultItems(expecteditems, items); }); }
public async Task TermSplittingTest2() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; await TestAsync(source, async w => { var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseNonContiguousPrefixPatternMatch_NotCaseSensitive, null); var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseExactPatternMatch, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem2 }; var items = await _aggregator.GetItemsAsync("GKW"); VerifyNavigateToResultItems(expecteditems, items); }); }
public void TermSplittingTest3() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; using (var workspace = SetupWorkspace(source)) { var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Substring, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem2 }; var items = _aggregator.GetItems("K W"); VerifyNavigateToResultItems(expecteditems, items); } }
public async Task TermSplittingTest7(TestHost testHost) { ////Diff from dev10 var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; await TestAsync(testHost, source, async w => { var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseSubstringPatternMatch_NotCaseSensitive, null); var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptySubstringPatternMatch, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem2 }; var items = await _aggregator.GetItemsAsync("K*W"); VerifyNavigateToResultItems(expecteditems, items); }); }
private void ReportMatchResult(Project project, INavigateToSearchResult result) { var matchedSpans = result.NameMatchSpans.SelectAsArray(t => t.ToSpan()); var patternMatch = new PatternMatch(GetPatternMatchKind(result.MatchKind), punctuationStripped: true, result.IsCaseSensitive, matchedSpans); var navigateToItem = new NavigateToItem( result.Name, result.Kind, GetNavigateToLanguage(project.Language), result.SecondarySort, result, patternMatch, _displayFactory); _callback.AddItem(navigateToItem); }
public async Task TermSplittingTest1(TestHost testHost, Composition composition) { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; await TestAsync(testHost, composition, source, async w => { var expecteditem1 = new NavigateToItem("get_keyword", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseNonContiguousPrefixPatternMatch_NotCaseSensitive, null); var expecteditem2 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCaseNonContiguousPrefixPatternMatch_NotCaseSensitive, null); var expecteditem3 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, s_emptyCamelCasePrefixPatternMatch, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem2, expecteditem3 }; var items = await _aggregator.GetItemsAsync("GK"); Assert.Equal(expecteditems.Count(), items.Count()); VerifyNavigateToResultItems(expecteditems, items); }); }
public async Task TermSplittingTest1() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; using (var workspace = await SetupWorkspaceAsync(source)) { var expecteditem1 = new NavigateToItem("get_keyword", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem2 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem3 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, true, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem2, expecteditem3 }; var items = _aggregator.GetItems("GK"); Assert.Equal(expecteditems.Count(), items.Count()); VerifyNavigateToResultItems(expecteditems, items); } }
public PythonNavigateToItemDisplay(NavigateToItem item) { _item = item; var tag = (PythonNavigateToItemProvider.ItemTag)item.Tag; _node = tag.Node; _icon = GetIcon(tag.GlyphService, _node.GlyphType); var descrItems = new List <DescriptionItem>(); IVsHierarchy hier; uint itemId; uint itemsCount; _node.SourceItems(out hier, out itemId, out itemsCount); if (hier != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Project:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(hier.GetProject().FullName) }))); string fileName; hier.GetCanonicalName(itemId, out fileName); if (fileName != null) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("File:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun(fileName) }))); var commonNode = _node as CommonLibraryNode; if (commonNode != null && commonNode.CanGoToSource) { descrItems.Add(new DescriptionItem( Array.AsReadOnly(new[] { new DescriptionRun("Line:", bold: true) }), Array.AsReadOnly(new[] { new DescriptionRun((commonNode.SourceSpan.iStartLine + 1).ToString()) }))); } } } _descrItems = descrItems.AsReadOnly(); }
public async Task FindPartialClass() { await TestAsync( @"public partial class Foo { int a; } partial class Foo { int b; }", async w => { var expecteditem1 = new NavigateToItem("Foo", NavigateToItemKind.Class, "csharp", null, null, MatchKind.Exact, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 }; var items = await _aggregator.GetItemsAsync("Foo"); VerifyNavigateToResultItems(expecteditems, items); }); }
internal void VerifyNavigateToResultItem( NavigateToItem result, string name, string displayMarkup, PatternMatchKind matchKind, string navigateToItemKind, Glyph glyph, string additionalInfo = null ) { // Verify symbol information Assert.Equal(name, result.Name); Assert.Equal(matchKind, result.PatternMatch.Kind); Assert.Equal(this.Language, result.Language); Assert.Equal(navigateToItemKind, result.Kind); MarkupTestFile.GetSpans( displayMarkup, out displayMarkup, out ImmutableArray <TextSpan> expectedDisplayNameSpans ); var itemDisplay = (NavigateToItemDisplay)result.DisplayFactory.CreateItemDisplay( result ); Assert.Equal(itemDisplay.GlyphMoniker, glyph.GetImageMoniker()); Assert.Equal(displayMarkup, itemDisplay.Name); Assert.Equal <TextSpan>( expectedDisplayNameSpans, itemDisplay.GetNameMatchRuns("").Select(s => s.ToTextSpan()).ToImmutableArray() ); if (additionalInfo != null) { Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation); } }
public async Task FindPartialClass(TestHost testHost) { await TestAsync(testHost, @"public partial class Goo { int a; } partial class Goo { int b; }", async w => { var expecteditem1 = new NavigateToItem("Goo", NavigateToItemKind.Class, "csharp", null, null, s_emptyExactPatternMatch, null); var expecteditems = new List <NavigateToItem> { expecteditem1, expecteditem1 }; var items = await _aggregator.GetItemsAsync("Goo"); VerifyNavigateToResultItems(expecteditems, items); }); }
// For ordering of NavigateToItems, see // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.language.navigateto.interfaces.navigatetoitem.aspx protected static int CompareNavigateToItems(NavigateToItem a, NavigateToItem b) { var result = ((int)a.PatternMatch.Kind) - ((int)b.PatternMatch.Kind); if (result != 0) { return(result); } result = a.Name.CompareTo(b.Name); if (result != 0) { return(result); } result = a.Kind.CompareTo(b.Kind); if (result != 0) { return(result); } result = a.SecondarySort.CompareTo(b.SecondarySort); return(result); }
private void VerifyNavigateToResultItem(NavigateToItem result, string name, MatchKind matchKind, string navigateToItemKind, string displayName = null, string additionalInfo = null) { // Verify symbol information Assert.Equal(name, result.Name); Assert.Equal(matchKind, result.MatchKind); Assert.Equal("csharp", result.Language); Assert.Equal(navigateToItemKind, result.Kind); // Verify display var itemDisplay = result.DisplayFactory.CreateItemDisplay(result); Assert.Equal(displayName ?? name, itemDisplay.Name); if (additionalInfo != null) { Assert.Equal(additionalInfo, itemDisplay.AdditionalInformation); } // Make sure to fetch the glyph var unused = itemDisplay.Glyph; _glyphServiceMock.Verify(); }
// For ordering of NavigateToItems, see // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.language.navigateto.interfaces.navigatetoitem.aspx private static int CompareNavigateToItems(NavigateToItem a, NavigateToItem b) { int result = ((int)a.MatchKind) - ((int)b.MatchKind); if (result != 0) { return(result); } result = a.Name.CompareTo(b.Name); if (result != 0) { return(result); } result = a.Kind.CompareTo(b.Kind); if (result != 0) { return(result); } result = a.SecondarySort.CompareTo(b.SecondarySort); return(result); }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { var searchResult = (INavigateToSearchResult)item.Tag; return new Dev15NavigateToItemDisplay(searchResult); }
// For ordering of NavigateToItems, see // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.language.navigateto.interfaces.navigatetoitem.aspx protected static int CompareNavigateToItems(NavigateToItem a, NavigateToItem b) => ComparerWithState.CompareTo(a, b, s_comparisonComponents);
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { return(new NitraNavigateToItemDisplay(_serviceProvider, _glyphService, item, _serverModel)); }
public async Task TermSplittingTest1() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; using (var workspace = await SetupWorkspaceAsync(source)) { var expecteditem1 = new NavigateToItem("get_keyword", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem2 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem3 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem2, expecteditem3 }; var items = _aggregator.GetItems("GK"); Assert.Equal(expecteditems.Count(), items.Count()); VerifyNavigateToResultItems(expecteditems, items); } }
public void AddItem(NavigateToItem item) => this.searchCallback.AddItem(NavigateToItemShim.Create(item));
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) => new NavigateToItemDisplay( _threadingContext, _threadOperationExecutor, _asyncListener, (INavigateToSearchResult)item.Tag);
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { return(new PythonNavigateToItemDisplay(item)); }
public void AddItem(NavigateToItem item) { _itemsReceived.Add(item); }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { var searchResult = (INavigateToSearchResult)item.Tag; return(new Dev14NavigateToItemDisplay(searchResult, _iconFactory)); }
public void FindOverriddenMembers() { var program = "class Foo { public virtual string Name { get; set; } } class DogBed : Foo { public override string Name { get { return base.Name; } set {} } }"; using (var workspace = SetupWorkspace(program)) { SetupVerifiableGlyph(StandardGlyphGroup.GlyphGroupProperty, StandardGlyphItem.GlyphItemPublic); var expecteditem1 = new NavigateToItem("Name", NavigateToItemKind.Property, "csharp", null, null, MatchKind.Exact, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 }; var items = _aggregator.GetItems("Name"); VerifyNavigateToResultItems(expecteditems, items); var item = items.ElementAt(0); var itemDisplay = item.DisplayFactory.CreateItemDisplay(item); var unused = itemDisplay.Glyph; Assert.Equal("Name", itemDisplay.Name); Assert.Equal($"{EditorFeaturesResources.Type}DogBed", itemDisplay.AdditionalInformation); _glyphServiceMock.Verify(); item = items.ElementAt(1); itemDisplay = item.DisplayFactory.CreateItemDisplay(item); unused = itemDisplay.Glyph; Assert.Equal("Name", itemDisplay.Name); Assert.Equal($"{EditorFeaturesResources.Type}Foo", itemDisplay.AdditionalInformation); _glyphServiceMock.Verify(); } }
public void FindPartialClass() { using (var workspace = SetupWorkspace("public partial class Foo { int a; } partial class Foo { int b; }")) { var expecteditem1 = new NavigateToItem("Foo", NavigateToItemKind.Class, "csharp", null, null, MatchKind.Exact, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 }; var items = _aggregator.GetItems("Foo"); VerifyNavigateToResultItems(expecteditems, items); } }
public NavigateToItemDisplay(NavigateToItem item) { Match = (NavigateToMatch)item.Tag; Name = Match.MatchedText; AdditionalInformation = $"sdmap: {Match.IdKind}"; }
public static NavigateToItemShim Create(NavigateToItem item) => new NavigateToItemShim(item.DisplayFactory.CreateItemDisplay(item));
public NitraNavigateToItemDisplay(IServiceProvider serviceProvider, IGlyphService glyphService, NavigateToItem item, ServerModel serverModel) { _serviceProvider = serviceProvider; _glyphService = glyphService; _item = item; _serverModel = serverModel; }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { return new JNavigateToItemDisplay(item); }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { var searchResult = (INavigateToSearchResult)item.Tag; return(new NavigateToItemDisplay(searchResult)); }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { var searchResult = (INavigateToSearchResult)item.Tag; return new NavigateToItemDisplay(searchResult, _iconFactory); }
public async Task FindPartialClass() { await TestAsync("public partial class Foo { int a; } partial class Foo { int b; }", async w => { var expecteditem1 = new NavigateToItem("Foo", NavigateToItemKind.Class, "csharp", null, null, MatchKind.Exact, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 }; var items = await _aggregator.GetItemsAsync("Foo"); VerifyNavigateToResultItems(expecteditems, items); }); }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { return(item.Tag as INavigateToItemDisplay); }
public async Task FindPartialMethods() { await TestAsync("partial class Foo { partial void Bar(); } partial class Foo { partial void Bar() { Console.Write(\"hello\"); } }", async w => { var expecteditem1 = new NavigateToItem("Bar", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Exact, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 }; var items = await _aggregator.GetItemsAsync("Bar"); VerifyNavigateToResultItems(expecteditems, items); }); }
public void FindPartialMethods() { using (var workspace = SetupWorkspace("partial class Foo { partial void Bar(); } partial class Foo { partial void Bar() { Console.Write(\"hello\"); } }")) { var expecteditem1 = new NavigateToItem("Bar", NavigateToItemKind.Method, "csharp", null, null, MatchKind.Exact, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem1 }; var items = _aggregator.GetItems("Bar"); VerifyNavigateToResultItems(expecteditems, items); } }
public async Task TermSplittingTest3() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; await TestAsync(source, async w => { var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Substring, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem2 }; var items = await _aggregator.GetItemsAsync("K W"); VerifyNavigateToResultItems(expecteditems, items); }); }
public void TermSplittingTest3() { var source = "class SyllableBreaking {int GetKeyWord; int get_key_word; string get_keyword; int getkeyword; int wake;}"; using (var workspace = SetupWorkspace(source)) { var expecteditem1 = new NavigateToItem("get_key_word", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Regular, null); var expecteditem2 = new NavigateToItem("GetKeyWord", NavigateToItemKind.Field, "csharp", null, null, MatchKind.Substring, true, null); var expecteditems = new List<NavigateToItem> { expecteditem1, expecteditem2 }; var items = _aggregator.GetItems("K W"); VerifyNavigateToResultItems(expecteditems, items); } }
public INavigateToItemDisplay CreateItemDisplay(NavigateToItem item) { return item.Tag as INavigateToItemDisplay; }
// For ordering of NavigateToItems, see // http://msdn.microsoft.com/en-us/library/microsoft.visualstudio.language.navigateto.interfaces.navigatetoitem.aspx private static int CompareNavigateToItems(NavigateToItem a, NavigateToItem b) { int result = ((int)a.MatchKind) - ((int)b.MatchKind); if (result != 0) { return result; } result = a.Name.CompareTo(b.Name); if (result != 0) { return result; } result = a.Kind.CompareTo(b.Kind); if (result != 0) { return result; } result = a.SecondarySort.CompareTo(b.SecondarySort); return result; }
private void ReportMatchResult(Project project, INavigateToSearchResult result) { var navigateToItem = new NavigateToItem( result.Name, result.Kind, GetNavigateToLanguage(project.Language), result.SecondarySort, result, result.MatchKind, result.IsCaseSensitive, _displayFactory); _callback.AddItem(navigateToItem); }
private void ReportMatchResult(Project project, INavigateToSearchResult result) { var navigateToItem = new NavigateToItem(result.Name, result.Kind, GetNavigateToLanguage(project.Language), result.SecondarySort, result, result.MatchKind, _displayFactory); _callback.AddItem(navigateToItem); }