logic: VS Plugin logging/exception handling

Added some additional logging and exception handling to solution parser
This commit is contained in:
wrongway88
2017-02-16 00:32:39 +01:00
parent 217e9ceff2
commit 18153a2ac5
7 changed files with 61 additions and 39 deletions
+1
View File
@@ -1,3 +1,4 @@
Settings.cpp WARNING: File for Settings not found: data/TestSettings.xml
Token.cpp ERROR: Location Id was not referenced by this Token.
Node.cpp WARNING: Cannot change NodeType after it was already set from namespace to class
Edge.cpp ERROR: Nodes are not plain copies.
Binary file not shown.
@@ -363,7 +363,7 @@ namespace CoatiSoftware.CoatiPlugin
{
if(creationResult._cdb != null && creationResult._cdbDirectory.Length > 0 && creationResult._cdbName.Length > 0)
{
_cdbList.Append(creationResult._cdb);
_cdbList.AppendOrUpdate(creationResult._cdb);
_cdbList.SaveMetaData();
// string metaData = creationResult._cdb.SerializeMetaDataXML();
@@ -85,59 +85,73 @@ namespace CoatiSoftware.CoatiPlugin.SolutionParser
List<string> includeDirectories = new List<string>();
List<string> preprocessorDefinitions = new List<string>();
IEnumerable configurations = project.Configurations as IEnumerable;
VCConfiguration vcProjectConfig = GetProjectConfiguration(project, configurationName, platformName);
VCConfiguration vcProjectConfig = null;
try
{
vcProjectConfig = GetProjectConfiguration(project, configurationName, platformName);
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to retreive project configuration: " + e.Message);
}
if (vcProjectConfig != null)
{
// get additional include directories
// source: http://www.mztools.com/articles/2014/MZ2014005.aspx
IEnumerable projectTools = vcProjectConfig.Tools as IEnumerable;
foreach (Object tool in projectTools)
try
{
VCCLCompilerTool compilerTool = tool as VCCLCompilerTool;
if (compilerTool != null)
// get additional include directories
// source: http://www.mztools.com/articles/2014/MZ2014005.aspx
IEnumerable projectTools = vcProjectConfig.Tools as IEnumerable;
foreach (Object tool in projectTools)
{
string additionalIncludeDirs = compilerTool.FullIncludePath;
string preprocessorDefinition = compilerTool.PreprocessorDefinitions;
VCCLCompilerTool compilerTool = tool as VCCLCompilerTool;
string[] prepDefs = preprocessorDefinition.Split(';');
foreach (string prepDef in prepDefs)
if (compilerTool != null)
{
preprocessorDefinitions.Add(prepDef);
}
string additionalIncludeDirs = compilerTool.FullIncludePath;
string preprocessorDefinition = compilerTool.PreprocessorDefinitions;
string[] directories = additionalIncludeDirs.Split(';');
string[] prepDefs = preprocessorDefinition.Split(';');
foreach (string directory in directories)
{
if (directory.Length <= 0)
foreach (string prepDef in prepDefs)
{
continue;
preprocessorDefinitions.Add(prepDef);
}
string dir = directory;
string[] directories = additionalIncludeDirs.Split(';');
// In case of a project-relative path
if(directory.Length > 0 && directory.Substring(0, 1) == ".")
foreach (string directory in directories)
{
dir = project.ProjectDirectory + directory;
if (directory.Length <= 0)
{
continue;
}
string dir = directory;
// In case of a project-relative path
if (directory.Length > 0 && directory.Substring(0, 1) == ".")
{
dir = project.ProjectDirectory + directory;
}
// make it canonical
dir = new Uri(dir).LocalPath;
includeDirectories.Add(dir);
}
// make it canonical
dir = new Uri(dir).LocalPath;
includeDirectories.Add(directory);
break; // TODO: find some documentation on why the break is needed
// Apparently only the first 'tool' is needed, but why?
}
break; // TODO: find some documentation on why the break is needed
// Apparently only the first 'tool' is needed, but why?
}
}
catch(Exception e)
{
Logging.Logging.LogError("Failed to retreive include directories: " + e.Message);
return new Tuple<List<string>, List<string>>(new List<string>(), new List<string>());
}
try
{
VCPlatform platform = vcProjectConfig.Platform as VCPlatform;
@@ -217,6 +231,8 @@ namespace CoatiSoftware.CoatiPlugin.SolutionParser
static private VCConfiguration GetProjectConfiguration(VCProject project, string configurationName, string platformName)
{
Logging.Logging.LogInfo("Attempting to retreive project configuration");
if (project == null)
{
return null;
@@ -20,12 +20,17 @@ namespace CoatiSoftware.CoatiPlugin.Utility
Refresh();
}
public void Append(SolutionParser.CompilationDatabase cdb)
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()
@@ -71,7 +76,7 @@ namespace CoatiSoftware.CoatiPlugin.Utility
System.DateTime youngest = System.DateTime.MinValue;
foreach (SolutionParser.CompilationDatabase cdb in candidates)
{
if (cdb.LastUpdated > youngest)
if (cdb.LastUpdated >= youngest)
{
youngest = cdb.LastUpdated;
result = cdb;
@@ -192,7 +192,7 @@ namespace CoatiSoftware.CoatiPlugin.Wizard
{
string projectName = project.Name;
Logging.Logging.LogInfo("Scheduling " + projectName + " for parsing.");
Logging.Logging.LogInfo("Scheduling " + Logging.Obfuscation.NameObfuscator.GetObfuscatedName(projectName) + " for parsing.");
Task t = factory.StartNew(() =>
{
@@ -1,7 +1,7 @@
<?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">
<Metadata>
<Identity Id="acf15780-03b5-440e-a41e-db79b7043fc2" Version="0.9.1" Language="en-US" Publisher="Coati Software OG" />
<Identity Id="acf15780-03b5-440e-a41e-db79b7043fc2" Version="0.9.3" Language="en-US" Publisher="Coati Software OG" />
<DisplayName>CoatiPlugin</DisplayName>
<Description xml:space="preserve">This package allows Coati to communicate with Visual Studio and vice versa.</Description>
<MoreInfo>http://www.coati.io/</MoreInfo>