logic: improved plugin performance

* reduced file open/close events while writing cdb
* fixed detection of header paths
* refactored Visual Studio extension code
* removed very old menu option for converting a solution directly into a Coati project (which would have been performed by Coati itself, not by the plugin).
This commit is contained in:
malte_langkabel
2017-06-12 12:10:48 +02:00
parent 148588b179
commit 72f3dcfc19
45 changed files with 1453 additions and 1582 deletions
+3 -2
View File
@@ -24,8 +24,9 @@
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin/bin /ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin/bin
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin/obj /ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin/obj
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin.IntegrationTests/bin/ /ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginTests/bin/Debug
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPlugin.IntegrationTests/obj /ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginTests/bin/Release
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginTests/obj
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginUtility/bin /ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginUtility/bin
/ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginUtility/obj /ide_plugins/vs/vs2015/SourcetrailPlugin/SourcetrailPluginUtility/obj
/ide_plugins/vs/vs2015/SourcetrailPlugin/VCProjectEngineWrapperInterfaces/bin /ide_plugins/vs/vs2015/SourcetrailPlugin/VCProjectEngineWrapperInterfaces/bin
Binary file not shown.
@@ -9,7 +9,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourcetrailPlugin", "Source
{8188D64D-E880-490C-B267-B493A2171BE3} = {8188D64D-E880-490C-B267-B493A2171BE3} {8188D64D-E880-490C-B267-B493A2171BE3} = {8188D64D-E880-490C-B267-B493A2171BE3}
EndProjectSection EndProjectSection
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourcetrailPlugin.IntegrationTests", "SourcetrailPlugin.IntegrationTests\SourcetrailPlugin.IntegrationTests.csproj", "{9DE8C188-0F0E-4F5D-B3C4-ECF9CFB23E0D}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SourcetrailPluginTests", "SourcetrailPluginTests\SourcetrailPluginTests.csproj", "{9DE8C188-0F0E-4F5D-B3C4-ECF9CFB23E0D}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCProjectEngineWrapperInterfaces", "VCProjectEngineWrapperInterfaces\VCProjectEngineWrapperInterfaces.csproj", "{F592DB46-0C77-470B-AAF8-80C51F44380E}" Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VCProjectEngineWrapperInterfaces", "VCProjectEngineWrapperInterfaces\VCProjectEngineWrapperInterfaces.csproj", "{F592DB46-0C77-470B-AAF8-80C51F44380E}"
EndProject EndProject
@@ -1,5 +1,6 @@
using System; using System;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using ComTypes = System.Runtime.InteropServices.ComTypes; using ComTypes = System.Runtime.InteropServices.ComTypes;
namespace ComUtils namespace ComUtils
@@ -1,7 +1,5 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading; using System.Threading;
using System.Threading.Tasks; using System.Threading.Tasks;
@@ -1,14 +1,12 @@
// PkgCmdID.cs // PkgCmdID.cs
// MUST match PkgCmdID.h // MUST match PkgCmdID.h
using System;
namespace CoatiSoftware.SourcetrailPlugin namespace CoatiSoftware.SourcetrailPlugin
{ {
static class PkgCmdIDList static class PkgCmdIDList
{ {
public const uint cmdidSourcetrailSetActiveToken = 0x104; public const uint cmdidSourcetrailSetActiveToken = 0x104;
public const uint cmdidSourcetrailCreateProject = 0x105; public const uint cmdidSourcetrailCreateCdb = 0x106;
public const uint cmdidSourcetrailCreateCDB = 0x106;
public const uint cmdidSourcetrailOpenLogFolder = 0x107; public const uint cmdidSourcetrailOpenLogFolder = 0x107;
}; };
@@ -1,11 +1,5 @@
using System.Collections.Generic; using Newtonsoft.Json;
using System.Xml.Serialization; using System.Collections.Generic;
using System.Xml;
using Newtonsoft.Json.Linq;
using System.IO;
using System.Threading;
using System;
using Newtonsoft.Json;
namespace CoatiSoftware.SourcetrailPlugin.SolutionParser namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
{ {
@@ -13,75 +7,72 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
{ {
private List<CompileCommand> _compileCommands = new List<CompileCommand>(); private List<CompileCommand> _compileCommands = new List<CompileCommand>();
// meta data private bool TryLoadData(string filePath)
private string _name = "";
private string _sourceProject = "";
private string _directory = "";
private System.DateTime _lastUpdated = new System.DateTime();
private List<string> _includedProjects = new List<string>();
private string _configurationName = "";
private string _platformName = "";
public string Name
{ {
get { return _name; } if (filePath.Length > 0)
set { _name = value; } {
if (System.IO.File.Exists(filePath))
{
string data = "";
using (System.IO.StreamReader file = new System.IO.StreamReader(filePath))
{
string line = "";
while ((line = file.ReadLine()) != null)
{
data += line;
}
}
DeserializeFromJson(data);
return true;
}
else
{
Logging.Logging.LogError("The cdb file at \"" + filePath + "\" does not exist.");
}
}
else
{
Logging.Logging.LogWarning("Can't load cdb data. Filepath has not been set.");
}
return false;
} }
public string SourceProject
{
get { return _sourceProject; }
set { _sourceProject = value; }
}
public string Directory
{
get { return _directory; }
set { _directory = value; }
}
public System.DateTime LastUpdated
{
get { return _lastUpdated; }
set { _lastUpdated = value; }
}
public List<string> IncludedProjects
{
get { return _includedProjects; }
set { _includedProjects = value; }
}
public string ConfigurationName
{
get { return _configurationName; }
set { _configurationName = value; }
}
public string PlatformName
{
get { return _platformName; }
set { _platformName = value; }
}
public int CompileCommandCount
{
get { return _compileCommands.Count; }
}
public static CompilationDatabase LoadFromFile(string filePath) public static CompilationDatabase LoadFromFile(string filePath)
{ {
CompilationDatabase cdb = new CompilationDatabase(); CompilationDatabase cdb = new CompilationDatabase();
cdb.Name = Path.GetFileNameWithoutExtension(filePath); bool success = cdb.TryLoadData(filePath);
cdb.Directory = Path.GetDirectoryName(filePath);
bool success = cdb.TryLoadData();
return cdb; return cdb;
} }
public string SerializeToJson()
{
return JsonConvert.SerializeObject(_compileCommands, Newtonsoft.Json.Formatting.Indented);
}
public void DeserializeFromJson(string serialized)
{
_compileCommands.Clear();
if (serialized.Length > 0)
{
_compileCommands = JsonConvert.DeserializeObject<List<CompileCommand>>(serialized);
}
}
public int CompileCommandCount
{
get { return _compileCommands.Count; }
}
public static bool operator ==(CompilationDatabase a, CompilationDatabase b) public static bool operator ==(CompilationDatabase a, CompilationDatabase b)
{ {
if (System.Object.ReferenceEquals(a, b)) if (System.Object.ReferenceEquals(a, b))
@@ -116,257 +107,19 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
return !(a == b); return !(a == b);
} }
public void AddCommandObject(CompileCommand commandObject) public void AddCompileCommand(CompileCommand commandObject)
{ {
_compileCommands.Add(commandObject); // updating is not efficient as it is _compileCommands.Add(commandObject);
} }
// remove commandObjects for removed files public void SortAlphabetically()
public void Clean()
{ {
for (int i = 0; i < _compileCommands.Count; i++) _compileCommands.Sort((c1, c2) => c1.File.CompareTo(c2.File));
{
if (System.IO.File.Exists(_compileCommands[i].File) == false)
{
_compileCommands.RemoveAt(i);
i--;
}
}
} }
public void ClearCommandObjects() public void Clear()
{ {
_compileCommands.Clear(); _compileCommands.Clear();
} }
public bool CheckCDBExists()
{
if (_directory.Length > 0 && _name.Length > 0)
{
string path = GetFilePath();
if(System.IO.File.Exists(path) == false)
{
_lastUpdated = System.DateTime.MinValue; // if file is missing, set date way back so it doesn't interfere with re-building
return false;
}
else
{
return true;
}
}
else
{
Logging.Logging.LogWarning("Can't check cdb data, directory and/or name has not been set: directory - '" + _directory + "', name - '" + _name + "'");
}
return false;
}
public bool TryLoadData()
{
if(_directory.Length > 0 && _name.Length > 0)
{
string path = GetFilePath();
if(System.IO.File.Exists(path))
{
string data = "";
using (System.IO.StreamReader file = new System.IO.StreamReader(path))
{
string line = "";
while ((line = file.ReadLine()) != null)
{
data += line;
}
}
DeserializeFromJson(data);
return true;
}
else
{
_lastUpdated = System.DateTime.MinValue; // if file is missing, set date way back so it doesn't interfere with re-building
Logging.Logging.LogError("The cdb file '" + path + "' does not exist.");
}
}
else
{
Logging.Logging.LogWarning("Can't load cdb data, directory and/or name has not been set: directory - '" + _directory + "', name - '" + _name + "'");
}
return false;
}
public void UnloadData()
{
_compileCommands.Clear();
}
public string SerializeToJson()
{
return JsonConvert.SerializeObject(_compileCommands, Newtonsoft.Json.Formatting.Indented);
}
public void DeserializeFromJson(string serialized)
{
_compileCommands.Clear();
if (serialized.Length > 0)
{
_compileCommands = JsonConvert.DeserializeObject<List<CompileCommand>>(serialized);
}
}
public XmlNode GetMetaDataXML(XmlDocument doc)
{
// XmlDocument doc = new XmlDocument();
XmlNode root = doc.CreateElement("cdb");
XmlElement name = doc.CreateElement("name");
name.InnerText = _name;
XmlElement sourceProject = doc.CreateElement("sourceProject");
sourceProject.InnerText = _sourceProject;
XmlElement directory = doc.CreateElement("directory");
directory.InnerText = _directory;
XmlElement lastUpdated = doc.CreateElement("lastUpdated");
lastUpdated.InnerText = _lastUpdated.ToString();
XmlElement includedProjects = doc.CreateElement("includedProjects");
foreach (string project in _includedProjects)
{
XmlElement includedProject = doc.CreateElement("includedProject");
includedProject.InnerText = project;
includedProjects.AppendChild(includedProject);
}
XmlElement configuration = doc.CreateElement("configuration");
configuration.InnerText = _configurationName;
XmlElement platform = doc.CreateElement("platform");
platform.InnerText = _platformName;
root.AppendChild(name);
root.AppendChild(sourceProject);
root.AppendChild(directory);
root.AppendChild(lastUpdated);
root.AppendChild(includedProjects);
root.AppendChild(configuration);
root.AppendChild(platform);
return root;
}
public string SerializeMetaDataXML()
{
XmlDocument doc = new XmlDocument();
XmlNode root = GetMetaDataXML(doc);
System.IO.StringWriter writer = new System.IO.StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(XmlElement));
serializer.Serialize(writer, root);
return writer.ToString();
}
public static List<CompilationDatabase> ParseCDBsMetaData(string data)
{
List<CompilationDatabase> cdbs = new List<CompilationDatabase>();
if(data.Length > 0)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(data);
XmlNode root = doc.SelectSingleNode("cdbs");
XmlNodeList nodes = root.SelectNodes("cdb");
foreach (XmlNode node in nodes)
{
cdbs.Add(ParseCDBMetaData(node));
}
}
return cdbs;
}
public static CompilationDatabase ParseCDBMetaData(XmlNode node)
{
CompilationDatabase cdb = new CompilationDatabase();
XmlNode nameNode = node.SelectSingleNode("name");
string name = nameNode.InnerText;
XmlNode sourceNode = node.SelectSingleNode("sourceProject");
string source = sourceNode.InnerText;
XmlNode directoryNode = node.SelectSingleNode("directory");
string directory = directoryNode.InnerText;
XmlNode updatedNode = node.SelectSingleNode("lastUpdated");
string updated = updatedNode.InnerText;
System.DateTime updatedDate;
if(System.DateTime.TryParse(updated, out updatedDate) == false)
{
updatedDate = System.DateTime.MinValue;
}
XmlNode includedProjects = node.SelectSingleNode("includedProjects");
XmlNodeList includedProjectNodes = includedProjects.SelectNodes("includedProject");
List<string> includedProjectsList = new List<string>();
foreach(XmlNode p in includedProjectNodes)
{
includedProjectsList.Add(p.InnerText);
}
XmlNode configurationNode = node.SelectSingleNode("configuration");
string configuration = configurationNode.InnerText;
XmlNode platformNode = node.SelectSingleNode("platform");
string platform = platformNode.InnerText;
// if cdb file is not there anymore, set the modified date back so that a full update will be performed
if(System.IO.File.Exists(directory + "\\" + name + ".json") == false)
{
updatedDate = System.DateTime.MinValue;
}
cdb.Name = name;
cdb.SourceProject = source;
cdb.Directory = directory;
cdb.LastUpdated = updatedDate;
cdb.IncludedProjects = includedProjectsList;
cdb.ConfigurationName = configuration;
cdb.PlatformName = platform;
return cdb;
}
private bool TryUpdateCommandObject(CompileCommand co)
{
CompileCommand old = _compileCommands.Find(x => x.File == co.File);
if(old != null)
{
_compileCommands.Remove(old);
_compileCommands.Add(co);
return true;
}
return false;
}
private string GetFilePath()
{
return _directory + "\\" + _name + ".json";
}
} }
} }
@@ -0,0 +1,218 @@
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
{
public class CompilationDatabaseSettings
{
private string _name = "";
private string _sourceProject = "";
private string _directory = "";
private System.DateTime _lastUpdated = new System.DateTime();
private List<string> _includedProjects = new List<string>();
private string _configurationName = "";
private string _platformName = "";
public string Name
{
get { return _name; }
set { _name = value; }
}
public string SourceProject
{
get { return _sourceProject; }
set { _sourceProject = value; }
}
public string Directory
{
get { return _directory; }
set { _directory = value; }
}
public System.DateTime LastUpdated
{
get { return _lastUpdated; }
set { _lastUpdated = value; }
}
public List<string> IncludedProjects
{
get { return _includedProjects; }
set { _includedProjects = value; }
}
public string ConfigurationName
{
get { return _configurationName; }
set { _configurationName = value; }
}
public string PlatformName
{
get { return _platformName; }
set { _platformName = value; }
}
public bool CheckCdbExists()
{
if (_directory.Length > 0 && _name.Length > 0)
{
string path = GetFilePath();
if(System.IO.File.Exists(path) == false)
{
_lastUpdated = System.DateTime.MinValue; // if file is missing, set date way back so it doesn't interfere with re-building
return false;
}
else
{
return true;
}
}
else
{
Logging.Logging.LogWarning("Can't check cdb data, directory and/or name has not been set: directory - '" + _directory + "', name - '" + _name + "'");
}
return false;
}
public XmlNode GetMetaDataXML(XmlDocument doc)
{
// XmlDocument doc = new XmlDocument();
XmlNode root = doc.CreateElement("cdb");
XmlElement name = doc.CreateElement("name");
name.InnerText = _name;
XmlElement sourceProject = doc.CreateElement("sourceProject");
sourceProject.InnerText = _sourceProject;
XmlElement directory = doc.CreateElement("directory");
directory.InnerText = _directory;
XmlElement lastUpdated = doc.CreateElement("lastUpdated");
lastUpdated.InnerText = _lastUpdated.ToString();
XmlElement includedProjects = doc.CreateElement("includedProjects");
foreach (string project in _includedProjects)
{
XmlElement includedProject = doc.CreateElement("includedProject");
includedProject.InnerText = project;
includedProjects.AppendChild(includedProject);
}
XmlElement configuration = doc.CreateElement("configuration");
configuration.InnerText = _configurationName;
XmlElement platform = doc.CreateElement("platform");
platform.InnerText = _platformName;
root.AppendChild(name);
root.AppendChild(sourceProject);
root.AppendChild(directory);
root.AppendChild(lastUpdated);
root.AppendChild(includedProjects);
root.AppendChild(configuration);
root.AppendChild(platform);
return root;
}
public string SerializeMetaDataXML()
{
XmlDocument doc = new XmlDocument();
XmlNode root = GetMetaDataXML(doc);
System.IO.StringWriter writer = new System.IO.StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(XmlElement));
serializer.Serialize(writer, root);
return writer.ToString();
}
public static List<CompilationDatabaseSettings> ParseCdbsMetaData(string data)
{
List<CompilationDatabaseSettings> cdbs = new List<CompilationDatabaseSettings>();
if(data.Length > 0)
{
XmlDocument doc = new XmlDocument();
doc.LoadXml(data);
XmlNode root = doc.SelectSingleNode("cdbs");
XmlNodeList nodes = root.SelectNodes("cdb");
foreach (XmlNode node in nodes)
{
cdbs.Add(ParseCdbMetaData(node));
}
}
return cdbs;
}
public static CompilationDatabaseSettings ParseCdbMetaData(XmlNode node)
{
CompilationDatabaseSettings cdb = new CompilationDatabaseSettings();
XmlNode nameNode = node.SelectSingleNode("name");
string name = nameNode.InnerText;
XmlNode sourceNode = node.SelectSingleNode("sourceProject");
string source = sourceNode.InnerText;
XmlNode directoryNode = node.SelectSingleNode("directory");
string directory = directoryNode.InnerText;
XmlNode updatedNode = node.SelectSingleNode("lastUpdated");
string updated = updatedNode.InnerText;
System.DateTime updatedDate;
if(System.DateTime.TryParse(updated, out updatedDate) == false)
{
updatedDate = System.DateTime.MinValue;
}
XmlNode includedProjects = node.SelectSingleNode("includedProjects");
XmlNodeList includedProjectNodes = includedProjects.SelectNodes("includedProject");
List<string> includedProjectsList = new List<string>();
foreach(XmlNode p in includedProjectNodes)
{
includedProjectsList.Add(p.InnerText);
}
XmlNode configurationNode = node.SelectSingleNode("configuration");
string configuration = configurationNode.InnerText;
XmlNode platformNode = node.SelectSingleNode("platform");
string platform = platformNode.InnerText;
// if cdb file is not there anymore, set the modified date back so that a full update will be performed
if(System.IO.File.Exists(directory + "\\" + name + ".json") == false)
{
updatedDate = System.DateTime.MinValue;
}
cdb.Name = name;
cdb.SourceProject = source;
cdb.Directory = directory;
cdb.LastUpdated = updatedDate;
cdb.IncludedProjects = includedProjectsList;
cdb.ConfigurationName = configuration;
cdb.PlatformName = platform;
return cdb;
}
private string GetFilePath()
{
return _directory + "\\" + _name + ".json";
}
}
}
@@ -1,5 +1,4 @@
 using Newtonsoft.Json;
using Newtonsoft.Json;
namespace CoatiSoftware.SourcetrailPlugin.SolutionParser namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
{ {
@@ -1,11 +1,10 @@
using System; using CoatiSoftware.SourcetrailPlugin.Utility;
using System.Collections.Generic;
using System.Linq;
using EnvDTE; using EnvDTE;
using System;
using System.IO; using System.Collections.Generic;
using System.Diagnostics; using System.Diagnostics;
using CoatiSoftware.SourcetrailPlugin.Utility; using System.IO;
using System.Linq;
using VCProjectEngineWrapper; using VCProjectEngineWrapper;
namespace CoatiSoftware.SourcetrailPlugin.SolutionParser namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
@@ -15,7 +14,8 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
static private List<Guid> _reloadedProjectGuids = new List<Guid>(); static private List<Guid> _reloadedProjectGuids = new List<Guid>();
static private List<string> _compatibilityFlags = new List<string>() { "-fms-extensions", "-fms-compatibility" }; static private List<string> _compatibilityFlags = new List<string>() { "-fms-extensions", "-fms-compatibility" };
static private string _compatibilityVersionFlagBase = "-fms-compatibility-version="; // We want to get the exact version at runtime for this flag, therefore keeping it seperate from the others makes things easier static private string _compatibilityVersionFlagBase = "-fms-compatibility-version="; // We want to get the exact version at runtime for this flag, therefore keeping it seperate from the others makes things easier
static private List<string> _extensionWhiteList = new List<string>() { "c", "cc", "cpp", "cxx", "C", "h", "hpp" }; static private List<string> _sourceExtensionWhiteList = new List<string>() { "c", "cc", "cpp", "cxx" };
static private List<string> _headerExtensionWhiteList = new List<string>() { "h", "hpp" };
private string _compatibilityVersionFlag = _compatibilityVersionFlagBase + "19"; // This default version would correspond to VS2015 private string _compatibilityVersionFlag = _compatibilityVersionFlagBase + "19"; // This default version would correspond to VS2015
@@ -35,7 +35,7 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
public List<CompileCommand> CreateCompileCommands(Project project, string configurationName, string platformName, string cStandard) public List<CompileCommand> CreateCompileCommands(Project project, string configurationName, string platformName, string cStandard)
{ {
Logging.Logging.LogInfo("Creating command objects from project " + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name)); Logging.Logging.LogInfo("Creating command objects for project \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "\".");
List<CompileCommand> result = new List<CompileCommand>(); List<CompileCommand> result = new List<CompileCommand>();
@@ -43,13 +43,13 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
Guid projectGuid = Utility.ProjectUtility.ReloadProject(project); Guid projectGuid = Utility.ProjectUtility.ReloadProject(project);
IVCProjectWrapper vcProject = VCProjectEngineWrapper.VCProjectWrapperFactory.create(project.Object); IVCProjectWrapper vcProject = VCProjectEngineWrapper.VCProjectWrapperFactory.create(project.Object);
if (vcProject.isValid()) if (vcProject != null && vcProject.isValid())
{ {
Logging.Logging.LogInfo("Project '" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "' has been converted to VCProject " + vcProject.GetWrappedVersion() + "."); Logging.Logging.LogInfo("Project \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "\" has been converted to VCProject " + vcProject.GetWrappedVersion() + ".");
} }
else else
{ {
Logging.Logging.LogWarning("Project '" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "' could not be converted to VCProject, skipping."); Logging.Logging.LogWarning("Project \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(project.Name) + "\" could not be converted to VCProject, skipping.");
return result; return result;
} }
@@ -84,7 +84,7 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
private CompileCommand CreateCompileCommand(EnvDTE.ProjectItem item, List<string> includeDirectories, List<string> preprocessorDefinitions, string vcStandard, string cStandard, string configurationName, string platformName) private CompileCommand CreateCompileCommand(EnvDTE.ProjectItem item, List<string> includeDirectories, List<string> preprocessorDefinitions, string vcStandard, string cStandard, string configurationName, string platformName)
{ {
Logging.Logging.LogInfo("Starting to create Command Object from item '" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(item.Name) + "'"); Logging.Logging.LogInfo("Starting to create Command Object from item \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(item.Name) + "\"");
try try
{ {
@@ -116,34 +116,11 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
Logging.Logging.LogInfo("Unable to retrieve build tool. Using extension white-list to determine file type."); Logging.Logging.LogInfo("Unable to retrieve build tool. Using extension white-list to determine file type.");
} }
if (IsSourceFile(item, compilerTool)) if (CheckIsSourceFile(item, compilerTool))
{ {
CompileCommand command = new CompileCommand(); CompileCommand command = new CompileCommand();
command.File = item.Name; command.File = item.Name;
// only write source files to cdb, headers are implicit
// however, retreive header directory
if (CheckIsHeader(item))
{
Properties props = item.Properties;
foreach (Property prop in props)
{
string propName = prop.Name;
string propValue = prop.Value as String;
if (propName == "FullPath")
{
int i = propValue.LastIndexOf('\\');
propValue = propValue.Substring(0, i);
_headerDirectories.Add(propValue);
}
}
return null;
}
string additionalOptions = ""; string additionalOptions = "";
if (compilerTool != null && compilerTool.isValid()) if (compilerTool != null && compilerTool.isValid())
{ {
@@ -202,6 +179,20 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
return command; return command;
} }
else if (CheckIsHeaderFile(item, compilerTool))
{
if (ProjectUtility.HasProperty(item.Properties, "FullPath"))
{
string propValue = item.Properties.Item("FullPath").Value.ToString();
int i = propValue.LastIndexOf('\\');
propValue = propValue.Substring(0, i);
_headerDirectories.Add(propValue);
}
return null;
}
else else
{ {
Logging.Logging.LogInfo("Item discarded, wrong code model"); Logging.Logging.LogInfo("Item discarded, wrong code model");
@@ -217,7 +208,7 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
return null; return null;
} }
static private bool IsSourceFile(ProjectItem item, IVCCLCompilerToolWrapper tool) static private bool CheckIsSourceFile(ProjectItem item, IVCCLCompilerToolWrapper tool)
{ {
if (tool != null && tool.isValid()) // if the tool is null it's probably not a normal VC project, indicating that the file code model is unavailable if (tool != null && tool.isValid()) // if the tool is null it's probably not a normal VC project, indicating that the file code model is unavailable
{ {
@@ -244,7 +235,7 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
return true; return true;
} }
} }
else if (_extensionWhiteList.Contains(GetFileExtension(item))) else if (_sourceExtensionWhiteList.Contains(GetFileExtension(item).ToLower()))
{ {
return true; return true;
} }
@@ -252,35 +243,28 @@ namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
return false; return false;
} }
static private bool CheckIsHeader(EnvDTE.ProjectItem item) static private bool CheckIsHeaderFile(EnvDTE.ProjectItem item, IVCCLCompilerToolWrapper tool)
{ {
Properties props = item.Properties; if (tool != null && tool.isValid()) // if the tool is null it's probably not a normal VC project, indicating that the file code model is unavailable
string propString = "";
try
{ {
foreach (Property prop in props) try
{ {
string propName = prop.Name; if (ProjectUtility.HasProperty(item.Properties, "ItemType") && item.Properties.Item("ItemType").Value.ToString() == "ClInclude")
string propValue = prop.Value as String;
propString += propName + " - " + propValue + "; ";
if (propName == "ItemType")
{ {
if (propValue as String == "ClInclude") Logging.Logging.LogInfo("Accepting item because of its \"ItemType\" property");
{ return true;
return true;
}
} }
} }
catch (Exception e)
{
Logging.Logging.LogError("Exception: " + e.Message);
}
} }
catch (Exception e) else if (_headerExtensionWhiteList.Contains(GetFileExtension(item).ToLower()))
{ {
Logging.Logging.LogError("Exception: " + e.Message); return true;
} }
return false; return false;
} }
@@ -1,5 +1,5 @@
using System; using CoatiSoftware.SourcetrailPlugin.Utility;
using CoatiSoftware.SourcetrailPlugin.Utility; using System;
using VCProjectEngineWrapper; using VCProjectEngineWrapper;
namespace CoatiSoftware.SourcetrailPlugin.SolutionParser namespace CoatiSoftware.SourcetrailPlugin.SolutionParser
@@ -139,9 +139,10 @@
<ItemGroup> <ItemGroup>
<Compile Include="ComUtils.cs" /> <Compile Include="ComUtils.cs" />
<Compile Include="Multitasking\LimitedThreadsTaskScheduler.cs" /> <Compile Include="Multitasking\LimitedThreadsTaskScheduler.cs" />
<Compile Include="SolutionParser\CompilationDatabase.cs" />
<Compile Include="Utility\IPathResolver.cs" /> <Compile Include="Utility\IPathResolver.cs" />
<Compile Include="SolutionParser\VsPathResolver.cs" /> <Compile Include="SolutionParser\VsPathResolver.cs" />
<Compile Include="Utility\CompilationDatabaseList.cs" /> <Compile Include="Utility\CompilationDatabaseSettingsList.cs" />
<Compile Include="Utility\DataUtility.cs" /> <Compile Include="Utility\DataUtility.cs" />
<Compile Include="Utility\FileUtility.cs" /> <Compile Include="Utility\FileUtility.cs" />
<Compile Include="Guids.cs" /> <Compile Include="Guids.cs" />
@@ -158,25 +159,25 @@
</Compile> </Compile>
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="PkgCmdID.cs" /> <Compile Include="PkgCmdID.cs" />
<Compile Include="SolutionParser\CommandObject.cs" /> <Compile Include="SolutionParser\CompileCommand.cs" />
<Compile Include="SolutionParser\CompilationDatabase.cs" /> <Compile Include="SolutionParser\CompilationDatabaseSettings.cs" />
<Compile Include="SolutionParser\SolutionParser.cs" /> <Compile Include="SolutionParser\SolutionParser.cs" />
<Compile Include="Utility\ProjectUtility.cs" /> <Compile Include="Utility\ProjectUtility.cs" />
<Compile Include="Utility\QueuedFileWriter.cs" /> <Compile Include="Utility\QueuedFileWriter.cs" />
<Compile Include="Utility\SolutionUtility.cs" /> <Compile Include="Utility\SolutionUtility.cs" />
<Compile Include="Utility\SystemUtility.cs" /> <Compile Include="Utility\SystemUtility.cs" />
<Compile Include="Utility\StringUtility.cs" /> <Compile Include="Utility\StringUtility.cs" />
<Compile Include="Wizard\WindowCDBReady.cs"> <Compile Include="Wizard\WindowCdbReady.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Wizard\WindowCDBReady.Designer.cs"> <Compile Include="Wizard\WindowCdbReady.Designer.cs">
<DependentUpon>WindowCDBReady.cs</DependentUpon> <DependentUpon>WindowCdbReady.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Wizard\WindowCreateCDB.cs"> <Compile Include="Wizard\WindowCreateCdb.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="Wizard\WindowCreateCDB.Designer.cs"> <Compile Include="Wizard\WindowCreateCdb.Designer.cs">
<DependentUpon>WindowCreateCDB.cs</DependentUpon> <DependentUpon>WindowCreateCdb.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="Wizard\ProjectSetupWindow.cs"> <Compile Include="Wizard\ProjectSetupWindow.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
@@ -202,11 +203,11 @@
<ManifestResourceName>VSPackage</ManifestResourceName> <ManifestResourceName>VSPackage</ManifestResourceName>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Wizard\WindowCDBReady.resx"> <EmbeddedResource Include="Wizard\WindowCdbReady.resx">
<DependentUpon>WindowCDBReady.cs</DependentUpon> <DependentUpon>WindowCdbReady.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Wizard\WindowCreateCDB.resx"> <EmbeddedResource Include="Wizard\WindowCreateCdb.resx">
<DependentUpon>WindowCreateCDB.cs</DependentUpon> <DependentUpon>WindowCreateCdb.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="Wizard\ProjectSetupWindow.resx"> <EmbeddedResource Include="Wizard\ProjectSetupWindow.resx">
<DependentUpon>ProjectSetupWindow.cs</DependentUpon> <DependentUpon>ProjectSetupWindow.cs</DependentUpon>
@@ -257,6 +258,22 @@
<Project>{f592db46-0c77-470b-aaf8-80c51f44380e}</Project> <Project>{f592db46-0c77-470b-aaf8-80c51f44380e}</Project>
<Name>VCProjectEngineWrapperInterfaces</Name> <Name>VCProjectEngineWrapperInterfaces</Name>
</ProjectReference> </ProjectReference>
<ProjectReference Include="..\VCProjectEngineWrapper\VCProjectEngineWrapperVs2012.csproj">
<Project>{c5439b90-42e7-414d-8c3f-bdcabb0592e2}</Project>
<Name>VCProjectEngineWrapperVs2012</Name>
</ProjectReference>
<ProjectReference Include="..\VCProjectEngineWrapper\VCProjectEngineWrapperVs2013.csproj">
<Project>{8718929c-5270-4e5a-8998-48ac7ce19dc2}</Project>
<Name>VCProjectEngineWrapperVs2013</Name>
</ProjectReference>
<ProjectReference Include="..\VCProjectEngineWrapper\VCProjectEngineWrapperVs2015.csproj">
<Project>{1c139999-9592-4891-aa62-2c8a16430d0a}</Project>
<Name>VCProjectEngineWrapperVs2015</Name>
</ProjectReference>
<ProjectReference Include="..\VCProjectEngineWrapper\VCProjectEngineWrapperVs2017.csproj">
<Project>{b49207f9-89a3-42d8-bc04-8bf77ed2e295}</Project>
<Name>VCProjectEngineWrapperVs2017</Name>
</ProjectReference>
</ItemGroup> </ItemGroup>
<PropertyGroup> <PropertyGroup>
<UseCodebase>true</UseCodebase> <UseCodebase>true</UseCodebase>
@@ -8,7 +8,7 @@
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<StartAction>Program</StartAction> <StartAction>Program</StartAction>
<StartProgram>D:\programme\Microsoft Visual Studio14\Common7\IDE\devenv.exe</StartProgram> <StartProgram>D:\programme\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.exe</StartProgram>
<StartArguments>/rootsuffix Exp</StartArguments> <StartArguments>/rootsuffix Exp</StartArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup> <PropertyGroup>
@@ -62,11 +62,11 @@
</Strings> </Strings>
</Button> </Button>
<Button guid="guidSourcetrailPluginCmdSet" id="cmdidSourcetrailCreateCDB" priority="0x0100" type="Button"> <Button guid="guidSourcetrailPluginCmdSet" id="cmdidSourcetrailCreateCdb" priority="0x0100" type="Button">
<Parent guid="guidSourcetrailPluginCmdSet" id="SubMenu" /> <Parent guid="guidSourcetrailPluginCmdSet" id="SubMenu" />
<Icon guid="icon" id="icon0" /> <Icon guid="icon" id="icon0" />
<Strings> <Strings>
<ButtonText>Create CDB</ButtonText> <ButtonText>Create Compilation Database</ButtonText>
</Strings> </Strings>
</Button> </Button>
@@ -129,8 +129,7 @@
<IDSymbol name="cmdidSourcetrailGetActiveFileName" value="0x0102"/> <IDSymbol name="cmdidSourcetrailGetActiveFileName" value="0x0102"/>
<IDSymbol name="cmdidSourcetrailGetActiveLineNumber" value="0x0103"/> <IDSymbol name="cmdidSourcetrailGetActiveLineNumber" value="0x0103"/>
<IDSymbol name="cmdidSourcetrailSetActiveToken" value="0x0104"/> <IDSymbol name="cmdidSourcetrailSetActiveToken" value="0x0104"/>
<IDSymbol name="cmdidSourcetrailCreateProject" value="0x0105"/> <IDSymbol name="cmdidSourcetrailCreateCdb" value="0x0106"/>
<IDSymbol name="cmdidSourcetrailCreateCDB" value="0x0106"/>
<IDSymbol name="cmdidSourcetrailOpenLogFolder" value="0x0107"/> <IDSymbol name="cmdidSourcetrailOpenLogFolder" value="0x0107"/>
<IDSymbol name="TopLevelMenu" value="0x1021"/> <IDSymbol name="TopLevelMenu" value="0x1021"/>
<IDSymbol name="SubMenu" value="0x1022"/> <IDSymbol name="SubMenu" value="0x1022"/>
@@ -1,14 +1,12 @@
using System; using EnvDTE;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using System;
using System.Collections.Generic;
using System.IO;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.ComponentModel; using System.ComponentModel;
using System.ComponentModel.Design; using System.ComponentModel.Design;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio.Shell;
using System.Collections.Generic;
using EnvDTE;
using System.IO;
namespace CoatiSoftware.SourcetrailPlugin namespace CoatiSoftware.SourcetrailPlugin
{ {
@@ -122,15 +120,14 @@ namespace CoatiSoftware.SourcetrailPlugin
public sealed class SourcetrailPluginPackage : Package public sealed class SourcetrailPluginPackage : Package
{ {
private MenuCommand _menuItemSetActiveToken = null; private MenuCommand _menuItemSetActiveToken = null;
private MenuCommand _menuItemCreateProject = null; private MenuCommand _menuItemCreateCdb = null;
private MenuCommand _menuItemCreateCDB = null;
private MenuCommand _menuItemOpenLogDir = null; private MenuCommand _menuItemOpenLogDir = null;
private SolutionEvents _solutionEvents = null; private SolutionEvents _solutionEvents = null;
private bool _validSolutionLoaded = false; private bool _validSolutionLoaded = false;
Utility.CompilationDatabaseList _cdbList = new Utility.CompilationDatabaseList(); Utility.CompilationDatabaseSettingsList _recentSettingsList = new Utility.CompilationDatabaseSettingsList();
public uint ServerPort public uint ServerPort
{ {
@@ -201,26 +198,22 @@ namespace CoatiSoftware.SourcetrailPlugin
// register the plugin UI elements // register the plugin UI elements
OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService; OleMenuCommandService mcs = GetService(typeof(IMenuCommandService)) as OleMenuCommandService;
if ( null != mcs ) if (null != mcs)
{ {
CommandID setActiveTokenCommandID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailSetActiveToken); CommandID setActiveTokenCommandID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailSetActiveToken);
CommandID createProjectID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailCreateProject); CommandID createCdbID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailCreateCdb);
CommandID createCDBID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailCreateCDB);
CommandID openLogDirID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailOpenLogFolder); CommandID openLogDirID = new CommandID(GuidList.guidSourcetrailPluginCmdSet, (int)PkgCmdIDList.cmdidSourcetrailOpenLogFolder);
_menuItemSetActiveToken = new MenuCommand(MenuItemCallback, setActiveTokenCommandID); _menuItemSetActiveToken = new MenuCommand(MenuItemCallback, setActiveTokenCommandID);
_menuItemCreateProject = new MenuCommand(MenuItemCallback, createProjectID); _menuItemCreateCdb = new MenuCommand(MenuItemCallback, createCdbID);
_menuItemCreateCDB = new MenuCommand(MenuItemCallback, createCDBID);
_menuItemOpenLogDir = new MenuCommand(MenuItemCallback, openLogDirID); _menuItemOpenLogDir = new MenuCommand(MenuItemCallback, openLogDirID);
_menuItemCreateProject.Enabled = false;
_menuItemSetActiveToken.Enabled = false; _menuItemSetActiveToken.Enabled = false;
_menuItemCreateCDB.Enabled = false; _menuItemCreateCdb.Enabled = false;
_menuItemOpenLogDir.Enabled = true; _menuItemOpenLogDir.Enabled = true;
mcs.AddCommand(_menuItemSetActiveToken); mcs.AddCommand(_menuItemSetActiveToken);
mcs.AddCommand(_menuItemCreateProject); mcs.AddCommand(_menuItemCreateCdb);
mcs.AddCommand(_menuItemCreateCDB);
mcs.AddCommand(_menuItemOpenLogDir); mcs.AddCommand(_menuItemOpenLogDir);
} }
@@ -248,9 +241,9 @@ namespace CoatiSoftware.SourcetrailPlugin
string solutionPath = Utility.SolutionUtility.GetSolutionPath(dte); string solutionPath = Utility.SolutionUtility.GetSolutionPath(dte);
if(_cdbList.CheckCDBForSolutionExists(solutionPath)) if(_recentSettingsList.CheckCdbForSolutionExists(solutionPath))
{ {
Logging.Logging.LogInfo("A CDB for the loaded solution already exists."); Logging.Logging.LogInfo("A Cdb for the loaded solution already exists.");
} }
bool enable = false; bool enable = false;
@@ -268,8 +261,7 @@ namespace CoatiSoftware.SourcetrailPlugin
{ {
Logging.Logging.LogInfo("Enabling plugin UI"); Logging.Logging.LogInfo("Enabling plugin UI");
_menuItemSetActiveToken.Enabled = true; _menuItemSetActiveToken.Enabled = true;
_menuItemCreateProject.Enabled = true; _menuItemCreateCdb.Enabled = true;
_menuItemCreateCDB.Enabled = true;
_validSolutionLoaded = true; _validSolutionLoaded = true;
} }
@@ -292,8 +284,7 @@ namespace CoatiSoftware.SourcetrailPlugin
Logging.Logging.LogInfo("Solution closed, disabling plugin UI"); Logging.Logging.LogInfo("Solution closed, disabling plugin UI");
_menuItemSetActiveToken.Enabled = false; _menuItemSetActiveToken.Enabled = false;
_menuItemCreateProject.Enabled = false; _menuItemCreateCdb.Enabled = false;
_menuItemCreateCDB.Enabled = false;
_validSolutionLoaded = false; _validSolutionLoaded = false;
} }
@@ -340,36 +331,36 @@ namespace CoatiSoftware.SourcetrailPlugin
{ {
DTE dte = (DTE)GetService(typeof(DTE)); DTE dte = (DTE)GetService(typeof(DTE));
Wizard.WindowCreateCDB createCDB = new Wizard.WindowCreateCDB(); Wizard.WindowCreateCdb createCdbWindow = new Wizard.WindowCreateCdb();
createCDB.Projects = projects; createCdbWindow.Projects = projects;
createCDB.ConfigurationName = configurationName; createCdbWindow.ConfigurationName = configurationName;
createCDB.PlatformName = platformName; createCdbWindow.PlatformName = platformName;
createCDB.TargetDir = targetDir; createCdbWindow.TargetDir = targetDir;
createCDB.FileName = fileName; createCdbWindow.FileName = fileName;
createCDB.CStandard = cStandard; createCdbWindow.CStandard = cStandard;
createCDB.ThreadCount = (int)ThreadCount; createCdbWindow.ThreadCount = (int)ThreadCount;
createCDB.SolutionDir = Utility.SolutionUtility.GetSolutionPath(dte); createCdbWindow.SolutionDir = Utility.SolutionUtility.GetSolutionPath(dte);
createCDB.CDB = _cdbList.GetCDBForSolution(createCDB.SolutionDir, targetDir + "\\" + fileName + ".json"); createCdbWindow.Cdb = _recentSettingsList.GetCdbForSolution(createCdbWindow.SolutionDir, targetDir + "\\" + fileName + ".json");
createCDB.CallbackOnFinishedCreatingCDB = HandleFinishedCDB; createCdbWindow.CallbackOnFinishedCreatingCdb = HandleFinishedCdb;
createCDB.StartWorking(); createCdbWindow.StartWorking();
createCDB.ShowDialog(); createCdbWindow.ShowDialog();
} }
private void HandleFinishedCDB(Wizard.WindowCreateCDB.CreationResult creationResult) private void HandleFinishedCdb(Wizard.WindowCreateCdb.CreationResult creationResult)
{ {
if(creationResult._cdb != null && creationResult._cdbDirectory.Length > 0 && creationResult._cdbName.Length > 0) if(creationResult._cdbSettings != null && creationResult._cdbDirectory.Length > 0 && creationResult._cdbName.Length > 0)
{ {
_cdbList.AppendOrUpdate(creationResult._cdb); _recentSettingsList.AppendOrUpdate(creationResult._cdbSettings);
_cdbList.SaveMetaData(); _recentSettingsList.SaveMetaData();
Wizard.WindowCDBReady dialog = new Wizard.WindowCDBReady(); Wizard.WindowCdbReady dialog = new Wizard.WindowCdbReady();
dialog.setData(creationResult); dialog.setData(creationResult);
dialog.ShowDialog(); dialog.ShowDialog();
_cdbList.Refresh(); _recentSettingsList.Refresh();
} }
else else
{ {
@@ -397,20 +388,10 @@ namespace CoatiSoftware.SourcetrailPlugin
Utility.AsynchronousClient.Send(message); Utility.AsynchronousClient.Send(message);
} }
else if(menuCommand.CommandID.ID == (int)PkgCmdIDList.cmdidSourcetrailCreateCDB) else if(menuCommand.CommandID.ID == (int)PkgCmdIDList.cmdidSourcetrailCreateCdb)
{ {
CreateCompilationDatabase(dte); CreateCompilationDatabase(dte);
} }
else if(menuCommand.CommandID.ID == (int)PkgCmdIDList.cmdidSourcetrailCreateProject)
{
// show hint to use CDB methad (only for CDB beta) and create project on ok
Wizard.WindowMessage windowMessage = new Wizard.WindowMessage();
windowMessage.Title = "Hint";
windowMessage.Message = "Consider using 'Create CDB' if errors arise during Sourcetrail's indexing. This will become standard in the future.";
windowMessage.OnOK = CreateSourcetrailProjectOld;
windowMessage.RefreshWindow();
windowMessage.ShowDialog();
}
else if(menuCommand.CommandID.ID == (int)PkgCmdIDList.cmdidSourcetrailOpenLogFolder) else if(menuCommand.CommandID.ID == (int)PkgCmdIDList.cmdidSourcetrailOpenLogFolder)
{ {
Utility.SystemUtility.OpenWindowsExplorerAtDirectory(Utility.DataUtility.GetStandardFolderDirectory()); Utility.SystemUtility.OpenWindowsExplorerAtDirectory(Utility.DataUtility.GetStandardFolderDirectory());
@@ -418,35 +399,6 @@ namespace CoatiSoftware.SourcetrailPlugin
} }
} }
// will be removed once the CDB project creation is fully integrated
private void CreateSourcetrailProjectOld()
{
DTE dte = (DTE)GetService(typeof(DTE));
string solutionName = Utility.SolutionUtility.GetSolutionPath(dte);
if (solutionName == "") // TODO: make a better fallback for non-existant solution
{
List<string> items = Utility.SolutionUtility.GetSolutionProjectsFullNames(dte);
if (items.Count > 0)
{
solutionName = items[0];
}
}
if (solutionName.Length > 0)
{
string message = Utility.NetworkProtocolUtility.CreateCreateProjectMessage(solutionName);
Utility.AsynchronousClient.Send(message);
}
else
{
DisplayMessage("Sourcetrail", "Can not create a Sourcetrail Project. Please check whether your VS solution is a valid C or C++ solution and is saved.");
}
}
private void OnNetworkReadCallback(string message) private void OnNetworkReadCallback(string message)
{ {
Utility.NetworkProtocolUtility.MESSAGE_TYPE messageType = Utility.NetworkProtocolUtility.GetMessageType(message); Utility.NetworkProtocolUtility.MESSAGE_TYPE messageType = Utility.NetworkProtocolUtility.GetMessageType(message);
@@ -542,17 +494,18 @@ namespace CoatiSoftware.SourcetrailPlugin
Guid clsid = Guid.Empty; Guid clsid = Guid.Empty;
int result; int result;
Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox( Microsoft.VisualStudio.ErrorHandler.ThrowOnFailure(uiShell.ShowMessageBox(
0, 0,
ref clsid, ref clsid,
title, title,
message, message,
string.Empty, string.Empty,
0, 0,
OLEMSGBUTTON.OLEMSGBUTTON_OK, OLEMSGBUTTON.OLEMSGBUTTON_OK,
OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST, OLEMSGDEFBUTTON.OLEMSGDEFBUTTON_FIRST,
OLEMSGICON.OLEMSGICON_INFO, OLEMSGICON.OLEMSGICON_INFO,
0, // false 0, // false
out result)); out result
));
} }
private void CreateCompilationDatabase(DTE dte) private void CreateCompilationDatabase(DTE dte)
@@ -570,7 +523,7 @@ namespace CoatiSoftware.SourcetrailPlugin
bool containsCFiles = true; // Utility.SolutionUtility.ContainsCFiles(dte); // takes ridiculously long, I'd rather just display the option by default bool containsCFiles = true; // Utility.SolutionUtility.ContainsCFiles(dte); // takes ridiculously long, I'd rather just display the option by default
window._containsCFiles = containsCFiles; window._containsCFiles = containsCFiles;
window._cdb = _cdbList.GetMostCurrentCDBForSolution(Utility.SolutionUtility.GetSolutionPath(dte)); window._cdb = _recentSettingsList.GetMostCurrentCdbForSolution(Utility.SolutionUtility.GetSolutionPath(dte));
window.UpdateGUI(); window.UpdateGUI();
window._onCreateProject = OnCreateProject; window._onCreateProject = OnCreateProject;
@@ -1,159 +0,0 @@
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
namespace CoatiSoftware.SourcetrailPlugin.Utility
{
class CompilationDatabaseList
{
private List<SolutionParser.CompilationDatabase> _cdbs = new List<SolutionParser.CompilationDatabase>();
public List<SolutionParser.CompilationDatabase> CDBs
{
get { return _cdbs; }
// set { _cdbs = value; }
}
public CompilationDatabaseList()
{
Refresh();
}
public void AppendOrUpdate(SolutionParser.CompilationDatabase cdb)
{
if(_cdbs.Exists(item => item.Name == cdb.Name && item.Directory == cdb.Directory) == false)
{
_cdbs.Add(cdb);
}
else
{
int idx = _cdbs.FindIndex(item => item.Name == cdb.Name && item.Directory == cdb.Directory);
_cdbs[idx] = cdb;
}
}
public void Refresh()
{
List<SolutionParser.CompilationDatabase> cdbs = new List<SolutionParser.CompilationDatabase>();
try
{
string data = Utility.DataUtility.GetInstance().GetData();
cdbs = SolutionParser.CompilationDatabase.ParseCDBsMetaData(data);
foreach (SolutionParser.CompilationDatabase cdb in cdbs)
{
cdb.CheckCDBExists();
}
}
catch (Exception e)
{
Logging.Logging.LogError("Failed to aquire data: " + e.Message);
}
_cdbs = cdbs;
}
public List<SolutionParser.CompilationDatabase> GetCDBsForSolution(string solutionPath)
{
return _cdbs.FindAll(item => item.SourceProject == solutionPath);
}
public SolutionParser.CompilationDatabase GetCDBForSolution(string solutionPath)
{
return _cdbs.Find(item => item.SourceProject == solutionPath);
}
public SolutionParser.CompilationDatabase GetMostCurrentCDBForSolution(string solutionPath)
{
SolutionParser.CompilationDatabase result = null;
try
{
List<SolutionParser.CompilationDatabase> candidates = GetCDBsForSolution(solutionPath);
System.DateTime youngest = System.DateTime.MinValue;
foreach (SolutionParser.CompilationDatabase cdb in candidates)
{
if (cdb.LastUpdated >= youngest)
{
youngest = cdb.LastUpdated;
result = cdb;
}
}
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to find cdb: " + e.Message);
}
return result;
}
public SolutionParser.CompilationDatabase GetCDBForSolution(string solutionPath, string cdbPath)
{
return _cdbs.Find(item => item.SourceProject == solutionPath && (item.Directory + "\\" + item.Name + ".json") == cdbPath);
}
public bool CheckCDBForSolutionExists(string solutionPath)
{
try
{
SolutionParser.CompilationDatabase cdb = GetCDBForSolution(solutionPath);
if (cdb != null && System.IO.File.Exists(cdb.Directory + "\\" + cdb.Name + ".json"))
{
return true;
}
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to check cdb: " + e.Message);
}
return false;
}
public void SaveMetaData()
{
try
{
XmlDocument doc = new XmlDocument();
XmlNode root = doc.CreateElement("cdbs");
foreach (SolutionParser.CompilationDatabase cdb in _cdbs)
{
XmlNode metaData = cdb.GetMetaDataXML(doc);
root.AppendChild(metaData);
}
System.IO.StringWriter writer = new System.IO.StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(XmlElement));
serializer.Serialize(writer, root);
DataUtility.GetInstance().ClearData();
DataUtility.GetInstance().AppendData(writer.ToString());
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to save meta data: " + e.Message);
}
}
public void UnloadCDBs()
{
if(_cdbs == null)
{
Logging.Logging.LogWarning("Member '_cdbs' is null, aborting.");
return;
}
foreach(SolutionParser.CompilationDatabase cdb in _cdbs)
{
cdb.ClearCommandObjects();
}
}
}
}
@@ -0,0 +1,145 @@
using CoatiSoftware.SourcetrailPlugin.SolutionParser;
using System;
using System.Collections.Generic;
using System.Xml;
using System.Xml.Serialization;
namespace CoatiSoftware.SourcetrailPlugin.Utility
{
class CompilationDatabaseSettingsList
{
private List<CompilationDatabaseSettings> _settings = new List<CompilationDatabaseSettings>();
public List<CompilationDatabaseSettings> Settings
{
get { return _settings; }
}
public CompilationDatabaseSettingsList()
{
Refresh();
}
public void AppendOrUpdate(CompilationDatabaseSettings cdb)
{
if(_settings.Exists(item => item.Name == cdb.Name && item.Directory == cdb.Directory) == false)
{
_settings.Add(cdb);
}
else
{
int idx = _settings.FindIndex(item => item.Name == cdb.Name && item.Directory == cdb.Directory);
_settings[idx] = cdb;
}
}
public void Refresh()
{
List<CompilationDatabaseSettings> cdbs = new List<CompilationDatabaseSettings>();
try
{
string data = Utility.DataUtility.GetInstance().GetData();
cdbs = CompilationDatabaseSettings.ParseCdbsMetaData(data);
foreach (CompilationDatabaseSettings cdb in cdbs)
{
cdb.CheckCdbExists();
}
}
catch (Exception e)
{
Logging.Logging.LogError("Failed to aquire data: " + e.Message);
}
_settings = cdbs;
}
public List<CompilationDatabaseSettings> GetCdbsForSolution(string solutionPath)
{
return _settings.FindAll(item => item.SourceProject == solutionPath);
}
public CompilationDatabaseSettings GetCdbForSolution(string solutionPath)
{
return _settings.Find(item => item.SourceProject == solutionPath);
}
public CompilationDatabaseSettings GetMostCurrentCdbForSolution(string solutionPath)
{
CompilationDatabaseSettings result = null;
try
{
List<CompilationDatabaseSettings> candidates = GetCdbsForSolution(solutionPath);
System.DateTime youngest = System.DateTime.MinValue;
foreach (CompilationDatabaseSettings cdb in candidates)
{
if (cdb.LastUpdated >= youngest)
{
youngest = cdb.LastUpdated;
result = cdb;
}
}
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to find cdb: " + e.Message);
}
return result;
}
public CompilationDatabaseSettings GetCdbForSolution(string solutionPath, string cdbPath)
{
return _settings.Find(item => item.SourceProject == solutionPath && (item.Directory + "\\" + item.Name + ".json") == cdbPath);
}
public bool CheckCdbForSolutionExists(string solutionPath)
{
try
{
CompilationDatabaseSettings cdb = GetCdbForSolution(solutionPath);
if (cdb != null && System.IO.File.Exists(cdb.Directory + "\\" + cdb.Name + ".json"))
{
return true;
}
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to check cdb: " + e.Message);
}
return false;
}
public void SaveMetaData()
{
try
{
XmlDocument doc = new XmlDocument();
XmlNode root = doc.CreateElement("cdbs");
foreach (CompilationDatabaseSettings cdb in _settings)
{
XmlNode metaData = cdb.GetMetaDataXML(doc);
root.AppendChild(metaData);
}
System.IO.StringWriter writer = new System.IO.StringWriter();
XmlSerializer serializer = new XmlSerializer(typeof(XmlElement));
serializer.Serialize(writer, root);
DataUtility.GetInstance().ClearData();
DataUtility.GetInstance().AppendData(writer.ToString());
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to save meta data: " + e.Message);
}
}
}
}
@@ -1,5 +1,5 @@
using System; using EnvDTE;
using EnvDTE; using System;
namespace CoatiSoftware.SourcetrailPlugin.Utility namespace CoatiSoftware.SourcetrailPlugin.Utility
{ {
@@ -1,5 +1,5 @@
using System; using VCProjectEngineWrapper;
using VCProjectEngineWrapper; using System;
namespace CoatiSoftware.SourcetrailPlugin.Utility namespace CoatiSoftware.SourcetrailPlugin.Utility
{ {
@@ -1,8 +1,5 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CoatiSoftware.SourcetrailPlugin.Utility namespace CoatiSoftware.SourcetrailPlugin.Utility
{ {
@@ -12,12 +9,11 @@ namespace CoatiSoftware.SourcetrailPlugin.Utility
private static string s_setActiveTokenPrefix = "setActiveToken"; private static string s_setActiveTokenPrefix = "setActiveToken";
private static string s_moveCursorPrefix = "moveCursor"; private static string s_moveCursorPrefix = "moveCursor";
private static string s_endOfMessageToken = "<EOM>"; private static string s_endOfMessageToken = "<EOM>";
private static string s_createProjectPrefix = "createProject"; // deprecate private static string s_createCdbProjectPrefix = "createCDBProject";
private static string s_createCDBProjectPrefix = "createCDBProject";
private static string s_ideId = "vs"; private static string s_ideId = "vs";
private static string s_createCDBPrefix = "createCDB"; private static string s_createCdbPrefix = "createCDB";
private static string s_pingPrefix = "ping"; private static string s_pingPrefix = "ping";
@@ -100,26 +96,9 @@ namespace CoatiSoftware.SourcetrailPlugin.Utility
return message; return message;
} }
public static string CreateCreateProjectMessage(string solutionPath)
{
string message = s_createProjectPrefix;
message += s_divider;
message += solutionPath;
message += s_divider;
message += s_ideId;
message += s_endOfMessageToken;
return message;
}
public static string CreateCreateProjectMessage(string cdbPath, List<string> headerPaths) public static string CreateCreateProjectMessage(string cdbPath, List<string> headerPaths)
{ {
string message = s_createCDBProjectPrefix; string message = s_createCdbProjectPrefix;
message += s_divider; message += s_divider;
@@ -160,7 +139,7 @@ namespace CoatiSoftware.SourcetrailPlugin.Utility
if (tokens.Count > 0) if (tokens.Count > 0)
{ {
if (tokens[0] == s_createCDBPrefix) if (tokens[0] == s_createCdbPrefix)
{ {
return MESSAGE_TYPE.CREATE_CDB; return MESSAGE_TYPE.CREATE_CDB;
} }
@@ -1,9 +1,8 @@
using System; using System;
using System.Text;
using System.Threading;
using System.Net.Sockets; using System.Net.Sockets;
using System.Net; using System.Net;
using System.Text;
using System.Threading;
namespace CoatiSoftware.SourcetrailPlugin.Utility namespace CoatiSoftware.SourcetrailPlugin.Utility
{ {
@@ -68,7 +68,6 @@ namespace CoatiSoftware.SourcetrailPlugin.Utility
} }
_statusLock.ExitReadLock(); _statusLock.ExitReadLock();
_statusLock.EnterWriteLock(); _statusLock.EnterWriteLock();
_working = true; _working = true;
_workerThread = new Thread(new ThreadStart(Work)); _workerThread = new Thread(new ThreadStart(Work));
@@ -125,39 +124,43 @@ namespace CoatiSoftware.SourcetrailPlugin.Utility
private void Commit() private void Commit()
{ {
_queueLock.EnterWriteLock(); {
_queueLock.EnterWriteLock();
Queue<string> tmpQueue = _inputQueue; Queue<string> tmpQueue = _inputQueue;
_inputQueue = _outputQueue; _inputQueue = _outputQueue;
_outputQueue = tmpQueue; _outputQueue = tmpQueue;
_queueLock.ExitWriteLock();
_queueLock.ExitWriteLock(); }
WriteQueueToFile(ref _outputQueue); WriteQueueToFile(ref _outputQueue);
} }
private void WriteQueueToFile(ref Queue<string> messageQueue) private void WriteQueueToFile(ref Queue<string> messageQueue)
{ {
_fileLock.EnterWriteLock(); if (messageQueue.Count > 0)
try
{ {
while(messageQueue.Count > 0) _fileLock.EnterWriteLock();
try
{ {
_messageWrittenCount++; StreamWriter writer = System.IO.File.AppendText(_targetDirectory + "\\" + _fileName);
string message = messageQueue.Dequeue(); while (messageQueue.Count > 0)
{
_messageWrittenCount++;
writer.WriteLine(messageQueue.Dequeue());
}
File.AppendAllText(_targetDirectory + "\\" + _fileName, message); writer.Close();
}
catch (Exception e)
{
Logging.Logging.LogError(e.Message);
}
finally
{
_fileLock.ExitWriteLock();
} }
}
catch (Exception e)
{
Logging.Logging.LogError(e.Message);
}
finally
{
_fileLock.ExitWriteLock();
} }
} }
} }
@@ -1,13 +1,10 @@
using System; using EnvDTE;
using EnvDTE80;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using EnvDTE;
using EnvDTE80;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes; using System.Runtime.InteropServices.ComTypes;
using Microsoft.VisualStudio.Shell;
using Microsoft.VisualStudio.Shell.Interop;
using Microsoft.VisualStudio;
namespace CoatiSoftware.SourcetrailPlugin.Utility namespace CoatiSoftware.SourcetrailPlugin.Utility
{ {
@@ -17,238 +17,242 @@
private void InitializeComponent() private void InitializeComponent()
{ {
this.components = new System.ComponentModel.Container(); this.components = new System.ComponentModel.Container();
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProjectSetupWindow)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ProjectSetupWindow));
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.buttonCreate = new System.Windows.Forms.Button(); this.buttonCreate = new System.Windows.Forms.Button();
this.comboBoxConfiguration = new System.Windows.Forms.ComboBox(); this.comboBoxConfiguration = new System.Windows.Forms.ComboBox();
this.comboBoxPlatform = new System.Windows.Forms.ComboBox(); this.comboBoxPlatform = new System.Windows.Forms.ComboBox();
this.labelConfiguration = new System.Windows.Forms.Label(); this.labelConfiguration = new System.Windows.Forms.Label();
this.labelPlatform = new System.Windows.Forms.Label(); this.labelPlatform = new System.Windows.Forms.Label();
this.buttonSelectAll = new System.Windows.Forms.Button(); this.buttonSelectAll = new System.Windows.Forms.Button();
this.labelSelectProject = new System.Windows.Forms.Label(); this.labelSelectProject = new System.Windows.Forms.Label();
this.folderBrowserTargetDirectory = new System.Windows.Forms.FolderBrowserDialog(); this.folderBrowserTargetDirectory = new System.Windows.Forms.FolderBrowserDialog();
this.textBoxTargetDirectory = new System.Windows.Forms.TextBox(); this.textBoxTargetDirectory = new System.Windows.Forms.TextBox();
this.buttonSelect = new System.Windows.Forms.Button(); this.buttonSelect = new System.Windows.Forms.Button();
this.textBoxFileName = new System.Windows.Forms.TextBox(); this.textBoxFileName = new System.Windows.Forms.TextBox();
this.labelFileName = new System.Windows.Forms.Label(); this.labelFileName = new System.Windows.Forms.Label();
this.labelFileNameEnding = new System.Windows.Forms.Label(); this.labelFileNameExtension = new System.Windows.Forms.Label();
this.helpProvider1 = new System.Windows.Forms.HelpProvider(); this.helpProvider1 = new System.Windows.Forms.HelpProvider();
this.comboBoxCStandard = new System.Windows.Forms.ComboBox(); this.comboBoxCStandard = new System.Windows.Forms.ComboBox();
this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); this.toolTip1 = new System.Windows.Forms.ToolTip(this.components);
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
this.labelCStandard = new System.Windows.Forms.Label(); this.labelCStandard = new System.Windows.Forms.Label();
this.treeViewProjects = new System.Windows.Forms.TreeView(); this.treeViewProjects = new System.Windows.Forms.TreeView();
this.SuspendLayout(); this.SuspendLayout();
// //
// buttonCancel // buttonCancel
// //
this.helpProvider1.SetHelpString(this.buttonCancel, "Abort creation of the CDB"); this.helpProvider1.SetHelpString(this.buttonCancel, "Abort creation of the Compilation Database");
this.buttonCancel.Location = new System.Drawing.Point(12, 413); this.buttonCancel.Location = new System.Drawing.Point(12, 413);
this.buttonCancel.Name = "buttonCancel"; this.buttonCancel.Name = "buttonCancel";
this.helpProvider1.SetShowHelp(this.buttonCancel, true); this.helpProvider1.SetShowHelp(this.buttonCancel, true);
this.buttonCancel.Size = new System.Drawing.Size(92, 23); this.buttonCancel.Size = new System.Drawing.Size(92, 23);
this.buttonCancel.TabIndex = 9; this.buttonCancel.TabIndex = 9;
this.buttonCancel.Text = "Cancel"; this.buttonCancel.Text = "Cancel";
this.toolTip1.SetToolTip(this.buttonCancel, "Abort creation of the CDB"); this.toolTip1.SetToolTip(this.buttonCancel, "Abort creation of the Compilation Database");
this.buttonCancel.UseVisualStyleBackColor = true; this.buttonCancel.UseVisualStyleBackColor = true;
this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click); this.buttonCancel.Click += new System.EventHandler(this.buttonCancel_Click);
// //
// buttonCreate // buttonCreate
// //
this.helpProvider1.SetHelpString(this.buttonCreate, "Start creation of the CDB"); this.helpProvider1.SetHelpString(this.buttonCreate, "Start creation of the Compilation Database");
this.buttonCreate.Location = new System.Drawing.Point(178, 413); this.buttonCreate.Location = new System.Drawing.Point(178, 413);
this.buttonCreate.Name = "buttonCreate"; this.buttonCreate.Name = "buttonCreate";
this.helpProvider1.SetShowHelp(this.buttonCreate, true); this.helpProvider1.SetShowHelp(this.buttonCreate, true);
this.buttonCreate.Size = new System.Drawing.Size(92, 23); this.buttonCreate.Size = new System.Drawing.Size(92, 23);
this.buttonCreate.TabIndex = 8; this.buttonCreate.TabIndex = 8;
this.buttonCreate.Text = "Create"; this.buttonCreate.Text = "Create";
this.toolTip1.SetToolTip(this.buttonCreate, "Start creation of the CDB"); this.toolTip1.SetToolTip(this.buttonCreate, "Start creation of the Compilation Database");
this.buttonCreate.UseVisualStyleBackColor = true; this.buttonCreate.UseVisualStyleBackColor = true;
this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click); this.buttonCreate.Click += new System.EventHandler(this.buttonCreate_Click);
// //
// comboBoxConfiguration // comboBoxConfiguration
// //
this.comboBoxConfiguration.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.comboBoxConfiguration.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxConfiguration.FormattingEnabled = true; this.comboBoxConfiguration.FormattingEnabled = true;
this.helpProvider1.SetHelpKeyword(this.comboBoxConfiguration, "Build configuration for CDB"); this.helpProvider1.SetHelpKeyword(this.comboBoxConfiguration, "Build configuration for Compilation Database");
this.helpProvider1.SetHelpString(this.comboBoxConfiguration, "The selected build configuration determines the compile flags for the CDB"); this.helpProvider1.SetHelpString(this.comboBoxConfiguration, "The selected build configuration determines the compile flags for the Compilation" +
this.comboBoxConfiguration.Location = new System.Drawing.Point(87, 277); " Database");
this.comboBoxConfiguration.Name = "comboBoxConfiguration"; this.comboBoxConfiguration.Location = new System.Drawing.Point(87, 277);
this.helpProvider1.SetShowHelp(this.comboBoxConfiguration, true); this.comboBoxConfiguration.Name = "comboBoxConfiguration";
this.comboBoxConfiguration.Size = new System.Drawing.Size(183, 21); this.helpProvider1.SetShowHelp(this.comboBoxConfiguration, true);
this.comboBoxConfiguration.TabIndex = 3; this.comboBoxConfiguration.Size = new System.Drawing.Size(183, 21);
this.toolTip1.SetToolTip(this.comboBoxConfiguration, "The selected build configuration determines the compile flags for the CDB"); this.comboBoxConfiguration.TabIndex = 3;
// this.toolTip1.SetToolTip(this.comboBoxConfiguration, "The selected build configuration determines the compile flags for the Compilation" +
// comboBoxPlatform " Database");
// //
this.comboBoxPlatform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; // comboBoxPlatform
this.comboBoxPlatform.FormattingEnabled = true; //
this.helpProvider1.SetHelpString(this.comboBoxPlatform, "The target platform determines some compiler flags included in the CDB"); this.comboBoxPlatform.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxPlatform.Location = new System.Drawing.Point(87, 304); this.comboBoxPlatform.FormattingEnabled = true;
this.comboBoxPlatform.Name = "comboBoxPlatform"; this.helpProvider1.SetHelpString(this.comboBoxPlatform, "The target platform determines some compiler flags included in the Compilation Da" +
this.helpProvider1.SetShowHelp(this.comboBoxPlatform, true); "tabase");
this.comboBoxPlatform.Size = new System.Drawing.Size(183, 21); this.comboBoxPlatform.Location = new System.Drawing.Point(87, 304);
this.comboBoxPlatform.TabIndex = 4; this.comboBoxPlatform.Name = "comboBoxPlatform";
this.toolTip1.SetToolTip(this.comboBoxPlatform, "The target platform determines some compiler flags included in the CDB"); this.helpProvider1.SetShowHelp(this.comboBoxPlatform, true);
// this.comboBoxPlatform.Size = new System.Drawing.Size(183, 21);
// labelConfiguration this.comboBoxPlatform.TabIndex = 4;
// this.toolTip1.SetToolTip(this.comboBoxPlatform, "The target platform determines some compiler flags included in the Compilation Da" +
this.labelConfiguration.AutoSize = true; "tabase");
this.labelConfiguration.Location = new System.Drawing.Point(12, 280); //
this.labelConfiguration.Name = "labelConfiguration"; // labelConfiguration
this.labelConfiguration.Size = new System.Drawing.Size(69, 13); //
this.labelConfiguration.TabIndex = 6; this.labelConfiguration.AutoSize = true;
this.labelConfiguration.Text = "Configuration"; this.labelConfiguration.Location = new System.Drawing.Point(12, 280);
// this.labelConfiguration.Name = "labelConfiguration";
// labelPlatform this.labelConfiguration.Size = new System.Drawing.Size(69, 13);
// this.labelConfiguration.TabIndex = 6;
this.labelPlatform.AutoSize = true; this.labelConfiguration.Text = "Configuration";
this.labelPlatform.Location = new System.Drawing.Point(12, 307); //
this.labelPlatform.Name = "labelPlatform"; // labelPlatform
this.labelPlatform.Size = new System.Drawing.Size(45, 13); //
this.labelPlatform.TabIndex = 7; this.labelPlatform.AutoSize = true;
this.labelPlatform.Text = "Platform"; this.labelPlatform.Location = new System.Drawing.Point(12, 307);
// this.labelPlatform.Name = "labelPlatform";
// buttonSelectAll this.labelPlatform.Size = new System.Drawing.Size(45, 13);
// this.labelPlatform.TabIndex = 7;
this.helpProvider1.SetHelpString(this.buttonSelectAll, "Select all projects if not all are ticked. Deselect all otherwise"); this.labelPlatform.Text = "Platform";
this.buttonSelectAll.Location = new System.Drawing.Point(178, 248); //
this.buttonSelectAll.Name = "buttonSelectAll"; // buttonSelectAll
this.helpProvider1.SetShowHelp(this.buttonSelectAll, true); //
this.buttonSelectAll.Size = new System.Drawing.Size(92, 23); this.helpProvider1.SetHelpString(this.buttonSelectAll, "Select all projects if not all are ticked. Deselect all otherwise");
this.buttonSelectAll.TabIndex = 2; this.buttonSelectAll.Location = new System.Drawing.Point(178, 248);
this.buttonSelectAll.Text = "De/Select All"; this.buttonSelectAll.Name = "buttonSelectAll";
this.toolTip1.SetToolTip(this.buttonSelectAll, "Select all projects if not all are ticked. Deselect all otherwise"); this.helpProvider1.SetShowHelp(this.buttonSelectAll, true);
this.buttonSelectAll.UseVisualStyleBackColor = true; this.buttonSelectAll.Size = new System.Drawing.Size(92, 23);
this.buttonSelectAll.Click += new System.EventHandler(this.buttonSelectAll_Click); this.buttonSelectAll.TabIndex = 2;
// this.buttonSelectAll.Text = "De/Select All";
// labelSelectProject this.toolTip1.SetToolTip(this.buttonSelectAll, "Select all projects if not all are ticked. Deselect all otherwise");
// this.buttonSelectAll.UseVisualStyleBackColor = true;
this.labelSelectProject.AutoSize = true; this.buttonSelectAll.Click += new System.EventHandler(this.buttonSelectAll_Click);
this.labelSelectProject.Location = new System.Drawing.Point(9, 9); //
this.labelSelectProject.Name = "labelSelectProject"; // labelSelectProject
this.labelSelectProject.Size = new System.Drawing.Size(78, 13); //
this.labelSelectProject.TabIndex = 9; this.labelSelectProject.AutoSize = true;
this.labelSelectProject.Text = "Select Projects"; this.labelSelectProject.Location = new System.Drawing.Point(9, 9);
this.labelSelectProject.Click += new System.EventHandler(this.label1_Click); this.labelSelectProject.Name = "labelSelectProject";
// this.labelSelectProject.Size = new System.Drawing.Size(78, 13);
// textBoxTargetDirectory this.labelSelectProject.TabIndex = 9;
// this.labelSelectProject.Text = "Select Projects";
this.helpProvider1.SetHelpString(this.textBoxTargetDirectory, "Target directory where the CDB will be stored"); this.labelSelectProject.Click += new System.EventHandler(this.label1_Click);
this.textBoxTargetDirectory.Location = new System.Drawing.Point(12, 333); //
this.textBoxTargetDirectory.Name = "textBoxTargetDirectory"; // textBoxTargetDirectory
this.helpProvider1.SetShowHelp(this.textBoxTargetDirectory, true); //
this.textBoxTargetDirectory.Size = new System.Drawing.Size(177, 20); this.helpProvider1.SetHelpString(this.textBoxTargetDirectory, "Target directory where the Compilation Database will be stored");
this.textBoxTargetDirectory.TabIndex = 10; this.textBoxTargetDirectory.Location = new System.Drawing.Point(12, 333);
this.toolTip1.SetToolTip(this.textBoxTargetDirectory, "Target directory where the CDB will be stored"); this.textBoxTargetDirectory.Name = "textBoxTargetDirectory";
// this.helpProvider1.SetShowHelp(this.textBoxTargetDirectory, true);
// buttonSelect this.textBoxTargetDirectory.Size = new System.Drawing.Size(177, 20);
// this.textBoxTargetDirectory.TabIndex = 10;
this.helpProvider1.SetHelpString(this.buttonSelect, "Pick a target directory via folder browser"); this.toolTip1.SetToolTip(this.textBoxTargetDirectory, "Target directory where the Compilation Database will be stored");
this.buttonSelect.Location = new System.Drawing.Point(195, 331); //
this.buttonSelect.Name = "buttonSelect"; // buttonSelect
this.helpProvider1.SetShowHelp(this.buttonSelect, true); //
this.buttonSelect.Size = new System.Drawing.Size(75, 23); this.helpProvider1.SetHelpString(this.buttonSelect, "Pick a target directory via folder browser");
this.buttonSelect.TabIndex = 5; this.buttonSelect.Location = new System.Drawing.Point(195, 331);
this.buttonSelect.Text = "Browse"; this.buttonSelect.Name = "buttonSelect";
this.toolTip1.SetToolTip(this.buttonSelect, "Pick a target directory via folder browser"); this.helpProvider1.SetShowHelp(this.buttonSelect, true);
this.buttonSelect.UseVisualStyleBackColor = true; this.buttonSelect.Size = new System.Drawing.Size(75, 23);
this.buttonSelect.Click += new System.EventHandler(this.buttonSelect_Click); this.buttonSelect.TabIndex = 5;
// this.buttonSelect.Text = "Browse";
// textBoxFileName this.toolTip1.SetToolTip(this.buttonSelect, "Pick a target directory via folder browser");
// this.buttonSelect.UseVisualStyleBackColor = true;
this.textBoxFileName.Location = new System.Drawing.Point(87, 360); this.buttonSelect.Click += new System.EventHandler(this.buttonSelect_Click);
this.textBoxFileName.Name = "textBoxFileName"; //
this.textBoxFileName.Size = new System.Drawing.Size(148, 20); // textBoxFileName
this.textBoxFileName.TabIndex = 6; //
this.textBoxFileName.TextChanged += new System.EventHandler(this.textBoxFileName_TextChanged); this.textBoxFileName.Location = new System.Drawing.Point(87, 360);
this.textBoxFileName.Leave += new System.EventHandler(this.textBoxFileName_Leave); this.textBoxFileName.Name = "textBoxFileName";
// this.textBoxFileName.Size = new System.Drawing.Size(148, 20);
// labelFileName this.textBoxFileName.TabIndex = 6;
// this.textBoxFileName.TextChanged += new System.EventHandler(this.textBoxFileName_TextChanged);
this.labelFileName.AutoSize = true; this.textBoxFileName.Leave += new System.EventHandler(this.textBoxFileName_Leave);
this.labelFileName.Location = new System.Drawing.Point(12, 363); //
this.labelFileName.Name = "labelFileName"; // labelFileName
this.labelFileName.Size = new System.Drawing.Size(60, 13); //
this.labelFileName.TabIndex = 13; this.labelFileName.AutoSize = true;
this.labelFileName.Text = "CDB Name"; this.labelFileName.Location = new System.Drawing.Point(12, 363);
// this.labelFileName.Name = "labelFileName";
// labelFileNameEnding this.labelFileName.Size = new System.Drawing.Size(49, 13);
// this.labelFileName.TabIndex = 13;
this.labelFileNameEnding.AutoSize = true; this.labelFileName.Text = "Filename";
this.labelFileNameEnding.Location = new System.Drawing.Point(241, 363); //
this.labelFileNameEnding.Name = "labelFileNameEnding"; // labelFileNameExtension
this.labelFileNameEnding.Size = new System.Drawing.Size(29, 13); //
this.labelFileNameEnding.TabIndex = 14; this.labelFileNameExtension.AutoSize = true;
this.labelFileNameEnding.Text = ".json"; this.labelFileNameExtension.Location = new System.Drawing.Point(241, 363);
// this.labelFileNameExtension.Name = "labelFileNameExtension";
// comboBoxCStandard this.labelFileNameExtension.Size = new System.Drawing.Size(29, 13);
// this.labelFileNameExtension.TabIndex = 14;
this.comboBoxCStandard.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; this.labelFileNameExtension.Text = ".json";
this.comboBoxCStandard.FormattingEnabled = true; //
this.helpProvider1.SetHelpString(this.comboBoxCStandard, "Your Solution contains C Files. Please specify which C standard is to be used for" + // comboBoxCStandard
" building."); //
this.comboBoxCStandard.Location = new System.Drawing.Point(87, 386); this.comboBoxCStandard.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCStandard.Name = "comboBoxCStandard"; this.comboBoxCStandard.FormattingEnabled = true;
this.helpProvider1.SetShowHelp(this.comboBoxCStandard, true); this.helpProvider1.SetHelpString(this.comboBoxCStandard, "In case your solution contains C files, please specify which C standard is to be " +
this.comboBoxCStandard.Size = new System.Drawing.Size(183, 21); "used for building.");
this.comboBoxCStandard.TabIndex = 7; this.comboBoxCStandard.Location = new System.Drawing.Point(87, 386);
this.toolTip1.SetToolTip(this.comboBoxCStandard, "Your Solution contains C Files. Please specify which C standard is to be used for" + this.comboBoxCStandard.Name = "comboBoxCStandard";
" building."); this.helpProvider1.SetShowHelp(this.comboBoxCStandard, true);
// this.comboBoxCStandard.Size = new System.Drawing.Size(183, 21);
// labelCStandard this.comboBoxCStandard.TabIndex = 7;
// this.toolTip1.SetToolTip(this.comboBoxCStandard, "In case your solution contains C files, please specify which C standard is to be " +
this.labelCStandard.AutoSize = true; "used for building.");
this.labelCStandard.Location = new System.Drawing.Point(12, 389); //
this.labelCStandard.Name = "labelCStandard"; // labelCStandard
this.labelCStandard.Size = new System.Drawing.Size(60, 13); //
this.labelCStandard.TabIndex = 16; this.labelCStandard.AutoSize = true;
this.labelCStandard.Text = "C Standard"; this.labelCStandard.Location = new System.Drawing.Point(12, 389);
// this.labelCStandard.Name = "labelCStandard";
// treeViewProjects this.labelCStandard.Size = new System.Drawing.Size(60, 13);
// this.labelCStandard.TabIndex = 16;
this.treeViewProjects.CheckBoxes = true; this.labelCStandard.Text = "C Standard";
this.treeViewProjects.Location = new System.Drawing.Point(12, 26); //
this.treeViewProjects.Name = "treeViewProjects"; // treeViewProjects
this.treeViewProjects.Size = new System.Drawing.Size(258, 216); //
this.treeViewProjects.TabIndex = 17; this.treeViewProjects.CheckBoxes = true;
this.treeViewProjects.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ProjectCheckList_MouseUp); this.treeViewProjects.Location = new System.Drawing.Point(12, 26);
this.treeViewProjects.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewProjects_NodeCheckChanged); this.treeViewProjects.Name = "treeViewProjects";
// this.treeViewProjects.Size = new System.Drawing.Size(258, 216);
// ProjectSetupWindow this.treeViewProjects.TabIndex = 17;
// this.treeViewProjects.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeViewProjects_NodeCheckChanged);
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.treeViewProjects.MouseUp += new System.Windows.Forms.MouseEventHandler(this.ProjectCheckList_MouseUp);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; //
this.AutoSize = true; // ProjectSetupWindow
this.ClientSize = new System.Drawing.Size(282, 443); //
this.Controls.Add(this.treeViewProjects); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.Controls.Add(this.labelCStandard); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.Controls.Add(this.comboBoxCStandard); this.AutoSize = true;
this.Controls.Add(this.labelFileNameEnding); this.ClientSize = new System.Drawing.Size(282, 443);
this.Controls.Add(this.labelFileName); this.Controls.Add(this.treeViewProjects);
this.Controls.Add(this.textBoxFileName); this.Controls.Add(this.labelCStandard);
this.Controls.Add(this.buttonSelect); this.Controls.Add(this.comboBoxCStandard);
this.Controls.Add(this.textBoxTargetDirectory); this.Controls.Add(this.labelFileNameExtension);
this.Controls.Add(this.labelSelectProject); this.Controls.Add(this.labelFileName);
this.Controls.Add(this.buttonSelectAll); this.Controls.Add(this.textBoxFileName);
this.Controls.Add(this.labelPlatform); this.Controls.Add(this.buttonSelect);
this.Controls.Add(this.labelConfiguration); this.Controls.Add(this.textBoxTargetDirectory);
this.Controls.Add(this.comboBoxPlatform); this.Controls.Add(this.labelSelectProject);
this.Controls.Add(this.comboBoxConfiguration); this.Controls.Add(this.buttonSelectAll);
this.Controls.Add(this.buttonCreate); this.Controls.Add(this.labelPlatform);
this.Controls.Add(this.buttonCancel); this.Controls.Add(this.labelConfiguration);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.Controls.Add(this.comboBoxPlatform);
this.helpProvider1.SetHelpString(this, "Create a CDB from the current C++ solution."); this.Controls.Add(this.comboBoxConfiguration);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Controls.Add(this.buttonCreate);
this.MaximizeBox = false; this.Controls.Add(this.buttonCancel);
this.MinimizeBox = false; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Name = "ProjectSetupWindow"; this.helpProvider1.SetHelpString(this, "Create a Compilation Database from the current C/C++ solution.");
this.helpProvider1.SetShowHelp(this, true); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Text = "Create Compilation Database"; this.MaximizeBox = false;
this.toolTip1.SetToolTip(this, "Create a CDB from the current C++ solution."); this.MinimizeBox = false;
this.ResumeLayout(false); this.Name = "ProjectSetupWindow";
this.PerformLayout(); this.helpProvider1.SetShowHelp(this, true);
this.Text = "Create Compilation Database";
this.toolTip1.SetToolTip(this, "Create a Compilation Database from the current C/C++ solution.");
this.ResumeLayout(false);
this.PerformLayout();
} }
@@ -266,7 +270,7 @@
private System.Windows.Forms.Button buttonSelect; private System.Windows.Forms.Button buttonSelect;
private System.Windows.Forms.TextBox textBoxFileName; private System.Windows.Forms.TextBox textBoxFileName;
private System.Windows.Forms.Label labelFileName; private System.Windows.Forms.Label labelFileName;
private System.Windows.Forms.Label labelFileNameEnding; private System.Windows.Forms.Label labelFileNameExtension;
private System.Windows.Forms.HelpProvider helpProvider1; private System.Windows.Forms.HelpProvider helpProvider1;
private System.Windows.Forms.ToolTip toolTip1; private System.Windows.Forms.ToolTip toolTip1;
private System.ComponentModel.BackgroundWorker backgroundWorker1; private System.ComponentModel.BackgroundWorker backgroundWorker1;
@@ -1,8 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Windows.Forms;
using System.IO; using System.IO;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using System.Windows.Forms;
namespace CoatiSoftware.SourcetrailPlugin.Wizard namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
@@ -39,7 +39,7 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
"c9x", "gnu9x", "iso9899:199x", "c99", "gnu99", "iso9899:1999", "iso9899:199409", "c90", "gnu90", "iso9899:1990", "c9x", "gnu9x", "iso9899:199x", "c99", "gnu99", "iso9899:1999", "iso9899:199409", "c90", "gnu90", "iso9899:1990",
"c89", "gnu89" }; "c89", "gnu89" };
public SolutionParser.CompilationDatabase _cdb = new SolutionParser.CompilationDatabase(); public SolutionParser.CompilationDatabaseSettings _cdb = new SolutionParser.CompilationDatabaseSettings();
public ProjectSetupWindow() public ProjectSetupWindow()
{ {
@@ -168,23 +168,30 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
private void InitTextBoxTargetDirectory() private void InitTextBoxTargetDirectory()
{ {
Logging.Logging.LogInfo("Setting default target directory: \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(_solutionDirectory) + "\""); if (_cdb == null)
{
folderBrowserTargetDirectory.SelectedPath = _solutionDirectory; Logging.Logging.LogInfo("Setting default target directory to default: \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(_solutionDirectory) + "\"");
string rootDirectory = folderBrowserTargetDirectory.SelectedPath.ToString(); folderBrowserTargetDirectory.SelectedPath = _solutionDirectory;
textBoxTargetDirectory.Text = rootDirectory; textBoxTargetDirectory.Text = _solutionDirectory;
}
else
{
Logging.Logging.LogInfo("Setting default target directory to recent: \"" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(_cdb.Directory) + "\"");
folderBrowserTargetDirectory.SelectedPath = _cdb.Directory;
textBoxTargetDirectory.Text = _cdb.Directory;
}
} }
private void InitTextBoxFileName() private void InitTextBoxFileName()
{ {
Logging.Logging.LogInfo("Setting default file name: '" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(_solutionFileName) + "'");
if(_cdb == null) if(_cdb == null)
{ {
Logging.Logging.LogInfo("Setting file name to default: '" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(_solutionFileName) + "'");
textBoxFileName.Text = _solutionFileName; textBoxFileName.Text = _solutionFileName;
} }
else else
{ {
Logging.Logging.LogInfo("Setting file name to recent: '" + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(_cdb.Name) + "'");
textBoxFileName.Text = _cdb.Name; textBoxFileName.Text = _cdb.Name;
} }
} }
@@ -252,7 +259,7 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
if(result == DialogResult.No) if(result == DialogResult.No)
{ {
Logging.Logging.LogInfo("Aborting CDB creation and attempting to make file name unique."); Logging.Logging.LogInfo("Aborting Cdb creation and attempting to make file name unique.");
MakeFileNameUnique(); MakeFileNameUnique();
return; return;
} }
@@ -286,7 +293,7 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
} }
else else
{ {
Logging.Logging.LogError("CDB create callback is not set. Cannot start creating CDB."); Logging.Logging.LogError("Cdb create callback is not set. Cannot start creating Cdb.");
} }
} }
@@ -305,7 +312,7 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
string fileName = textBoxFileName.Text; string fileName = textBoxFileName.Text;
string path = textBoxTargetDirectory.Text; string path = textBoxTargetDirectory.Text;
string extension = labelFileNameEnding.Text; string extension = labelFileNameExtension.Text;
return File.Exists(path + "\\" + fileName + extension); return File.Exists(path + "\\" + fileName + extension);
} }
@@ -1,6 +1,6 @@
namespace CoatiSoftware.SourcetrailPlugin.Wizard namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
partial class WindowCDBReady partial class WindowCdbReady
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -28,7 +28,7 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WindowCDBReady)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WindowCdbReady));
this.label_message = new System.Windows.Forms.Label(); this.label_message = new System.Windows.Forms.Label();
this.button_ok = new System.Windows.Forms.Button(); this.button_ok = new System.Windows.Forms.Button();
this.button_import = new System.Windows.Forms.Button(); this.button_import = new System.Windows.Forms.Button();
@@ -80,7 +80,7 @@
this.button_open.UseVisualStyleBackColor = true; this.button_open.UseVisualStyleBackColor = true;
this.button_open.Click += new System.EventHandler(this.button_open_Click); this.button_open.Click += new System.EventHandler(this.button_open_Click);
// //
// WindowCDBReady // WindowCdbReady
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -92,9 +92,9 @@
this.Controls.Add(this.label_message); this.Controls.Add(this.label_message);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.MinimumSize = new System.Drawing.Size(330, 160); this.MinimumSize = new System.Drawing.Size(330, 160);
this.Name = "WindowCDBReady"; this.Name = "WindowCdbReady";
this.Text = "CDB Ready"; this.Text = "Cdb Ready";
this.Resize += new System.EventHandler(this.WindowCDBReady_Resize); this.Resize += new System.EventHandler(this.WindowCdbReady_Resize);
this.ResumeLayout(false); this.ResumeLayout(false);
} }
@@ -1,24 +1,14 @@
using System; using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing; using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; using System.Windows.Forms;
namespace CoatiSoftware.SourcetrailPlugin.Wizard namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
public partial class WindowCDBReady : Form public partial class WindowCdbReady : Form
{ {
private string _message0 = "The CDB "; private WindowCreateCdb.CreationResult _creationResult = new WindowCreateCdb.CreationResult();
private string _message1 = " was created at directory ";
private string _message2 = "Do you want to auto-import it in Sourcetrail now?";
private WindowCreateCDB.CreationResult _creationResult = new WindowCreateCDB.CreationResult(); public WindowCdbReady()
public WindowCDBReady()
{ {
InitializeComponent(); InitializeComponent();
@@ -26,12 +16,13 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
label_message.MaximumSize = new Size((int)((float)MaximumSize.Width * 0.8f), 0); label_message.MaximumSize = new Size((int)((float)MaximumSize.Width * 0.8f), 0);
} }
public void setData(WindowCreateCDB.CreationResult creationResult) public void setData(WindowCreateCdb.CreationResult creationResult)
{ {
_creationResult = creationResult; _creationResult = creationResult;
label_message.Text = _message0 + "'" + creationResult._cdbName + "'" + _message1 + "\"" + creationResult._cdbDirectory + "\"."; label_message.Text = "The Compilation Database \"" + creationResult._cdbName +
label_message.Text += "\n" + _message2; "\" was created at directory \"" + creationResult._cdbDirectory + "\".\n" +
"Do you want to auto-import it in Sourcetrail now?";
} }
private void button_ok_Click(object sender, EventArgs e) private void button_ok_Click(object sender, EventArgs e)
@@ -53,7 +44,7 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
Close(); Close();
} }
private void WindowCDBReady_Resize(object sender, EventArgs e) private void WindowCdbReady_Resize(object sender, EventArgs e)
{ {
label_message.MaximumSize = new Size((int)((float)MaximumSize.Width * 0.8f), 0); label_message.MaximumSize = new Size((int)((float)MaximumSize.Width * 0.8f), 0);
} }
@@ -1,6 +1,6 @@
namespace CoatiSoftware.SourcetrailPlugin.Wizard namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
partial class WindowCreateCDB partial class WindowCreateCdb
{ {
/// <summary> /// <summary>
/// Required designer variable. /// Required designer variable.
@@ -28,7 +28,7 @@
/// </summary> /// </summary>
private void InitializeComponent() private void InitializeComponent()
{ {
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WindowCreateCDB)); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(WindowCreateCdb));
this.progressBar = new System.Windows.Forms.ProgressBar(); this.progressBar = new System.Windows.Forms.ProgressBar();
this.labelStatus = new System.Windows.Forms.Label(); this.labelStatus = new System.Windows.Forms.Label();
this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker(); this.backgroundWorker1 = new System.ComponentModel.BackgroundWorker();
@@ -57,7 +57,7 @@
this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged); this.backgroundWorker1.ProgressChanged += new System.ComponentModel.ProgressChangedEventHandler(this.backgroundWorker1_ProgressChanged);
this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted); this.backgroundWorker1.RunWorkerCompleted += new System.ComponentModel.RunWorkerCompletedEventHandler(this.backgroundWorker1_RunWorkerCompleted);
// //
// WindowCreateCDB // WindowCreateCdb
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
@@ -67,9 +67,9 @@
this.Cursor = System.Windows.Forms.Cursors.WaitCursor; this.Cursor = System.Windows.Forms.Cursors.WaitCursor;
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow;
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon"))); this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "WindowCreateCDB"; this.Name = "WindowCreateCdb";
this.Text = "Creating Compilation Data Base"; this.Text = "Creating Compilation Data Base";
this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.WindowCreateCDB_FormClosed); this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.WindowCreateCdb_FormClosed);
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@@ -1,27 +1,27 @@
using System; using CoatiSoftware.SourcetrailPlugin.SolutionParser;
using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.ComponentModel; using System.ComponentModel;
using System.IO; using System.IO;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Threading; using System.Threading;
using System.Windows.Forms; using System.Windows.Forms;
using CoatiSoftware.SourcetrailPlugin.SolutionParser;
namespace CoatiSoftware.SourcetrailPlugin.Wizard namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
public partial class WindowCreateCDB : Form public partial class WindowCreateCdb : Form
{ {
public struct CreationResult public struct CreationResult
{ {
public SolutionParser.CompilationDatabase _cdb; public SolutionParser.CompilationDatabaseSettings _cdbSettings;
public string _cdbDirectory; public string _cdbDirectory;
public string _cdbName; public string _cdbName;
public List<string> _headerDirectories; public List<string> _headerDirectories;
} }
public delegate void OnFinishedCreatingCDB(CreationResult result); public delegate void OnFinishedCreatingCdb(CreationResult result);
private OnFinishedCreatingCDB _onFinishedCreateCDB = null; private OnFinishedCreatingCdb _onFinishedCreateCdb = null;
private List<EnvDTE.Project> _projects = new List<EnvDTE.Project>(); private List<EnvDTE.Project> _projects = new List<EnvDTE.Project>();
@@ -33,19 +33,19 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
private string _solutionDir = ""; private string _solutionDir = "";
private List<string> _headerDirectories; private List<string> _headerDirectories;
private SolutionParser.CompilationDatabase _cdb = null; private SolutionParser.CompilationDatabaseSettings _cdb = null;
CreationResult _result = new CreationResult(); private CreationResult _result = new CreationResult();
private int _threadCount = 1; private int _threadCount = 1;
private static object _lockObject = new object(); private static object _lockObject = new object();
private static ReaderWriterLockSlim _readWriteLock = new ReaderWriterLockSlim(); private static ReaderWriterLockSlim _readWriteLock = new ReaderWriterLockSlim();
public OnFinishedCreatingCDB CallbackOnFinishedCreatingCDB public OnFinishedCreatingCdb CallbackOnFinishedCreatingCdb
{ {
get { return _onFinishedCreateCDB; } get { return _onFinishedCreateCdb; }
set { _onFinishedCreateCDB = value; } set { _onFinishedCreateCdb = value; }
} }
public List<EnvDTE.Project> Projects public List<EnvDTE.Project> Projects
@@ -96,14 +96,14 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
set { _solutionDir = value; } set { _solutionDir = value; }
} }
public SolutionParser.CompilationDatabase CDB public SolutionParser.CompilationDatabaseSettings Cdb
{ {
get { return _cdb; } get { return _cdb; }
set { _cdb = value; } set { _cdb = value; }
} }
public WindowCreateCDB() public WindowCreateCdb()
{ {
InitializeComponent(); InitializeComponent();
@@ -116,57 +116,51 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
public void StartWorking() public void StartWorking()
{ {
// Show();
backgroundWorker1.RunWorkerAsync(); backgroundWorker1.RunWorkerAsync();
} }
private CreationResult CreateCDB() private CreationResult CreateCdb()
{ {
CreationResult result = new CreationResult(); CreationResult result = new CreationResult();
result._cdb = null; result._cdbSettings = null;
result._cdbDirectory = ""; result._cdbDirectory = "";
result._cdbName = ""; result._cdbName = "";
result._headerDirectories = new List<string>(); result._headerDirectories = new List<string>();
Logging.Logging.LogInfo("Starting to create CDB"); Logging.Logging.LogInfo("Starting to create CDB");
SolutionParser.CompilationDatabase cdb = null; SolutionParser.CompilationDatabaseSettings cdbSettings = null;
_headerDirectories = new List<string>(); _headerDirectories = new List<string>();
try try
{ {
System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch(); System.Diagnostics.Stopwatch watch = new System.Diagnostics.Stopwatch();
watch.Start(); watch.Start();
CreateCompilationDatabase();
cdb = CreateCommandObjects();
watch.Stop(); watch.Stop();
Logging.Logging.LogInfo("Finished, elapsed time: " + watch.ElapsedMilliseconds.ToString() + " ms"); Logging.Logging.LogInfo("Finished creating CDB, elapsed time: " + watch.ElapsedMilliseconds.ToString() + " ms");
cdb.Name = _fileName; cdbSettings = new CompilationDatabaseSettings();
cdb.Directory = _targetDir; cdbSettings.Name = _fileName;
cdb.SourceProject = _solutionDir; cdbSettings.Directory = _targetDir;
cdb.LastUpdated = DateTime.Now; cdbSettings.SourceProject = _solutionDir;
cdb.ConfigurationName = _configurationName; cdbSettings.LastUpdated = DateTime.Now;
cdb.PlatformName = _platformName; cdbSettings.ConfigurationName = _configurationName;
cdbSettings.PlatformName = _platformName;
cdb.IncludedProjects = new List<string>(); cdbSettings.IncludedProjects = new List<string>();
foreach (EnvDTE.Project p in _projects) foreach (EnvDTE.Project p in _projects)
{ {
cdb.IncludedProjects.Add(p.Name); cdbSettings.IncludedProjects.Add(p.Name);
} }
cdb.Clean();
} }
catch(Exception e) catch(Exception e)
{ {
Logging.Logging.LogError("Failed to create CDB: " + e.Message); Logging.Logging.LogError("Failed to create CDB: " + e.Message);
} }
result._cdb = cdb; result._cdbSettings = cdbSettings;
result._cdbDirectory = _targetDir; result._cdbDirectory = _targetDir;
result._cdbName = _fileName; result._cdbName = _fileName;
result._headerDirectories = _headerDirectories; result._headerDirectories = _headerDirectories;
@@ -176,17 +170,11 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
return result; return result;
} }
private SolutionParser.CompilationDatabase CreateCommandObjects() private void CreateCompilationDatabase()
{ {
SolutionParser.CompilationDatabase cdb = new SolutionParser.CompilationDatabase();
cdb.Directory = _targetDir;
cdb.Name = _fileName;
File.WriteAllText(_targetDir + "\\" + _fileName + ".json", ""); File.WriteAllText(_targetDir + "\\" + _fileName + ".json", "");
File.AppendAllText(_targetDir + "\\" + _fileName + ".json", "[\n"); File.AppendAllText(_targetDir + "\\" + _fileName + ".json", "[\n");
// Mutex commandObjectMutex = new Mutex();
Utility.QueuedFileWriter fileWriter = new Utility.QueuedFileWriter(_fileName + ".json", _targetDir); Utility.QueuedFileWriter fileWriter = new Utility.QueuedFileWriter(_fileName + ".json", _targetDir);
fileWriter.StartWorking(); fileWriter.StartWorking();
@@ -221,9 +209,6 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
foreach (CompileCommand command in commands) foreach (CompileCommand command in commands)
{ {
// cdb.AddOrUpdateCommandObject(obj, false); // since the data is written to file right away now, no need to store it
// the cdb is however still needed to store some meta data later
string serializedCommand = ""; string serializedCommand = "";
foreach (string line in command.SerializeToJson().Split('\n')) foreach (string line in command.SerializeToJson().Split('\n'))
{ {
@@ -262,13 +247,11 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
File.AppendAllText(_targetDir + "\\" + _fileName + ".json", "\n]"); File.AppendAllText(_targetDir + "\\" + _fileName + ".json", "\n]");
} }
return cdb;
} }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{ {
_result = CreateCDB(); _result = CreateCdb();
} }
private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e) private void backgroundWorker1_ProgressChanged(object sender, ProgressChangedEventArgs e)
@@ -291,17 +274,17 @@ namespace CoatiSoftware.SourcetrailPlugin.Wizard
{ {
if(e.Cancelled == false && e.Error == null /*&& progressBar.Value >= 100*/) if(e.Cancelled == false && e.Error == null /*&& progressBar.Value >= 100*/)
{ {
_onFinishedCreateCDB?.Invoke(_result); _onFinishedCreateCdb?.Invoke(_result);
} }
else else
{ {
Logging.Logging.LogWarning("CDB creation was aborted by user"); Logging.Logging.LogWarning("Cdb creation was aborted by user");
} }
Close(); Close();
} }
private void WindowCreateCDB_FormClosed(object sender, FormClosedEventArgs e) private void WindowCreateCdb_FormClosed(object sender, FormClosedEventArgs e)
{ {
backgroundWorker1.CancelAsync(); backgroundWorker1.CancelAsync();
} }
@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011"> <PackageManifest Version="2.0.0" xmlns="http://schemas.microsoft.com/developer/vsx-schema/2011" xmlns:d="http://schemas.microsoft.com/developer/vsx-schema-design/2011">
<Metadata> <Metadata>
<Identity Id="acf15780-03b5-440e-a41e-db79b7043fc2" Version="0.9.82" Language="en-US" Publisher="Coati Software OG" /> <Identity Id="acf15780-03b5-440e-a41e-db79b7043fc2" Version="0.9.83" Language="en-US" Publisher="Coati Software OG" />
<DisplayName>SourcetrailPlugin</DisplayName> <DisplayName>SourcetrailPlugin</DisplayName>
<Description xml:space="preserve">The Sourcetrail Plugin allows Visual Studio to communicate with Sourcetrail - an external source code exploration tool. It also enables Visual Studio to generate a Clang Compilation Database from any Visual Studio Solution which can be used to automate the Sourcetrail project setup and to run other Clang based tools.</Description> <Description xml:space="preserve">The Sourcetrail Plugin allows Visual Studio to communicate with Sourcetrail - an external source code exploration tool. It also enables Visual Studio to generate a Clang Compilation Database from any Visual Studio Solution which can be used to automate the Sourcetrail project setup and to run other Clang based tools.</Description>
<MoreInfo>https://www.sourcetrail.com/</MoreInfo> <MoreInfo>https://www.sourcetrail.com/</MoreInfo>
@@ -1,12 +1,12 @@
using System; using CoatiSoftware.SourcetrailPlugin.IntegrationTests.Helpers;
using CoatiSoftware.SourcetrailPlugin.SolutionParser;
using EnvDTE;
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.VSSDK.Tools.VsIdeTesting; using Microsoft.VSSDK.Tools.VsIdeTesting;
using Microsoft.VisualStudio.Shell.Interop; using Microsoft.VisualStudio.Shell.Interop;
using EnvDTE; using System;
using CoatiSoftware.SourcetrailPlugin.SolutionParser;
using System.IO;
using CoatiSoftware.SourcetrailPlugin.IntegrationTests.Helpers;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO;
namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests
{ {
@@ -44,7 +44,7 @@ namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests
UIThreadInvoker.Initialize(); UIThreadInvoker.Initialize();
UIThreadInvoker.Invoke(new Action(() => UIThreadInvoker.Invoke(new Action(() =>
{ {
TestCompilationDatabaseForSolution("../../../SourcetrailPlugin.IntegrationTests/bin/data/cinder/cinder.sln"); TestCompilationDatabaseForSolution("../../../SourcetrailPluginTests/bin/data/cinder/cinder.sln");
})); }));
} }
@@ -55,7 +55,7 @@ namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests
UIThreadInvoker.Initialize(); UIThreadInvoker.Initialize();
UIThreadInvoker.Invoke(new Action(() => UIThreadInvoker.Invoke(new Action(() =>
{ {
TestCompilationDatabaseForSolution("../../../SourcetrailPlugin.IntegrationTests/bin/data/all_in_same_folder/test.sln"); TestCompilationDatabaseForSolution("../../../SourcetrailPluginTests/bin/data/all_in_same_folder/test.sln");
})); }));
} }
@@ -83,6 +83,7 @@ namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests
string cdbPath = Path.ChangeExtension(solutionPath, "json"); string cdbPath = Path.ChangeExtension(solutionPath, "json");
if (_updateExpectedOutput) if (_updateExpectedOutput)
{ {
output.SortAlphabetically();
Console.WriteLine("writing compilation database to file: " + cdbPath); Console.WriteLine("writing compilation database to file: " + cdbPath);
File.WriteAllText(cdbPath, output.SerializeToJson()); File.WriteAllText(cdbPath, output.SerializeToJson());
Assert.IsTrue(File.Exists(cdbPath)); Assert.IsTrue(File.Exists(cdbPath));
@@ -120,7 +121,7 @@ namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests
project, configurationNames[0], platformNames[0], "c11" project, configurationNames[0], platformNames[0], "c11"
)) ))
{ {
cdb.AddCommandObject(command); cdb.AddCompileCommand(command);
} }
} }
@@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using CoatiSoftware.SourcetrailPlugin.SolutionParser;
using CoatiSoftware.SourcetrailPlugin.SolutionParser; using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests.UnitTests namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests.UnitTests
{ {
@@ -31,10 +31,10 @@ namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests.UnitTests
command.Command = "D test test.cpp"; command.Command = "D test test.cpp";
CompilationDatabase cdb1 = new CompilationDatabase(); CompilationDatabase cdb1 = new CompilationDatabase();
cdb1.AddCommandObject(command); cdb1.AddCompileCommand(command);
CompilationDatabase cdb2 = new CompilationDatabase(); CompilationDatabase cdb2 = new CompilationDatabase();
cdb2.AddCommandObject(command); cdb2.AddCompileCommand(command);
Assert.IsTrue(cdb1 == cdb2); Assert.IsTrue(cdb1 == cdb2);
} }
@@ -48,7 +48,7 @@ namespace CoatiSoftware.SourcetrailPlugin.IntegrationTests.UnitTests
command.Command = "D DEFINE=\"value\" test.cpp"; command.Command = "D DEFINE=\"value\" test.cpp";
CompilationDatabase originalCompilationDatabase = new CompilationDatabase(); CompilationDatabase originalCompilationDatabase = new CompilationDatabase();
originalCompilationDatabase.AddCommandObject(command); originalCompilationDatabase.AddCompileCommand(command);
string serialized = originalCompilationDatabase.SerializeToJson(); string serialized = originalCompilationDatabase.SerializeToJson();
CompilationDatabase deserializedCompilationDatabase = new CompilationDatabase(); CompilationDatabase deserializedCompilationDatabase = new CompilationDatabase();