Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
diff --git a/cbinding/cbinding/cbinding/cmake/cmakeproject.cs b/caddin/cbinding/cbinding/cmake/cmakeproject.cs
index f9348da..65b9442 100644
--- a/cbinding/cbinding/cbinding/cmake/cmakeproject.cs
+++ b/caddin/cbinding/cbinding/cmake/cmakeproject.cs
@@ -1,4 +1,4 @@
-//
+//
// CMakeProject.cs
//
// Author:
@@ -43,12 +43,48 @@ namespace CBinding
string name;
FilePath outputDirectory = new FilePath ("./bin");
CMakeFileFormat fileFormat;
- GeneralOptionsPanel guiOptions = new GeneralOptionsPanel ();
+ CMakeToolchain cmakeToolchain;
+
+ /// <summary>
+ /// Occurs when a file is removed from this project.
+ /// </summary>
+ public event ProjectFileEventHandler FileRemovedFromProject;
+
+ /// <summary>
+ /// Occurs when a file is added to this project.
+ /// </summary>
+ public event ProjectFileEventHandler FileAddedToProject;
+
+ /// <summary>
+ /// Occurs when a file of this project has been modified
+ /// </summary>
+ public event ProjectFileEventHandler FileChangedInProject;
+
+ /// <summary>
+ /// Occurs when a file of this project has been renamed
+ /// </summary>
+ public event ProjectFileRenamedEventHandler FileRenamedInProject;
+
+
+ public bool HasLibClang { get; private set; }
+
+ public CLangManager ClangManager { get; private set; }
+
+ public SymbolDatabaseMediator DB { get; private set; }
+
+ public UnsavedFilesManager UnsavedFiles { get; private set; }
+
static readonly string [] supportedLanguages = { "C", "C++", "Objective-C", "Objective-C++" };
- Regex extensions = new Regex (@"(\.c|\.c\+\+|\.cc|\.cpp|\.cxx|\.m|\.mm|\.h|\.hh|\.h\+\+|\.hm|\.hpp|\.hxx|\.in|\.txx)$",
+ static Regex extensions = new Regex (@"(\.c|\.c\+\+|\.cc|\.cpp|\.cxx|\.m|\.mm|\.h|\.hh|\.h\+\+|\.hm|\.hpp|\.hxx|\.in|\.txx)$",
RegexOptions.IgnoreCase);
+ public static bool IsCFile (string file) {
+ if (extensions.IsMatch (file))
+ return true;
+ return false;
+ }
+
public override FilePath FileName {
get {
return file;
@@ -58,18 +94,6 @@ namespace CBinding
}
}
- Stream ExecuteCommand (string command, string args, string workingDir, ProgressMonitor monitor)
- {
- var stream = new MemoryStream ();
- var streamWriter = new StreamWriter (stream);
- FilePath path = file.ParentDirectory.Combine (workingDir);
- ProcessWrapper p = Runtime.ProcessService.StartProcess (command, args, path, monitor.Log, streamWriter, null);
- p.WaitForExit ();
- streamWriter.Flush ();
- stream.Position = 0;
- return stream;
- }
-
bool CheckCMake ()
{
try {
@@ -81,103 +105,6 @@ namespace CBinding
}
}
- Tuple<int, string> GetFileAndLine (string line, string separator)
- {
- int lineNumber = 0;
- string fileName = "";
- string s = line.Split (new string [] { separator }, StringSplitOptions.RemoveEmptyEntries) [1].Trim ();
- string [] args = s.Split (':');
- if (args [0].Length > 0) fileName = args [0];
- if (args.Length > 1 && args [1].Length > 0) {
- if (args [1].Contains ("("))
- int.TryParse (args [1].Split ('(') [0], out lineNumber);
- else
- int.TryParse (args [1], out lineNumber);
- }
-
- return Tuple.Create (lineNumber, fileName);
- }
-
- BuildResult ParseGenerationResult (Stream result, ProgressMonitor monitor)
- {
- var results = new BuildResult ();
- result.Position = 0;
- var sr = new StreamReader (result);
- var sb = new StringBuilder ();
- string line;
- string fileName = "";
- int lineNumber = 0;
- bool isWarning = false;
-
- while ((line = sr.ReadLine ()) != null) {
- //e.g. CMake Warning in/at CMakeLists.txt:10 (COMMAND):
- //or: CMake Warning:
- if (line.StartsWith ("CMake Warning", StringComparison.OrdinalIgnoreCase)) {
- //reset everything and add last error or warning.
- if (sb.Length > 0) {
- if (isWarning)
- results.AddWarning (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- else
- results.AddError (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- }
-
- sb.Clear ();
- fileName = "";
- lineNumber = 0;
- isWarning = true;
-
- // in/at CMakeLists.txt:10 (COMMAND):
- if (line.Contains (" in ")) {
- Tuple<int, string> t = GetFileAndLine (line, " in ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else if (line.Contains (" at ")) {
- Tuple<int, string> t = GetFileAndLine (line, " at ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else {
- string [] warning = line.Split (':');
- if (!string.IsNullOrEmpty (warning.ElementAtOrDefault (1))) {
- sb.Append (warning [1]);
- }
- }
- } else if (line.StartsWith ("CMake Error", StringComparison.OrdinalIgnoreCase)) {
- //reset everything and add last error or warning.
- if (sb.Length > 0) {
- if (isWarning)
- results.AddWarning (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- else
- results.AddError (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- }
-
- sb.Clear ();
- fileName = "";
- lineNumber = 0;
- isWarning = false;
-
- // in/at CMakeLists.txt:10 (COMMAND):
- if (line.Contains (" in ")) {
- Tuple<int, string> t = GetFileAndLine (line, " in ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else if (line.Contains (" at ")) {
- Tuple<int, string> t = GetFileAndLine (line, " at ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else {
- string [] error = line.Split (':');
- if (!string.IsNullOrEmpty (error.ElementAtOrDefault (1))) {
- sb.Append (error [1]);
- }
- }
- } else {
- sb.Append (line);
- }
- }
-
- return results;
- }
-
public void RemoveTarget (string targetName)
{
fileFormat.RemoveTarget (targetName);
@@ -193,6 +120,31 @@ namespace CBinding
return name;
}
+ public string MatchingFile (string sourceFile)
+ {
+ string filenameStub = Path.GetFileNameWithoutExtension (sourceFile);
+ bool wantHeader = !CMakeProject.IsHeaderFile (sourceFile);
+
+ foreach (FilePath file in OnGetItemFiles (false)) {
+ if (filenameStub == Path.GetFileNameWithoutExtension (file.FileName)
+ && (wantHeader == IsHeaderFile (file.FileName))) {
+ return file.FileName;
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Determines if a header file is specified by filename.
+ /// </summary>
+ /// <returns><c>true</c> if a header file is specified by filename; otherwise, <c>false</c>.</returns>
+ /// <param name="filename">Filename.</param>
+ public static bool IsHeaderFile (string filename)
+ {
+ return (0 <= Array.IndexOf (extensions.Split ("|").ToArray (), Path.GetExtension (filename.ToUpper ())));
+ }
+
public void LoadFrom (FilePath file)
{
this.file = file;
@@ -247,60 +199,32 @@ namespace CBinding
}
}
- protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration,
+ protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration,
OperationContext operationContext)
{
- return Task.Factory.StartNew (() => {
- BuildResult results;
+ BuildResult results;
- if (!CheckCMake ()) {
- results = new BuildResult ();
- results.AddError ("CMake cannot be found.");
- return results;
- }
+ if (!CheckCMake ()) {
+ results = new BuildResult ();
+ results.AddError ("CMake cannot be found.");
+ return results;
+ }
- FileService.CreateDirectory (file.ParentDirectory.Combine (outputDirectory));
+ FileService.CreateDirectory (file.ParentDirectory.Combine (outputDirectory));
- Stream generationResult;
- int buildFlag = 0;
- monitor.BeginStep ("Generating build files.");
- if (guiOptions.default_c_compiler.Name == "msvc") {
- generationResult = ExecuteCommand ("cmake", "../ -G \"Visual Studio 15 2017\"", outputDirectory, monitor);
- buildFlag = 1;
- } else {
- generationResult = ExecuteCommand ("cmake", "../ -G \"MinGW Makefiles\"", outputDirectory, monitor); //Default is gcc.
- }
- results = ParseGenerationResult (generationResult, monitor);
- monitor.EndStep ();
-
- string projectMsvc = string.Format ("{0}.{1}", fileFormat.ProjectName, "sln");
- monitor.BeginStep ("Building...");
- if (buildFlag == 1) {
- Stream buildResult = ExecuteCommand ("msbuild", projectMsvc, outputDirectory, monitor);
- buildFlag = 0;
- } else {
- Stream buildResult = ExecuteCommand ("mingw32-make", "", outputDirectory, monitor);
- }
- //TODO: Parse results.
- monitor.EndStep ();
+ cmakeToolchain = CMakeToolchain.GetToolchain ();
+ cmakeToolchain.setFileLocation (file);
+ results = await cmakeToolchain.GenerateMakefiles (fileFormat.ProjectName, outputDirectory, monitor);
+
+ return results;
- return results;
- });
}
- protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration,
- OperationContext buildSession)
+ protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration,
+ OperationContext buildSession)
{
- return Task.Factory.StartNew (() => {
- var results = new BuildResult ();
-
- FilePath path = BaseDirectory.Combine (outputDirectory);
- if (Directory.Exists (path)) {
- FileService.DeleteDirectory (path);
- }
-
- return results;
- });
+ BuildResult results = await cmakeToolchain.Clean (fileFormat.ProjectName, outputDirectory, monitor);
+ return results;
}
protected override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
@@ -367,6 +291,8 @@ namespace CBinding
{
base.OnFileRemoved (file);
+ FileRemovedFromProject?.Invoke (this, new ProjectFileEventArgs ());
+
foreach (var target in fileFormat.Targets.Values.ToList ()) {
target.RemoveFile (file);
}
@@ -389,6 +315,8 @@ namespace CBinding
{
base.OnFileRenamed (oldFile, newFile);
+ // FileRenamedInProject?.Invoke (this, new ProjectFileRenamedEventArgs ()); FIXME:- Need a fix
+
var oldFiles = new List<FilePath> () { oldFile };
var newFiles = new List<FilePath> () { newFile };
@@ -435,13 +363,25 @@ namespace CBinding
fileFormat.SaveAll ();
}
+ public override void OnFileChanged (FilePath file)
+ {
+ base.OnFileChanged (file);
+
+ if (!IsCFile (file))
+ return;
+
+ FileChangedInProject?.Invoke (this, new ProjectFileEventArgs ());
+ }
+
public override void OnFileAdded (FilePath file)
{
base.OnFileAdded (file);
- if (!extensions.IsMatch (file))
+ if (!IsCFile (file))
return;
+ FileAddedToProject?.Invoke (this, new ProjectFileEventArgs ());
+
using (var dlg = new TargetPickerDialog ("Pick a target", fileFormat)) {
if (MessageService.ShowCustomDialog (dlg) != (int)ResponseType.Ok)
return;
@@ -460,7 +400,7 @@ namespace CBinding
var filesToAdd = new List<FilePath> ();
foreach (var file in files) {
- if (extensions.IsMatch (file))
+ if (IsCFile (file))
filesToAdd.Add (file);
}
@@ -508,5 +448,22 @@ namespace CBinding
{
Initialize (this);
}
+
+ /// <summary>
+ /// Initialize this instance.
+ /// </summary>
+ protected override void OnInitialize ()
+ {
+ base.OnInitialize ();
+ try {
+ ClangManager = new CLangManager (this);
+ DB = new SymbolDatabaseMediator (this, ClangManager);
+ UnsavedFiles = new UnsavedFilesManager (this);
+ HasLibClang = true;
+ } catch (DllNotFoundException ex) {
+ LoggingService.LogError ("Could not load libclang", ex);
+ HasLibClang = false;
+ }
+ }
}
-}
+}
\ No newline at end of file
diff --git a/cbinding/cbinding/cbinding/cmake/cmakeproject.cs b/caddin/cbinding/cbinding/cmake/cmakeproject.cs
index f9348da..65b9442 100644
--- a/cbinding/cbinding/cbinding/cmake/cmakeproject.cs
+++ b/caddin/cbinding/cbinding/cmake/cmakeproject.cs
@@ -1,4 +1,4 @@
-//
+//
// CMakeProject.cs
//
// Author:
@@ -43,12 +43,48 @@ namespace CBinding
string name;
FilePath outputDirectory = new FilePath ("./bin");
CMakeFileFormat fileFormat;
- GeneralOptionsPanel guiOptions = new GeneralOptionsPanel ();
+ CMakeToolchain cmakeToolchain;
+
+ /// <summary>
+ /// Occurs when a file is removed from this project.
+ /// </summary>
+ public event ProjectFileEventHandler FileRemovedFromProject;
+
+ /// <summary>
+ /// Occurs when a file is added to this project.
+ /// </summary>
+ public event ProjectFileEventHandler FileAddedToProject;
+
+ /// <summary>
+ /// Occurs when a file of this project has been modified
+ /// </summary>
+ public event ProjectFileEventHandler FileChangedInProject;
+
+ /// <summary>
+ /// Occurs when a file of this project has been renamed
+ /// </summary>
+ public event ProjectFileRenamedEventHandler FileRenamedInProject;
+
+
+ public bool HasLibClang { get; private set; }
+
+ public CLangManager ClangManager { get; private set; }
+
+ public SymbolDatabaseMediator DB { get; private set; }
+
+ public UnsavedFilesManager UnsavedFiles { get; private set; }
+
static readonly string [] supportedLanguages = { "C", "C++", "Objective-C", "Objective-C++" };
- Regex extensions = new Regex (@"(\.c|\.c\+\+|\.cc|\.cpp|\.cxx|\.m|\.mm|\.h|\.hh|\.h\+\+|\.hm|\.hpp|\.hxx|\.in|\.txx)$",
+ static Regex extensions = new Regex (@"(\.c|\.c\+\+|\.cc|\.cpp|\.cxx|\.m|\.mm|\.h|\.hh|\.h\+\+|\.hm|\.hpp|\.hxx|\.in|\.txx)$",
RegexOptions.IgnoreCase);
+ public static bool IsCFile (string file) {
+ if (extensions.IsMatch (file))
+ return true;
+ return false;
+ }
+
public override FilePath FileName {
get {
return file;
@@ -58,18 +94,6 @@ namespace CBinding
}
}
- Stream ExecuteCommand (string command, string args, string workingDir, ProgressMonitor monitor)
- {
- var stream = new MemoryStream ();
- var streamWriter = new StreamWriter (stream);
- FilePath path = file.ParentDirectory.Combine (workingDir);
- ProcessWrapper p = Runtime.ProcessService.StartProcess (command, args, path, monitor.Log, streamWriter, null);
- p.WaitForExit ();
- streamWriter.Flush ();
- stream.Position = 0;
- return stream;
- }
-
bool CheckCMake ()
{
try {
@@ -81,103 +105,6 @@ namespace CBinding
}
}
- Tuple<int, string> GetFileAndLine (string line, string separator)
- {
- int lineNumber = 0;
- string fileName = "";
- string s = line.Split (new string [] { separator }, StringSplitOptions.RemoveEmptyEntries) [1].Trim ();
- string [] args = s.Split (':');
- if (args [0].Length > 0) fileName = args [0];
- if (args.Length > 1 && args [1].Length > 0) {
- if (args [1].Contains ("("))
- int.TryParse (args [1].Split ('(') [0], out lineNumber);
- else
- int.TryParse (args [1], out lineNumber);
- }
-
- return Tuple.Create (lineNumber, fileName);
- }
-
- BuildResult ParseGenerationResult (Stream result, ProgressMonitor monitor)
- {
- var results = new BuildResult ();
- result.Position = 0;
- var sr = new StreamReader (result);
- var sb = new StringBuilder ();
- string line;
- string fileName = "";
- int lineNumber = 0;
- bool isWarning = false;
-
- while ((line = sr.ReadLine ()) != null) {
- //e.g. CMake Warning in/at CMakeLists.txt:10 (COMMAND):
- //or: CMake Warning:
- if (line.StartsWith ("CMake Warning", StringComparison.OrdinalIgnoreCase)) {
- //reset everything and add last error or warning.
- if (sb.Length > 0) {
- if (isWarning)
- results.AddWarning (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- else
- results.AddError (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- }
-
- sb.Clear ();
- fileName = "";
- lineNumber = 0;
- isWarning = true;
-
- // in/at CMakeLists.txt:10 (COMMAND):
- if (line.Contains (" in ")) {
- Tuple<int, string> t = GetFileAndLine (line, " in ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else if (line.Contains (" at ")) {
- Tuple<int, string> t = GetFileAndLine (line, " at ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else {
- string [] warning = line.Split (':');
- if (!string.IsNullOrEmpty (warning.ElementAtOrDefault (1))) {
- sb.Append (warning [1]);
- }
- }
- } else if (line.StartsWith ("CMake Error", StringComparison.OrdinalIgnoreCase)) {
- //reset everything and add last error or warning.
- if (sb.Length > 0) {
- if (isWarning)
- results.AddWarning (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- else
- results.AddError (BaseDirectory.Combine (fileName), lineNumber, 0, "", sb.ToString ());
- }
-
- sb.Clear ();
- fileName = "";
- lineNumber = 0;
- isWarning = false;
-
- // in/at CMakeLists.txt:10 (COMMAND):
- if (line.Contains (" in ")) {
- Tuple<int, string> t = GetFileAndLine (line, " in ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else if (line.Contains (" at ")) {
- Tuple<int, string> t = GetFileAndLine (line, " at ");
- lineNumber = t.Item1;
- fileName = t.Item2;
- } else {
- string [] error = line.Split (':');
- if (!string.IsNullOrEmpty (error.ElementAtOrDefault (1))) {
- sb.Append (error [1]);
- }
- }
- } else {
- sb.Append (line);
- }
- }
-
- return results;
- }
-
public void RemoveTarget (string targetName)
{
fileFormat.RemoveTarget (targetName);
@@ -193,6 +120,31 @@ namespace CBinding
return name;
}
+ public string MatchingFile (string sourceFile)
+ {
+ string filenameStub = Path.GetFileNameWithoutExtension (sourceFile);
+ bool wantHeader = !CMakeProject.IsHeaderFile (sourceFile);
+
+ foreach (FilePath file in OnGetItemFiles (false)) {
+ if (filenameStub == Path.GetFileNameWithoutExtension (file.FileName)
+ && (wantHeader == IsHeaderFile (file.FileName))) {
+ return file.FileName;
+ }
+ }
+
+ return null;
+ }
+
+ /// <summary>
+ /// Determines if a header file is specified by filename.
+ /// </summary>
+ /// <returns><c>true</c> if a header file is specified by filename; otherwise, <c>false</c>.</returns>
+ /// <param name="filename">Filename.</param>
+ public static bool IsHeaderFile (string filename)
+ {
+ return (0 <= Array.IndexOf (extensions.Split ("|").ToArray (), Path.GetExtension (filename.ToUpper ())));
+ }
+
public void LoadFrom (FilePath file)
{
this.file = file;
@@ -247,60 +199,32 @@ namespace CBinding
}
}
- protected override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration,
+ protected async override Task<BuildResult> OnBuild (ProgressMonitor monitor, ConfigurationSelector configuration,
OperationContext operationContext)
{
- return Task.Factory.StartNew (() => {
- BuildResult results;
+ BuildResult results;
- if (!CheckCMake ()) {
- results = new BuildResult ();
- results.AddError ("CMake cannot be found.");
- return results;
- }
+ if (!CheckCMake ()) {
+ results = new BuildResult ();
+ results.AddError ("CMake cannot be found.");
+ return results;
+ }
- FileService.CreateDirectory (file.ParentDirectory.Combine (outputDirectory));
+ FileService.CreateDirectory (file.ParentDirectory.Combine (outputDirectory));
- Stream generationResult;
- int buildFlag = 0;
- monitor.BeginStep ("Generating build files.");
- if (guiOptions.default_c_compiler.Name == "msvc") {
- generationResult = ExecuteCommand ("cmake", "../ -G \"Visual Studio 15 2017\"", outputDirectory, monitor);
- buildFlag = 1;
- } else {
- generationResult = ExecuteCommand ("cmake", "../ -G \"MinGW Makefiles\"", outputDirectory, monitor); //Default is gcc.
- }
- results = ParseGenerationResult (generationResult, monitor);
- monitor.EndStep ();
-
- string projectMsvc = string.Format ("{0}.{1}", fileFormat.ProjectName, "sln");
- monitor.BeginStep ("Building...");
- if (buildFlag == 1) {
- Stream buildResult = ExecuteCommand ("msbuild", projectMsvc, outputDirectory, monitor);
- buildFlag = 0;
- } else {
- Stream buildResult = ExecuteCommand ("mingw32-make", "", outputDirectory, monitor);
- }
- //TODO: Parse results.
- monitor.EndStep ();
+ cmakeToolchain = CMakeToolchain.GetToolchain ();
+ cmakeToolchain.setFileLocation (file);
+ results = await cmakeToolchain.GenerateMakefiles (fileFormat.ProjectName, outputDirectory, monitor);
+
+ return results;
- return results;
- });
}
- protected override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration,
- OperationContext buildSession)
+ protected async override Task<BuildResult> OnClean (ProgressMonitor monitor, ConfigurationSelector configuration,
+ OperationContext buildSession)
{
- return Task.Factory.StartNew (() => {
- var results = new BuildResult ();
-
- FilePath path = BaseDirectory.Combine (outputDirectory);
- if (Directory.Exists (path)) {
- FileService.DeleteDirectory (path);
- }
-
- return results;
- });
+ BuildResult results = await cmakeToolchain.Clean (fileFormat.ProjectName, outputDirectory, monitor);
+ return results;
}
protected override Task OnExecute (ProgressMonitor monitor, ExecutionContext context, ConfigurationSelector configuration)
@@ -367,6 +291,8 @@ namespace CBinding
{
base.OnFileRemoved (file);
+ FileRemovedFromProject?.Invoke (this, new ProjectFileEventArgs ());
+
foreach (var target in fileFormat.Targets.Values.ToList ()) {
target.RemoveFile (file);
}
@@ -389,6 +315,8 @@ namespace CBinding
{
base.OnFileRenamed (oldFile, newFile);
+ // FileRenamedInProject?.Invoke (this, new ProjectFileRenamedEventArgs ()); FIXME:- Need a fix
+
var oldFiles = new List<FilePath> () { oldFile };
var newFiles = new List<FilePath> () { newFile };
@@ -435,13 +363,25 @@ namespace CBinding
fileFormat.SaveAll ();
}
+ public override void OnFileChanged (FilePath file)
+ {
+ base.OnFileChanged (file);
+
+ if (!IsCFile (file))
+ return;
+
+ FileChangedInProject?.Invoke (this, new ProjectFileEventArgs ());
+ }
+
public override void OnFileAdded (FilePath file)
{
base.OnFileAdded (file);
- if (!extensions.IsMatch (file))
+ if (!IsCFile (file))
return;
+ FileAddedToProject?.Invoke (this, new ProjectFileEventArgs ());
+
using (var dlg = new TargetPickerDialog ("Pick a target", fileFormat)) {
if (MessageService.ShowCustomDialog (dlg) != (int)ResponseType.Ok)
return;
@@ -460,7 +400,7 @@ namespace CBinding
var filesToAdd = new List<FilePath> ();
foreach (var file in files) {
- if (extensions.IsMatch (file))
+ if (IsCFile (file))
filesToAdd.Add (file);
}
@@ -508,5 +448,22 @@ namespace CBinding
{
Initialize (this);
}
+
+ /// <summary>
+ /// Initialize this instance.
+ /// </summary>
+ protected override void OnInitialize ()
+ {
+ base.OnInitialize ();
+ try {
+ ClangManager = new CLangManager (this);
+ DB = new SymbolDatabaseMediator (this, ClangManager);
+ UnsavedFiles = new UnsavedFilesManager (this);
+ HasLibClang = true;
+ } catch (DllNotFoundException ex) {
+ LoggingService.LogError ("Could not load libclang", ex);
+ HasLibClang = false;
+ }
+ }
}
-}
+}
\ No newline at end of file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment