-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update existing repo: #122
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,7 +14,8 @@ namespace SourceBrowser.Generator.Transformers | |
public class TreeViewTransformer : AbstractWorkspaceVisitor | ||
{ | ||
private string _savePath; | ||
HtmlTextWriter _writer; | ||
private StreamWriter _sw; | ||
private HtmlTextWriter _writer; | ||
private readonly string _userNameAndRepoPrefix; | ||
|
||
private const string _treeViewOutputFile = "treeView.html"; | ||
|
@@ -34,20 +35,55 @@ public TreeViewTransformer(string savePath, string userName, string repoName) | |
|
||
protected override void VisitWorkspace(WorkspaceModel workspaceModel) | ||
{ | ||
using (var stringWriter = new StreamWriter(_savePath, false)) | ||
using(_writer = new HtmlTextWriter(stringWriter)) | ||
// The first WorkspaceModel that is visited is the root of the tree view | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't understand why this code had to change. This PR is making it possible to re-analyze solutions so I wouldn't think this would be a required change. |
||
// and its children are the solutions. | ||
|
||
bool disposeWriters = false; | ||
|
||
// Create the writers only if they're null | ||
if (_sw == null) | ||
{ | ||
_sw = new StreamWriter(_savePath, false); | ||
|
||
if (_writer != null) | ||
_writer.Dispose(); | ||
|
||
_writer = new HtmlTextWriter(_sw); | ||
|
||
disposeWriters = true; | ||
} | ||
|
||
if (disposeWriters) | ||
{ | ||
// The current WorkspaceModel is the root node, no need to increase the depth | ||
_writer.AddAttribute(HtmlTextWriterAttribute.Id, "browserTree"); | ||
_writer.AddAttribute(HtmlTextWriterAttribute.Class, "treeview"); | ||
_writer.AddAttribute("data-role", "treeview"); | ||
_writer.RenderBeginTag(HtmlTextWriterTag.Ul); | ||
|
||
} | ||
else | ||
{ | ||
// The current WorkspaceModel is a Child of the root node. | ||
depth++; | ||
base.VisitWorkspace(workspaceModel); | ||
depth--; | ||
} | ||
|
||
base.VisitWorkspace(workspaceModel); | ||
|
||
if (disposeWriters) | ||
{ | ||
// The current WorkspaceModel is the root node. | ||
// Every child has been visited: dispose the writers. | ||
|
||
disposeWriters = false; | ||
_writer.RenderEndTag(); | ||
_writer.WriteLine(); | ||
_writer.Dispose(); | ||
_sw.Dispose(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll address here your doubts about the changes in the the changes that I made to make the application able to process multiple solutions in the same repository were to process all the .sln files in parallel and when this processing was finished a new WorkspaceModel item was created and it's children were the WorkspaceModel resulted from the solutions. When the TreeViewTransformer visited the first WorkspaceModel (which is the root) it created the writers and then it invoked the base method, which recursively visited all the sub nodes. Anyway, what I wrote was more of a hack than a proper fix, so I'd like to use another approach: by restoring the TreeViewTransformer class as it was before of my changes, we can bypass the same problem by adding all the solutions' children to the root node, instead of the solutions' WorkspaceModels. So, in the // Add all the results to the root workspace model.
foreach (var workspace in processedWorkspaces)
rootWorkspaceModel.Children.Add(workspace);
// WorkspaceModel (root)
// - WorkspaceModel (sln1)
// - FolderModel
// - ...
// - WorkspaceModel (sln2)
// - FolderModel
// - ... with foreach (var children in processedWorkspaces.SelectMany(e => e.Children))
rootWorkspaceModel.Children.Add(children);
// WorkspaceModel (root)
// - FolderModel (from sln1's WorkspaceModel)
// - ...
// - FolderModel (from sln2's WorkspaceModel)
// - ... resulting in a single Please, give me your opinions about this. Thanks! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, I tried to solve this by adding the solutions' children to a new but then the navigation didn't work well because the relative paths didn't match the files in the treeview anymore. I'm thinking that this could be solved by navigating to a solution's treeview when you click on the solution's name, so basically when you go to /Browse/{user}/{repo} the treeview section shows the available solutions. But before going this path, I need your opinions. |
||
} | ||
else | ||
{ | ||
// The current WorkspaceModel is a Child of the root node. | ||
depth--; | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Weird, we're not even using this backing field
_workspaceModel
.