提交 9d951053 编写于 作者: A Andrew Casey

Use FilePath in VisualStudioWorkspaceImpl.AddDocumentToProjectItems

AddDocumentToProjectItems accepts a filePath argument but none of its
callers pass one, even though there's one on DocumentInfo.  If a
filePath is provided, don't attempt to retrieve the FULL_NAME from the
hierarchy to synthesize filePath.

Empirically, it looks like DocumentInfo.FilePath usually (always?)
returns null.

Context: we'd like to pass a non-null value in TypeScript as part of our
Move-to-File implementation.
上级 e3ced36b
......@@ -554,15 +554,15 @@ private void AddDocumentCore(DocumentInfo info, SourceText initialText, bool isA
if (IsWebsite(project))
{
AddDocumentToFolder(hostProject, project, info.Id, SpecializedCollections.SingletonEnumerable(AppCodeFolderName), info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument);
AddDocumentToFolder(hostProject, project, info.Id, SpecializedCollections.SingletonEnumerable(AppCodeFolderName), info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument, filePath: info.FilePath);
}
else if (folders.Any())
{
AddDocumentToFolder(hostProject, project, info.Id, folders, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument);
AddDocumentToFolder(hostProject, project, info.Id, folders, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument, filePath: info.FilePath);
}
else
{
AddDocumentToProject(hostProject, project, info.Id, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument);
AddDocumentToProject(hostProject, project, info.Id, info.Name, info.SourceCodeKind, initialText, isAdditionalDocument: isAdditionalDocument, filePath: info.FilePath);
}
var undoManager = TryGetUndoManager();
......@@ -644,7 +644,8 @@ protected override void AddExistingDocument(DocumentId documentId, string filePa
string filePath = null,
bool isAdditionalDocument = false)
{
if (!project.TryGetFullPath(out var folderPath))
string folderPath = null;
if (filePath == null && !project.TryGetFullPath(out folderPath))
{
// TODO(cyrusn): Throw an appropriate exception here.
throw new Exception(ServicesVSResources.Could_not_find_location_of_folder_on_disk);
......@@ -665,7 +666,9 @@ protected override void AddExistingDocument(DocumentId documentId, string filePa
bool isAdditionalDocument = false)
{
var folder = project.FindOrCreateFolder(folders);
if (!folder.TryGetFullPath(out var folderPath))
string folderPath = null;
if (filePath == null && !folder.TryGetFullPath(out folderPath))
{
// TODO(cyrusn): Throw an appropriate exception here.
throw new Exception(ServicesVSResources.Could_not_find_location_of_folder_on_disk);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册