Skip to content

Commit

Permalink
Move navigation strings to resx.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugues Valois committed Feb 8, 2017
1 parent 092119b commit 13583f7
Show file tree
Hide file tree
Showing 11 changed files with 173 additions and 55 deletions.
108 changes: 108 additions & 0 deletions Python/Product/Common/Strings.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

38 changes: 38 additions & 0 deletions Python/Product/Common/Strings.resx
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,44 @@ The web.config file will be configured to resolve URIs matching this pattern to
<data name="MixedModeDebugSymbolsRequiredDownloadSymbols" xml:space="preserve">
<value>Download symbols for my interpreter</value>
</data>
<data name="WaitForCompleteAnalysisDialog_Waiting" xml:space="preserve">
<value>Waiting for analysis to complete...</value>
</data>
<data name="WaitForCompleteAnalysisDialog_Cancel" xml:space="preserve">
<value>Cancel</value>
</data>
<data name="FindReferencesCaretMustBeOnValidExpression" xml:space="preserve">
<value>The caret must be on valid expression to find all references.</value>
</data>
<data name="SourceAnalysisNotUpToDate" xml:space="preserve">
<value>Python source analysis is not up to date</value>
</data>
<data name="PythonNavigateToItemDisplay_ProjectHeader" xml:space="preserve">
<value>Project:</value>
</data>
<data name="PythonNavigateToItemDisplay_FileHeader" xml:space="preserve">
<value>File:</value>
</data>
<data name="PythonNavigateToItemDisplay_LineHeader" xml:space="preserve">
<value>Line:</value>
</data>
<data name="PythonNavigateToItemDisplay_ProjectInfo" xml:space="preserve">
<value>Project: {0}</value>
<comment>{0} is project name</comment>
</data>
<data name="PythonNavigateToItemDisplay_FileInfo" xml:space="preserve">
<value>File: {0}</value>
<comment>{0} is file name</comment>
</data>
<data name="SymbolListDefinitions" xml:space="preserve">
<value>Definitions</value>
</data>
<data name="SymbolListValues" xml:space="preserve">
<value>Values</value>
</data>
<data name="SymbolListReferences" xml:space="preserve">
<value>References</value>
</data>
<data name="ErrorOpeningInteractiveWindow" xml:space="preserve">
<value>An error occurred opening this interactive window.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Text.Editor;
using Microsoft.VisualStudio.Text.Operations;
using Microsoft.VisualStudio.TextManager.Interop;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,10 @@

using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Threading;
using Microsoft.PythonTools.Analysis;
using Microsoft.PythonTools.Intellisense;
using Microsoft.PythonTools.Parsing;
using Microsoft.PythonTools.Parsing.Ast;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
Expand Down Expand Up @@ -59,12 +52,12 @@ namespace Microsoft.PythonTools.Navigation {
/// the drop down to remove grayed out elements.
/// </summary>
class DropDownBarClient : IVsDropdownBarClient {
private AnalysisEntry _analysisEntry; // analysis entry which gets updated with new ASTs for us to inspect.
private readonly AnalysisEntry _analysisEntry; // analysis entry which gets updated with new ASTs for us to inspect.
private readonly Dispatcher _dispatcher; // current dispatcher so we can get back to our thread
private IWpfTextView _textView; // text view we're drop downs for
private IVsDropdownBar _dropDownBar; // drop down bar - used to refresh when changes occur
private NavigationInfo _navigations;
private object _navigationsLock = new object();
private readonly object _navigationsLock = new object();
private readonly IServiceProvider _serviceProvider;
private readonly UIThreadBase _uiThread;
private IntPtr _imageList;
Expand Down
34 changes: 13 additions & 21 deletions Python/Product/PythonTools/PythonTools/Navigation/EditFilter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,18 @@
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Windows;
using Microsoft.PythonTools.Analysis;
using Microsoft.PythonTools.Editor;
using Microsoft.PythonTools.Editor.Core;
using Microsoft.PythonTools.Intellisense;
using Microsoft.PythonTools.Navigation;
using Microsoft.PythonTools.Project;
using Microsoft.PythonTools.Refactoring;
using Microsoft.PythonTools.Repl;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.OLE.Interop;
using Microsoft.PythonTools.InteractiveWindow;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Text;
Expand Down Expand Up @@ -168,14 +164,14 @@ private async void GotoDefinition() {
MessageBox.Show(Strings.CannotGoToDefn_Name.FormatUI(defs.Expression), Strings.ProductTitle);
}
} else if (definitions.Count == 0) {
ShowFindSymbolsDialog(defs.Expression, new SymbolList("Values", StandardGlyphGroup.GlyphForwardType, values.Values));
ShowFindSymbolsDialog(defs.Expression, new SymbolList(Strings.SymbolListValues, StandardGlyphGroup.GlyphForwardType, values.Values));
} else if (values.Count == 0) {
ShowFindSymbolsDialog(defs.Expression, new SymbolList("Definitions", StandardGlyphGroup.GlyphLibrary, definitions.Values));
ShowFindSymbolsDialog(defs.Expression, new SymbolList(Strings.SymbolListDefinitions, StandardGlyphGroup.GlyphLibrary, definitions.Values));
} else {
ShowFindSymbolsDialog(defs.Expression,
new LocationCategory("Goto Definition",
new SymbolList("Definitions", StandardGlyphGroup.GlyphLibrary, definitions.Values),
new SymbolList("Values", StandardGlyphGroup.GlyphForwardType, values.Values)
new LocationCategory(
new SymbolList(Strings.SymbolListDefinitions, StandardGlyphGroup.GlyphLibrary, definitions.Values),
new SymbolList(Strings.SymbolListValues, StandardGlyphGroup.GlyphForwardType, values.Values)
)
);
}
Expand Down Expand Up @@ -228,11 +224,11 @@ internal static LocationCategory GetFindRefLocations(VsProjectAnalyzer analyzer,
Dictionary<AnalysisLocation, SimpleLocationInfo> references, definitions, values;
GetDefsRefsAndValues(analyzer, serviceProvider, expr, analysis, out definitions, out references, out values);

var locations = new LocationCategory("Find All References",
new SymbolList("Definitions", StandardGlyphGroup.GlyphLibrary, definitions.Values),
new SymbolList("Values", StandardGlyphGroup.GlyphForwardType, values.Values),
new SymbolList("References", StandardGlyphGroup.GlyphReference, references.Values)
);
var locations = new LocationCategory(
new SymbolList(Strings.SymbolListDefinitions, StandardGlyphGroup.GlyphLibrary, definitions.Values),
new SymbolList(Strings.SymbolListValues, StandardGlyphGroup.GlyphForwardType, values.Values),
new SymbolList(Strings.SymbolListReferences, StandardGlyphGroup.GlyphReference, references.Values)
);
return locations;
}

Expand Down Expand Up @@ -296,16 +292,12 @@ private void ShowFindSymbolsDialog(string expr, IVsNavInfo symbols) {
ErrorHandler.ThrowOnFailure(findSym.DoSearch(new Guid(CommonConstants.LibraryGuid), new VSOBSEARCHCRITERIA2[] { searchCriteria }));
} else {
var statusBar = (IVsStatusbar)_serviceProvider.GetService(typeof(SVsStatusbar));
statusBar.SetText("The caret must be on valid expression to find all references.");
statusBar.SetText(Strings.FindReferencesCaretMustBeOnValidExpression);
}
}

internal class LocationCategory : SimpleObjectList<SymbolList>, IVsNavInfo, ICustomSearchListProvider {
private readonly string _name;

internal LocationCategory(string name, params SymbolList[] locations) {
_name = name;

internal LocationCategory(params SymbolList[] locations) {
foreach (var location in locations) {
if (location.Children.Count > 0) {
Children.Add(location);
Expand Down Expand Up @@ -628,7 +620,7 @@ private void UpdateStatusForIncompleteAnalysis() {
var statusBar = (IVsStatusbar)_serviceProvider.GetService(typeof(SVsStatusbar));
var analyzer = _textView.GetAnalyzerAtCaret(_serviceProvider);
if (analyzer != null && analyzer.IsAnalyzing) {
statusBar.SetText("Python source analysis is not up to date");
statusBar.SetText(Strings.SourceAnalysisNotUpToDate);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,8 @@
using System.Windows;
using System.Windows.Media.Imaging;
using Microsoft.PythonTools.Infrastructure;
using Microsoft.PythonTools.Parsing;
using Microsoft.VisualStudio.Language.Intellisense;
using Microsoft.VisualStudio.Language.NavigateTo.Interfaces;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudioTools;
using Microsoft.VisualStudioTools.Navigation;
using AnalysisReference = Microsoft.PythonTools.Intellisense.AnalysisProtocol.AnalysisReference;
using Completion = Microsoft.PythonTools.Intellisense.AnalysisProtocol.Completion;

Expand Down Expand Up @@ -64,23 +60,23 @@ public PythonNavigateToItemDisplay(NavigateToItem item) {

if (!string.IsNullOrEmpty(tag.ProjectName)) {
descrItems.Add(new DescriptionItem(
Array.AsReadOnly(new[] { new DescriptionRun("Project:", bold: true) }),
Array.AsReadOnly(new[] { new DescriptionRun(Strings.PythonNavigateToItemDisplay_ProjectHeader, bold: true) }),
Array.AsReadOnly(new[] { new DescriptionRun(tag.ProjectName) })
));
AdditionalInformation = "Project: " + tag.ProjectName;
AdditionalInformation = Strings.PythonNavigateToItemDisplay_ProjectInfo.FormatUI(tag.ProjectName);
}

if (!string.IsNullOrEmpty(_location?.file)) {
descrItems.Add(new DescriptionItem(
Array.AsReadOnly(new[] { new DescriptionRun("File:", bold: true) }),
Array.AsReadOnly(new[] { new DescriptionRun(Strings.PythonNavigateToItemDisplay_FileHeader, bold: true) }),
Array.AsReadOnly(new[] { new DescriptionRun(_location.file) })
));
if (string.IsNullOrEmpty(AdditionalInformation)) {
AdditionalInformation = "File: " + _location.file;
AdditionalInformation = Strings.PythonNavigateToItemDisplay_FileInfo.FormatUI(_location.file);
}
if (_location.line > 0) {
descrItems.Add(new DescriptionItem(
Array.AsReadOnly(new[] { new DescriptionRun("Line:", bold: true) }),
Array.AsReadOnly(new[] { new DescriptionRun(Strings.PythonNavigateToItemDisplay_LineHeader, bold: true) }),
Array.AsReadOnly(new[] { new DescriptionRun(_location.line.ToString()) })
));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,8 @@
using System;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.PythonTools.Analysis;
using Microsoft.PythonTools.Debugger;
using Microsoft.PythonTools.Debugger.DebugEngine;
using Microsoft.PythonTools.Infrastructure;
using Microsoft.PythonTools.Parsing.Ast;
using Microsoft.VisualStudio;
using Microsoft.VisualStudio.ComponentModelHost;
using Microsoft.VisualStudio.Editor;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@

using System;
using System.Runtime.InteropServices;
using Microsoft.PythonTools.Analysis;
using Microsoft.PythonTools.Infrastructure;
using Microsoft.PythonTools.Intellisense;
using Microsoft.PythonTools.Project;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudioTools;
using Microsoft.VisualStudioTools.Navigation;
using Microsoft.VisualStudioTools.Project;
Expand Down
Loading

0 comments on commit 13583f7

Please sign in to comment.