Skip to content

Commit

Permalink
1st check-in of intellisense work
Browse files Browse the repository at this point in the history
  • Loading branch information
dinov committed May 8, 2014
1 parent 5d2aea7 commit 062aa3a
Show file tree
Hide file tree
Showing 414 changed files with 56,625 additions and 9,438 deletions.
2 changes: 1 addition & 1 deletion Common/Docs/HowTo.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Requirements are:
* Python 3.3
* markdown2 (`pip install markdown2`)
* Pygments (`pip install pygments`)
* Pillow with JPEG and PNG codecs (`pip install Pillow`)
* Pillow with JPEG and PNG codecs (`pip install --use-wheel Pillow`)

The first time the script is run, it will generate a file `maps.cache`, which contains all of the mappings used for the `src` and `file` links. This file should be deleted when source files are added, removed, moved or renamed, but will significantly speed up later refresh times.

Expand Down
2 changes: 0 additions & 2 deletions Common/Product/SharedProject/CommonPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ internal CommonPackage() {
}
};
#endif
UIThread.MustBeCalledFromUIThread();

IServiceContainer container = this as IServiceContainer;
ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateService);
//container.AddService(GetLanguageServiceType(), callback, true);
Expand Down
46 changes: 24 additions & 22 deletions Common/Product/SharedProject/HierarchyIdMap.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,37 +15,41 @@
using System.Collections.Generic;

namespace Microsoft.VisualStudioTools.Project {
/// <summary>
/// Alternative to EventSinkCollection. EventSinkCollection typically has O(n)
/// performance for additions. This trades off a little extra memory usage for
/// removed nodes in favor of O(1) addition time. Both implementations have take
/// O(n) for removal.
/// </summary>
sealed class HierarchyIdMap {
private readonly List<HierarchyNode> _ids = new List<HierarchyNode>();
private readonly Stack<int> _freedIds = new Stack<int>();
private readonly Dictionary<uint, HierarchyNode> _ids = new Dictionary<uint,HierarchyNode>();
private List<uint> _freedIds = new List<uint>();

public uint Add(HierarchyNode node) {
UIThread.MustBeCalledFromUIThread();

uint res;

if (_freedIds.Count > 0) {
var i = _freedIds.Pop();
_ids[i] = node;
return (uint)i;
res = _freedIds[_freedIds.Count - 1];
_freedIds.RemoveAt(_freedIds.Count - 1);
} else {
_ids.Add(node);
// ids are 1 based
return (uint)_ids.Count;
res = (uint)_ids.Count + 1;
}

_ids[res] = node;
return res;
}

public void Remove(HierarchyNode node) {
UIThread.MustBeCalledFromUIThread();

int i = (int)node.ID - 1;
if (0 <= i && i < _ids.Count && object.ReferenceEquals(node, _ids[i])) {
_ids[i] = null;
} else {
for (i = 0; i < _ids.Count; ++i) {
if (object.ReferenceEquals(node, _ids[i])) {
_ids[i] = null;
_freedIds.Push(i);
break;
}
foreach (var keyValue in _ids) {
if (keyValue.Value == node) {
_ids.Remove(keyValue.Key);
_freedIds.Add(keyValue.Key);
break;
}
}
}
Expand All @@ -54,11 +58,9 @@ public HierarchyNode this[uint itemId] {
get {
UIThread.MustBeCalledFromUIThread();

int i = (int)itemId - 1;
if (0 <= i && i < _ids.Count) {
return _ids[i];
}
return null;
HierarchyNode res;
_ids.TryGetValue(itemId, out res);
return res;
}
}

Expand Down
53 changes: 4 additions & 49 deletions Common/Product/SharedProject/OutputWindowRedirector.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,15 @@ class OutputWindowRedirector : Redirector {
private static readonly Guid OutputWindowGuid = new Guid("{34E76E81-EE4A-11D0-AE2E-00A0C90FFFC3}");
static OutputWindowRedirector _generalPane;

/// <summary>
/// Gets or creates the specified output pane.
/// </summary>
/// <exception cref="InvalidOperationException">The output pane could
/// not be found or created.</exception>
public static OutputWindowRedirector Get(IServiceProvider provider, Guid id, string title) {
var outputWindow = provider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
if (outputWindow == null) {
throw new InvalidOperationException("Unable to get output window service");
}

IVsOutputWindow outputWindow = provider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
IVsOutputWindowPane pane;
if (ErrorHandler.Failed(outputWindow.GetPane(id, out pane)) || pane == null) {
if (ErrorHandler.Failed(outputWindow.CreatePane(id, title, 1, 0))) {
throw new InvalidOperationException("Unable to create output pane");
}
ErrorHandler.ThrowOnFailure(outputWindow.CreatePane(id, title, 1, 0));
}
return new OutputWindowRedirector(provider, id);
}

/// <summary>
/// Gets or creates the "General" output pane.
/// </summary>
/// <exception cref="InvalidOperationException">The "General" pane could
/// not be found or created.</exception>
public static OutputWindowRedirector GetGeneral(IServiceProvider provider) {
if (_generalPane == null) {
_generalPane = Get(provider, VSConstants.OutputWindowPaneGuid.GeneralPane_guid, "General");
Expand All @@ -58,19 +42,6 @@ public static OutputWindowRedirector GetGeneral(IServiceProvider provider) {

public IVsOutputWindowPane Pane { get { return _pane; } }

/// <summary>
/// Creates a redirector to the specified output pane.
/// </summary>
/// <param name="provider">
/// An active service provider.
/// </param>
/// <param name="paneGuid">
/// The ID of the pane to direct output to.
/// </param>
/// <exception cref="InvalidOperationException">
/// The pane could not be found or the Output Window service is not
/// available.
/// </exception>
public OutputWindowRedirector(IServiceProvider provider, Guid paneGuid) {
var shell = provider.GetService(typeof(SVsUIShell)) as IVsUIShell;
if (shell != null) {
Expand All @@ -79,26 +50,10 @@ public OutputWindowRedirector(IServiceProvider provider, Guid paneGuid) {
var windowGuid = OutputWindowGuid;
shell.FindToolWindow(0, ref windowGuid, out _window);
}
var outputWindow = provider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
if (outputWindow == null) {
throw new InvalidOperationException("Unable to get output window service");
}
if (ErrorHandler.Failed(outputWindow.GetPane(paneGuid, out _pane))) {
throw new InvalidOperationException("Unable to get output pane");
}
IVsOutputWindow outputWindow = provider.GetService(typeof(SVsOutputWindow)) as IVsOutputWindow;
ErrorHandler.ThrowOnFailure(outputWindow.GetPane(paneGuid, out _pane));
}

/// <summary>
/// Creates a redirector to the specified output pane.
/// </summary>
/// <param name="window">
/// The window containing the pane. Optional, but if omitted then the
/// <see cref="Show"/> and <see cref="ShowAndActivate"/> methods become
/// no-ops.
/// </param>
/// <param name="pane">
/// The pane to direct output to.
/// </param>
public OutputWindowRedirector(IVsWindowFrame window, IVsOutputWindowPane pane) {
_window = window;
if (pane == null) {
Expand Down
4 changes: 2 additions & 2 deletions Common/Product/SharedProject/ProjectFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ namespace Microsoft.VisualStudioTools.Project {

public abstract class ProjectFactory : Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectFactoryBase,
#if DEV11_OR_LATER
IVsAsynchronousProjectCreate,
IVsAsynchronousProjectCreate,
IVsProjectUpgradeViaFactory4,
#endif
IVsProjectUpgradeViaFactory {
IVsProjectUpgradeViaFactory {
#region fields
private Microsoft.VisualStudio.Shell.Package package;
private System.IServiceProvider site;
Expand Down
15 changes: 4 additions & 11 deletions Common/Product/SharedProject/ProjectNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -597,8 +597,10 @@ public ImageHandler ImageHandler {
}
}

protected abstract Stream ProjectIconsImageStripStream {
get;
protected virtual Stream ProjectIconsImageStripStream {
get {
return typeof(ProjectNode).Assembly.GetManifestResourceStream("Microsoft.VisualStudioTools.Resources.Icons.SharedProjectImageList.bmp");
}
}

/// <summary>
Expand Down Expand Up @@ -4236,10 +4238,6 @@ public virtual int IsDocumentInProject(string mkDoc, out int found, VSDOCUMENTPR
found = 0;
itemId = 0;

// Debugger will pass in non-normalized paths for remote Linux debugging (produced by concatenating a local Windows-style path
// with a portion of the remote Unix-style path) - need to normalize to look it up.
mkDoc = CommonUtils.NormalizePath(mkDoc);

// If it is the project file just return.
if (CommonUtils.IsSamePath(mkDoc, this.GetMkDocument())) {
found = 1;
Expand Down Expand Up @@ -5667,16 +5665,11 @@ internal void OnInvalidateItems(HierarchyNode parent) {
}

foreach (IVsHierarchyEvents sink in _hierarchyEventSinks) {
bool wasExpanded = parent.GetIsExpanded();
int result = sink.OnInvalidateItems(parent.HierarchyId);

if (ErrorHandler.Failed(result) && result != VSConstants.E_NOTIMPL) {
ErrorHandler.ThrowOnFailure(result);
}

if (wasExpanded) {
parent.ExpandItem(EXPANDFLAGS.EXPF_ExpandFolder);
}
}
}

Expand Down
82 changes: 54 additions & 28 deletions Common/Product/SharedProject/ProjectReferenceNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,10 @@
* ***************************************************************************/

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;
using Microsoft.CSharp.RuntimeBinder;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;

Expand Down Expand Up @@ -118,15 +115,53 @@ internal EnvDTE.Project ReferencedProjectObject {

// Search for the project in the collection of the projects in the
// current solution.
var dte = (EnvDTE.DTE)ProjectMgr.GetService(typeof(EnvDTE.DTE));
if (null == dte || null == dte.Solution) {
EnvDTE.DTE dte = (EnvDTE.DTE)this.ProjectMgr.GetService(typeof(EnvDTE.DTE));
if ((null == dte) || (null == dte.Solution)) {
return null;
}
var unmodeled = new Guid(EnvDTE.Constants.vsProjectKindUnmodeled);
referencedProject = dte.Solution.Projects
.Cast<EnvDTE.Project>()
.Where(prj => !Utilities.GuidEquals(unmodeled, prj.Kind))
.FirstOrDefault(prj => CommonUtils.IsSamePath(referencedProjectFullPath, prj.FullName));
foreach (EnvDTE.Project prj in dte.Solution.Projects) {
//Skip this project if it is an umodeled project (unloaded)
if (string.Compare(EnvDTE.Constants.vsProjectKindUnmodeled, prj.Kind, StringComparison.OrdinalIgnoreCase) == 0) {
continue;
}

// Get the full path of the current project.
EnvDTE.Property pathProperty = null;
try {
if (prj.Properties == null) {
continue;
}

pathProperty = prj.Properties.Item("FullPath");
if (null == pathProperty) {
// The full path should alway be availabe, but if this is not the
// case then we have to skip it.
continue;
}
} catch (ArgumentException) {
continue;
}
string prjPath = pathProperty.Value.ToString();
EnvDTE.Property fileNameProperty = null;
// Get the name of the project file.
try {
fileNameProperty = prj.Properties.Item("FileName");
if (null == fileNameProperty) {
// Again, this should never be the case, but we handle it anyway.
continue;
}
} catch (ArgumentException) {
continue;
}
prjPath = Path.Combine(prjPath, fileNameProperty.Value.ToString());

// If the full path of this project is the same as the one of this
// reference, then we have found the right project.
if (CommonUtils.IsSamePath(prjPath, referencedProjectFullPath)) {
this.referencedProject = prj;
break;
}
}
}

return this.referencedProject;
Expand All @@ -151,14 +186,14 @@ internal string ReferencedProjectOutputPath {
if (null == confManager) {
return null;
}

// Get the active configuration.
EnvDTE.Configuration config = confManager.ActiveConfiguration;

if (null == config) {
return null;
}


if (null == config.Properties) {
return null;
}
Expand All @@ -177,28 +212,19 @@ internal string ReferencedProjectOutputPath {

// Now get the name of the assembly from the project.
// Some project system throw if the property does not exist. We expect an ArgumentException.
string outputName = null;
EnvDTE.Property assemblyNameProperty = null;
try {
outputName = this.ReferencedProjectObject.Properties.Item("OutputFileName").Value.ToString();
assemblyNameProperty = this.ReferencedProjectObject.Properties.Item("OutputFileName");
} catch (ArgumentException) {
} catch (NullReferenceException) {
}

if (outputName == null) {
try {
outputName = ((object[])config.OutputGroups.Item("Built").FileNames)
.OfType<string>()
.FirstOrDefault();
} catch (ArgumentException) {
} catch (NullReferenceException) {
} catch (InvalidCastException) {
}
if (null == assemblyNameProperty) {
return null;
}

// build the full path adding the name of the assembly to the output path.
return string.IsNullOrEmpty(outputName) ?
null :
CommonUtils.GetAbsoluteFilePath(outputPath, outputName);
outputPath = Path.Combine(outputPath, assemblyNameProperty.Value.ToString());

return outputPath;
}
}

Expand Down
3 changes: 1 addition & 2 deletions Common/Product/SharedProject/ProjectResources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,6 @@ internal class SR {
internal const string WebPiFeed = "WebPiFeed";
internal const string WebPiProduct = "WebPiProduct";
internal const string WebPiFeedDescription = "WebPiFeedDescription";
internal const string WebPiFeedError = "WebPiFeedError";
internal const string WebPiProductDescription = "WebPiProductDescription";
internal const string WebPiReferenceProperties = "WebPiReferenceProperties";
internal const string UnexpectedUpgradeError = "UnexpectedUpgradeError";
Expand Down Expand Up @@ -197,7 +196,7 @@ protected static string GetStringInternal(ResourceManager manager, string value,
}

Debug.WriteLineIf(
Enumerable.Range(0, args.Length).Any(i => result.IndexOf(string.Format("{{{0}}}", i)) < 0),
Enumerable.Range(0, args.Length).Any(i => result.IndexOf(string.Format("{{{0}}}", i)) >= 0),
string.Format("Resource string '{0}' does not use all {1} arguments", value, args.Length)
);
Debug.WriteLineIf(
Expand Down
5 changes: 0 additions & 5 deletions Common/Product/SharedProject/ProjectResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -611,9 +611,4 @@ Run Visual Studio with the /Log option and check ActivityLog.xml for more detail
<data name="AddReferenceExtensions" xml:space="preserve">
<value>Dynamic Link Libraries (*.dll)|*.dll|All Files (*.*)|*.*</value>
</data>
<data name="WebPiFeedError" xml:space="preserve">
<value>Unable to get feed "{0}".

{1}</value>
</data>
</root>
Loading

0 comments on commit 062aa3a

Please sign in to comment.